Changeset 56:dcb2e04003ac
- Timestamp:
- 02/04/08 06:34:19 (1 year ago)
- Files:
-
- dwt/internal/win32/OS.d (modified) (2 diffs)
- dwt/internal/win32/WINTYPES.d (modified) (3 diffs)
- dwt/widgets/Menu.d (modified) (47 diffs)
- dwt/widgets/MenuItem.d (modified) (2 diffs)
- tango_sys_win32/Types.di (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/internal/win32/OS.d
r55 r56 68 68 version(WinCE){ 69 69 public const static BOOL IsWinCE = true; 70 public static const BOOL IsHPC = false; //todo 70 71 }else{ 71 72 public const static BOOL IsWinCE = false; 73 public static const BOOL IsHPC = false; 72 74 } 73 75 74 76 public static const BOOL IsPPC_ = false; 75 public static const BOOL IsHPC = false;76 77 77 78 // PORTING_FIXME, is it Windows WFSP? … … 771 772 public static const int GW_HWNDPREV = 0x3; 772 773 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; 774 775 public static const int HCBT_CREATEWND = 3; 775 776 public static const int HCF_HIGHCONTRASTON = 0x1; dwt/internal/win32/WINTYPES.d
r52 r56 947 947 * that the correct struct size is used for the Windows platform. 948 948 */ 949 struct MENUITEMINFOA950 {951 UINT cbSize;952 UINT fMask;953 UINT fType; // used if MIIM_TYPE954 UINT fState; // used if MIIM_STATE955 UINT wID; // used if MIIM_ID956 HMENU hSubMenu; // used if MIIM_SUBMENU957 HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS958 HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS959 DWORD dwItemData; // used if MIIM_DATA960 LPSTR dwTypeData; // used if MIIM_TYPE961 UINT cch; // used if MIIM_TYPE962 HBITMAP hbmpItem;963 }964 alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA;965 struct MENUITEMINFOW966 {967 UINT cbSize;968 UINT fMask;969 UINT fType; // used if MIIM_TYPE970 UINT fState; // used if MIIM_STATE971 UINT wID; // used if MIIM_ID972 HMENU hSubMenu; // used if MIIM_SUBMENU973 HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS974 HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS975 DWORD dwItemData; // used if MIIM_DATA976 LPWSTR dwTypeData; // used if MIIM_TYPE977 UINT cch; // used if MIIM_TYPE978 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; 980 980 //version(ANSI){ 981 981 // alias MENUITEMINFOA MENUITEMINFO; … … 1811 1811 alias SHITEMID* LPCSHITEMID; 1812 1812 1813 version(WinCE)1814 {1813 //version(WinCE) 1814 //{ 1815 1815 struct SHMENUBARINFO { 1816 1816 int cbSize; … … 1839 1839 VOID *pvImData; 1840 1840 } 1841 } // end of version WinCE1841 //} // end of version WinCE 1842 1842 1843 1843 //struct SIZE { dwt/widgets/Menu.d
r54 r56 13 13 module dwt.widgets.Menu; 14 14 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 /++40 15 import dwt.DWT; 41 16 import dwt.DWTException; … … 47 22 import dwt.graphics.Rectangle; 48 23 import dwt.internal.ImageList; 49 import dwt.internal.win32.MENUBARINFO;50 import dwt.internal.win32.MENUINFO;51 import dwt.internal.win32.MENUITEMINFO;52 24 import 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 26 import dwt.widgets.Widget; 27 import dwt.widgets.Decorations; 28 import dwt.widgets.MenuItem; 29 import dwt.widgets.Control; 30 import dwt.widgets.Shell; 31 import dwt.widgets.TypedListener; 32 33 import dwt.dwthelper.utils; 58 34 59 35 /** … … 75 51 */ 76 52 77 public class Menu extendsWidget {53 public class Menu : Widget { 78 54 /** 79 55 * the handle to the OS resource … … 86 62 * </p> 87 63 */ 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; 91 70 int foreground = -1, background = -1; 92 71 Image backgroundImage; … … 97 76 98 77 /* Resource ID for SHMENUBARINFO */ 99 static finalint ID_PPC = 100;78 static const int ID_PPC = 100; 100 79 101 80 /* SmartPhone SoftKeyBar resource ids */ 102 static finalint ID_SPMM = 102;103 static finalint ID_SPBM = 103;104 static finalint ID_SPMB = 104;105 static finalint ID_SPBB = 105;106 static finalint ID_SPSOFTKEY0 = 106;107 static finalint 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; 108 87 109 88 /** … … 126 105 * @see Widget#getStyle 127 106 */ 128 public Menu(Control parent) {107 public this (Control parent) { 129 108 this (checkNull (parent).menuShell (), DWT.POP_UP); 130 109 } … … 161 140 * @see Widget#getStyle 162 141 */ 163 public Menu(Decorations parent, int style) {164 this (parent, checkStyle (style), 0);142 public this (Decorations parent, int style) { 143 this (parent, checkStyle (style), null); 165 144 } 166 145 … … 185 164 * @see Widget#getStyle 186 165 */ 187 public Menu(Menu parentMenu) {166 public this (Menu parentMenu) { 188 167 this (checkNull (parentMenu).parent, DWT.DROP_DOWN); 189 168 } … … 209 188 * @see Widget#getStyle 210 189 */ 211 public Menu(MenuItem parentItem) {190 public this (MenuItem parentItem) { 212 191 this (checkNull (parentItem).parent); 213 192 } 214 193 215 Menu (Decorations parent, int style, inthandle) {194 this (Decorations parent, int style, HWND handle) { 216 195 super (parent, checkStyle (style)); 217 196 this.parent = parent; … … 237 216 void _setVisible (bool visible) { 238 217 if ((style & (DWT.BAR | DWT.DROP_DOWN)) !is 0) return; 239 inthwndParent = parent.handle;218 auto hwndParent = parent.handle; 240 219 if (visible) { 241 220 int flags = OS.TPM_LEFTBUTTON; … … 249 228 if (!hasLocation) { 250 229 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); 253 232 } 254 233 /* … … 265 244 * the menu is zero and issue a fake WM_MENUSELECT. 266 245 */ 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); 268 247 if (!success && GetMenuItemCount (handle) is 0) { 269 248 OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0); … … 347 326 348 327 void createHandle () { 349 if (handle !is 0) return;328 if (handle !is null) return; 350 329 if ((style & DWT.BAR) !is 0) { 351 if (OS.IsPPC) {352 inthwndShell = parent.handle;353 SHMENUBARINFO mbi = new SHMENUBARINFO ();330 static if( OS.IsWinCE ) if (OS.IsPPC) { 331 auto hwndShell = parent.handle; 332 SHMENUBARINFO mbi; 354 333 mbi.cbSize = SHMENUBARINFO.sizeof; 355 334 mbi.hwndParent = hwndShell; … … 357 336 mbi.nToolBarId = ID_PPC; 358 337 mbi.hInstRes = OS.GetLibraryHandle (); 359 bool success = OS.SHCreateMenuBar (mbi);338 bool success = cast(bool) OS.SHCreateMenuBar (&mbi); 360 339 hwndCB = mbi.hwndMB; 361 340 if (!success) error (DWT.ERROR_NO_HANDLES); … … 373 352 * 2 buttons 374 353 */ 375 if (OS.IsSP) {354 static if (OS.IsSP_) { 376 355 /* Determine type of menubar */ 377 356 int nToolBarId; … … 383 362 384 363 /* Create SHMENUBAR */ 385 SHMENUBARINFO mbi = new SHMENUBARINFO ();364 SHMENUBARINFO mbi; 386 365 mbi.cbSize = SHMENUBARINFO.sizeof; 387 366 mbi.hwndParent = parent.handle; … … 389 368 mbi.nToolBarId = nToolBarId; /* as defined in .rc file */ 390 369 mbi.hInstRes = OS.GetLibraryHandle (); 391 if (!OS.SHCreateMenuBar ( mbi)) error (DWT.ERROR_NO_HANDLES);370 if (!OS.SHCreateMenuBar (&mbi)) error (DWT.ERROR_NO_HANDLES); 392 371 hwndCB = mbi.hwndMB; 393 372 … … 441 420 } 442 421 handle = OS.CreateMenu (); 443 if (handle is 0) error (DWT.ERROR_NO_HANDLES);444 if (OS.IsHPC) {445 inthwndShell = parent.handle;422 if (handle is null) error (DWT.ERROR_NO_HANDLES); 423 static if (OS.IsHPC) { 424 auto hwndShell = parent.handle; 446 425 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); 448 427 OS.CommandBar_Show (hwndCB, false); 449 428 OS.CommandBar_InsertMenubarEx (hwndCB, 0, handle, 0); … … 458 437 } else { 459 438 handle = OS.CreatePopupMenu (); 460 if (handle is 0) error (DWT.ERROR_NO_HANDLES);439 if (handle is null) error (DWT.ERROR_NO_HANDLES); 461 440 } 462 441 } … … 467 446 display.addMenuItem (item); 468 447 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; 472 451 lpButton.idCommand = item.id; 473 lpButton.fsStyle = (byte) OS.TBSTYLE_AUTOSIZE;452 lpButton.fsStyle = cast(byte) OS.TBSTYLE_AUTOSIZE; 474 453 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; 477 456 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; 479 458 } else { 480 if (OS.IsWinCE) {459 static if (OS.IsWinCE) { 481 460 int uFlags = OS.MF_BYPOSITION; 482 461 TCHAR lpNewItem = null; … … 507 486 * space. 508 487 */ 509 inthHeap = 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; 515 494 info.cbSize = MENUITEMINFO.sizeof; 516 495 info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA; … … 518 497 info.fType = item.widgetStyle (); 519 498 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); 522 501 } 523 502 } … … 563 542 void destroyItem (MenuItem item) { 564 543 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_) { 567 546 redraw(); 568 547 return; … … 582 561 } else { 583 562 int index = 0; 584 MENUITEMINFO info = new MENUITEMINFO ();563 MENUITEMINFO info; 585 564 info.cbSize = MENUITEMINFO.sizeof; 586 565 info.fMask = OS.MIIM_DATA; 587 while (OS.GetMenuItemInfo (handle, index, true, info)) {566 while (OS.GetMenuItemInfo (handle, index, true, &info)) { 588 567 if (info.dwItemData is item.id) break; 589 568 index++; … … 605 584 606 585 override void destroyWidget () { 607 int hMenu = handle, hCB = hwndCB; 586 HMENU hMenu = handle; 587 HWND hCB = hwndCB; 608 588 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 } 611 593 } else { 612 if (hMenu !is 0) OS.DestroyMenu (hMenu);594 if (hMenu !is null) OS.DestroyMenu (hMenu); 613 595 } 614 596 } … … 685 667 return new Rectangle (0, 0, 0, 0); 686 668 } 687 inthwndShell = parent.handle;688 MENUBARINFO info = new MENUBARINFO ();669 auto hwndShell = parent.handle; 670 MENUBARINFO info; 689 671 info.cbSize = MENUBARINFO.sizeof; 690 if (OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 0, info)) {691 int width = info.r ight - 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); 694 676 } 695 677 } else { 696 678 int count = GetMenuItemCount (handle); 697 679 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)) { 702 684 int x = rect1.left - 2, y = rect1.top - 2; 703 685 int width = (rect2.right - rect2.left) + 4; … … 728 710 int id = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED); 729 711 if (id is -1) return null; 730 MENUITEMINFO info = new MENUITEMINFO ();712 MENUITEMINFO info; 731 713 info.cbSize = MENUITEMINFO.sizeof; 732 714 info.fMask = OS.MIIM_ID; 733 if (OS.GetMenuItemInfo (handle, id, false, info)) {715 if (OS.GetMenuItemInfo (handle, id, false, &info)) { 734 716 return display.getMenuItem (info.wID); 735 717 } … … 790 772 checkWidget (); 791 773 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); 796 778 if (result is 0) error (DWT.ERROR_CANNOT_GET_ITEM); 797 779 id = lpButton.idCommand; 798 780 } 799 if (OS.IsSP ) {781 if (OS.IsSP_) { 800 782 if (!(0 <= index && index <= 1)) error (DWT.ERROR_CANNOT_GET_ITEM); 801 783 id = index is 0 ? id0 : id1; 802 784 } 803 785 } else { 804 MENUITEMINFO info = new MENUITEMINFO ();786 MENUITEMINFO info; 805 787 info.cbSize = MENUITEMINFO.sizeof; 806 788 info.fMask = OS.MIIM_DATA; 807 if (!OS.GetMenuItemInfo (handle, index, true, info)) {789 if (!OS.GetMenuItemInfo (handle, index, true, &info)) { 808 790 error (DWT.ERROR_INVALID_RANGE); 809 791 } … … 846 828 public MenuItem [] getItems () { 847 829 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_) { 850 832 MenuItem [] result = new MenuItem [2]; 851 833 result[0] = display.getMenuItem (id0); … … 854 836 } 855 837 int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0); 856 TBBUTTON lpButton = new TBBUTTON ();838 TBBUTTON lpButton; 857 839 MenuItem [] result = new MenuItem [count]; 858 840 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); 860 842 result [i] = display.getMenuItem (lpButton.idCommand); 861 843 } … … 865 847 int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle); 866 848 MenuItem [] items = new MenuItem [length]; 867 MENUITEMINFO info = new MENUITEMINFO ();849 MENUITEMINFO info; 868 850 info.cbSize = MENUITEMINFO.sizeof; 869 851 info.fMask = OS.MIIM_DATA; 870 while (OS.GetMenuItemInfo (handle, index, true, info)) {852 while (OS.GetMenuItemInfo (handle, index, true, &info)) { 871 853 if (count is items.length) { 872 854 MenuItem [] newItems = new MenuItem [count + 4]; … … 884 866 } 885 867 886 int GetMenuItemCount ( inthandle) {868 int GetMenuItemCount (HANDLE handle) { 887 869 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); 890 872 } 891 873 int count = 0; 892 MENUITEMINFO info = new MENUITEMINFO ();874 MENUITEMINFO info; 893 875 info.cbSize = MENUITEMINFO.sizeof; 894 while (OS.GetMenuItemInfo (handle, count, true, info)) count++;876 while (OS.GetMenuItemInfo (handle, count, true, &info)) count++; 895 877 return count; 896 878 } … … 898 880 } 899 881 900 override StringgetNameText () {901 Stringresult = "";882 override char[] getNameText () { 883 char[] result = ""; 902 884 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 (); 909 891 } 910 892 return result; … … 1019 1001 1020 1002 int 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; 1022 1004 if (imageList is null) { 1023 1005 Rectangle bounds = image.getBounds (); 1024 1006 imageList = display.getImageList (style & DWT.RIGHT_TO_LEFT, bounds.width, bounds.height); 1025 1007 int index = imageList.add (image); 1026 inthImageList = imageList.getHandle ();1008 HANDLE hImageList = imageList.getHandle (); 1027 1009 OS.SendMessage (hwndCB, OS.TB_SETIMAGELIST, 0, hImageList); 1028 1010 return index; … … 1059 1041 if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT); 1060 1042 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_) { 1063 1045 return OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0); 1064 1046 } 1065 if (OS.IsSP ) {1047 if (OS.IsSP_) { 1066 1048 if (item.id is id0) return 0; 1067 1049 if (item.id is id1) return 1; … … 1070 1052 } 1071 1053 int index = 0; 1072 MENUITEMINFO info = new MENUITEMINFO ();1054 MENUITEMINFO info; 1073 1055 info.cbSize = MENUITEMINFO.sizeof; 1074 1056 info.fMask = OS.MIIM_DATA; 1075 while (OS.GetMenuItemInfo (handle, index, true, info)) {1057 while (OS.GetMenuItemInfo (handle, index, true, &info)) { 1076 1058 if (info.dwItemData is item.id) return index; 1077 1059 index++; … … 1134 1116 override void releaseHandle () { 1135 1117 super.releaseHandle (); 1136 handle = hwndCB = 0; 1118 handle = null; 1119 hwndCB = null; 1137 1120 } 1138 1121 … … 1142 1125 MenuItem item = items [i]; 1143 1126 if (item !is null && !item.isDisposed ()) { 1144 if (OS.IsPPC && hwndCB !is 0) {1127 if (OS.IsPPC_ && hwndCB !is null) { 1145 1128 item.dispose (); 1146 1129 } else { … … 1170 1153 super.releaseWidget (); 1171 1154 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) { 1175 1158 if (imageList !is null) { 1176 1159 OS.SendMessage (hwndCB, OS.TB_SETIMAGELIST, 0, 0); … … 1455 1438 1456 1439 void update () { 1457 if (OS.IsPPC || OS.IsSP) return;1458 if (OS.IsHPC) {1440 if (OS.IsPPC_ || OS.IsSP_) return; 1441 static if (OS.IsHPC) { 1459 1442 /* 1460 1443 * Each time a menu has been modified, the command menu bar … … 1488 1471 MenuItem item = items [i]; 1489 1472 if (item.image !is null) { 1490 if ((hasImage = true) && hasCheck) break; 1473 hasImage = true; 1474 if (hasCheck) break; 1491 1475 } 1492 1476 if ((item.style & (DWT.CHECK | DWT.RADIO)) !is 0) { 1493 if ((hasCheck = true) && hasImage) break; 1477 hasCheck = true; 1478 if ( hasImage) break; 1494 1479 } 1495 1480 } … … 1516 1501 if (!OS.IsWin95) { 1517 1502 if (OS.WIN32_VERSION < OS.VERSION (6, 0)) { 1518 MENUITEMINFO info = new MENUITEMINFO ();1503 MENUITEMINFO info; 1519 1504 info.cbSize = MENUITEMINFO.sizeof; 1520 1505 info.fMask = OS.MIIM_BITMAP; … … 1523 1508 if ((style & DWT.SEPARATOR) is 0) { 1524 1509 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); 1527 1512 } 1528 1513 } … … 1532 1517 1533 1518 /* Update the menu to hide or show the space for bitmaps */ 1534 MENUINFO lpcmi = new MENUINFO ();1519 MENUINFO lpcmi; 1535 1520 lpcmi.cbSize = MENUINFO.sizeof; 1536 1521 lpcmi.fMask = OS.MIM_STYLE; 1537 OS.GetMenuInfo (handle, lpcmi);1522 OS.GetMenuInfo (handle, &lpcmi); 1538 1523 if (hasImage && !hasCheck) { 1539 1524 lpcmi.dwStyle |= OS.MNS_CHECKORBMP; … … 1541 1526 lpcmi.dwStyle &= ~OS.MNS_CHECKORBMP; 1542 1527 } 1543 OS.SetMenuInfo (handle, lpcmi);1528 OS.SetMenuInfo (handle, &lpcmi); 1544 1529 } 1545 1530 1546 1531 void updateBackground () { 1547 if (hBrush is 0) OS.DeleteObject (hBrush);1548 hBrush = 0;1532 if (hBrush is null) OS.DeleteObject (hBrush); 1533 hBrush = null; 1549 1534 if (backgroundImage !is null) { 1550 1535 hBrush = OS.CreatePatternBrush (backgroundImage.handle); … … 1552 1537 if (background !is -1) hBrush = OS.CreateSolidBrush (background); 1553 1538 } 1554 MENUINFO lpcmi = new MENUINFO ();1539 MENUINFO lpcmi; 1555 1540 lpcmi.cbSize = MENUINFO.sizeof; 1556 1541 lpcmi.fMask = OS.MIM_BACKGROUND; 1557 1542 lpcmi.hbrBack = hBrush; 1558 OS.SetMenuInfo (handle, lpcmi);1543 OS.SetMenuInfo (handle, &lpcmi); 1559 1544 } 1560 1545 1561 1546 void updateForeground () { 1562 1547 if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return; 1563 MENUITEMINFO info = new MENUITEMINFO ();1548 MENUITEMINFO info; 1564 1549 info.cbSize = MENUITEMINFO.sizeof; 1565 1550 int index = 0; 1566 while (OS.GetMenuItemInfo (handle, index, true, info)) {1551 while (OS.GetMenuItemInfo (handle, index, true, &info)) { 1567 1552 info.fMask = OS.MIIM_BITMAP; 1568 1553 info.hbmpItem = OS.HBMMENU_CALLBACK; 1569 OS.SetMenuItemInfo (handle, index, true, info);1554 OS.SetMenuItemInfo (handle, index, true, &info); 1570 1555 index++; 1571 1556 } … … 1573 1558 } 1574 1559 } 1575 ++/ 1560 dwt/widgets/MenuItem.d
r54 r56 16 16 import dwt.widgets.Widget; 17 17 import dwt.widgets.Menu; 18 import dwt.widgets.Decorations; 18 19 import dwt.internal.win32.OS; 19 20 … … 32 33 LRESULT wmMeasureChild (int wParam, int lParam) ; 33 34 void fillAccel (ACCEL* accel) ; 35 int widgetStyle () ; 36 void fixMenus (Decorations newParent) ; 37 void releaseMenu () ; 34 38 } 35 39 /++ tango_sys_win32/Types.di
r33 r56 10214 10214 alias MENUEX_TEMPLATE_ITEM* PMENUEXTEMPLATEITEM; 10215 10215 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 */ 10223 struct 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 } 10238 alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA; 10239 struct 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; 10254 version(ANSI){ 10255 alias MENUITEMINFOA MENUITEMINFO; 10256 }else{ 10257 alias MENUITEMINFOW MENUITEMINFO; 10258 } 10259 alias MENUITEMINFO * LPMENUITEMINFO; 10260 alias 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; 10237 10283 10238 10284 struct MENUITEMTEMPLATE
