Changeset 39:f5e70f9aeeda

Show
Ignore:
Timestamp:
02/01/08 11:45:36 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Decorations

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/internal/win32/OS.d

    r38 r39  
    7373 
    7474    public static const BOOL IsPPC_; 
    75     public static const BOOL IsHPC; 
    76     public static const BOOL IsSP_; 
     75    public static const BOOL IsHPC = false; 
     76 
     77    // PORTING_FIXME, is it Windows WFSP? 
     78    public static const BOOL IsSP_ = false; 
     79 
    7780    public static const BOOL IsDBLocale; 
    7881 
     
    116119        IsWin95 = (info.dwPlatformId is VER_PLATFORM_WIN32_WINDOWS); 
    117120        IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT); 
    118         IsSP_ = false; 
     121        //IsSP_ = false; 
    119122        IsPPC_ = false; 
    120         IsHPC = false; 
     123        //IsHPC = false; 
    121124        IsDBLocale = false; 
    122125        WIN32_MAJOR = info.dwMajorVersion; 
     
    38773880    alias WINAPI.GetCharacterPlacementA GetCharacterPlacement; 
    38783881    alias WINAPI.GetClassInfoA GetClassInfo; 
     3882    alias STDWIN.GetClassNameA GetClassName; 
    38793883    alias WINAPI.GetClipboardFormatNameA GetClipboardFormatName; 
    38803884    alias WINAPI.GetKeyNameTextA GetKeyNameText; 
     
    39743978    alias WINAPI.GetCharacterPlacementW GetCharacterPlacement; 
    39753979    alias WINAPI.GetClassInfoW GetClassInfo; 
     3980    alias STDWIN.GetClassNameW GetClassName; 
    39763981    alias WINAPI.GetClipboardFormatNameW GetClipboardFormatName; 
    39773982    alias WINAPI.GetKeyNameTextW GetKeyNameText; 
  • dwt/widgets/Button.d

    r31 r39  
    1616 
    1717class Button : Control{ 
     18void setDefault (bool value) ; 
     19void click () ; 
    1820} 
    1921 
  • dwt/widgets/Decorations.d

    r35 r39  
    1313module dwt.widgets.Decorations; 
    1414 
    15 import dwt.widgets.Canvas; 
    16 import dwt.widgets.Menu; 
    17 import dwt.widgets.Control; 
    18 import dwt.internal.win32.OS; 
    19  
    20 class Decorations : Canvas { 
    21 Menu findMenu (HMENU hMenu) ; 
    22 void bringToTop () ; 
    23 void fixDecorations (Decorations newDecorations, Control control, Menu [] menus) ; 
    24 void setSavedFocus (Control control) ; 
    25 public Menu getMenuBar () ; 
    26 void saveFocus () ; 
    27 
    28 /++ 
     15 
    2916import dwt.DWT; 
    3017import dwt.DWTException; 
     
    3320import dwt.graphics.Point; 
    3421import dwt.graphics.Rectangle; 
    35 import dwt.internal.win32.ACCEL; 
    36 import dwt.internal.win32.CREATESTRUCT; 
    37 import dwt.internal.win32.LRESULT; 
    38 import dwt.internal.win32.MENUITEMINFO; 
    39 import dwt.internal.win32.MSG; 
    4022import dwt.internal.win32.OS; 
    41 import dwt.internal.win32.RECT; 
    42 import dwt.internal.win32.STARTUPINFO; 
    43 import dwt.internal.win32.TCHAR; 
    44 import dwt.internal.win32.WINDOWPLACEMENT; 
    45 import dwt.internal.win32.WINDOWPOS; 
     23 
     24import dwt.widgets.Canvas; 
     25import dwt.widgets.Menu; 
     26import dwt.widgets.Control; 
     27import dwt.widgets.Button; 
     28import dwt.widgets.Composite; 
     29import dwt.widgets.Event; 
     30import dwt.widgets.Shell; 
     31import dwt.widgets.MenuItem; 
     32import dwt.widgets.Display; 
     33 
     34import dwt.dwthelper.utils; 
    4635 
    4736/** 
     
    123112 */ 
    124113 
    125 public class Decorations extends Canvas { 
     114public class Decorations : Canvas { 
    126115    Image image, smallImage, largeImage; 
    127116    Image [] images; 
     
    130119    Control savedFocus; 
    131120    Button defaultButton, saveDefault; 
    132     int swFlags, hAccel, nAccel; 
     121    int swFlags; 
     122    HACCEL hAccel; 
     123    int nAccel; 
    133124    bool moved, resized, opened; 
    134125    int oldX = OS.CW_USEDEFAULT, oldY = OS.CW_USEDEFAULT; 
     
    138129 * Prevents uninitialized instances from being created outside the package. 
    139130 */ 
    140 Decorations () { 
     131this () { 
    141132} 
    142133 
     
    179170 * @see Widget#getStyle 
    180171 */ 
    181 public Decorations (Composite parent, int style) { 
     172public this (Composite parent, int style) { 
    182173    super (parent, checkStyle (style)); 
    183174} 
     
    191182        */ 
    192183        if (maximized) { 
    193             RECT rect = new RECT ()
    194             OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0); 
     184            RECT rect
     185            OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); 
    195186            int width = rect.right - rect.left, height = rect.bottom - rect.top; 
    196             if (OS.IsPPC) { 
     187            if (OS.IsPPC_) { 
    197188                /* Leave space for the menu bar */ 
    198189                if (menuBar !is null) { 
    199                     int hwndCB = menuBar.hwndCB; 
    200                     RECT rectCB = new RECT ()
    201                     OS.GetWindowRect (hwndCB, rectCB); 
     190                    auto hwndCB = menuBar.hwndCB; 
     191                    RECT rectCB
     192                    OS.GetWindowRect (hwndCB, &rectCB); 
    202193                    height -= rectCB.bottom - rectCB.top; 
    203194                } 
    204195            } 
    205196            int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; 
    206             SetWindowPos (handle, 0, rect.left, rect.top, width, height, flags); 
     197            SetWindowPos (handle, null, rect.left, rect.top, width, height, flags); 
    207198        } 
    208199    } else { 
     
    321312} 
    322313 
    323 int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    324     if (handle is 0) return 0
    325     return OS.DefMDIChildProc (hwnd, msg, wParam, lParam); 
     314override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     315    if (handle is null) return LRESULT.ZERO
     316    return cast(LRESULT) OS.DefMDIChildProc (hwnd, msg, wParam, lParam); 
    326317} 
    327318 
     
    366357 
    367358    /* Get the size of the trimmings */ 
    368     RECT rect = new RECT ()
    369     OS.SetRect (rect, x, y, x + width, y + height); 
     359    RECT rect
     360    OS.SetRect (&rect, x, y, x + width, y + height); 
    370361    int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 
    371362    int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 
    372     bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is 0
    373     OS.AdjustWindowRectEx (rect, bits1, hasMenu, bits2); 
     363    bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is null
     364    OS.AdjustWindowRectEx (&rect, bits1, hasMenu, bits2); 
    374365 
    375366    /* Get the size of the scroll bars */ 
     
    379370    /* Compute the height of the menu bar */ 
    380371    if (hasMenu) { 
    381         RECT testRect = new RECT ()
    382         OS.SetRect (testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); 
    383         OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect); 
     372        RECT testRect
     373        OS.SetRect (&testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); 
     374        OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &testRect); 
    384375        while ((testRect.bottom - testRect.top) < height) { 
    385376            if (testRect.bottom - testRect.top is 0) break; 
    386377            rect.top -= OS.GetSystemMetrics (OS.SM_CYMENU) - OS.GetSystemMetrics (OS.SM_CYBORDER); 
    387             OS.SetRect (testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); 
    388             OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect); 
     378            OS.SetRect (&testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top); 
     379            OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, &testRect); 
    389380        } 
    390381    } 
     
    393384 
    394385void createAccelerators () { 
    395     hAccel = nAccel = 0; 
     386    hAccel = null; 
     387    nAccel = 0; 
    396388    int maxAccel = 0; 
    397389    MenuItem [] items = display.items; 
    398390    if (menuBar is null || items is null) { 
    399         if (!OS.IsPPC) return; 
     391        if (!OS.IsPPC_) return; 
    400392        maxAccel = 1; 
    401393    } else { 
    402         maxAccel = OS.IsPPC ? items.length + 1 : items.length; 
    403     } 
    404     ACCEL accel = new ACCEL ()
     394        maxAccel = OS.IsPPC_ ? items.length + 1 : items.length; 
     395    } 
     396    ACCEL accel
    405397    byte [] buffer1 = new byte [ACCEL.sizeof]; 
    406398    byte [] buffer2 = new byte [maxAccel * ACCEL.sizeof]; 
     
    415407                    } 
    416408                    if (menu is menuBar) { 
    417                         item.fillAccel (accel); 
    418                         OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 
     409                        item.fillAccel (&accel); 
     410                        *cast(ACCEL*)buffer1.ptr = accel; 
     411                        //OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 
    419412                        System.arraycopy (buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof); 
    420413                        nAccel++; 
     
    424417        } 
    425418    } 
    426     if (OS.IsPPC) { 
     419    if (OS.IsPPC_) { 
    427420        /* 
    428421        * Note on WinCE PPC.  Close the shell when user taps CTRL-Q. 
    429422        * IDOK represents the "Done Button" which also closes the shell. 
    430423        */ 
    431         accel.fVirt = (byte) (OS.FVIRTKEY | OS.FCONTROL); 
    432         accel.key = (short) 'Q'; 
    433         accel.cmd = (short) OS.IDOK; 
    434         OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 
     424        accel.fVirt = cast(byte) (OS.FVIRTKEY | OS.FCONTROL); 
     425        accel.key = cast(short) 'Q'; 
     426        accel.cmd = cast(short) OS.IDOK; 
     427        *cast(ACCEL*)buffer1.ptr = accel; 
     428        //OS.MoveMemory (buffer1, accel, ACCEL.sizeof); 
    435429        System.arraycopy (buffer1, 0, buffer2, nAccel * ACCEL.sizeof, ACCEL.sizeof); 
    436430        nAccel++; 
    437431    } 
    438     if (nAccel !is 0) hAccel = OS.CreateAcceleratorTable (buffer2, nAccel); 
     432    if (nAccel !is 0) hAccel = OS.CreateAcceleratorTable ( cast(ACCEL*)buffer2.ptr, nAccel); 
    439433} 
    440434 
     
    457451    if ((state & FOREIGN_HANDLE) is 0) { 
    458452        if (!OS.IsWinCE) { 
    459             int hIcon = OS.LoadIcon (0, OS.IDI_APPLICATION); 
     453            auto hIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); 
    460454            OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_SMALL, hIcon); 
    461455        } 
     
    466460    super.createWidget (); 
    467461    swFlags = OS.IsWinCE ? OS.SW_SHOWMAXIMIZED : OS.SW_SHOWNOACTIVATE; 
    468     hAccel = -1; 
     462    hAccel = cast(HACCEL)-1; 
    469463} 
    470464 
    471465void destroyAccelerators () { 
    472     if (hAccel !is 0 && hAccel !is -1) OS.DestroyAcceleratorTable (hAccel); 
    473     hAccel = -1; 
     466    if (hAccel !is null && hAccel !is cast(HACCEL)-1) OS.DestroyAcceleratorTable (hAccel); 
     467    hAccel = cast(HACCEL)-1; 
    474468} 
    475469 
     
    477471    if (isDisposed()) return; 
    478472    if (!isValidThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); 
    479     if (!(this instanceof Shell)) { 
     473    if (!(cast(Shell)this)) { 
    480474        if (!traverseDecorations (true)) { 
    481475            Shell shell = getShell (); 
     
    487481} 
    488482 
    489 Menu findMenu (int hMenu) { 
     483Menu findMenu (HMENU hMenu) { 
    490484    if (menus is null) return null; 
    491485    for (int i=0; i<menus.length; i++) { 
     
    522516    if (!OS.IsWinCE) { 
    523517        if (OS.IsIconic (handle)) { 
    524             WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ()
     518            WINDOWPLACEMENT lpwndpl
    525519            lpwndpl.length = WINDOWPLACEMENT.sizeof; 
    526             OS.GetWindowPlacement (handle, lpwndpl); 
    527             int width = lpwndpl.right - lpwndpl.left; 
    528             int height = lpwndpl.bottom - lpwndpl.top; 
    529             return new Rectangle (lpwndpl.left, lpwndpl.top, width, height); 
     520            OS.GetWindowPlacement (handle, &lpwndpl); 
     521            int width = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left; 
     522            int height = lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top; 
     523            return new Rectangle (lpwndpl.rcNormalPosition.left, lpwndpl.rcNormalPosition.top, width, height); 
    530524        } 
    531525    } 
     
    540534    * subtract the height of the CommandBar. 
    541535    */ 
    542     if (OS.IsHPC) { 
     536    static if (OS.IsHPC) { 
    543537        Rectangle rect = super.getClientArea (); 
    544538        if (menuBar !is null) { 
    545             int hwndCB = menuBar.hwndCB; 
     539            auto hwndCB = menuBar.hwndCB; 
    546540            int height = OS.CommandBar_Height (hwndCB); 
    547541            rect.y += height; 
     
    550544        return rect; 
    551545    } 
    552     if (!OS.IsWinCE) { 
     546    static if (!OS.IsWinCE) { 
    553547        if (OS.IsIconic (handle)) { 
    554             WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ()
     548            WINDOWPLACEMENT lpwndpl
    555549            lpwndpl.length = WINDOWPLACEMENT.sizeof; 
    556             OS.GetWindowPlacement (handle, lpwndpl); 
    557             int width = lpwndpl.right - lpwndpl.left; 
    558             int height = lpwndpl.bottom - lpwndpl.top; 
     550            OS.GetWindowPlacement (handle, &lpwndpl); 
     551            int width = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left; 
     552            int height = lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top; 
    559553            /* 
    560554            * Feature in Windows.  For some reason WM_NCCALCSIZE does 
     
    570564            if (horizontalBar !is null) width -= OS.GetSystemMetrics (OS.SM_CYHSCROLL); 
    571565            if (verticalBar !is null) height -= OS.GetSystemMetrics (OS.SM_CXVSCROLL); 
    572             RECT rect = new RECT ()
     566            RECT rect
    573567            int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 
    574568            int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 
    575             bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is 0
    576             OS.AdjustWindowRectEx (rect, bits1, hasMenu, bits2); 
     569            bool hasMenu = OS.IsWinCE ? false : OS.GetMenu (handle) !is null
     570            OS.AdjustWindowRectEx (&rect, bits1, hasMenu, bits2); 
    577571            width = Math.max (0, width - (rect.right - rect.left)); 
    578572            height = Math.max (0, height - (rect.bottom - rect.top)); 
     
    666660    if (!OS.IsWinCE) { 
    667661        if (OS.IsIconic (handle)) { 
    668             WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ()
     662            WINDOWPLACEMENT lpwndpl
    669663            lpwndpl.length = WINDOWPLACEMENT.sizeof; 
    670             OS.GetWindowPlacement (handle, lpwndpl); 
    671             return new Point (lpwndpl.left, lpwndpl.top); 
     664            OS.GetWindowPlacement (handle, &lpwndpl); 
     665            return new Point (lpwndpl.rcNormalPosition.left, lpwndpl.rcNormalPosition.top); 
    672666        } 
    673667    } 
     
    691685public bool getMaximized () { 
    692686    checkWidget (); 
    693     if (OS.IsWinCE) return swFlags is OS.SW_SHOWMAXIMIZED; 
    694     if (OS.IsWindowVisible (handle)) return OS.IsZoomed (handle); 
     687    static if (OS.IsWinCE) return swFlags is OS.SW_SHOWMAXIMIZED; 
     688    if (OS.IsWindowVisible (handle)) return cast(bool) OS.IsZoomed (handle); 
    695689    return swFlags is OS.SW_SHOWMAXIMIZED; 
    696690} 
     
    728722public bool getMinimized () { 
    729723    checkWidget (); 
    730     if (OS.IsWinCE) return false; 
    731     if (OS.IsWindowVisible (handle)) return OS.IsIconic (handle); 
     724    static if (OS.IsWinCE) return false; 
     725    if (OS.IsWindowVisible (handle)) return cast(bool) OS.IsIconic (handle); 
    732726    return swFlags is OS.SW_SHOWMINNOACTIVE; 
    733727} 
    734728 
    735 String getNameText () { 
     729char[] getNameText () { 
    736730    return getText (); 
    737731} 
     
    739733public Point getSize () { 
    740734    checkWidget (); 
    741     if (!OS.IsWinCE) { 
     735    static if (!OS.IsWinCE) { 
    742736        if (OS.IsIconic (handle)) { 
    743             WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ()
     737            WINDOWPLACEMENT lpwndpl
    744738            lpwndpl.length = WINDOWPLACEMENT.sizeof; 
    745             OS.GetWindowPlacement (handle, lpwndpl); 
    746             int width = lpwndpl.right - lpwndpl.left; 
    747             int height = lpwndpl.bottom - lpwndpl.top; 
     739            OS.GetWindowPlacement (handle, &lpwndpl); 
     740            int width = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left; 
     741            int height = lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top; 
    748742            return new Point (width, height); 
    749743        } 
     
    765759 * </ul> 
    766760 */ 
    767 public String getText () { 
     761public char[] getText () { 
    768762    checkWidget (); 
    769763    int length = OS.GetWindowTextLength (handle); 
    770764    if (length is 0) return ""; 
    771765    /* Use the character encoding for the default locale */ 
    772     TCHAR buffer = new TCHAR (0, length + 1); 
    773     OS.GetWindowText (handle, buffer, length + 1); 
    774     return buffer.toString (0, length); 
     766    TCHAR[] buffer; 
     767    buffer.length = length + 1; 
     768    OS.GetWindowText (handle, buffer.ptr, length + 1); 
     769    return TCHARsToStr( buffer ); 
    775770} 
    776771 
     
    829824    savedFocus = null; 
    830825    defaultButton = saveDefault = null; 
    831     if (hAccel !is 0 && hAccel !is -1) OS.DestroyAcceleratorTable (hAccel); 
    832     hAccel = -1; 
     826    if (hAccel !is null && hAccel !is cast(HACCEL)-1) OS.DestroyAcceleratorTable (hAccel); 
     827    hAccel = cast(HACCEL)-1; 
    833828} 
    834829 
     
    875870    } 
    876871    forceResize (); 
    877     RECT rect = new RECT ()
    878     OS.GetWindowRect (handle, rect); 
     872    RECT rect
     873    OS.GetWindowRect (handle, &rect); 
    879874    bool sameOrigin = true; 
    880875    if ((OS.SWP_NOMOVE & flags) is 0) { 
     
    887882        if (!sameExtent) resized = true; 
    888883    } 
    889     if (!OS.IsWinCE) { 
     884    static if (!OS.IsWinCE) { 
    890885        if (OS.IsZoomed (handle)) { 
    891886            if (sameOrigin && sameExtent) return; 
     
    991986    if (largeImage !is null) largeImage.dispose (); 
    992987    smallImage = largeImage = null; 
    993     int hSmallIcon = 0, hLargeIcon = 0
     988    HICON hSmallIcon, hLargeIcon
    994989    Image smallIcon = null, largeIcon = null; 
    995990    if (image !is null) { 
     
    10381033        */ 
    10391034        if ((state & FOREIGN_HANDLE) is 0) { 
    1040             hSmallIcon = OS.LoadIcon (0, OS.IDI_APPLICATION); 
     1035            hSmallIcon = OS.LoadIcon (null, cast(wchar*)OS.IDI_APPLICATION); 
    10411036        } 
    10421037    } 
     
    10631058    */ 
    10641059    if (!OS.IsWinCE) { 
    1065         if (hSmallIcon is 0 && hLargeIcon is 0 && (style & DWT.BORDER) !is 0) { 
     1060        if (hSmallIcon is null && hLargeIcon is null && (style & DWT.BORDER) !is 0) { 
    10661061            int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE; 
    1067             OS.RedrawWindow (handle, null, 0, flags); 
     1062            OS.RedrawWindow (handle, null, null, flags); 
    10681063        } 
    10691064    } 
     
    11561151        if (menu.parent !is this) error (DWT.ERROR_INVALID_PARENT); 
    11571152    } 
    1158     if (OS.IsWinCE) { 
     1153    static if (OS.IsWinCE) { 
    11591154        if (OS.IsHPC) { 
    11601155            bool resize = menuBar !is menu; 
     
    11711166            } 
    11721167        } else { 
    1173             if (OS.IsPPC) { 
     1168            if (OS.IsPPC_) { 
    11741169                /* 
    11751170                * Note in WinCE PPC.  The menu bar is a separate popup window. 
     
    11921187        if (menu !is null) display.removeBar (menu); 
    11931188        menuBar = menu; 
    1194         int hMenu = menuBar !is null ? menuBar.handle: 0
     1189        auto hMenu = menuBar !is null ? menuBar.handle: null
    11951190        OS.SetMenu (handle, hMenu); 
    11961191    } 
     
    12361231    * feature. 
    12371232    */ 
    1238     int hwndParent = parent.handle; 
     1233    auto hwndParent = parent.handle; 
    12391234    display.lockActiveWindow = true; 
    12401235    OS.SetParent (handle, hwndParent); 
     
    12471242    OS.SetWindowLong (handle, OS.GWL_ID, 0); 
    12481243    int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE; 
    1249     SetWindowPos (handle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags); 
     1244    SetWindowPos (handle, cast(HWND)OS.HWND_BOTTOM, 0, 0, 0, 0, flags); 
    12501245    display.lockActiveWindow = false; 
    12511246} 
    12521247 
    12531248void setPlacement (int x, int y, int width, int height, int flags) { 
    1254     WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ()
     1249    WINDOWPLACEMENT lpwndpl
    12551250    lpwndpl.length = WINDOWPLACEMENT.sizeof; 
    1256     OS.GetWindowPlacement (handle, lpwndpl); 
     1251    OS.GetWindowPlacement (handle, &lpwndpl); 
    12571252    lpwndpl.showCmd = OS.SW_SHOWNA; 
    12581253    if (OS.IsIconic (handle)) { 
     
    12651260    bool sameOrigin = true; 
    12661261    if ((flags & OS.SWP_NOMOVE) is 0) { 
    1267         sameOrigin = lpwndpl.left !is x || lpwndpl.top !is y; 
    1268         lpwndpl.right = x + (lpwndpl.right - lpwndpl.left); 
    1269         lpwndpl.bottom = y + (lpwndpl.bottom - lpwndpl.top); 
    1270         lpwndpl.left = x; 
    1271         lpwndpl.top = y; 
     1262        sameOrigin = lpwndpl.rcNormalPosition.left !is x || lpwndpl.rcNormalPosition.top !is y; 
     1263        lpwndpl.rcNormalPosition.right = x + (lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left); 
     1264        lpwndpl.rcNormalPosition.bottom = y + (lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top); 
     1265        lpwndpl.rcNormalPosition.left = x; 
     1266        lpwndpl.rcNormalPosition.top = y; 
    12721267    } 
    12731268    bool sameExtent = true; 
    12741269    if ((flags & OS.SWP_NOSIZE) is 0) { 
    1275         sameExtent = lpwndpl.right - lpwndpl.left !is width || lpwndpl.bottom - lpwndpl.top !is height; 
    1276         lpwndpl.right = lpwndpl.left + width; 
    1277         lpwndpl.bottom = lpwndpl.top + height; 
    1278     } 
    1279     OS.SetWindowPlacement (handle, lpwndpl); 
     1270        sameExtent = lpwndpl.rcNormalPosition.right - lpwndpl.rcNormalPosition.left !is width || lpwndpl.rcNormalPosition.bottom - lpwndpl.rcNormalPosition.top !is height; 
     1271        lpwndpl.rcNormalPosition.right = lpwndpl.rcNormalPosition.left + width; 
     1272        lpwndpl.rcNormalPosition.bottom = lpwndpl.rcNormalPosition.top + height; 
     1273    } 
     1274    OS.SetWindowPlacement (handle, &lpwndpl); 
    12801275    if (OS.IsIconic (handle)) { 
    12811276        if (sameOrigin) { 
     
    12941289            sendEvent (DWT.Resize); 
    12951290            if (isDisposed ()) return; 
    1296             if (layout !is null) { 
     1291            if (layout_ !is null) { 
    12971292                markLayout (false, false); 
    12981293                updateLayout (true, false); 
     
    13071302 
    13081303void setSystemMenu () { 
    1309     if (OS.IsWinCE) return; 
    1310     int hMenu = OS.GetSystemMenu (handle, false); 
    1311     if (hMenu is 0) return; 
     1304    static if (OS.IsWinCE) return; 
     1305    auto hMenu = OS.GetSystemMenu (handle, false); 
     1306    if (hMenu is null) return; 
    13121307    int oldCount = OS.GetMenuItemCount (hMenu); 
    13131308    if ((style & DWT.RESIZE) is 0) { 
     
    13261321    if ((style & DWT.CLOSE) is 0 || newCount !is oldCount) { 
    13271322        OS.DeleteMenu (hMenu, OS.SC_TASKLIST, OS.MF_BYCOMMAND); 
    1328         MENUITEMINFO info = new MENUITEMINFO ()
     1323        MENUITEMINFO info
    13291324        info.cbSize = MENUITEMINFO.sizeof; 
    13301325        info.fMask = OS.MIIM_ID; 
    13311326        int index = 0; 
    13321327        while (index < newCount) { 
    1333             if (OS.GetMenuItemInfo (hMenu, index, true, info)) { 
     1328            if (OS.GetMenuItemInfo (hMenu, index, true, &info)) { 
    13341329                if (info.wID is OS.SC_CLOSE) break; 
    13351330            } 
     
    13601355 * </ul> 
    13611356 */ 
    1362 public void setText (String string) { 
     1357public void setText (char[] string) { 
    13631358    checkWidget (); 
    13641359    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    13651360    /* Use the character encoding for the default locale */ 
    1366     TCHAR buffer = new TCHAR (0, string, true); 
    1367     OS.SetWindowText (handle, buffer); 
     1361    OS.SetWindowText (handle, StrToTCHARz(string)); 
    13681362} 
    13691363 
     
    13831377        sendEvent (DWT.Show); 
    13841378        if (isDisposed ()) return; 
    1385         if (OS.IsHPC) { 
     1379        static if (OS.IsHPC) { 
    13861380            if (menuBar !is null) { 
    1387                 int hwndCB = menuBar.hwndCB; 
     1381                auto hwndCB = menuBar.hwndCB; 
    13881382                OS.CommandBar_DrawMenuBar (hwndCB, 0); 
    13891383            } 
     
    13921386            state &= ~HIDDEN; 
    13931387        } else { 
    1394             if (OS.IsWinCE) { 
     1388            static if (OS.IsWinCE) { 
    13951389                OS.ShowWindow (handle, OS.SW_SHOW); 
    13961390            } else { 
     
    13991393                    OS.DrawMenuBar (handle); 
    14001394                } 
    1401                 STARTUPINFO lpStartUpInfo = Display.lpStartupInfo; 
     1395                STARTUPINFO* lpStartUpInfo = Display.lpStartupInfo; 
    14021396                if (lpStartUpInfo !is null && (lpStartUpInfo.dwFlags & OS.STARTF_USESHOWWINDOW) !is 0) { 
    14031397                    OS.ShowWindow (handle, lpStartUpInfo.wShowWindow); 
     
    14231417        } 
    14241418    } else { 
    1425         if (!OS.IsWinCE) { 
     1419        static if (!OS.IsWinCE) { 
    14261420            if (OS.IsIconic (handle)) { 
    14271421                swFlags = OS.SW_SHOWMINNOACTIVE; 
     
    14681462} 
    14691463 
    1470 bool translateAccelerator (MSG msg) { 
     1464bool translateAccelerator (MSG* msg) { 
    14711465    if (!isEnabled () || !isActive ()) return false; 
    14721466    if (menuBar !is null && !menuBar.isEnabled ()) return false; 
     
    14761470} 
    14771471 
    1478 bool translateMenuAccelerator (MSG msg) { 
    1479     if (hAccel is -1) createAccelerators (); 
    1480     return hAccel !is 0 && OS.TranslateAccelerator (handle, hAccel, msg) !is 0; 
    1481 } 
    1482  
    1483 bool translateMDIAccelerator (MSG msg) { 
    1484     if (!(this instanceof Shell)) { 
     1472bool translateMenuAccelerator (MSG* msg) { 
     1473    if (hAccel is cast(HACCEL)-1) createAccelerators (); 
     1474    return hAccel !is null && OS.TranslateAccelerator (handle, hAccel, msg) !is 0; 
     1475} 
     1476 
     1477bool translateMDIAccelerator (MSG* msg) { 
     1478    if (!(cast(Shell)this)) { 
    14851479        Shell shell = getShell (); 
    1486         int hwndMDIClient = shell.hwndMDIClient
    1487         if (hwndMDIClient !is 0 && OS.TranslateMDISysAccel (hwndMDIClient, msg)) { 
     1480        auto hwndMDIClient = shell.hwndMDIClient_
     1481        if (hwndMDIClient !is null && OS.TranslateMDISysAccel (hwndMDIClient, msg)) { 
    14881482            return true; 
    14891483        } 
     
    15281522    while ((index = (index + offset + length) % length) !is start) { 
    15291523        Control child = children [index]; 
    1530         if (!child.isDisposed () && child instanceof Decorations) { 
     1524        if (!child.isDisposed () && ( null !is cast(Decorations)child)) { 
    15311525            if (child.setFocus ()) return true; 
    15321526        } 
     
    15461540} 
    15471541 
    1548 CREATESTRUCT widgetCreateStruct () { 
     1542CREATESTRUCT* widgetCreateStruct () { 
    15491543    return new CREATESTRUCT (); 
    15501544} 
     
    15541548    bits &= ~OS.WS_EX_CLIENTEDGE; 
    15551549    if ((style & DWT.NO_TRIM) !is 0) return bits; 
    1556     if (OS.IsPPC) { 
     1550    if (OS.IsPPC_) { 
    15571551        if ((style & DWT.CLOSE) !is 0) bits |= OS.WS_EX_CAPTIONOKBTN; 
    15581552    } 
     
    15621556} 
    15631557 
    1564 int widgetParent () { 
     1558HWND widgetParent () { 
    15651559    Shell shell = getShell (); 
    15661560    return shell.hwndMDIClient (); 
     
    15911585        * It does not set the WS_THICKFRAME style. 
    15921586        */ 
    1593         if (!OS.IsPPC) bits |= OS.WS_THICKFRAME; 
     1587        if (!OS.IsPPC_) bits |= OS.WS_THICKFRAME; 
    15941588    } else { 
    15951589        if ((style & DWT.BORDER) is 0) bits |= OS.WS_BORDER; 
     
    15971591 
    15981592    /* Set the system menu and close box bits */ 
    1599     if (!OS.IsPPC && !OS.IsSP) { 
     1593    if (!OS.IsPPC_ && !OS.IsSP_) { 
    16001594        if ((style & DWT.CLOSE) !is 0) bits |= OS.WS_SYSMENU; 
    16011595    } 
     
    16041598} 
    16051599 
    1606 int windowProc (int hwnd, int msg, int wParam, int lParam) { 
     1600override int windowProc (HWND hwnd, int msg, int wParam, int lParam) { 
    16071601    switch (msg) { 
    16081602        case Display.SWT_GETACCEL: 
    16091603        case Display.SWT_GETACCELCOUNT: 
    1610             if (hAccel is -1) createAccelerators (); 
    1611             return msg is Display.SWT_GETACCELCOUNT ? nAccel : hAccel; 
     1604            if (hAccel is cast(HACCEL)-1) createAccelerators (); 
     1605            return msg is Display.SWT_GETACCELCOUNT ? nAccel : cast(int)hAccel; 
    16121606    } 
    16131607    return super.windowProc (hwnd, msg, wParam, lParam); 
     
    16161610LRESULT WM_ACTIVATE (int wParam, int lParam) { 
    16171611    LRESULT result = super.WM_ACTIVATE (wParam, lParam); 
    1618     if (result !is null) return result; 
     1612    if (result !is LRESULT.NULL) return result; 
    16191613    /* 
    16201614    * Feature in AWT.  When an AWT Window is activated, 
     
    16291623    * WM_ACTIVATE messages that come from AWT Windows. 
    16301624    */ 
    1631     if (OS.GetParent (lParam) is handle) { 
    1632         TCHAR buffer = new TCHAR (0, 128)
    1633         OS.GetClassName (lParam, buffer, buffer.length ()); 
    1634         String className = buffer.toString (0, buffer.strlen ()); 
    1635         if (className.equals (Display.AWT_WINDOW_CLASS)) { 
     1625    if (OS.GetParent ( cast(HWND)lParam) is handle) { 
     1626        TCHAR[128] buffer = 0
     1627        OS.GetClassName (cast(HWND)lParam, buffer.ptr, buffer.length ); 
     1628        char[] className = TCHARzToStr( buffer.ptr ); 
     1629        if (className == Display.AWT_WINDOW_CLASS) { 
    16361630            return LRESULT.ZERO; 
    16371631        } 
     
    16451639        */ 
    16461640        if ((wParam >> 16) !is 0) return result; 
    1647         Control control = display.findControl (lParam); 
    1648         if (control is null || control instanceof Shell) { 
    1649             if (this instanceof Shell) { 
     1641        Control control = display.findControl (cast(HWND)lParam); 
     1642        if (control is null || (null !is cast(Shell)control)) { 
     1643            if (cast(Shell)this) { 
    16501644                sendEvent (DWT.Activate); 
    16511645                if (isDisposed ()) return LRESULT.ZERO; 
     
    16571651        bool lockWindow = display.isXMouseActive (); 
    16581652        if (lockWindow) display.lockActiveWindow = true; 
    1659         Control control = display.findControl (lParam); 
    1660         if (control is null || control instanceof Shell) { 
    1661             if (this instanceof Shell) { 
     1653        Control control = display.findControl (cast(HWND)lParam); 
     1654        if (control is null || (null !is cast(Shell)control)) { 
     1655            if (cast(Shell)this) { 
    16621656                sendEvent (DWT.Deactivate); 
    16631657                if (!isDisposed ()) { 
     
    16771671LRESULT WM_CLOSE (int wParam, int lParam) { 
    16781672    LRESULT result = super.WM_CLOSE (wParam, lParam); 
    1679     if (result !is null) return result; 
     1673    if (result !is LRESULT.NULL) return result; 
    16801674    if (isEnabled () && isActive ()) closeWidget (); 
    16811675    return LRESULT.ZERO; 
     
    16841678LRESULT WM_HOTKEY (int wParam, int lParam) { 
    16851679    LRESULT result = super.WM_HOTKEY (wParam, lParam); 
    1686     if (result !is null) return result; 
    1687     if (OS.IsSP) { 
    1688         /* 
    1689         * Feature on WinCE SP.  The Back key is either used to close 
    1690         * the foreground Dialog or used as a regular Back key in an EDIT 
    1691         * control. The article 'Back Key' in MSDN for Smartphone 
    1692         * describes how an application should handle it.  The 
    1693         * workaround is to override the Back key when creating 
    1694         * the menubar and handle it based on the style of the Shell. 
    1695         * If the Shell has the DWT.CLOSE style, close the Shell. 
    1696         * Otherwise, send the Back key to the window with focus. 
    1697         */ 
    1698         if (((lParam >> 16) & 0xFFFF) is OS.VK_ESCAPE) { 
    1699             if ((style & DWT.CLOSE) !is 0) { 
    1700                 OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); 
    1701             } else { 
    1702                 OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam); 
    1703             } 
    1704             return LRESULT.ZERO; 
     1680    if (result !is LRESULT.NULL) return result; 
     1681    static if( OS.IsWinCE ){ 
     1682        if (OS.IsSP_) { 
     1683            /* 
     1684            * Feature on WinCE SP.  The Back key is either used to close 
     1685            * the foreground Dialog or used as a regular Back key in an EDIT 
     1686            * control. The article 'Back Key' in MSDN for Smartphone 
     1687            * describes how an application should handle it.  The 
     1688            * workaround is to override the Back key when creating 
     1689            * the menubar and handle it based on the style of the Shell. 
     1690            * If the Shell has the DWT.CLOSE style, close the Shell. 
     1691            * Otherwise, send the Back key to the window with focus. 
     1692            */ 
     1693            if (((lParam >> 16) & 0xFFFF) is OS.VK_ESCAPE) { 
     1694                if ((style & DWT.CLOSE) !is 0) { 
     1695                    OS.PostMessage (handle, OS.WM_CLOSE, 0, 0); 
     1696                } else { 
     1697                    OS.SHSendBackToFocusWindow (OS.WM_HOTKEY, wParam, lParam); 
     1698                } 
     1699                return LRESULT.ZERO; 
     1700            } 
    17051701        } 
    17061702    } 
     
    17181714        Point location = getLocation (); 
    17191715        if (location.x is oldX && location.y is oldY) { 
    1720             return null
     1716            return LRESULT.NULL
    17211717        } 
    17221718        oldX = location.x; 
     
    17281724LRESULT WM_NCACTIVATE (int wParam, int lParam) { 
    17291725    LRESULT result = super.WM_NCACTIVATE (wParam, lParam); 
    1730     if (result !is null) return result; 
     1726    if (result !is LRESULT.NULL) return result; 
    17311727    if (wParam is 0) { 
    17321728        if (display.lockActiveWindow) return LRESULT.ZERO; 
    1733         Control control = display.findControl (lParam); 
     1729        Control control = display.findControl (cast(HANDLE)lParam); 
    17341730        if (control !is null) { 
    17351731            Shell shell = getShell (); 
    17361732            Decorations decorations = control.menuShell (); 
    17371733            if (decorations.getShell () is shell) { 
    1738                 if (this instanceof Shell) return LRESULT.ONE; 
     1734                if (cast(Shell)this) return LRESULT.ONE; 
    17391735                if (display.ignoreRestoreFocus) { 
    17401736                    if (display.lastHittest !is OS.HTCLIENT) { 
     
    17451741        } 
    17461742    } 
    1747     if (!(this instanceof Shell)) { 
    1748         int hwndShell = getShell().handle; 
     1743    if (!(cast(Shell)this)) { 
     1744        auto hwndShell = getShell().handle; 
    17491745        OS.SendMessage (hwndShell, OS.WM_NCACTIVATE, wParam, lParam); 
    17501746    } 
     
    17541750LRESULT WM_QUERYOPEN (int wParam, int lParam) { 
    17551751    LRESULT result = super.WM_QUERYOPEN (wParam, lParam); 
    1756     if (result !is null) return result; 
     1752    if (result !is LRESULT.NULL) return result; 
    17571753    sendEvent (DWT.Deiconify); 
    17581754    // widget could be disposed at this point 
     
    17671763 
    17681764LRESULT WM_SIZE (int wParam, int lParam) { 
    1769     LRESULT result = null
     1765    LRESULT result = LRESULT.NULL
    17701766    bool changed = true; 
    17711767    if (resized) { 
     
    18021798LRESULT WM_SYSCOMMAND (int wParam, int lParam) { 
    18031799    LRESULT result = super.WM_SYSCOMMAND (wParam, lParam); 
    1804     if (result !is null) return result; 
    1805     if (!(this instanceof Shell)) { 
     1800    if (result !is LRESULT.NULL) return result; 
     1801    if (!(cast(Shell)this)) { 
    18061802        int cmd = wParam & 0xFFF0; 
    18071803        switch (cmd) { 
     
    18211817LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { 
    18221818    LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam); 
    1823     if (result !is null) return result; 
     1819    if (result !is LRESULT.NULL) return result; 
    18241820    if (display.lockActiveWindow) { 
    1825         WINDOWPOS lpwp = new WINDOWPOS ()
    1826         OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); 
     1821        WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam
     1822        //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof); 
    18271823        lpwp.flags |= OS.SWP_NOZORDER; 
    1828         OS.MoveMemory (lParam, lpwp, WINDOWPOS.sizeof); 
     1824        //OS.MoveMemory (lParam, &lpwp, WINDOWPOS.sizeof); 
    18291825    } 
    18301826    return result; 
     
    18321828 
    18331829} 
    1834 ++/ 
  • dwt/widgets/Display.d

    r37 r39  
    211211 
    212212    /* Startup info */ 
    213     static STARTUPINFO lpStartupInfo; 
     213    static STARTUPINFO* lpStartupInfo; 
    214214    static this() { 
    215215        static if (!OS.IsWinCE) { 
    216             //lpStartupInfo = new STARTUPINFO (); 
     216            lpStartupInfo = new STARTUPINFO (); 
    217217            lpStartupInfo.cb = STARTUPINFO.sizeof; 
    218             OS.GetStartupInfo (&lpStartupInfo); 
     218            OS.GetStartupInfo (lpStartupInfo); 
    219219        } 
    220220    } 
     
    33883388public bool readAndDispatch () { 
    33893389    checkDevice (); 
    3390     //lpStartupInfo = null; 
     3390    lpStartupInfo = null; 
    33913391    drawMenuBars (); 
    33923392    runPopups (); 
  • dwt/widgets/Menu.d

    r35 r39  
    1616import dwt.widgets.Decorations; 
    1717import dwt.widgets.MenuItem; 
     18import dwt.internal.win32.OS; 
    1819 
    1