# 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= 6) {
- TOOLINFO lpti = new TOOLINFO ();
+ TOOLINFO lpti;
lpti.cbSize = TOOLINFO.sizeof;
- int hwndToolTip = OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
- if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) !is 0) {
+ auto hwndToolTip = cast(HWND) OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+ if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) {
if ((lpti.uFlags & OS.TTF_IDISHWND) is 0) {
- OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti);
- OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, lpti);
+ OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, &lpti);
+ OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, &lpti);
}
}
}
@@ -812,7 +809,7 @@
override LRESULT WM_NCHITTEST (int wParam, int lParam) {
LRESULT result = super.WM_NCHITTEST (wParam, lParam);
- if (result !is null) return result;
+ if (result !is LRESULT.NULL) return result;
/*
* Feature in Windows. The tab control implements
* WM_NCHITTEST to return HTCLIENT when the cursor
@@ -826,7 +823,7 @@
* the mouse is in the client area.
*/
int hittest = OS.DefWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
- return new LRESULT (hittest);
+ return cast(LRESULT) (hittest);
}
override LRESULT WM_NOTIFY (int wParam, int lParam) {
@@ -849,13 +846,13 @@
* for this control.
*/
LRESULT result = super.WM_NOTIFY (wParam, lParam);
- if (result !is null) return result;
+ if (result !is LRESULT.NULL) return result;
return LRESULT.ZERO;
}
override LRESULT WM_PARENTNOTIFY (int wParam, int lParam) {
LRESULT result = super.WM_PARENTNOTIFY (wParam, lParam);
- if (result !is null) return result;
+ if (result !is LRESULT.NULL) return result;
/*
* Feature in Windows. Windows does not explicitly set the orientation of
* the buddy control. Instead, the orientation is inherited when WS_EX_LAYOUTRTL
@@ -871,9 +868,10 @@
int code = wParam & 0xFFFF;
switch (code) {
case OS.WM_CREATE: {
- int id = (wParam >> 16), hwnd = lParam;
+ int id = (wParam >> 16);
+ HWND hwnd = cast(HWND) lParam;
if (id is ID_UPDOWN) {
- int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
+ auto bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
OS.SetWindowLong (hwnd, OS.GWL_EXSTYLE, bits | OS.WS_EX_LAYOUTRTL);
}
break;
@@ -906,10 +904,10 @@
override LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
- if (result !is null) return result;
+ if (result !is LRESULT.NULL) return result;
if (!OS.IsWindowVisible (handle)) return result;
- WINDOWPOS lpwp = new WINDOWPOS ();
- OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
+ WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam;
+ //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
if ((lpwp.flags & (OS.SWP_NOSIZE | OS.SWP_NOREDRAW)) !is 0) {
return result;
}
@@ -923,37 +921,37 @@
OS.InvalidateRect (handle, null, true);
return result;
}
- RECT rect = new RECT ();
- OS.SetRect (rect, 0, 0, lpwp.cx, lpwp.cy);
- OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, rect);
+ RECT rect;
+ OS.SetRect (&rect, 0, 0, lpwp.cx, lpwp.cy);
+ OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &rect);
int newWidth = rect.right - rect.left;
int newHeight = rect.bottom - rect.top;
- OS.GetClientRect (handle, rect);
+ OS.GetClientRect (handle, &rect);
int oldWidth = rect.right - rect.left;
int oldHeight = rect.bottom - rect.top;
if (newWidth is oldWidth && newHeight is oldHeight) {
return result;
}
- RECT inset = new RECT ();
- OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, inset);
+ RECT inset;
+ OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, &inset);
int marginX = -inset.right, marginY = -inset.bottom;
if (newWidth !is oldWidth) {
int left = oldWidth;
if (newWidth < oldWidth) left = newWidth;
- OS.SetRect (rect, left - marginX, 0, newWidth, newHeight);
- OS.InvalidateRect (handle, rect, true);
+ OS.SetRect (&rect, left - marginX, 0, newWidth, newHeight);
+ OS.InvalidateRect (handle, &rect, true);
}
if (newHeight !is oldHeight) {
int bottom = oldHeight;
if (newHeight < oldHeight) bottom = newHeight;
if (newWidth < oldWidth) oldWidth -= marginX;
- OS.SetRect (rect, 0, bottom - marginY, oldWidth, newHeight);
- OS.InvalidateRect (handle, rect, true);
+ OS.SetRect (&rect, 0, bottom - marginY, oldWidth, newHeight);
+ OS.InvalidateRect (handle, &rect, true);
}
return result;
}
-override LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) {
+override LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) {
int code = hdr.code;
switch (code) {
case OS.TCN_SELCHANGE:
@@ -980,4 +978,4 @@
}
}
-++/
+
diff -r 66203354c9d3 -r 774d936d1380 dwt/widgets/TabItem.d
--- a/dwt/widgets/TabItem.d Mon Feb 04 15:39:21 2008 +0100
+++ b/dwt/widgets/TabItem.d Mon Feb 04 16:26:54 2008 +0100
@@ -10,22 +10,17 @@
*******************************************************************************/
module dwt.widgets.TabItem;
-import dwt.widgets.Item;
-import dwt.widgets.Widget;
-
-class TabItem : Item {
- public this (Widget parent, int style) {
- super (parent, style);
- }
-}
-/++
-
import dwt.DWT;
import dwt.DWTException;
import dwt.graphics.Image;
import dwt.internal.win32.OS;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TCITEM;
+
+import dwt.widgets.Item;
+import dwt.widgets.Widget;
+import dwt.widgets.TabFolder;
+import dwt.widgets.Control;
+
+import dwt.dwthelper.utils;
/**
* Instances of this class represent a selectable user interface object
@@ -41,10 +36,10 @@
*
*/
-public class TabItem extends Item {
+public class TabItem : Item {
TabFolder parent;
Control control;
- String toolTipText;
+ char[] toolTipText;
/**
* Constructs a new instance of this class given its parent
@@ -76,7 +71,7 @@
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style) {
+public this (TabFolder parent, int style) {
super (parent, style);
this.parent = parent;
parent.createItem (this, parent.getItemCount ());
@@ -114,13 +109,13 @@
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public TabItem (TabFolder parent, int style, int index) {
+public this (TabFolder parent, int style, int index) {
super (parent, style);
this.parent = parent;
parent.createItem (this, index);
}
-void _setText (int index, String string) {
+void _setText (int index, char[] string) {
/*
* Bug in Windows. In version 6.00 of COMCTL32.DLL, tab
* items with an image and a label that includes '&' cause
@@ -130,26 +125,26 @@
*/
if (OS.COMCTL32_MAJOR >= 6 && image !is null) {
if (string.indexOf ('&') !is -1) {
- int length = string.length ();
- char[] text = new char [length];
- string.getChars ( 0, length, text, 0);
+ int length_ = string.length ;
+ char[] text = new char [length_];
+ string.getChars ( 0, length_, text, 0);
int i = 0, j = 0;
- for (i=0; iERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*/
-public String getToolTipText () {
+public char[] getToolTipText () {
checkWidget();
return toolTipText;
}
@@ -282,11 +277,11 @@
if (OS.COMCTL32_MAJOR >= 6) {
if (text.indexOf ('&') !is -1) _setText (index, text);
}
- int hwnd = parent.handle;
- TCITEM tcItem = new TCITEM ();
+ auto hwnd = parent.handle;
+ TCITEM tcItem;
tcItem.mask = OS.TCIF_IMAGE;
tcItem.iImage = parent.imageIndex (image);
- OS.SendMessage (hwnd, OS.TCM_SETITEM, index, tcItem);
+ OS.SendMessage (hwnd, OS.TCM_SETITEM, index, &tcItem);
}
/**
* Sets the receiver's text. The string may include
@@ -314,10 +309,10 @@
*
*
*/
-override public void setText (String string) {
+override public void setText (char[] string) {
checkWidget();
if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
- if (string.equals (text)) return;
+ if (string ==/*eq*/text ) return;
int index = parent.indexOf (this);
if (index is -1) return;
super.setText (string);
@@ -335,10 +330,10 @@
* ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*
*/
-public void setToolTipText (String string) {
+public void setToolTipText (char[] string) {
checkWidget();
toolTipText = string;
}
}
-++/
+