Changeset 25
- Timestamp:
- 06/05/04 03:39:45 (4 years ago)
- Files:
-
- branches/0.1/src/dwt/conversion_notes.txt (added)
- branches/0.1/src/dwt/internal/win32/os.d (modified) (5 diffs)
- branches/0.1/src/dwt/internal/win32/types.d (modified) (3 diffs)
- branches/0.1/src/dwt/util/system.d (added)
- branches/0.1/src/dwt/util/thread.d (added)
- branches/0.1/src/dwt/widgets/button.d (modified) (2 diffs)
- branches/0.1/src/dwt/widgets/caret.d (modified) (3 diffs)
- branches/0.1/src/dwt/widgets/control.d (modified) (1 diff)
- branches/0.1/src/dwt/widgets/display.d (modified) (44 diffs)
- branches/0.1/src/dwt/widgets/imagelist.d (modified) (9 diffs)
- branches/0.1/src/dwt/widgets/menu.d (modified) (20 diffs)
- branches/0.1/src/dwt/widgets/menuitem.d (modified) (16 diffs)
- branches/0.1/src/dwt/widgets/shell.d (modified) (6 diffs)
- branches/0.1/src/dwt/widgets/synchronizer.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/0.1/src/dwt/internal/win32/os.d
r24 r25 1934 1934 } 1935 1935 1936 static int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN lParam) {1936 static int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN* lParam) { 1937 1937 if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 1938 1938 return SendMessageA (hWnd, Msg, wParam, lParam); … … 1944 1944 } 1945 1945 1946 static int SendMessage (int hWnd, int Msg, int wParam, LVITEM lParam) {1946 static int SendMessage (int hWnd, int Msg, int wParam, LVITEM* lParam) { 1947 1947 if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 1948 1948 return SendMessageA (hWnd, Msg, wParam, lParam); … … 1959 1959 } 1960 1960 1961 static int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON lParam) {1961 static int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON* lParam) { 1962 1962 if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 1963 1963 return SendMessageA (hWnd, Msg, wParam, lParam); … … 1969 1969 } 1970 1970 1971 static int SendMessage (int hWnd, int Msg, int wParam, TCITEM lParam) {1971 static int SendMessage (int hWnd, int Msg, int wParam, TCITEM* lParam) { 1972 1972 if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 1973 1973 return SendMessageA (hWnd, Msg, wParam, lParam); … … 1984 1984 } 1985 1985 1986 static int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam) {1986 static int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT* lParam) { 1987 1987 if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 1988 1988 return SendMessageA (hWnd, Msg, wParam, lParam); 1989 1989 } 1990 1990 1991 static int SendMessage (int hWnd, int Msg, int wParam, TVITEM lParam) {1991 static int SendMessage (int hWnd, int Msg, int wParam, TVITEM* lParam) { 1992 1992 if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 1993 1993 return SendMessageA (hWnd, Msg, wParam, lParam); branches/0.1/src/dwt/internal/win32/types.d
r24 r25 42 42 int x; 43 43 int y; 44 }45 46 /+ not sure who created this originally, but the pointers and uints didn't match the Java version47 48 struct MENUINFO {49 uint cbSize;50 uint fMask;51 uint dwStyle;52 uint cyMax;53 HBRUSH hbrBack;54 uint dwContextHelpID;55 void* dwMenuData;56 }57 58 struct MENUITEMINFO {59 uint cbSize;60 uint fMask;61 uint fType; // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)62 uint fState; // used if MIIM_STATE63 uint wID; // used if MIIM_ID64 HMENU hSubMenu; // used if MIIM_SUBMENU65 HBITMAP hbmpChecked; // used if MIIM_CHECKMARKS66 HBITMAP hbmpUnchecked; // used if MIIM_CHECKMARKS67 void* dwItemData; // used if MIIM_DATA68 char* dwTypeData; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)69 uint cch; // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)70 HBITMAP hbmpItem; // used if MIIM_BITMAP71 }72 +/73 74 struct MENUINFO {75 int cbSize;76 int fMask;77 int dwStyle;78 int cyMax;79 int hbrBack;80 int dwContextHelpID;81 int dwMenuData;82 }83 84 struct MENUITEMINFO {85 int cbSize;86 int fMask;87 int fType;88 int fState;89 int wID;90 int hSubMenu;91 int hbmpChecked;92 int hbmpUnchecked;93 int dwItemData;94 int dwTypeData;95 int cch;96 int hbmpItem;97 }98 99 struct MONITORINFO {100 int cbSize;101 RECT rcMonitor;102 RECT rcWork;103 int dwFlags;104 44 } 105 45 … … 209 149 int lParam; 210 150 int iIndent; 151 } 152 153 struct MENUINFO { 154 int cbSize; 155 int fMask; 156 int dwStyle; 157 int cyMax; 158 int hbrBack; 159 int dwContextHelpID; 160 int dwMenuData; 161 } 162 163 struct MENUITEMINFO { 164 int cbSize; 165 int fMask; 166 int fType; 167 int fState; 168 int wID; 169 int hSubMenu; 170 int hbmpChecked; 171 int hbmpUnchecked; 172 int dwItemData; 173 int dwTypeData; 174 int cch; 175 int hbmpItem; 176 } 177 178 struct MONITORINFO { 179 int cbSize; 180 RECT rcMonitor; 181 RECT rcWork; 182 int dwFlags; 211 183 } 212 184 … … 528 500 byte lfPitchAndFamily; 529 501 // use LOGFONT.size instead of sizeof 502 bool isValid; 530 503 } 531 504 branches/0.1/src/dwt/widgets/button.d
r24 r25 22 22 module dwt.widgets.button; 23 23 24 private import dwt.widgets.composite;25 24 private import dwt.widgets.control; 26 25 … … 62 61 private import dwt.util.util; 63 62 63 private import dwt.widgets.composite; 64 64 65 65 Image image; branches/0.1/src/dwt/widgets/caret.d
r24 r25 296 296 image = null; 297 297 font = null; 298 // TODO: oldFont = null;298 oldFont.isValid = false; // added isValid because I couldn't set the struct to null 299 299 } 300 300 … … 313 313 void restoreIMEFont () { 314 314 if (!OS.IsDBLocale) return; 315 if (oldFont == null) return;315 if (oldFont.isValid == false) return; // added isValid because I couldn't set the struct to null 316 316 int hwnd = parent.handle; 317 317 int hIMC = OS.ImmGetContext (hwnd); 318 OS.ImmSetCompositionFont (hIMC, oldFont);318 OS.ImmSetCompositionFont (hIMC, &oldFont); 319 319 OS.ImmReleaseContext (hwnd, hIMC); 320 oldFont = null;320 oldFont.isValid = false; // added isValid because I couldn't set the struct to null 321 321 } 322 322 323 323 void saveIMEFont () { 324 324 if (!OS.IsDBLocale) return; 325 if (oldFont != null) return;325 if (oldFont.isValid == true) return; 326 326 int hwnd = parent.handle; 327 327 int hIMC = OS.ImmGetContext (hwnd); 328 oldFont = OS.IsUnicode ? cast(LOGFONT) new LOGFONTW () : new LOGFONTA ();329 if (OS.ImmGetCompositionFont (hIMC, oldFont)) oldFont = null;328 oldFont.isValid = true; // oldFont = OS.IsUnicode ? cast(LOGFONT) new LOGFONTW () : new LOGFONTA (); 329 if (OS.ImmGetCompositionFont (hIMC, &oldFont)) oldFont.isValid=false; 330 330 OS.ImmReleaseContext (hwnd, hIMC); 331 331 } … … 451 451 void setIMEFont (int hFont) { 452 452 if (!OS.IsDBLocale) return; 453 LOGFONT logFont = OS.IsUnicode ? cast(LOGFONT) new LOGFONTW () : new LOGFONTA ();454 if (OS.GetObject (hFont, LOGFONT.sizeof,logFont) != 0) {453 LOGFONT logFont; // = OS.IsUnicode ? cast(LOGFONT) new LOGFONTW () : new LOGFONTA (); 454 if (OS.GetObject (hFont, cast(int)LOGFONT.sizeof, &logFont) != 0) { 455 455 int hwnd = parent.handle; 456 456 int hIMC = OS.ImmGetContext (hwnd); 457 OS.ImmSetCompositionFont (hIMC, logFont);457 OS.ImmSetCompositionFont (hIMC, &logFont); 458 458 OS.ImmReleaseContext (hwnd, hIMC); 459 459 } branches/0.1/src/dwt/widgets/control.d
r24 r25 21 21 module dwt.widgets.control; 22 22 23 private import dwt.graphics.IDrawable; 24 23 25 private import dwt.widgets.widget; 24 private import dwt.graphics.IDrawable;25 26 26 27 branches/0.1/src/dwt/widgets/display.d
r24 r25 115 115 116 116 private import dwt.util.runnable; 117 private import dwt.util.system; 118 private import dwt.util.thread; 117 119 private import dwt.util.util; 118 120 … … 125 127 private import dwt.widgets.widget; 126 128 127 private import std.thread;129 //private import std.thread; 128 130 129 131 /** … … 144 146 145 147 int threadId, processId; 146 //TCHAR windowClass;148 TCHAR windowClass; 147 149 static int WindowClassCount; 148 150 static final String WindowName = "DWT_Window"; … … 173 175 174 176 /* Sync/Async Widget Communication */ 175 // Synchronizer synchronizer= new Synchronizer (this); // TODO: 'this' is only allowed in non-static member functions (dmd 0.89)177 Synchronizer synchronizer; // = new Synchronizer (this); // TODO: 'this' is only allowed in non-static member functions (dmd 0.89) 176 178 Thread thread; 177 179 … … 187 189 /* Keyboard and Mouse State */ 188 190 int lastKey, lastAscii, lastMouse; 189 b itlastVirtual, lastNull, lastDead;191 bool lastVirtual, lastNull, lastDead; 190 192 byte[] keyboard = new byte [256]; 191 b itaccelKeyHit, mnemonicKeyHit;192 b itlockActiveWindow;193 bool accelKeyHit, mnemonicKeyHit; 194 bool lockActiveWindow; 193 195 194 196 /* MDI */ 195 b itignoreRestoreFocus;197 bool ignoreRestoreFocus; 196 198 Control lastHittestControl; 197 199 int lastHittest; … … 205 207 206 208 /* ImageList Cache */ 207 //ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;209 ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList; 208 210 209 211 /* Custom Colors for ChooseColor */ … … 303 305 static Display[] Displays = new Display [4]; 304 306 305 /+ 307 306 308 /* Multiple Monitors */ 307 309 static Monitor[] monitors = null; 308 310 static int monitorCount = 0; 309 311 310 +/ 312 311 313 312 314 /* Modality */ 313 315 Shell[] modalShells; 314 static b itTrimEnabled = false;316 static bool TrimEnabled = false; 315 317 316 318 /* Package Name */ … … 389 391 /* Get the current keyboard. */ 390 392 for (int i=0; i<keyboard.length; i++) keyboard [i] = 0; 391 if (!OS.GetKeyboardState ( keyboard)) return 0;393 if (!OS.GetKeyboardState (cast(char*)keyboard)) return 0; 392 394 393 395 /* Translate the key to ASCII or UNICODE using the virtual keyboard */ 394 396 if (OS.IsUnicode) { 395 char [] result = newchar [1];396 if (OS.ToUnicode (key, key, keyboard, result, 1, 0) == 1) return result [0];397 wchar[] result = new wchar [1]; 398 if (OS.ToUnicode (key, key, cast(char*)keyboard, result, 1, 0) == 1) return result [0]; 397 399 } else { 398 400 short [] result = new short [1]; 399 if (OS.ToAscii (key, key, keyboard, result, 0) == 1) return result [0];401 if (OS.ToAscii (key, key, cast(char*)keyboard, result, 0) == 1) return result [0]; 400 402 } 401 403 return 0; … … 572 574 */ 573 575 protected void checkSubclass () { 576 /+ TODO: reflection? 574 577 if (!isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS); 578 +/ 575 579 } 576 580 … … 610 614 } 611 615 616 617 /+ TODO: delegates? 612 618 /** 613 619 * Requests that the connection between DWT and the underlying … … 629 635 if (event.doit) dispose (); 630 636 } 631 637 +/ 632 638 /** 633 639 * Creates the device in the operating system. If the device … … 644 650 protected void create (DeviceData data) { 645 651 checkSubclass (); 652 /+ TODO: currentThread 646 653 checkDisplay (thread = Thread.currentThread ()); 654 +/ 647 655 createDisplay (data); 648 656 register (this); … … 717 725 switch (msg) { 718 726 case OS.WM_APP + 2: { 719 MSG keyMsg = new MSG ();727 MSG keyMsg; 720 728 OS.MoveMemory (keyMsg, lParam, MSG.sizeof); 721 729 OS.TranslateMessage (keyMsg); … … 727 735 case OS.WM_APP + 3: { 728 736 OS.DestroyWindow (hwnd); 737 /+ TODO: delegates? 729 738 if (embeddedCallback != null) embeddedCallback.dispose (); 730 739 if (getMsgCallback != null) getMsgCallback.dispose (); 731 740 embeddedCallback = getMsgCallback = null; 732 741 embeddedProc = getMsgProc = 0; 742 +/ 733 743 break; 734 744 } … … 754 764 } 755 765 756 /+ 757 b itfilterEvent (Event event) {766 /+ TODO: delegates? 767 bool filterEvent (Event event) { 758 768 if (filterTable != null) filterTable.sendEvent (event); 759 769 return false; 760 770 } 761 +/ 762 763 b itfilters (int eventType) {771 772 773 bool filters (int eventType) { 764 774 if (filterTable == null) return false; 765 775 return filterTable.hooks (eventType); 766 776 } 767 768 b itfilterMessage (MSG msg) {777 +/ 778 bool filterMessage (MSG msg) { 769 779 int message = msg.message; 770 780 if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) { … … 896 906 checkDevice (); 897 907 if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) { 898 RECT rect = new RECT ();899 OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);908 RECT rect; 909 OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); 900 910 int width = rect.right - rect.left; 901 911 int height = rect.bottom - rect.top; … … 961 971 public Control getCursorControl () { 962 972 checkDevice (); 963 POINT pt = new POINT ();964 if (!OS.GetCursorPos ( pt)) return null;965 return findControl (OS.WindowFromPoint ( pt));973 POINT pt; 974 if (!OS.GetCursorPos (&pt)) return null; 975 return findControl (OS.WindowFromPoint (&pt)); 966 976 } 967 977 … … 979 989 public Point getCursorLocation () { 980 990 checkDevice (); 981 POINT pt = new POINT ();982 OS.GetCursorPos ( pt);991 POINT pt; 992 OS.GetCursorPos (&pt); 983 993 return new Point (pt.x, pt.y); 984 994 } … … 1015 1025 /+ TODO: reflection? other way in D? 1016 1026 1017 static b itisValidClass (Class clazz) {1027 static bool isValidClass (Class clazz) { 1018 1028 char[] name = clazz.getName (); 1019 1029 int index = name.lastIndexOf ('.'); … … 1053 1063 if (keys == null) return null; 1054 1064 for (int i=0; i<keys.length; i++) { 1055 if (keys [i] .equals (key)) return values [i];1065 if (keys [i] == key) return values [i]; 1056 1066 } 1057 1067 return null; … … 1166 1176 if (result != 0) return 4; 1167 1177 int depth = 4; 1168 int [] lpcbData = {128}; 1178 int [] lpcbData; 1179 lpcbData[0] = 128; 1169 1180 1170 1181 /* Use the character encoding for the default locale */ … … 1175 1186 if (result == 0) { 1176 1187 try { 1177 depth = Integer.parseInt (lpData.toString (0, lpData.strlen ())); 1178 } catch (NumberFormatException e) {}; 1188 depth = cast(int) lpData; 1189 /+ depth = Integer.parseInt (lpData.toString (0, lpData.strlen ())); +/ 1190 } catch (Exception e) {}; 1179 1191 } 1180 1192 OS.RegCloseKey (phkResult [0]); … … 1318 1330 public Monitor [] getMonitors () { 1319 1331 checkDevice (); 1332 /+ TODO: "cannot implicitly convert Monitor to int" 1320 1333 if (OS.IsWinCE || (OS.WIN32_MAJOR << 16 | OS.WIN32_MINOR) < (4 << 16 | 10)) { 1321 return new Monitor [] [getPrimaryMonitor ()]; 1322 } 1334 return new Monitor [] [ getPrimaryMonitor() ]; 1335 } 1336 +/ 1323 1337 monitors = new Monitor [4]; 1338 /+ TODO: 1324 1339 Callback callback = new Callback (this, "monitorEnumProc", 4); 1325 1340 int lpfnEnum = callback.getAddress (); 1326 1341 OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); 1327 1342 callback.dispose (); 1343 +/ 1328 1344 Monitor [] result = new Monitor [monitorCount]; 1329 1345 System.arraycopy (monitors, 0, result, 0, monitorCount); … … 1333 1349 } 1334 1350 1351 /+ TODO: delegates? 1335 1352 int getMsgProc (int code, int wParam, int lParam) { 1336 1353 if (embeddedHwnd == 0) { … … 1377 1394 return OS.CallNextHookEx (msgHook, code, wParam, lParam); 1378 1395 } 1396 +/ 1379 1397 1380 1398 /** … … 1393 1411 monitor.width = width; 1394 1412 monitor.height = height; 1395 RECT rect = new RECT ();1396 OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);1413 RECT rect; 1414 OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0); 1397 1415 monitor.clientX = rect.left; 1398 1416 monitor.clientY = rect.top; … … 1402 1420 } 1403 1421 monitors = new Monitor [4]; 1422 /+ TODO: 1404 1423 Callback callback = new Callback (this, "monitorEnumProc", 4); 1405 1424 int lpfnEnum = callback.getAddress (); 1406 1425 OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); 1407 1426 callback.dispose (); 1427 +/ 1408 1428 Monitor result = null; 1409 MONITORINFO lpmi = new MONITORINFO ();1429 MONITORINFO lpmi; 1410 1430 lpmi.cbSize = MONITORINFO.sizeof; 1411 1431 for (int i = 0; i < monitorCount; i++) { 1412 1432 Monitor monitor = monitors [i]; 1413 OS.GetMonitorInfo (monitors [i].handle, lpmi);1433 OS.GetMonitorInfo (monitors [i].handle, &lpmi); 1414 1434 if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) != 0) { 1415 1435 result = monitor; … … 1438 1458 for (int i=0; i<controlTable.length; i++) { 1439 1459 Control control = controlTable [i]; 1440 // TODO: instanceof if (control != null && control instanceof Shell) count++;1460 if (control != null && cast(Shell)control) count++; 1441 1461 } 1442 1462 int index = 0; … … 1444 1464 for (int i=0; i<controlTable.length; i++) { 1445 1465 Control control = controlTable [i]; 1446 // TODO: instanceof 1447 /+ 1448 if (control != null && control instanceof Shell) { 1449 result [index++] = (Shell) control; 1450 } 1451 +/ 1466 if (control != null && cast(Shell)control) { 1467 result [index++] = cast(Shell) control; 1468 } 1452 1469 } 1453 1470 return result; … … 1618 1635 super.init (); 1619 1636 1637 /+ TODO: callbacks 1620 1638 /* Create the callbacks */ 1621 1639 windowCallback = new Callback (this, "windowProc", 4); 1622 1640 windowProc = windowCallback.getAddress (); 1623 1641 if (windowProc == 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 1642 +/ 1624 1643 1625 1644 /* Remember the current procsss and thread */ … … 1647 1666 int systemFont = 0; 1648 1667 if (!OS.IsWinCE) { 1649 NONCLIENTMETRICS info = OS.IsUnicode ? cast(NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ();1668 NONCLIENTMETRICS info; // = OS.IsUnicode ? cast(NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA (); 1650 1669 info.cbSize = NONCLIENTMETRICS.sizeof; 1651 1670 if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) { … … 1704 1723 } 1705 1724 1706 b itisWakeMessage (MSG msg) {1725 bool isWakeMessage (MSG msg) { 1707 1726 return msg.hwnd == hwndMessage && msg.message == OS.WM_NULL; 1708 1727 } 1709 1728 1710 b itisValidThread () {1729 bool isValidThread () { 1711 1730 return thread == Thread.currentThread (); 1712 1731 } … … 1893 1912 switch (msg) { 1894 1913 case OS.WM_APP + 2: 1895 b itconsumed = false;1914 bool consumed = false; 1896 1915 MSG keyMsg = new MSG (); 1897 1916 OS.MoveMemory (keyMsg, lParam, MSG.sizeof); … … 2057 2076 * @see #wake 2058 2077 */ 2059 public b itreadAndDispatch () {2078 public bool readAndDispatch () { 2060 2079 checkDevice (); 2061 2080 drawMenuBars (); … … 2111 2130 * @see #destroy 2112 2131 */ 2113 protected void release () { 2132 protected void release () { 2133 /+ TODO: delegates? 2114 2134 sendEvent (DWT.Dispose, new Event ()); 2135 +/ 2115 2136 Shell [] shells = getShells (); 2116 2137 for (int i=0; i<shells.length; i++) { … … 2130 2151 super.release (); 2131 2152 } 2153 2132 2154 2133 2155 void releaseDisplay () { … … 2366 2388 } 2367 2389 2368 b itrunAsyncMessages () {2390 bool runAsyncMessages () { 2369 2391 return synchronizer.runAsyncMessages (); 2370 2392 } … … 2372 2394 /+ TODO: delegates? 2373 2395 2374 b itrunDeferredEvents () {2396 bool runDeferredEvents () { 2375 2397 /* 2376 2398 * Run deferred events. This code is always … … 2408 2430 } 2409 2431 2410 b itrunPopups () {2432 bool runPopups () { 2411 2433 if (popups == null) return false; 2412 b itresult = false;2434 bool result = false; 2413 2435 while (popups != null) { 2414 2436 Menu menu = popups [0]; … … 2427 2449 +/ 2428 2450 2429 b itrunTimer (int id) {2451 bool runTimer (int id) { 2430 2452 if (timerList != null && timerIds != null) { 2431 2453 int index = 0; … … 2686 2708 * @see #wake 2687 2709 */ 2688 public b itsleep () {2710 public bool sleep () { 2689 2711 checkDevice (); 2690 2712 if (getMessageCount () != 0) return true; … … 2790 2812 } 2791 2813 2792 b ittranslateAccelerator (MSG msg, Control control) {2814 bool translateAccelerator (MSG msg, Control control) { 2793 2815 accelKeyHit = true; 2794 b itresult = control.translateAccelerator (msg);2816 bool result = control.translateAccelerator (msg); 2795 2817 accelKeyHit = false; 2796 2818 return result; … … 2804 2826 } 2805 2827 2806 b ittranslateMnemonic (MSG msg, Control control) {2828 bool translateMnemonic (MSG msg, Control control) { 2807 2829 switch (msg.message) { 2808 2830 case OS.WM_CHAR: … … 2813 2835 } 2814 2836 2815 b ittranslateTraversal (MSG msg, Control control) {2837 bool translateTraversal (MSG msg, Control control) { 2816 2838 switch (msg.message) { 2817 2839 case OS.WM_KEYDOWN: branches/0.1/src/dwt/widgets/imagelist.d
r17 r25 22 22 module dwt.widgets.imagelist; 23 23 24 /+25 import org.eclipse.swt.internal.win32.*;26 import org.eclipse.swt.*;27 import org.eclipse.swt.graphics.*;28 +/29 24 30 25 class ImageList { 31 26 32 /+ TODO: implement Images and all objects in dwt.graphics.* 33 27 private { 28 29 import dwt.dwt; 30 31 import dwt.graphics.color; 32 import dwt.graphics.image; 33 import dwt.graphics.point; 34 import dwt.graphics.rectangle; 35 36 import dwt.internal.win32.os; 37 import dwt.internal.win32.types; 38 39 import dwt.util.system; 40 } 41 42 34 43 int handle, refCount; 35 44 Image[] images; 36 45 static final int CREATE_FLAGS; 37 static { 46 /+ static { 47 // if (OS.IsWinCE) { 48 // CREATE_FLAGS = OS.ILC_MASK | OS.ILC_COLOR; 49 // } else { 50 int flags = OS.ILC_MASK; 51 int hDC = OS.GetDC (0); 52 int bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL); 53 int planes = OS.GetDeviceCaps (hDC, OS.PLANES); 54 OS.ReleaseDC (0, hDC); 55 int depth = bits * planes; 56 switch (depth) { 57 case 4: 58 flags |= OS.ILC_COLOR4; 59 break; 60 case 8: 61 flags |= OS.ILC_COLOR8; 62 break; 63 case 16: 64 flags |= OS.ILC_COLOR16; 65 break; 66 case 24: 67 flags |= OS.ILC_COLOR24; 68 break; 69 case 32: 70 flags |= OS.ILC_COLOR32; 71 break; 72 default: 73 flags |= OS.ILC_COLOR; 74 } 75 CREATE_FLAGS = flags; 76 // } 77 // } 78 +/ 79 80 public this () { 81 38 82 if (OS.IsWinCE) { 39 83 CREATE_FLAGS = OS.ILC_MASK | OS.ILC_COLOR; … … 66 110 CREATE_FLAGS = flags; 67 111 } 68 } 69 70 public ImageList () { 112 71 113 handle = OS.ImageList_Create (32, 32, CREATE_FLAGS, 16, 16); 72 114 images = new Image [4]; … … 93 135 OS.ImageList_GetIconSize (handle, cx, cy); 94 136 switch (image.type) { 95 case SWT.BITMAP: {137 case DWT.BITMAP: { 96 138 int hBitmap = copyBitmap (hImage, cx [0], cy [0]); 97 139 int background = -1; … … 114 156 break; 115 157 } 116 case SWT.ICON: {158 case DWT.ICON: { 117 159 if (OS.IsWinCE) { 118 160 OS.ImageList_ReplaceIcon (handle, index == count ? -1 : index, hImage); … … 139 181 140 182 int copyBitmap (int hImage, int width, int height) { 141 BITMAP bm = new BITMAP ();142 OS.GetObject (hImage, BITMAP.sizeof, bm);183 BITMAP bm; 184 OS.GetObject (hImage, BITMAP.sizeof, &bm); 143 185 int hDC = OS.GetDC (0); 144 186 int hdc1 = OS.CreateCompatibleDC (hDC); … … 160 202 161 203 int copyIcon (int hImage, int width, int height) { 162 if (OS.IsWinCE) SWT.error(SWT.ERROR_NOT_IMPLEMENTED);204 if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED); 163 205 int hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, OS.LR_DEFAULTCOLOR); 164 206 return hIcon != 0 ? hIcon : hImage; … … 225 267 int hImage = image.handle; 226 268 switch (image.type) { 227 case SWT.BITMAP: {269 case DWT.BITMAP: { 228 270 int background = -1; 229 271 Color color = image.getBackground (); … … 236 278 break; 237 279 } 238 case SWT.ICON: {280 case DWT.ICON: { 239 281 if (OS.IsWinCE) { 240 282 OS.ImageList_ReplaceIcon (handle, index, hImage); … … 275 317 } 276 318 277 +/ 278 279 } 319 } branches/0.1/src/dwt/widgets/menu.d
r17 r25 398 398 } 399 399 info.idCommand = id0 = item.id; 400 OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY0, info);400 OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY0, &info); 401 401 402 402 /* Set second item */ … … 410 410 } 411 411 info.idCommand = id1 = item.id; 412 OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY1, info);412 OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, ID_SPSOFTKEY1, &info); 413 413 414 414 /* … … 451 451 if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) { 452 452 if (OS.IsSP) return; 453 TBBUTTON lpButton = new TBBUTTON ();453 TBBUTTON lpButton; 454 454 lpButton.idCommand = item.id; 455 455 lpButton.fsStyle = cast(byte) (OS.TBSTYLE_DROPDOWN | OS.TBSTYLE_AUTOSIZE | 0x80); … … 457 457 lpButton.iBitmap = OS.I_IMAGENONE; 458 458 if ((item.style & DWT.SEPARATOR) != 0) lpButton.fsStyle = cast(byte) OS.BTNS_SEP; 459 success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, lpButton) != 0;459 success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, &lpButton) != 0; 460 460 } else { 461 461 if (OS.IsWinCE) { … … 469 469 success = OS.InsertMenu (handle, index, uFlags, item.id, lpNewItem); 470 470 if (success) { 471 MENUITEMINFO info = new MENUITEMINFO ();471 MENUITEMINFO info; 472 472 info.cbSize = MENUITEMINFO.sizeof; 473 473 info.fMask = OS.MIIM_DATA; 474 474 info.dwItemData = item.id; 475 success = OS.SetMenuItemInfo (handle, index, true, info);475 success = OS.SetMenuItemInfo (handle, index, true, &info); 476 476 } 477 477 } else { … … 492 492 int byteCount = buffer.length () * TCHAR.sizeof; 493 493 int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 494 OS.MoveMemory ( pszText, buffer, byteCount);495 MENUITEMINFO info = new MENUITEMINFO ();494 OS.MoveMemory (&pszText, buffer, byteCount); 495 MENUITEMINFO info; 496 496 info.cbSize = MENUITEMINFO.sizeof; 497 497 info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA; … … 499 499 info.fType = item.widgetStyle (); 500 500 info.dwTypeData = pszText; 501 success = OS.InsertMenuItem (handle, index, true, info);501 success = OS.InsertMenuItem (handle, index, true, &info); 502 502 if (pszText != 0) OS.HeapFree (hHeap, 0, pszText); 503 503 } … … 620 620 int id = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED); 621 621 if (id == -1) return null; 622 MENUITEMINFO info = new MENUITEMINFO ();622 MENUITEMINFO info; 623 623 info.cbSize = MENUITEMINFO.sizeof; 624 624 info.fMask = OS.MIIM_ID; 625 if (OS.GetMenuItemInfo (handle, id, false, info)) {625 if (OS.GetMenuItemInfo (handle, id, false, &info)) { 626 626 return parent.findMenuItem (info.wID); 627 627 } … … 669 669 if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) { 670 670 if (OS.IsPPC) { 671 TBBUTTON lpButton = new TBBUTTON ();672 int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, lpButton);671 TBBUTTON lpButton; 672 int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, &lpButton); 673 673 if (result == 0) error (DWT.ERROR_CANNOT_GET_ITEM); 674 674 id = lpButton.idCommand; … … 679 679 } 680 680 } else { 681 MENUITEMINFO info = new MENUITEMINFO ();681 MENUITEMINFO info; 682 682 info.cbSize = MENUITEMINFO.sizeof; 683 683 info.fMask = OS.MIIM_DATA; 684 if (!OS.GetMenuItemInfo (handle, index, true, info)) {684 if (!OS.GetMenuItemInfo (handle, index, true, &info)) { 685 685 error (DWT.ERROR_INVALID_RANGE); 686 686 } … … 731 731 } 732 732 int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0); 733 TBBUTTON lpButton = new TBBUTTON ();733 TBBUTTON lpButton; 734 734 MenuItem [] result = new MenuItem [count]; 735 735 for (int i=0; i<count; i++) { 736 OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, lpButton);736 OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, &lpButton); 737 737 result [i] = parent.findMenuItem (lpButton.idCommand); 738 738 } … … 742 742 int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle); 743 743 MenuItem [] items = new MenuItem [length]; 744 MENUITEMINFO info = new MENUITEMINFO ();744 MENUITEMINFO info; 745 745 info.cbSize = MENUITEMINFO.sizeof; 746 746 info.fMask = OS.MIIM_DATA; 747 while (OS.GetMenuItemInfo (handle, index, true, info)) {747 while (OS.GetMenuItemInfo (handle, index, true, &info)) { 748 748 if (index == items.length) { 749 749 MenuItem [] newItems = new MenuItem [index + 4]; 750 /+ TODO: arraycopy 750 751 System.arraycopy (items, 0, newItems, 0, index); 752 +/ 751 753 items = newItems; 752 754 } … … 755 757 if (index == items.length) return items; 756 758 MenuItem [] result = new MenuItem [index]; 759 /+ TODO: arraycopy 757 760 System.arraycopy (items, 0, result, 0, index); 761 +/ 758 762 return result; 759 763 } … … 766 770 } 767 771 int count = 0; 768 MENUITEMINFO info = new MENUITEMINFO ();772 MENUITEMINFO info; 769 773 info.cbSize = MENUITEMINFO.sizeof; 770 while (OS.GetMenuItemInfo (handle, count, true, info)) count++;774 while (OS.GetMenuItemInfo (handle, count, true, &info)) count++; 771 775 return count; 772 776 } … … 780 784 if (length > 0) { 781 785 for (int i=0; i<length-1; i++) { 782 result = result + items [i].getNameText() + ", ";783 } 784 result = result +items [length-1].getNameText ();786 result ~= items [i].getNameText() ~ cast(String)(", "); 787 } 788 result ~= items [length-1].getNameText (); 785 789 } 786 790 return result; … … 877 881 checkWidget (); 878 882 if ((style & DWT.BAR) != 0) { 879 return this == parent.menuShell ().menuBar;883 return cast(bool)(this == parent.menuShell().menuBar); 880 884 } 881 885 if ((style & DWT.POP_UP) != 0) { … … 886 890 } 887 891 } 888 return this == getShell ().activeMenu;892 return cast(bool)(this == getShell ().activeMenu);&n
