Changeset 7
- Timestamp:
- 10/26/07 02:18:22 (5 years ago)
- Files:
-
- trunk/win32/dfl/application.d (modified) (5 diffs)
- trunk/win32/dfl/base.d (modified) (5 diffs)
- trunk/win32/dfl/button.d (modified) (2 diffs)
- trunk/win32/dfl/collections.d (modified) (1 diff)
- trunk/win32/dfl/combobox.d (modified) (4 diffs)
- trunk/win32/dfl/control.d (modified) (32 diffs)
- trunk/win32/dfl/drawing.d (modified) (17 diffs)
- trunk/win32/dfl/fontdialog.d (modified) (9 diffs)
- trunk/win32/dfl/form.d (modified) (17 diffs)
- trunk/win32/dfl/groupbox.d (modified) (2 diffs)
- trunk/win32/dfl/imagelist.d (added)
- trunk/win32/dfl/internal/com.d (modified) (3 diffs)
- trunk/win32/dfl/internal/dlib.d (modified) (2 diffs)
- trunk/win32/dfl/internal/utf.d (modified) (5 diffs)
- trunk/win32/dfl/internal/winapi.d (modified) (5 diffs)
- trunk/win32/dfl/label.d (modified) (1 diff)
- trunk/win32/dfl/listbox.d (modified) (6 diffs)
- trunk/win32/dfl/listview.d (modified) (13 diffs)
- trunk/win32/dfl/makelib.bat (modified) (5 diffs)
- trunk/win32/dfl/menu.d (modified) (5 diffs)
- trunk/win32/dfl/progressbar.d (modified) (2 diffs)
- trunk/win32/dfl/registry.d (modified) (25 diffs)
- trunk/win32/dfl/richtextbox.d (modified) (2 diffs)
- trunk/win32/dfl/socket.d (modified) (1 diff)
- trunk/win32/dfl/splitter.d (modified) (7 diffs)
- trunk/win32/dfl/statusbar.d (modified) (14 diffs)
- trunk/win32/dfl/tabcontrol.d (modified) (1 diff)
- trunk/win32/dfl/treeview.d (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/win32/dfl/application.d
r5 r7 120 120 { 121 121 version = WINDOWS_HUNG_WORKAROUND; 122 } 123 124 125 deprecated enum DflCompat 126 { 127 NONE = 0, 128 MENU_092 = 0x1, // Adding to menus is the old way. 129 CONTROL_RECREATE_095 = 0x2, // Controls don't recreate automatically when necessary. 130 CONTROL_KEYEVENT_096 = 0x4, // Key events don't propagate up the control hierarchy when they are not handled. 131 FORM_DIALOGRESULT_096 = 0x8, // When a Form is in showDialog, changing the dialogResult from NONE doesn't close the form. 122 132 } 123 133 … … 236 246 237 247 248 /+ 249 // /// 250 bool visualStyles() // getter 251 { 252 // IsAppThemed: 253 // "Do not call this function during DllMain or global objects contructors. 254 // This may cause invalid return values in Microsoft Windows Vista and may cause Windows XP to become unstable." 255 } 256 +/ 257 258 238 259 /// Path of the executable including its file name. 239 260 char[] executablePath() // getter … … 1138 1159 1139 1160 1161 version(DFL_NO_COMPAT) 1162 package const DflCompat _compat = DflCompat.NONE; 1163 else 1164 package DflCompat _compat = DflCompat.NONE; 1165 1166 1167 deprecated void setCompat(DflCompat dflcompat) 1168 { 1169 version(DFL_NO_COMPAT) 1170 { 1171 assert(0, "Compatibility disabled"); // version=DFL_NO_COMPAT 1172 } 1173 else 1174 { 1175 if(messageLoop) 1176 { 1177 assert(0, "setCompat"); // Called too late, must enable compatibility sooner. 1178 return; 1179 } 1180 1181 _compat |= dflcompat; 1182 } 1183 } 1184 1185 1140 1186 private static size_t _doref(void* p, int by) 1141 1187 { … … 1380 1426 1381 1427 1382 /+1383 1428 // Note: phobos-only. 1384 1429 debug(SHOW_MESSAGE_INFO) … … 1556 1601 } 1557 1602 } 1558 +/1559 1603 1560 1604 trunk/win32/dfl/base.d
r5 r7 297 297 298 298 /// 299 enum CheckState: ubyte 300 { 301 UNCHECKED = BST_UNCHECKED, /// 302 CHECKED = BST_CHECKED, /// ditto 303 INDETERMINATE = BST_INDETERMINATE, /// ditto 304 } 305 306 307 /// 299 308 struct Message // docmain 300 309 { … … 512 521 513 522 523 interface IDialogResult 524 { 525 // /// 526 DialogResult dialogResult(); // getter 527 // /// ditto 528 void dialogResult(DialogResult); // setter 529 } 530 531 514 532 /// 515 533 enum SortOrder: ubyte … … 669 687 670 688 /// 689 enum ColorDepth: ubyte 690 { 691 DEPTH_4BIT = 1, /// 692 DEPTH_8BIT , /// ditto 693 DEPTH_16BIT, /// ditto 694 DEPTH_24BIT, /// ditto 695 DEPTH_32BIT, /// ditto 696 } 697 698 699 /// 671 700 class PaintEventArgs: EventArgs 672 701 { … … 883 912 884 913 914 /+ 885 915 /// 886 916 class LabelEditEventArgs: EventArgs … … 937 967 938 968 alias Event!(LabelEditEventArgs) LabelEditEventHandler; // deprecated 969 +/ 939 970 940 971 trunk/win32/dfl/button.d
r5 r7 11 11 12 12 private extern(Windows) void _initButton(); 13 14 15 ///16 enum CheckState: ubyte17 {18 UNCHECKED = BST_UNCHECKED, ///19 CHECKED = BST_CHECKED, /// ditto20 INDETERMINATE = BST_INDETERMINATE, /// ditto21 }22 13 23 14 … … 325 316 326 317 onClick(EventArgs.empty); 318 } 319 320 321 protected override void onClick(EventArgs ea) 322 { 323 super.onClick(ea); 324 325 if(!(Application._compat & DflCompat.FORM_DIALOGRESULT_096)) 326 { 327 if(DialogResult.NONE != this.dialogResult) 328 { 329 auto xx = cast(IDialogResult)topLevelControl; 330 if(xx) 331 xx.dialogResult = this.dialogResult; 332 } 333 } 327 334 } 328 335 trunk/win32/dfl/collections.d
r5 r7 265 265 else 266 266 { 267 if(getObjectString(onval) == value) // ?268 return true;267 if(getObjectString(onval) == value) 268 return idx; 269 269 } 270 270 } trunk/win32/dfl/combobox.d
r5 r7 508 508 static class ObjectCollection 509 509 { 510 this(ComboBox lbox)510 protected this(ComboBox lbox) 511 511 { 512 512 this.lbox = lbox; … … 514 514 515 515 516 this(ComboBox lbox, Object[] range)516 protected this(ComboBox lbox, Object[] range) 517 517 { 518 518 this.lbox = lbox; … … 521 521 522 522 523 this(ComboBox lbox, char[][] range)523 protected this(ComboBox lbox, char[][] range) 524 524 { 525 525 this.lbox = lbox; … … 529 529 530 530 /+ 531 this(ComboBox lbox, ObjectCollection range)531 protected this(ComboBox lbox, ObjectCollection range) 532 532 { 533 533 this.lbox = lbox; trunk/win32/dfl/control.d
r5 r7 670 670 static class ControlCollection 671 671 { 672 this(Control owner)672 protected this(Control owner) 673 673 { 674 674 _owner = owner; … … 976 976 977 977 onControlAdded(cea); 978 } 979 980 981 private void _ctrlremoved(ControlEventArgs cea) 982 { 983 alayout(cea.control); 984 985 onControlRemoved(cea); 978 986 } 979 987 … … 1070 1078 +/ 1071 1079 1072 sdock = cast(DockStyle)sdock.init; // Can't be set at the same time. 1080 //sdock = cast(DockStyle)sdock.init; // Can't be set at the same time. 1081 sdock = DockStyle.NONE; // Can't be set at the same time. 1073 1082 } 1074 1083 … … 2055 2064 2056 2065 2066 /+ 2067 /// 2068 // ea is the new parent. 2069 protected void onParentChanging(ControlEventArgs ea) 2070 { 2071 } 2072 +/ 2073 2074 2057 2075 /// 2058 2076 final Form findForm() … … 2084 2102 throw new DflException("Cannot add a top level control to a control"); 2085 2103 2104 //scope ControlEventArgs pcea = new ControlEventArgs(c); 2105 //onParentChanging(pcea); 2106 2086 2107 Control oldparent; 2087 2108 _FixAmbientOld oldinfo; … … 2132 2153 onParentChanged(EventArgs.empty); 2133 2154 if(oldparent) 2134 oldparent. onControlRemoved(cea);2155 oldparent._ctrlremoved(cea); 2135 2156 c._ctrladded(cea); 2136 2157 _fixAmbient(&oldinfo); … … 2146 2167 onParentChanged(EventArgs.empty); 2147 2168 if(oldparent) 2148 oldparent. onControlRemoved(cea);2169 oldparent._ctrlremoved(cea); 2149 2170 c._ctrladded(cea); 2150 2171 _fixAmbient(&oldinfo); … … 2164 2185 onParentChanged(EventArgs.empty); 2165 2186 assert(oldparent !is null); 2166 oldparent. onControlRemoved(cea);2187 oldparent._ctrlremoved(cea); 2167 2188 _fixAmbient(&oldinfo); 2168 2189 } … … 3187 3208 3188 3209 3210 override int opCmp(Object o) 3211 { 3212 Control ctrl = cast(Control)o; 3213 if(!ctrl) 3214 return -1; 3215 return opCmp(ctrl); 3216 } 3217 3218 3219 int opCmp(Control ctrl) 3220 { 3221 if(!isHandleCreated || hwnd != ctrl.hwnd) 3222 return super.opCmp(ctrl); 3223 return 0; 3224 } 3225 3226 3189 3227 /// 3190 3228 final bool focus() … … 3330 3368 3331 3369 RedrawWindow(hwnd, null, rgn.handle, RDW_ERASE | RDW_INVALIDATE | (andChildren ? RDW_ALLCHILDREN : RDW_NOCHILDREN)); 3370 } 3371 3372 3373 /// 3374 // Redraws the entire control, including nonclient area. 3375 final void redraw() 3376 { 3377 if(!hwnd) 3378 return; 3379 3380 RedrawWindow(hwnd, null, HRGN.init, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME); 3332 3381 } 3333 3382 … … 4445 4494 case WM_SYSCHAR: 4446 4495 //case WM_IMECHAR: 4496 /+ 4447 4497 if(processKeyEventArgs(msg)) 4448 4498 { … … 4453 4503 msg.result = 1; // The key was not processed. 4454 4504 break; 4505 +/ 4506 msg.result = !processKeyEventArgs(msg); 4507 return; 4455 4508 4456 4509 case WM_MOUSEWHEEL: // Requires Windows 98 or NT4. … … 4914 4967 if(ctrl) 4915 4968 { 4916 onControlRemoved(new ControlEventArgs(ctrl));4969 _ctrlremoved(new ControlEventArgs(ctrl)); 4917 4970 4918 4971 // ? … … 4993 5046 } 4994 5047 } 5048 5049 defWndProc(msg); 5050 // Only want chars if ALT isn't down, because it would break mnemonics. 5051 if(!(GetAsyncKeyState(VK_MENU) & 0x8000)) 5052 msg.result |= DLGC_WANTCHARS; 5053 return; 4995 5054 } 4996 5055 4997 /+ // This prevents mnemonics from working.4998 defWndProc(msg);4999 msg.result |= DLGC_WANTCHARS; // For keyPress.5000 return;5001 +/5002 5056 break; 5003 5057 … … 5429 5483 package final void doShow() 5430 5484 { 5431 //ShowWindow(hwnd, SW_SHOW);5432 //SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);5433 //SetWindowPos(hwnd, GetParent(hwnd) ? HWND_BOTTOM : HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); // ?5434 //if(GetParent(hwnd))5435 5485 if(wparent) // Exclude owner. 5436 5486 { 5437 HWND hw; 5438 hw = GetWindow(hwnd, GW_HWNDPREV); 5439 if(!hw) 5440 hw = HWND_BOTTOM; // ? 5441 SetWindowPos(hwnd, hw, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); 5442 //SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW); 5487 SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER); 5443 5488 } 5444 5489 else … … 5451 5496 package final void doHide() 5452 5497 { 5453 //ShowWindow(hwnd, SW_HIDE); 5454 SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_HIDEWINDOW); 5498 SetWindowPos(hwnd, HWND.init, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_HIDEWINDOW | SWP_NOZORDER); 5455 5499 } 5456 5500 … … 5730 5774 5731 5775 /+ 5732 // /5776 // /// 5733 5777 final bool hasVisualStyle() // getter 5734 5778 { 5779 bool result = false; 5735 5780 HWND hw = handle; // Always reference handle. 5736 5781 HMODULE huxtheme = GetModuleHandleA("uxtheme.dll"); … … 5741 5786 if(getwintheme) 5742 5787 { 5743 re turngetwintheme(hw) != null;5744 } 5745 FreeLibrary(huxtheme);5746 } 5747 return false;5788 result = getwintheme(hw) != null; 5789 } 5790 //FreeLibrary(huxtheme); 5791 } 5792 return result; 5748 5793 } 5749 5794 +/ … … 6365 6410 } 6366 6411 6367 return kea.handled; 6412 if(kea.handled) 6413 return true; 6368 6414 } 6369 6415 break; … … 6374 6420 scope KeyEventArgs kea = new KeyEventArgs(cast(Keys)(msg.wParam | modifierKeys)); 6375 6421 onKeyUp(kea); 6376 return kea.handled; 6422 if(kea.handled) 6423 return true; 6377 6424 } 6378 6425 break; … … 6387 6434 scope KeyEventArgs kea = new KeyEventArgs(cast(Keys)(vk | modifierKeys)); 6388 6435 onKeyPress(kea); 6389 return kea.handled; 6436 if(kea.handled) 6437 return true; 6390 6438 } 6391 6439 break; … … 6408 6456 } 6409 6457 6458 if(Application._compat & DflCompat.CONTROL_KEYEVENT_096) 6459 goto def_action; 6460 6461 // ? 6462 if(!parent 6463 || (IsWindowVisible(hwnd) 6464 && ((ctrlStyle & ControlStyles.SELECTABLE) 6465 || (SendMessageA(hwnd, WM_GETDLGCODE, 0, 0) & DLGC_WANTALLKEYS)))) 6466 { 6467 def_action: 6468 defWndProc(msg); 6469 //return true; 6470 return !msg.result; 6471 } 6472 else 6473 { 6474 //if(parent) 6475 assert(parent !is null); 6476 return parent.processKeyEventArgs(msg); 6477 } 6478 6410 6479 return false; 6411 6480 } … … 6453 6522 else 6454 6523 { 6455 _compat = CCompat.DFL095; 6524 //_compat = CCompat.DFL095; 6525 Application.setCompat(DflCompat.CONTROL_RECREATE_095); 6456 6526 } 6457 6527 } … … 6464 6534 6465 6535 version(SET_DFL_095) 6466 private const ubyte _compat = CCompat.DFL095; 6536 package const ubyte _compat = CCompat.DFL095; 6537 else version(DFL_NO_COMPAT) 6538 package const ubyte _compat = CCompat.NONE; 6467 6539 else 6468 private ubyte _compat = CCompat.NONE; 6540 package CCompat _compat() // getter 6541 { if(Application._compat & DflCompat.CONTROL_RECREATE_095) return CCompat.DFL095; return CCompat.NONE; } 6469 6542 6470 6543 … … 6815 6888 case WM_SYSKEYUP: 6816 6889 case WM_SYSCHAR: 6817 //case WM_IMECHAR: 6890 //case WM_IMECHAR: // ? 6818 6891 prevWndProc(m); 6819 6892 break; … … 7059 7132 result.height = result.height - dpad.bottom - dpad.top; 7060 7133 7134 // Add scroll width. 7061 7135 if(scrollSize.width > clientSize.width) 7062 7136 result.width = result.width + (scrollSize.width - clientSize.width); … … 7064 7138 result.height = result.height + (scrollSize.height - clientSize.height); 7065 7139 7140 // Adjust scroll position. 7141 result.location = Point(result.location.x - scrollPosition.x, result.location.y - scrollPosition.y); 7142 7066 7143 return result; 7067 7144 } … … 7196 7273 7197 7274 const Size DEFAULT_SCALE = { 5, 13 }; 7198 7199 7200 protected:7201 7275 7202 7276 /// … … 7241 7315 return (_style() & WS_VSCROLL) != 0; 7242 7316 } 7317 7318 7319 protected: 7243 7320 7244 7321 … … 7309 7386 case SB_THUMBTRACK: 7310 7387 case SB_THUMBPOSITION: 7311 delta = cast(int)HIWORD(m.wParam) - yspos; 7388 //delta = cast(int)HIWORD(m.wParam) - yspos; // Limited to 16-bits. 7389 delta = si.nTrackPos - yspos; 7312 7390 break; 7313 7391 case SB_BOTTOM: … … 7371 7449 case SB_THUMBTRACK: 7372 7450 case SB_THUMBPOSITION: 7373 delta = cast(int)HIWORD(m.wParam) - xspos; 7451 //delta = cast(int)HIWORD(m.wParam) - xspos; // Limited to 16-bits. 7452 delta = si.nTrackPos - xspos; 7374 7453 break; 7375 7454 case SB_RIGHT: … … 7575 7654 /// 7576 7655 Control activeControl(); // getter 7577 /// ditto7656 7578 7657 deprecated void activeControl(Control); // setter 7579 7658 7580 ///7581 7659 deprecated bool activateControl(Control); 7582 7660 } trunk/win32/dfl/drawing.d
r5 r7 1088 1088 1089 1089 1090 version(Tango) 1091 { 1092 // TO-DO: not implemented yet. 1093 } 1094 else 1095 { 1096 private import std.stream; // TO-DO: remove this import; use dfl.internal.dlib. 1097 1098 1099 /// 1100 class Picture: Image // docmain 1101 { 1102 // Note: requires OleInitialize(null). 1103 1104 1105 /// 1106 // Throws exception on failure. 1107 this(Stream stm) 1108 { 1109 this.ipic = _fromStdStream(stm); 1110 if(!this.ipic) 1111 throw new DflException("Unable to load picture from stream"); 1112 } 1113 1114 /// ditto 1115 // Throws exception on failure. 1116 this(char[] fileName) 1117 { 1118 this.ipic = _fromFileName(fileName); 1119 if(!this.ipic) 1120 throw new DflException("Unable to load picture from file '" ~ fileName ~ "'"); 1121 } 1122 1123 1124 private this(dfl.internal.wincom.IPicture ipic) 1125 { 1126 this.ipic = ipic; 1127 } 1128 1129 1130 /// 1131 // Returns null on failure instead of throwing exception. 1132 static Picture fromStream(Stream stm) 1133 { 1134 dfl.internal.wincom.IPicture ipic; 1135 ipic = _fromStdStream(stm); 1136 if(!ipic) 1137 return null; 1138 return new Picture(ipic); 1139 } 1140 1141 1142 /// 1143 // Returns null on failure instead of throwing exception. 1144 static Picture fromFile(char[] fileName) 1145 { 1146 dfl.internal.wincom.IPicture ipic; 1147 ipic = _fromFileName(fileName); 1148 if(!ipic) 1149 return null; 1150 return new Picture(ipic); 1151 } 1152 1153 1154 /// 1155 final void draw(HDC hdc, Point pt) // package 1156 { 1157 int lhx, lhy; 1158 int width, height; 1159 lhx = loghimX; 1160 lhy = loghimY; 1161 width = MAP_LOGHIM_TO_PIX(lhx, GetDeviceCaps(hdc, LOGPIXELSX)); 1162 height = MAP_LOGHIM_TO_PIX(lhy, GetDeviceCaps(hdc, LOGPIXELSY)); 1163 ipic.Render(hdc, pt.x, pt.y + height, width, -height, 0, 0, lhx, lhy, null); 1164 } 1165 1166 /// ditto 1167 final override void draw(Graphics g, Point pt) 1168 { 1169 return draw(g.handle, pt); 1170 } 1171 1172 1173 /// 1174 final void drawStretched(HDC hdc, Rect r) // package 1175 { 1176 int lhx, lhy; 1177 lhx = loghimX; 1178 lhy = loghimY; 1179 ipic.Render(hdc, r.x, r.y + r.height, r.width, -r.height, 0, 0, lhx, lhy, null); 1180 } 1181 1182 /// ditto 1183 final override void drawStretched(Graphics g, Rect r) 1184 { 1185 return drawStretched(g.handle, r); 1186 } 1187 1188 1189 /// 1190 final OLE_XSIZE_HIMETRIC loghimX() // getter 1191 { 1192 OLE_XSIZE_HIMETRIC xsz; 1193 if(S_OK != ipic.get_Width(&xsz)) 1194 return 0; // ? 1195 return xsz; 1196 } 1197 1198 /// ditto 1199 final OLE_YSIZE_HIMETRIC loghimY() // getter 1200 { 1201 OLE_YSIZE_HIMETRIC ysz; 1202 if(S_OK != ipic.get_Height(&ysz)) 1203 return 0; // ? 1204 return ysz; 1205 } 1206 1207 1208 /// 1209 final override int width() // getter 1210 { 1211 Graphics g; 1212 int result; 1213 g = Graphics.getScreen(); 1214 result = getWidth(g); 1215 g.dispose(); 1216 return result; 1217 } 1218 1219 1220 /// 1221 final override int height() // getter 1222 { 1223 Graphics g; 1224 int result; 1225 g = Graphics.getScreen(); 1226 result = getHeight(g); 1227 g.dispose(); 1228 return result; 1229 } 1230 1231 1232 /// 1233 final override Size size() // getter 1234 { 1235 Graphics g; 1236 Size result; 1237 g = Graphics.getScreen(); 1238 result = getSize(g); 1239 g.dispose(); 1240 return result; 1241 } 1242 1243 1244 /// 1245 final int getWidth(HDC hdc) // package 1246 { 1247 return MAP_LOGHIM_TO_PIX(loghimX, GetDeviceCaps(hdc, LOGPIXELSX)); 1248 } 1249 1250 /// ditto 1251 final int getWidth(Graphics g) 1252 { 1253 return getWidth(g.handle); 1254 } 1255 1256 1257 /// 1258 final int getHeight(HDC hdc) // package 1259 { 1260 return MAP_LOGHIM_TO_PIX(loghimY, GetDeviceCaps(hdc, LOGPIXELSX)); 1261 } 1262 1263 /// ditto 1264 final int getHeight(Graphics g) 1265 { 1266 return getHeight(g.handle); 1267 } 1268 1269 1270 final Size getSize(HDC hdc) // package 1271 { 1272 return Size(getWidth(hdc), getHeight(hdc)); 1273 } 1274 1275 /// 1276 final Size getSize(Graphics g) 1277 { 1278 return Size(getWidth(g), getHeight(g)); 1279 } 1280 1281 1282 /// 1283 void dispose() 1284 { 1285 if(ipic) 1090 /// 1091 class Picture: Image // docmain 1092 { 1093 // Note: requires OleInitialize(null). 1094 1095 1096 /// 1097 // Throws exception on failure. 1098 this(DStream stm) 1099 { 1100 this.ipic = _fromDStream(stm); 1101 if(!this.ipic) 1102 throw new DflException("Unable to load picture from stream"); 1103 } 1104 1105 /// ditto 1106 // Throws exception on failure. 1107 this(char[] fileName) 1108 { 1109 this.ipic = _fromFileName(fileName); 1110 if(!this.ipic) 1111 throw new DflException("Unable to load picture from file '" ~ fileName ~ "'"); 1112 } 1113 1114 1115 private this(dfl.internal.wincom.IPicture ipic) 1116 { 1117 this.ipic = ipic; 1118 } 1119 1120 1121 /// 1122 // Returns null on failure instead of throwing exception. 1123 static Picture fromStream(DStream stm) 1124 { 1125 dfl.internal.wincom.IPicture ipic; 1126 ipic = _fromDStream(stm); 1127 if(!ipic) 1128 return null; 1129 return new Picture(ipic); 1130 } 1131 1132 1133 /// 1134 // Returns null on failure instead of throwing exception. 1135 static Picture fromFile(char[] fileName) 1136 { 1137 dfl.internal.wincom.IPicture ipic; 1138 ipic = _fromFileName(fileName); 1139 if(!ipic) 1140 return null; 1141 return new Picture(ipic); 1142 } 1143 1144 1145 /// 1146 final void draw(HDC hdc, Point pt) // package 1147 { 1148 int lhx, lhy; 1149 int width, height; 1150 lhx = loghimX; 1151 lhy = loghimY; 1152 width = MAP_LOGHIM_TO_PIX(lhx, GetDeviceCaps(hdc, LOGPIXELSX)); 1153 height = MAP_LOGHIM_TO_PIX(lhy, GetDeviceCaps(hdc, LOGPIXELSY)); 1154 ipic.Render(hdc, pt.x, pt.y + height, width, -height, 0, 0, lhx, lhy, null); 1155 } 1156 1157 /// ditto 1158 final override void draw(Graphics g, Point pt) 1159 { 1160 return draw(g.handle, pt); 1161 } 1162 1163 1164 /// 1165 final void drawStretched(HDC hdc, Rect r) // package 1166 { 1167 int lhx, lhy; 1168 lhx = loghimX; 1169 lhy = loghimY; 1170 ipic.Render(hdc, r.x, r.y + r.height, r.width, -r.height, 0, 0, lhx, lhy, null); 1171 } 1172 1173 /// ditto 1174 final override void drawStretched(Graphics g, Rect r) 1175 { 1176 return drawStretched(g.handle, r); 1177 } 1178 1179 1180 /// 1181 final OLE_XSIZE_HIMETRIC loghimX() // getter 1182 { 1183 OLE_XSIZE_HIMETRIC xsz; 1184 if(S_OK != ipic.get_Width(&xsz)) 1185 return 0; // ? 1186 return xsz; 1187 } 1188 1189 /// ditto 1190 final OLE_YSIZE_HIMETRIC loghimY() // getter 1191 { 1192 OLE_YSIZE_HIMETRIC ysz; 1193 if(S_OK != ipic.get_Height(&ysz)) 1194 return 0; // ? 1195 return ysz; 1196 } 1197 1198 1199 /// 1200 final override int width() // getter 1201 { 1202 Graphics g; 1203 int result; 1204 g = Graphics.getScreen(); 1205 result = getWidth(g); 1206 g.dispose(); 1207 return result; 1208 } 1209 1210 1211 /// 1212 final override int height() // getter 1213 { 1214 Graphics g; 1215 int result; 1216 g = Graphics.getScreen(); 1217 result = getHeight(g); 1218 g.dispose(); 1219 return result; 1220 } 1221 1222 1223 /// 1224 final override Size size() // getter 1225 { 1226 Graphics g; 1227 Size result; 1228 g = Graphics.getScreen(); 1229 result = getSize(g); 1230 g.dispose(); 1231 return result; 1232 } 1233 1234 1235 /// 1236 final int getWidth(HDC hdc) // package 1237 { 1238 return MAP_LOGHIM_TO_PIX(loghimX, GetDeviceCaps(hdc, LOGPIXELSX)); 1239 } 1240 1241 /// ditto 1242 final int getWidth(Graphics g) 1243 { 1244 return getWidth(g.handle); 1245 } 1246 1247 1248 /// 1249 final int getHeight(HDC hdc) // package 1250 { 1251 return MAP_LOGHIM_TO_PIX(loghimY, GetDeviceCaps(hdc, LOGPIXELSX)); 1252 } 1253 1254 /// ditto 1255 final int getHeight(Graphics g) 1256 { 1257 return getHeight(g.handle); 1258 } 1259 1260 1261 final Size getSize(HDC hdc) // package 1262 { 1263 return Size(getWidth(hdc), getHeight(hdc)); 1264 } 1265 1266 /// 1267 final Size getSize(Graphics g) 1268 { 1269 return Size(getWidth(g), getHeight(g)); 1270 } 1271 1272 1273 /// 1274 void dispose() 1275 { 1276 if(ipic) 1277 { 1278 ipic.Release(); 1279 ipic = null; 1280 } 1281 } 1282 1283 1284 ~this() 1285 { 1286 dispose(); 1287 } 1288 1289 1290 final HBITMAP toHBitmap(HDC hdc) // package 1291 { 1292 HDC memdc; 1293 HBITMAP result; 1294 HGDIOBJ oldbm; 1295 memdc = CreateCompatibleDC(hdc); 1296 if(!memdc) 1297 throw new DflException("Device error"); 1298 try 1299 { 1300 Size sz; 1301 sz = getSize(hdc); 1302 result = CreateCompatibleBitmap(hdc, sz.width, sz.height); 1303 if(!result) 1286 1304 { 1287 ipic.Release();1288 ipic = null;1305 bad_bm: 1306 throw new DflException("Unable to allocate image"); 1289 1307 } 1290 } 1291 1292 1293 ~this() 1294 { 1295 dispose(); 1296 } 1297 1298 1299 final HBITMAP toHBitmap(HDC hdc) // package 1300 { 1301 HDC memdc; 1302 HBITMAP result; 1303 HGDIOBJ oldbm; 1304 memdc = CreateCompatibleDC(hdc); 1305 if(!memdc) 1306 throw new DflException("Device error"); 1307 try 1308 { 1309 Size sz; 1310 sz = getSize(hdc); 1311 result = CreateCompatibleBitmap(hdc, sz.width, sz.height); 1312 if(!result) 1313 { 1314 bad_bm: 1315 throw new DflException("Unable to allocate image"); 1316 } 1317 oldbm = SelectObject(memdc, result); 1318 draw(memdc, Point(0, 0)); 1319 } 1320 finally 1321 { 1322 if(oldbm) 1323 SelectObject(memdc, oldbm); 1324 DeleteDC(memdc); 1325 } 1326 return result; 1327 } 1328 1329 1330 final Bitmap toBitmap(HDC hdc) // package 1331 { 1332 HBITMAP hbm; 1333 hbm = toHBitmap(hdc); 1334 if(!hbm) 1335 throw new DflException("Unable to create bitmap"); 1336 return new Bitmap(hbm, true); // Owned. 1337 } 1338 1339 1340 final Bitmap toBitmap() 1341 { 1342 Graphics g; 1343 Bitmap result; 1344 g = Graphics.getScreen(); 1345 result = toBitmap(g); 1346 g.dispose(); 1347 return result; 1348 } 1349 1350 /// ditto 1351 final Bitmap toBitmap(Graphics g) 1352 { 1353 return toBitmap(g.handle); 1354 } 1355 1356 1357 private: 1358 dfl.internal.wincom.IPicture ipic = null; 1359 1360 1361 static dfl.internal.wincom.IPicture _fromIStream(dfl.internal.wincom.IStream istm) 1362 { 1363 dfl.internal.wincom.IPicture ipic; 1364 if(S_OK != OleLoadPicture(istm, 0, FALSE, &_IID_IPicture, cast(void**)&ipic)) 1365 return null; 1366 return ipic; 1367 } 1368 1369 1370 static dfl.internal.wincom.IPicture _fromStdStream(Stream stm) 1371 in 1372 { 1373 assert(stm !is null); 1374 } 1375 body 1376 { 1377 scope StdStreamToIStream istm = new StdStreamToIStream(stm); 1378 return _fromIStream(istm); 1379 } 1380 1381 1382 static dfl.internal.wincom.IPicture _fromFileName(char[] fileName) 1383 { 1384 alias dfl.internal.winapi.HANDLE HANDLE; // Otherwise, odd conflict with wine. 1385 1386 HANDLE hf; 1387 HANDLE hg; 1388 void* pg; 1389 DWORD dwsz, dw; 1390 1391 hf = dfl.internal.utf.createFile(fileName, GENERIC_READ, FILE_SHARE_READ, null, 1392 OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, null); 1393 if(!hf) 1394 return null; 1395 1396 dwsz = GetFileSize(hf, null); 1397 if(0xFFFFFFFF == dwsz) 1398 { 1399 failclose: 1400 CloseHandle(hf); 1401 return null; 1402 } 1403 1404 hg = GlobalAlloc(GMEM_MOVEABLE, dwsz); 1405 if(!hg) 1406 goto failclose; 1407 1408 pg = GlobalLock(hg); 1409 if(!pg) 1410 { 1411 CloseHandle(hf); 1412 CloseHandle(hg); 1413 return null; 1414 } 1415 1416 if(!ReadFile(hf, pg, dwsz, &dw, null) || dwsz != dw) 1417 { 1418 CloseHandle(hf); 1419 GlobalUnlock(hg); 1420 CloseHandle(hg); 1421 return null; 1422 } 1423 1308 oldbm = SelectObject(memdc, result); 1309 draw(memdc, Point(0, 0)); 1310 } 1311 finally 1312 { 1313 if(oldbm) 1314 SelectObject(memdc, oldbm); 1315 DeleteDC(memdc); 1316 } 1317 return result; 1318 } 1319 1320 1321 final Bitmap toBitmap(HDC hdc) // package 1322 { 1323 HBITMAP hbm; 1324 hbm = toHBitmap(hdc); 1325 if(!hbm) 1326 throw new DflException("Unable to create bitmap"); 1327 return new Bitmap(hbm, true); // Owned. 1328 } 1329 1330 1331 final Bitmap toBitmap() 1332 { 1333 Graphics g; 1334 Bitmap result; 1335 g = Graphics.getScreen(); 1336 result = toBitmap(g); 1337 g.dispose(); 1338 return result; 1339 } 1340 1341 /// ditto 1342 final Bitmap toBitmap(Graphics g) 1343 { 1344 return toBitmap(g.handle); 1345 } 1346 1347 1348 private: 1349 dfl.internal.wincom.IPicture ipic = null; 1350 1351 1352 static dfl.internal.wincom.IPicture _fromIStream(dfl.internal.wincom.IStream istm) 1353 { 1354 dfl.internal.wincom.IPicture ipic; 1355 if(S_OK != OleLoadPicture(istm, 0, FALSE, &_IID_IPicture, cast(void**)&ipic)) 1356 return null; 1357 return ipic; 1358 } 1359 1360 1361 static dfl.internal.wincom.IPicture _fromDStream(DStream stm) 1362 in 1363 { 1364 assert(stm !is null); 1365 } 1366 body 1367 { 1368 scope DStreamToIStream istm = new DStreamToIStream(stm); 1369 return _fromIStream(istm); 1370 } 1371 1372 1373 static dfl.internal.wincom.IPicture _fromFileName(char[] fileName) 1374 { 1375 alias dfl.internal.winapi.HANDLE HANDLE; // Otherwise, odd conflict with wine. 1376 1377 HANDLE hf; 1378 HANDLE hg; 1379 void* pg; 1380 DWORD dwsz, dw; 1381 1382 hf = dfl.internal.utf.createFile(fileName, GENERIC_READ, FILE_SHARE_READ, null, 1383 OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, null); 1384 if(!hf) 1385 return null; 1386 1387 dwsz = GetFileSize(hf, null); 1388 if(0xFFFFFFFF == dwsz) 1389 { 1390 failclose: 1391 CloseHandle(hf); 1392 return null; 1393 } 1394 1395 hg = GlobalAlloc(GMEM_MOVEABLE, dwsz); 1396 if(!hg) 1397 goto failclose; 1398 1399 pg = GlobalLock(hg); 1400 if(!pg) 1401 { 1402 CloseHandle(hf); 1403 CloseHandle(hg); 1404 return null; 1405 } 1406 1407 if(!ReadFile(hf, pg, dwsz, &dw, null) || dwsz != dw) 1408 { 1424 1409 CloseHandle(hf); 1425 1410 GlobalUnlock(hg); 1426 1427 IStream istm; 1428 dfl.internal.wincom.IPicture ipic; 1429 1430 if(S_OK != CreateStreamOnHGlobal(hg, TRUE, &istm)) 1431 { 1432 CloseHandle(hg); 1433 return null; 1434 } 1435 // Don't need to CloseHandle(hg) due to 2nd param being TRUE. 1436 1437 ipic = _fromIStream(istm); 1438 if(!ipic) 1439 { 1440 istm.Release(); 1441 return null; 1442 } 1443 1411 CloseHandle(hg); 1412 return null; 1413 } 1414 1415 CloseHandle(hf); 1416 GlobalUnlock(hg); 1417 1418 IStream istm; 1419 dfl.internal.wincom.IPicture ipic; 1420 1421 if(S_OK != CreateStreamOnHGlobal(hg, TRUE, &istm)) 1422 { 1423 CloseHandle(hg); 1424 return null; 1425 } 1426 // Don't need to CloseHandle(hg) due to 2nd param being TRUE. 1427 1428 ipic = _fromIStream(istm); 1429 if(!ipic) 1430 { 1444 1431 istm.Release(); 1445 1446 return ipic; 1447 } 1432 return null; 1433 } 1434 1435 istm.Release(); 1436 1437 return ipic; 1448 1438 } 1449 1439 } … … 1773 1763 if(vSplit) 1774 1764 { 1775 x = movableArea. width / 2 - MWIDTH / 2;1765 x = movableArea.x + (movableArea.width / 2 - MWIDTH / 2); 1776 1766 //y = movableArea.height / 2 - ((MWIDTH * count) + (MSPACE * (count - 1))) / 2; 1777 y = movableArea. height / 2 - ((MWIDTH * count) + (MSPACE * count)) / 2;1767 y = movableArea.y + (movableArea.height / 2 - ((MWIDTH * count) + (MSPACE * count)) / 2); 1778 1768 1779 1769 for(iw = 0; iw != count; iw++) … … 1786 1776 { 1787 1777 //x = movableArea.width / 2 - ((MHEIGHT * count) + (MSPACE * (count - 1))) / 2; 1788 x = movableArea. width / 2 - ((MHEIGHT * count) + (MSPACE * count)) / 2;1789 y = movableArea. height / 2 - MHEIGHT / 2;1778 x = movableArea.x + (movableArea.width / 2 - ((MHEIGHT * count) + (MSPACE * count)) / 2); 1779 y = movableArea.y + (movableArea.height / 2 - MHEIGHT / 2); 1790 1780 1791 1781 for(iw = 0; iw != count; iw++) … … 2356 2346 2357 2347 2358 /// 2359 final bool copyTo(HDC dest, int destX, int destY, int width, int height, int srcX, int srcY, DWORD rop) // package 2348 final bool copyTo(HDC dest, int destX, int destY, int width, int height, int srcX = 0, int srcY = 0, DWORD rop = SRCCOPY) // package 2360 2349 { 2361 2350 return cast(bool)dfl.internal.winapi.BitBlt(dest, destX, destY, width, height, this.handle, srcX, srcY, rop); 2362 2351 } 2363 2352 2364 /// ditto 2365 final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height, int srcX, int srcY, DWORD rop) 2353 2354 /// 2355 final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height, int srcX = 0, int srcY = 0, DWORD rop = SRCCOPY) 2366 2356 { 2367 2357 return copyTo(destGraphics.handle, destX, destY, width, height, srcX, srcY, rop); … … 2369 2359 2370 2360 /// ditto 2371 final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height, int srcX, int srcY)2372 {2373 return copyTo(destGraphics.handle, destX, destY, width, height, srcX, srcY, SRCCOPY);2374 }2375 2376 /// ditto2377 final bool copyTo(Graphics destGraphics, int destX, int destY, int width, int height)2378 {2379 return copyTo(destGraphics.handle, destX, destY, width, height, 0, 0, SRCCOPY);2380 }2381 2382 /// ditto2383 2361 final bool copyTo(Graphics destGraphics, Rect bounds) 2384 2362 { 2385 return copyTo(destGraphics.handle, bounds.x, bounds.y, bounds.width, bounds.height , 0, 0, SRCCOPY);2363 return copyTo(destGraphics.handle, bounds.x, bounds.y, bounds.width, bounds.height); 2386 2364 } 2387 2365 … … 2480 2458 2481 2459 2482 /+ 2483 // Requires creating yet another DC; compatible with screen? Picture.toBitmap() is. 2460 final Size size() // getter 2461 { 2462 return Size(_w, _h); 2463 } 2464 2465 2466 /// 2467 final HBITMAP hbitmap() // getter // package 2468 { 2469 return hbm; 2470 } 2471 2472 2473 // Needs to copy so it can be selected into other DC`s. 2474 final HBITMAP toHBitmap(HDC hdc) // package 2475 { 2476 HDC memdc; 2477 HBITMAP result; 2478 HGDIOBJ oldbm; 2479 memdc = CreateCompatibleDC(hdc); 2480 if(!memdc) 2481 throw new DflException("Device error"); 2482 try 2483 { 2484 result = CreateCompatibleBitmap(hdc, width, height); 2485 if(!result) 2486 { 2487 bad_bm: 2488 throw new DflException("Unable to allocate image"); 2489 } 2490 oldbm = SelectObject(memdc, result); 2491 copyTo(memdc, 0, 0, width, height); 2492 } 2493 finally 2494 { 2495 if(oldbm) 2496 SelectObject(memdc, oldbm); 2497 DeleteDC(memdc); 2498 } 2499 return result; 2500 } 2501 2502 2503 final Bitmap toBitmap(HDC hdc) // package 2504 { 2505 HBITMAP hbm; 2506 hbm = toHBitmap(hdc); 2507 if(!hbm) 2508 throw new DflException("Unable to create bitmap"); 2509 return new Bitmap(hbm, true); // Owned. 2510 } 2511 2512 2513 /// 2484 2514 final Bitmap toBitmap() 2485 2515 { 2486 } 2487 +/ 2488 2489 2490 /// 2491 final HBITMAP hbitmap() // getter // package 2492 { 2493 return hbm; 2516 Graphics g; 2517 Bitmap result; 2518 g = Graphics.getScreen(); 2519 result = toBitmap(g); 2520 g.dispose(); 2521 return result; 2522 } 2523 2524 /// ditto 2525 final Bitmap toBitmap(Graphics g) 2526 { 2527 return toBitmap(g.handle); 2494 2528 } 2495 2529 … … 2798 2832 { 2799 2833 // Used internally. 2800 this(HFONT hf, LOGFONTA* lf, bool owned = true) // package 2801 { 2834 static void LOGFONTAtoLogFont(inout LogFont lf, LOGFONTA* plfa) // package // deprecated 2835 { 2836 lf.lfa = *plfa; 2837 lf.faceName = dfl.internal.utf.fromAnsiz(plfa.lfFaceName.ptr); 2838 } 2839 2840 // Used internally. 2841 static void LOGFONTWtoLogFont(inout LogFont lf, LOGFONTW* plfw) // package // deprecated 2842 { 2843 lf.lfw = *plfw; 2844 lf.faceName = dfl.internal.utf.fromUnicodez(plfw.lfFaceName.ptr); 2845 } 2846 2847 2848 // Used internally. 2849 this(HFONT hf, LOGFONTA* plfa, bool owned = true) // package // deprecated 2850 { 2851 LogFont lf; 2852 LOGFONTAtoLogFont(lf, plfa); 2853 2802 2854 this.hf = hf; 2803 2855 this.owned = owned; … … 2810 2862 2811 2863 // Used internally. 2812 this(HFONT hf, bool owned = true) // package2864 this(HFONT hf, inout LogFont lf, bool owned = true) // package 2813 2865 { 2814 2866 this.hf = hf; … … 2816 2868 this._unit = GraphicsUnit.POINT; 2817 2869 2818 LOGFONTA lf; 2819 _info(&lf); 2820 2821 _fstyle = _style(&lf); 2822 _initLf(&lf); 2870 _fstyle = _style(lf); 2871 _initLf(lf); 2823 2872 } 2824 2873 2825 2874 2826 2875 // Used internally. 2827 this(LOGFONTA* lf, bool owned = true) // package 2828 { 2876 this(HFONT hf, bool owned = true) // package 2877 { 2878 this.hf = hf; 2879 this.owned = owned; 2880 this._unit = GraphicsUnit.POINT; 2881 2882 LogFont lf; 2883 _info(lf); 2884 2885 _fstyle = _style(lf); 2886 _initLf(lf); 2887 } 2888 2889 2890 // Used internally. 2891 this(LOGFONTA* plfa, bool owned = true) // package // deprecated 2892 { 2893 LogFont lf; 2894 LOGFONTAtoLogFont(lf, plfa); 2895 2829 2896 this(_create(lf), lf, owned); 2830 2897 } 2831 2898 2832 2899 2833 package static HFONT _create(LOGFONTA* lf) 2900 // Used internally. 2901 this(inout LogFont lf, bool owned = true) // package 2902 { 2903 this(_create(lf), lf, owned); 2904 } 2905 2906 2907 package static HFONT _create(inout LogFont lf) 2834 2908 { 2835 2909 HFONT result; 2836 result = CreateFontIndirectA(lf);2910 result = dfl.internal.utf.createFontIndirect(lf); 2837 2911 if(!result) 2838 2912 throw new DflException("Unable to create font"); … … 2841 2915 2842 2916 2843 private static void _style( LOGFONTA*lf, FontStyle style)2844 { 2845 lf.lf Weight = (style & FontStyle.BOLD) ? FW_BOLD : FW_NORMAL;2846 lf.lf Italic = (style & FontStyle.ITALIC) ? TRUE : FALSE;2847 lf.lf Underline = (style & FontStyle.UNDERLINE) ? TRUE : FALSE;2848 lf.lf StrikeOut = (style & FontStyle.STRIKEOUT) ? TRUE : FALSE;2849 } 2850 2851 2852 private static FontStyle _style( LOGFONTA*lf)2917 private static void _style(inout LogFont lf, FontStyle style) 2918 { 2919 lf.lf.lfWeight = (style & FontStyle.BOLD) ? FW_BOLD : FW_NORMAL; 2920 lf.lf.lfItalic = (style & FontStyle.ITALIC) ? TRUE : FALSE; 2921 lf.lf.lfUnderline = (style & FontStyle.UNDERLINE) ? TRUE : FALSE; 2922 lf.lf.lfStrikeOut = (style & FontStyle.STRIKEOUT) ? TRUE : FALSE; 2923 } 2924 2925 2926 private static FontStyle _style(inout LogFont lf) 2853 2927 { 2854 2928 FontStyle style = FontStyle.REGULAR; 2855 2929 2856 if(lf.lf Weight >= FW_BOLD)2930 if(lf.lf.lfWeight >= FW_BOLD) 2857 2931 style |= FontStyle.BOLD; 2858 if(lf.lf Italic)2932 if(lf.lf.lfItalic) 2859 2933 style |= FontStyle.ITALIC; 2860 if(lf.lf Underline)2934 if(lf.lf.lfUnderline) 2861 2935 style |= FontStyle.UNDERLINE; 2862 if(lf.lf StrikeOut)2936 if(lf.lf.lfStrikeOut) 2863 2937 style |= FontStyle.STRIKEOUT; 2864 2938 … … 2867 2941 2868 2942 2869 package void _info(LOGFONTA* lf) 2943 package void _info(LOGFONTA* lf) // deprecated 2870 2944 { 2871 2945 if(GetObjectA(hf, LOGFONTA.sizeof, lf) != LOGFONTA.sizeof) 2946 throw new DflException("Unable to get font information"); 2947 } 2948 2949 package void _info(LOGFONTW* lf) // deprecated 2950 { 2951 auto proc = cast(GetObjectWProc)GetProcAddress(GetModuleHandleA("gdi32.dll"), "GetObjectW"); 2952 2953 if(!proc || proc(hf, LOGFONTW.sizeof, lf) != LOGFONTW.sizeof) 2954 throw new DflException("Unable to get font information"); 2955 } 2956 2957 2958 package void _info(inout LogFont lf) 2959 { 2960 if(!dfl.internal.utf.getLogFont(hf, lf)) 2872 2961 throw new DflException("Unable to get font information"); 2873 2962 } … … 2983 3072 this(Font font, FontStyle style) 2984 3073 { 2985 L OGFONTAlf;3074 LogFont lf; 2986 3075 _unit = font._unit; 2987 font._info( &lf);2988 _style( &lf, style);2989 this(_create( &lf));3076 font._info(lf); 3077 _style(lf, style); 3078 this(_create(lf)); 2990 3079 2991 3080 _fstyle = style; 2992 _initLf(font, &lf);3081 _initLf(font, lf); 2993 3082 } 2994 3083 … … 3022 3111 FontSmoothing smoothing = FontSmoothing.DEFAULT) 3023 3112 { 3024 L OGFONTAlf;3113 LogFont lf; 3025 3114 3026 3115 _unit = unit; 3027 3116 3028 if(name.length >= lf.lfFaceName.length) 3029 throw new DflException("Invalid font name"); 3030 lf.lfFaceName[0 .. name.length] = name; 3031 lf.lfFaceName[name.length] = 0; 3032 3033 lf.lfHeight = -getLfHeight(emSize, unit); 3034 _style(&lf, style); 3035 3036 lf.lfCharSet = gdiCharSet; 3037 lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 3038 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 3039 //lf.lfQuality = DEFAULT_QUALITY; 3040 lf.lfQuality = smoothing; 3041 lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 3042 3043 this(_create(&lf)); 3117 lf.faceName = name; 3118 3119 lf.lf.lfHeight = -getLfHeight(emSize, unit); 3120 _style(lf, style); 3121 3122 lf.lf.lfCharSet = gdiCharSet; 3123 lf.lf.lfOutPrecision = OUT_DEFAULT_PRECIS; 3124 lf.lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; 3125 //lf.lf.lfQuality = DEFAULT_QUALITY; 3126 lf.lf.lfQuality = smoothing; 3127 lf.lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 3128 3129 this(_create(lf)); 3044 3130 3045 3131 _fstyle = style; 3046 _initLf( &lf);3132 _initLf(lf); 3047 3133 } 3048 3134 … … 3075 3161 LOGFONTA lf; 3076 3162 _info(&lf); 3077 return getEmSize(lf.lf Height, _unit);3163 return getEmSize(lf.lf.lfHeight, _unit); 3078 3164 +/ 3079 3165 return getEmSize(this.lfHeight, _unit); … … 3087 3173 LOGFONTA lf; 3088 3174 _info(&lf); 3089 return getEmSize(lf.lf Height, unit);3175 return getEmSize(lf.lf.lfHeight, unit); 3090 3176 +/ 3091 3177 return getEmSize(this.lfHeight, unit); … … 3119 3205 3120 3206 3207 /+ 3121 3208 private void _initLf(LOGFONTA* lf) 3122 3209 { … … 3125 3212 this.lfCharSet = lf.lfCharSet; 3126 3213 } 3127 3128 3214 +/ 3215 3216 private void _initLf(inout LogFont lf) 3217 { 3218 this.lfHeight = lf.lf.lfHeight; 3219 this.lfName = lf.faceName; 3220 this.lfCharSet = lf.lf.lfCharSet; 3221 } 3222 3223 3224 /+ 3129 3225 private void _initLf(Font otherfont, LOGFONTA* lf) 3226 { 3227 this.lfHeight = otherfont.lfHeight; 3228 this.lfName = otherfont.lfName; 3229 this.lfCharSet = otherfont.lfCharSet; 3230 } 3231 +/ 3232 3233 private void _initLf(Font otherfont, inout LogFont lf) 3130 3234 { 3131 3235 this.lfHeight = otherfont.lfHeight; trunk/win32/dfl/fontdialog.d
r5 r7 7 7 8 8 private import dfl.base, dfl.commondialog, dfl.internal.winapi, dfl.application, 9 dfl.control, dfl.drawing, dfl.event ;9 dfl.control, dfl.drawing, dfl.event, dfl.internal.utf; 10 10 11 11 … … 25 25 cf.lStructSize = cf.sizeof; 26 26 cf.Flags = INIT_FLAGS; 27 cf.lpLogFont = cast(typeof(cf.lpLogFont))&lf ;27 cf.lpLogFont = cast(typeof(cf.lpLogFont))&lfw; 28 28 cf.lCustData = cast(typeof(cf.lCustData))cast(void*)this; 29 29 cf.lpfnHook = &fondHookProc; … … 35 35 { 36 36 _fon = null; 37 //lf = lf.init; // It's completely updated when needed.38 37 cf.Flags = INIT_FLAGS; 39 38 cf.rgbColors = 0; … … 334 333 BOOL result = FALSE; 335 334 336 font._info(&lf); // -font- gets default font if not set.337 335 cf.hwndOwner = owner; 338 336 339 // TODO: fix this when LOGFONTW is implemented. 340 /+if(dfl.internal.utf.useUnicode) 341 { 337 if(dfl.internal.utf.useUnicode) 338 { 339 font._info(&lfw); // -font- gets default font if not set. 340 342 341 const char[] NAME = "ChooseFontW"; 343 342 static ChooseFontWProc proc = null; … … 345 344 if(!proc) 346 345 { 347 proc = cast(ChooseFontWProc)GetProcAddress(GetModuleHandleA("comdlg32.dll"), NAME );346 proc = cast(ChooseFontWProc)GetProcAddress(GetModuleHandleA("comdlg32.dll"), NAME.ptr); 348 347 if(!proc) 349 348 throw new Exception("Unable to load procedure " ~ NAME ~ "."); … … 352 351 result = proc(&cfw); 353 352 } 354 else+/ 355 { 353 else 354 { 355 font._info(&lfa); // -font- gets default font if not set. 356 356 357 result = ChooseFontA(&cfa); 357 358 } … … 368 369 private void _update() 369 370 { 370 _fon = new Font(Font._create(&lf), true); 371 LogFont lf; 372 373 if(dfl.internal.utf.useUnicode) 374 Font.LOGFONTWtoLogFont(lf, &lfw); 375 else 376 Font.LOGFONTAtoLogFont(lf, &lfa); 377 378 _fon = new Font(Font._create(lf), true); 371 379 } 372 380 … … 380 388 381 389 private: 390 382 391 union 383 392 { … … 391 400 } 392 401 393 LOGFONTA lf; 402 union 403 { 404 LOGFONTW lfw; 405 LOGFONTA lfa; 406 407 static assert(LOGFONTW.lfFaceName.offsetof == LOGFONTA.lfFaceName.offsetof); 408 } 409 394 410 Font _fon; 395 411 trunk/win32/dfl/form.d
r5 r7 11 11 private import dfl.application, dfl.base, dfl.menu, dfl.internal.utf; 12 12 private import dfl.collections; 13 14 15 version(NO_DFL_PARK_WINDOW) 16 { 17 } 18 else 19 { 20 version = DFL_PARK_WINDOW; 21 } 13 22 14 23 … … 105 114 106 115 /// 107 class Form: ContainerControl // docmain116 class Form: ContainerControl, IDialogResult // docmain 108 117 { 109 118 /// … … 130 139 { 131 140 cancelBtn = btn; 141 142 if(btn) 143 { 144 if(!(Application._compat & DflCompat.FORM_DIALOGRESULT_096)) 145 { 146 btn.dialogResult = DialogResult.CANCEL; 147 } 148 } 132 149 } 133 150 … … 252 269 version(DFL_PARK_WINDOW) 253 270 { 254 if(!cp.parent && !showInTaskbar ())271 if(!cp.parent && !showInTaskbar) 255 272 cp.parent = getParkHwnd(); 256 273 } … … 428 445 } 429 446 447 if(!nofilter) 448 Application.addMessageFilter(mfilter); // To process IsDialogMessage(). 449 430 450 //createChildren(); 431 451 try … … 460 480 } 461 481 } 482 483 // Load before shown. 484 // Not calling if recreating handle! 485 onLoad(EventArgs.empty); 462 486 } 463 487 … … 488 512 } 489 513 //cbits &= ~CBits.FVISIBLE; 490 491 //Application.addMessageFilter(mfilter = new FormMessageFilter(this)); // To process IsDialogMessage().492 if(!nofilter)493 Application.addMessageFilter(mfilter); // To process IsDialogMessage().494 495 //onHandleCreated(EventArgs.empty); // Called in Control's WM_CREATE now.496 497 onLoad(EventArgs.empty);498 514 } 499 515 … … 599 615 { 600 616 fresult = dr; 617 618 if(!(Application._compat & DflCompat.FORM_DIALOGRESULT_096)) 619 { 620 if(modal && DialogResult.NONE != dr) 621 close(); 622 } 601 623 } 602 624 … … 733 755 | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); // Recalculate the frame. 734 756 } 757 758 invalidate(true); 735 759 736 760 _resetSystemMenu(); … … 1393 1417 wowner = frm; 1394 1418 if(isHandleCreated) 1395 SetParent(hwnd, frm.hwnd); 1419 { 1420 if(CCompat.DFL095 == _compat) 1421 SetParent(hwnd, frm.hwnd); 1422 else 1423 _crecreate(); 1424 } 1396 1425 } 1397 1426 else 1398 1427 { 1399 1428 if(isHandleCreated) 1400 SetParent(hwnd, HWND.init); 1429 { 1430 if(showInTaskbar || CCompat.DFL095 == _compat) 1431 SetParent(hwnd, HWND.init); 1432 else 1433 _crecreate(); 1434 } 1401 1435 } 1402 1436 … … 1446 1480 version(DFL_PARK_WINDOW) 1447 1481 { 1482 /+ // Not working, the form disappears (probably stuck as a child). 1448 1483 if(!GetParent(handle)) 1484 { 1485 //_style((_style() | WS_POPUP) & ~WS_CHILD); 1486 1449 1487 SetParent(handle, getParkHwnd()); 1488 } 1489 +/ 1490 _crecreate(); 1450 1491 } 1451 1492 } … … 2437 2478 +/ 2438 2479 2480 case WM_SETFOCUS: 2481 { 2482 // Prevent DefDlgProc from getting this message because it'll focus controls it shouldn't. 2483 bool didf = false; 2484 enumChildWindows(msg.hWnd, 2485 (HWND hw) 2486 { 2487 auto wl = GetWindowLongA(hw, GWL_STYLE); 2488 if(((WS_VISIBLE | WS_TABSTOP) == ((WS_VISIBLE | WS_TABSTOP) & wl)) 2489 && !(WS_DISABLED & wl)) 2490 { 2491 DefDlgProcA(msg.hWnd, WM_NEXTDLGCTL, cast(WPARAM)hw, MAKELPARAM(true, 0)); 2492 didf = true; 2493 return FALSE; 2494 } 2495 return TRUE; 2496 }); 2497 if(!didf) 2498 SetFocus(msg.hWnd); 2499 } 2500 return; 2501 2439 2502 default: 2440 2503 version(NO_MDI) … … 2521 2584 } 2522 2585 } 2523 2524 2525 /+2526 // DMD 0.129: Internal error: ..\ztc\cod3.c 7362527 protected override bool processTabKey(bool forward)2528 {2529 if(selectNextControl(activeControl, forward, true, true))2530 return true;2531 return false;2532 }2533 +/2534 2586 2535 2587 … … 2692 2744 } 2693 2745 2746 // isDialogMessage seems to be eating WM_CHAR in some cases, so see for myself if it should get it. 2747 if(WM_CHAR == m.msg) 2748 { 2749 // ? ... 2750 return false; // Continue. 2751 } 2752 2694 2753 //if(!form.isMdiChild && !form.isMdiContainer) 2695 2754 { … … 2864 2923 version(DFL_PARK_WINDOW) 2865 2924 { 2866 static assert(0);2867 2868 2869 2925 HWND getParkHwnd() 2870 2926 { 2871 2927 if(!_hwPark) 2872 _makePark(); 2928 { 2929 synchronized 2930 { 2931 if(!_hwPark) 2932 _makePark(); 2933 } 2934 } 2873 2935 return _hwPark; 2874 2936 } … … 2878 2940 { 2879 2941 WNDCLASSEXA wce; 2880 (cast(ubyte*)&wce)[0 .. wce.sizeof] = 0;2881 2942 wce.cbSize = wce.sizeof; 2882 2943 wce.style = CS_DBLCLKS; 2883 wce.lpszClassName = PARK_CLASSNAME ;2944 wce.lpszClassName = PARK_CLASSNAME.ptr; 2884 2945 wce.lpfnWndProc = &DefWindowProcA; 2885 2946 wce.hInstance = Application.getInstance(); … … 2895 2956 } 2896 2957 2897 _hwPark = CreateWindowExA(WS_EX_ WINDOWEDGE | WS_EX_CONTROLPARENT, PARK_CLASSNAME, "",2898 WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 0, 0,2958 _hwPark = CreateWindowExA(WS_EX_TOOLWINDOW, PARK_CLASSNAME.ptr, "", 2959 WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, 2899 2960 HWND.init, HMENU.init, wce.hInstance, null); 2900 2961 if(!_hwPark) trunk/win32/dfl/groupbox.d
r5 r7 50 50 _initButton(); 51 51 52 if( _defTextHeight.init== _defTextHeight)52 if(DEFTEXTHEIGHT_INIT == _defTextHeight) 53 53 { 54 54 _recalcTextHeight(defaultFont); … … 122 122 private: 123 123 124 static int _defTextHeight = -1; 124 const int DEFTEXTHEIGHT_INIT = -1; 125 static int _defTextHeight = DEFTEXTHEIGHT_INIT; 125 126 int _textHeight = -1; 126 127 trunk/win32/dfl/internal/com.d
r5 r7 5 5 module dfl.internal.com; 6 6 7 private import dfl.internal.winapi, dfl.internal.wincom; 8 9 version(Tango) 10 { 11 } 12 else 13 { 14 private import std.stream; 15 } 7 private import dfl.internal.winapi, dfl.internal.wincom, dfl.internal.dlib; 16 8 17 9 … … 44 36 45 37 46 version(Tango) 47 { 48 } 49 else 50 { 51 class StdStreamToIStream: DflComObject, dfl.internal.wincom.IStream 52 { 53 this(Stream sourceStdStream) 54 { 55 this.stm = sourceStdStream; 56 } 57 58 59 // TODO: catch general exceptions and react. 60 61 extern(Windows): 62 override HRESULT QueryInterface(IID* riid, void** ppv) 63 { 64 if(*riid == _IID_IStream) 65 { 66 *ppv = cast(void*)cast(dfl.internal.wincom.IStream)this; 67 AddRef(); 68 return S_OK; 69 } 70 else if(*riid == _IID_ISequentialStream) 71 { 72 *ppv = cast(void*)cast(dfl.internal.wincom.ISequentialStream)this; 73 AddRef(); 74 return S_OK; 75 } 76 else if(*riid == _IID_IUnknown) 77 { 78 *ppv = cast(void*)cast(IUnknown)this; 79 AddRef(); 80 return S_OK; 38 class DStreamToIStream: DflComObject, dfl.internal.wincom.IStream 39 { 40 this(DStream sourceDStream) 41 { 42 this.stm = sourceDStream; 43 } 44 45 46 extern(Windows): 47 48 override HRESULT QueryInterface(IID* riid, void** ppv) 49 { 50 if(*riid == _IID_IStream) 51 { 52 *ppv = cast(void*)cast(dfl.internal.wincom.IStream)this; 53 AddRef(); 54 return S_OK; 55 } 56 else if(*riid == _IID_ISequentialStream) 57 { 58 *ppv = cast(void*)cast(dfl.internal.wincom.ISequentialStream)this; 59 AddRef(); 60 return S_OK; 61 } 62 else if(*riid == _IID_IUnknown) 63 { 64 *ppv = cast(void*)cast(IUnknown)this; 65 AddRef(); 66 return S_OK; 67 } 68 else 69 { 70 *ppv = null; 71 return E_NOINTERFACE; 72 } 73 } 74 75 76 HRESULT Read(void* pv, ULONG cb, ULONG* pcbRead) 77 { 78 ULONG read; 79 HRESULT result = S_OK; 80 81 try 82 { 83 version(Tango) 84 { 85 read = stm.input.read(pv[0 .. cb]); 81 86 } 82 87 else 83 88 { 84 *ppv = null; 85 return E_NOINTERFACE; 86 } 87 } 88 89 90 HRESULT Read(void* pv, ULONG cb, ULONG* pcbRead) 91 { 92 ULONG read; 93 read = stm.readBlock(pv, cb); 94 if(pcbRead) 95 *pcbRead = read; 96 if(!read) 97 return S_FALSE; 98 return S_OK; 99 } 100 101 102 HRESULT Write(void* pv, ULONG cb, ULONG* pcbWritten) 103 { 104 ULONG written; 105 written = stm.writeBlock(pv, cb); 106 if(pcbWritten) 107 *pcbWritten = written; 108 if(!written) 109 return S_FALSE; 110 return S_OK; 111 } 112 113 114 HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) 89 read = stm.readBlock(pv, cb); 90 } 91 } 92 catch(DStreamException e) 93 { 94 result = S_FALSE; // ? 95 } 96 97 if(pcbRead) 98 *pcbRead = read; 99 //if(!read) 100 // result = S_FALSE; 101 return result; 102 } 103 104 105 HRESULT Write(void* pv, ULONG cb, ULONG* pcbWritten) 106 { 107 ULONG written; 108 HRESULT result = S_OK; 109 110 try 111 { 112 version(Tango) 113 { 114 written = stm.output.write(pv[0 .. cb]); 115 } 116 else 117 { 118 written = stm.writeBlock(pv, cb); 119 } 120 } 121 catch(DStreamException e) 122 { 123 result = S_FALSE; // ? 124 } 125 126 if(pcbWritten) 127 *pcbWritten = written; 128 //if(!written) 129 // result = S_FALSE; 130 return result; 131 } 132 133 134 HRESULT Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition) 135 { 136 version(Tango) 137 { 138 auto stmseek = cast(DStream.Seek)stm; 139 if(!stmseek) 140 return S_FALSE; // ? 141 } 142 else 115 143 { 116 144 if(!stm.seekable) 117 145 return S_FALSE; // ? 118 119 HRESULT result = S_OK; 120 ulong pos; 121 try 122 { 146 } 147 148 HRESULT result = S_OK; 149 150 try 151 { 152 version(Tango) 153 { 154 long pos; 155 switch(dwOrigin) 156 { 157 case STREAM_SEEK_SET: 158 pos = stmseek.seek(dlibMove.QuadPart, DStream.Seek.Anchor.Begin); 159 if(plibNewPosition) 160 plibNewPosition.QuadPart = pos; 161 break; 162 163 case STREAM_SEEK_CUR: 164 pos = stmseek.seek(dlibMove.QuadPart, DStream.Seek.Anchor.Current); 165 if(plibNewPosition) 166 plibNewPosition.QuadPart = pos; 167 break; 168 169 case STREAM_SEEK_END: 170 pos = stmseek.seek(dlibMove.QuadPart, DStream.Seek.Anchor.End); 171 if(plibNewPosition) 172 plibNewPosition.QuadPart = pos; 173 break; 174 175 default: 176 result = STG_E_INVALIDFUNCTION; 177 } 178 } 179 else 180 { 181 ulong pos; 123 182 switch(dwOrigin) 124 183 { … … 145 204 } 146 205 } 147 catch(SeekException se) 148 { 149 result = S_FALSE; // ? 150 } 151 152 return result; 153 } 154 155 156 HRESULT SetSize(ULARGE_INTEGER libNewSize) 157 { 158 return E_NOTIMPL; 159 } 160 161 162 HRESULT CopyTo(IStream pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) 163 { 164 // TODO: implement. 165 return E_NOTIMPL; 166 } 167 168 169 HRESULT Commit(DWORD grfCommitFlags) 170 { 171 // Ignore -grfCommitFlags- and just flush the stream.. 206 } 207 catch(DStreamException e) 208 { 209 result = S_FALSE; // ? 210 } 211 212 return result; 213 } 214 215 216 HRESULT SetSize(ULARGE_INTEGER libNewSize) 217 { 218 return E_NOTIMPL; 219 } 220 221 222 HRESULT CopyTo(IStream pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) 223 { 224 // TODO: implement. 225 return E_NOTIMPL; 226 } 227 228 229 HRESULT Commit(DWORD grfCommitFlags) 230 { 231 // Ignore -grfCommitFlags- and just flush the stream.. 232 version(Tango) 233 { 234 stm.output.flush(); 235 } 236 else 237 { 172 238 stm.flush(); 173 return S_OK; // ? 174 } 175 176 177 HRESULT Revert() 178 { 179 return E_NOTIMPL; // ? S_FALSE ? 180 } 181 182 183 HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 184 { 185 return E_NOTIMPL; 186 } 187 188 189 HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 190 { 191 return E_NOTIMPL; 192 } 193 194 195 HRESULT Stat(STATSTG* pstatstg, DWORD grfStatFlag) 196 { 197 return E_NOTIMPL; // ? 198 } 199 200 201 HRESULT Clone(IStream* ppstm) 202 { 203 // Cloned stream needs its own seek position. 204 return E_NOTIMPL; // ? 205 } 206 207 208 extern(D): 209 210 private: 211 Stream stm; 212 } 213 } 214 239 } 240 return S_OK; // ? 241 } 242 243 244 HRESULT Revert() 245 { 246 return E_NOTIMPL; // ? S_FALSE ? 247 } 248 249 250 HRESULT LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 251 { 252 return E_NOTIMPL; 253 } 254 255 256 HRESULT UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) 257 { 258 return E_NOTIMPL; 259 } 260 261 262 HRESULT Stat(STATSTG* pstatstg, DWORD grfStatFlag) 263 { 264 return E_NOTIMPL; // ? 265 } 266 267 268 HRESULT Clone(IStream* ppstm) 269 { 270 // Cloned stream needs its own seek position. 271 return E_NOTIMPL; // ? 272 } 273 274 275 extern(D): 276 277 private: 278 DStream stm; 279 } 280 281 version(Tango) 282 { 283 } 284 else 285 { 286 alias DStreamToIStream StdStreamToIStream; // deprecated 287 } 288 trunk/win32/dfl/internal/dlib.d
r5 r7 254 254 255 255 256 private import tango.io.model.IConduit; 257 258 alias tango.io.model.IConduit.IConduit DStream; 259 260 alias tango.core.Exception.IOException DStreamException; // Note: from tango.core.Exception. 261 262 256 263 class DObject 257 264 { … … 349 356 alias std.ctype.isxdigit charIsHexDigit; 350 357 358 359 private import std.stream; 360 361 alias std.stream.Stream DStream; 362 363 alias std.stream.StreamException DStreamException; 364 365 351 366 alias Object DObject; 352 367 } 353 368 369 370 char* unsafeToStringz(char[] s) 371 { 372 if(!s.ptr[s.length]) 373 return s.ptr; 374 return stringToStringz(s); 375 } 376 trunk/win32/dfl/internal/utf.d
r5 r7 68 68 } 69 69 70 package HMODULE user32, kernel32, _advapi32, gdi32; 70 package: 71 72 version(DFL_LOAD_INTERNAL_LIBS) 73 { 74 alias LoadLibraryA initInternalLib; 75 } 76 else 77 { 78 version = DFL_GET_INTERNAL_LIBS; 79 80 alias GetModuleHandleA initInternalLib; 81 } 82 83 84 HMODULE _user32, _kernel32, _advapi32, _gdi32; 71 85 72 86 package HMODULE advapi32() // getter 73 87 { 88 // advapi32 generally always delay loads. 74 89 if(!_advapi32) 75 90 _advapi32 = LoadLibraryA("advapi32.dll"); 76 91 return _advapi32; 92 } 93 94 package HMODULE gdi32() // getter 95 { 96 // gdi32 sometimes delay loads. 97 version(DFL_GET_INTERNAL_LIBS) 98 { 99 if(!_gdi32) 100 _gdi32 = LoadLibraryA("gdi32.dll"); 101 } 102 return _gdi32; 103 } 104 105 package HMODULE user32() // getter 106 { 107 version(DFL_GET_INTERNAL_LIBS) 108 { 109 if(!_user32) 110 _user32 = LoadLibraryA("user32.dll"); 111 } 112 return _user32; 113 } 114 115 package HMODULE kernel32() // getter 116 { 117 version(DFL_GET_INTERNAL_LIBS) 118 { 119 if(!_kernel32) 120 _kernel32 = LoadLibraryA("kernel32.dll"); 121 } 122 return _kernel32; 77 123 } 78 124 … … 101 147 +/ 102 148 103 user32 = GetModuleHandleA("user32.dll");104 kernel32 = GetModuleHandleA("kernel32.dll");149 _user32 = initInternalLib("user32.dll"); 150 _kernel32 = initInternalLib("kernel32.dll"); 105 151 _advapi32 = GetModuleHandleA("advapi32.dll"); // Not guaranteed to be loaded. 106 gdi32 = GetModuleHandleA("gdi32.dll");152 _gdi32 = initInternalLib("gdi32.dll"); 107 153 } 108 154 } … … 369 415 alias typeof(&SetMenuItemInfoW) SetMenuItemInfoWProc; 370 416 alias typeof(&InsertMenuItemW) InsertMenuItemWProc; 417 alias typeof(&CreateFontIndirectW) CreateFontIndirectWProc; 418 alias typeof(&GetObjectW) GetObjectWProc; 371 419 } 372 420 … … 374 422 private void getProcErr(char[] procName) 375 423 { 376 throw new Exception("Unable to load procedure " ~ procName ~ "."); 424 char[] errdesc; 425 version(DFL_NO_PROC_ERROR_INFO) 426 { 427 } 428 else 429 { 430 auto le = cast(int)GetLastError(); 431 if(le) 432 errdesc = " (error " ~ intToString(le) ~ ")"; 433 } 434 throw new Exception("Unable to load procedure " ~ procName ~ errdesc); 377 435 } 378 436 … … 1981 2039 } 1982 2040 2041 2042 struct LogFont 2043 { 2044 union 2045 { 2046 LOGFONTW lfw; 2047 LOGFONTA lfa; 2048 } 2049 alias lfw lf; 2050 2051 char[] faceName; 2052 } 2053 2054 2055 HFONT createFontIndirect(inout LogFont lf) 2056 { 2057 if(useUnicode) 2058 { 2059 version(STATIC_UNICODE) 2060 { 2061 alias CreateFontIndirectW proc; 2062 } 2063 else 2064 { 2065 const char[] NAME = "CreateFontIndirectW"; 2066 static CreateFontIndirectWProc proc = null; 2067 2068 if(!proc) 2069 { 2070 proc = cast(CreateFontIndirectWProc)GetProcAddress(gdi32, NAME.ptr); 2071 if(!proc) 2072 getProcErr(NAME); 2073 } 2074 } 2075 2076 wchar[] ws = toUnicode(lf.faceName); 2077 if(ws.length >= LF_FACESIZE) 2078 ws = ws[0 .. LF_FACESIZE - 1]; // ? 2079 foreach(idx, wch; ws) 2080 { 2081 lf.lfw.lfFaceName[idx] = wch; 2082 } 2083 lf.lfw.lfFaceName[ws.length] = 0; 2084 2085 return proc(&lf.lfw); 2086 } 2087 else 2088 { 2089 char[] as = toAnsi(lf.faceName); 2090 if(as.length >= LF_FACESIZE) 2091 as = as[0 .. LF_FACESIZE - 1]; // ? 2092 foreach(idx, ach; as) 2093 { 2094 lf.lfa.lfFaceName[idx] = ach; 2095 } 2096 lf.lfa.lfFaceName[as.length] = 0; 2097 2098 return CreateFontIndirectA(&lf.lfa); 2099 } 2100 } 2101 2102 2103 // GetObject for a LogFont. 2104 int getLogFont(HFONT hf, inout LogFont lf) 2105 { 2106 if(useUnicode) 2107 { 2108 version(STATIC_UNICODE) 2109 { 2110 alias GetObjectW proc; 2111 } 2112 else 2113 { 2114 const char[] NAME = "GetObjectW"; 2115 static GetObjectWProc proc = null; 2116 2117 if(!proc) 2118 { 2119 proc = cast(GetObjectWProc)GetProcAddress(gdi32, NAME.ptr); 2120 if(!proc) 2121 getProcErr(NAME); 2122 } 2123 } 2124 2125 if(LOGFONTW.sizeof != proc(hf, LOGFONTW.sizeof, &lf.lfw)) 2126 return 0; 2127 lf.faceName = fromUnicodez(lf.lfw.lfFaceName.ptr); 2128 return LOGFONTW.sizeof; 2129 } 2130 else 2131 { 2132 if(LOGFONTA.sizeof != GetObjectA(hf, LOGFONTA.sizeof, &lf.lfa)) 2133 return 0; 2134 lf.faceName = fromAnsiz(lf.lfa.lfFaceName.ptr); 2135 return LOGFONTA.sizeof; 2136 } 2137 } 2138 trunk/win32/dfl/internal/winapi.d
r5 r7 1169 1169 LVN_FIRST = cast(UINT)-100, 1170 1170 1171 LVN_ITEMCHANGING = (LVN_FIRST - 0), 1172 LVN_ITEMCHANGED = (LVN_FIRST - 1), 1173 1174 LVN_BEGINLABELEDITA = LVN_FIRST - 5, 1175 LVN_BEGINLABELEDITW = LVN_FIRST - 75, 1176 1177 LVN_ENDLABELEDITA = LVN_FIRST - 6, 1178 LVN_ENDLABELEDITW = LVN_FIRST - 76, 1179 1171 1180 LVN_COLUMNCLICK = LVN_FIRST - 8, 1172 1181 … … 1426 1435 SM_CYSMICON = 50, 1427 1436 1437 SM_CYSMCAPTION = 51, 1438 1428 1439 SM_CXSIZEFRAME = SM_CXFRAME, 1429 1440 SM_CYSIZEFRAME = SM_CYFRAME, … … 1916 1927 1917 1928 1929 struct TVITEMW 1930 { 1931 UINT mask; 1932 HTREEITEM hItem; 1933 UINT state; 1934 UINT stateMask; 1935 LPWSTR pszText; 1936 int cchTextMax; 1937 int iImage; 1938 int iSelectedImage; 1939 int cChildren; 1940 LPARAM lParam; 1941 } 1942 alias TVITEMW* LPTVITEMW; 1943 alias TVITEMW* PTVITEMW; 1944 alias TVITEMW TV_ITEMW; 1945 alias TVITEMW* LPTV_ITEMW; 1946 alias TVITEMW* PTV_ITEMW; 1947 1948 1918 1949 struct TVHITTESTINFO 1919 1950 { … … 1957 1988 alias NMTVDISPINFOA TV_DISPINFOA; 1958 1989 alias NMTVDISPINFOA* LPTV_DISPINFOA; 1990 1991 1992 struct NMTVDISPINFOW 1993 { 1994 NMHDR hdr; 1995 TVITEMW item; 1996 } 1997 alias NMTVDISPINFOW* LPNMTVDISPINFOW; 1998 alias NMTVDISPINFOW TV_DISPINFOW; 1999 alias NMTVDISPINFOW* LPTV_DISPINFOW; 1959 2000 1960 2001 … … 2706 2747 int SetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi, BOOL fRedraw); 2707 2748 BOOL GetScrollInfo(HWND hwnd, int fnBar, LPSCROLLINFO lpsi); 2749 BOOL DragDetect(HWND hwnd, POINT pt); 2750 HFONT CreateFontIndirectW(LOGFONTW *lplf); 2751 DWORD GetThemeAppProperties(); 2752 BOOL IsAppThemed(); 2708 2753 2709 2754 //} // Temporary. trunk/win32/dfl/label.d
r5 r7 350 350 { 351 351 case WM_GETDLGCODE: 352 //m.result = 0;352 super.wndProc(m); 353 353 //if(useMnemonic) 354 m.result = DLGC_STATIC;354 m.result |= DLGC_STATIC; 355 355 break; 356 356 trunk/win32/dfl/listbox.d
r5 r7 203 203 204 204 205 this(ListBox lb)205 protected this(ListBox lb) 206 206 { 207 207 lbox = lb; … … 361 361 362 362 363 this(ListBox lb)363 protected this(ListBox lb) 364 364 { 365 365 lbox = lb; … … 999 999 static class ObjectCollection 1000 1000 { 1001 this(ListBox lbox)1001 protected this(ListBox lbox) 1002 1002 { 1003 1003 this.lbox = lbox; … … 1005 1005 1006 1006 1007 this(ListBox lbox, Object[] range)1007 protected this(ListBox lbox, Object[] range) 1008 1008 { 1009 1009 this.lbox = lbox; … … 1012 1012 1013 1013 1014 this(ListBox lbox, char[][] range)1014 protected this(ListBox lbox, char[][] range) 1015 1015 { 1016 1016 this.lbox = lbox; … … 1020 1020 1021 1021 /+ 1022 this(ListBox lbox, ObjectCollection range)1022 protected this(ListBox lbox, ObjectCollection range) 1023 1023 { 1024 1024 this.lbox = lbox; trunk/win32/dfl/listview.d
r5 r7 180 180 static class ListViewSubItemCollection 181 181 { 182 this(ListViewItem owner)182 protected this(ListViewItem owner) 183 183 in 184 184 { … … 536 536 537 537 /// 538 class LabelEditEventArgs: EventArgs 539 { 540 /// 541 this(ListViewItem item, char[] label) 542 { 543 _item = item; 544 _label = label; 545 } 546 547 /// ditto 548 this(ListViewItem node) 549 { 550 _item = item; 551 } 552 553 554 /// 555 final ListViewItem item() // getter 556 { 557 return _item; 558 } 559 560 561 /// 562 final char[] label() // getter 563 { 564 return _label; 565 } 566 567 568 /// 569 final void cancelEdit(bool byes) // setter 570 { 571 _cancel = byes; 572 } 573 574 /// ditto 575 final bool cancelEdit() // getter 576 { 577 return _cancel; 578 } 579 580 581 private: 582 ListViewItem _item; 583 char[] _label; 584 bool _cancel = false; 585 } 586 587 588 alias Event!(LabelEditEventArgs) LabelEditEventHandler; // deprecated 589 590 591 /+ 592 class ItemCheckEventArgs: EventArgs 593 { 594 this(int index, CheckState newCheckState, CheckState oldCheckState) 595 { 596 this._idx = index; 597 this._ncs = newCheckState; 598 this._ocs = oldCheckState; 599 } 600 601 602 final CheckState currentValue() // getter 603 { 604 return _ocs; 605 } 606 607 608 /+ 609 final void newValue(CheckState cs) // setter 610 { 611 _ncs = cs; 612 } 613 +/ 614 615 616 final CheckState newValue() // getter 617 { 618 return _ncs; 619 } 620 621 622 private: 623 int _idx; 624 CheckState _ncs, _ocs; 625 } 626 +/ 627 628 629 class ItemCheckedEventArgs: EventArgs 630 { 631 this(ListViewItem item) 632 { 633 this._item = item; 634 } 635 636 637 final ListViewItem item() // getter 638 { 639 return this._item; 640 } 641 642 643 private: 644 ListViewItem _item; 645 } 646 647 648 /// 538 649 class ListView: ControlSuperClass // docmain 539 650 { … … 541 652 static class ListViewItemCollection 542 653 { 543 this(ListView lv)654 protected this(ListView lv) 544 655 in 545 656 { … … 715 826 static class ColumnHeaderCollection 716 827 { 717 this(ListView owner)828 protected this(ListView owner) 718 829 in 719 830 { … … 877 988 878 989 879 this(ListView lv)990 protected this(ListView lv) 880 991 { 881 992 lview = lv; … … 966 1077 967 1078 968 this(ListView lv)1079 protected this(ListView lv) 969 1080 { 970 1081 lview = lv; … … 1052 1163 1053 1164 1054 this(ListView lv)1165 protected this(ListView lv) 1055 1166 { 1056 1167 lview = lv; … … 1392 1503 // Simple as addRow("item", "sub item1", "sub item2", "etc"); 1393 1504 // rowstrings[0] is the item and rowstrings[1 .. rowstrings.length] are its sub items. 1394 final void addRow(char[][] rowstrings ...) 1505 //final void addRow(char[][] rowstrings ...) 1506 final ListViewItem addRow(char[][] rowstrings ...) 1395 1507 { 1396 1508 if(rowstrings.length) … … 1401 1513 item.subItems.addRange(rowstrings[1 .. rowstrings.length]); 1402 1514 items.add(item); 1403 } 1515 return item; 1516 } 1517 assert(0); 1518 return null; 1404 1519 } 1405 1520 … … 1794 1909 1795 1910 1796 Event!(ListView, ColumnClickEventArgs) columnClick;1797 1798 1799 protected void onColumnClick(ColumnClickEventArgs ea)1800 {1801 columnClick(this, ea);1802 }1803 1804 1805 1911 // TODO: 1806 //LabelEditEventHandler afterLabelEdit; 1807 //LabelEditEventHandler beforeLabelEdit; 1808 // itemActivate, itemCheck, itemDrag 1912 // itemActivate, itemDrag 1809 1913 //EventHandler selectedIndexChanged; 1810 1914 //CancelEventHandler selectedIndexChanging; // ? 1915 1916 Event!(ListView, ColumnClickEventArgs) columnClick; /// 1917 Event!(ListView, LabelEditEventArgs) afterLabelEdit; /// 1918 Event!(ListView, LabelEditEventArgs) beforeLabelEdit; /// 1919 //Event!(ListView, ItemCheckEventArgs) itemCheck; /// 1920 Event!(ListView, ItemCheckedEventArgs) itemChecked; /// 1921 1922 1923 protected void onColumnClick(ColumnClickEventArgs ea) 1924 { 1925 columnClick(this, ea); 1926 } 1927 1928 1929 /// 1930 protected void onAfterLabelEdit(LabelEditEventArgs ea) 1931 { 1932 afterLabelEdit(this, ea); 1933 } 1934 1935 1936 /// 1937 protected void onBeforeLabelEdit(LabelEditEventArgs ea) 1938 { 1939 beforeLabelEdit(this, ea); 1940 } 1941 1942 1943 /+ 1944 protected void onItemCheck(ItemCheckEventArgs ea) 1945 { 1946 itemCheck(this, ea); 1947 } 1948 +/ 1949 1950 1951 protected void onItemChecked(ItemCheckedEventArgs ea) 1952 { 1953 itemChecked(this, ea); 1954 } 1811 1955 1812 1956 … … 1986 2130 { 1987 2131 case LVN_GETDISPINFOA: 2132 if(dfl.internal.utf.useUnicode) 2133 break; 1988 2134 { 1989 2135 LV_DISPINFOA* lvdi; … … 2030 2176 break; 2031 2177 2178 /+ 2179 case LVN_ITEMCHANGING: 2180 { 2181 auto nmlv = cast(NM_LISTVIEW*)nmh; 2182 if(-1 != nmlv.iItem) 2183 { 2184 UINT stchg = nmlv.uNewState ^ nmlv.uOldState; 2185 if(stchg & (3 << 12)) 2186 { 2187 // Note: not tested. 2188 scope ItemCheckEventArgs ea = new ItemCheckEventArgs(nmlv.iItem, 2189 (((nmlv.uNewState >> 12) & 3) - 1) ? CheckState.CHECKED : CheckState.UNCHECKED, 2190 (((nmlv.uOldState >> 12) & 3) - 1) ? CheckState.CHECKED : CheckState.UNCHECKED); 2191 onItemCheck(ea); 2192 } 2193 } 2194 } 2195 break; 2196 +/ 2197 2198 case LVN_ITEMCHANGED: 2199 { 2200 auto nmlv = cast(NM_LISTVIEW*)nmh; 2201 if(-1 != nmlv.iItem) 2202 { 2203 UINT stchg = nmlv.uNewState ^ nmlv.uOldState; 2204 if(stchg & (3 << 12)) 2205 { 2206 scope ItemCheckedEventArgs ea = new ItemCheckedEventArgs(items[nmlv.iItem]); 2207 onItemChecked(ea); 2208 } 2209 } 2210 } 2211 break; 2212 2032 2213 case LVN_COLUMNCLICK: 2033 2214 { … … 2035 2216 scope ccea = new ColumnClickEventArgs(nmlv.iSubItem); 2036 2217 onColumnClick(ccea); 2218 } 2219 break; 2220 2221 case LVN_BEGINLABELEDITW: 2222 goto begin_label_edit; 2223 2224 case LVN_BEGINLABELEDITA: 2225 if(dfl.internal.utf.useUnicode) 2226 break; 2227 begin_label_edit: 2228 2229 { 2230 LV_DISPINFOA* nmdi; 2231 nmdi = cast(LV_DISPINFOA*)nmh; 2232 if(nmdi.item.iSubItem) 2233 { 2234 m.result = TRUE; 2235 break; 2236 } 2237 ListViewItem lvitem; 2238 lvitem = cast(ListViewItem)cast(void*)nmdi.item.lParam; 2239 scope LabelEditEventArgs leea = new LabelEditEventArgs(lvitem); 2240 onBeforeLabelEdit(leea); 2241 m.result = leea.cancelEdit; 2242 } 2243 break; 2244 2245 case LVN_ENDLABELEDITW: 2246 { 2247 char[] label; 2248 LV_DISPINFOW* nmdi; 2249 nmdi = cast(LV_DISPINFOW*)nmh; 2250 if(nmdi.item.pszText) 2251 { 2252 ListViewItem lvitem; 2253 lvitem = cast(ListViewItem)cast(void*)nmdi.item.lParam; 2254 if(nmdi.item.iSubItem) 2255 { 2256 m.result = FALSE; 2257 break; 2258 } 2259 label = fromUnicodez(nmdi.item.pszText); 2260 scope LabelEditEventArgs nleea = new LabelEditEventArgs(lvitem, label); 2261 onAfterLabelEdit(nleea); 2262 if(nleea.cancelEdit) 2263 { 2264 m.result = FALSE; 2265 } 2266 else 2267 { 2268 // TODO: check if correct implementation. 2269 // Update the lvitem's cached text.. 2270 lvitem.settextin(label); 2271 2272 m.result = TRUE; 2273 } 2274 } 2275 } 2276 break; 2277 2278 case LVN_ENDLABELEDITA: 2279 if(dfl.internal.utf.useUnicode) 2280 break; 2281 { 2282 char[] label; 2283 LV_DISPINFOA* nmdi; 2284 nmdi = cast(LV_DISPINFOA*)nmh; 2285 if(nmdi.item.pszText) 2286 { 2287 ListViewItem lvitem; 2288 lvitem = cast(ListViewItem)cast(void*)nmdi.item.lParam; 2289 if(nmdi.item.iSubItem) 2290 { 2291 m.result = FALSE; 2292 break; 2293 } 2294 label = fromAnsiz(nmdi.item.pszText); 2295 scope LabelEditEventArgs nleea = new LabelEditEventArgs(lvitem, label); 2296 onAfterLabelEdit(nleea); 2297 if(nleea.cancelEdit) 2298 { 2299 m.result = FALSE; 2300 } 2301 else 2302 { 2303 // TODO: check if correct implementation. 2304 // Update the lvitem's cached text.. 2305 lvitem.settextin(label); 2306 2307 m.result = TRUE; 2308 } 2309 } 2037 2310 } 2038 2311 break; trunk/win32/dfl/makelib.bat
r5 r7 20 20 :dmc_set 21 21 22 if exist "%dmc_path%" goto got_dmc 23 @echo DMC not found; using DMD path (if you get errors, install DMC) 24 set dmc_path=%dmd_path% 25 :got_dmc 22 26 23 set dfl_files=base.d application.d internal/dlib.d internal/clib.d internal/utf.d internal/com.d control.d form.d registry.d drawing.d menu.d notifyicon.d commondialog.d filedialog.d folderdialog.d panel.d textbox.d richtextbox.d picturebox.d listbox.d groupbox.d splitter.d usercontrol.d button.d label.d collections.d internal/winapi.d internal/wincom.d event.d socket.d timer.d environment.d messagebox.d tooltip.d combobox.d treeview.d tabcontrol.d colordialog.d listview.d data.d clipboard.d fontdialog.d progressbar.d resources.d statusbar.d24 27 25 set dfl_objs=base.obj application.obj dlib.obj clib.obj utf.obj com.obj control.obj form.obj registry.obj drawing.obj menu.obj notifyicon.obj commondialog.obj filedialog.obj folderdialog.obj panel.obj textbox.obj richtextbox.obj picturebox.obj listbox.obj groupbox.obj splitter.obj usercontrol.obj button.obj label.obj collections.obj winapi.obj wincom.obj event.obj socket.obj timer.obj environment.obj messagebox.obj tooltip.obj combobox.obj treeview.obj tabcontrol.obj colordialog.obj listview.obj data.obj clipboard.obj fontdialog.obj progressbar.obj resources.obj statusbar.obj 28 if not "%dlib%" == "Tango" goto dfl_not_tango_files 29 set _stdcwindowsd=internal/_stdcwindows.d 30 set _stdcwindowsobj=_stdcwindows.obj 31 :dfl_not_tango_files 32 33 set dfl_files=base.d application.d internal/dlib.d internal/clib.d internal/utf.d internal/com.d control.d form.d registry.d drawing.d menu.d notifyicon.d commondialog.d filedialog.d folderdialog.d panel.d textbox.d richtextbox.d picturebox.d listbox.d groupbox.d splitter.d usercontrol.d button.d label.d collections.d internal/winapi.d internal/wincom.d event.d socket.d timer.d environment.d messagebox.d tooltip.d combobox.d treeview.d tabcontrol.d colordialog.d listview.d data.d clipboard.d fontdialog.d progressbar.d resources.d statusbar.d %_stdcwindowsd% 34 35 set dfl_objs=base.obj application.obj dlib.obj clib.obj utf.obj com.obj control.obj form.obj registry.obj drawing.obj menu.obj notifyicon.obj commondialog.obj filedialog.obj folderdialog.obj panel.obj textbox.obj richtextbox.obj picturebox.obj listbox.obj groupbox.obj splitter.obj usercontrol.obj button.obj label.obj collections.obj winapi.obj wincom.obj event.obj socket.obj timer.obj environment.obj messagebox.obj tooltip.obj combobox.obj treeview.obj tabcontrol.obj colordialog.obj listview.obj data.obj clipboard.obj fontdialog.obj progressbar.obj resources.obj statusbar.obj %_stdcwindowsobj% 26 36 27 37 @rem Also update link pragmas for build. … … 33 43 @rem set dfl_flags=%dfl_flags% -debug=SHOW_MESSAGENFO 34 44 set _dfl_flags=%dfl_flags% -v1 45 46 if not "%dfl_debug_flags%" == "" goto dfl_debug_flags_set 47 set dfl_debug_flags=-debug -g 48 :dfl_debug_flags_set 49 if not "%dfl_release_flags%" == "" goto dfl_release_flags_set 50 if not "%dlib%" == "Tango" goto dfl_not_release_tango 51 echo Due to a bug in DMD, release mode dfl lib will not include -inline; set environment variable dfl_release_flags to override. 52 set dfl_release_flags=-O -release 53 goto dfl_release_flags_set 54 :dfl_not_release_tango 55 set dfl_release_flags=-O -inline -release 56 :dfl_release_flags_set 35 57 36 58 … … 69 91 @echo Compiling debug DFL... 70 92 71 %dmd_path%\bin\dmd -c -debug -g -I.. %_dfl_flags%%dfl_files%93 %dmd_path%\bin\dmd -c %dfl_debug_flags% %_dfl_flags% -I.. %dfl_files% 72 94 @if errorlevel 1 goto oops 73 95 … … 82 104 @echo Compiling release DFL... 83 105 84 %dmd_path%\bin\dmd -c -O -inline -release -I.. %_dfl_flags%%dfl_files%106 %dmd_path%\bin\dmd -c %dfl_release_flags% %_dfl_flags% -I.. %dfl_files% 85 107 @if errorlevel 1 goto oops 86 108 … … 99 121 100 122 @rem This file is used by dfl.exe 101 @%dmd_path%\bin\dmd > dflcompile.info 123 @echo dlib=%dlib%>dflcompile.info 124 @%dmd_path%\bin\dmd>>dflcompile.info 102 125 103 126 trunk/win32/dfl/menu.d
r5 r7 99 99 fType = ~MFT_SEPARATOR; 100 100 mii.cbSize = mii.sizeof; 101 mii.fMask = MIIM_TYPE ;101 mii.fMask = MIIM_TYPE | MIIM_STATE; // Not setting the state can cause implicit disabled/gray if the text was empty. 102 102 mii.fType = fType; 103 mii.fState = fState; 103 104 //mii.dwTypeData = stringToStringz(txt); 104 105 … … 677 678 UINT _state() // getter 678 679 { 679 // if(mparent) fetch value ? 680 // if(mparent) fetch value ? No: Windows seems to add disabled/gray when the text is empty. 680 681 return fState; 681 682 } … … 695 696 else 696 697 { 697 _compat092 = true; 698 //_compat092 = true; 699 Application.setCompat(DflCompat.MENU_092); 698 700 } 699 701 } 700 702 701 703 version(SET_DFL_092) 702 {703 704 private const bool _compat092 = true; 704 } 705 else version(DFL_NO_COMPAT) 706 private const bool _compat092 = false; 705 707 else 706 { 707 private static bool _compat092 = false; 708 } 708 private static bool _compat092() // getter 709 { return 0 != (Application._compat & DflCompat.MENU_092); } 709 710 710 711 … … 712 713 static class MenuItemCollection 713 714 { 714 this(Menu owner)715 protected this(Menu owner) 715 716 { 716 717 _owner = owner; … … 857 858 858 859 // Menu item that isn't popup (yet). 859 pr ivatethis()860 protected this() 860 861 { 861 862 _init(); trunk/win32/dfl/progressbar.d
r5 r7 168 168 super.onHandleCreated(ea); 169 169 170 if(_min != _min.init || _max != _max.init)170 if(_min != MIN_INIT || _max != MAX_INIT) 171 171 { 172 172 prevwproc(PBM_SETRANGE, 0, MAKELPARAM(_min, _max)); 173 173 } 174 174 175 if(_step != _step.init)175 if(_step != STEP_INIT) 176 176 { 177 177 prevwproc(PBM_SETSTEP, _step, 0); 178 178 } 179 179 180 if(_val != _val.init)180 if(_val != VAL_INIT) 181 181 { 182 182 prevwproc(PBM_SETPOS, _val, 0); … … 214 214 private: 215 215 216 int _min = 0, _max = 100, _step = 10, _val = 0; 216 const int MIN_INIT = 0; 217 const int MAX_INIT = 100; 218 const int STEP_INIT = 10; 219 const int VAL_INIT = 0; 220 221 int _min = MIN_INIT, _max = MAX_INIT, _step = STEP_INIT, _val = VAL_INIT; 217 222 218 223 trunk/win32/dfl/registry.d
r5 r7 11 11 12 12 private import dfl.internal.winapi, dfl.base, dfl.internal.utf; 13 14 15 class DflRegistryException: DflException // package 16 { 17 this(char[] msg, int errorCode = 0) 18 { 19 this.errorCode = errorCode; 20 debug 21 { 22 if(errorCode) 23 msg = msg ~ " (error " ~ intToString(errorCode) ~ ")"; // Dup. 24 } 25 super(msg); 26 } 27 28 29 int errorCode; 30 } 13 31 14 32 … … 256 274 { 257 275 if(!s.length) 258 throw new Dfl Exception("Empty strings are not allowed in multi_sz registry values");276 throw new DflRegistryException("Empty strings are not allowed in multi_sz registry values"); 259 277 260 278 multi[i .. i + s.length] = s; … … 638 656 DWORD count; 639 657 640 if(ERROR_SUCCESS != RegQueryInfoKeyA(hkey, null, null, null, &count, 641 null, null, null, null, null, null, null)) 642 infoErr(); 658 LONG rr = RegQueryInfoKeyA(hkey, null, null, null, &count, 659 null, null, null, null, null, null, null); 660 if(ERROR_SUCCESS != rr) 661 infoErr(rr); 643 662 644 663 return count; … … 651 670 DWORD count; 652 671 653 if(ERROR_SUCCESS != RegQueryInfoKeyA(hkey, null, null, null, null, 654 null, null, &count, null, null, null, null)) 655 infoErr(); 672 LONG rr = RegQueryInfoKeyA(hkey, null, null, null, null, 673 null, null, &count, null, null, null, null); 674 if(ERROR_SUCCESS != rr) 675 infoErr(rr); 656 676 657 677 return count; … … 673 693 DWORD cdisp; 674 694 675 if(ERROR_SUCCESS != RegCreateKeyExA(hkey, unsafeStringz(name), 0, null, 0, KEY_ALL_ACCESS, null, &newHkey, &cdisp)) 676 throw new DflException("Unable to create registry key"); 695 LONG rr = RegCreateKeyExA(hkey, unsafeStringz(name), 0, null, 0, KEY_ALL_ACCESS, null, &newHkey, &cdisp); 696 if(ERROR_SUCCESS != rr) 697 throw new DflRegistryException("Unable to create registry key", rr); 677 698 678 699 return new RegistryKey(newHkey); … … 683 704 final void deleteSubKey(char[] name, bool throwIfMissing) 684 705 { 685 LONG opencode;686 706 HKEY openHkey; 687 707 char* namez; 688 708 689 709 if(!name.length || !name[0]) 690 { 691 unable: 692 throw new DflException("Unable to delete subkey"); 693 } 710 throw new DflRegistryException("Unable to delete subkey"); 694 711 695 712 namez = unsafeStringz(name); 696 713 697 opencode = RegOpenKeyExA(hkey, namez, 0, KEY_ALL_ACCESS, &openHkey);714 LONG opencode = RegOpenKeyExA(hkey, namez, 0, KEY_ALL_ACCESS, &openHkey); 698 715 if(ERROR_SUCCESS == opencode) 699 716 { 700 717 DWORD count; 701 718 702 if(ERROR_SUCCESS == RegQueryInfoKeyA(openHkey, null, null, null, &count, 703 null, null, null, null, null, null, null)) 719 LONG querycode = RegQueryInfoKeyA(openHkey, null, null, null, &count, 720 null, null, null, null, null, null, null); 721 if(ERROR_SUCCESS == querycode) 704 722 { 705 723 RegCloseKey(openHkey); 706 724 725 LONG delcode; 707 726 if(!count) 708 727 { 709 if(ERROR_SUCCESS == RegDeleteKeyA(hkey, namez)) 728 delcode = RegDeleteKeyA(hkey, namez); 729 if(ERROR_SUCCESS == delcode) 710 730 return; // OK. 711 731 712 goto unable;732 throw new DflRegistryException("Unable to delete subkey", delcode); 713 733 } 714 734 715 throw new Dfl Exception("Cannot delete registry key with subkeys");735 throw new DflRegistryException("Cannot delete registry key with subkeys"); 716 736 } 717 737 718 738 RegCloseKey(openHkey); 739 740 throw new DflRegistryException("Unable to delete registry key", querycode); 719 741 } 720 742 else … … 730 752 } 731 753 } 732 }733 734 throw new DflException("Unable to delete registry key");754 755 throw new DflRegistryException("Unable to delete registry key", opencode); 756 } 735 757 } 736 758 … … 758 780 if(ERROR_SUCCESS == RegOpenKeyExA(shkey, namez, 0, KEY_ALL_ACCESS, &openHkey)) 759 781 { 760 void ouch( )782 void ouch(LONG why = 0) 761 783 { 762 throw new Dfl Exception("Unable to delete entire subkey tree");784 throw new DflRegistryException("Unable to delete entire subkey tree", why); 763 785 } 764 786 … … 766 788 DWORD count; 767 789 768 if(ERROR_SUCCESS == RegQueryInfoKeyA(openHkey, null, null, null, &count, 769 null, null, null, null, null, null, null)) 790 LONG querycode = RegQueryInfoKeyA(openHkey, null, null, null, &count, 791 null, null, null, null, null, null, null); 792 if(ERROR_SUCCESS == querycode) 770 793 { 771 794 if(!count) … … 773 796 del_me: 774 797 RegCloseKey(openHkey); 775 if(ERROR_SUCCESS == RegDeleteKeyA(shkey, namez)) 798 LONG delcode = RegDeleteKeyA(shkey, namez); 799 if(ERROR_SUCCESS == delcode) 776 800 return; // OK. 777 801 778 //throw new DflException("Unable to delete subkey"); 779 ouch(); 802 ouch(delcode); 780 803 } 781 804 else … … 790 813 next_subkey: 791 814 len = skn.length; 792 switch(RegEnumKeyExA(openHkey, 0, skn.ptr, &len, null, null, null, null)) 815 LONG enumcode = RegEnumKeyExA(openHkey, 0, skn.ptr, &len, null, null, null, null); 816 switch(enumcode) 793 817 { 794 818 case ERROR_SUCCESS: … … 801 825 802 826 default: 803 ouch( );827 ouch(enumcode); 804 828 } 805 829 … … 815 839 else 816 840 { 817 ouch( );841 ouch(querycode); 818 842 } 819 843 } … … 824 848 final void deleteValue(char[] name, bool throwIfMissing) 825 849 { 826 switch(RegDeleteValueA(hkey, unsafeStringz(name))) 850 LONG rr = RegDeleteValueA(hkey, unsafeStringz(name)); 851 switch(rr) 827 852 { 828 853 case ERROR_SUCCESS: … … 833 858 break; 834 859 default: 835 throw new Dfl Exception("Unable to delete registry value");860 throw new DflRegistryException("Unable to delete registry value", rr); 836 861 } 837 862 } … … 880 905 { 881 906 len = buf.length; 882 switch(RegEnumKeyExA(hkey, idx, buf.ptr, &len, null, null, null, null)) 907 LONG rr = RegEnumKeyExA(hkey, idx, buf.ptr, &len, null, null, null, null); 908 switch(rr) 883 909 { 884 910 case ERROR_SUCCESS: … … 891 917 892 918 default: 893 throw new Dfl Exception("Unable to obtain subkey names");919 throw new DflRegistryException("Unable to obtain subkey names", rr); 894 920 } 895 921 } … … 907 933 908 934 len = 0; 909 switch(RegQueryValueExA(hkey, unsafeStringz(name), null, &type, null, &len)) 935 LONG querycode = RegQueryValueExA(hkey, unsafeStringz(name), null, &type, null, &len); 936 switch(querycode) 910 937 { 911 938 case ERROR_SUCCESS: … … 917 944 return defaultValue; 918 945 919 default: err :920 throw new Dfl Exception("Unable to get registry value");946 default: errquerycode: 947 throw new DflRegistryException("Unable to get registry value", querycode); 921 948 } 922 949 923 950 data = new ubyte[len]; 924 if(ERROR_SUCCESS != RegQueryValueExA(hkey, unsafeStringz(name), null, &type, data.ptr, &len)) 925 goto err; 951 // Note: reusing querycode here and above. 952 querycode = RegQueryValueExA(hkey, unsafeStringz(name), null, &type, data.ptr, &len); 953 if(ERROR_SUCCESS != querycode) 954 goto errquerycode; 926 955 927 956 switch(type) … … 1014 1043 1015 1044 default: 1016 throw new Dfl Exception("Unknown type for registry value");1045 throw new DflRegistryException("Unknown type for registry value"); 1017 1046 } 1018 1047 … … 1039 1068 { 1040 1069 len = buf.length; 1041 switch(RegEnumValueA(hkey, idx, buf.ptr, &len, null, null, null, null)) 1070 LONG rr = RegEnumValueA(hkey, idx, buf.ptr, &len, null, null, null, null); 1071 switch(rr) 1042 1072 { 1043 1073 case ERROR_SUCCESS: … … 1050 1080 1051 1081 default: 1052 throw new Dfl Exception("Unable to obtain value names");1082 throw new DflRegistryException("Unable to obtain value names", rr); 1053 1083 } 1054 1084 } … … 1063 1093 HKEY openHkey; 1064 1094 1065 if(ERROR_SUCCESS != RegConnectRegistryA(unsafeStringz(machineName), cast(HKEY)hhive, &openHkey)) 1066 throw new DflException("Unable to open remote base key"); 1095 LONG rr = RegConnectRegistryA(unsafeStringz(machineName), cast(HKEY)hhive, &openHkey); 1096 if(ERROR_SUCCESS != rr) 1097 throw new DflRegistryException("Unable to open remote base key", rr); 1067 1098 1068 1099 return new RegistryKey(openHkey); … … 1093 1124 final void setValue(char[] name, RegistryValue value) 1094 1125 { 1095 if(ERROR_SUCCESS != value.save(hkey, name)) 1096 throw new DflException("Unable to set registry value"); 1126 LONG rr = value.save(hkey, name); 1127 if(ERROR_SUCCESS != rr) 1128 throw new DflRegistryException("Unable to set registry value", rr); 1097 1129 } 1098 1130 … … 1145 1177 1146 1178 1147 void infoErr()1148 { 1149 throw new Dfl Exception("Unable to obtain registry information");1150 } 1151 } 1152 1179 private void infoErr(LONG why) 1180 { 1181 throw new DflRegistryException("Unable to obtain registry information", why); 1182 } 1183 } 1184 trunk/win32/dfl/richtextbox.d
r5 r7 502 502 if(created) 503 503 { 504 // To-do: support Unicode font names. 505 504 506 CHARFORMAT2A cf; 505 507 LOGFONTA lf; … … 566 568 lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 567 569 } 568 return new Font(Font._create(&lf)); 570 //return new Font(Font._create(&lf)); 571 LogFont _lf; 572 Font.LOGFONTAtoLogFont(_lf, &lf); 573 return new Font(Font._create(_lf)); 569 574 } 570 575 } trunk/win32/dfl/socket.d
r5 r7 189 189 190 190 191 override void close() 192 { 193 unregisterEvent(this); 194 super.close(); 191 static if(is(typeof(&this.detach))) 192 { 193 override void detach() 194 { 195 unregisterEvent(this); 196 super.detach(); 197 } 198 } 199 else 200 { 201 override void close() 202 { 203 unregisterEvent(this); 204 super.close(); 205 } 195 206 } 196 207 trunk/win32/dfl/splitter.d
r5 r7 118 118 119 119 120 package void initsplit(int sx, int sy) 121 { 122 capture = true; 123 124 downing = true; 125 //downpos = Point(mea.x, mea.y); 126 127 switch(dock) 128 { 129 case DockStyle.TOP: 130 case DockStyle.BOTTOM: 131 downpos = sy; 132 lastpos = 0; 133 drawxorClient(0, lastpos); 134 break; 135 136 default: // LEFT / RIGHT. 137 downpos = sx; 138 lastpos = 0; 139 drawxorClient(lastpos, 0); 140 } 141 } 142 143 144 final void resumeSplit(int sx, int sy) // package 145 { 146 if(Control.mouseButtons & MouseButtons.LEFT) 147 { 148 initsplit(sx, sy); 149 150 if(cursor) 151 Cursor.current = cursor; 152 } 153 } 154 155 // /// ditto 156 final void resumeSplit() // package 157 { 158 Point pt = pointToClient(Cursor.position); 159 return resumeSplit(pt.x, pt.y); 160 } 161 162 120 163 /// 121 164 void movingGrip(bool byes) // setter … … 149 192 if(mgrip) 150 193 { 151 ea.graphics.drawMoveGrip( bounds, DockStyle.LEFT == dock || DockStyle.RIGHT == dock);194 ea.graphics.drawMoveGrip(displayRectangle, DockStyle.LEFT == dock || DockStyle.RIGHT == dock); 152 195 } 153 196 } … … 156 199 protected override void onResize(EventArgs ea) 157 200 { 158 super.onResize(ea);159 160 201 if(mgrip) 161 202 { 162 203 invalidate(); 163 204 } 205 206 resize(this, ea); 164 207 } 165 208 … … 171 214 if(mea.button == MouseButtons.LEFT) 172 215 { 173 capture = true; 174 175 downing = true; 176 //downpos = Point(mea.x, mea.y); 177 178 switch(dock) 179 { 180 case DockStyle.TOP: 181 case DockStyle.BOTTOM: 182 downpos = mea.y; 183 lastpos = 0; 184 drawxorClient(0, lastpos); 185 break; 186 187 default: // LEFT / RIGHT. 188 downpos = mea.x; 189 lastpos = 0; 190 drawxorClient(lastpos, 0); 191 } 216 initsplit(mea.x, mea.y); 192 217 } 193 218 } … … 437 462 438 463 //SplitterEventHandler splitterMoved; 439 Event!(Splitter, EventArgs) splitterMoved; ///464 Event!(Splitter, SplitterEventArgs) splitterMoved; /// 440 465 //SplitterEventHandler splitterMoving; 441 Event!(Splitter, EventArgs) splitterMoving; ///466 Event!(Splitter, SplitterEventArgs) splitterMoving; /// 442 467 443 468 … … 446 471 override Size defaultSize() // getter 447 472 { 448 return Size(GetSystemMetrics(SM_CXSIZEFRAME), GetSystemMetrics(SM_CYSIZEFRAME)); 473 //return Size(GetSystemMetrics(SM_CXSIZEFRAME), GetSystemMetrics(SM_CYSIZEFRAME)); 474 int sx = GetSystemMetrics(SM_CXSIZEFRAME); 475 int sy = GetSystemMetrics(SM_CYSIZEFRAME); 476 // Need a bit extra room for the move-grips. 477 if(sx < 5) 478 sx = 5; 479 if(sy < 5) 480 sy = 5; 481 return Size(sx, sy); 449 482 } 450 483 … … 453 486 void onSplitterMoving(SplitterEventArgs sea) 454 487 { 455 456 457 488 splitterMoving(this, sea); 458 489 } trunk/win32/dfl/statusbar.d
r5 r7 146 146 } 147 147 148 if(_parent && _parent. created)148 if(_parent && _parent.isHandleCreated) 149 149 { 150 150 _parent.panels._fixtexts(); // Also fixes styles. … … 199 199 final void text(char[] txt) // setter 200 200 { 201 if(_parent && _parent. created)201 if(_parent && _parent.isHandleCreated) 202 202 { 203 203 int idx = _parent.panels.indexOf(this); … … 236 236 _width = w; 237 237 238 if(_parent && _parent. created)238 if(_parent && _parent.isHandleCreated) 239 239 { 240 240 _parent.panels._fixwidths(); … … 285 285 class StatusBarPanelCollection 286 286 { 287 this(StatusBar sb)287 protected this(StatusBar sb) 288 288 in 289 289 { … … 302 302 303 303 304 void _fixwidths()305 { 306 assert( created);304 package void _fixwidths() 305 { 306 assert(isHandleCreated); 307 307 308 308 UINT[20] _pws = void; … … 320 320 void _fixtexts() 321 321 { 322 assert( created);322 assert(isHandleCreated); 323 323 324 324 if(dfl.internal.utf.useUnicode) … … 341 341 void _setcurparts() 342 342 { 343 assert( created);343 assert(isHandleCreated); 344 344 345 345 _fixwidths(); … … 353 353 if(size_t.max == idx) // Clear all. 354 354 { 355 if(sb. created)355 if(sb.isHandleCreated) 356 356 { 357 357 sb.prevwproc(SB_SETPARTS, 0, 0); // 0 parts. … … 360 360 else 361 361 { 362 if(sb. created)362 if(sb.isHandleCreated) 363 363 { 364 364 _setcurparts(); … … 373 373 throw new DflException("StatusBarPanel already belongs to a StatusBar"); 374 374 375 if(sb.created) 375 val._parent = sb; 376 377 if(sb.isHandleCreated) 376 378 { 377 379 _setcurparts(); … … 446 448 return; 447 449 448 if( created)450 if(isHandleCreated) 449 451 { 450 452 prevwproc(SB_SIMPLE, cast(WPARAM)!byes, 0); … … 496 498 override void text(char[] txt) // setter 497 499 { 498 if( created && !showPanels)500 if(isHandleCreated && !showPanels) 499 501 { 500 502 _sendidxtext(255, 0, txt); … … 517 519 super.onHandleCreated(ea); 518 520 519 panels._setcurparts(); 520 521 if(_issimple && _simpletext.length) 522 _sendidxtext(255, 0, _simpletext); 523 prevwproc(SB_SIMPLE, cast(WPARAM)_issimple, 0); 524 525 panels._setcurparts(); 521 if(_issimple) 522 { 523 prevwproc(SB_SIMPLE, cast(WPARAM)true, 0); 524 panels._setcurparts(); 525 if(_simpletext.length) 526 _sendidxtext(255, 0, _simpletext); 527 } 528 else 529 { 530 panels._setcurparts(); 531 prevwproc(SB_SIMPLE, cast(WPARAM)false, 0); 532 } 526 533 } 527 534 … … 587 594 void _sendidxtext(int idx, WPARAM utype, char[] txt) 588 595 { 589 assert( created);596 assert(isHandleCreated); 590 597 591 598 if(dfl.internal.utf.useUnicode) trunk/win32/dfl/tabcontrol.d
r5 r7 168 168 class TabPageCollection 169 169 { 170 this(TabControl owner)170 protected this(TabControl owner) 171 171 in 172 172 { trunk/win32/dfl/treeview.d
r5 r7 1797 1797 { 1798 1798 case TVE_COLLAPSE: 1799 onAfterCollapse(new TreeViewEventArgs(cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 1800 TreeViewAction.COLLAPSE)); 1799 { 1800 scope TreeViewEventArgs tvea = new TreeViewEventArgs( 1801 cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 1802 TreeViewAction.COLLAPSE); 1803 onAfterCollapse(tvea); 1804 } 1801 1805 break; 1802 1806 1803 1807 case TVE_EXPAND: 1804 onAfterExpand(new TreeViewEventArgs(cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 1805 TreeViewAction.EXPAND)); 1808 { 1809 scope TreeViewEventArgs tvea = new TreeViewEventArgs( 1810 cast(TreeNode)cast(void*)nmtv.itemNew.lParam, 1811 TreeViewAction.EXPAND); 1812 onAfterExpand(tvea); 1813 } 1806 1814 break; 1807 1815 … … 1821 1829 TV_DISPINFOA* nmdi; 1822 1830 nmdi = cast(TV_DISPINFOA*)nmh; 1823 NodeLabelEditEventArgs nleea;1824 1831 TreeNode node; 1825 1832 node = cast(TreeNode)cast(void*)nmdi.item.lParam; 1826 // The nleea.label should contain the NEW text, which 1827 // there is no new text before it's edited... ? 1828 // TODO: check if correct implementation. 1829 nleea = new NodeLabelEditEventArgs(node /+ , node.text +/); 1833 scope NodeLabelEditEventArgs nleea = new NodeLabelEditEventArgs(node); 1830 1834 onBeforeLabelEdit(nleea); 1831 1835 m.result = nleea.cancelEdit; … … 1834 1838 1835 1839 case TVN_ENDLABELEDITW: 1836 goto end_label_edit; 1840 { 1841 char[] label; 1842 TV_DISPINFOW* nmdi; 1843 nmdi = cast(TV_DISPINFOW*)nmh; 1844 if(nmdi.item.pszText) 1845 { 1846 TreeNode node; 1847 node = cast(TreeNode)cast(void*)nmdi.item.lParam; 1848 label = fromUnicodez(nmdi.item.pszText); 1849 scope NodeLabelEditEventArgs nleea = new NodeLabelEditEventArgs(node, label); 1850 onAfterLabelEdit(nleea); 1851 if(nleea.cancelEdit) 1852 { 1853 m.result = FALSE; 1854 } 1855 else 1856 { 1857 // TODO: check if correct implementation. 1858 // Update the node's cached text.. 1859 node.ttext = label; 1860 1861 m.result = TRUE; 1862 } 1863 } 1864 } 1865 break; 1837 1866 1838 1867 case TVN_ENDLABELEDITA: 1839 1868 if(dfl.internal.utf.useUnicode) 1840 1869 break; 1841 end_label_edit:1842 1843 1870 { 1844 1871 char[] label; 1845 1872 TV_DISPINFOA* nmdi; 1846 1873 nmdi = cast(TV_DISPINFOA*)nmh; 1847 NodeLabelEditEventArgs nleea;1848 TreeNode node;1849 // TODO: check if correct implementation.1850 node = cast(TreeNode)cast(void*)nmdi.item.lParam;1851 1874 if(nmdi.item.pszText) 1852 label = stringFromStringz(nmdi.item.pszText).dup;1853 nleea = new NodeLabelEditEventArgs(node, label);1854 if(!nmdi.item.pszText)1855 nleea.cancelEdit = true;1856 onAfterLabelEdit(nleea);1857 if(nleea.cancelEdit)1858 1875 { 1859 m.result = FALSE; 1860 } 1861 else 1862 { 1863 // TODO: check if correct implementation. 1864 // Update the node's cached text.. 1865 node.ttext = label; 1866 1867 m.result = TRUE; 1876 TreeNode node; 1877 node = cast(TreeNode)cast(void*)nmdi.item.lParam; 1878 label = fromAnsiz(nmdi.item.pszText); 1879 scope NodeLabelEditEventArgs nleea = new NodeLabelEditEventArgs(node, label); 1880 onAfterLabelEdit(nleea); 1881 if(nleea.cancelEdit) 1882 { 1883 m.result = FALSE; 1884 } 1885 else 1886 { 1887 // TODO: check if correct implementation. 1888 // Update the node's cached text.. 1889 node.ttext = label; 1890 1891 m.result = TRUE; 1892 } 1868 1893 } 1869 1894 }
