Changeset 62
- Timestamp:
- 05/16/07 18:49:22 (2 years ago)
- Files:
-
- branches/bughunt/minwin/label.d (modified) (3 diffs)
- branches/bughunt/minwin/text.d (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/bughunt/minwin/label.d
r33 r62 28 28 HDC dc = GetDC(peer); 29 29 sysAssert(dc !is null, "Failed to get label DC in preferredSize"); 30 SIZE s; 30 int x = 0; 31 int y = 0; 31 32 try { 32 33 Font f = standardFont(StandardFont.Gui); 33 34 HFONT oldfont = SelectObject(dc,f.peer); 34 35 sysAssert(oldfont !is null, "Failed to get Label font in preferredSize"); 35 BOOL ok = GetTextExtentPoint32X(dc,text_data,text_data.length,&s); 36 scope lines = std.string.splitlines(text_data); 37 foreach(line; lines) { 38 SIZE s = void; 39 BOOL ok = GetTextExtentPoint32X(dc,line,line.length,&s); 40 sysAssert(ok != false, "Failed to get font extents in preferredSize"); 41 if (s.cx > x) x = s.cx; 42 y += s.cy; 43 } 36 44 SelectObject(dc,oldfont); 37 sysAssert(ok != false, "Failed to get font extents in preferredSize");38 45 } finally { 39 46 ReleaseDC(peer,dc); 40 47 } 41 48 POINT p; 42 p.x = s.cx;43 p.y = s.cy;49 p.x = x; 50 p.y = y; 44 51 if (userPreferredWidth > 0) 45 52 p.x = userPreferredWidth; … … 60 67 sysAssert(peer !is null, "Failed to create peer Label"); 61 68 this.name = name; 62 t ext_data= text;69 this.text = text; 63 70 Font f = standardFont(StandardFont.Gui); 64 71 SendMessageA(peer,WM_SETFONT,cast(WPARAM)f.peer,0); … … 66 73 parent.addChild(this); 67 74 } 68 char[] text() {return text_data;}69 void text(char[] c) {70 text_data = c;71 SendMessageX(peer,WM_SETTEXT,0,c);72 }73 75 mixin LabelPrefSizeImpl!(); 74 76 mixin WindowChildImpl!(); 77 78 char[] text() { 79 return text_data; 80 } 81 void text(char[] str) { 82 scope lines = std.string.splitlines(str); 83 scope winstr = std.string.join(lines,std.string.newline); 84 SendMessageX(peer,WM_SETTEXT,0,winstr); 85 text_data = str; 86 } 75 87 } 76 88 branches/bughunt/minwin/text.d
r59 r62 75 75 } 76 76 } 77 // TODO: is the other way needed as well?78 77 void text(char[] str) { 79 78 scope lines = std.string.splitlines(str); … … 108 107 PeerForAdd parentp = parent.getPeerForAdd(); 109 108 DWORD dwStyle = (vscroll?WS_VSCROLL:0) | (hscroll?WS_HSCROLL:0); 110 peer = CreateWindowX("EDIT",text, 109 scope lines = std.string.splitlines(text); 110 scope winstr = std.string.join(lines,std.string.newline); 111 peer = CreateWindowX("EDIT",winstr, 111 112 ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | dwStyle, 112 113 0,0,10,10,parentp,
