Changeset 53

Show
Ignore:
Timestamp:
05/16/07 02:49:16 (2 years ago)
Author:
lindquist
Message:

Win32 fixed GroupBox? bug #12

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/bughunt/minwin/button.d

    r52 r53  
    3434        // only command is action command 
    3535        version(LOG) log.writefln("calling action delegate"); 
    36         int c = cmd; 
     36 
     37        int c; 
    3738        version(MinWin32) { 
    38             int c = HIWORD(cmd); 
    39         } 
     39            c = HIWORD(cmd); 
     40        } else { 
     41            c = cmd; 
     42        } 
     43 
    4044        if (c == ButtonClickedCommand) { 
    4145            actionDelegate(cast(Component)this); 
     
    8488            } 
    8589            version(LOG)log.printf(" no radio button selected??\n"); 
    86             return 0
     90            return -1
    8791        } 
    8892    } 
     
    129133        } 
    130134        void selected(bool x) { 
    131             SendMessageA(peer,BM_SETCHECK,x,0); 
     135            SendMessageA(peer,BM_SETCHECK,x?BST_CHECKED:BST_UNCHECKED,0); 
    132136        } 
    133137    } 
  • branches/bughunt/minwin/group.d

    r33 r53  
    3030         if (parent) 
    3131             parent.addChild(this); 
    32    
     32   
    3333    void disposePeer(){} 
    3434    PeerForAdd getPeerForAdd() { 
    3535         return parent.getPeerForAdd(); 
    36    
     36   
    3737    void getPeerOffset(inout int x, inout int y) { 
    3838        int px, py; 
     
    119119version (MinWin32) { 
    120120 
    121     private { 
    122         import minwin.app; 
    123         import minwin.mswindows; 
    124         import std.utf; 
    125     } 
    126  
    127     class GroupBox : WindowChild { 
     121    import minwin.app; 
     122    import minwin.mswindows; 
     123    import std.utf; 
     124 
     125    class GroupBox : Group { 
    128126        int labelHeight; 
     127        PeerWrapper groupbox; 
    129128 
    130129        char[] text_data; 
     
    132131        void text(char[] c) { 
    133132            text_data = c; 
    134             SendMessageX(peer,WM_SETTEXT,0,c); 
     133            SendMessageX(groupbox.peer,WM_SETTEXT,0,c); 
    135134        } 
    136135 
    137136        this(Component parent, char[] text, char[] name = "") { 
     137            super(parent, name); 
     138            create_groupbox(this,text); 
     139        } 
     140 
     141        private void create_groupbox(Component parent, char[] text) { 
    138142            PeerForAdd parentp = parent.getPeerForAdd(); 
    139143            text_data = text; 
    140             peer = CreateWindowX("BUTTON",text, 
     144            HWND grp = CreateWindowX("BUTTON",text, 
    141145                 BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 
    142146                 0,0,10,10,parentp, 
    143147                 cast(HMENU)0,gApp.hInstance,null); 
    144             sysAssert(peer !is null, "Failed to create peer Button"); 
    145             setWindowChildPeer(this,peer,OWNS_PEER); 
    146             this.name = name; 
     148            sysAssert(grp !is null, "Failed to create peer GroupBox"); 
     149            groupbox = new PeerWrapper(parent,grp); 
     150            groupbox.parentOwnsLayout = false; 
    147151            Font f = standardFont(StandardFont.Gui); 
    148             SendMessageA(peer,WM_SETFONT,cast(WPARAM)f.peer,0); 
    149             HDC dc = GetDC(peer); 
     152            SendMessageA(grp,WM_SETFONT,cast(WPARAM)f.peer,0); 
     153            HDC dc = GetDC(grp); 
    150154            HFONT oldFont = SelectObject(dc,f.peer); 
    151155            TEXTMETRICA metrics; 
     
    153157            labelHeight = metrics.tmHeight; 
    154158            SelectObject(dc,oldFont); 
    155             ReleaseDC(peer,dc); 
    156             parent.addChild(this); 
    157         } 
    158  
    159  
    160         void getLayoutBounds(inout Rect r) { 
     159            ReleaseDC(grp,dc); 
     160        } 
     161 
     162        override void setBounds(inout Rect r) { 
     163            bounds = r; 
     164            SetWindowPos(groupbox.peer, null, r.left, r.top, r.width, r.height, 
     165                SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION); 
     166            childLayoutDirty = true; 
     167            repaint(); 
     168        } 
     169 
     170        override void size(Point s) { 
     171            bounds.LTWH(bounds.left,bounds.top,s.x,s.y); 
     172            SetWindowPos(groupbox.peer, null, 0, 0, s.x, s.y, 
     173                SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREPOSITION); 
     174            childLayoutDirty = true; 
     175            repaint(); 
     176        } 
     177 
     178        override void getLayoutBounds(inout Rect r) { 
    161179            super.getLayoutBounds(r); 
    162180            r.LTWH(r.left+2, r.top+labelHeight+2, r.width-4, r.height-labelHeight-4); 
    163181        } 
    164182 
    165         Point preferredSize() { 
     183        override Point preferredSize() { 
    166184            Point s; 
    167185            if (layoutMgr) { 
     
    170188            s.y = s.y + labelHeight+4; 
    171189            s.x = s.x + 4; 
    172             if (userPreferredWidth() > 0) 
    173                 s.x = userPreferredWidth()
    174             if (userPreferredHeight() > 0) 
    175                 s.y = userPreferredHeight()
     190            if (userPreferredWidth > 0) 
     191                s.x = userPreferredWidth
     192            if (userPreferredHeight > 0) 
     193                s.y = userPreferredHeight
    176194            return s; 
    177195        } 
    178         mixin WindowChildImpl!(); 
    179196    } 
    180197 
  • branches/bughunt/minwin/mswindows.d

    r49 r53  
    2222export BOOL DestroyWindow (HWND hWnd); 
    2323export BOOL MoveWindow (HWND hWnd, int x, int y, int w, int h, byte bRepaint); 
    24 export int SetWindowLongA (HWND hWnd, int nIndex, int dwNewLong); 
    25 export int GetWindowLongA (HWND hWnd, int nIndex); 
    2624export int GetWindowTextA (HWND hWnd, LPTSTR str, int count); 
    2725export int GetWindowTextW (HWND hWnd, LPWSTR str, int count); 
     
    3634export int LoadStringW(HINSTANCE inst, LPWSTR id, LPWSTR buf, int siz); 
    3735export int MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); 
     36export LRESULT CallWindowProcA(WNDPROC lpPrevWndFunc,HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam); 
    3837 
    3938struct INITCOMMONCONTROLSEX { 
     
    163162    GW_MAX =              5 
    164163} 
    165  
    166 enum : int { GWL_USERDATA = -21 } 
    167164 
    168165export HWND GetWindow (HWND hWnd, int dir); 
     
    624621const HWND HWND_NOTOPMOST = cast(HWND)-2; 
    625622 
     623/* 
     624 * Window field offsets for GetWindowLong() 
     625 */ 
     626export LONG GetWindowLongA(HWND hWnd,int nIndex); 
     627export int SetWindowLongA (HWND hWnd, int nIndex, int dwNewLong); 
     628enum : int { 
     629    GWL_WNDPROC        = -4, 
     630    GWL_HINSTANCE      = -6, 
     631    GWL_HWNDPARENT     = -8, 
     632    GWL_STYLE          = -16, 
     633    GWL_EXSTYLE        = -20, 
     634    GWL_USERDATA       = -21, 
     635    GWL_ID             = -12, 
     636} 
     637 
     638/* 
     639 * Class field offsets for GetClassLong 
     640 */ 
     641export DWORD GetClassLongA(HWND hWnd,int nIndex); 
     642enum : int { 
     643    GCL_MENUNAME       = -8, 
     644    GCL_HBRBACKGROUND  = -10, 
     645    GCL_HCURSOR        = -12, 
     646    GCL_HICON          = -14, 
     647    GCL_HMODULE        = -16, 
     648    GCL_CBWNDEXTRA     = -18, 
     649    GCL_CBCLSEXTRA     = -20, 
     650    GCL_WNDPROC        = -24, 
     651    GCL_STYLE          = -26, 
     652    GCW_ATOM           = -32, 
     653    GCL_HICONSM        = -34 
     654} 
     655 
    626656// 
    627657// these wrappers makes windows unicode look alot better and avoids excessive code duplication 
  • branches/bughunt/minwin/window.d

    r48 r53  
    431431        wc.hInstance = hInst; 
    432432        wc.hIcon = DefaultWindowIcon.peer; 
    433        //wc.hIconSm = DefaultWindowSmallIcon.peer; 
     433        //wc.hIconSm = DefaultWindowSmallIcon.peer; 
    434434        wc.hCursor = LoadCursorA(cast(HINSTANCE) null, IDC_ARROW); 
    435435        wc.hbrBackground = null; 
  • branches/bughunt/samples/widgets.d

    r51 r53  
    2121    GroupBox box = new GroupBox(win,"Group"); 
    2222    box.layoutMgr = new FlowLayout; 
    23     RadioGroup g = new RadioGroup; 
    2423    RadioButton r1 = new RadioButton(box,"click me"); 
    2524    RadioButton r2 = new RadioButton(box,"no, click me"); 
    2625    RadioButton r3 = new RadioButton(box,"or me ;)"); 
    27     g.addButton(r1); 
    28     g.addButton(r2); 
    29     g.addButton(r3); 
     26    RadioGroup g = new RadioGroup; 
     27    g.addButton(r1,r2,r3); 
    3028    g.select(0); 
    3129 
    32     CheckBox b1 = new CheckBox(win,"check 1"); 
    33     CheckBox b2 = new CheckBox(win,"check 2"); 
    34     ToggleButton b3 = new ToggleButton(win,"toggle 1"); 
     30    Button b1 = new Button(win,"button 1"); 
     31    CheckBox b2 = new CheckBox(win,"check 1"); 
     32    CheckBox b3 = new CheckBox(win,"check 2"); 
     33    ToggleButton b4 = new ToggleButton(win,"toggle 1"); 
    3534 
    3635    Label lab = new Label(win,"This is a label");