Changeset 62:7757dae4f29f

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

Sash

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/widgets/Sash.d

    r54 r62  
    1111module dwt.widgets.Sash; 
    1212 
    13 import dwt.widgets.Control; 
    14 class Sash : Control { 
    15 
    16 /++ 
     13 
     14 
    1715import dwt.DWT; 
    1816import dwt.DWTException; 
     
    2018import dwt.events.SelectionListener; 
    2119import dwt.graphics.Point; 
    22 import dwt.internal.win32.LRESULT; 
    2320import dwt.internal.win32.OS; 
    24 import dwt.internal.win32.POINT; 
    25 import dwt.internal.win32.RECT; 
    26 import dwt.internal.win32.TCHAR; 
     21 
     22import dwt.widgets.Control; 
     23import dwt.widgets.Composite; 
     24import dwt.widgets.TypedListener; 
     25import dwt.widgets.Event; 
     26 
     27import dwt.dwthelper.utils; 
    2728 
    2829/** 
     
    4344 * </p> 
    4445 */ 
    45 public class Sash extends Control { 
     46public class Sash : Control { 
    4647 
    4748    alias Control.computeSize computeSize; 
     
    5051    bool dragging; 
    5152    int startX, startY, lastX, lastY; 
    52     final static int INCREMENT = 1; 
    53     final static int PAGE_INCREMENT = 9; 
     53    const static int INCREMENT = 1; 
     54    const static int PAGE_INCREMENT = 9; 
    5455 
    5556/** 
     
    8283 * @see Widget#getStyle 
    8384 */ 
    84 public Sash (Composite parent, int style) { 
     85public this (Composite parent, int style) { 
    8586    super (parent, checkStyle (style)); 
    8687} 
     
    119120} 
    120121 
    121 override int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    122     if (handle is 0) return 0
    123     return OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     122override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     123    if (handle is null) return LRESULT.ZERO
     124    return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 
    124125} 
    125126 
     
    149150void drawBand (int x, int y, int width, int height) { 
    150151    if ((style & DWT.SMOOTH) !is 0) return; 
    151     int hwndTrack = parent.handle; 
    152     byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0}
    153     int stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits); 
    154     int stippleBrush = OS.CreatePatternBrush (stippleBitmap); 
    155     int hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE); 
    156     int oldBrush = OS.SelectObject (hDC, stippleBrush); 
     152    HWND hwndTrack = parent.handle; 
     153    byte [] bits = [-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0]
     154    auto stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits.ptr); 
     155    auto stippleBrush = OS.CreatePatternBrush (stippleBitmap); 
     156    auto hDC = OS.GetDCEx (hwndTrack, null, OS.DCX_CACHE); 
     157    auto oldBrush = OS.SelectObject (hDC, stippleBrush); 
    157158    OS.PatBlt (hDC, x, y, width, height, OS.PATINVERT); 
    158159    OS.SelectObject (hDC, oldBrush); 
     
    187188} 
    188189 
    189 override TCHAR windowClass () { 
    190     return display.windowClass
     190override char[] windowClass () { 
     191    return display.windowClass()
    191192} 
    192193 
    193194override int windowProc () { 
    194     return display.windowProc
     195    return display.windowProc()
    195196} 
    196197 
    197198override LRESULT WM_ERASEBKGND (int wParam, int lParam) { 
    198199    super.WM_ERASEBKGND (wParam, lParam); 
    199     drawBackground (wParam); 
     200    drawBackground (cast(HANDLE) wParam); 
    200201    return LRESULT.ONE; 
    201202} 
     
    203204override LRESULT WM_KEYDOWN (int wParam, int lParam) { 
    204205    LRESULT result = super.WM_KEYDOWN (wParam, lParam); 
    205     if (result !is null) return result; 
     206    if (result !is LRESULT.NULL) return result; 
    206207    switch (wParam) { 
    207208        case OS.VK_LEFT: 
     
    213214            if (OS.GetKeyState (OS.VK_LBUTTON) < 0) return result; 
    214215            int step = OS.GetKeyState (OS.VK_CONTROL) < 0 ? INCREMENT : PAGE_INCREMENT; 
    215             POINT pt = new POINT ()
     216            POINT pt
    216217            if ((style & DWT.VERTICAL) !is 0) { 
    217218                if (wParam is OS.VK_UP || wParam is OS.VK_DOWN) break; 
     
    221222                pt.y = wParam is OS.VK_UP ? -step : step; 
    222223            } 
    223             int hwndTrack = parent.handle; 
    224             OS.MapWindowPoints (handle, hwndTrack, pt, 1); 
    225             RECT rect = new RECT (), clientRect = new RECT ()
    226             OS.GetWindowRect (handle, rect); 
     224            auto hwndTrack = parent.handle; 
     225            OS.MapWindowPoints (handle, hwndTrack, &pt, 1); 
     226            RECT rect, clientRect
     227            OS.GetWindowRect (handle, &rect); 
    227228            int width = rect.right - rect.left; 
    228229            int height = rect.bottom - rect.top; 
    229             OS.GetClientRect (hwndTrack, clientRect); 
     230            OS.GetClientRect (hwndTrack, &clientRect); 
    230231            int clientWidth = clientRect.right - clientRect.left; 
    231232            int clientHeight = clientRect.bottom - clientRect.top; 
     
    239240 
    240241            /* Update the pointer position */ 
    241             POINT cursorPt = new POINT ()
     242            POINT cursorPt
    242243            cursorPt.x = pt.x;  cursorPt.y = pt.y; 
    243             OS.ClientToScreen (hwndTrack, cursorPt); 
     244            OS.ClientToScreen (hwndTrack, &cursorPt); 
    244245            if ((style & DWT.VERTICAL) !is 0) { 
    245246                cursorPt.y += height / 2; 
     
    268269 
    269270override LRESULT WM_GETDLGCODE (int wParam, int lParam) { 
    270     return new LRESULT (OS.DLGC_STATIC); 
     271    return cast(LRESULT)(OS.DLGC_STATIC); 
    271272} 
    272273 
     
    276277 
    277278    /* Compute the banding rectangle */ 
    278     int hwndTrack = parent.handle; 
    279     POINT pt = new POINT ()
    280     pt.x = (short) (lParam & 0xFFFF); 
    281     pt.y = (short) (lParam >> 16); 
    282     RECT rect = new RECT ()
    283     OS.GetWindowRect (handle, rect); 
    284     OS.MapWindowPoints (handle, 0, pt, 1); 
     279    auto hwndTrack = parent.handle; 
     280    POINT pt
     281    pt.x = cast(short) (lParam & 0xFFFF); 
     282    pt.y = cast(short) (lParam >> 16); 
     283    RECT rect
     284    OS.GetWindowRect (handle, &rect); 
     285    OS.MapWindowPoints (handle, null, &pt, 1); 
    285286    startX = pt.x - rect.left; 
    286287    startY = pt.y - rect.top; 
    287     OS.MapWindowPoints (0, hwndTrack, rect, 2); 
     288    OS.MapWindowPoints (null, hwndTrack, cast(POINT*) &rect, 2); 
    288289    lastX = rect.left; 
    289290    lastY = rect.top; 
     
    314315        } else { 
    315316            int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; 
    316             OS.RedrawWindow (hwndTrack, null, 0, flags); 
     317            OS.RedrawWindow (hwndTrack, null, null, flags); 
    317318        } 
    318319        drawBand (event.x, event.y, width, height); 
     
    332333    if (!dragging) return result; 
    333334    dragging = false; 
    334     RECT rect = new RECT ()
    335     OS.GetWindowRect (handle, rect); 
     335    RECT rect
     336    OS.GetWindowRect (handle, &rect); 
    336337    int width = rect.right - rect.left; 
    337338    int height = rect.bottom - rect.top; 
     
    357358override LRESULT WM_MOUSEMOVE (int wParam, int lParam) { 
    358359    LRESULT result = super.WM_MOUSEMOVE (wParam, lParam); 
    359     if (result !is null) return result; 
     360    if (result !is LRESULT.NULL) return result; 
    360361    if (!dragging || (wParam & OS.MK_LBUTTON) is 0) return result; 
    361362 
    362363    /* Compute the banding rectangle */ 
    363     POINT pt = new POINT ()
    364     pt.x = (short) (lParam & 0xFFFF); 
    365     pt.y = (short) (lParam >> 16); 
    366     int hwndTrack = parent.handle; 
    367     OS.MapWindowPoints (handle, hwndTrack, pt, 1); 
    368     RECT rect = new RECT (), clientRect = new RECT ()
    369     OS.GetWindowRect (handle, rect); 
     364    POINT pt
     365    pt.x = cast(short) (lParam & 0xFFFF); 
     366    pt.y = cast(short) (lParam >> 16); 
     367    auto hwndTrack = parent.handle; 
     368    OS.MapWindowPoints (handle, hwndTrack, &pt, 1); 
     369    RECT rect, clientRect
     370    OS.GetWindowRect (handle, &rect); 
    370371    int width = rect.right - rect.left; 
    371372    int height = rect.bottom - rect.top; 
    372     OS.GetClientRect (hwndTrack, clientRect); 
     373    OS.GetClientRect (hwndTrack, &clientRect); 
    373374    int newX = lastX, newY = lastY; 
    374375    if ((style & DWT.VERTICAL) !is 0) { 
     
    401402    } else { 
    402403        int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; 
    403         OS.RedrawWindow (hwndTrack, null, 0, flags); 
     404        OS.RedrawWindow (hwndTrack, null, null, flags); 
    404405    } 
    405406    drawBand (lastX, lastY, width, height); 
     
    413414override LRESULT WM_SETCURSOR (int wParam, int lParam) { 
    414415    LRESULT result = super.WM_SETCURSOR (wParam, lParam); 
    415     if (result !is null) return result; 
     416    if (result !is LRESULT.NULL) return result; 
    416417    int hitTest = lParam & 0xFFFF; 
    417418    if (hitTest is OS.HTCLIENT) { 
    418         int hCursor = 0
     419        HCURSOR hCursor
    419420        if ((style & DWT.HORIZONTAL) !is 0) { 
    420             hCursor = OS.LoadCursor (0, OS.IDC_SIZENS); 
     421            hCursor = OS.LoadCursor (null, cast(TCHAR*)OS.IDC_SIZENS); 
    421422        } else { 
    422             hCursor = OS.LoadCursor (0, OS.IDC_SIZEWE); 
     423            hCursor = OS.LoadCursor (null, cast(TCHAR*)OS.IDC_SIZEWE); 
    423424        } 
    424425        OS.SetCursor (hCursor); 
     
    429430 
    430431} 
    431 ++/ 
     432 
  • dwt/widgets/Scale.d

    r54 r62  
    1111module dwt.widgets.Scale; 
    1212 
    13 import dwt.widgets.Control; 
    14 import dwt.widgets.Composite; 
    15  
    16 class Scale : Control { 
    17     this (Composite parent, int style) ; 
    18 } 
    19 /++ 
    2013import dwt.DWT; 
    2114import dwt.DWTException; 
     
    2720import dwt.internal.win32.TCHAR; 
    2821import dwt.internal.win32.WNDCLASS; 
     22 
     23import dwt.widgets.Control; 
     24import dwt.widgets.Composite; 
     25 
     26import dwt.dwthelper.utils; 
    2927 
    3028/** 
     
    4745 */ 
    4846 
    49 public class Scale extends Control { 
     47public class Scale : Control { 
    5048 
    5149    alias Control.computeSize computeSize; 
     
    5452 
    5553    bool ignoreResize; 
    56     static final int TrackBarProc; 
    57     static final TCHAR TrackBarClass = new TCHAR (0, OS.TRACKBAR_CLASS, true)
    58     static
    59         WNDCLASS lpWndClass = new WNDCLASS ()
    60         OS.GetClassInfo (0, TrackBarClass, lpWndClass); 
     54    static const WNDPROC TrackBarProc; 
     55    static const TCHAR[] TrackBarClass = OS.TRACKBAR_CLASS
     56    static this()
     57        WNDCLASS lpWndClass
     58        OS.GetClassInfo (null, TrackBarClass.ptr, &lpWndClass); 
    6159        TrackBarProc = lpWndClass.lpfnWndProc; 
    6260        /* 
     
    7775        * this class name, and fail unexpectedly. 
    7876        */ 
    79         int hInstance = OS.GetModuleHandle (null); 
    80         int hHeap = OS.GetProcessHeap (); 
     77        auto hInstance = OS.GetModuleHandle (null); 
     78        auto hHeap = OS.GetProcessHeap (); 
    8179        lpWndClass.hInstance = hInstance; 
    8280        lpWndClass.style &= ~OS.CS_GLOBALCLASS; 
    8381        lpWndClass.style |= OS.CS_DBLCLKS; 
    8482        int byteCount = TrackBarClass.length () * TCHAR.sizeof; 
    85         int lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     83        auto lpszClassName = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    8684        OS.MoveMemory (lpszClassName, TrackBarClass, byteCount); 
    8785        lpWndClass.lpszClassName = lpszClassName; 
     
    119117 * @see Widget#getStyle 
    120118 */ 
    121 public Scale (Composite parent, int style) { 
     119public this (Composite parent, int style) { 
    122120    super (parent, checkStyle (style)); 
    123121} 
     
    154152} 
    155153 
    156 override int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    157     if (handle is 0) return 0
    158     return OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam); 
     154override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     155    if (handle is null) return LRESULT.ZERO
     156    return cast(LRESULT)OS.CallWindowProc (TrackBarProc, hwnd, msg, wParam, lParam); 
    159157} 
    160158 
     
    167165    int border = getBorderWidth (); 
    168166    int width = border * 2, height = border * 2; 
    169     RECT rect = new RECT ()
    170     OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, rect); 
     167    RECT rect
     168    OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, &rect); 
    171169    if ((style & DWT.HORIZONTAL) !is 0) { 
    172170        width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10; 
     
    486484        case OS.TB_ENDTRACK: 
    487485        case OS.TB_THUMBPOSITION: 
    488             return null
     486            return LRESULT.NULL
    489487    } 
    490488 
     
    511509    sendEvent (DWT.Selection, event); 
    512510    // widget could be disposed at this point 
    513     return null
    514 } 
    515  
    516 } 
    517 ++/ 
     511    return LRESULT.NULL
     512} 
     513 
     514} 
     515