Changeset 25

Show
Ignore:
Timestamp:
06/05/04 03:39:45 (4 years ago)
Author:
brad
Message:

More widgets work to get compiling. (Menu, Caret, ImageList?, Shell)
Implemented System.arraycopy in dwt.util.system
Got farther with implementing display (line 1649, currently)
Began doing some instanceof conversions.
Added document for conversion notes (Java --> D)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.1/src/dwt/internal/win32/os.d

    r24 r25  
    19341934} 
    19351935 
    1936 static int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN lParam) { 
     1936static int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN* lParam) { 
    19371937    if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 
    19381938    return SendMessageA (hWnd, Msg, wParam, lParam); 
     
    19441944} 
    19451945 
    1946 static int SendMessage (int hWnd, int Msg, int wParam, LVITEM lParam) { 
     1946static int SendMessage (int hWnd, int Msg, int wParam, LVITEM* lParam) { 
    19471947    if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 
    19481948    return SendMessageA (hWnd, Msg, wParam, lParam); 
     
    19591959} 
    19601960 
    1961 static int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON lParam) { 
     1961static int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON* lParam) { 
    19621962    if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 
    19631963    return SendMessageA (hWnd, Msg, wParam, lParam); 
     
    19691969} 
    19701970 
    1971 static int SendMessage (int hWnd, int Msg, int wParam, TCITEM lParam) { 
     1971static int SendMessage (int hWnd, int Msg, int wParam, TCITEM* lParam) { 
    19721972    if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 
    19731973    return SendMessageA (hWnd, Msg, wParam, lParam); 
     
    19841984} 
    19851985 
    1986 static int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam) { 
     1986static int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT* lParam) { 
    19871987    if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 
    19881988    return SendMessageA (hWnd, Msg, wParam, lParam); 
    19891989} 
    19901990 
    1991 static int SendMessage (int hWnd, int Msg, int wParam, TVITEM lParam) { 
     1991static int SendMessage (int hWnd, int Msg, int wParam, TVITEM* lParam) { 
    19921992    if (IsUnicode) return SendMessageW (hWnd, Msg, wParam, lParam); 
    19931993    return SendMessageA (hWnd, Msg, wParam, lParam); 
  • branches/0.1/src/dwt/internal/win32/types.d

    r24 r25  
    4242    int x; 
    4343    int y; 
    44 } 
    45  
    46 /+ not sure who created this originally, but the pointers and uints didn't match the Java version 
    47  
    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_STATE 
    63     uint     wID;           // used if MIIM_ID 
    64     HMENU    hSubMenu;      // used if MIIM_SUBMENU 
    65     HBITMAP  hbmpChecked;   // used if MIIM_CHECKMARKS 
    66     HBITMAP  hbmpUnchecked; // used if MIIM_CHECKMARKS 
    67     void*    dwItemData;   // used if MIIM_DATA 
    68     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_BITMAP 
    71 } 
    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; 
    10444} 
    10545 
     
    209149    int lParam; 
    210150    int iIndent; 
     151} 
     152 
     153struct MENUINFO { 
     154    int cbSize; 
     155    int fMask; 
     156    int dwStyle; 
     157    int cyMax; 
     158    int hbrBack; 
     159    int dwContextHelpID; 
     160    int dwMenuData; 
     161} 
     162 
     163struct 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 
     178struct MONITORINFO { 
     179    int     cbSize; 
     180    RECT    rcMonitor; 
     181    RECT    rcWork; 
     182    int     dwFlags; 
    211183} 
    212184 
     
    528500    byte lfPitchAndFamily; 
    529501    // use LOGFONT.size instead of sizeof 
     502    bool isValid; 
    530503} 
    531504 
  • branches/0.1/src/dwt/widgets/button.d

    r24 r25  
    2222module dwt.widgets.button; 
    2323 
    24 private import dwt.widgets.composite; 
    2524private import dwt.widgets.control; 
    2625 
     
    6261    private import dwt.util.util; 
    6362 
     63    private import dwt.widgets.composite; 
    6464 
    6565    Image image; 
  • branches/0.1/src/dwt/widgets/caret.d

    r24 r25  
    296296    image = null; 
    297297    font = null; 
    298     // TODO: oldFont = null; 
     298    oldFont.isValid = false;   // added isValid because I couldn't set the struct to null 
    299299} 
    300300 
     
    313313void restoreIMEFont () { 
    314314    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 
    316316    int hwnd = parent.handle; 
    317317    int hIMC = OS.ImmGetContext (hwnd); 
    318     OS.ImmSetCompositionFont (hIMC, oldFont); 
     318    OS.ImmSetCompositionFont (hIMC, &oldFont); 
    319319    OS.ImmReleaseContext (hwnd, hIMC); 
    320     oldFont = null; 
     320    oldFont.isValid = false;           // added isValid because I couldn't set the struct to null 
    321321} 
    322322 
    323323void saveIMEFont () { 
    324324    if (!OS.IsDBLocale) return; 
    325     if (oldFont != null) return; 
     325    if (oldFont.isValid == true) return; 
    326326    int hwnd = parent.handle; 
    327327    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
    330330    OS.ImmReleaseContext (hwnd, hIMC); 
    331331} 
     
    451451void setIMEFont (int hFont) { 
    452452    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) { 
    455455        int hwnd = parent.handle; 
    456456        int hIMC = OS.ImmGetContext (hwnd); 
    457         OS.ImmSetCompositionFont (hIMC, logFont); 
     457        OS.ImmSetCompositionFont (hIMC, &logFont); 
    458458        OS.ImmReleaseContext (hwnd, hIMC); 
    459459    } 
  • branches/0.1/src/dwt/widgets/control.d

    r24 r25  
    2121module dwt.widgets.control; 
    2222 
     23private import dwt.graphics.IDrawable; 
     24 
    2325private import dwt.widgets.widget; 
    24 private import dwt.graphics.IDrawable; 
    2526 
    2627 
  • branches/0.1/src/dwt/widgets/display.d

    r24 r25  
    115115     
    116116    private import dwt.util.runnable; 
     117    private import dwt.util.system; 
     118    private import dwt.util.thread; 
    117119    private import dwt.util.util; 
    118120     
     
    125127    private import dwt.widgets.widget; 
    126128     
    127     private import std.thread; 
     129    //private import std.thread; 
    128130     
    129131    /** 
     
    144146     
    145147    int threadId, processId;   
    146 //    TCHAR windowClass; 
     148  TCHAR windowClass; 
    147149    static int WindowClassCount; 
    148150    static final String WindowName = "DWT_Window"; 
     
    173175 
    174176    /* 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) 
    176178    Thread thread; 
    177179 
     
    187189    /* Keyboard and Mouse State */ 
    188190    int lastKey, lastAscii, lastMouse; 
    189     bit lastVirtual, lastNull, lastDead; 
     191    bool lastVirtual, lastNull, lastDead; 
    190192    byte[] keyboard = new byte [256]; 
    191     bit accelKeyHit, mnemonicKeyHit; 
    192     bit lockActiveWindow; 
     193    bool accelKeyHit, mnemonicKeyHit; 
     194    bool lockActiveWindow; 
    193195     
    194196    /* MDI */ 
    195     bit ignoreRestoreFocus; 
     197    bool ignoreRestoreFocus; 
    196198    Control lastHittestControl; 
    197199    int lastHittest; 
     
    205207     
    206208    /* ImageList Cache */    
    207 //    ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList; 
     209  ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList; 
    208210 
    209211    /* Custom Colors for ChooseColor */ 
     
    303305    static Display[] Displays = new Display [4]; 
    304306 
    305 /+ 
     307 
    306308    /* Multiple Monitors */ 
    307309    static Monitor[] monitors = null; 
    308310    static int monitorCount = 0; 
    309311 
    310 +/ 
     312 
    311313     
    312314    /* Modality */ 
    313315    Shell[] modalShells; 
    314     static bit TrimEnabled = false; 
     316    static bool TrimEnabled = false; 
    315317 
    316318    /* Package Name */ 
     
    389391    /* Get the current keyboard. */ 
    390392    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; 
    392394         
    393395    /* Translate the key to ASCII or UNICODE using the virtual keyboard */ 
    394396    if (OS.IsUnicode) { 
    395         char [] result = new char [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]; 
    397399    } else { 
    398400        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]; 
    400402    } 
    401403    return 0; 
     
    572574 */ 
    573575protected void checkSubclass () { 
     576    /+ TODO: reflection? 
    574577    if (!isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS); 
     578    +/ 
    575579} 
    576580 
     
    610614} 
    611615 
     616 
     617/+ TODO: delegates? 
    612618/** 
    613619 * Requests that the connection between DWT and the underlying 
     
    629635    if (event.doit) dispose (); 
    630636} 
    631  
     637+/ 
    632638/** 
    633639 * Creates the device in the operating system.  If the device 
     
    644650protected void create (DeviceData data) { 
    645651    checkSubclass (); 
     652    /+ TODO: currentThread 
    646653    checkDisplay (thread = Thread.currentThread ()); 
     654    +/ 
    647655    createDisplay (data); 
    648656    register (this); 
     
    717725    switch (msg) { 
    718726        case OS.WM_APP + 2: { 
    719             MSG keyMsg = new MSG ()
     727            MSG keyMsg
    720728            OS.MoveMemory (keyMsg, lParam, MSG.sizeof); 
    721729            OS.TranslateMessage (keyMsg); 
     
    727735        case OS.WM_APP + 3: { 
    728736            OS.DestroyWindow (hwnd); 
     737            /+ TODO: delegates? 
    729738            if (embeddedCallback != null) embeddedCallback.dispose (); 
    730739            if (getMsgCallback != null) getMsgCallback.dispose (); 
    731740            embeddedCallback = getMsgCallback = null; 
    732741            embeddedProc = getMsgProc = 0; 
     742            +/ 
    733743            break; 
    734744        } 
     
    754764} 
    755765 
    756 /+ 
    757 bit filterEvent (Event event) { 
     766/+ TODO: delegates? 
     767bool filterEvent (Event event) { 
    758768    if (filterTable != null) filterTable.sendEvent (event); 
    759769    return false; 
    760770} 
    761 +/ 
    762  
    763 bit filters (int eventType) { 
     771 
     772 
     773bool filters (int eventType) { 
    764774    if (filterTable == null) return false; 
    765775    return filterTable.hooks (eventType); 
    766776} 
    767  
    768 bit filterMessage (MSG msg) { 
     777+/ 
     778bool filterMessage (MSG msg) { 
    769779    int message = msg.message; 
    770780    if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) { 
     
    896906    checkDevice (); 
    897907    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); 
    900910        int width = rect.right - rect.left; 
    901911        int height = rect.bottom - rect.top; 
     
    961971public Control getCursorControl () { 
    962972    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)); 
    966976} 
    967977 
     
    979989public Point getCursorLocation () { 
    980990    checkDevice (); 
    981     POINT pt = new POINT ()
    982     OS.GetCursorPos (pt); 
     991    POINT pt
     992    OS.GetCursorPos (&pt); 
    983993    return new Point (pt.x, pt.y); 
    984994} 
     
    10151025/+ TODO: reflection?  other way in D? 
    10161026 
    1017 static bit isValidClass (Class clazz) { 
     1027static bool isValidClass (Class clazz) { 
    10181028    char[] name = clazz.getName (); 
    10191029    int index = name.lastIndexOf ('.'); 
     
    10531063    if (keys == null) return null; 
    10541064    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]; 
    10561066    } 
    10571067    return null; 
     
    11661176    if (result != 0) return 4; 
    11671177    int depth = 4; 
    1168     int [] lpcbData = {128}; 
     1178    int [] lpcbData; 
     1179    lpcbData[0] = 128; 
    11691180     
    11701181    /* Use the character encoding for the default locale */ 
     
    11751186    if (result == 0) { 
    11761187        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) {}; 
    11791191    } 
    11801192    OS.RegCloseKey (phkResult [0]); 
     
    13181330public Monitor [] getMonitors () { 
    13191331    checkDevice (); 
     1332/+  TODO:  "cannot implicitly convert Monitor to int" 
    13201333    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+/ 
    13231337    monitors = new Monitor [4]; 
     1338/+  TODO: 
    13241339    Callback callback = new Callback (this, "monitorEnumProc", 4); 
    13251340    int lpfnEnum = callback.getAddress (); 
    13261341    OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); 
    13271342    callback.dispose (); 
     1343+/ 
    13281344    Monitor [] result = new Monitor [monitorCount]; 
    13291345    System.arraycopy (monitors, 0, result, 0, monitorCount); 
     
    13331349} 
    13341350 
     1351/+ TODO: delegates? 
    13351352int getMsgProc (int code, int wParam, int lParam) { 
    13361353    if (embeddedHwnd == 0) { 
     
    13771394    return OS.CallNextHookEx (msgHook, code, wParam, lParam); 
    13781395} 
     1396+/ 
    13791397 
    13801398/** 
     
    13931411        monitor.width = width; 
    13941412        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); 
    13971415        monitor.clientX = rect.left; 
    13981416        monitor.clientY = rect.top; 
     
    14021420    } 
    14031421    monitors = new Monitor [4]; 
     1422/+  TODO: 
    14041423    Callback callback = new Callback (this, "monitorEnumProc", 4); 
    14051424    int lpfnEnum = callback.getAddress (); 
    14061425    OS.EnumDisplayMonitors (0, null, lpfnEnum, 0); 
    14071426    callback.dispose (); 
     1427+/ 
    14081428    Monitor result = null; 
    1409     MONITORINFO lpmi = new MONITORINFO ()
     1429    MONITORINFO lpmi
    14101430    lpmi.cbSize = MONITORINFO.sizeof; 
    14111431    for (int i = 0; i < monitorCount; i++) { 
    14121432        Monitor monitor = monitors [i]; 
    1413         OS.GetMonitorInfo (monitors [i].handle, lpmi); 
     1433        OS.GetMonitorInfo (monitors [i].handle, &lpmi); 
    14141434        if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) != 0) { 
    14151435            result = monitor; 
     
    14381458    for (int i=0; i<controlTable.length; i++) { 
    14391459        Control control = controlTable [i]; 
    1440 // TODO: instanceof        if (control != null && control instanceof Shell) count++; 
     1460   if (control != null && cast(Shell)control) count++; 
    14411461    } 
    14421462    int index = 0; 
     
    14441464    for (int i=0; i<controlTable.length; i++) { 
    14451465        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        } 
    14521469    } 
    14531470    return result; 
     
    16181635    super.init (); 
    16191636         
     1637/+  TODO: callbacks 
    16201638    /* Create the callbacks */ 
    16211639    windowCallback = new Callback (this, "windowProc", 4); 
    16221640    windowProc = windowCallback.getAddress (); 
    16231641    if (windowProc == 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 
     1642+/ 
    16241643     
    16251644    /* Remember the current procsss and thread */ 
     
    16471666    int systemFont = 0; 
    16481667    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 (); 
    16501669        info.cbSize = NONCLIENTMETRICS.sizeof; 
    16511670        if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) { 
     
    17041723} 
    17051724 
    1706 bit isWakeMessage (MSG msg) { 
     1725bool isWakeMessage (MSG msg) { 
    17071726    return msg.hwnd == hwndMessage && msg.message == OS.WM_NULL; 
    17081727} 
    17091728 
    1710 bit isValidThread () { 
     1729bool isValidThread () { 
    17111730    return thread == Thread.currentThread (); 
    17121731} 
     
    18931912    switch (msg) { 
    18941913        case OS.WM_APP + 2: 
    1895             bit consumed = false; 
     1914            bool consumed = false; 
    18961915            MSG keyMsg = new MSG (); 
    18971916            OS.MoveMemory (keyMsg, lParam, MSG.sizeof); 
     
    20572076 * @see #wake 
    20582077 */ 
    2059 public bit readAndDispatch () { 
     2078public bool readAndDispatch () { 
    20602079    checkDevice (); 
    20612080    drawMenuBars (); 
     
    21112130 * @see #destroy 
    21122131 */ 
    2113 protected void release () { 
     2132 protected void release () { 
     2133    /+ TODO: delegates? 
    21142134    sendEvent (DWT.Dispose, new Event ()); 
     2135    +/ 
    21152136    Shell [] shells = getShells (); 
    21162137    for (int i=0; i<shells.length; i++) { 
     
    21302151    super.release (); 
    21312152} 
     2153 
    21322154 
    21332155void releaseDisplay () { 
     
    23662388} 
    23672389 
    2368 bit runAsyncMessages () { 
     2390bool runAsyncMessages () { 
    23692391    return synchronizer.runAsyncMessages (); 
    23702392} 
     
    23722394/+ TODO: delegates? 
    23732395 
    2374 bit runDeferredEvents () { 
     2396bool runDeferredEvents () { 
    23752397    /* 
    23762398    * Run deferred events.  This code is always 
     
    24082430} 
    24092431 
    2410 bit runPopups () { 
     2432bool runPopups () { 
    24112433    if (popups == null) return false; 
    2412     bit result = false; 
     2434    bool result = false; 
    24132435    while (popups != null) { 
    24142436        Menu menu = popups [0]; 
     
    24272449+/ 
    24282450 
    2429 bit runTimer (int id) { 
     2451bool runTimer (int id) { 
    24302452    if (timerList != null && timerIds != null) { 
    24312453        int index = 0; 
     
    26862708 * @see #wake 
    26872709 */ 
    2688 public bit sleep () { 
     2710public bool sleep () { 
    26892711    checkDevice (); 
    26902712    if (getMessageCount () != 0) return true; 
     
    27902812} 
    27912813 
    2792 bit translateAccelerator (MSG msg, Control control) { 
     2814bool translateAccelerator (MSG msg, Control control) { 
    27932815    accelKeyHit = true; 
    2794     bit result = control.translateAccelerator (msg); 
     2816    bool result = control.translateAccelerator (msg); 
    27952817    accelKeyHit = false; 
    27962818    return result; 
     
    28042826} 
    28052827 
    2806 bit translateMnemonic (MSG msg, Control control) { 
     2828bool translateMnemonic (MSG msg, Control control) { 
    28072829    switch (msg.message) { 
    28082830        case OS.WM_CHAR: 
     
    28132835} 
    28142836 
    2815 bit translateTraversal (MSG msg, Control control) { 
     2837bool translateTraversal (MSG msg, Control control) { 
    28162838    switch (msg.message) { 
    28172839        case OS.WM_KEYDOWN: 
  • branches/0.1/src/dwt/widgets/imagelist.d

    r17 r25  
    2222module dwt.widgets.imagelist; 
    2323 
    24 /+  
    25 import org.eclipse.swt.internal.win32.*; 
    26 import org.eclipse.swt.*; 
    27 import org.eclipse.swt.graphics.*; 
    28 +/ 
    2924 
    3025class ImageList { 
    3126 
    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     
    3443    int handle, refCount; 
    3544    Image[] images; 
    3645    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 
     80public this () { 
     81 
    3882        if (OS.IsWinCE) { 
    3983            CREATE_FLAGS = OS.ILC_MASK | OS.ILC_COLOR; 
     
    66110            CREATE_FLAGS = flags; 
    67111        } 
    68     } 
    69      
    70 public ImageList () { 
     112 
    71113    handle = OS.ImageList_Create (32, 32, CREATE_FLAGS, 16, 16); 
    72114    images = new Image [4]; 
     
    93135    OS.ImageList_GetIconSize (handle, cx, cy); 
    94136    switch (image.type) { 
    95         case SWT.BITMAP: { 
     137        case DWT.BITMAP: { 
    96138            int hBitmap = copyBitmap (hImage, cx [0], cy [0]); 
    97139            int background = -1; 
     
    114156            break; 
    115157        } 
    116         case SWT.ICON: { 
     158        case DWT.ICON: { 
    117159            if (OS.IsWinCE) {    
    118160                OS.ImageList_ReplaceIcon (handle, index == count ? -1 : index, hImage); 
     
    139181 
    140182int 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); 
    143185    int hDC = OS.GetDC (0); 
    144186    int hdc1 = OS.CreateCompatibleDC (hDC); 
     
    160202 
    161203int 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); 
    163205    int hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, OS.LR_DEFAULTCOLOR); 
    164206    return hIcon != 0 ? hIcon : hImage; 
     
    225267        int hImage = image.handle; 
    226268        switch (image.type) { 
    227             case SWT.BITMAP: { 
     269            case DWT.BITMAP: { 
    228270                int background = -1; 
    229271                Color color = image.getBackground (); 
     
    236278                break; 
    237279            } 
    238             case SWT.ICON: { 
     280            case DWT.ICON: { 
    239281                if (OS.IsWinCE) { 
    240282                    OS.ImageList_ReplaceIcon (handle, index, hImage); 
     
    275317} 
    276318 
    277 +/ 
    278  
    279 
     319
  • branches/0.1/src/dwt/widgets/menu.d

    r17 r25  
    398398            } 
    399399            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);    
    401401 
    402402            /* Set second item */ 
     
    410410            } 
    411411            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); 
    413413 
    414414            /* 
     
    451451    if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) { 
    452452        if (OS.IsSP) return; 
    453         TBBUTTON lpButton = new TBBUTTON ()
     453        TBBUTTON lpButton
    454454        lpButton.idCommand = item.id; 
    455455        lpButton.fsStyle = cast(byte) (OS.TBSTYLE_DROPDOWN | OS.TBSTYLE_AUTOSIZE | 0x80); 
     
    457457        lpButton.iBitmap = OS.I_IMAGENONE; 
    458458        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; 
    460460    } else { 
    461461        if (OS.IsWinCE) { 
     
    469469            success = OS.InsertMenu (handle, index, uFlags, item.id, lpNewItem); 
    470470            if (success) { 
    471                 MENUITEMINFO info = new MENUITEMINFO ()
     471                MENUITEMINFO info
    472472                info.cbSize = MENUITEMINFO.sizeof; 
    473473                info.fMask = OS.MIIM_DATA; 
    474474                info.dwItemData = item.id; 
    475                 success = OS.SetMenuItemInfo (handle, index, true, info); 
     475                success = OS.SetMenuItemInfo (handle, index, true, &info); 
    476476            } 
    477477        } else { 
     
    492492            int byteCount = buffer.length () * TCHAR.sizeof; 
    493493            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
    496496            info.cbSize = MENUITEMINFO.sizeof; 
    497497            info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA; 
     
    499499            info.fType = item.widgetStyle (); 
    500500            info.dwTypeData = pszText; 
    501             success = OS.InsertMenuItem (handle, index, true, info); 
     501            success = OS.InsertMenuItem (handle, index, true, &info); 
    502502            if (pszText != 0) OS.HeapFree (hHeap, 0, pszText); 
    503503        } 
     
    620620    int id = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED); 
    621621    if (id == -1) return null; 
    622     MENUITEMINFO info = new MENUITEMINFO ()
     622    MENUITEMINFO info
    623623    info.cbSize = MENUITEMINFO.sizeof; 
    624624    info.fMask = OS.MIIM_ID; 
    625     if (OS.GetMenuItemInfo (handle, id, false, info)) { 
     625    if (OS.GetMenuItemInfo (handle, id, false, &info)) { 
    626626        return parent.findMenuItem (info.wID); 
    627627    } 
     
    669669    if ((OS.IsPPC || OS.IsSP) && hwndCB != 0) { 
    670670        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); 
    673673            if (result == 0) error (DWT.ERROR_CANNOT_GET_ITEM); 
    674674            id = lpButton.idCommand; 
     
    679679        } 
    680680    } else { 
    681         MENUITEMINFO info = new MENUITEMINFO ()
     681        MENUITEMINFO info
    682682        info.cbSize = MENUITEMINFO.sizeof; 
    683683        info.fMask = OS.MIIM_DATA; 
    684         if (!OS.GetMenuItemInfo (handle, index, true, info)) { 
     684        if (!OS.GetMenuItemInfo (handle, index, true, &info)) { 
    685685            error (DWT.ERROR_INVALID_RANGE); 
    686686        } 
     
    731731        } 
    732732        int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0); 
    733         TBBUTTON lpButton = new TBBUTTON ()
     733        TBBUTTON lpButton
    734734        MenuItem [] result = new MenuItem [count]; 
    735735        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); 
    737737            result [i] = parent.findMenuItem (lpButton.idCommand); 
    738738        } 
     
    742742    int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle); 
    743743    MenuItem [] items = new MenuItem [length]; 
    744     MENUITEMINFO info = new MENUITEMINFO ()
     744    MENUITEMINFO info
    745745    info.cbSize = MENUITEMINFO.sizeof; 
    746746    info.fMask = OS.MIIM_DATA; 
    747     while (OS.GetMenuItemInfo (handle, index, true, info)) { 
     747    while (OS.GetMenuItemInfo (handle, index, true, &info)) { 
    748748        if (index == items.length) { 
    749749            MenuItem [] newItems = new MenuItem [index + 4]; 
     750            /+ TODO: arraycopy 
    750751            System.arraycopy (items, 0, newItems, 0, index); 
     752            +/ 
    751753            items = newItems; 
    752754        } 
     
    755757    if (index == items.length) return items; 
    756758    MenuItem [] result = new MenuItem [index]; 
     759    /+ TODO: arraycopy 
    757760    System.arraycopy (items, 0, result, 0, index); 
     761    +/ 
    758762    return result; 
    759763} 
     
    766770        } 
    767771        int count = 0; 
    768         MENUITEMINFO info = new MENUITEMINFO ()
     772        MENUITEMINFO info
    769773        info.cbSize = MENUITEMINFO.sizeof; 
    770         while (OS.GetMenuItemInfo (handle, count, true, info)) count++; 
     774        while (OS.GetMenuItemInfo (handle, count, true, &info)) count++; 
    771775        return count; 
    772776    } 
     
    780784    if (length > 0) { 
    781785        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 (); 
    785789    } 
    786790    return result; 
     
    877881    checkWidget (); 
    878882    if ((style & DWT.BAR) != 0) { 
    879         return this == parent.menuShell ().menuBar
     883        return cast(bool)(this == parent.menuShell().menuBar)
    880884    } 
    881885    if ((style & DWT.POP_UP) != 0) { 
     
    886890        } 
    887891    } 
    888     return this == getShell ().activeMenu
     892    return cast(bool)(this == getShell ().activeMenu);&n