# HG changeset patch # User Frank Benoit # Date 1201978600 -3600 # Node ID e28b4e239c0a60d5fd602f2875e01a82ad8e01bd # Parent f4a025bb42e953379dee39d55e215dbe1b75458f CoolItem diff -r f4a025bb42e9 -r e28b4e239c0a dwt/widgets/CoolItem.d --- a/dwt/widgets/CoolItem.d Sat Feb 02 18:33:51 2008 +0100 +++ b/dwt/widgets/CoolItem.d Sat Feb 02 19:56:40 2008 +0100 @@ -12,58 +12,21 @@ *******************************************************************************/ module dwt.widgets.CoolItem; -import dwt.widgets.Item; import dwt.widgets.Widget; - -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.widgets.TypedListener; + import dwt.DWT; import dwt.DWTException; import dwt.events.SelectionEvent; import dwt.events.SelectionListener; import dwt.graphics.Point; import dwt.graphics.Rectangle; -import dwt.internal.win32.MARGINS; import dwt.internal.win32.OS; -import dwt.internal.win32.REBARBANDINFO; -import dwt.internal.win32.RECT; + +import dwt.dwthelper.utils; /** * Instances of this class are selectable user interface @@ -80,7 +43,7 @@ *

*/ -public class CoolItem extends Item { +public class CoolItem : Item { CoolBar parent; Control control; int id; @@ -116,7 +79,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public CoolItem (CoolBar parent, int style) { +public this (CoolBar parent, int style) { super (parent, style); this.parent = parent; parent.createItem (this, parent.getItemCount ()); @@ -154,7 +117,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public CoolItem (CoolBar parent, int style, int index) { +public this (CoolBar parent, int style, int index) { super (parent, style); this.parent = parent; parent.createItem (this, index); @@ -264,12 +227,12 @@ checkWidget (); int index = parent.indexOf (this); if (index is -1) return new Rectangle (0, 0, 0, 0); - int hwnd = parent.handle; - RECT rect = new RECT (); - OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect); + auto hwnd = parent.handle; + RECT rect; + OS.SendMessage (hwnd, OS.RB_GETRECT, index, &rect); if (OS.COMCTL32_MAJOR >= 6) { - MARGINS margins = new MARGINS (); - OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins); + MARGINS margins; + OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, &margins); rect.left -= margins.cxLeftWidth; rect.right += margins.cxRightWidth; } @@ -288,11 +251,11 @@ checkWidget (); int index = parent.indexOf (this); if (index is -1) return new Rectangle (0, 0, 0, 0); - int hwnd = parent.handle; - RECT insetRect = new RECT (); - OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, insetRect); - RECT rect = new RECT (); - OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect); + auto hwnd = parent.handle; + RECT insetRect; + OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, &insetRect); + RECT rect; + OS.SendMessage (hwnd, OS.RB_GETRECT, index, &rect); int x = rect.left + insetRect.left; int y = rect.top; int width = rect.right - rect.left - insetRect.left; @@ -303,10 +266,10 @@ height -= insetRect.top + insetRect.bottom; } if (index is 0) { - REBARBANDINFO rbBand = new REBARBANDINFO (); + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; rbBand.fMask = OS.RBBIM_HEADERSIZE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); width = width - rbBand.cxHeader + 1; } return new Rectangle (x, y, Math.max (0, width), Math.max (0, height)); @@ -376,9 +339,9 @@ this.control = null; } Control oldControl = this.control, newControl = control; - int hwnd = parent.handle; - int hwndChild = newControl !is null ? control.topHandle () : 0; - REBARBANDINFO rbBand = new REBARBANDINFO (); + auto hwnd = parent.handle; + auto hwndChild = newControl !is null ? control.topHandle () : null; + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; rbBand.fMask = OS.RBBIM_CHILD; rbBand.hwndChild = hwndChild; @@ -390,16 +353,16 @@ * moves the new child to the top of the Z-order. The fix is * to save and restore the visibility and Z-order. */ - int hwndAbove = 0; + HWND hwndAbove; if (newControl !is null) { hwndAbove = OS.GetWindow (hwndChild, OS.GW_HWNDPREV); } bool hideNew = newControl !is null && !newControl.getVisible (); bool showOld = oldControl !is null && oldControl.getVisible (); - OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, &rbBand); if (hideNew) newControl.setVisible (false); if (showOld) oldControl.setVisible (true); - if (hwndAbove !is 0 && hwndAbove !is hwndChild) { + if (hwndAbove !is null && hwndAbove !is hwndChild) { int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; SetWindowPos (hwndChild, hwndAbove, 0, 0, 0, 0, flags); } @@ -421,11 +384,11 @@ checkWidget (); int index = parent.indexOf (this); if (index is -1) return new Point (0, 0); - int hwnd = parent.handle; - REBARBANDINFO rbBand = new REBARBANDINFO (); + auto hwnd = parent.handle; + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); int width = rbBand.cxIdeal + parent.getMargin (index); if ((parent.style & DWT.VERTICAL) !is 0) { return new Point (rbBand.cyMaxChild, width); @@ -451,7 +414,7 @@ width = Math.max (0, width); height = Math.max (0, height); ideal = true; - int hwnd = parent.handle; + auto hwnd = parent.handle; int cxIdeal, cyMaxChild; if ((parent.style & DWT.VERTICAL) !is 0) { cxIdeal = Math.max (0, height - parent.getMargin (index)); @@ -460,19 +423,19 @@ cxIdeal = Math.max (0, width - parent.getMargin (index)); cyMaxChild = height; } - REBARBANDINFO rbBand = new REBARBANDINFO (); + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; /* Get the child size fields first so we don't overwrite them. */ rbBand.fMask = OS.RBBIM_CHILDSIZE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); /* Set the size fields we are currently modifying. */ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE; rbBand.cxIdeal = cxIdeal; rbBand.cyMaxChild = cyMaxChild; if (!minimum) rbBand.cyMinChild = cyMaxChild; - OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, &rbBand); } /** @@ -511,12 +474,12 @@ checkWidget (); int index = parent.indexOf (this); if (index is -1) new Point (0, 0); - int hwnd = parent.handle; - RECT rect = new RECT (); - OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect); + auto hwnd = parent.handle; + RECT rect; + OS.SendMessage (hwnd, OS.RB_GETRECT, index, &rect); if (OS.COMCTL32_MAJOR >= 6) { - MARGINS margins = new MARGINS (); - OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins); + MARGINS margins; + OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, &margins); rect.left -= margins.cxLeftWidth; rect.right += margins.cxRightWidth; } @@ -553,7 +516,7 @@ if (index is -1) return; width = Math.max (0, width); height = Math.max (0, height); - int hwnd = parent.handle; + auto hwnd = parent.handle; int cx, cyChild, cxIdeal; if ((parent.style & DWT.VERTICAL) !is 0) { cx = height; @@ -564,12 +527,12 @@ cyChild = height; cxIdeal = Math.max (0, width - parent.getMargin (index)); } - REBARBANDINFO rbBand = new REBARBANDINFO (); + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; /* Get the child size fields first so we don't overwrite them. */ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); /* Set the size fields we are currently modifying. */ if (!ideal) rbBand.cxIdeal = cxIdeal; @@ -581,15 +544,15 @@ */ if (!parent.isLastItemOfRow (index)) { if (OS.COMCTL32_MAJOR >= 6) { - MARGINS margins = new MARGINS (); - OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins); + MARGINS margins; + OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, &margins); cx -= margins.cxLeftWidth + margins.cxRightWidth; } int separator = (parent.style & DWT.FLAT) is 0 ? CoolBar.SEPARATOR_WIDTH : 0; rbBand.cx = cx - separator; rbBand.fMask |= OS.RBBIM_SIZE; } - OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, &rbBand); } /** @@ -632,11 +595,11 @@ checkWidget (); int index = parent.indexOf (this); if (index is -1) return new Point (0, 0); - int hwnd = parent.handle; - REBARBANDINFO rbBand = new REBARBANDINFO (); + auto hwnd = parent.handle; + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; rbBand.fMask = OS.RBBIM_CHILDSIZE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); if ((parent.style & DWT.VERTICAL) !is 0) { return new Point (rbBand.cyMinChild, rbBand.cxMinChild); } @@ -664,7 +627,7 @@ width = Math.max (0, width); height = Math.max (0, height); minimum = true; - int hwnd = parent.handle; + auto hwnd = parent.handle; int cxMinChild, cyMinChild; if ((parent.style & DWT.VERTICAL) !is 0) { cxMinChild = height; @@ -673,17 +636,17 @@ cxMinChild = width; cyMinChild = height; } - REBARBANDINFO rbBand = new REBARBANDINFO (); + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; /* Get the child size fields first so we don't overwrite them. */ rbBand.fMask = OS.RBBIM_CHILDSIZE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); /* Set the size fields we are currently modifying. */ rbBand.cxMinChild = cxMinChild; rbBand.cyMinChild = cyMinChild; - OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, &rbBand); } /** @@ -710,27 +673,27 @@ bool getWrap() { int index = parent.indexOf (this); - int hwnd = parent.handle; - REBARBANDINFO rbBand = new REBARBANDINFO (); + auto hwnd = parent.handle; + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; rbBand.fMask = OS.RBBIM_STYLE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); return (rbBand.fStyle & OS.RBBS_BREAK) !is 0; } void setWrap(bool wrap) { int index = parent.indexOf (this); - int hwnd = parent.handle; - REBARBANDINFO rbBand = new REBARBANDINFO (); + auto hwnd = parent.handle; + REBARBANDINFO rbBand; rbBand.cbSize = REBARBANDINFO.sizeof; rbBand.fMask = OS.RBBIM_STYLE; - OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, &rbBand); if (wrap) { rbBand.fStyle |= OS.RBBS_BREAK; } else { rbBand.fStyle &= ~OS.RBBS_BREAK; } - OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand); + OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, &rbBand); } /** @@ -761,4 +724,3 @@ } } -++/ \ No newline at end of file