# HG changeset patch # User Frank Benoit # Date 1201562172 -3600 # Node ID 99d8b02576c3acf64891a24bd14c2ef68c2d65a5 # Parent 943a86053d88f1ae49877acc6dcc9963e103c98d Control diff -r 943a86053d88 -r 99d8b02576c3 dwt/accessibility/Accessible.d --- a/dwt/accessibility/Accessible.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/accessibility/Accessible.d Tue Jan 29 00:16:12 2008 +0100 @@ -12,8 +12,12 @@ *******************************************************************************/ module dwt.accessibility.Accessible; +import dwt.widgets.Control; //PORTING_TYPE public class Accessible { + public static Accessible internal_new_Accessible(Control control) ; + public void internal_dispose_Accessible() ; + public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) ; } /++ diff -r 943a86053d88 -r 99d8b02576c3 dwt/internal/win32/OS.d --- a/dwt/internal/win32/OS.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/internal/win32/OS.d Tue Jan 29 00:16:12 2008 +0100 @@ -4474,6 +4474,7 @@ alias WINAPI.SetActiveWindow SetActiveWindow; alias WINAPI.SetBkColor SetBkColor; alias WINAPI.SetBkMode SetBkMode; +alias STDWIN.SetBrushOrgEx SetBrushOrgEx; alias WINAPI.SetCapture SetCapture; alias WINAPI.SetCaretPos SetCaretPos; alias WINAPI.SetClipboardData SetClipboardData; diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Composite.d --- a/dwt/widgets/Composite.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Composite.d Tue Jan 29 00:16:12 2008 +0100 @@ -14,15 +14,26 @@ import dwt.widgets.Scrollable; import dwt.widgets.Control; +import dwt.widgets.Layout; import dwt.graphics.Font; +import dwt.internal.win32.OS; class Composite : Scrollable { + Layout layout_; + int font; + WINDOWPOS* [] lpwp; + Control [] tabList; + int layoutCount, backgroundMode; + public Control [] getChildren () ; void updateFont (Font oldFont, Font newFont) ; public void layout () ; public void layout (bool ) ; public void layout (bool , bool ) ; public void layout (Control[]) ; +Control [] _getTabList () ; +void removeControl (Control control) ; +Control [] _getChildren () ; } /++ import dwt.DWT; @@ -33,18 +44,7 @@ import dwt.graphics.Image; import dwt.graphics.Point; import dwt.graphics.Rectangle; -import dwt.internal.Callback; -import dwt.internal.win32.LRESULT; -import dwt.internal.win32.MSG; -import dwt.internal.win32.NMHDR; -import dwt.internal.win32.NMTTDISPINFO; -import dwt.internal.win32.NMTTDISPINFOA; -import dwt.internal.win32.NMTTDISPINFOW; import dwt.internal.win32.OS; -import dwt.internal.win32.PAINTSTRUCT; -import dwt.internal.win32.POINT; -import dwt.internal.win32.RECT; -import dwt.internal.win32.WINDOWPOS; /** * Instances of this class are controls which are capable @@ -79,7 +79,7 @@ public class Composite extends Scrollable { Layout layout; int font; - WINDOWPOS [] lpwp; + WINDOWPOS* [] lpwp; Control [] tabList; int layoutCount, backgroundMode; diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Control.d --- a/dwt/widgets/Control.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Control.d Tue Jan 29 00:16:12 2008 +0100 @@ -82,6 +82,15 @@ import dwt.widgets.Composite; import dwt.widgets.Event; import dwt.widgets.Shell; +import dwt.widgets.Menu; +import dwt.widgets.MenuItem; +import dwt.widgets.Decorations; +import dwt.widgets.TypedListener; +import dwt.widgets.Listener; +import dwt.widgets.Display; + +import dwt.dwthelper.utils; +import dwt.dwthelper.System; /** * Control is the abstract superclass of all windowed user interface classes. @@ -103,6 +112,9 @@ */ public abstract class Control : Widget, Drawable { + + alias Widget.dragDetect dragDetect; + /** * the handle to the OS resource * (Warning: This field is platform dependent) @@ -499,7 +511,7 @@ addListener (DWT.Traverse,typedListener); } -int borderHandle () { +HANDLE borderHandle () { return handle; } @@ -509,7 +521,7 @@ state &= ~PARENT_BACKGROUND; Composite composite = parent; do { - int mode = composite.backgroundMode; + auto mode = composite.backgroundMode; if (mode !is 0) { if (mode is DWT.INHERIT_DEFAULT) { Control control = this; @@ -536,7 +548,7 @@ style &= ~DWT.DOUBLE_BUFFERED; } -bool checkHandle (int hwnd) { +bool checkHandle (HWND hwnd) { return hwnd is handle; } @@ -668,9 +680,9 @@ if (handle is null) error (DWT.ERROR_NO_HANDLES); int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); if ((bits & OS.WS_CHILD) !is 0) { - OS.SetWindowLong (handle, OS.GWL_ID, handle); + OS.SetWindowLong (handle, OS.GWL_ID, cast(int)handle); } - if (OS.IsDBLocale && hwndParent !is 0) { + if (OS.IsDBLocale && hwndParent !is null) { auto hIMC = OS.ImmGetContext (hwndParent); OS.ImmAssociateContext (handle, hIMC); OS.ImmReleaseContext (hwndParent, hIMC); @@ -848,17 +860,17 @@ return sendDragEvent (button, stateMask, x, y); } -void drawBackground (int hDC) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - drawBackground (hDC, rect); -} - -void drawBackground (int hDC, RECT rect) { +void drawBackground (HDC hDC) { + RECT rect; + OS.GetClientRect (handle, &rect); + drawBackground (hDC, &rect); +} + +void drawBackground (HDC hDC, RECT* rect) { drawBackground (hDC, rect, -1); } -void drawBackground (int hDC, RECT rect, int pixel) { +void drawBackground (HDC hDC, RECT* rect, int pixel) { Control control = findBackgroundControl (); if (control !is null) { if (control.backgroundImage !is null) { @@ -882,21 +894,21 @@ fillBackground (hDC, pixel, rect); } -void drawImageBackground (int hDC, int hwnd, int hBitmap, RECT rect) { - RECT rect2 = new RECT (); - OS.GetClientRect (hwnd, rect2); - OS.MapWindowPoints (hwnd, handle, rect2, 2); - int hBrush = findBrush (hBitmap, OS.BS_PATTERN); - POINT lpPoint = new POINT (); - OS.GetWindowOrgEx (hDC, lpPoint); - OS.SetBrushOrgEx (hDC, -rect2.left - lpPoint.x, -rect2.top - lpPoint.y, lpPoint); - int hOldBrush = OS.SelectObject (hDC, hBrush); +void drawImageBackground (HDC hDC, HWND hwnd, HBITMAP hBitmap, RECT* rect) { + RECT rect2; + OS.GetClientRect (hwnd, &rect2); + OS.MapWindowPoints (hwnd, handle, cast(POINT*)&rect2, 2); + auto hBrush = findBrush ( cast(int)hBitmap, OS.BS_PATTERN); + POINT lpPoint; + OS.GetWindowOrgEx (hDC, &lpPoint); + OS.SetBrushOrgEx (hDC, -rect2.left - lpPoint.x, -rect2.top - lpPoint.y, &lpPoint); + auto hOldBrush = OS.SelectObject (hDC, hBrush); OS.PatBlt (hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); OS.SetBrushOrgEx (hDC, lpPoint.x, lpPoint.y, null); OS.SelectObject (hDC, hOldBrush); } -void drawThemeBackground (int hDC, int hwnd, RECT rect) { +void drawThemeBackground (HDC hDC, HWND hwnd, RECT* rect) { /* Do nothing */ } @@ -908,17 +920,17 @@ OS.EnableWindow (handle, enabled); } -void fillBackground (int hDC, int pixel, RECT rect) { +void fillBackground (HDC hDC, int pixel, RECT* rect) { if (rect.left > rect.right || rect.top > rect.bottom) return; - int hPalette = display.hPalette; - if (hPalette !is 0) { + auto hPalette = display.hPalette; + if (hPalette !is null) { OS.SelectPalette (hDC, hPalette, false); OS.RealizePalette (hDC); } OS.FillRect (hDC, rect, findBrush (pixel, OS.BS_SOLID)); } -void fillImageBackground (int hDC, Control control, RECT rect) { +void fillImageBackground (HDC hDC, Control control, RECT* rect) { if (rect.left > rect.right || rect.top > rect.bottom) return; if (control !is null) { Image image = control.backgroundImage; @@ -928,7 +940,7 @@ } } -void fillThemeBackground (int hDC, Control control, RECT rect) { +void fillThemeBackground (HDC hDC, Control control, RECT* rect) { if (rect.left > rect.right || rect.top > rect.bottom) return; if (control !is null) { control.drawThemeBackground (hDC, handle, rect); @@ -940,7 +952,7 @@ return (state & PARENT_BACKGROUND) !is 0 ? parent.findBackgroundControl () : null; } -int findBrush (int value, int lbStyle) { +HBRUSH findBrush (int value, int lbStyle) { return parent.findBrush (value, lbStyle); } @@ -965,13 +977,13 @@ char findMnemonic (char[] string) { int index = 0; - int length = string.length; + int length_ = string.length; do { - while (index < length && string.charAt (index) !is '&') index++; - if (++index >= length) return '\0'; + while (index < length_ && string.charAt (index) !is '&') index++; + if (++index >= length_) return '\0'; if (string.charAt (index) !is '&') return string.charAt (index); index++; - } while (index < length); + } while (index < length_); return '\0'; } @@ -987,7 +999,7 @@ if (control.setFixedFocus ()) return; } shell.setSavedFocus (focusControl); - OS.SetFocus (0); + OS.SetFocus (null); } /** @@ -1156,10 +1168,10 @@ public Rectangle getBounds () { checkWidget (); forceResize (); - RECT rect = new RECT (); - OS.GetWindowRect (topHandle (), rect); - auto hwndParent = parent is null ? 0 : parent.handle; - OS.MapWindowPoints (0, hwndParent, rect, 2); + RECT rect; + OS.GetWindowRect (topHandle (), &rect); + auto hwndParent = parent is null ? null : parent.handle; + OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2); int width = rect.right - rect.left; int height = rect.bottom - rect.top; return new Rectangle (rect.left, rect.top, width, height); @@ -1167,12 +1179,12 @@ int getCodePage () { if (OS.IsUnicode) return OS.CP_ACP; - auto hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); + auto hFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); LOGFONT logFont; OS.GetObject (hFont, LOGFONT.sizeof, &logFont); int cs = logFont.lfCharSet & 0xFF; int [] lpCs = new int [8]; - if (OS.TranslateCharsetInfo (cs, lpCs, OS.TCI_SRCCHARSET)) { + if (OS.TranslateCharsetInfo (cast(uint*)cs, cast(CHARSETINFO*)lpCs.ptr, OS.TCI_SRCCHARSET)) { return lpCs [1]; } return OS.GetACP (); @@ -1180,17 +1192,15 @@ char[] getClipboardText () { char[] string = ""; - if (OS.OpenClipboard (0)) { - int hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT); - if (hMem !is 0) { + if (OS.OpenClipboard (null)) { + auto hMem = OS.GetClipboardData (OS.IsUnicode ? OS.CF_UNICODETEXT : OS.CF_TEXT); + if (hMem !is null) { /* Ensure byteCount is a multiple of 2 bytes on UNICODE platforms */ int byteCount = OS.GlobalSize (hMem) / TCHAR.sizeof * TCHAR.sizeof; - int ptr = OS.GlobalLock (hMem); - if (ptr !is 0) { + auto ptr = OS.GlobalLock (hMem); + if (ptr !is null) { /* Use the character encoding for the default locale */ - TCHAR buffer = new TCHAR (0, byteCount / TCHAR.sizeof); - OS.MoveMemory (buffer, ptr, byteCount); - string = buffer.toString (0, buffer.strlen ()); + string = TCHARzToStr( cast(TCHAR*)ptr ); OS.GlobalUnlock (hMem); } } @@ -1253,7 +1263,7 @@ */ public bool getEnabled () { checkWidget (); - return OS.IsWindowEnabled (handle); + return cast(bool)OS.IsWindowEnabled (handle); } /** @@ -1268,7 +1278,7 @@ */ public Font getFont () { checkWidget (); - auto hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); + auto hFont = cast(HFONT)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); if (hFont is null) hFont = defaultFont (); return Font.win32_new (display, hFont); } @@ -1325,8 +1335,8 @@ forceResize (); RECT rect; OS.GetWindowRect (topHandle (), &rect); - int hwndParent = parent is null ? 0 : parent.handle; - OS.MapWindowPoints (0, hwndParent, &rect, 2); + auto hwndParent = parent is null ? null : parent.handle; + OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2); return new Point (rect.left, rect.top); } @@ -1357,7 +1367,7 @@ * * @since 3.0 */ -public Monitor getMonitor () { +public dwt.widgets.Monitor.Monitor getMonitor () { checkWidget (); if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) { return display.getPrimaryMonitor (); @@ -1374,8 +1384,8 @@ monitor.height = lpmi.rcMonitor.bottom - lpmi.rcMonitor.top; monitor.clientX = lpmi.rcWork.left; monitor.clientY = lpmi.rcWork.top; - monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork.left; - monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork.top; + monitor.clientWidth = lpmi.rcWork.right - lpmi.rcWork.left; + monitor.clientHeight = lpmi.rcWork.bottom - lpmi.rcWork.top; return monitor; } @@ -1499,9 +1509,9 @@ bool hasCursor () { RECT rect; if (!OS.GetClientRect (handle, &rect)) return false; - OS.MapWindowPoints (handle, 0, &rect, 2); + OS.MapWindowPoints (handle, null, cast(POINT*)&rect, 2); POINT pt; - return OS.GetCursorPos (pt) && OS.PtInRect (&rect, pt); + return OS.GetCursorPos (&pt) && OS.PtInRect (&rect, pt); } bool hasFocus () { @@ -1569,7 +1579,7 @@ if (control is null) control = this; auto background = control.getBackgroundPixel (); if (background !is OS.GetBkColor (hDC)) data.background = background; - data.hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0); + data.hFont = cast(HFONT) OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0); data.uiState = OS.SendMessage (hwnd, OS.WM_QUERYUISTATE, 0, 0); } return hDC; @@ -1772,12 +1782,12 @@ return getVisible () && parent.isVisible (); } -void mapEvent (int hwnd, Event event) { +void mapEvent (HWND hwnd, Event event) { if (hwnd !is handle) { - POINT point = new POINT (); + POINT point; point.x = event.x; point.y = event.y; - OS.MapWindowPoints (hwnd, handle, point, 1); + OS.MapWindowPoints (hwnd, handle, &point, 1); event.x = point.x; event.y = point.y; } @@ -1821,12 +1831,13 @@ */ public void moveAbove (Control control) { checkWidget (); - int topHandle = topHandle (), hwndAbove = OS.HWND_TOP; + auto topHandle_ = topHandle (); + HWND hwndAbove = cast(HWND) OS.HWND_TOP; if (control !is null) { if (control.isDisposed ()) error(DWT.ERROR_INVALID_ARGUMENT); if (parent !is control.parent) return; - int hwnd = control.topHandle (); - if (hwnd is null || hwnd is topHandle) return; + auto hwnd = control.topHandle (); + if (hwnd is null || hwnd is topHandle_) return; hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV); /* * Bug in Windows. For some reason, when GetWindow () @@ -1836,11 +1847,11 @@ * this case and move the control to the top. */ if (hwndAbove is null || hwndAbove is hwnd) { - hwndAbove = OS.HWND_TOP; + hwndAbove = cast(HWND) OS.HWND_TOP; } } int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; - SetWindowPos (topHandle, hwndAbove, 0, 0, 0, 0, flags); + SetWindowPos (topHandle_, hwndAbove, 0, 0, 0, 0, flags); } /** @@ -1865,8 +1876,8 @@ */ public void moveBelow (Control control) { checkWidget (); - auto topHandle = topHandle (); - int hwndAbove = OS.HWND_BOTTOM; + auto topHandle_ = topHandle (); + HWND hwndAbove = cast(HWND)OS.HWND_BOTTOM; if (control !is null) { if (control.isDisposed ()) error(DWT.ERROR_INVALID_ARGUMENT); if (parent !is control.parent) return; @@ -1890,18 +1901,19 @@ * this case and do nothing because the control is already * at the bottom. */ - int hwndParent = parent.handle, hwnd = hwndParent; + auto hwndParent = parent.handle; + auto hwnd = hwndParent; hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV); - while (hwndAbove !is 0 && hwndAbove !is hwnd) { + while (hwndAbove !is null && hwndAbove !is hwnd) { if (OS.GetWindow (hwndAbove, OS.GW_OWNER) is hwndParent) break; hwndAbove = OS.GetWindow (hwnd = hwndAbove, OS.GW_HWNDPREV); } if (hwndAbove is hwnd) return; } } - if (hwndAbove is 0 || hwndAbove is topHandle) return; + if (hwndAbove is null || hwndAbove is topHandle_) return; int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; - SetWindowPos (topHandle, hwndAbove, 0, 0, 0, 0, flags); + SetWindowPos (topHandle_, hwndAbove, 0, 0, 0, 0, flags); } Accessible new_Accessible (Control control) { @@ -1987,7 +1999,7 @@ } else { int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; if (all) flags |= OS.RDW_ALLCHILDREN; - OS.RedrawWindow (handle, null, 0, flags); + OS.RedrawWindow (handle, null, null, flags); } } /** @@ -2024,14 +2036,14 @@ checkWidget (); if (width <= 0 || height <= 0) return; if (!OS.IsWindowVisible (handle)) return; - RECT rect = new RECT (); - OS.SetRect (rect, x, y, x + width, y + height); + RECT rect; + OS.SetRect (&rect, x, y, x + width, y + height); if (OS.IsWinCE) { - OS.InvalidateRect (handle, rect, true); + OS.InvalidateRect (handle, &rect, true); } else { int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; if (all) flags |= OS.RDW_ALLCHILDREN; - OS.RedrawWindow (handle, rect, 0, flags); + OS.RedrawWindow (handle, &rect, null, flags); } } @@ -2060,7 +2072,7 @@ void releaseHandle () { super.releaseHandle (); - handle = 0; + handle = null; parent = null; } @@ -2071,7 +2083,7 @@ void releaseWidget () { super.releaseWidget (); if (OS.IsDBLocale) { - OS.ImmAssociateContext (handle, 0); + OS.ImmAssociateContext (handle, null); } if (toolTipText_ !is null) { setToolTipText (getShell (), null); @@ -2395,9 +2407,9 @@ } void showWidget (bool visible) { - int topHandle = topHandle (); - OS.ShowWindow (topHandle, visible ? OS.SW_SHOW : OS.SW_HIDE); - if (handle !is topHandle) OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE); + auto topHandle_ = topHandle (); + OS.ShowWindow (topHandle_, visible ? OS.SW_SHOW : OS.SW_HIDE); + if (handle !is topHandle_) OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE); } bool sendFocusEvent (int type) { @@ -2519,12 +2531,12 @@ updateBackgroundImage (); } -void setBackgroundImage (int hBitmap) { +void setBackgroundImage (HBITMAP hBitmap) { if (OS.IsWinCE) { OS.InvalidateRect (handle, null, true); } else { int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; - OS.RedrawWindow (handle, null, 0, flags); + OS.RedrawWindow (handle, null, null, flags); } } @@ -2533,7 +2545,7 @@ OS.InvalidateRect (handle, null, true); } else { int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE; - OS.RedrawWindow (handle, null, 0, flags); + OS.RedrawWindow (handle, null, null, flags); } } @@ -2571,10 +2583,10 @@ } void setBounds (int x, int y, int width, int height, int flags, bool defer) { - int topHandle = topHandle (); + auto topHandle_ = topHandle (); if (defer && parent !is null) { forceResize (); - if (OS.GetWindow (handle, OS.GW_CHILD) is 0) { + if (OS.GetWindow (handle, OS.GW_CHILD) is null) { if (findImageControl () !is null) { flags |= OS.SWP_NOCOPYBITS; } else { @@ -2583,9 +2595,9 @@ } } } - WINDOWPOS [] lpwp = parent.lpwp; + WINDOWPOS* [] lpwp = parent.lpwp; if (lpwp is null) { - SetWindowPos (topHandle, 0, x, y, width, height, flags); + SetWindowPos (topHandle_, null, x, y, width, height, flags); } else { int index = 0; while (index < lpwp.length) { @@ -2593,12 +2605,12 @@ index ++; } if (index is lpwp.length) { - WINDOWPOS [] newLpwp = new WINDOWPOS [lpwp.length + 4]; - System.arraycopy (lpwp, 0, newLpwp, 0, lpwp.length); + WINDOWPOS* [] newLpwp = new WINDOWPOS* [lpwp.length + 4]; + SimpleType!(WINDOWPOS*).arraycopy (lpwp, 0, newLpwp, 0, lpwp.length); parent.lpwp = lpwp = newLpwp; } - WINDOWPOS wp = new WINDOWPOS (); - wp.hwnd = topHandle; + WINDOWPOS* wp = new WINDOWPOS; + wp.hwnd = topHandle_; wp.x = x; wp.y = y; wp.cx = width; @@ -2607,7 +2619,7 @@ lpwp [index] = wp; } } else { - SetWindowPos (topHandle, 0, x, y, width, height, flags); + SetWindowPos (topHandle_, null, x, y, width, height, flags); } } @@ -2686,20 +2698,20 @@ checkWidget (); if (cursor !is null && cursor.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); this.cursor = cursor; - if (OS.IsWinCE) { + static if (OS.IsWinCE) { int hCursor = cursor !is null ? cursor.handle : 0; OS.SetCursor (hCursor); return; } - int hwndCursor = OS.GetCapture (); - if (hwndCursor is 0) { - POINT pt = new POINT (); - if (!OS.GetCursorPos (pt)) return; - int hwnd = hwndCursor = OS.WindowFromPoint (pt); - while (hwnd !is 0 && hwnd !is handle) { + auto hwndCursor = OS.GetCapture (); + if (hwndCursor is null) { + POINT pt; + if (!OS.GetCursorPos (&pt)) return; + auto hwnd = hwndCursor = OS.WindowFromPoint (pt); + while (hwnd !is null && hwnd !is handle) { hwnd = OS.GetParent (hwnd); } - if (hwnd is 0) return; + if (hwnd is null) return; } Control control = display.getControl (hwndCursor); if (control is null) control = this; @@ -2707,7 +2719,7 @@ } void setDefaultFont () { - int hFont = display.getSystemFont ().handle; + auto hFont = display.getSystemFont ().handle; OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0); } @@ -2758,15 +2770,15 @@ * desktop. */ Control control = null; - bool fixFocus = false; + bool fixFocus_ = false; if (!enabled) { if (display.focusEvent !is DWT.FocusOut) { control = display.getFocusControl (); - fixFocus = isFocusAncestor (control); + fixFocus_ = isFocusAncestor (control); } } enableWidget (enabled); - if (fixFocus) fixFocus (control); + if (fixFocus_) fixFocus (control); } bool setFixedFocus () { @@ -2811,12 +2823,12 @@ */ public void setFont (Font font) { checkWidget (); - int hFont = 0; + HFONT hFont; if (font !is null) { if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); hFont = font.handle; } - if (hFont is 0) hFont = defaultFont (); + if (hFont is null) hFont = defaultFont (); OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1); } @@ -3003,28 +3015,28 @@ } if (redraw) { if (--drawCount is 0) { - int topHandle = topHandle (); - OS.SendMessage (topHandle, OS.WM_SETREDRAW, 1, 0); - if (handle !is topHandle) OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0); + auto topHandle_ = topHandle (); + OS.SendMessage (topHandle_, OS.WM_SETREDRAW, 1, 0); + if (handle !is topHandle_) OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0); if ((state & HIDDEN) !is 0) { state &= ~HIDDEN; - OS.ShowWindow (topHandle, OS.SW_HIDE); - if (handle !is topHandle) OS.ShowWindow (handle, OS.SW_HIDE); + OS.ShowWindow (topHandle_, OS.SW_HIDE); + if (handle !is topHandle_) OS.ShowWindow (handle, OS.SW_HIDE); } else { if (OS.IsWinCE) { - OS.InvalidateRect (topHandle, null, true); - if (handle !is topHandle) OS.InvalidateRect (handle, null, true); + OS.InvalidateRect (topHandle_, null, true); + if (handle !is topHandle_) OS.InvalidateRect (handle, null, true); } else { int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN; - OS.RedrawWindow (topHandle, null, 0, flags); + OS.RedrawWindow (topHandle_, null, null, flags); } } } } else { if (drawCount++ is 0) { - int topHandle = topHandle (); - OS.SendMessage (topHandle, OS.WM_SETREDRAW, 0, 0); - if (handle !is topHandle) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); + auto topHandle_ = topHandle (); + OS.SendMessage (topHandle_, OS.WM_SETREDRAW, 0, 0); + if (handle !is topHandle_) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); } } } @@ -3146,11 +3158,11 @@ * desktop. */ Control control = null; - bool fixFocus = false; + bool fixFocus_ = false; if (!visible) { if (display.focusEvent !is DWT.FocusOut) { control = display.getFocusControl (); - fixFocus = isFocusAncestor (control); + fixFocus_ = isFocusAncestor (control); } } if (drawCount !is 0) { @@ -3163,7 +3175,7 @@ sendEvent (DWT.Hide); if (isDisposed ()) return; } - if (fixFocus) fixFocus (control); + if (fixFocus_) fixFocus (control); } void sort (int [] items) { @@ -3184,7 +3196,7 @@ void subclass () { int oldProc = windowProc (); - int newProc = display.windowProc; + int newProc = display.windowProc(); if (oldProc is newProc) return; OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc); } @@ -3207,9 +3219,9 @@ */ public Point toControl (int x, int y) { checkWidget (); - POINT pt = new POINT (); + POINT pt; pt.x = x; pt.y = y; - OS.ScreenToClient (handle, pt); + OS.ScreenToClient (handle, &pt); return new Point (pt.x, pt.y); } @@ -3253,9 +3265,9 @@ */ public Point toDisplay (int x, int y) { checkWidget (); - POINT pt = new POINT (); + POINT pt; pt.x = x; pt.y = y; - OS.ClientToScreen (handle, pt); + OS.ClientToScreen (handle, &pt); return new Point (pt.x, pt.y); } @@ -3281,7 +3293,7 @@ return toDisplay (point.x, point.y); } -int topHandle () { +HANDLE topHandle () { return handle; } @@ -3298,7 +3310,7 @@ bool translateMnemonic (MSG* msg) { if (msg.wParam < 0x20) return false; - int hwnd = msg.hwnd; + auto hwnd = msg.hwnd; if (OS.GetKeyState (OS.VK_MENU) >= 0) { int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); if ((code & OS.DLGC_WANTALLKEYS) !is 0) return false; @@ -3318,7 +3330,7 @@ } bool translateTraversal (MSG* msg) { - int hwnd = msg.hwnd; + auto hwnd = msg.hwnd; int key = msg.wParam; if (key is OS.VK_MENU) { OS.SendMessage (hwnd, OS.WM_CHANGEUISTATE, OS.UIS_INITIALIZE, 0); @@ -3390,7 +3402,7 @@ * using the VK_UP and VK_DOWN keys, not with VK_LEFT * or VK_RIGHT. */ - if (OS.IsSP) { + if (OS.IsSP_) { if (key is OS.VK_LEFT || key is OS.VK_RIGHT) return false; } lastVirtual = true; @@ -3601,7 +3613,7 @@ } else { int flags = OS.RDW_UPDATENOW; if (all) flags |= OS.RDW_ALLCHILDREN; - OS.RedrawWindow (handle, null, 0, flags); + OS.RedrawWindow (handle, null, null, flags); } } @@ -3614,7 +3626,7 @@ void updateBackgroundImage () { Control control = findBackgroundControl (); Image image = control !is null ? control.backgroundImage : backgroundImage; - setBackgroundImage (image !is null ? image.handle : 0); + setBackgroundImage (image !is null ? image.handle : null); } void updateBackgroundMode () { @@ -3626,7 +3638,7 @@ } void updateFont (Font oldFont, Font newFont) { - if (getFont ().equals (oldFont)) setFont (newFont); + if (getFont () ==/*eq*/oldFont ) setFont (newFont); } void updateImages () { @@ -3637,13 +3649,13 @@ /* Do nothing */ } -CREATESTRUCT widgetCreateStruct () { +CREATESTRUCT* widgetCreateStruct () { return null; } int widgetExtStyle () { int bits = 0; - if (!OS.IsPPC) { + if (!OS.IsPPC_) { if ((style & DWT.BORDER) !is 0) bits |= OS.WS_EX_CLIENTEDGE; } // if ((style & DWT.BORDER) !is 0) { @@ -3672,7 +3684,7 @@ // if ((style & DWT.BORDER) !is 0) { // if ((style & DWT.FLAT) !is 0) bits |= OS.WS_BORDER; // } - if (OS.IsPPC) { + if (OS.IsPPC_) { if ((style & DWT.BORDER) !is 0) bits |= OS.WS_BORDER; } return bits; @@ -3719,20 +3731,20 @@ Menu [] menus = oldShell.findMenus (this); fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); } - int topHandle = topHandle (); - if (OS.SetParent (topHandle, parent.handle) is 0) return false; + auto topHandle_ = topHandle (); + if (OS.SetParent (topHandle_, parent.handle) is null) return false; this.parent = parent; int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; - SetWindowPos (topHandle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags); + SetWindowPos (topHandle_, cast(HWND)OS.HWND_BOTTOM, 0, 0, 0, 0, flags); return true; } -abstract TCHAR windowClass (); +abstract char[] windowClass (); abstract int windowProc (); -int windowProc (int hwnd, int msg, int wParam, int lParam) { - LRESULT result = null; +int windowProc (HWND hwnd, int msg, int wParam, int lParam) { + LRESULT result = LRESULT.NULL; switch (msg) { case OS.WM_ACTIVATE: result = WM_ACTIVATE (wParam, lParam); break; case OS.WM_CAPTURECHANGED: result = WM_CAPTURECHANGED (wParam, lParam); break; @@ -3823,12 +3835,12 @@ case OS.WM_XBUTTONDOWN: result = WM_XBUTTONDOWN (wParam, lParam); break; case OS.WM_XBUTTONUP: result = WM_XBUTTONUP (wParam, lParam); break; } - if (result !is null) return result.value; + if (result !is LRESULT.NULL) return result; return callWindowProc (hwnd, msg, wParam, lParam); } LRESULT WM_ACTIVATE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_CAPTURECHANGED (int wParam, int lParam) { @@ -3840,11 +3852,11 @@ } LRESULT WM_CLEAR (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_CLOSE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_COMMAND (int wParam, int lParam) { @@ -3861,10 +3873,10 @@ return item.wmCommandChild (wParam, lParam); } } - return null; + return LRESULT.NULL; } - Control control = display.getControl (lParam); - if (control is null) return null; + Control control = display.getControl (cast(HANDLE)lParam); + if (control is null) return LRESULT.NULL; return control.wmCommandChild (wParam, lParam); } @@ -3873,42 +3885,42 @@ } LRESULT WM_CTLCOLOR (int wParam, int lParam) { - int hPalette = display.hPalette; - if (hPalette !is 0) { - OS.SelectPalette (wParam, hPalette, false); - OS.RealizePalette (wParam); + auto hPalette = display.hPalette; + if (hPalette !is null) { + OS.SelectPalette ( cast(HPALETTE)wParam, hPalette, false); + OS.RealizePalette (cast(HPALETTE)wParam); } - Control control = display.getControl (lParam); - if (control is null) return null; + Control control = display.getControl (cast(HANDLE)lParam); + if (control is null) return LRESULT.NULL; return control.wmColorChild (wParam, lParam); } LRESULT WM_CUT (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_DESTROY (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_DRAWITEM (int wParam, int lParam) { DRAWITEMSTRUCT* struct_ = cast(DRAWITEMSTRUCT*)lParam; if (struct_.CtlType is OS.ODT_MENU) { MenuItem item = display.getMenuItem (struct_.itemID); - if (item is null) return null; + if (item is null) return LRESULT.NULL; return item.wmDrawChild (wParam, lParam); } Control control = display.getControl (struct_.hwndItem); - if (control is null) return null; + if (control is null) return LRESULT.NULL; return control.wmDrawChild (wParam, lParam); } LRESULT WM_ENDSESSION (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_ENTERIDLE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_ERASEBKGND (int wParam, int lParam) { @@ -3920,39 +3932,38 @@ if (findThemeControl () !is null) return LRESULT.ONE; } } - return null; + return LRESULT.NULL; } LRESULT WM_GETDLGCODE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_GETFONT (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_GETOBJECT (int wParam, int lParam) { if (accessible !is null) { - int result = accessible.internal_WM_GETOBJECT (wParam, lParam); - if (result !is 0) return new LRESULT (result); + LRESULT result = cast(LRESULT) accessible.internal_WM_GETOBJECT (wParam, lParam); + if (result !is 0) return result; } - return null; + return LRESULT.NULL; } LRESULT WM_GETMINMAXINFO (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_HOTKEY (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_HELP (int wParam, int lParam) { - if (OS.IsWinCE) return null; - HELPINFO lphi = new HELPINFO (); - OS.MoveMemory (lphi, lParam, HELPINFO.sizeof); + if (OS.IsWinCE) return LRESULT.NULL; + HELPINFO* lphi = cast(HELPINFO*)lParam; Decorations shell = menuShell (); - if (!shell.isEnabled ()) return null; + if (!shell.isEnabled ()) return LRESULT.NULL; if (lphi.iContextType is OS.HELPINFO_MENUITEM) { MenuItem item = display.getMenuItem (lphi.iCtrlId); if (item !is null && item.isEnabled ()) { @@ -3964,24 +3975,24 @@ if (menu.hooks (DWT.Help)) widget = menu; } if (widget !is null) { - int hwndShell = shell.handle; + auto hwndShell = shell.handle; OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0); widget.postEvent (DWT.Help); return LRESULT.ONE; } } - return null; + return LRESULT.NULL; } if (hooks (DWT.Help)) { postEvent (DWT.Help); return LRESULT.ONE; } - return null; + return LRESULT.NULL; } LRESULT WM_HSCROLL (int wParam, int lParam) { - Control control = display.getControl (lParam); - if (control is null) return null; + Control control = display.getControl (cast(HANDLE)lParam); + if (control is null) return LRESULT.NULL; return control.wmScrollChild (wParam, lParam); } @@ -3990,13 +4001,13 @@ } LRESULT WM_IME_COMPOSITION (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_INITMENUPOPUP (int wParam, int lParam) { /* Ignore WM_INITMENUPOPUP for an accelerator */ - if (display.accelKeyHit) return null; + if (display.accelKeyHit) return LRESULT.NULL; /* * If the high order word of LPARAM is non-zero, @@ -4006,7 +4017,7 @@ Shell shell = getShell (); Menu oldMenu = shell.activeMenu, newMenu = null; if ((lParam >> 16) is 0) { - newMenu = menuShell ().findMenu (wParam); + newMenu = menuShell ().findMenu (cast(HANDLE)wParam); if (newMenu !is null) newMenu.update (); } Menu menu = newMenu; @@ -4047,11 +4058,11 @@ newMenu.sendEvent (DWT.Show); // widget could be disposed at this point } - return null; + return LRESULT.NULL; } LRESULT WM_INPUTLANGCHANGE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_KEYDOWN (int wParam, int lParam) { @@ -4094,12 +4105,12 @@ MEASUREITEMSTRUCT* struct_ = cast(MEASUREITEMSTRUCT*)lParam;; if (struct_.CtlType is OS.ODT_MENU) { MenuItem item = display.getMenuItem (struct_.itemID); - if (item is null) return null; + if (item is null) return LRESULT.NULL; return item.wmMeasureChild (wParam, lParam); } - int hwnd = OS.GetDlgItem (handle, struct_.CtlID); + auto hwnd = OS.GetDlgItem (handle, struct_.CtlID); Control control = display.getControl (hwnd); - if (control is null) return null; + if (control is null) return LRESULT.NULL; return control.wmMeasureChild (wParam, lParam); } @@ -4115,9 +4126,9 @@ int type = wParam >> 16; if (type is 0 || type is OS.MF_SYSMENU) { display.mnemonicKeyHit = false; - return new LRESULT (OS.MNC_CLOSE << 16); + return cast( LRESULT )(OS.MNC_CLOSE << 16); } - return null; + return LRESULT.NULL; } LRESULT WM_MENUSELECT (int wParam, int lParam) { @@ -4153,23 +4164,23 @@ * to null in a destroyed widget is not harmful. */ shell.activeMenu = null; - return null; + return LRESULT.NULL; } - if ((code & OS.MF_SYSMENU) !is 0) return null; + if ((code & OS.MF_SYSMENU) !is 0) return LRESULT.NULL; if ((code & OS.MF_HILITE) !is 0) { MenuItem item = null; Decorations menuShell = menuShell (); if ((code & OS.MF_POPUP) !is 0) { int index = wParam & 0xFFFF; - MENUITEMINFO info = new MENUITEMINFO (); + MENUITEMINFO info; info.cbSize = MENUITEMINFO.sizeof; info.fMask = OS.MIIM_SUBMENU; - if (OS.GetMenuItemInfo (lParam, index, true, info)) { + if (OS.GetMenuItemInfo (cast(HANDLE)lParam, index, true, &info)) { Menu newMenu = menuShell.findMenu (info.hSubMenu); if (newMenu !is null) item = newMenu.cascade; } } else { - Menu newMenu = menuShell.findMenu (lParam); + Menu newMenu = menuShell.findMenu (cast(HANDLE)lParam); if (newMenu !is null) { int id = wParam & 0xFFFF; item = display.getMenuItem (id); @@ -4212,11 +4223,11 @@ } if (item !is null) item.sendEvent (DWT.Arm); } - return null; + return LRESULT.NULL; } LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_MOUSEHOVER (int wParam, int lParam) { @@ -4250,34 +4261,33 @@ } sendEvent (DWT.Move); // widget could be disposed at this point - return null; + return LRESULT.NULL; } LRESULT WM_NCACTIVATE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_NCCALCSIZE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_NCHITTEST (int wParam, int lParam) { - if (!OS.IsWindowEnabled (handle)) return null; - if (!isActive ()) return new LRESULT (OS.HTTRANSPARENT); - return null; + if (!OS.IsWindowEnabled (handle)) return LRESULT.NULL; + if (!isActive ()) return cast( LRESULT )(OS.HTTRANSPARENT); + return LRESULT.NULL; } LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_NCPAINT (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_NOTIFY (int wParam, int lParam) { - NMHDR hdr = new NMHDR (); - OS.MoveMemory (hdr, lParam, NMHDR.sizeof); + NMHDR* hdr = cast(NMHDR*)lParam; return wmNotify (hdr, wParam, lParam); } @@ -4286,15 +4296,15 @@ } LRESULT WM_PALETTECHANGED (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_PARENTNOTIFY (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_PASTE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_PRINT (int wParam, int lParam) { @@ -4302,19 +4312,19 @@ } LRESULT WM_PRINTCLIENT (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_QUERYENDSESSION (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_QUERYOPEN (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) { @@ -4332,15 +4342,15 @@ LRESULT WM_SETCURSOR (int wParam, int lParam) { int hitTest = cast(short) (lParam & 0xFFFF); if (hitTest is OS.HTCLIENT) { - Control control = display.getControl (wParam); - if (control is null) return null; + Control control = display.getControl (cast(HANDLE)wParam); + if (control is null) return LRESULT.NULL; Cursor cursor = control.findCursor (); if (cursor !is null) { OS.SetCursor (cursor.handle); return LRESULT.ONE; } } - return null; + return LRESULT.NULL; } LRESULT WM_SETFOCUS (int wParam, int lParam) { @@ -4348,25 +4358,25 @@ } LRESULT WM_SETTINGCHANGE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_SETFONT (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_SETREDRAW (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_SHOWWINDOW (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_SIZE (int wParam, int lParam) { sendEvent (DWT.Resize); // widget could be disposed at this point - return null; + return LRESULT.NULL; } LRESULT WM_SYSCHAR (int wParam, int lParam) { @@ -4374,7 +4384,7 @@ } LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_SYSCOMMAND (int wParam, int lParam) { @@ -4397,7 +4407,7 @@ int cmd = wParam & 0xFFF0; switch (cmd) { case OS.SC_CLOSE: - int hwndShell = menuShell ().handle; + auto hwndShell = menuShell ().handle; int bits = OS.GetWindowLong (hwndShell, OS.GWL_STYLE); if ((bits & OS.WS_SYSMENU) is 0) return LRESULT.ZERO; break; @@ -4449,15 +4459,15 @@ if (menu !is null) { char key = Display.mbcsToWcs (lParam); if (key !is 0) { - key = Character.toUpperCase (key); + key = CharacterToLower (key); MenuItem [] items = menu.getItems (); for (int i=0; i 0 && mnemonic is 0) { + if (text.length > 0 && mnemonic is 0) { char ch = text.charAt (0); - if (Character.toUpperCase (ch) is key) { + if (CharacterToLower (ch) is key) { display.mnemonicKeyHit = false; return LRESULT.ZERO; } @@ -4487,7 +4497,7 @@ menuShell ().saveFocus (); break; } - return null; + return LRESULT.NULL; } LRESULT WM_SYSKEYDOWN (int wParam, int lParam) { @@ -4499,25 +4509,25 @@ } LRESULT WM_TIMER (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_UNDO (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_VSCROLL (int wParam, int lParam) { - Control control = display.getControl (lParam); - if (control is null) return null; + Control control = display.getControl (cast(HANDLE)lParam); + if (control is null) return LRESULT.NULL; return control.wmScrollChild (wParam, lParam); } LRESULT WM_WINDOWPOSCHANGED (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { @@ -4530,18 +4540,17 @@ if (drawCount !is 0) { Shell shell = getShell (); if (shell !is this) { - WINDOWPOS lpwp = new WINDOWPOS (); - OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); + WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam; if ((lpwp.flags & OS.SWP_NOMOVE) is 0 || (lpwp.flags & OS.SWP_NOSIZE) is 0) { - RECT rect = new RECT (); - OS.GetWindowRect (topHandle (), rect); - int hwndParent = parent is null ? 0 : parent.handle; - OS.MapWindowPoints (0, hwndParent, rect, 2); - OS.InvalidateRect (hwndParent, rect, true); + RECT rect; + OS.GetWindowRect (topHandle (), &rect); + auto hwndParent = parent is null ? null : parent.handle; + OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2); + OS.InvalidateRect (hwndParent, &rect, true); } } } - return null; + return LRESULT.NULL; } LRESULT WM_XBUTTONDBLCLK (int wParam, int lParam) { @@ -4563,77 +4572,77 @@ if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { control = findThemeControl (); if (control !is null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - OS.SetTextColor (wParam, getForegroundPixel ()); - OS.SetBkColor (wParam, getBackgroundPixel ()); - fillThemeBackground (wParam, control, rect); - OS.SetBkMode (wParam, OS.TRANSPARENT); - return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); + RECT rect; + OS.GetClientRect (handle, &rect); + OS.SetTextColor (cast(HANDLE)wParam, getForegroundPixel ()); + OS.SetBkColor (cast(HANDLE)wParam, getBackgroundPixel ()); + fillThemeBackground (cast(HANDLE)wParam, control, &rect); + OS.SetBkMode (cast(HANDLE)wParam, OS.TRANSPARENT); + return cast( LRESULT )(OS.GetStockObject (OS.NULL_BRUSH)); } } } - if (foreground is -1) return null; + if (foreground is -1) return LRESULT.NULL; } if (control is null) control = this; int forePixel = getForegroundPixel (); int backPixel = control.getBackgroundPixel (); - OS.SetTextColor (wParam, forePixel); - OS.SetBkColor (wParam, backPixel); + OS.SetTextColor (cast(HANDLE)wParam, forePixel); + OS.SetBkColor (cast(HANDLE)wParam, backPixel); if (control.backgroundImage !is null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - int hwnd = control.handle; - int hBitmap = control.backgroundImage.handle; - OS.MapWindowPoints (handle, hwnd, rect, 2); - POINT lpPoint = new POINT (); - OS.GetWindowOrgEx (wParam, lpPoint); - OS.SetBrushOrgEx (wParam, -rect.left - lpPoint.x, -rect.top - lpPoint.y, lpPoint); - int hBrush = findBrush (hBitmap, OS.BS_PATTERN); + RECT rect; + OS.GetClientRect (handle, &rect); + auto hwnd = control.handle; + auto hBitmap = control.backgroundImage.handle; + OS.MapWindowPoints (handle, hwnd, cast(POINT*)&rect, 2); + POINT lpPoint; + OS.GetWindowOrgEx (cast(HANDLE)wParam, &lpPoint); + OS.SetBrushOrgEx (cast(HANDLE)wParam, -rect.left - lpPoint.x, -rect.top - lpPoint.y, &lpPoint); + auto hBrush = findBrush (cast(int)hBitmap, OS.BS_PATTERN); if ((state & DRAW_BACKGROUND) !is 0) { - int hOldBrush = OS.SelectObject (wParam, hBrush); - OS.MapWindowPoints (hwnd, handle, rect, 2); - OS.PatBlt (wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); - OS.SelectObject (wParam, hOldBrush); + auto hOldBrush = OS.SelectObject (cast(HANDLE)wParam, hBrush); + OS.MapWindowPoints (hwnd, handle, cast(POINT*)&rect, 2); + OS.PatBlt (cast(HANDLE)wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); + OS.SelectObject (cast(HANDLE)wParam, hOldBrush); } - OS.SetBkMode (wParam, OS.TRANSPARENT); - return new LRESULT (hBrush); + OS.SetBkMode (cast(HANDLE)wParam, OS.TRANSPARENT); + return cast( LRESULT )(hBrush); } - int hBrush = findBrush (backPixel, OS.BS_SOLID); + auto hBrush = findBrush (backPixel, OS.BS_SOLID); if ((state & DRAW_BACKGROUND) !is 0) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - int hOldBrush = OS.SelectObject (wParam, hBrush); - OS.PatBlt (wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); - OS.SelectObject (wParam, hOldBrush); + RECT rect; + OS.GetClientRect (handle, &rect); + auto hOldBrush = OS.SelectObject (cast(HANDLE)wParam, hBrush); + OS.PatBlt (cast(HANDLE)wParam, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, OS.PATCOPY); + OS.SelectObject (cast(HANDLE)wParam, hOldBrush); } - return new LRESULT (hBrush); + return cast( LRESULT )(hBrush); } LRESULT wmCommandChild (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT wmDrawChild (int wParam, int lParam) { - return null; + return LRESULT.NULL; } LRESULT wmMeasureChild (int wParam, int lParam) { - return null; -} - -LRESULT wmNotify (NMHDR hdr, int wParam, int lParam) { + return LRESULT.NULL; +} + +LRESULT wmNotify (NMHDR* hdr, int wParam, int lParam) { Control control = display.getControl (hdr.hwndFrom); - if (control is null) return null; + if (control is null) return LRESULT.NULL; return control.wmNotifyChild (hdr, wParam, lParam); } -LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) { - return null; +LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) { + return LRESULT.NULL; } LRESULT wmScrollChild (int wParam, int lParam) { - return null; -} - -} + return LRESULT.NULL; +} + +} diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Decorations.d --- a/dwt/widgets/Decorations.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Decorations.d Tue Jan 29 00:16:12 2008 +0100 @@ -13,8 +13,17 @@ module dwt.widgets.Decorations; import dwt.widgets.Canvas; +import dwt.widgets.Menu; +import dwt.widgets.Control; +import dwt.internal.win32.OS; + class Decorations : Canvas { +Menu findMenu (HMENU hMenu) ; void bringToTop () ; +void fixDecorations (Decorations newDecorations, Control control, Menu [] menus) ; +void setSavedFocus (Control control) ; +public Menu getMenuBar () ; +void saveFocus () ; } /++ import dwt.DWT; diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Display.d --- a/dwt/widgets/Display.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Display.d Tue Jan 29 00:16:12 2008 +0100 @@ -4440,6 +4440,10 @@ return d.windowProc( hwnd, msg, wParam, lParam ); } +int windowProc(){ + return cast(int)&windowProcFunc; +} + int windowProc (HWND hwnd, uint msg, uint wParam, int lParam) { /* * Bug in Adobe Reader 7.0. For some reason, when Adobe diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Menu.d --- a/dwt/widgets/Menu.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Menu.d Tue Jan 29 00:16:12 2008 +0100 @@ -13,12 +13,19 @@ module dwt.widgets.Menu; import dwt.widgets.Widget; +import dwt.widgets.Decorations; +import dwt.widgets.MenuItem; + class Menu : Widget { + MenuItem cascade; + Decorations parent; this( Widget, int ); public void setLocation (int x, int y) ; public void setVisible (bool visible) ; void update (); void _setVisible (bool visible) ; +public Menu getParentMenu () ; +public MenuItem [] getItems () ; } /++ import dwt.DWT; diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/MenuItem.d --- a/dwt/widgets/MenuItem.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/MenuItem.d Tue Jan 29 00:16:12 2008 +0100 @@ -14,12 +14,19 @@ import dwt.widgets.Item; import dwt.widgets.Widget; +import dwt.widgets.Menu; class MenuItem : Item { + Menu parent, menu; int id; public this (Widget parent, int style) { super (parent, style); } +public bool getEnabled () ; +public bool isEnabled () ; +LRESULT wmCommandChild (int wParam, int lParam) ; +LRESULT wmDrawChild (int wParam, int lParam) ; +LRESULT wmMeasureChild (int wParam, int lParam) ; } /++ import dwt.DWT; diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Shell.d --- a/dwt/widgets/Shell.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Shell.d Tue Jan 29 00:16:12 2008 +0100 @@ -11,9 +11,21 @@ module dwt.widgets.Shell; import dwt.widgets.Decorations; +import dwt.widgets.Control; +import dwt.widgets.Menu; +import dwt.internal.win32.OS; + class Shell : Decorations { + Menu activeMenu; void checkWidget (); -void updateModal () ; + void updateModal () ; + void fixShell (Shell newShell, Control control) ; + void setActiveControl (Control control) ; + void register () ; + void releaseBrushes () ; + void releaseChildren (bool destroy) ; + void setToolTipText (HWND hwnd, char[] text) ; + void fixToolTip () ; } /++ import dwt.DWT; @@ -23,22 +35,7 @@ import dwt.graphics.Point; import dwt.graphics.Rectangle; import dwt.graphics.Region; -import dwt.internal.win32.CREATESTRUCT; -import dwt.internal.win32.LOGBRUSH; -import dwt.internal.win32.LRESULT; -import dwt.internal.win32.MINMAXINFO; -import dwt.internal.win32.MSG; -import dwt.internal.win32.NMTTDISPINFO; import dwt.internal.win32.OS; -import dwt.internal.win32.POINT; -import dwt.internal.win32.RECT; -import dwt.internal.win32.SHACTIVATEINFO; -import dwt.internal.win32.SIPINFO; -import dwt.internal.win32.STARTUPINFO; -import dwt.internal.win32.TCHAR; -import dwt.internal.win32.TOOLINFO; -import dwt.internal.win32.WINDOWPOS; -import dwt.internal.win32.WNDCLASS; /** * Instances of this class represent the "windows" diff -r 943a86053d88 -r 99d8b02576c3 dwt/widgets/Widget.d --- a/dwt/widgets/Widget.d Mon Jan 28 21:27:31 2008 +0100 +++ b/dwt/widgets/Widget.d Tue Jan 29 00:16:12 2008 +0100 @@ -26,12 +26,6 @@ } ++/ -enum LRESULT { - NULL = -1, - ZERO = 0, - ONE = 1, -} - import dwt.DWT; import dwt.DWTException; import dwt.events.DisposeListener; @@ -79,6 +73,14 @@ */ public abstract class Widget { + + public enum LRESULT { + NULL = -1, + ZERO = 0, + ONE = 1, + } + + int style, state; Display display; EventTable eventTable; @@ -232,8 +234,8 @@ addListener (DWT.Dispose, typedListener); } -int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { - return 0; +LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { + return LRESULT.ZERO; } /** @@ -1303,12 +1305,12 @@ return Format( "{} {{{}}", getName (), string ); //$NON-NLS-1$ //$NON-NLS-2$ } -LRESULT wmCaptureChanged (int hwnd, int wParam, int lParam) { +LRESULT wmCaptureChanged (HWND hwnd, int wParam, int lParam) { display.captureChanged = true; return LRESULT.NULL; } -LRESULT wmChar (int hwnd, int wParam, int lParam) { +LRESULT wmChar (HWND hwnd, int wParam, int lParam) { /* * Do not report a lead byte as a key pressed. */ @@ -1713,7 +1715,7 @@ } LRESULT wmKillFocus (HWND hwnd, int wParam, int lParam) { - int code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam); + LRESULT code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam); assert( code !is LRESULT.NULL ); sendFocusEvent (DWT.FocusOut); // widget could be disposed at this point @@ -1749,7 +1751,7 @@ display.captureChanged = false; sendMouseEvent (DWT.MouseDown, 1, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam); if (sendMouseEvent (DWT.MouseDoubleClick, 1, hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -1788,7 +1790,7 @@ display.captureChanged = false; bool dispatch = sendMouseEvent (DWT.MouseDown, 1, count, 0, false, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam); if (dispatch && (consume is null || !consume [0])) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_LBUTTONDOWN, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_LBUTTONDOWN, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -1855,7 +1857,7 @@ Display display = this.display; LRESULT result = LRESULT.NULL; if (sendMouseEvent (DWT.MouseUp, 1, hwnd, OS.WM_LBUTTONUP, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_LBUTTONUP, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_LBUTTONUP, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -1893,7 +1895,7 @@ display.captureChanged = false; sendMouseEvent (DWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam); if (sendMouseEvent (DWT.MouseDoubleClick, 2, hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -1909,7 +1911,7 @@ Display display = this.display; display.captureChanged = false; if (sendMouseEvent (DWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_MBUTTONDOWN, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_MBUTTONDOWN, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -1924,7 +1926,7 @@ Display display = this.display; LRESULT result = LRESULT.NULL; if (sendMouseEvent (DWT.MouseUp, 2, hwnd, OS.WM_MBUTTONUP, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_MBUTTONUP, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_MBUTTONUP, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -2052,7 +2054,7 @@ if (OS.IsWinCE) { RECT rect; OS.GetUpdateRect (hwnd, &rect, false); - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam); assert( result !is LRESULT.NULL ); /* * Bug in Windows. When InvalidateRgn(), InvalidateRect() @@ -2089,7 +2091,7 @@ } else { auto rgn = OS.CreateRectRgn (0, 0, 0, 0); OS.GetUpdateRgn (hwnd, rgn, false); - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam); assert( result !is LRESULT.NULL ); GCData data = new GCData (); data.hwnd = hwnd; @@ -2134,7 +2136,7 @@ if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE); if ((bits & OS.WS_EX_CLIENTEDGE) !is 0) { - int code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam); + LRESULT code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam); assert( code !is LRESULT.NULL ); RECT rect; OS.GetWindowRect (hwnd, &rect); @@ -2170,7 +2172,7 @@ display.captureChanged = false; sendMouseEvent (DWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam); if (sendMouseEvent (DWT.MouseDoubleClick, 3, hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -2186,7 +2188,7 @@ Display display = this.display; display.captureChanged = false; if (sendMouseEvent (DWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_RBUTTONDOWN, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_RBUTTONDOWN, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -2201,7 +2203,7 @@ Display display = this.display; LRESULT result = LRESULT.NULL; if (sendMouseEvent (DWT.MouseUp, 3, hwnd, OS.WM_RBUTTONUP, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam); assert( result !is LRESULT.NULL ); } else { /* Call the DefWindowProc() to support WM_CONTEXTMENU */ @@ -2223,7 +2225,7 @@ } LRESULT wmSetFocus (HWND hwnd, int wParam, int lParam) { - LRESULT code = cast(LRESULT) callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam); + LRESULT code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam); assert( code !is LRESULT.NULL ); sendFocusEvent (DWT.FocusIn); // widget could be disposed at this point @@ -2253,7 +2255,7 @@ /* Call the window proc to determine whether it is a system key or mnemonic */ bool oldKeyHit = display.mnemonicKeyHit; display.mnemonicKeyHit = true; - LRESULT result = cast(LRESULT) callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam); + LRESULT result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam); assert( result !is LRESULT.NULL ); bool consumed = false; if (!display.mnemonicKeyHit) { @@ -2412,7 +2414,7 @@ int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5; sendMouseEvent (DWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); if (sendMouseEvent (DWT.MouseDoubleClick, button, hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -2430,7 +2432,7 @@ display.xMouse = true; int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5; if (sendMouseEvent (DWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO; @@ -2446,7 +2448,7 @@ LRESULT result = LRESULT.NULL; int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5; if (sendMouseEvent (DWT.MouseUp, button, hwnd, OS.WM_XBUTTONUP, wParam, lParam)) { - result = cast(LRESULT) callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam); + result = callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam); assert( result !is LRESULT.NULL ); } else { result = LRESULT.ZERO;