comparison dwt/widgets/TreeItem.d @ 237:e2affbeb686d

Making tango.sys.win32.Types and dwt.internal.win32.WINTYPES to match common declaration. Make ansi charactars of type ubyte.
author Frank Benoit <benoit@tionex.de>
date Thu, 19 Jun 2008 03:25:36 +0200
parents c749c13479ef
children ecb80b2a89e1
comparison
equal deleted inserted replaced
236:9c1bb90eba13 237:e2affbeb686d
252 auto hwnd = parent.handle; 252 auto hwnd = parent.handle;
253 TVITEM tvItem; 253 TVITEM tvItem;
254 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 254 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
255 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 255 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
256 tvItem.state = 1 << 12; 256 tvItem.state = 1 << 12;
257 tvItem.hItem = handle; 257 tvItem.hItem = cast(HTREEITEM)handle;
258 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem); 258 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
259 } 259 }
260 background = foreground = -1; 260 background = foreground = -1;
261 font = null; 261 font = null;
262 cellBackground = cellForeground = null; 262 cellBackground = cellForeground = null;
438 if (!getText && !getImage) return new RECT(); 438 if (!getText && !getImage) return new RECT();
439 auto hwnd = parent.handle; 439 auto hwnd = parent.handle;
440 if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) { 440 if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) {
441 TVITEM tvItem; 441 TVITEM tvItem;
442 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT; 442 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
443 tvItem.hItem = handle; 443 tvItem.hItem = cast(HTREEITEM)handle;
444 tvItem.pszText = OS.LPSTR_TEXTCALLBACK; 444 tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
445 parent.ignoreCustomDraw = true; 445 parent.ignoreCustomDraw = true;
446 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem); 446 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
447 parent.ignoreCustomDraw = false; 447 parent.ignoreCustomDraw = false;
448 } 448 }
454 firstColumn = index is OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0); 454 firstColumn = index is OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
455 } 455 }
456 RECT* rect = new RECT(); 456 RECT* rect = new RECT();
457 if (firstColumn) { 457 if (firstColumn) {
458 bool full = columnCount is 0 && getText && getImage && fullText && fullImage; 458 bool full = columnCount is 0 && getText && getImage && fullText && fullImage;
459 if (!OS.TreeView_GetItemRect (hwnd, handle, rect, !full)) { 459 if (!OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)handle, rect, !full)) {
460 return new RECT(); 460 return new RECT();
461 } 461 }
462 if (getImage && !fullImage) { 462 if (getImage && !fullImage) {
463 if (OS.SendMessage (hwnd, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) !is 0) { 463 if (OS.SendMessage (hwnd, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) !is 0) {
464 Point size = parent.getImageSize (); 464 Point size = parent.getImageSize ();
490 if (!(0 <= index && index < columnCount)) return new RECT(); 490 if (!(0 <= index && index < columnCount)) return new RECT();
491 RECT* headerRect = new RECT(); 491 RECT* headerRect = new RECT();
492 if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) headerRect) is 0) { 492 if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) headerRect) is 0) {
493 return new RECT(); 493 return new RECT();
494 } 494 }
495 if (!OS.TreeView_GetItemRect (hwnd, handle, rect, false)) { 495 if (!OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)handle, rect, false)) {
496 return new RECT(); 496 return new RECT();
497 } 497 }
498 rect.left = headerRect.left; 498 rect.left = headerRect.left;
499 if (fullText && getImage && clip) { 499 if (fullText && getImage && clip) {
500 rect.right = headerRect.right; 500 rect.right = headerRect.right;
574 if ((parent.style & DWT.CHECK) is 0) return false; 574 if ((parent.style & DWT.CHECK) is 0) return false;
575 auto hwnd = parent.handle; 575 auto hwnd = parent.handle;
576 TVITEM tvItem; 576 TVITEM tvItem;
577 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 577 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
578 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 578 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
579 tvItem.hItem = handle; 579 tvItem.hItem = cast(HTREEITEM)handle;
580 int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem); 580 int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
581 return (result !is 0) && (((tvItem.state >> 12) & 1) is 0); 581 return (result !is 0) && (((tvItem.state >> 12) & 1) is 0);
582 } 582 }
583 583
584 /** 584 /**
718 if ((parent.style & DWT.CHECK) is 0) return false; 718 if ((parent.style & DWT.CHECK) is 0) return false;
719 auto hwnd = parent.handle; 719 auto hwnd = parent.handle;
720 TVITEM tvItem; 720 TVITEM tvItem;
721 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 721 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
722 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 722 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
723 tvItem.hItem = handle; 723 tvItem.hItem = cast(HTREEITEM)handle;
724 int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem); 724 int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
725 return (result !is 0) && ((tvItem.state >> 12) > 2); 725 return (result !is 0) && ((tvItem.state >> 12) > 2);
726 } 726 }
727 727
728 /** 728 /**
992 full = true; 992 full = true;
993 } 993 }
994 } 994 }
995 } 995 }
996 RECT rect; 996 RECT rect;
997 if (OS.TreeView_GetItemRect (hwnd, handle, &rect, !full)) { 997 if (OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)handle, &rect, !full)) {
998 OS.InvalidateRect (hwnd, &rect, true); 998 OS.InvalidateRect (hwnd, &rect, true);
999 } 999 }
1000 } 1000 }
1001 1001
1002 void redraw (int column, bool drawText, bool drawImage) { 1002 void redraw (int column, bool drawText, bool drawImage) {
1044 public void removeAll () { 1044 public void removeAll () {
1045 checkWidget (); 1045 checkWidget ();
1046 auto hwnd = parent.handle; 1046 auto hwnd = parent.handle;
1047 TVITEM tvItem; 1047 TVITEM tvItem;
1048 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM; 1048 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
1049 tvItem.hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, cast(int)handle); 1049 tvItem.hItem = cast(HTREEITEM) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, cast(int)handle);
1050 while (tvItem.hItem !is null) { 1050 while (tvItem.hItem !is null) {
1051 OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, cast(int)&tvItem); 1051 OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, cast(int)&tvItem);
1052 TreeItem item = tvItem.lParam !is -1 ? parent.items [tvItem.lParam] : null; 1052 TreeItem item = tvItem.lParam !is -1 ? parent.items [tvItem.lParam] : null;
1053 if (item !is null && !item.isDisposed ()) { 1053 if (item !is null && !item.isDisposed ()) {
1054 item.dispose (); 1054 item.dispose ();
1055 } else { 1055 } else {
1056 parent.releaseItem (tvItem.hItem, &tvItem, false); 1056 parent.releaseItem (tvItem.hItem, &tvItem, false);
1057 parent.destroyItem (null, tvItem.hItem); 1057 parent.destroyItem (null, tvItem.hItem);
1058 } 1058 }
1059 tvItem.hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, cast(int)handle); 1059 tvItem.hItem = cast(HTREEITEM) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, cast(int)handle);
1060 } 1060 }
1061 } 1061 }
1062 1062
1063 /** 1063 /**
1064 * Sets the receiver's background color to the color specified 1064 * Sets the receiver's background color to the color specified
1153 if ((parent.style & DWT.CHECK) is 0) return; 1153 if ((parent.style & DWT.CHECK) is 0) return;
1154 auto hwnd = parent.handle; 1154 auto hwnd = parent.handle;
1155 TVITEM tvItem; 1155 TVITEM tvItem;
1156 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 1156 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
1157 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 1157 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
1158 tvItem.hItem = handle; 1158 tvItem.hItem = cast(HTREEITEM)handle;
1159 OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem); 1159 OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
1160 int state = tvItem.state >> 12; 1160 int state = tvItem.state >> 12;
1161 if (checked) { 1161 if (checked) {
1162 if ((state & 0x1) !is 0) state++; 1162 if ((state & 0x1) !is 0) state++;
1163 } else { 1163 } else {
1175 * a redraw. 1175 * a redraw.
1176 */ 1176 */
1177 if ((parent.style & DWT.VIRTUAL) !is 0) { 1177 if ((parent.style & DWT.VIRTUAL) !is 0) {
1178 if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) { 1178 if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) {
1179 RECT rect; 1179 RECT rect;
1180 if (OS.TreeView_GetItemRect (hwnd, handle, &rect, false)) { 1180 if (OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)handle, &rect, false)) {
1181 OS.InvalidateRect (hwnd, &rect, true); 1181 OS.InvalidateRect (hwnd, &rect, true);
1182 } 1182 }
1183 } 1183 }
1184 } 1184 }
1185 } 1185 }
1254 rects = new RECT [count + 1]; 1254 rects = new RECT [count + 1];
1255 HANDLE hItem = hTopItem; 1255 HANDLE hItem = hTopItem;
1256 int index = 0; 1256 int index = 0;
1257 while (hItem !is null && (noAnimate || hItem !is handle) && index < count) { 1257 while (hItem !is null && (noAnimate || hItem !is handle) && index < count) {
1258 RECT rect; 1258 RECT rect;
1259 if (OS.TreeView_GetItemRect (hwnd, hItem, &rect, true)) { 1259 if (OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)hItem, &rect, true)) {
1260 rects [index++] = rect; 1260 rects [index++] = rect;
1261 } 1261 }
1262 hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, cast(int) &hItem); 1262 hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, cast(int) &hItem);
1263 } 1263 }
1264 if (noAnimate || hItem !is handle) { 1264 if (noAnimate || hItem !is handle) {
1304 /* Scroll back to the top item */ 1304 /* Scroll back to the top item */
1305 if (noScroll && hTopItem !is null) { 1305 if (noScroll && hTopItem !is null) {
1306 bool collapsed = false; 1306 bool collapsed = false;
1307 if (!expanded) { 1307 if (!expanded) {
1308 RECT rect; 1308 RECT rect;
1309 while (hTopItem !is null && !OS.TreeView_GetItemRect (hwnd, hTopItem, &rect, false)) { 1309 while (hTopItem !is null && !OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)hTopItem, &rect, false)) {
1310 hTopItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hTopItem); 1310 hTopItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hTopItem);
1311 collapsed = true; 1311 collapsed = true;
1312 } 1312 }
1313 } 1313 }
1314 bool scrolled = true; 1314 bool scrolled = true;
1335 if (OS.EqualRect (&oldRect, &newRect)) { 1335 if (OS.EqualRect (&oldRect, &newRect)) {
1336 HANDLE hItem = hTopItem; 1336 HANDLE hItem = hTopItem;
1337 int index = 0; 1337 int index = 0;
1338 while (hItem !is null && index < count) { 1338 while (hItem !is null && index < count) {
1339 RECT rect; 1339 RECT rect;
1340 if (OS.TreeView_GetItemRect (hwnd, hItem, &rect, true)) { 1340 if (OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)hItem, &rect, true)) {
1341 if (!OS.EqualRect (&rect, & rects [index])) { 1341 if (!OS.EqualRect (&rect, & rects [index])) {
1342 break; 1342 break;
1343 } 1343 }
1344 } 1344 }
1345 hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem); 1345 hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
1365 if (OS.GetScrollInfo (hwnd, OS.SB_VERT, &info)) { 1365 if (OS.GetScrollInfo (hwnd, OS.SB_VERT, &info)) {
1366 OS.SetScrollInfo (hwnd, OS.SB_VERT, &info, true); 1366 OS.SetScrollInfo (hwnd, OS.SB_VERT, &info, true);
1367 } 1367 }
1368 if (handle is hBottomItem) { 1368 if (handle is hBottomItem) {
1369 RECT rect; 1369 RECT rect;
1370 if (OS.TreeView_GetItemRect (hwnd, hBottomItem, &rect, false)) { 1370 if (OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)hBottomItem, &rect, false)) {
1371 OS.InvalidateRect (hwnd, &rect, true); 1371 OS.InvalidateRect (hwnd, &rect, true);
1372 } 1372 }
1373 } 1373 }
1374 } else { 1374 } else {
1375 static if (OS.IsWinCE) { 1375 static if (OS.IsWinCE) {
1433 return; 1433 return;
1434 } 1434 }
1435 auto hwnd = parent.handle; 1435 auto hwnd = parent.handle;
1436 TVITEM tvItem; 1436 TVITEM tvItem;
1437 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT; 1437 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
1438 tvItem.hItem = handle; 1438 tvItem.hItem = cast(HTREEITEM)handle;
1439 tvItem.pszText = OS.LPSTR_TEXTCALLBACK; 1439 tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
1440 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem); 1440 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
1441 } 1441 }
1442 1442
1443 1443
1488 return; 1488 return;
1489 } 1489 }
1490 auto hwnd = parent.handle; 1490 auto hwnd = parent.handle;
1491 TVITEM tvItem; 1491 TVITEM tvItem;
1492 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT; 1492 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
1493 tvItem.hItem = handle; 1493 tvItem.hItem = cast(HTREEITEM)handle;
1494 tvItem.pszText = OS.LPSTR_TEXTCALLBACK; 1494 tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
1495 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem); 1495 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
1496 } else { 1496 } else {
1497 redraw (index, true, false); 1497 redraw (index, true, false);
1498 } 1498 }
1593 if ((parent.style & DWT.CHECK) is 0) return; 1593 if ((parent.style & DWT.CHECK) is 0) return;
1594 auto hwnd = parent.handle; 1594 auto hwnd = parent.handle;
1595 TVITEM tvItem; 1595 TVITEM tvItem;
1596 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE; 1596 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
1597 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK; 1597 tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
1598 tvItem.hItem = handle; 1598 tvItem.hItem = cast(HTREEITEM)handle;
1599 OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem); 1599 OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
1600 int state = tvItem.state >> 12; 1600 int state = tvItem.state >> 12;
1601 if (grayed) { 1601 if (grayed) {
1602 if (state <= 2) state +=2; 1602 if (state <= 2) state +=2;
1603 } else { 1603 } else {
1615 * a redraw. 1615 * a redraw.
1616 */ 1616 */
1617 if ((parent.style & DWT.VIRTUAL) !is 0) { 1617 if ((parent.style & DWT.VIRTUAL) !is 0) {
1618 if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) { 1618 if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) {
1619 RECT rect; 1619 RECT rect;
1620 if (OS.TreeView_GetItemRect (hwnd, handle, &rect, false)) { 1620 if (OS.TreeView_GetItemRect (hwnd, cast(HTREEITEM)handle, &rect, false)) {
1621 OS.InvalidateRect (hwnd, &rect, true); 1621 OS.InvalidateRect (hwnd, &rect, true);
1622 } 1622 }
1623 } 1623 }
1624 } 1624 }
1625 } 1625 }
1701 return; 1701 return;
1702 } 1702 }
1703 auto hwnd = parent.handle; 1703 auto hwnd = parent.handle;
1704 TVITEM tvItem; 1704 TVITEM tvItem;
1705 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE; 1705 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE;
1706 tvItem.hItem = handle; 1706 tvItem.hItem = cast(HTREEITEM)handle;
1707 tvItem.iImage = tvItem.iSelectedImage = OS.I_IMAGECALLBACK; 1707 tvItem.iImage = tvItem.iSelectedImage = OS.I_IMAGECALLBACK;
1708 /* 1708 /*
1709 * Bug in Windows. When I_IMAGECALLBACK is used with TVM_SETITEM 1709 * Bug in Windows. When I_IMAGECALLBACK is used with TVM_SETITEM
1710 * to indicate that an image has changed, Windows does not draw 1710 * to indicate that an image has changed, Windows does not draw
1711 * the new image. The fix is to use LPSTR_TEXTCALLBACK to force 1711 * the new image. The fix is to use LPSTR_TEXTCALLBACK to force
1808 return; 1808 return;
1809 } 1809 }
1810 auto hwnd = parent.handle; 1810 auto hwnd = parent.handle;
1811 TVITEM tvItem; 1811 TVITEM tvItem;
1812 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT; 1812 tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
1813 tvItem.hItem = handle; 1813 tvItem.hItem = cast(HTREEITEM)handle;
1814 tvItem.pszText = OS.LPSTR_TEXTCALLBACK; 1814 tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
1815 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem); 1815 OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
1816 } else { 1816 } else {
1817 redraw (index, true, false); 1817 redraw (index, true, false);
1818 } 1818 }