Changeset 56:dcb2e04003ac

Show
Ignore:
Timestamp:
02/04/08 06:34:19 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Menu

Files:

Legend:

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

    r55 r56  
    6868    version(WinCE){ 
    6969        public const static BOOL IsWinCE = true; 
     70        public static const BOOL IsHPC = false; //todo 
    7071    }else{ 
    7172        public const static BOOL IsWinCE = false; 
     73        public static const BOOL IsHPC = false; 
    7274    } 
    7375 
    7476    public static const BOOL IsPPC_ = false; 
    75     public static const BOOL IsHPC = false; 
    7677 
    7778    // PORTING_FIXME, is it Windows WFSP? 
     
    771772    public static const int GW_HWNDPREV = 0x3; 
    772773    public static const int GW_OWNER = 0x4; 
    773     public static const int HBMMENU_CALLBACK = 0xffffffff; 
     774    public static const HBITMAP HBMMENU_CALLBACK = cast(HBITMAP) 0xffffffff; 
    774775    public static const int HCBT_CREATEWND = 3; 
    775776    public static const int HCF_HIGHCONTRASTON = 0x1; 
  • dwt/internal/win32/WINTYPES.d

    r52 r56  
    947947* that the correct struct size is used for the Windows platform. 
    948948*/ 
    949 struct MENUITEMINFOA 
    950 
    951     UINT    cbSize; 
    952     UINT    fMask; 
    953     UINT    fType;          // used if MIIM_TYPE 
    954     UINT    fState;         // used if MIIM_STATE 
    955     UINT    wID;            // used if MIIM_ID 
    956     HMENU   hSubMenu;       // used if MIIM_SUBMENU 
    957     HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS 
    958     HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS 
    959     DWORD   dwItemData;     // used if MIIM_DATA 
    960     LPSTR   dwTypeData;     // used if MIIM_TYPE 
    961     UINT    cch;            // used if MIIM_TYPE 
    962     HBITMAP hbmpItem; 
    963 
    964 alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA; 
    965 struct MENUITEMINFOW 
    966 
    967     UINT    cbSize; 
    968     UINT    fMask; 
    969     UINT    fType;          // used if MIIM_TYPE 
    970     UINT    fState;         // used if MIIM_STATE 
    971     UINT    wID;            // used if MIIM_ID 
    972     HMENU   hSubMenu;       // used if MIIM_SUBMENU 
    973     HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS 
    974     HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS 
    975     DWORD   dwItemData;     // used if MIIM_DATA 
    976     LPWSTR  dwTypeData;     // used if MIIM_TYPE 
    977     UINT    cch;            // used if MIIM_TYPE 
    978     HBITMAP hbmpItem; 
    979 }   alias MENUITEMINFOW* PMENUITEMINFOW, LPMENUITEMINFOW; 
     949// struct MENUITEMINFOA 
     950//
     951//     UINT    cbSize; 
     952//     UINT    fMask; 
     953//     UINT    fType;          // used if MIIM_TYPE 
     954//     UINT    fState;         // used if MIIM_STATE 
     955//     UINT    wID;            // used if MIIM_ID 
     956//     HMENU   hSubMenu;       // used if MIIM_SUBMENU 
     957//     HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS 
     958//     HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS 
     959//     DWORD   dwItemData;     // used if MIIM_DATA 
     960//     LPSTR   dwTypeData;     // used if MIIM_TYPE 
     961//     UINT    cch;            // used if MIIM_TYPE 
     962//     HBITMAP hbmpItem; 
     963//
     964// alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA; 
     965// struct MENUITEMINFOW 
     966//
     967//     UINT    cbSize; 
     968//     UINT    fMask; 
     969//     UINT    fType;          // used if MIIM_TYPE 
     970//     UINT    fState;         // used if MIIM_STATE 
     971//     UINT    wID;            // used if MIIM_ID 
     972//     HMENU   hSubMenu;       // used if MIIM_SUBMENU 
     973//     HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS 
     974//     HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS 
     975//     DWORD   dwItemData;     // used if MIIM_DATA 
     976//     LPWSTR  dwTypeData;     // used if MIIM_TYPE 
     977//     UINT    cch;            // used if MIIM_TYPE 
     978//     HBITMAP hbmpItem; 
     979// }   alias MENUITEMINFOW* PMENUITEMINFOW, LPMENUITEMINFOW; 
    980980//version(ANSI){ 
    981981//    alias MENUITEMINFOA MENUITEMINFO; 
     
    18111811alias SHITEMID* LPCSHITEMID; 
    18121812 
    1813 version(WinCE) 
    1814 
     1813//version(WinCE) 
     1814//
    18151815    struct SHMENUBARINFO { 
    18161816        int cbSize; 
     
    18391839        VOID *pvImData; 
    18401840    } 
    1841 } // end of version WinCE 
     1841//} // end of version WinCE 
    18421842 
    18431843//struct SIZE { 
  • dwt/widgets/Menu.d

    r54 r56  
    1313module dwt.widgets.Menu; 
    1414 
    15 import dwt.widgets.Widget; 
    16 import dwt.widgets.Decorations; 
    17 import dwt.widgets.MenuItem; 
    18 import dwt.internal.win32.OS; 
    19  
    20 class Menu : Widget { 
    21     int x, y; 
    22     HBRUSH hBrush; 
    23     HWND hwndCB; 
    24     int id0, id1; 
    25     MenuItem cascade; 
    26     Decorations parent; 
    27     HMENU handle; 
    28     this( Widget, int ); 
    29 public void setLocation (int x, int y) ; 
    30 public void setVisible (bool visible) ; 
    31 void update (); 
    32 void _setVisible (bool visible) ; 
    33 public Menu getParentMenu () ; 
    34 public MenuItem [] getItems () ; 
    35 void fixMenus (Decorations newParent) ; 
    36 public bool isEnabled () ; 
    37 public bool getEnabled () ; 
    38 } 
    39 /++ 
    4015import dwt.DWT; 
    4116import dwt.DWTException; 
     
    4722import dwt.graphics.Rectangle; 
    4823import dwt.internal.ImageList; 
    49 import dwt.internal.win32.MENUBARINFO; 
    50 import dwt.internal.win32.MENUINFO; 
    51 import dwt.internal.win32.MENUITEMINFO; 
    5224import dwt.internal.win32.OS; 
    53 import dwt.internal.win32.RECT; 
    54 import dwt.internal.win32.SHMENUBARINFO; 
    55 import dwt.internal.win32.TBBUTTON; 
    56 import dwt.internal.win32.TBBUTTONINFO; 
    57 import dwt.internal.win32.TCHAR; 
     25 
     26import dwt.widgets.Widget; 
     27import dwt.widgets.Decorations; 
     28import dwt.widgets.MenuItem; 
     29import dwt.widgets.Control; 
     30import dwt.widgets.Shell; 
     31import dwt.widgets.TypedListener; 
     32 
     33import dwt.dwthelper.utils; 
    5834 
    5935/** 
     
    7551 */ 
    7652 
    77 public class Menu extends Widget { 
     53public class Menu : Widget { 
    7854    /** 
    7955     * the handle to the OS resource 
     
    8662     * </p> 
    8763     */ 
    88     public int handle; 
    89  
    90     int x, y, hBrush, hwndCB, id0, id1; 
     64    public HMENU handle; 
     65 
     66    int x, y; 
     67    HBRUSH hBrush; 
     68    HWND hwndCB; 
     69    int id0, id1; 
    9170    int foreground = -1, background = -1; 
    9271    Image backgroundImage; 
     
    9776 
    9877    /* Resource ID for SHMENUBARINFO */ 
    99     static final int ID_PPC = 100; 
     78    static const int ID_PPC = 100; 
    10079 
    10180    /* SmartPhone SoftKeyBar resource ids */ 
    102     static final int ID_SPMM = 102; 
    103     static final int ID_SPBM = 103; 
    104     static final int ID_SPMB = 104; 
    105     static final int ID_SPBB = 105; 
    106     static final int ID_SPSOFTKEY0 = 106; 
    107     static final int ID_SPSOFTKEY1 = 107; 
     81    static const int ID_SPMM = 102; 
     82    static const int ID_SPBM = 103; 
     83    static const int ID_SPMB = 104; 
     84    static const int ID_SPBB = 105; 
     85    static const int ID_SPSOFTKEY0 = 106; 
     86    static const int ID_SPSOFTKEY1 = 107; 
    10887 
    10988/** 
     
    126105 * @see Widget#getStyle 
    127106 */ 
    128 public Menu (Control parent) { 
     107public this (Control parent) { 
    129108    this (checkNull (parent).menuShell (), DWT.POP_UP); 
    130109} 
     
    161140 * @see Widget#getStyle 
    162141 */ 
    163 public Menu (Decorations parent, int style) { 
    164     this (parent, checkStyle (style), 0); 
     142public this (Decorations parent, int style) { 
     143    this (parent, checkStyle (style), null); 
    165144} 
    166145 
     
    185164 * @see Widget#getStyle 
    186165 */ 
    187 public Menu (Menu parentMenu) { 
     166public this (Menu parentMenu) { 
    188167    this (checkNull (parentMenu).parent, DWT.DROP_DOWN); 
    189168} 
     
    209188 * @see Widget#getStyle 
    210189 */ 
    211 public Menu (MenuItem parentItem) { 
     190public this (MenuItem parentItem) { 
    212191    this (checkNull (parentItem).parent); 
    213192} 
    214193 
    215 Menu (Decorations parent, int style, int handle) { 
     194this (Decorations parent, int style, HWND handle) { 
    216195    super (parent, checkStyle (style)); 
    217196    this.parent = parent; 
     
    237216void _setVisible (bool visible) { 
    238217    if ((style & (DWT.BAR | DWT.DROP_DOWN)) !is 0) return; 
    239     int hwndParent = parent.handle; 
     218    auto hwndParent = parent.handle; 
    240219    if (visible) { 
    241220        int flags = OS.TPM_LEFTBUTTON; 
     
    249228        if (!hasLocation) { 
    250229            int pos = OS.GetMessagePos (); 
    251             nX = (short) (pos & 0xFFFF); 
    252             nY = (short) (pos >> 16); 
     230            nX = cast(short) (pos & 0xFFFF); 
     231            nY = cast(short) (pos >> 16); 
    253232        } 
    254233        /* 
     
    265244        * the menu is zero and issue a fake WM_MENUSELECT. 
    266245        */ 
    267         bool success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null); 
     246        bool success = cast(bool) OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null); 
    268247        if (!success && GetMenuItemCount (handle) is 0) { 
    269248            OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0); 
     
    347326 
    348327void createHandle () { 
    349     if (handle !is 0) return; 
     328    if (handle !is null) return; 
    350329    if ((style & DWT.BAR) !is 0) { 
    351         if (OS.IsPPC) { 
    352             int hwndShell = parent.handle; 
    353             SHMENUBARINFO mbi = new SHMENUBARINFO ()
     330        static if( OS.IsWinCE ) if (OS.IsPPC) { 
     331            auto hwndShell = parent.handle; 
     332            SHMENUBARINFO mbi
    354333            mbi.cbSize = SHMENUBARINFO.sizeof; 
    355334            mbi.hwndParent = hwndShell; 
     
    357336            mbi.nToolBarId = ID_PPC; 
    358337            mbi.hInstRes = OS.GetLibraryHandle (); 
    359             bool success = OS.SHCreateMenuBar (mbi); 
     338            bool success = cast(bool) OS.SHCreateMenuBar (&mbi); 
    360339            hwndCB = mbi.hwndMB; 
    361340            if (!success) error (DWT.ERROR_NO_HANDLES); 
     
    373352        *    2 buttons 
    374353        */ 
    375         if (OS.IsSP) { 
     354        static if (OS.IsSP_) { 
    376355            /* Determine type of menubar */ 
    377356            int nToolBarId; 
     
    383362 
    384363            /* Create SHMENUBAR */ 
    385             SHMENUBARINFO mbi = new SHMENUBARINFO ()
     364            SHMENUBARINFO mbi
    386365            mbi.cbSize = SHMENUBARINFO.sizeof; 
    387366            mbi.hwndParent = parent.handle; 
     
    389368            mbi.nToolBarId = nToolBarId; /* as defined in .rc file */ 
    390369            mbi.hInstRes = OS.GetLibraryHandle (); 
    391             if (!OS.SHCreateMenuBar (mbi)) error (DWT.ERROR_NO_HANDLES); 
     370            if (!OS.SHCreateMenuBar (&mbi)) error (DWT.ERROR_NO_HANDLES); 
    392371            hwndCB = mbi.hwndMB; 
    393372 
     
    441420        } 
    442421        handle = OS.CreateMenu (); 
    443         if (handle is 0) error (DWT.ERROR_NO_HANDLES); 
    444         if (OS.IsHPC) { 
    445             int hwndShell = parent.handle; 
     422        if (handle is null) error (DWT.ERROR_NO_HANDLES); 
     423        static if (OS.IsHPC) { 
     424            auto hwndShell = parent.handle; 
    446425            hwndCB = OS.CommandBar_Create (OS.GetModuleHandle (null), hwndShell, 1); 
    447             if (hwndCB is 0) error (DWT.ERROR_NO_HANDLES); 
     426            if (hwndCB is null) error (DWT.ERROR_NO_HANDLES); 
    448427            OS.CommandBar_Show (hwndCB, false); 
    449428            OS.CommandBar_InsertMenubarEx (hwndCB, 0, handle, 0); 
     
    458437    } else { 
    459438        handle = OS.CreatePopupMenu (); 
    460         if (handle is 0) error (DWT.ERROR_NO_HANDLES); 
     439        if (handle is null) error (DWT.ERROR_NO_HANDLES); 
    461440    } 
    462441} 
     
    467446    display.addMenuItem (item); 
    468447    bool success = false; 
    469     if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) { 
    470         if (OS.IsSP) return; 
    471         TBBUTTON lpButton = new TBBUTTON ()
     448    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) { 
     449        if (OS.IsSP_) return; 
     450        TBBUTTON lpButton
    472451        lpButton.idCommand = item.id; 
    473         lpButton.fsStyle = (byte) OS.TBSTYLE_AUTOSIZE; 
     452        lpButton.fsStyle = cast(byte) OS.TBSTYLE_AUTOSIZE; 
    474453        if ((item.style & DWT.CASCADE) !is 0) lpButton.fsStyle |= OS.TBSTYLE_DROPDOWN | 0x80; 
    475         if ((item.style & DWT.SEPARATOR) !is 0) lpButton.fsStyle = (byte) OS.BTNS_SEP; 
    476         lpButton.fsState = (byte) OS.TBSTATE_ENABLED; 
     454        if ((item.style & DWT.SEPARATOR) !is 0) lpButton.fsStyle = cast(byte) OS.BTNS_SEP; 
     455        lpButton.fsState = cast(byte) OS.TBSTATE_ENABLED; 
    477456        lpButton.iBitmap = OS.I_IMAGENONE; 
    478         success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, lpButton) !is 0; 
     457        success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, &lpButton) !is 0; 
    479458    } else { 
    480         if (OS.IsWinCE) { 
     459        static if (OS.IsWinCE) { 
    481460            int uFlags = OS.MF_BYPOSITION; 
    482461            TCHAR lpNewItem = null; 
     
    507486            * space. 
    508487            */ 
    509             int hHeap = OS.GetProcessHeap (); 
    510             TCHAR buffer = new TCHAR (0, " ", true); 
    511             int byteCount = buffer.length () * TCHAR.sizeof; 
    512             int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    513             OS.MoveMemory (pszText, buffer, byteCount); 
    514             MENUITEMINFO info = new MENUITEMINFO ()
     488            auto hHeap = OS.GetProcessHeap (); 
     489            TCHAR[] buffer = StrToTCHARs (0, " \0"); 
     490            int byteCount = (buffer.length-1) * TCHAR.sizeof; 
     491            auto pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     492            OS.MoveMemory (pszText, buffer.ptr, byteCount); 
     493            MENUITEMINFO info
    515494            info.cbSize = MENUITEMINFO.sizeof; 
    516495            info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA; 
     
    518497            info.fType = item.widgetStyle (); 
    519498            info.dwTypeData = pszText; 
    520             success = OS.InsertMenuItem (handle, index, true, info); 
    521             if (pszText !is 0) OS.HeapFree (hHeap, 0, pszText); 
     499            success = cast(bool) OS.InsertMenuItem (handle, index, true, &info); 
     500            if (pszText !is null) OS.HeapFree (hHeap, 0, pszText); 
    522501        } 
    523502    } 
     
    563542void destroyItem (MenuItem item) { 
    564543    if (OS.IsWinCE) { 
    565         if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) { 
    566             if (OS.IsSP) { 
     544        if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) { 
     545            if (OS.IsSP_) { 
    567546                redraw(); 
    568547                return; 
     
    582561        } else { 
    583562            int index = 0; 
    584             MENUITEMINFO info = new MENUITEMINFO ()
     563            MENUITEMINFO info
    585564            info.cbSize = MENUITEMINFO.sizeof; 
    586565            info.fMask = OS.MIIM_DATA; 
    587             while (OS.GetMenuItemInfo (handle, index, true, info)) { 
     566            while (OS.GetMenuItemInfo (handle, index, true, &info)) { 
    588567                if (info.dwItemData is item.id) break; 
    589568                index++; 
     
    605584 
    606585override void destroyWidget () { 
    607     int hMenu = handle, hCB = hwndCB; 
     586    HMENU hMenu = handle; 
     587    HWND hCB = hwndCB; 
    608588    releaseHandle (); 
    609     if (OS.IsWinCE && hCB !is 0) { 
    610         OS.CommandBar_Destroy (hCB); 
     589    if (OS.IsWinCE && hCB !is null) { 
     590        static if( OS.IsWinCE ){ 
     591            OS.CommandBar_Destroy (hCB); 
     592        } 
    611593    } else { 
    612         if (hMenu !is 0) OS.DestroyMenu (hMenu); 
     594        if (hMenu !is null) OS.DestroyMenu (hMenu); 
    613595    } 
    614596} 
     
    685667            return new Rectangle (0, 0, 0, 0); 
    686668        } 
    687         int hwndShell = parent.handle; 
    688         MENUBARINFO info = new MENUBARINFO ()
     669        auto hwndShell = parent.handle; 
     670        MENUBARINFO info
    689671        info.cbSize = MENUBARINFO.sizeof; 
    690         if (OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 0, info)) { 
    691             int width = info.right - info.left; 
    692             int height = info.bottom - info.top; 
    693             return new Rectangle (info.left, info.top, width, height); 
     672        if (OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 0, &info)) { 
     673            int width = info.rcBar.right - info.rcBar.left; 
     674            int height = info.rcBar.bottom - info.rcBar.top; 
     675            return new Rectangle (info.rcBar.left, info.rcBar.top, width, height); 
    694676        } 
    695677    } else { 
    696678        int count = GetMenuItemCount (handle); 
    697679        if (count !is 0) { 
    698             RECT rect1 = new RECT ()
    699             if (OS.GetMenuItemRect (0, handle, 0, rect1)) { 
    700                 RECT rect2 = new RECT ()
    701                 if (OS.GetMenuItemRect (0, handle, count - 1, rect2)) { 
     680            RECT rect1
     681            if (OS.GetMenuItemRect (null, handle, 0, &rect1)) { 
     682                RECT rect2
     683                if (OS.GetMenuItemRect (null, handle, count - 1, &rect2)) { 
    702684                    int x = rect1.left - 2, y = rect1.top - 2; 
    703685                    int width = (rect2.right - rect2.left) + 4; 
     
    728710    int id = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED); 
    729711    if (id is -1) return null; 
    730     MENUITEMINFO info = new MENUITEMINFO ()
     712    MENUITEMINFO info
    731713    info.cbSize = MENUITEMINFO.sizeof; 
    732714    info.fMask = OS.MIIM_ID; 
    733     if (OS.GetMenuItemInfo (handle, id, false, info)) { 
     715    if (OS.GetMenuItemInfo (handle, id, false, &info)) { 
    734716        return display.getMenuItem (info.wID); 
    735717    } 
     
    790772    checkWidget (); 
    791773    int id = 0; 
    792     if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) { 
    793         if (OS.IsPPC) { 
    794             TBBUTTON lpButton = new TBBUTTON ()
    795             int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, lpButton); 
     774    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) { 
     775        static if (OS.IsPPC_) { 
     776            TBBUTTON lpButton
     777            int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, &lpButton); 
    796778            if (result is 0) error (DWT.ERROR_CANNOT_GET_ITEM); 
    797779            id = lpButton.idCommand; 
    798780        } 
    799         if (OS.IsSP) { 
     781        if (OS.IsSP_) { 
    800782            if (!(0 <= index && index <= 1)) error (DWT.ERROR_CANNOT_GET_ITEM); 
    801783            id = index is 0 ? id0 : id1; 
    802784        } 
    803785    } else { 
    804         MENUITEMINFO info = new MENUITEMINFO ()
     786        MENUITEMINFO info
    805787        info.cbSize = MENUITEMINFO.sizeof; 
    806788        info.fMask = OS.MIIM_DATA; 
    807         if (!OS.GetMenuItemInfo (handle, index, true, info)) { 
     789        if (!OS.GetMenuItemInfo (handle, index, true, &info)) { 
    808790            error (DWT.ERROR_INVALID_RANGE); 
    809791        } 
     
    846828public MenuItem [] getItems () { 
    847829    checkWidget (); 
    848     if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) { 
    849         if (OS.IsSP) { 
     830    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) { 
     831        if (OS.IsSP_) { 
    850832            MenuItem [] result = new MenuItem [2]; 
    851833            result[0] = display.getMenuItem (id0); 
     
    854836        } 
    855837        int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0); 
    856         TBBUTTON lpButton = new TBBUTTON ()
     838        TBBUTTON lpButton
    857839        MenuItem [] result = new MenuItem [count]; 
    858840        for (int i=0; i<count; i++) { 
    859             OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, lpButton); 
     841            OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, &lpButton); 
    860842            result [i] = display.getMenuItem (lpButton.idCommand); 
    861843        } 
     
    865847    int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle); 
    866848    MenuItem [] items = new MenuItem [length]; 
    867     MENUITEMINFO info = new MENUITEMINFO ()
     849    MENUITEMINFO info
    868850    info.cbSize = MENUITEMINFO.sizeof; 
    869851    info.fMask = OS.MIIM_DATA; 
    870     while (OS.GetMenuItemInfo (handle, index, true, info)) { 
     852    while (OS.GetMenuItemInfo (handle, index, true, &info)) { 
    871853        if (count is items.length) { 
    872854            MenuItem [] newItems = new MenuItem [count + 4]; 
     
    884866} 
    885867 
    886 int GetMenuItemCount (int handle) { 
     868int GetMenuItemCount (HANDLE handle) { 
    887869    if (OS.IsWinCE) { 
    888         if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) { 
    889             return OS.IsSP ? 2 : OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0); 
     870        if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) { 
     871            return OS.IsSP_ ? 2 : OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0); 
    890872        } 
    891873        int count = 0; 
    892         MENUITEMINFO info = new MENUITEMINFO ()
     874        MENUITEMINFO info
    893875        info.cbSize = MENUITEMINFO.sizeof; 
    894         while (OS.GetMenuItemInfo (handle, count, true, info)) count++; 
     876        while (OS.GetMenuItemInfo (handle, count, true, &info)) count++; 
    895877        return count; 
    896878    } 
     
    898880} 
    899881 
    900 override String getNameText () { 
    901     String result = ""; 
     882override char[] getNameText () { 
     883    char[] result = ""; 
    902884    MenuItem [] items = getItems (); 
    903     int length = items.length; 
    904     if (length > 0) { 
    905         for (int i=0; i<length-1; i++) { 
    906             result = result + items [i].getNameText() + ", "; 
    907         } 
    908         result = result + items [length-1].getNameText (); 
     885    int length_ = items.length; 
     886    if (length_ > 0) { 
     887        for (int i=0; i<length_-1; i++) { 
     888            result = result ~ items [i].getNameText() ~ ", "; 
     889        } 
     890        result = result ~ items [length_-1].getNameText (); 
    909891    } 
    910892    return result; 
     
    10191001 
    10201002int imageIndex (Image image) { 
    1021     if (hwndCB is 0 || image is null) return OS.I_IMAGENONE; 
     1003    if (hwndCB is null || image is null) return OS.I_IMAGENONE; 
    10221004    if (imageList is null) { 
    10231005        Rectangle bounds = image.getBounds (); 
    10241006        imageList = display.getImageList (style & DWT.RIGHT_TO_LEFT, bounds.width, bounds.height); 
    10251007        int index = imageList.add (image); 
    1026         int hImageList = imageList.getHandle (); 
     1008        HANDLE hImageList = imageList.getHandle (); 
    10271009        OS.SendMessage (hwndCB, OS.TB_SETIMAGELIST, 0, hImageList); 
    10281010        return index; 
     
    10591041    if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT); 
    10601042    if (item.parent !is this) return -1; 
    1061     if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) { 
    1062         if (OS.IsPPC) { 
     1043    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) { 
     1044        if (OS.IsPPC_) { 
    10631045            return OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0); 
    10641046        } 
    1065         if (OS.IsSP) { 
     1047        if (OS.IsSP_) { 
    10661048            if (item.id is id0) return 0; 
    10671049            if (item.id is id1) return 1; 
     
    10701052    } 
    10711053    int index = 0; 
    1072     MENUITEMINFO info = new MENUITEMINFO ()
     1054    MENUITEMINFO info
    10731055    info.cbSize = MENUITEMINFO.sizeof; 
    10741056    info.fMask = OS.MIIM_DATA; 
    1075     while (OS.GetMenuItemInfo (handle, index, true, info)) { 
     1057    while (OS.GetMenuItemInfo (handle, index, true, &info)) { 
    10761058        if (info.dwItemData is item.id) return index; 
    10771059        index++; 
     
    11341116override void releaseHandle () { 
    11351117    super.releaseHandle (); 
    1136     handle = hwndCB = 0; 
     1118    handle = null; 
     1119    hwndCB = null; 
    11371120} 
    11381121 
     
    11421125        MenuItem item = items [i]; 
    11431126        if (item !is null && !item.isDisposed ()) { 
    1144             if (OS.IsPPC && hwndCB !is 0) { 
     1127            if (OS.IsPPC_ && hwndCB !is null) { 
    11451128                item.dispose (); 
    11461129            } else { 
     
    11701153    super.releaseWidget (); 
    11711154    backgroundImage = null; 
    1172     if (hBrush is 0) OS.DeleteObject (hBrush); 
    1173     hBrush = 0
    1174     if (OS.IsPPC && hwndCB !is 0) { 
     1155    if (hBrush is null) OS.DeleteObject (hBrush); 
     1156    hBrush = null
     1157    if (OS.IsPPC_ && hwndCB !is null) { 
    11751158        if (imageList !is null) { 
    11761159            OS.SendMessage (hwndCB, OS.TB_SETIMAGELIST, 0, 0); 
     
    14551438 
    14561439void update () { 
    1457     if (OS.IsPPC || OS.IsSP) return; 
    1458     if (OS.IsHPC) { 
     1440    if (OS.IsPPC_ || OS.IsSP_) return; 
     1441    static if (OS.IsHPC) { 
    14591442        /* 
    14601443        * Each time a menu has been modified, the command menu bar 
     
    14881471        MenuItem item = items [i]; 
    14891472        if (item.image !is null) { 
    1490             if ((hasImage = true) && hasCheck) break; 
     1473            hasImage = true; 
     1474            if (hasCheck) break; 
    14911475        } 
    14921476        if ((item.style & (DWT.CHECK | DWT.RADIO)) !is 0) { 
    1493             if ((hasCheck = true) && hasImage) break; 
     1477            hasCheck = true; 
     1478            if ( hasImage) break; 
    14941479        } 
    14951480    } 
     
    15161501    if (!OS.IsWin95) { 
    15171502        if (OS.WIN32_VERSION < OS.VERSION (6, 0)) { 
    1518             MENUITEMINFO info = new MENUITEMINFO ()
     1503            MENUITEMINFO info
    15191504            info.cbSize = MENUITEMINFO.sizeof; 
    15201505            info.fMask = OS.MIIM_BITMAP; 
     
    15231508                if ((style & DWT.SEPARATOR) is 0) { 
    15241509                    if (item.image is null || foreground !is -1) { 
    1525                         info.hbmpItem = hasImage || foreground !is -1 ? OS.HBMMENU_CALLBACK : 0
    1526                         OS.SetMenuItemInfo (handle, item.id, false, info); 
     1510                        info.hbmpItem = hasImage || foreground !is -1 ? OS.HBMMENU_CALLBACK : null
     1511                        OS.SetMenuItemInfo (handle, item.id, false, &info); 
    15271512                    } 
    15281513                } 
     
    15321517 
    15331518    /* Update the menu to hide or show the space for bitmaps */ 
    1534     MENUINFO lpcmi = new MENUINFO ()
     1519    MENUINFO lpcmi
    15351520    lpcmi.cbSize = MENUINFO.sizeof; 
    15361521    lpcmi.fMask = OS.MIM_STYLE; 
    1537     OS.GetMenuInfo (handle, lpcmi); 
     1522    OS.GetMenuInfo (handle, &lpcmi); 
    15381523    if (hasImage && !hasCheck) { 
    15391524        lpcmi.dwStyle |= OS.MNS_CHECKORBMP; 
     
    15411526        lpcmi.dwStyle &= ~OS.MNS_CHECKORBMP; 
    15421527    } 
    1543     OS.SetMenuInfo (handle, lpcmi); 
     1528    OS.SetMenuInfo (handle, &lpcmi); 
    15441529} 
    15451530 
    15461531void updateBackground () { 
    1547     if (hBrush is 0) OS.DeleteObject (hBrush); 
    1548     hBrush = 0
     1532    if (hBrush is null) OS.DeleteObject (hBrush); 
     1533    hBrush = null
    15491534    if (backgroundImage !is null) { 
    15501535        hBrush = OS.CreatePatternBrush (backgroundImage.handle); 
     
    15521537        if (background !is -1) hBrush = OS.CreateSolidBrush (background); 
    15531538    } 
    1554     MENUINFO lpcmi = new MENUINFO ()
     1539    MENUINFO lpcmi
    15551540    lpcmi.cbSize = MENUINFO.sizeof; 
    15561541    lpcmi.fMask = OS.MIM_BACKGROUND; 
    15571542    lpcmi.hbrBack = hBrush; 
    1558     OS.SetMenuInfo (handle, lpcmi); 
     1543    OS.SetMenuInfo (handle, &lpcmi); 
    15591544} 
    15601545 
    15611546void updateForeground () { 
    15621547    if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return; 
    1563     MENUITEMINFO info = new MENUITEMINFO ()
     1548    MENUITEMINFO info
    15641549    info.cbSize = MENUITEMINFO.sizeof; 
    15651550    int index = 0; 
    1566     while (OS.GetMenuItemInfo (handle, index, true, info)) { 
     1551    while (OS.GetMenuItemInfo (handle, index, true, &info)) { 
    15671552        info.fMask = OS.MIIM_BITMAP; 
    15681553        info.hbmpItem = OS.HBMMENU_CALLBACK; 
    1569         OS.SetMenuItemInfo (handle, index, true, info); 
     1554        OS.SetMenuItemInfo (handle, index, true, &info); 
    15701555        index++; 
    15711556    } 
     
    15731558} 
    15741559} 
    1575 ++/ 
     1560 
  • dwt/widgets/MenuItem.d

    r54 r56  
    1616import dwt.widgets.Widget; 
    1717import dwt.widgets.Menu; 
     18import dwt.widgets.Decorations; 
    1819import dwt.internal.win32.OS; 
    1920 
     
    3233LRESULT wmMeasureChild (int wParam, int lParam) ; 
    3334void fillAccel (ACCEL* accel) ; 
     35int widgetStyle () ; 
     36void fixMenus (Decorations newParent) ; 
     37void releaseMenu () ; 
    3438} 
    3539/++ 
  • tango_sys_win32/Types.di

    r33 r56  
    1021410214alias MENUEX_TEMPLATE_ITEM* PMENUEXTEMPLATEITEM; 
    1021510215 
    10216 struct MENUITEMINFO 
    10217 
    10218     UINT cbSize; 
    10219     UINT fMask; 
    10220     UINT fType; 
    10221     UINT fState; 
    10222     UINT wID; 
    10223     HMENU hSubMenu; 
    10224     HBITMAP hbmpChecked; 
    10225     HBITMAP hbmpUnchecked; 
    10226     DWORD dwItemData; 
    10227     LPTSTR dwTypeData; 
    10228     UINT cch; 
    10229 
    10230  
    10231 alias MENUITEMINFO* LPMENUITEMINFO; 
    10232 alias MENUITEMINFO* LPCMENUITEMINFO; 
    10233 alias MENUITEMINFO TAGMENUITEMINFO; 
    10234 alias MENUITEMINFO TMENUITEMINFO; 
    10235 alias MENUITEMINFO TMENUITEMINFOA; 
    10236 alias MENUITEMINFO* PMENUITEMINFO; 
     10216/* 
     10217* Feature in Windows.  The hbmpItem field requires Windows 4.10 
     10218* or greater.  On Windows NT 4.0, passing in a larger struct size 
     10219* in the cbSize field does nothing.  On Windows 95, the MENUITEMINFO 
     10220* calls fail when the struct size is too large.  The fix is to ensure 
     10221* that the correct struct size is used for the Windows platform. 
     10222*/ 
     10223struct MENUITEMINFOA 
     10224
     10225    UINT    cbSize; 
     10226    UINT    fMask; 
     10227    UINT    fType;          // used if MIIM_TYPE 
     10228    UINT    fState;         // used if MIIM_STATE 
     10229    UINT    wID;            // used if MIIM_ID 
     10230    HMENU   hSubMenu;       // used if MIIM_SUBMENU 
     10231    HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS 
     10232    HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS 
     10233    DWORD   dwItemData;     // used if MIIM_DATA 
     10234    LPSTR   dwTypeData;     // used if MIIM_TYPE 
     10235    UINT    cch;            // used if MIIM_TYPE 
     10236    HBITMAP hbmpItem; 
     10237
     10238alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA; 
     10239struct MENUITEMINFOW 
     10240
     10241    UINT    cbSize; 
     10242    UINT    fMask; 
     10243    UINT    fType;          // used if MIIM_TYPE 
     10244    UINT    fState;         // used if MIIM_STATE 
     10245    UINT    wID;            // used if MIIM_ID 
     10246    HMENU   hSubMenu;       // used if MIIM_SUBMENU 
     10247    HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS 
     10248    HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS 
     10249    DWORD   dwItemData;     // used if MIIM_DATA 
     10250    LPWSTR  dwTypeData;     // used if MIIM_TYPE 
     10251    UINT    cch;            // used if MIIM_TYPE 
     10252    HBITMAP hbmpItem; 
     10253}   alias MENUITEMINFOW* PMENUITEMINFOW, LPMENUITEMINFOW; 
     10254version(ANSI){ 
     10255    alias MENUITEMINFOA MENUITEMINFO; 
     10256}else{ 
     10257    alias MENUITEMINFOW MENUITEMINFO; 
     10258
     10259alias MENUITEMINFO * LPMENUITEMINFO; 
     10260alias MENUITEMINFO * LPCMENUITEMINFO; 
     10261 
     10262// struct MENUITEMINFO 
     10263// { 
     10264//  UINT cbSize; 
     10265//  UINT fMask; 
     10266//  UINT fType; 
     10267//  UINT fState; 
     10268//  UINT wID; 
     10269//  HMENU hSubMenu; 
     10270//  HBITMAP hbmpChecked; 
     10271//  HBITMAP hbmpUnchecked; 
     10272//  DWORD dwItemData; 
     10273//  LPTSTR dwTypeData; 
     10274//  UINT cch; 
     10275// } 
     10276// 
     10277// alias MENUITEMINFO* LPMENUITEMINFO; 
     10278// alias MENUITEMINFO* LPCMENUITEMINFO; 
     10279// alias MENUITEMINFO TAGMENUITEMINFO; 
     10280// alias MENUITEMINFO TMENUITEMINFO; 
     10281// alias MENUITEMINFO TMENUITEMINFOA; 
     10282// alias MENUITEMINFO* PMENUITEMINFO; 
    1023710283 
    1023810284struct MENUITEMTEMPLATE