Changeset 63:adfa8c39be39

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

Scale, ScrollBar?

Files:

Legend:

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

    r61 r63  
    17091709    public static const int TPM_RIGHTBUTTON = 0x2; 
    17101710    public static const int TPM_RIGHTALIGN = 0x8; 
    1711     public static const char[] TRACKBAR_CLASS = "msctls_trackbar32"; //$NON-NLS-1$ 
     1711    public static const TCHAR[] TRACKBAR_CLASS = "msctls_trackbar32"; //$NON-NLS-1$ 
    17121712    public static const int TRANSPARENT = 0x1; 
    17131713    public static const int TREIS_DISABLED = 4; 
  • dwt/widgets/Scale.d

    r62 r63  
    1515import dwt.events.SelectionListener; 
    1616import dwt.graphics.Point; 
    17 import dwt.internal.win32.LRESULT; 
    1817import dwt.internal.win32.OS; 
    19 import dwt.internal.win32.RECT; 
    20 import dwt.internal.win32.TCHAR; 
    21 import dwt.internal.win32.WNDCLASS; 
    2218 
    2319import dwt.widgets.Control; 
    2420import dwt.widgets.Composite; 
     21import dwt.widgets.TypedListener; 
     22import dwt.widgets.Event; 
    2523 
    2624import dwt.dwthelper.utils; 
     
    8078        lpWndClass.style &= ~OS.CS_GLOBALCLASS; 
    8179        lpWndClass.style |= OS.CS_DBLCLKS; 
    82         int byteCount = TrackBarClass.length () * TCHAR.sizeof; 
     80        int byteCount = (TrackBarClass.length+1) * TCHAR.sizeof; 
    8381        auto lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    84         OS.MoveMemory (lpszClassName, TrackBarClass, byteCount); 
     82        OS.MoveMemory (lpszClassName, TrackBarClass.ptr, byteCount); 
    8583        lpWndClass.lpszClassName = lpszClassName; 
    86         OS.RegisterClass (lpWndClass); 
     84        OS.RegisterClass (&lpWndClass); 
    8785        OS.HeapFree (hHeap, 0, lpszClassName); 
    8886    } 
     
    297295} 
    298296 
    299 override void setBackgroundImage (int hImage) { 
     297override void setBackgroundImage (HBITMAP hImage) { 
    300298    super.setBackgroundImage (hImage); 
    301299    /* 
     
    432430} 
    433431 
    434 override TCHAR windowClass () { 
    435     return TrackBarClass
     432override char[] windowClass () { 
     433    return TCHARsToStr(TrackBarClass)
    436434} 
    437435 
    438436override int windowProc () { 
    439     return TrackBarProc; 
     437    return cast(int) TrackBarProc; 
    440438} 
    441439 
     
    473471 
    474472override LRESULT WM_SIZE (int wParam, int lParam) { 
    475     if (ignoreResize) return null
     473    if (ignoreResize) return LRESULT.NULL
    476474    return super.WM_SIZE (wParam, lParam); 
    477475} 
  • dwt/widgets/ScrollBar.d

    r54 r63  
    1111module dwt.widgets.ScrollBar; 
    1212 
    13 import dwt.widgets.Widget; 
    14 class ScrollBar : Widget { 
    15     this( Widget, int ); 
    16 public void setMaximum (int value) ; 
    17 public void setThumb (int value) ; 
    18 public int getThumb () ; 
    19 public bool getEnabled () ; 
    20 public int getSelection () ; 
    21 public int getIncrement () ; 
    22 public int getPageIncrement () ; 
    23 LRESULT wmScrollChild (int wParam, int lParam) ; 
    24 public bool getVisible () ; 
    25 } 
    26 /++ 
    2713import dwt.DWT; 
    2814import dwt.DWTException; 
     
    3117import dwt.graphics.Point; 
    3218import dwt.graphics.Rectangle; 
    33 import dwt.internal.win32.LRESULT; 
    3419import dwt.internal.win32.OS; 
    35 import dwt.internal.win32.RECT; 
    36 import dwt.internal.win32.SCROLLINFO; 
     20 
     21import dwt.widgets.Widget; 
     22import dwt.widgets.TypedListener; 
     23import dwt.widgets.Event; 
     24import dwt.widgets.Scrollable; 
     25 
     26import dwt.dwthelper.utils; 
    3727 
    3828/** 
     
    10090 */ 
    10191 
    102 public class ScrollBar extends Widget { 
     92public class ScrollBar : Widget { 
    10393    Scrollable parent; 
    10494    int increment, pageIncrement; 
     
    133123 * @see Widget#getStyle 
    134124 */ 
    135 ScrollBar (Scrollable parent, int style) { 
     125this (Scrollable parent, int style) { 
    136126    super (parent, checkStyle (style)); 
    137127    this.parent = parent; 
     
    199189 
    200190override void destroyWidget () { 
    201     int hwnd = hwndScrollBar (), type = scrollBarType (); 
    202     if (OS.IsWinCE) { 
    203         SCROLLINFO info = new SCROLLINFO (); 
     191    auto hwnd = hwndScrollBar (); 
     192    auto type = scrollBarType (); 
     193    static if (OS.IsWinCE) { 
     194        SCROLLINFO info; 
    204195        info.cbSize = SCROLLINFO.sizeof; 
    205196        info.fMask = OS.SIF_RANGE | OS.SIF_PAGE; 
     
    207198        info.nMax = 100; 
    208199        info.nMin = 0; 
    209         OS.SetScrollInfo (hwnd, type, info, true); 
     200        OS.SetScrollInfo (hwnd, type, &info, true); 
    210201    } else { 
    211202        OS.ShowScrollBar (hwnd, type, false); 
     
    217208//  checkWidget (); 
    218209    parent.forceResize (); 
    219     RECT rect = new RECT ()
    220     OS.GetClientRect (parent.scrolledHandle (), rect); 
     210    RECT rect
     211    OS.GetClientRect (parent.scrolledHandle (), &rect); 
    221212    int x = 0, y = 0, width, height; 
    222213    if ((style & DWT.HORIZONTAL) !is 0) { 
     
    281272public int getMaximum () { 
    282273    checkWidget(); 
    283     SCROLLINFO info = new SCROLLINFO ()
     274    SCROLLINFO info
    284275    info.cbSize = SCROLLINFO.sizeof; 
    285276    info.fMask = OS.SIF_RANGE; 
    286     int hwnd = hwndScrollBar (); 
    287     int type = scrollBarType (); 
    288     OS.GetScrollInfo (hwnd, type, info); 
     277    auto hwnd = hwndScrollBar (); 
     278    auto type = scrollBarType (); 
     279    OS.GetScrollInfo (hwnd, type, &info); 
    289280    return info.nMax; 
    290281} 
     
    302293public int getMinimum () { 
    303294    checkWidget(); 
    304     SCROLLINFO info = new SCROLLINFO ()
     295    SCROLLINFO info
    305296    info.cbSize = SCROLLINFO.sizeof; 
    306297    info.fMask = OS.SIF_RANGE; 
    307     int hwnd = hwndScrollBar (); 
    308     int type = scrollBarType (); 
    309     OS.GetScrollInfo (hwnd, type, info); 
     298    auto hwnd = hwndScrollBar (); 
     299    auto type = scrollBarType (); 
     300    OS.GetScrollInfo (hwnd, type, &info); 
    310301    return info.nMin; 
    311302} 
     
    355346public int getSelection () { 
    356347    checkWidget(); 
    357     SCROLLINFO info = new SCROLLINFO ()
     348    SCROLLINFO info
    358349    info.cbSize = SCROLLINFO.sizeof; 
    359350    info.fMask = OS.SIF_POS; 
    360     int hwnd = hwndScrollBar (); 
    361     int type = scrollBarType (); 
    362     OS.GetScrollInfo (hwnd, type, info); 
     351    auto hwnd = hwndScrollBar (); 
     352    auto type = scrollBarType (); 
     353    OS.GetScrollInfo (hwnd, type, &info); 
    363354    return info.nPos; 
    364355} 
     
    380371    checkWidget(); 
    381372    parent.forceResize (); 
    382     RECT rect = new RECT ()
    383     OS.GetClientRect (parent.scrolledHandle (), rect); 
     373    RECT rect
     374    OS.GetClientRect (parent.scrolledHandle (), &rect); 
    384375    int width, height; 
    385376    if ((style & DWT.HORIZONTAL) !is 0) { 
     
    408399public int getThumb () { 
    409400    checkWidget(); 
    410     SCROLLINFO info = new SCROLLINFO ()
     401    SCROLLINFO info
    411402    info.cbSize = SCROLLINFO.sizeof; 
    412403    info.fMask = OS.SIF_PAGE; 
    413     int hwnd = hwndScrollBar (); 
    414     int type = scrollBarType (); 
    415     OS.GetScrollInfo (hwnd, type, info); 
     404    auto hwnd = hwndScrollBar (); 
     405    auto type = scrollBarType (); 
     406    OS.GetScrollInfo (hwnd, type, &info); 
    416407    if (info.nPage !is 0) --info.nPage; 
    417408    return info.nPage; 
     
    440431} 
    441432 
    442 int hwndScrollBar () { 
     433HWND hwndScrollBar () { 
    443434    return parent.scrolledHandle (); 
    444435} 
     
    543534    */ 
    544535//  if (OS.IsWinCE) error (DWT.ERROR_NOT_IMPLEMENTED); 
    545     if (!OS.IsWinCE) { 
    546         int hwnd = hwndScrollBar (), type = scrollBarType (); 
     536    static if (!OS.IsWinCE) { 
     537        auto hwnd = hwndScrollBar (); 
     538        auto type = scrollBarType (); 
    547539        int flags = enabled ? OS.ESB_ENABLE_BOTH : OS.ESB_DISABLE_BOTH; 
    548540        OS.EnableScrollBar (hwnd, type, flags); 
     
    590582    checkWidget(); 
    591583    if (value < 0) return; 
    592     SCROLLINFO info = new SCROLLINFO ()
     584    SCROLLINFO info
    593585    info.cbSize = SCROLLINFO.sizeof; 
    594     int hwnd = hwndScrollBar (), type = scrollBarType (); 
     586    auto hwnd = hwndScrollBar (); 
     587    auto type = scrollBarType (); 
    595588    info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL; 
    596     OS.GetScrollInfo (hwnd, type, info); 
     589    OS.GetScrollInfo (hwnd, type, &info); 
    597590    if (value - info.nMin - info.nPage < 1) return; 
    598591    info.nMax = value; 
    599     SetScrollInfo (hwnd, type, info, true); 
     592    SetScrollInfo (hwnd, type, &info, true); 
    600593} 
    601594 
     
    616609    checkWidget(); 
    617610    if (value < 0) return; 
    618     SCROLLINFO info = new SCROLLINFO ()
     611    SCROLLINFO info
    619612    info.cbSize = SCROLLINFO.sizeof; 
    620     int hwnd = hwndScrollBar (), type = scrollBarType (); 
     613    auto hwnd = hwndScrollBar (); 
     614    auto type = scrollBarType (); 
    621615    info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL; 
    622     OS.GetScrollInfo (hwnd, type, info); 
     616    OS.GetScrollInfo (hwnd, type, &info); 
    623617    if (info.nMax - value - info.nPage < 1) return; 
    624618    info.nMin = value; 
    625     SetScrollInfo (hwnd, type, info, true); 
     619    SetScrollInfo (hwnd, type, &info, true); 
    626620} 
    627621 
     
    645639} 
    646640 
    647 bool SetScrollInfo (int hwnd, int flags, SCROLLINFO info, bool fRedraw) { 
     641bool SetScrollInfo (HWND hwnd, int flags, SCROLLINFO* info, bool fRedraw) { 
    648642    /* 
    649643    * Bug in Windows.  For some reason, when SetScrollInfo() 
     
    655649    */ 
    656650    if ((state & (DISABLED | HIDDEN)) !is 0) fRedraw = false; 
    657     bool result = OS.SetScrollInfo (hwnd, flags, info, fRedraw); 
     651    bool result = cast(bool) OS.SetScrollInfo (hwnd, flags, info, fRedraw); 
    658652 
    659653    /* 
     
    722716public void setSelection (int selection) { 
    723717    checkWidget(); 
    724     SCROLLINFO info = new SCROLLINFO ()
     718    SCROLLINFO info
    725719    info.cbSize = SCROLLINFO.sizeof; 
    726     int hwnd = hwndScrollBar (), type = scrollBarType (); 
     720    auto hwnd = hwndScrollBar (); 
     721    auto type = scrollBarType (); 
    727722    info.fMask = OS.SIF_POS; 
    728723    info.nPos = selection; 
    729     SetScrollInfo (hwnd, type, info, true); 
     724    SetScrollInfo (hwnd, type, &info, true); 
    730725} 
    731726 
     
    747742    checkWidget(); 
    748743    if (value < 1) return; 
    749     SCROLLINFO info = new SCROLLINFO ()
     744    SCROLLINFO info
    750745    info.cbSize = SCROLLINFO.sizeof; 
    751     int hwnd = hwndScrollBar (), type = scrollBarType (); 
     746    auto hwnd = hwndScrollBar (); 
     747    auto type = scrollBarType (); 
    752748    info.fMask = OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL; 
    753     OS.GetScrollInfo (hwnd, type, info); 
     749    OS.GetScrollInfo (hwnd, type, &info); 
    754750    info.nPage = value; 
    755751    if (info.nPage !is 0) info.nPage++; 
    756     SetScrollInfo (hwnd, type, info, true); 
     752    SetScrollInfo (hwnd, type, &info, true); 
    757753} 
    758754 
     
    787783    this.increment = increment; 
    788784    this.pageIncrement = pageIncrement; 
    789     SCROLLINFO info = new SCROLLINFO ()
     785    SCROLLINFO info
    790786    info.cbSize = SCROLLINFO.sizeof; 
    791787    info.fMask = OS.SIF_POS | OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL; 
     
    795791    info.nPage = thumb; 
    796792    if (info.nPage !is 0) info.nPage++; 
    797     int hwnd = hwndScrollBar (), type = scrollBarType (); 
    798     SetScrollInfo (hwnd, type, info, true); 
     793    auto hwnd = hwndScrollBar (); 
     794    auto type = scrollBarType (); 
     795    SetScrollInfo (hwnd, type, &info, true); 
    799796} 
    800797 
     
    826823    */ 
    827824    if (OS.IsWinCE) { 
    828         SCROLLINFO info = new SCROLLINFO ()
     825        SCROLLINFO info
    829826        info.cbSize = SCROLLINFO.sizeof; 
    830         int hwnd = hwndScrollBar (), type = scrollBarType (); 
     827        auto hwnd = hwndScrollBar (); 
     828        auto type = scrollBarType (); 
    831829        info.fMask = OS.SIF_RANGE | OS.SIF_PAGE; 
    832830        if (visible) info.fMask |= OS.SIF_DISABLENOSCROLL; 
    833         OS.GetScrollInfo (hwnd, type, info); 
     831        OS.GetScrollInfo (hwnd, type, &info); 
    834832        if (info.nPage is info.nMax - info.nMin + 1) { 
    835833            /* 
     
    842840            int max = info.nMax; 
    843841            info.nMax++; 
    844             OS.SetScrollInfo (hwnd, type, info, false); 
     842            OS.SetScrollInfo (hwnd, type, &info, false); 
    845843            info.nMax = max; 
    846             OS.SetScrollInfo (hwnd, type, info, true); 
     844            OS.SetScrollInfo (hwnd, type, &info, true); 
    847845        } else { 
    848846            /* 
     
    864862    */ 
    865863    state = visible ? state & ~HIDDEN : state | HIDDEN; 
    866     int hwnd = hwndScrollBar (), type = scrollBarType (); 
     864    auto hwnd = hwndScrollBar (); 
     865    auto type = scrollBarType (); 
    867866    if (OS.ShowScrollBar (hwnd, type, visible)) { 
    868867        /* 
     
    880879        */ 
    881880        if ((state & DISABLED) is 0) { 
    882             SCROLLINFO info = new SCROLLINFO ()
     881            SCROLLINFO info
    883882            info.cbSize = SCROLLINFO.sizeof; 
    884883            info.fMask = OS.SIF_RANGE | OS.SIF_PAGE; 
    885             OS.GetScrollInfo (hwnd, type, info); 
     884            OS.GetScrollInfo (hwnd, type, &info); 
    886885            if (info.nMax - info.nMin - info.nPage >= 0) { 
    887886                OS.EnableScrollBar (hwnd, type, OS.ESB_ENABLE_BOTH); 
     
    897896    /* Do nothing when scrolling is ending */ 
    898897    int code = wParam & 0xFFFF; 
    899     if (code is OS.SB_ENDSCROLL) return null
     898    if (code is OS.SB_ENDSCROLL) return LRESULT.NULL
    900899 
    901900    /* 
     
    918917    sendEvent (DWT.Selection, event); 
    919918    // the widget could be destroyed at this point 
    920     return null
    921 } 
    922  
    923 } 
    924 ++/ 
     919    return LRESULT.NULL
     920} 
     921 
     922} 
     923