# HG changeset patch # User Frank Benoit # Date 1202138814 -3600 # Node ID 774d936d13808169bff8e816a05c6e4ae4a7da77 # Parent 66203354c9d355eaa2b7543bb0907b4ba02450f1 TabFolder, TabItem diff -r 66203354c9d3 -r 774d936d1380 dwt/widgets/Spinner.d --- a/dwt/widgets/Spinner.d Mon Feb 04 15:39:21 2008 +0100 +++ b/dwt/widgets/Spinner.d Mon Feb 04 16:26:54 2008 +0100 @@ -1047,7 +1047,7 @@ char[] decimalSeparator = getDecimalSeparator (); index = string.indexOf (decimalSeparator); if (index !is -1) { - string = string[0 .. index] ~ string[ index + 1 .. $ ]; + string = string.substring (0, index) ~ string.substring (index + 1); } index = 0; } diff -r 66203354c9d3 -r 774d936d1380 dwt/widgets/TabFolder.d --- a/dwt/widgets/TabFolder.d Mon Feb 04 15:39:21 2008 +0100 +++ b/dwt/widgets/TabFolder.d Mon Feb 04 16:26:54 2008 +0100 @@ -10,10 +10,7 @@ *******************************************************************************/ module dwt.widgets.TabFolder; -import dwt.widgets.Composite; -class TabFolder : Composite { -} -/++ + import dwt.DWT; import dwt.DWTException; import dwt.events.SelectionEvent; @@ -23,16 +20,15 @@ import dwt.graphics.Point; import dwt.graphics.Rectangle; import dwt.internal.ImageList; -import dwt.internal.win32.LRESULT; -import dwt.internal.win32.NMHDR; -import dwt.internal.win32.NMTTDISPINFO; import dwt.internal.win32.OS; -import dwt.internal.win32.RECT; -import dwt.internal.win32.TCHAR; -import dwt.internal.win32.TCITEM; -import dwt.internal.win32.TOOLINFO; -import dwt.internal.win32.WINDOWPOS; -import dwt.internal.win32.WNDCLASS; + +import dwt.widgets.Composite; +import dwt.widgets.TabItem; +import dwt.widgets.TypedListener; +import dwt.widgets.Event; +import dwt.widgets.Control; + +import dwt.dwthelper.utils; /** * Instances of this class implement the notebook user interface @@ -59,26 +55,26 @@ * IMPORTANT: This class is not intended to be subclassed. *

*/ -public class TabFolder extends Composite { +public class TabFolder : Composite { alias Composite.computeSize computeSize; alias Composite.windowProc windowProc; TabItem [] items; ImageList imageList; - static final int TabFolderProc; - static final TCHAR TabFolderClass = new TCHAR (0, OS.WC_TABCONTROL, true); + static const WNDPROC TabFolderProc; + static const TCHAR[] TabFolderClass = OS.WC_TABCONTROL; /* * These are the undocumented control id's for the children of * a tab control. Since there are no constants for these values, * they may change with different versions of Windows. */ - static final int ID_UPDOWN = 1; + static const int ID_UPDOWN = 1; - static { - WNDCLASS lpWndClass = new WNDCLASS (); - OS.GetClassInfo (0, TabFolderClass, lpWndClass); + static this() { + WNDCLASS lpWndClass; + OS.GetClassInfo (null, TabFolderClass.ptr, &lpWndClass); TabFolderProc = lpWndClass.lpfnWndProc; /* * Feature in Windows. The tab control window class @@ -99,15 +95,15 @@ * code, other than DWT, could create a control with * this class name, and fail unexpectedly. */ - int hInstance = OS.GetModuleHandle (null); - int hHeap = OS.GetProcessHeap (); + auto hInstance = OS.GetModuleHandle (null); + auto hHeap = OS.GetProcessHeap (); lpWndClass.hInstance = hInstance; lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW | OS.CS_GLOBALCLASS); - int byteCount = TabFolderClass.length () * TCHAR.sizeof; - int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); - OS.MoveMemory (lpszClassName, TabFolderClass, byteCount); + int byteCount = (TabFolderClass.length+1) * TCHAR.sizeof; + auto lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); + OS.MoveMemory (lpszClassName, TabFolderClass.ptr, byteCount); lpWndClass.lpszClassName = lpszClassName; - OS.RegisterClass (lpWndClass); + OS.RegisterClass (&lpWndClass); OS.HeapFree (hHeap, 0, lpszClassName); } @@ -139,7 +135,7 @@ * @see Widget#checkSubclass * @see Widget#getStyle */ -public TabFolder (Composite parent, int style) { +public this (Composite parent, int style) { super (parent, checkStyle (style)); } @@ -175,9 +171,9 @@ addListener(DWT.DefaultSelection,typedListener); } -override int callWindowProc (int hwnd, int msg, int wParam, int lParam) { - if (handle is 0) return 0; - return OS.CallWindowProc (TabFolderProc, hwnd, msg, wParam, lParam); +override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { + if (handle is null) return LRESULT.ZERO; + return cast(LRESULT) OS.CallWindowProc (TabFolderProc, hwnd, msg, wParam, lParam); } static int checkStyle (int style) { @@ -185,7 +181,7 @@ * When the DWT.TOP style has not been set, force the * tabs to be on the bottom for tab folders on PPC. */ - if (OS.IsPPC) { + if (OS.IsPPC_) { if ((style & DWT.TOP) is 0) style |= DWT.BOTTOM; } style = checkBits (style, DWT.TOP, DWT.BOTTOM, 0, 0, 0, 0); @@ -207,17 +203,17 @@ override public Point computeSize (int wHint, int hHint, bool changed) { checkWidget (); Point size = super.computeSize (wHint, hHint, changed); - RECT insetRect = new RECT (), itemRect = new RECT (); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect); + RECT insetRect, itemRect; + OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, &insetRect); int width = insetRect.left - insetRect.right; int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0); if (count !is 0) { - OS.SendMessage (handle, OS.TCM_GETITEMRECT, count - 1, itemRect); + OS.SendMessage (handle, OS.TCM_GETITEMRECT, count - 1, &itemRect); width = Math.max (width, itemRect.right - insetRect.right); } - RECT rect = new RECT (); - OS.SetRect (rect, 0, 0, width, size.y); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect); + RECT rect; + OS.SetRect (&rect, 0, 0, width, size.y); + OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, &rect); int border = getBorderWidth (); rect.left -= border; rect.right += border; width = rect.right - rect.left; @@ -227,9 +223,9 @@ override public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget (); - RECT rect = new RECT (); - OS.SetRect (rect, x, y, x + width, y + height); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect); + RECT rect; + OS.SetRect (&rect, x, y, x + width, y + height); + OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, &rect); int border = getBorderWidth (); rect.left -= border; rect.right += border; rect.top -= border; rect.bottom += border; @@ -246,8 +242,8 @@ System.arraycopy (items, 0, newItems, 0, items.length); items = newItems; } - TCITEM tcItem = new TCITEM (); - if (OS.SendMessage (handle, OS.TCM_INSERTITEM, index, tcItem) is -1) { + TCITEM tcItem; + if (OS.SendMessage (handle, OS.TCM_INSERTITEM, index, &tcItem) is -1) { error (DWT.ERROR_ITEM_NOT_ADDED); } System.arraycopy (items, index, items, index + 1, count - index); @@ -271,7 +267,7 @@ state &= ~(CANVAS | THEME_BACKGROUND); /* Enable the flat look for tab folders on PPC */ - if (OS.IsPPC) { + if (OS.IsPPC_) { OS.SendMessage (handle, OS.CCM_SETVERSION, 0x020c /*COMCTL32_VERSION*/, 0); } @@ -282,7 +278,7 @@ * is set. The fix is to set TTM_SETMAXTIPWIDTH to * a large value. */ - int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0); + auto hwndToolTip = cast(HWND) OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0); OS.SendMessage (hwndToolTip, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); } @@ -318,12 +314,13 @@ } } -override void drawThemeBackground (int hDC, int hwnd, RECT rect) { - RECT rect2 = new RECT (); - OS.GetClientRect (handle, rect2); - OS.MapWindowPoints (handle, hwnd, rect2, 2); - if (OS.IntersectRect (new RECT (), rect2, rect)) { - OS.DrawThemeBackground (display.hTabTheme (), hDC, OS.TABP_BODY, 0, rect2, null); +override void drawThemeBackground (HDC hDC, HWND hwnd, RECT* rect) { + RECT rect2; + OS.GetClientRect (handle, &rect2); + OS.MapWindowPoints (handle, hwnd, cast(POINT*) &rect2, 2); + RECT dummy; + if (OS.IntersectRect (&dummy, &rect2, rect)) { + OS.DrawThemeBackground (display.hTabTheme (), hDC, OS.TABP_BODY, 0, &rect2, null); } } @@ -335,9 +332,9 @@ override public Rectangle getClientArea () { checkWidget (); forceResize (); - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, rect); + RECT rect; + OS.GetClientRect (handle, &rect); + OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, &rect); int width = rect.right - rect.left; int height = rect.bottom - rect.top; return new Rectangle (rect.left, rect.top, width, height); @@ -424,7 +421,7 @@ checkWidget (); int index = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0); if (index is -1) return new TabItem [0]; - return new TabItem [] {items [index]}; + return [ items [index] ]; } /** @@ -449,7 +446,7 @@ Rectangle bounds = image.getBounds (); imageList = display.getImageList (style & DWT.RIGHT_TO_LEFT, bounds.width, bounds.height); int index = imageList.add (image); - int hImageList = imageList.getHandle (); + auto hImageList = imageList.getHandle (); OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList); return index; } @@ -513,12 +510,12 @@ return new Point (width, height); } -override bool mnemonicHit (char key) { +override bool mnemonicHit (wchar key) { for (int i=0; i