Mercurial > projects > dwt-mac
comparison dwt/widgets/TreeItem.d @ 7:e831403a80a9
Add 'cast' to casts
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 14:30:35 +0200 |
parents | 1a8b3cb347e0 |
children | d8635bb48c7c |
comparison
equal
deleted
inserted
replaced
6:b903c16b6f48 | 7:e831403a80a9 |
---|---|
239 // event.width = width; | 239 // event.width = width; |
240 // event.height = height [0]; | 240 // event.height = height [0]; |
241 // parent.sendEvent (DWT.MeasureItem, event); | 241 // parent.sendEvent (DWT.MeasureItem, event); |
242 // if (parent.itemHeight < event.height) { | 242 // if (parent.itemHeight < event.height) { |
243 // parent.itemHeight = event.height; | 243 // parent.itemHeight = event.height; |
244 // OS.SetDataBrowserTableViewRowHeight (parent.handle, (short) event.height); | 244 // OS.SetDataBrowserTableViewRowHeight (parent.handle, cast(short) event.height); |
245 // } | 245 // } |
246 // width = event.width; | 246 // width = event.width; |
247 // } | 247 // } |
248 if (index is 0) this.width = width; | 248 if (index is 0) this.width = width; |
249 return width; | 249 return width; |
345 String text = getText (index); | 345 String text = getText (index); |
346 int length = text.length(); | 346 int length = text.length(); |
347 char[] chars = new char[length]; | 347 char[] chars = new char[length]; |
348 text.getChars(0, length, chars, 0); | 348 text.getChars(0, length, chars, 0); |
349 NSString str = NSString.stringWithCharacters(chars, length); | 349 NSString str = NSString.stringWithCharacters(chars, length); |
350 NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); | 350 NSAttributedString attribStr = (cast(NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); |
351 attribStr.autorelease(); | 351 attribStr.autorelease(); |
352 return attribStr; | 352 return attribStr; |
353 } | 353 } |
354 | 354 |
355 void destroyWidget () { | 355 void destroyWidget () { |
410 * </ul> | 410 * </ul> |
411 */ | 411 */ |
412 public Rectangle getBounds () { | 412 public Rectangle getBounds () { |
413 checkWidget (); | 413 checkWidget (); |
414 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 414 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
415 NSOutlineView outlineView = (NSOutlineView) parent.view; | 415 NSOutlineView outlineView = cast(NSOutlineView) parent.view; |
416 int row = outlineView.rowForItem(handle); | 416 int row = outlineView.rowForItem(handle); |
417 NSRect rect = outlineView.rectOfRow (row); | 417 NSRect rect = outlineView.rectOfRow (row); |
418 rect = outlineView.convertRect_toView_ (rect, parent.scrollView); | 418 rect = outlineView.convertRect_toView_ (rect, parent.scrollView); |
419 Rectangle result = new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); | 419 Rectangle result = new Rectangle(cast(int) rect.x, cast(int) rect.y, cast(int) rect.width, cast(int) rect.height); |
420 return result; | 420 return result; |
421 } | 421 } |
422 | 422 |
423 /** | 423 /** |
424 * Returns a rectangle describing the receiver's size and location | 424 * Returns a rectangle describing the receiver's size and location |
436 */ | 436 */ |
437 public Rectangle getBounds (int index) { | 437 public Rectangle getBounds (int index) { |
438 checkWidget (); | 438 checkWidget (); |
439 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 439 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
440 if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0); | 440 if (index !is 0 && !(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0); |
441 NSOutlineView outlineView = (NSOutlineView) parent.view; | 441 NSOutlineView outlineView = cast(NSOutlineView) parent.view; |
442 int row = outlineView.rowForItem(handle); | 442 int row = outlineView.rowForItem(handle); |
443 if ((parent.style & DWT.CHECK) !is 0) index ++; | 443 if ((parent.style & DWT.CHECK) !is 0) index ++; |
444 NSRect rect = outlineView.frameOfCellAtColumn(index, row); | 444 NSRect rect = outlineView.frameOfCellAtColumn(index, row); |
445 rect = outlineView.convertRect_toView_ (rect, parent.scrollView); | 445 rect = outlineView.convertRect_toView_ (rect, parent.scrollView); |
446 return new Rectangle((int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height); | 446 return new Rectangle(cast(int)rect.x, cast(int)rect.y, cast(int)rect.width, cast(int)rect.height); |
447 } | 447 } |
448 | 448 |
449 /** | 449 /** |
450 * Returns <code>true</code> if the receiver is checked, | 450 * Returns <code>true</code> if the receiver is checked, |
451 * and false otherwise. When the parent does not have | 451 * and false otherwise. When the parent does not have |
959 Color oldColor = background; | 959 Color oldColor = background; |
960 if (oldColor is color) return; | 960 if (oldColor is color) return; |
961 background = color; | 961 background = color; |
962 if (oldColor !is null && oldColor.equals (color)) return; | 962 if (oldColor !is null && oldColor.equals (color)) return; |
963 cached = true; | 963 cached = true; |
964 ((NSOutlineView)parent.view).reloadItem_(handle); | 964 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
965 } | 965 } |
966 | 966 |
967 /** | 967 /** |
968 * Sets the background color at the given column index in the receiver | 968 * Sets the background color at the given column index in the receiver |
969 * to the color specified by the argument, or to the default system color for the item | 969 * to the color specified by the argument, or to the default system color for the item |
997 Color oldColor = cellBackground [index]; | 997 Color oldColor = cellBackground [index]; |
998 if (oldColor is color) return; | 998 if (oldColor is color) return; |
999 cellBackground [index] = color; | 999 cellBackground [index] = color; |
1000 if (oldColor !is null && oldColor.equals (color)) return; | 1000 if (oldColor !is null && oldColor.equals (color)) return; |
1001 cached = true; | 1001 cached = true; |
1002 ((NSOutlineView)parent.view).reloadItem_(handle); | 1002 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1003 } | 1003 } |
1004 | 1004 |
1005 /** | 1005 /** |
1006 * Sets the checked state of the receiver. | 1006 * Sets the checked state of the receiver. |
1007 * <p> | 1007 * <p> |
1017 checkWidget (); | 1017 checkWidget (); |
1018 if ((parent.style & DWT.CHECK) is 0) return; | 1018 if ((parent.style & DWT.CHECK) is 0) return; |
1019 if (this.checked is checked) return; | 1019 if (this.checked is checked) return; |
1020 this.checked = checked; | 1020 this.checked = checked; |
1021 cached = true; | 1021 cached = true; |
1022 ((NSOutlineView)parent.view).reloadItem_(handle); | 1022 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1023 } | 1023 } |
1024 | 1024 |
1025 /** | 1025 /** |
1026 * Sets the expanded state of the receiver. | 1026 * Sets the expanded state of the receiver. |
1027 * <p> | 1027 * <p> |
1036 public void setExpanded (bool expanded) { | 1036 public void setExpanded (bool expanded) { |
1037 checkWidget (); | 1037 checkWidget (); |
1038 if (expanded is getExpanded ()) return; | 1038 if (expanded is getExpanded ()) return; |
1039 parent.ignoreExpand = true; | 1039 parent.ignoreExpand = true; |
1040 if (expanded) { | 1040 if (expanded) { |
1041 ((NSOutlineView)parent.view).expandItem_(handle); | 1041 (cast(NSOutlineView)parent.view).expandItem_(handle); |
1042 } else { | 1042 } else { |
1043 ((NSOutlineView)parent.view).collapseItem_(handle); | 1043 (cast(NSOutlineView)parent.view).collapseItem_(handle); |
1044 } | 1044 } |
1045 parent.ignoreExpand = false; | 1045 parent.ignoreExpand = false; |
1046 cached = true; | 1046 cached = true; |
1047 // if (expanded) { | 1047 // if (expanded) { |
1048 // parent.setScrollWidth (false, childIds, false); | 1048 // parent.setScrollWidth (false, childIds, false); |
1077 Font oldFont = this.font; | 1077 Font oldFont = this.font; |
1078 if (oldFont is font) return; | 1078 if (oldFont is font) return; |
1079 this.font = font; | 1079 this.font = font; |
1080 if (oldFont !is null && oldFont.equals (font)) return; | 1080 if (oldFont !is null && oldFont.equals (font)) return; |
1081 cached = true; | 1081 cached = true; |
1082 ((NSOutlineView)parent.view).reloadItem_(handle); | 1082 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1083 } | 1083 } |
1084 | 1084 |
1085 /** | 1085 /** |
1086 * Sets the font that the receiver will use to paint textual information | 1086 * Sets the font that the receiver will use to paint textual information |
1087 * for the specified cell in this item to the font specified by the | 1087 * for the specified cell in this item to the font specified by the |
1115 Font oldFont = this.font; | 1115 Font oldFont = this.font; |
1116 if (oldFont is font) return; | 1116 if (oldFont is font) return; |
1117 cellFont [index] = font; | 1117 cellFont [index] = font; |
1118 if (oldFont !is null && oldFont.equals (font)) return; | 1118 if (oldFont !is null && oldFont.equals (font)) return; |
1119 cached = true; | 1119 cached = true; |
1120 ((NSOutlineView)parent.view).reloadItem_(handle); | 1120 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1121 } | 1121 } |
1122 | 1122 |
1123 /** | 1123 /** |
1124 * Sets the receiver's foreground color to the color specified | 1124 * Sets the receiver's foreground color to the color specified |
1125 * by the argument, or to the default system color for the item | 1125 * by the argument, or to the default system color for the item |
1148 Color oldColor = foreground; | 1148 Color oldColor = foreground; |
1149 if (oldColor is color) return; | 1149 if (oldColor is color) return; |
1150 foreground = color; | 1150 foreground = color; |
1151 if (oldColor !is null && oldColor.equals (color)) return; | 1151 if (oldColor !is null && oldColor.equals (color)) return; |
1152 cached = true; | 1152 cached = true; |
1153 ((NSOutlineView)parent.view).reloadItem_(handle); | 1153 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1154 } | 1154 } |
1155 | 1155 |
1156 /** | 1156 /** |
1157 * Sets the foreground color at the given column index in the receiver | 1157 * Sets the foreground color at the given column index in the receiver |
1158 * to the color specified by the argument, or to the default system color for the item | 1158 * to the color specified by the argument, or to the default system color for the item |
1186 Color oldColor = cellForeground [index]; | 1186 Color oldColor = cellForeground [index]; |
1187 if (oldColor is color) return; | 1187 if (oldColor is color) return; |
1188 cellForeground [index] = color; | 1188 cellForeground [index] = color; |
1189 if (oldColor !is null && oldColor.equals (color)) return; | 1189 if (oldColor !is null && oldColor.equals (color)) return; |
1190 cached = true; | 1190 cached = true; |
1191 ((NSOutlineView)parent.view).reloadItem_(handle); | 1191 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1192 } | 1192 } |
1193 | 1193 |
1194 /** | 1194 /** |
1195 * Sets the grayed state of the checkbox for this item. This state change | 1195 * Sets the grayed state of the checkbox for this item. This state change |
1196 * only applies if the Tree was created with the DWT.CHECK style. | 1196 * only applies if the Tree was created with the DWT.CHECK style. |
1206 checkWidget (); | 1206 checkWidget (); |
1207 if ((parent.style & DWT.CHECK) is 0) return; | 1207 if ((parent.style & DWT.CHECK) is 0) return; |
1208 if (this.grayed is grayed) return; | 1208 if (this.grayed is grayed) return; |
1209 this.grayed = grayed; | 1209 this.grayed = grayed; |
1210 cached = true; | 1210 cached = true; |
1211 ((NSOutlineView)parent.view).reloadItem_(handle); | 1211 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1212 } | 1212 } |
1213 | 1213 |
1214 /** | 1214 /** |
1215 * Sets the image for multiple columns in the tree. | 1215 * Sets the image for multiple columns in the tree. |
1216 * | 1216 * |
1274 } | 1274 } |
1275 images [index] = image; | 1275 images [index] = image; |
1276 } | 1276 } |
1277 // cached = true; | 1277 // cached = true; |
1278 // if (index is 0) parent.setScrollWidth (this); | 1278 // if (index is 0) parent.setScrollWidth (this); |
1279 ((NSOutlineView)parent.view).reloadItem_(handle); | 1279 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1280 } | 1280 } |
1281 | 1281 |
1282 public void setImage (Image image) { | 1282 public void setImage (Image image) { |
1283 checkWidget (); | 1283 checkWidget (); |
1284 setImage (0, image); | 1284 setImage (0, image); |
1356 if (string.equals (strings [index])) return; | 1356 if (string.equals (strings [index])) return; |
1357 strings [index] = string; | 1357 strings [index] = string; |
1358 } | 1358 } |
1359 cached = true; | 1359 cached = true; |
1360 if (index is 0) parent.setScrollWidth (this); | 1360 if (index is 0) parent.setScrollWidth (this); |
1361 ((NSOutlineView)parent.view).reloadItem_(handle); | 1361 (cast(NSOutlineView)parent.view).reloadItem_(handle); |
1362 } | 1362 } |
1363 | 1363 |
1364 public void setText (String string) { | 1364 public void setText (String string) { |
1365 checkWidget (); | 1365 checkWidget (); |
1366 setText (0, string); | 1366 setText (0, string); |