Mercurial > projects > dwt-mac
comparison dwt/widgets/TableItem.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 |
---|---|
151 // event.width = width; | 151 // event.width = width; |
152 // event.height = height[0]; | 152 // event.height = height[0]; |
153 // parent.sendEvent (DWT.MeasureItem, event); | 153 // parent.sendEvent (DWT.MeasureItem, event); |
154 // if (parent.itemHeight < event.height) { | 154 // if (parent.itemHeight < event.height) { |
155 // parent.itemHeight = event.height; | 155 // parent.itemHeight = event.height; |
156 // OS.SetDataBrowserTableViewRowHeight (parent.handle, (short) event.height); | 156 // OS.SetDataBrowserTableViewRowHeight (parent.handle, cast(short) event.height); |
157 // } | 157 // } |
158 // width = event.width; | 158 // width = event.width; |
159 // } | 159 // } |
160 if (index is 0) this.width = width; | 160 if (index is 0) this.width = width; |
161 return width; | 161 return width; |
202 String text = getText (index); | 202 String text = getText (index); |
203 int length = text.length(); | 203 int length = text.length(); |
204 char[] chars = new char[length]; | 204 char[] chars = new char[length]; |
205 text.getChars(0, length, chars, 0); | 205 text.getChars(0, length, chars, 0); |
206 NSString str = NSString.stringWithCharacters(chars, length); | 206 NSString str = NSString.stringWithCharacters(chars, length); |
207 NSAttributedString attribStr = ((NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); | 207 NSAttributedString attribStr = (cast(NSAttributedString)new NSAttributedString().alloc()).initWithString_attributes_(str, dict); |
208 attribStr.autorelease(); | 208 attribStr.autorelease(); |
209 return attribStr; | 209 return attribStr; |
210 } | 210 } |
211 | 211 |
212 void destroyWidget () { | 212 void destroyWidget () { |
268 * @since 3.2 | 268 * @since 3.2 |
269 */ | 269 */ |
270 public Rectangle getBounds () { | 270 public Rectangle getBounds () { |
271 checkWidget (); | 271 checkWidget (); |
272 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 272 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
273 NSTableView tableView = (NSTableView) parent.view; | 273 NSTableView tableView = cast(NSTableView) parent.view; |
274 NSRect rect = tableView.rectOfRow (parent.indexOf (this)); | 274 NSRect rect = tableView.rectOfRow (parent.indexOf (this)); |
275 rect = tableView.convertRect_toView_ (rect, parent.scrollView); | 275 rect = tableView.convertRect_toView_ (rect, parent.scrollView); |
276 Rectangle result = new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); | 276 Rectangle result = new Rectangle(cast(int) rect.x, cast(int) rect.y, cast(int) rect.width, cast(int) rect.height); |
277 return result; | 277 return result; |
278 } | 278 } |
279 | 279 |
280 /** | 280 /** |
281 * Returns a rectangle describing the receiver's size and location | 281 * Returns a rectangle describing the receiver's size and location |
290 * </ul> | 290 * </ul> |
291 */ | 291 */ |
292 public Rectangle getBounds (int index) { | 292 public Rectangle getBounds (int index) { |
293 checkWidget (); | 293 checkWidget (); |
294 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 294 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
295 NSTableView tableView = (NSTableView) parent.view; | 295 NSTableView tableView = cast(NSTableView) parent.view; |
296 if ((parent.style & DWT.CHECK) !is 0) index ++; | 296 if ((parent.style & DWT.CHECK) !is 0) index ++; |
297 NSRect rect = tableView.frameOfCellAtColumn (index, parent.indexOf (this)); | 297 NSRect rect = tableView.frameOfCellAtColumn (index, parent.indexOf (this)); |
298 rect = tableView.convertRect_toView_ (rect, parent.scrollView); | 298 rect = tableView.convertRect_toView_ (rect, parent.scrollView); |
299 Rectangle result = new Rectangle((int) rect.x, (int) rect.y, (int) rect.width, (int) rect.height); | 299 Rectangle result = new Rectangle(cast(int) rect.x, cast(int) rect.y, cast(int) rect.width, cast(int) rect.height); |
300 return result; | 300 return result; |
301 } | 301 } |
302 | 302 |
303 /** | 303 /** |
304 * Returns <code>true</code> if the receiver is checked, | 304 * Returns <code>true</code> if the receiver is checked, |
617 return null; | 617 return null; |
618 } | 618 } |
619 | 619 |
620 void redraw () { | 620 void redraw () { |
621 // 0[aTableView setNeedsDisplayInRect:[aTableView rectOfRow:row]]; | 621 // 0[aTableView setNeedsDisplayInRect:[aTableView rectOfRow:row]]; |
622 ((NSTableView)parent.view).reloadData(); | 622 (cast(NSTableView)parent.view).reloadData(); |
623 ((NSTableView)parent.view).tile(); | 623 (cast(NSTableView)parent.view).tile(); |
624 } | 624 } |
625 | 625 |
626 void releaseHandle () { | 626 void releaseHandle () { |
627 super.releaseHandle (); | 627 super.releaseHandle (); |
628 parent = null; | 628 parent = null; |
668 Color oldColor = background; | 668 Color oldColor = background; |
669 if (oldColor is color) return; | 669 if (oldColor is color) return; |
670 background = color; | 670 background = color; |
671 if (oldColor !is null && oldColor.equals (color)) return; | 671 if (oldColor !is null && oldColor.equals (color)) return; |
672 cached = true; | 672 cached = true; |
673 NSTableView view = (NSTableView)parent.view; | 673 NSTableView view = cast(NSTableView)parent.view; |
674 NSRect rect = view.rectOfRow(parent.indexOf(this)); | 674 NSRect rect = view.rectOfRow(parent.indexOf(this)); |
675 view.setNeedsDisplayInRect(rect); | 675 view.setNeedsDisplayInRect(rect); |
676 } | 676 } |
677 | 677 |
678 /** | 678 /** |
707 Color oldColor = cellBackground [index]; | 707 Color oldColor = cellBackground [index]; |
708 if (oldColor is color) return; | 708 if (oldColor is color) return; |
709 cellBackground [index] = color; | 709 cellBackground [index] = color; |
710 if (oldColor !is null && oldColor.equals (color)) return; | 710 if (oldColor !is null && oldColor.equals (color)) return; |
711 cached = true; | 711 cached = true; |
712 NSTableView view = (NSTableView)parent.view; | 712 NSTableView view = cast(NSTableView)parent.view; |
713 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); | 713 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); |
714 view.setNeedsDisplayInRect(rect); | 714 view.setNeedsDisplayInRect(rect); |
715 } | 715 } |
716 | 716 |
717 /** | 717 /** |
729 checkWidget (); | 729 checkWidget (); |
730 if ((parent.style & DWT.CHECK) is 0) return; | 730 if ((parent.style & DWT.CHECK) is 0) return; |
731 if (this.checked is checked) return; | 731 if (this.checked is checked) return; |
732 this.checked = checked; | 732 this.checked = checked; |
733 cached = true; | 733 cached = true; |
734 NSTableView view = (NSTableView)parent.view; | 734 NSTableView view = cast(NSTableView)parent.view; |
735 NSRect rect = view.rectOfRow(parent.indexOf(this)); | 735 NSRect rect = view.rectOfRow(parent.indexOf(this)); |
736 view.setNeedsDisplayInRect(rect); | 736 view.setNeedsDisplayInRect(rect); |
737 } | 737 } |
738 | 738 |
739 /** | 739 /** |
761 Font oldFont = this.font; | 761 Font oldFont = this.font; |
762 if (oldFont is font) return; | 762 if (oldFont is font) return; |
763 this.font = font; | 763 this.font = font; |
764 if (oldFont !is null && oldFont.equals (font)) return; | 764 if (oldFont !is null && oldFont.equals (font)) return; |
765 cached = true; | 765 cached = true; |
766 NSTableView view = (NSTableView)parent.view; | 766 NSTableView view = cast(NSTableView)parent.view; |
767 NSRect rect = view.rectOfRow(parent.indexOf(this)); | 767 NSRect rect = view.rectOfRow(parent.indexOf(this)); |
768 view.setNeedsDisplayInRect(rect); | 768 view.setNeedsDisplayInRect(rect); |
769 } | 769 } |
770 | 770 |
771 /** | 771 /** |
801 Font oldFont = cellFont [index]; | 801 Font oldFont = cellFont [index]; |
802 if (oldFont is font) return; | 802 if (oldFont is font) return; |
803 cellFont [index] = font; | 803 cellFont [index] = font; |
804 if (oldFont !is null && oldFont.equals (font)) return; | 804 if (oldFont !is null && oldFont.equals (font)) return; |
805 cached = true; | 805 cached = true; |
806 NSTableView view = (NSTableView)parent.view; | 806 NSTableView view = cast(NSTableView)parent.view; |
807 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); | 807 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); |
808 view.setNeedsDisplayInRect(rect); | 808 view.setNeedsDisplayInRect(rect); |
809 } | 809 } |
810 | 810 |
811 /** | 811 /** |
833 Color oldColor = foreground; | 833 Color oldColor = foreground; |
834 if (oldColor is color) return; | 834 if (oldColor is color) return; |
835 foreground = color; | 835 foreground = color; |
836 if (oldColor !is null && oldColor.equals (color)) return; | 836 if (oldColor !is null && oldColor.equals (color)) return; |
837 cached = true; | 837 cached = true; |
838 NSTableView view = (NSTableView)parent.view; | 838 NSTableView view = cast(NSTableView)parent.view; |
839 NSRect rect = view.rectOfRow(parent.indexOf(this)); | 839 NSRect rect = view.rectOfRow(parent.indexOf(this)); |
840 view.setNeedsDisplayInRect(rect); | 840 view.setNeedsDisplayInRect(rect); |
841 } | 841 } |
842 | 842 |
843 /** | 843 /** |
872 Color oldColor = cellForeground [index]; | 872 Color oldColor = cellForeground [index]; |
873 if (oldColor is color) return; | 873 if (oldColor is color) return; |
874 cellForeground [index] = color; | 874 cellForeground [index] = color; |
875 if (oldColor !is null && oldColor.equals (color)) return; | 875 if (oldColor !is null && oldColor.equals (color)) return; |
876 cached = true; | 876 cached = true; |
877 NSTableView view = (NSTableView)parent.view; | 877 NSTableView view = cast(NSTableView)parent.view; |
878 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); | 878 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); |
879 view.setNeedsDisplayInRect(rect); | 879 view.setNeedsDisplayInRect(rect); |
880 } | 880 } |
881 | 881 |
882 /** | 882 /** |
894 checkWidget (); | 894 checkWidget (); |
895 if ((parent.style & DWT.CHECK) is 0) return; | 895 if ((parent.style & DWT.CHECK) is 0) return; |
896 if (this.grayed is grayed) return; | 896 if (this.grayed is grayed) return; |
897 this.grayed = grayed; | 897 this.grayed = grayed; |
898 cached = true; | 898 cached = true; |
899 NSTableView view = (NSTableView)parent.view; | 899 NSTableView view = cast(NSTableView)parent.view; |
900 NSRect rect = view.rectOfRow(parent.indexOf(this)); | 900 NSRect rect = view.rectOfRow(parent.indexOf(this)); |
901 view.setNeedsDisplayInRect(rect); | 901 view.setNeedsDisplayInRect(rect); |
902 } | 902 } |
903 | 903 |
904 /** | 904 /** |
962 } | 962 } |
963 images [index] = image; | 963 images [index] = image; |
964 } | 964 } |
965 // cached = true; | 965 // cached = true; |
966 // if (index is 0) parent.setScrollWidth (this); | 966 // if (index is 0) parent.setScrollWidth (this); |
967 NSTableView view = (NSTableView)parent.view; | 967 NSTableView view = cast(NSTableView)parent.view; |
968 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); | 968 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); |
969 view.setNeedsDisplayInRect(rect); | 969 view.setNeedsDisplayInRect(rect); |
970 } | 970 } |
971 | 971 |
972 public void setImage (Image image) { | 972 public void setImage (Image image) { |
1044 if (string.equals (strings [index])) return; | 1044 if (string.equals (strings [index])) return; |
1045 strings [index] = string; | 1045 strings [index] = string; |
1046 } | 1046 } |
1047 cached = true; | 1047 cached = true; |
1048 if (index is 0) parent.setScrollWidth (this); | 1048 if (index is 0) parent.setScrollWidth (this); |
1049 NSTableView view = (NSTableView)parent.view; | 1049 NSTableView view = cast(NSTableView)parent.view; |
1050 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); | 1050 NSRect rect = view.frameOfCellAtColumn(index + ((parent.style & DWT.CHECK) !is 0 ? 1 : 0), parent.indexOf(this)); |
1051 view.setNeedsDisplayInRect(rect); | 1051 view.setNeedsDisplayInRect(rect); |
1052 } | 1052 } |
1053 | 1053 |
1054 public void setText (String string) { | 1054 public void setText (String string) { |