Changeset 47:6940f8be58ba

Show
Ignore:
Timestamp:
02/02/08 18:59:28 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

ExpandBar?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • doc/Common.txt

    r2 r47  
    1 Dwt-win shares some modules with the Dwt-linux port. For now, the revision and changeset of the dwt-linux port will be listed here for future reference, in case there are updates to the linux port.   
     1Dwt-win shares some modules with the Dwt-linux port. For now, the revision and changeset of the dwt-linux port will be listed here for future reference, in case there are updates to the linux port. 
    22 
    33This is the revision that the Dwt-win modules are based on: 
     
    2020dwt/internal/SerializableCompatibility.d 
    2121 
     22- Verify getCodePage accesses 
     23- OS.CallWindowProc was removed in various places. It turned out, they are need. So revert those changeset 
     24- OS.MoveMemory, use it and make the ported code more like the original 
    2225 
     26Left out widgets: 
     27    DateTime 
     28    DirectoryDialog 
     29 
     30 
     31 
     32 
  • dwt/internal/win32/OS.d

    r45 r47  
    869869    public static const int IDC_ARROW = 0x7f00; 
    870870    public static const int IDC_CROSS = 0x7f03; 
    871     public static const int IDC_HAND = 0x7f89; 
     871    public static const TCHAR* IDC_HAND = cast(TCHAR*) 0x7f89; 
    872872    public static const int IDC_HELP = 0x7f8b; 
    873873    public static const int IDC_IBEAM = 0x7f01; 
  • dwt/widgets/ExpandBar.d

    r31 r47  
    1313module dwt.widgets.ExpandBar; 
    1414 
    15 import dwt.widgets.Composite; 
    16 class ExpandBar : Composite { 
    17 
    18 /++ 
     15 
    1916import dwt.DWT; 
    2017import dwt.DWTException; 
     
    2724import dwt.graphics.Point; 
    2825import dwt.graphics.Rectangle; 
    29 import dwt.internal.win32.LOGFONT; 
    30 import dwt.internal.win32.LRESULT; 
    31 import dwt.internal.win32.NONCLIENTMETRICS; 
    32 import dwt.internal.win32.NONCLIENTMETRICSA; 
    33 import dwt.internal.win32.NONCLIENTMETRICSW; 
     26import dwt.graphics.Drawable; 
    3427import dwt.internal.win32.OS; 
    35 import dwt.internal.win32.PAINTSTRUCT; 
    36 import dwt.internal.win32.RECT; 
    37 import dwt.internal.win32.SCROLLINFO; 
    38 import dwt.internal.win32.TCHAR; 
    39 import dwt.internal.win32.TEXTMETRIC; 
    40 import dwt.internal.win32.TEXTMETRICA; 
    41 import dwt.internal.win32.TEXTMETRICW; 
     28 
     29import dwt.widgets.Composite; 
     30import dwt.widgets.Control; 
     31import dwt.widgets.ExpandItem; 
     32import dwt.widgets.ScrollBar; 
     33import dwt.widgets.ExpandItem; 
     34import dwt.widgets.TypedListener; 
     35import dwt.widgets.Event; 
     36 
     37import dwt.dwthelper.utils; 
    4238 
    4339/** 
     
    6561 * @since 3.2 
    6662 */ 
    67 public class ExpandBar extends Composite { 
     63public class ExpandBar : Composite { 
    6864    ExpandItem[] items; 
    6965    int itemCount; 
     
    7167    int spacing = 4; 
    7268    int yCurrentScroll; 
    73     int hFont; 
     69    HFONT hFont; 
    7470 
    7571 
     
    10197 * @see Widget#getStyle 
    10298 */ 
    103 public ExpandBar (Composite parent, int style) { 
     99public this (Composite parent, int style) { 
    104100    super (parent, checkStyle (style)); 
    105101} 
     
    132128} 
    133129 
    134 int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    135     if (handle is 0) return 0
    136     return OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     130LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     131    if (handle is null) return LRESULT.ZERO
     132    return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 
    137133} 
    138134 
     
    151147    if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) { 
    152148        if (itemCount > 0) { 
    153             int hDC = OS.GetDC (handle); 
    154             int hTheme = 0
     149            auto hDC = OS.GetDC (handle); 
     150            HTHEME hTheme
    155151            if (isAppThemed ()) { 
    156152                hTheme = display.hExplorerBarTheme (); 
    157153            } 
    158             int hCurrentFont = 0, oldFont = 0
    159             if (hTheme is 0) { 
    160                 if (hFont !is 0) { 
     154            HFONT hCurrentFont, oldFont
     155            if (hTheme is null) { 
     156                if (hFont !is null) { 
    161157                    hCurrentFont = hFont; 
    162158                } else { 
    163159                    if (!OS.IsWinCE) { 
    164                         NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ()
     160                        NONCLIENTMETRICS info
    165161                        info.cbSize = NONCLIENTMETRICS.sizeof; 
    166                         if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) { 
    167                             LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfCaptionFont : ((NONCLIENTMETRICSA)info).lfCaptionFont; 
     162                        if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) { 
     163                            LOGFONT* logFont = &info.lfCaptionFont; 
    168164                            hCurrentFont = OS.CreateFontIndirect (logFont); 
    169165                        } 
    170166                    } 
    171167                } 
    172                 if (hCurrentFont !is 0) { 
     168                if (hCurrentFont !is null) { 
    173169                    oldFont = OS.SelectObject (hDC, hCurrentFont); 
    174170                } 
     
    182178                width = Math.max (width, item.getPreferredWidth (hTheme, hDC)); 
    183179            } 
    184             if (hCurrentFont !is 0) { 
     180            if (hCurrentFont !is null) { 
    185181                OS.SelectObject (hDC, oldFont); 
    186182                if (hCurrentFont !is hFont) OS.DeleteObject (hCurrentFont); 
     
    215211    if (focusItem is null) focusItem = item; 
    216212 
    217     RECT rect = new RECT ()
    218     OS.GetWindowRect (handle, rect); 
     213    RECT rect
     214    OS.GetWindowRect (handle, &rect); 
    219215    item.width = Math.max (0, rect.right - rect.left - spacing * 2); 
    220216    layoutItems (index, true); 
     
    258254} 
    259255 
    260 void drawThemeBackground (int hDC, int hwnd, RECT rect) { 
    261     RECT rect2 = new RECT ()
    262     OS.GetClientRect (handle, rect2); 
    263     OS.MapWindowPoints (handle, hwnd, rect2, 2); 
    264     OS.DrawThemeBackground (display.hExplorerBarTheme (), hDC, OS.EBP_NORMALGROUPBACKGROUND, 0, rect2, null); 
    265 } 
    266  
    267 void drawWidget (GC gc, RECT clipRect) { 
    268     int hTheme = 0
     256void drawThemeBackground (HDC hDC, HWND hwnd, RECT* rect) { 
     257    RECT rect2
     258    OS.GetClientRect (handle, &rect2); 
     259    OS.MapWindowPoints (handle, hwnd, cast(POINT*) &rect2, 2); 
     260    OS.DrawThemeBackground (display.hExplorerBarTheme (), hDC, OS.EBP_NORMALGROUPBACKGROUND, 0, &rect2, null); 
     261} 
     262 
     263void drawWidget (GC gc, RECT* clipRect) { 
     264    HTHEME hTheme
    269265    if (isAppThemed ()) { 
    270266        hTheme = display.hExplorerBarTheme (); 
    271267    } 
    272     if (hTheme !is 0) { 
    273         RECT rect = new RECT ()
    274         OS.GetClientRect (handle, rect); 
    275         OS.DrawThemeBackground (hTheme, gc.handle, OS.EBP_HEADERBACKGROUND, 0, rect, clipRect); 
     268    if (hTheme !is null) { 
     269        RECT rect
     270        OS.GetClientRect (handle, &rect); 
     271        OS.DrawThemeBackground (hTheme, gc.handle, OS.EBP_HEADERBACKGROUND, 0, &rect, clipRect); 
    276272    } else { 
    277273        drawBackground (gc.handle); 
     
    282278        drawFocus = (uiState & OS.UISF_HIDEFOCUS) is 0; 
    283279    } 
    284     int hCaptionFont = 0, oldFont = 0
    285     if (hTheme is 0) { 
    286         if (!OS.IsWinCE && hFont is 0) { 
    287             NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ()
     280    HFONT hCaptionFont, oldFont
     281    if (hTheme is null) { 
     282        if (!OS.IsWinCE && hFont is null) { 
     283            NONCLIENTMETRICS info
    288284            info.cbSize = NONCLIENTMETRICS.sizeof; 
    289             if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) { 
    290                 LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfCaptionFont : ((NONCLIENTMETRICSA)info).lfCaptionFont; 
     285            if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) { 
     286                LOGFONT* logFont = &info.lfCaptionFont; 
    291287                hCaptionFont = OS.CreateFontIndirect (logFont); 
    292288                oldFont = OS.SelectObject (gc.handle, hCaptionFont); 
     
    298294        item.drawItem (gc, hTheme, clipRect, item is focusItem && drawFocus); 
    299295    } 
    300     if (hCaptionFont !is 0) { 
     296    if (hCaptionFont !is null) { 
    301297        OS.SelectObject (gc.handle, oldFont); 
    302298        OS.DeleteObject (hCaptionFont); 
     
    317313 
    318314int getBandHeight () { 
    319     if (hFont is 0) return ExpandItem.CHEVRON_SIZE; 
    320     int hDC = OS.GetDC (handle); 
    321     int oldHFont = OS.SelectObject (hDC, hFont); 
    322     TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA()
    323     OS.GetTextMetrics (hDC, lptm); 
     315    if (hFont is null) return ExpandItem.CHEVRON_SIZE; 
     316    auto hDC = OS.GetDC (handle); 
     317    auto oldHFont = OS.SelectObject (hDC, hFont); 
     318    TEXTMETRIC lptm
     319    OS.GetTextMetrics (hDC, &lptm); 
    324320    OS.SelectObject (hDC, oldHFont); 
    325321    OS.ReleaseDC (handle, hDC); 
     
    431427    if (background !is -1) return false; 
    432428    if (foreground !is -1) return false; 
    433     if (hFont !is 0) return false; 
     429    if (hFont !is null) return false; 
    434430    return OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed (); 
    435431} 
    436432 
    437 void layoutItems (int index, bool setScrollbar) { 
     433void layoutItems (int index, bool setScrollbar_) { 
    438434    if (index < itemCount) { 
    439435        int y = spacing - yCurrentScroll; 
     
    450446        } 
    451447    } 
    452     if (setScrollbar) setScrollbar (); 
     448    if (setScrollbar_) setScrollbar (); 
    453449} 
    454450 
     
    496492    if (!OS.IsWinCE) { 
    497493        int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN; 
    498         OS.RedrawWindow (handle, null, 0, flags); 
     494        OS.RedrawWindow (handle, null, null, flags); 
    499495    } 
    500496} 
     
    502498public void setFont (Font font) { 
    503499    super.setFont (font); 
    504     hFont = font !is null ? font.handle : 0
     500    hFont = font !is null ? font.handle : null
    505501    layoutItems (0, true); 
    506502} 
     
    510506    if (!OS.IsWinCE) { 
    511507        int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN; 
    512         OS.RedrawWindow (handle, null, 0, flags); 
     508        OS.RedrawWindow (handle, null, null, flags); 
    513509    } 
    514510} 
     
    517513    if (itemCount is 0) return; 
    518514    if ((style & DWT.V_SCROLL) is 0) return; 
    519     RECT rect = new RECT()
    520     OS.GetClientRect (handle, rect); 
     515    RECT rect
     516    OS.GetClientRect (handle, &rect); 
    521517    int height = rect.bottom - rect.top; 
    522518    ExpandItem item = items [itemCount - 1]; 
     
    531527    maxHeight += yCurrentScroll; 
    532528 
    533     SCROLLINFO info = new SCROLLINFO ()
     529    SCROLLINFO info
    534530    info.cbSize = SCROLLINFO.sizeof; 
    535531    info.fMask = OS.SIF_RANGE | OS.SIF_PAGE | OS.SIF_POS; 
     
    539535    info.nPos = Math.min (yCurrentScroll, info.nMax); 
    540536    if (info.nPage !is 0) info.nPage++; 
    541     OS.SetScrollInfo (handle, OS.SB_VERT, info, true); 
     537    OS.SetScrollInfo (handle, OS.SB_VERT, &info, true); 
    542538} 
    543539 
     
    556552    if (spacing is this.spacing) return; 
    557553    this.spacing = spacing; 
    558     RECT rect = new RECT ()
    559     OS.GetClientRect (handle, rect); 
     554    RECT rect
     555    OS.GetClientRect (handle, &rect); 
    560556    int width = Math.max (0, (rect.right - rect.left) - spacing * 2); 
    561557    for (int i = 0; i < itemCount; i++) { 
     
    577573} 
    578574 
    579 TCHAR windowClass () { 
    580     return display.windowClass
     575char[] windowClass () { 
     576    return display.windowClass()
    581577} 
    582578 
    583579int windowProc () { 
    584     return display.windowProc; 
     580    return cast(int) display.windowProc; 
    585581} 
    586582 
    587583LRESULT WM_KEYDOWN (int wParam, int lParam) { 
    588584    LRESULT result = super.WM_KEYDOWN (wParam, lParam); 
    589     if (result !is null) return result; 
     585    if (result !is LRESULT.NULL) return result; 
    590586    if (focusItem is null) return result; 
    591587    switch (wParam) { 
     
    631627    LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam); 
    632628    if (result is LRESULT.ZERO) return result; 
    633     int x = (short) (lParam & 0xFFFF); 
    634     int y = (short) (lParam >> 16); 
     629    int x = cast(short) (lParam & 0xFFFF); 
     630    int y = cast(short) (lParam >> 16); 
    635631    for (int i = 0; i < itemCount; i++) { 
    636632        ExpandItem item = items[i]; 
     
    651647    if (result is LRESULT.ZERO) return result; 
    652648    if (focusItem is null) return result; 
    653     int x = (short) (lParam & 0xFFFF); 
    654     int y = (short) (lParam >> 16); 
     649    int x = cast(short) (lParam & 0xFFFF); 
     650    int y = cast(short) (lParam >> 16); 
    655651    bool hover = focusItem.isHover (x, y); 
    656652    if (hover) { 
     
    666662LRESULT WM_MOUSELEAVE (int wParam, int lParam) { 
    667663    LRESULT result = super.WM_MOUSELEAVE (wParam, lParam); 
    668     if (result !is null) return result; 
     664    if (result !is LRESULT.NULL) return result; 
    669665    for (int i = 0; i < itemCount; i++) { 
    670666        ExpandItem item = items [i]; 
     
    681677    LRESULT result = super.WM_MOUSEMOVE (wParam, lParam); 
    682678    if (result is LRESULT.ZERO) return result; 
    683     int x = (short) (lParam & 0xFFFF); 
    684     int y = (short) (lParam >> 16); 
     679    int x = cast(short) (lParam & 0xFFFF); 
     680    int y = cast(short) (lParam >> 16); 
    685681    for (int i = 0; i < itemCount; i++) { 
    686682        ExpandItem item = items [i]; 
     
    695691 
    696692LRESULT WM_PAINT (int wParam, int lParam) { 
    697     PAINTSTRUCT ps = new PAINTSTRUCT ()
     693    PAINTSTRUCT ps
    698694    GCData data = new GCData (); 
    699     data.ps = ps; 
     695    data.ps = &ps; 
    700696    data.hwnd = handle; 
    701697    GC gc = new_GC (data); 
    702698    if (gc !is null) { 
    703         int width = ps.right - ps.left; 
    704         int height = ps.bottom - ps.top; 
     699        int width = ps.rcPaint.right - ps.rcPaint.left; 
     700        int height = ps.rcPaint.bottom - ps.rcPaint.top; 
    705701        if (width !is 0 && height !is 0) { 
    706             RECT rect = new RECT ()
    707             OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom); 
    708             drawWidget (gc, rect); 
     702            RECT rect
     703            OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); 
     704            drawWidget (gc, &rect); 
    709705            if (hooks (DWT.Paint) || filters (DWT.Paint)) { 
    710706                Event event = new Event (); 
     
    725721LRESULT WM_PRINTCLIENT (int wParam, int lParam) { 
    726722    LRESULT result = super.WM_PRINTCLIENT (wParam, lParam); 
    727     RECT rect = new RECT ()
    728     OS.GetClientRect (handle, rect); 
     723    RECT rect
     724    OS.GetClientRect (handle, &rect); 
    729725    GCData data = new GCData (); 
    730726    data.device = display; 
    731727    data.foreground = getForegroundPixel (); 
    732     GC gc = GC.win32_new (wParam, data); 
    733     drawWidget (gc, rect); 
     728    GC gc = GC.win32_new ( cast(Drawable)cast(void*)wParam, data); 
     729    drawWidget (gc, &rect); 
    734730    gc.dispose (); 
    735731    return result; 
     
    738734LRESULT WM_SETCURSOR (int wParam, int lParam) { 
    739735    LRESULT result = super.WM_SETCURSOR (wParam, lParam); 
    740     if (result !is null) return result; 
     736    if (result !is LRESULT.NULL) return result; 
    741737    int hitTest = lParam & 0xFFFF; 
    742738    if (hitTest is OS.HTCLIENT) { 
     
    744740            ExpandItem item = items [i]; 
    745741            if (item.hover) { 
    746                 int hCursor = OS.LoadCursor (0, OS.IDC_HAND); 
     742                auto hCursor = OS.LoadCursor (null, OS.IDC_HAND); 
    747743                OS.SetCursor (hCursor); 
    748744                return LRESULT.ONE; 
     
    761757LRESULT WM_SIZE (int wParam, int lParam) { 
    762758    LRESULT result = super.WM_SIZE (wParam, lParam); 
    763     RECT rect = new RECT ()
    764     OS.GetClientRect (handle, rect); 
     759    RECT rect
     760    OS.GetClientRect (handle, &rect); 
    765761    int width = Math.max (0, (rect.right - rect.left) - spacing * 2); 
    766762    for (int i = 0; i < itemCount; i++) { 
     
    773769} 
    774770 
    775 LRESULT wmScroll (ScrollBar bar, bool update, int hwnd, int msg, int wParam, int lParam) { 
     771LRESULT wmScroll (ScrollBar bar, bool update, HWND hwnd, int msg, int wParam, int lParam) { 
    776772    LRESULT result = super.wmScroll (bar, true, hwnd, msg, wParam, lParam); 
    777     SCROLLINFO info = new SCROLLINFO ()
     773    SCROLLINFO info
    778774    info.cbSize = SCROLLINFO.sizeof; 
    779775    info.fMask = OS.SIF_POS; 
    780     OS.GetScrollInfo (handle, OS.SB_VERT, info); 
     776    OS.GetScrollInfo (handle, OS.SB_VERT, &info); 
    781777    int updateY = yCurrentScroll - info.nPos; 
    782     OS.ScrollWindowEx (handle, 0, updateY, null, null, 0, null, OS.SW_SCROLLCHILDREN | OS.SW_INVALIDATE); 
     778    OS.ScrollWindowEx (handle, 0, updateY, null, null, null, null, OS.SW_SCROLLCHILDREN | OS.SW_INVALIDATE); 
    783779    yCurrentScroll = info.nPos; 
    784780    if (updateY !is 0) { 
     
    790786} 
    791787} 
    792 ++/ 
     788 
  • dwt/widgets/ExpandItem.d

    r45 r47  
    3232    bool getExpanded(); 
    3333    void setControl(Control); 
    34     void drawItem(GC, int, RECT, bool); 
     34    void drawItem(GC, HTHEME, RECT*, bool); 
    3535    bool isHover(int, int); 
    3636    void setExpanded(bool); 
     
    4242    void setHeight(int); 
    4343    override void setImage(Image); 
    44     int getPreferredWidth(int, int); 
     44    int getPreferredWidth(HTHEME, HDC); 
    4545    int getHeaderHeight(); 
    4646    ExpandBar parent; 
     
    227227} 
    228228 
    229 void drawItem (GC gc, int hTheme, RECT clipRect, bool drawFocus) { 
     229void drawItem (GC gc, HTHEME hTheme, RECT* clipRect, bool drawFocus) { 
    230230    int hDC = gc.handle; 
    231231    int headerHeight = parent.getBandHeight (); 
     
    372372} 
    373373 
    374 int getPreferredWidth (int hTheme, int hDC) { 
     374int getPreferredWidth (HTHEME hTheme, HDC hDC) { 
    375375    int width = ExpandItem.TEXT_INSET * 2 + ExpandItem.CHEVRON_SIZE; 
    376376    if (image !is null) {