Changeset 53
- Timestamp:
- 05/16/07 02:49:16 (2 years ago)
- Files:
-
- branches/bughunt/minwin/button.d (modified) (3 diffs)
- branches/bughunt/minwin/group.d (modified) (5 diffs)
- branches/bughunt/minwin/mswindows.d (modified) (4 diffs)
- branches/bughunt/minwin/window.d (modified) (1 diff)
- branches/bughunt/samples/widgets.d (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/bughunt/minwin/button.d
r52 r53 34 34 // only command is action command 35 35 version(LOG) log.writefln("calling action delegate"); 36 int c = cmd; 36 37 int c; 37 38 version(MinWin32) { 38 int c = HIWORD(cmd); 39 } 39 c = HIWORD(cmd); 40 } else { 41 c = cmd; 42 } 43 40 44 if (c == ButtonClickedCommand) { 41 45 actionDelegate(cast(Component)this); … … 84 88 } 85 89 version(LOG)log.printf(" no radio button selected??\n"); 86 return 0;90 return -1; 87 91 } 88 92 } … … 129 133 } 130 134 void selected(bool x) { 131 SendMessageA(peer,BM_SETCHECK,x ,0);135 SendMessageA(peer,BM_SETCHECK,x?BST_CHECKED:BST_UNCHECKED,0); 132 136 } 133 137 } branches/bughunt/minwin/group.d
r33 r53 30 30 if (parent) 31 31 parent.addChild(this); 32 }32 } 33 33 void disposePeer(){} 34 34 PeerForAdd getPeerForAdd() { 35 35 return parent.getPeerForAdd(); 36 }36 } 37 37 void getPeerOffset(inout int x, inout int y) { 38 38 int px, py; … … 119 119 version (MinWin32) { 120 120 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 { 128 126 int labelHeight; 127 PeerWrapper groupbox; 129 128 130 129 char[] text_data; … … 132 131 void text(char[] c) { 133 132 text_data = c; 134 SendMessageX( peer,WM_SETTEXT,0,c);133 SendMessageX(groupbox.peer,WM_SETTEXT,0,c); 135 134 } 136 135 137 136 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) { 138 142 PeerForAdd parentp = parent.getPeerForAdd(); 139 143 text_data = text; 140 peer= CreateWindowX("BUTTON",text,144 HWND grp = CreateWindowX("BUTTON",text, 141 145 BS_GROUPBOX | WS_CHILD | WS_VISIBLE, 142 146 0,0,10,10,parentp, 143 147 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; 147 151 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); 150 154 HFONT oldFont = SelectObject(dc,f.peer); 151 155 TEXTMETRICA metrics; … … 153 157 labelHeight = metrics.tmHeight; 154 158 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) { 161 179 super.getLayoutBounds(r); 162 180 r.LTWH(r.left+2, r.top+labelHeight+2, r.width-4, r.height-labelHeight-4); 163 181 } 164 182 165 Point preferredSize() {183 override Point preferredSize() { 166 184 Point s; 167 185 if (layoutMgr) { … … 170 188 s.y = s.y + labelHeight+4; 171 189 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; 176 194 return s; 177 195 } 178 mixin WindowChildImpl!();179 196 } 180 197 branches/bughunt/minwin/mswindows.d
r49 r53 22 22 export BOOL DestroyWindow (HWND hWnd); 23 23 export 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);26 24 export int GetWindowTextA (HWND hWnd, LPTSTR str, int count); 27 25 export int GetWindowTextW (HWND hWnd, LPWSTR str, int count); … … 36 34 export int LoadStringW(HINSTANCE inst, LPWSTR id, LPWSTR buf, int siz); 37 35 export int MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType); 36 export LRESULT CallWindowProcA(WNDPROC lpPrevWndFunc,HWND hWnd,UINT Msg,WPARAM wParam,LPARAM lParam); 38 37 39 38 struct INITCOMMONCONTROLSEX { … … 163 162 GW_MAX = 5 164 163 } 165 166 enum : int { GWL_USERDATA = -21 }167 164 168 165 export HWND GetWindow (HWND hWnd, int dir); … … 624 621 const HWND HWND_NOTOPMOST = cast(HWND)-2; 625 622 623 /* 624 * Window field offsets for GetWindowLong() 625 */ 626 export LONG GetWindowLongA(HWND hWnd,int nIndex); 627 export int SetWindowLongA (HWND hWnd, int nIndex, int dwNewLong); 628 enum : 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 */ 641 export DWORD GetClassLongA(HWND hWnd,int nIndex); 642 enum : 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 626 656 // 627 657 // these wrappers makes windows unicode look alot better and avoids excessive code duplication branches/bughunt/minwin/window.d
r48 r53 431 431 wc.hInstance = hInst; 432 432 wc.hIcon = DefaultWindowIcon.peer; 433 //wc.hIconSm = DefaultWindowSmallIcon.peer;433 //wc.hIconSm = DefaultWindowSmallIcon.peer; 434 434 wc.hCursor = LoadCursorA(cast(HINSTANCE) null, IDC_ARROW); 435 435 wc.hbrBackground = null; branches/bughunt/samples/widgets.d
r51 r53 21 21 GroupBox box = new GroupBox(win,"Group"); 22 22 box.layoutMgr = new FlowLayout; 23 RadioGroup g = new RadioGroup;24 23 RadioButton r1 = new RadioButton(box,"click me"); 25 24 RadioButton r2 = new RadioButton(box,"no, click me"); 26 25 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); 30 28 g.select(0); 31 29 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"); 35 34 36 35 Label lab = new Label(win,"This is a label");
