# HG changeset patch
# User Frank Benoit
# Date 1201973631 -3600
# Node ID f4a025bb42e953379dee39d55e215dbe1b75458f
# Parent c913756e6950cc05ce67a361f4b5c87efd814c9f
CoolBar
diff -r c913756e6950 -r f4a025bb42e9 dwt/internal/win32/OS.d
--- a/dwt/internal/win32/OS.d Sat Feb 02 01:51:46 2008 +0100
+++ b/dwt/internal/win32/OS.d Sat Feb 02 18:33:51 2008 +0100
@@ -1404,7 +1404,7 @@
public static const int RDW_INVALIDATE = 0x1;
public static const int RDW_UPDATENOW = 0x100;
public static const int READ_CONTROL = 0x20000;
- public static const char[] REBARCLASSNAME = "ReBarWindow32"; //$NON-NLS-1$
+ public static const TCHAR[] REBARCLASSNAME = "ReBarWindow32"; //$NON-NLS-1$
public static const int RGN_AND = 0x1;
public static const int RGN_COPY = 5;
public static const int RGN_DIFF = 0x4;
diff -r c913756e6950 -r f4a025bb42e9 dwt/internal/win32/WINTYPES.d
--- a/dwt/internal/win32/WINTYPES.d Sat Feb 02 01:51:46 2008 +0100
+++ b/dwt/internal/win32/WINTYPES.d Sat Feb 02 18:33:51 2008 +0100
@@ -36,6 +36,13 @@
alias HANDLE HTHEME;
+struct NMREBARCHILDSIZE {
+ NMHDR hdr;
+ UINT uBand;
+ UINT wID;
+ RECT rcChild;
+ RECT rcBand;
+}
// ....
//--------------------------------------------------------------------------------
diff -r c913756e6950 -r f4a025bb42e9 dwt/widgets/CoolBar.d
--- a/dwt/widgets/CoolBar.d Sat Feb 02 01:51:46 2008 +0100
+++ b/dwt/widgets/CoolBar.d Sat Feb 02 18:33:51 2008 +0100
@@ -14,26 +14,19 @@
import dwt.widgets.Composite;
-class CoolBar : Composite {
-}
-/++
+
import dwt.DWT;
import dwt.DWTException;
import dwt.graphics.Point;
import dwt.graphics.Rectangle;
-import dwt.internal.win32.INITCOMMONCONTROLSEX;
-import dwt.internal.win32.LRESULT;
-import dwt.internal.win32.MARGINS;
-import dwt.internal.win32.NMCUSTOMDRAW;
-import dwt.internal.win32.NMHDR;
-import dwt.internal.win32.NMREBARCHEVRON;
-import dwt.internal.win32.NMREBARCHILDSIZE;
import dwt.internal.win32.OS;
-import dwt.internal.win32.POINT;
-import dwt.internal.win32.REBARBANDINFO;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.WNDCLASS;
+
+import dwt.widgets.Composite;
+import dwt.widgets.Control;
+import dwt.widgets.CoolItem;
+import dwt.widgets.Event;
+
+import dwt.dwthelper.utils;
/**
* Instances of this class provide an area for dynamically
@@ -59,26 +52,27 @@
*
*/
-public class CoolBar extends Composite {
+public class CoolBar : Composite {
+
CoolItem [] items;
CoolItem [] originalItems;
bool locked;
bool ignoreResize;
- static final int ReBarProc;
- static final TCHAR ReBarClass = new TCHAR (0, OS.REBARCLASSNAME, true);
- static {
- INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
+ static const WNDPROC ReBarProc;
+ static const TCHAR* ReBarClass = OS.REBARCLASSNAME.ptr;
+ static this() {
+ INITCOMMONCONTROLSEX icex;
icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
icex.dwICC = OS.ICC_COOL_CLASSES;
- OS.InitCommonControlsEx (icex);
- WNDCLASS lpWndClass = new WNDCLASS ();
- OS.GetClassInfo (0, ReBarClass, lpWndClass);
+ OS.InitCommonControlsEx (&icex);
+ WNDCLASS lpWndClass;
+ OS.GetClassInfo (null, ReBarClass, &lpWndClass);
ReBarProc = lpWndClass.lpfnWndProc;
}
- static final int SEPARATOR_WIDTH = 2;
- static final int MAX_WIDTH = 0x7FFF;
- static final int DEFAULT_COOLBAR_WIDTH = 0;
- static final int DEFAULT_COOLBAR_HEIGHT = 0;
+ static const int SEPARATOR_WIDTH = 2;
+ static const int MAX_WIDTH = 0x7FFF;
+ static const int DEFAULT_COOLBAR_WIDTH = 0;
+ static const int DEFAULT_COOLBAR_HEIGHT = 0;
/**
* Constructs a new instance of this class given its parent
@@ -108,7 +102,7 @@
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public CoolBar (Composite parent, int style) {
+public this (Composite parent, int style) {
super (parent, checkStyle (style));
/*
* Ensure that either of HORIZONTAL or VERTICAL is set.
@@ -130,9 +124,9 @@
}
}
-int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
- if (handle is 0) return 0;
- return OS.CallWindowProc (ReBarProc, hwnd, msg, wParam, lParam);
+LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
+ if (handle is null) return LRESULT.NULL;
+ return cast(LRESULT) OS.CallWindowProc (ReBarProc, hwnd, msg, wParam, lParam);
}
static int checkStyle (int style) {
@@ -174,22 +168,22 @@
}
}
}
- RECT oldRect = new RECT ();
- OS.GetWindowRect (handle, oldRect);
+ RECT oldRect;
+ OS.GetWindowRect (handle, &oldRect);
int oldWidth = oldRect.right - oldRect.left;
int oldHeight = oldRect.bottom - oldRect.top;
int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
- SetWindowPos (handle, 0, 0, 0, newWidth, newHeight, flags);
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.RB_GETRECT, count - 1, rect);
+ SetWindowPos (handle, null, 0, 0, newWidth, newHeight, flags);
+ RECT rect;
+ OS.SendMessage (handle, OS.RB_GETRECT, count - 1, &rect);
height = Math.max (height, rect.bottom);
- SetWindowPos (handle, 0, 0, 0, oldWidth, oldHeight, flags);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
+ SetWindowPos (handle, null, 0, 0, oldWidth, oldHeight, flags);
+ REBARBANDINFO rbBand;
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_IDEALSIZE | OS.RBBIM_STYLE;
int rowWidth = 0;
for (int i = 0; i < count; i++) {
- OS.SendMessage(handle, OS.RB_GETBANDINFO, i, rbBand);
+ OS.SendMessage(handle, OS.RB_GETBANDINFO, i, &rbBand);
if ((rbBand.fStyle & OS.RBBS_BREAK) !is 0) {
width = Math.max(width, rowWidth);
rowWidth = 0;
@@ -236,7 +230,7 @@
* The control will not destroy a font that it did not
* create.
*/
- int hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ auto hFont = OS.GetStockObject (OS.SYSTEM_FONT);
OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
}
@@ -250,9 +244,9 @@
System.arraycopy (items, 0, newItems, 0, items.length);
items = newItems;
}
- int hHeap = OS.GetProcessHeap ();
- int lpText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
+ auto hHeap = OS.GetProcessHeap ();
+ auto lpText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof);
+ REBARBANDINFO rbBand;
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_TEXT | OS.RBBIM_STYLE | OS.RBBIM_ID;
rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS;
@@ -289,7 +283,7 @@
}
/* Insert the item */
- if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) is 0) {
+ if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, &rbBand) is 0) {
error (DWT.ERROR_ITEM_NOT_ADDED);
}
@@ -380,7 +374,7 @@
originalItems = newOriginals;
}
-void drawThemeBackground (int hDC, int hwnd, RECT rect) {
+void drawThemeBackground (HDC hDC, HWND hwnd, RECT* rect) {
if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
if (background is -1 && (style & DWT.FLAT) !is 0) {
Control control = findBackgroundControl ();
@@ -390,11 +384,11 @@
}
}
}
- RECT rect2 = new RECT ();
- OS.GetClientRect (handle, rect2);
- OS.MapWindowPoints (handle, hwnd, rect2, 2);
- POINT lpPoint = new POINT ();
- OS.SetWindowOrgEx (hDC, -rect2.left, -rect2.top, lpPoint);
+ RECT rect2;
+ OS.GetClientRect (handle, &rect2);
+ OS.MapWindowPoints (handle, hwnd, cast(POINT*) &rect2, 2);
+ POINT lpPoint;
+ OS.SetWindowOrgEx (hDC, -rect2.left, -rect2.top, &lpPoint);
OS.SendMessage (handle, OS.WM_PRINT, hDC, OS.PRF_CLIENT | OS.PRF_ERASEBKGND);
OS.SetWindowOrgEx (hDC, lpPoint.x, lpPoint.y, null);
}
@@ -407,12 +401,12 @@
int getMargin (int index) {
int margin = 0;
if (OS.COMCTL32_MAJOR >= 6) {
- MARGINS margins = new MARGINS ();
- OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, margins);
+ MARGINS margins;
+ OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, &margins);
margin += margins.cxLeftWidth + margins.cxRightWidth;
}
- RECT rect = new RECT ();
- OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, rect);
+ RECT rect;
+ OS.SendMessage (handle, OS.RB_GETBANDBORDERS, index, &rect);
if ((style & DWT.FLAT) !is 0) {
/*
* Bug in Windows. When the style bit RBS_BANDBORDERS is not set
@@ -459,10 +453,10 @@
checkWidget ();
int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (!(0 <= index && index < count)) error (DWT.ERROR_INVALID_RANGE);
- REBARBANDINFO rbBand = new REBARBANDINFO ();
+ REBARBANDINFO rbBand;
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_ID;
- OS.SendMessage (handle, OS.RB_GETBANDINFO, index, rbBand);
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, index, &rbBand);
return items [rbBand.wID];
}
@@ -506,11 +500,11 @@
checkWidget ();
int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
int [] indices = new int [count];
- REBARBANDINFO rbBand = new REBARBANDINFO ();
+ REBARBANDINFO rbBand;
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_ID;
for (int i=0; i= 6) {
- OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, margins);
+ OS.SendMessage (handle, OS.RB_GETBANDMARGINS, 0, &margins);
rect.left -= margins.cxLeftWidth;
rect.right += margins.cxRightWidth;
}
@@ -596,11 +590,11 @@
int getLastIndexOfRow (int index) {
int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
if (count is 0) return -1;
- REBARBANDINFO rbBand = new REBARBANDINFO ();
+ REBARBANDINFO rbBand;
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_STYLE;
for (int i=index + 1; i= 6 && OS.IsAppThemed ()) {
@@ -1115,14 +1109,14 @@
return super.WM_SIZE (wParam, lParam);
}
-LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) {
+LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) {
switch (hdr.code) {
case OS.RBN_BEGINDRAG: {
int pos = OS.GetMessagePos ();
- POINT pt = new POINT ();
- pt.x = (short) (pos & 0xFFFF);
- pt.y = (short) (pos >> 16);
- OS.ScreenToClient (handle, pt);
+ POINT pt;
+ pt.x = cast(short) (pos & 0xFFFF);
+ pt.y = cast(short) (pos >> 16);
+ OS.ScreenToClient (handle, &pt);
int button = display.lastButton !is 0 ? display.lastButton : 1;
if (!sendDragEvent (button, pt.x, pt.y)) return LRESULT.ONE;
break;
@@ -1137,15 +1131,15 @@
* nothing. If the control is a combo, the drop down portion is
* recalculated.
*/
- NMREBARCHILDSIZE lprbcs = new NMREBARCHILDSIZE ();
- OS.MoveMemory (lprbcs, lParam, NMREBARCHILDSIZE.sizeof);
+ NMREBARCHILDSIZE* lprbcs = cast(NMREBARCHILDSIZE*)lParam;
+ //OS.MoveMemory (lprbcs, lParam, NMREBARCHILDSIZE.sizeof);
if (lprbcs.uBand !is -1) {
CoolItem item = items [lprbcs.wID];
Control control = item.control;
if (control !is null) {
- int width = lprbcs.rcChild_right - lprbcs.rcChild_left;
- int height = lprbcs.rcChild_bottom - lprbcs.rcChild_top;
- control.setBounds (lprbcs.rcChild_left, lprbcs.rcChild_top, width, height);
+ int width = lprbcs.rcChild.right - lprbcs.rcChild.left;
+ int height = lprbcs.rcChild.bottom - lprbcs.rcChild.top;
+ control.setBounds (lprbcs.rcChild.left, lprbcs.rcChild.top, width, height);
}
}
break;
@@ -1164,18 +1158,18 @@
break;
}
case OS.RBN_CHEVRONPUSHED: {
- NMREBARCHEVRON lpnm = new NMREBARCHEVRON ();
- OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof);
+ NMREBARCHEVRON* lpnm = cast(NMREBARCHEVRON*)lParam;
+ //OS.MoveMemory (lpnm, lParam, NMREBARCHEVRON.sizeof);
CoolItem item = items [lpnm.wID];
if (item !is null) {
Event event = new Event();
event.detail = DWT.ARROW;
if ((style & DWT.VERTICAL) !is 0) {
- event.x = lpnm.right;
- event.y = lpnm.top;
+ event.x = lpnm.rc.right;
+ event.y = lpnm.rc.top;
} else {
- event.x = lpnm.left;
- event.y = lpnm.bottom;
+ event.x = lpnm.rc.left;
+ event.y = lpnm.rc.bottom;
}
item.postEvent (DWT.Selection, event);
}
@@ -1190,11 +1184,11 @@
*/
if (OS.COMCTL32_MAJOR < 6) break;
if (findBackgroundControl () !is null || (style & DWT.FLAT) !is 0) {
- NMCUSTOMDRAW nmcd = new NMCUSTOMDRAW ();
- OS.MoveMemory (nmcd, lParam, NMCUSTOMDRAW.sizeof);
+ NMCUSTOMDRAW* nmcd = cast(NMCUSTOMDRAW*)lParam;
+ //OS.MoveMemory (nmcd, lParam, NMCUSTOMDRAW.sizeof);
switch (nmcd.dwDrawStage) {
case OS.CDDS_PREERASE:
- return new LRESULT (OS.CDRF_SKIPDEFAULT | OS.CDRF_NOTIFYPOSTERASE);
+ return cast(LRESULT) (OS.CDRF_SKIPDEFAULT | OS.CDRF_NOTIFYPOSTERASE);
case OS.CDDS_POSTERASE:
drawBackground (nmcd.hdc);
break;
@@ -1206,4 +1200,3 @@
return super.wmNotifyChild (hdr, wParam, lParam);
}
}
-++/
\ No newline at end of file
diff -r c913756e6950 -r f4a025bb42e9 dwt/widgets/CoolItem.d
--- a/dwt/widgets/CoolItem.d Sat Feb 02 01:51:46 2008 +0100
+++ b/dwt/widgets/CoolItem.d Sat Feb 02 18:33:51 2008 +0100
@@ -15,10 +15,43 @@
import dwt.widgets.Item;
import dwt.widgets.Widget;
-class CoolItem : Item {
+import dwt.events.SelectionListener;
+import dwt.graphics.Point;
+import dwt.graphics.Rectangle;
+import dwt.widgets.Control;
+import dwt.widgets.CoolBar;
+import dwt.widgets.Item;
+class CoolItem : Item {
public this (Widget parent, int style) {
super (parent, style);
}
+ Rectangle getClientArea();
+ override void checkSubclass();
+ Point computeSize(int, int);
+ override void destroyWidget();
+ override void releaseHandle();
+ void setControl(Control);
+ bool getWrap();
+ void setWrap(bool);
+ CoolBar getParent();
+ Point getSize();
+ void setSize(int, int);
+ void setSize(Point);
+ Rectangle getBounds();
+ Point getMinimumSize();
+ Point getPreferredSize();
+ void setMinimumSize(int, int);
+ void setMinimumSize(Point);
+ void setPreferredSize(int, int);
+ void setPreferredSize(Point);
+ Control getControl();
+ void addSelectionListener(SelectionListener);
+ void removeSelectionListener(SelectionListener);
+ CoolBar parent;
+ Control control;
+ int id;
+ bool ideal;
+ bool minimum;
}
/++
import dwt.DWT;
diff -r c913756e6950 -r f4a025bb42e9 dwt/widgets/ExpandItem.d
--- a/dwt/widgets/ExpandItem.d Sat Feb 02 01:51:46 2008 +0100
+++ b/dwt/widgets/ExpandItem.d Sat Feb 02 18:33:51 2008 +0100
@@ -15,11 +15,49 @@
import dwt.widgets.Item;
import dwt.widgets.Widget;
-class ExpandItem : Item {
+import dwt.graphics.GC;
+import dwt.graphics.Image;
+import dwt.internal.win32.OS;
+import dwt.widgets.Control;
+import dwt.widgets.ExpandBar;
+import dwt.widgets.Item;
+class ExpandItem : Item {
public this (Widget parent, int style) {
super (parent, style);
}
+ void redraw(bool);
+ override void releaseWidget();
+ override void destroyWidget();
+ override void releaseHandle();
+ bool getExpanded();
+ void setControl(Control);
+ void drawItem(GC, int, RECT, bool);
+ bool isHover(int, int);
+ void setExpanded(bool);
+ ExpandBar getParent();
+ void setBounds(int, int, int, int, bool, bool);
+ int getHeight();
+ override void setText(char[]);
+ Control getControl();
+ void setHeight(int);
+ override void setImage(Image);
+ int getPreferredWidth(int, int);
+ int getHeaderHeight();
+ ExpandBar parent;
+ Control control;
+ bool expanded;
+ bool hover;
+ int x;
+ int y;
+ int width;
+ int height;
+ int imageHeight;
+ int imageWidth;
+ static int TEXT_INSET;
+ static int BORDER;
+ static int CHEVRON_SIZE;
}
+
/++
import dwt.DWT;
import dwt.DWTException;