Mercurial > projects > dwt-mac
comparison dwt/custom/TableTreeItem.d @ 41:6337764516f1
Sync dwt/custom with dwt-linux (took copy of complete folder)
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 07 Oct 2008 16:29:55 +0200 |
parents | 1a8b3cb347e0 |
children |
comparison
equal
deleted
inserted
replaced
40:fbe68c33eeee | 41:6337764516f1 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
10 *******************************************************************************/ | 12 *******************************************************************************/ |
11 module dwt.custom; | 13 module dwt.custom.TableTreeItem; |
12 | 14 |
13 | 15 |
14 import dwt.*; | 16 |
15 import dwt.graphics.*; | 17 import dwt.DWT; |
16 import dwt.widgets.*; | 18 import dwt.DWTException; |
19 import dwt.graphics.Color; | |
20 import dwt.graphics.Font; | |
21 import dwt.graphics.GC; | |
22 import dwt.graphics.Image; | |
23 import dwt.graphics.Rectangle; | |
24 import dwt.widgets.Event; | |
25 import dwt.widgets.Item; | |
26 import dwt.widgets.Table; | |
27 import dwt.widgets.TableItem; | |
28 import dwt.widgets.Widget; | |
29 import dwt.custom.TableTree; | |
30 import dwt.dwthelper.utils; | |
31 | |
17 | 32 |
18 /** | 33 /** |
19 * A TableTreeItem is a selectable user interface object | 34 * A TableTreeItem is a selectable user interface object |
20 * that represents an item in a hierarchy of items in a | 35 * that represents an item in a hierarchy of items in a |
21 * TableTree. | 36 * TableTree. |
22 * | 37 * |
23 * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn | 38 * @deprecated As of 3.1 use Tree, TreeItem and TreeColumn |
24 */ | 39 */ |
25 public class TableTreeItem : Item { | 40 public class TableTreeItem : Item { |
26 TableItem tableItem; | 41 TableItem tableItem; |
27 TableTree parent; | 42 TableTree parent; |
28 TableTreeItem parentItem; | 43 TableTreeItem parentItem; |
29 TableTreeItem [] items = TableTree.EMPTY_ITEMS; | 44 TableTreeItem [] items; |
30 String[] texts = TableTree.EMPTY_TEXTS; | 45 String[] texts; |
31 Image[] images = TableTree.EMPTY_IMAGES; | 46 Image[] images; |
32 Color background; | 47 Color background; |
33 Color foreground; | 48 Color foreground; |
34 Font font; | 49 Font font; |
35 bool expanded; | 50 bool expanded; |
36 bool checked; | 51 bool checked; |
42 * and a style value describing its behavior and appearance. | 57 * and a style value describing its behavior and appearance. |
43 * The item is added to the end of the items maintained by its parent. | 58 * The item is added to the end of the items maintained by its parent. |
44 * <p> | 59 * <p> |
45 * The style value is either one of the style constants defined in | 60 * The style value is either one of the style constants defined in |
46 * class <code>DWT</code> which is applicable to instances of this | 61 * class <code>DWT</code> which is applicable to instances of this |
47 * class, or must be built by <em>bitwise OR</em>'ing together | 62 * class, or must be built by <em>bitwise OR</em>'ing together |
48 * (that is, using the <code>int</code> "|" operator) two or more | 63 * (that is, using the <code>int</code> "|" operator) two or more |
49 * of those <code>DWT</code> style constants. The class description | 64 * of those <code>DWT</code> style constants. The class description |
50 * lists the style constants that are applicable to the class. | 65 * lists the style constants that are applicable to the class. |
51 * Style bits are also inherited from superclasses. | 66 * Style bits are also inherited from superclasses. |
52 * </p> | 67 * </p> |
74 * a style value describing its behavior and appearance, and the index | 89 * a style value describing its behavior and appearance, and the index |
75 * at which to place it in the items maintained by its parent. | 90 * at which to place it in the items maintained by its parent. |
76 * <p> | 91 * <p> |
77 * The style value is either one of the style constants defined in | 92 * The style value is either one of the style constants defined in |
78 * class <code>DWT</code> which is applicable to instances of this | 93 * class <code>DWT</code> which is applicable to instances of this |
79 * class, or must be built by <em>bitwise OR</em>'ing together | 94 * class, or must be built by <em>bitwise OR</em>'ing together |
80 * (that is, using the <code>int</code> "|" operator) two or more | 95 * (that is, using the <code>int</code> "|" operator) two or more |
81 * of those <code>DWT</code> style constants. The class description | 96 * of those <code>DWT</code> style constants. The class description |
82 * lists the style constants that are applicable to the class. | 97 * lists the style constants that are applicable to the class. |
83 * Style bits are also inherited from superclasses. | 98 * Style bits are also inherited from superclasses. |
84 * </p> | 99 * </p> |
107 * and a style value describing its behavior and appearance. | 122 * and a style value describing its behavior and appearance. |
108 * The item is added to the end of the items maintained by its parent. | 123 * The item is added to the end of the items maintained by its parent. |
109 * <p> | 124 * <p> |
110 * The style value is either one of the style constants defined in | 125 * The style value is either one of the style constants defined in |
111 * class <code>DWT</code> which is applicable to instances of this | 126 * class <code>DWT</code> which is applicable to instances of this |
112 * class, or must be built by <em>bitwise OR</em>'ing together | 127 * class, or must be built by <em>bitwise OR</em>'ing together |
113 * (that is, using the <code>int</code> "|" operator) two or more | 128 * (that is, using the <code>int</code> "|" operator) two or more |
114 * of those <code>DWT</code> style constants. The class description | 129 * of those <code>DWT</code> style constants. The class description |
115 * lists the style constants that are applicable to the class. | 130 * lists the style constants that are applicable to the class. |
116 * Style bits are also inherited from superclasses. | 131 * Style bits are also inherited from superclasses. |
117 * </p> | 132 * </p> |
139 * a style value describing its behavior and appearance, and the index | 154 * a style value describing its behavior and appearance, and the index |
140 * at which to place it in the items maintained by its parent. | 155 * at which to place it in the items maintained by its parent. |
141 * <p> | 156 * <p> |
142 * The style value is either one of the style constants defined in | 157 * The style value is either one of the style constants defined in |
143 * class <code>DWT</code> which is applicable to instances of this | 158 * class <code>DWT</code> which is applicable to instances of this |
144 * class, or must be built by <em>bitwise OR</em>'ing together | 159 * class, or must be built by <em>bitwise OR</em>'ing together |
145 * (that is, using the <code>int</code> "|" operator) two or more | 160 * (that is, using the <code>int</code> "|" operator) two or more |
146 * of those <code>DWT</code> style constants. The class description | 161 * of those <code>DWT</code> style constants. The class description |
147 * lists the style constants that are applicable to the class. | 162 * lists the style constants that are applicable to the class. |
148 * Style bits are also inherited from superclasses. | 163 * Style bits are also inherited from superclasses. |
149 * </p> | 164 * </p> |
165 public this(TableTreeItem parent, int style, int index) { | 180 public this(TableTreeItem parent, int style, int index) { |
166 this (parent.getParent(), parent, style, index); | 181 this (parent.getParent(), parent, style, index); |
167 } | 182 } |
168 | 183 |
169 this(TableTree parent, TableTreeItem parentItem, int style, int index) { | 184 this(TableTree parent, TableTreeItem parentItem, int style, int index) { |
185 | |
186 items = TableTree.EMPTY_ITEMS; | |
187 texts = TableTree.EMPTY_TEXTS; | |
188 images = TableTree.EMPTY_IMAGES; | |
189 | |
170 super(parent, style); | 190 super(parent, style); |
171 this.parent = parent; | 191 this.parent = parent; |
172 this.parentItem = parentItem; | 192 this.parentItem = parentItem; |
173 if (parentItem is null) { | 193 if (parentItem is null) { |
174 | 194 |
175 /* Root items are visible immediately */ | 195 /* Root items are visible immediately */ |
176 int tableIndex = parent.addItem(this, index); | 196 int tableIndex = parent.addItem(this, index); |
177 tableItem = new TableItem(parent.getTable(), style, tableIndex); | 197 tableItem = new TableItem(parent.getTable(), style, tableIndex); |
178 tableItem.setData(TableTree.ITEMID, this); | 198 tableItem.setData(TableTree.ITEMID, this); |
179 addCheck(); | 199 addCheck(); |
204 tableItem.setGrayed(grayed); | 224 tableItem.setGrayed(grayed); |
205 } | 225 } |
206 void addItem(TableTreeItem item, int index) { | 226 void addItem(TableTreeItem item, int index) { |
207 if (item is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); | 227 if (item is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
208 if (index < 0 || index > items.length) DWT.error(DWT.ERROR_INVALID_ARGUMENT); | 228 if (index < 0 || index > items.length) DWT.error(DWT.ERROR_INVALID_ARGUMENT); |
209 | 229 |
210 /* Now that item has a sub-node it must indicate that it can be expanded */ | 230 /* Now that item has a sub-node it must indicate that it can be expanded */ |
211 if (items.length is 0 && index is 0) { | 231 if (items.length is 0 && index is 0) { |
212 if (tableItem !is null) { | 232 if (tableItem !is null) { |
213 Image image = expanded ? parent.getMinusImage() : parent.getPlusImage(); | 233 Image image = expanded ? parent.getMinusImage() : parent.getPlusImage(); |
214 tableItem.setImage(0, image); | 234 tableItem.setImage(0, image); |
215 } | 235 } |
216 } | 236 } |
217 | 237 |
218 /* Put the item in the items list */ | 238 /* Put the item in the items list */ |
219 TableTreeItem[] newItems = new TableTreeItem[items.length + 1]; | 239 TableTreeItem[] newItems = new TableTreeItem[items.length + 1]; |
220 System.arraycopy(items, 0, newItems, 0, index); | 240 System.arraycopy(items, 0, newItems, 0, index); |
221 newItems[index] = item; | 241 newItems[index] = item; |
222 System.arraycopy(items, index, newItems, index + 1, items.length - index); | 242 System.arraycopy(items, index, newItems, index + 1, items.length - index); |
226 | 246 |
227 /** | 247 /** |
228 * Returns the receiver's background color. | 248 * Returns the receiver's background color. |
229 * | 249 * |
230 * @return the background color | 250 * @return the background color |
231 * | 251 * |
232 * @exception DWTException <ul> | 252 * @exception DWTException <ul> |
233 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 253 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
234 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 254 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
235 * </ul> | 255 * </ul> |
236 * | 256 * |
237 * @since 2.0 | 257 * @since 2.0 |
238 * | 258 * |
239 */ | 259 */ |
240 public Color getBackground () { | 260 public Color getBackground () { |
241 checkWidget (); | 261 checkWidget (); |
242 return (background is null) ? parent.getBackground() : background; | 262 return (background is null) ? parent.getBackground() : background; |
243 } | 263 } |
288 * | 308 * |
289 * @exception DWTException <ul> | 309 * @exception DWTException <ul> |
290 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 310 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
291 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 311 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
292 * </ul> | 312 * </ul> |
293 * | 313 * |
294 * @since 2.1 | 314 * @since 2.1 |
295 */ | 315 */ |
296 public bool getGrayed () { | 316 public bool getGrayed () { |
297 checkWidget(); | 317 checkWidget(); |
298 if (tableItem is null) return grayed; | 318 if (tableItem is null) return grayed; |
334 * | 354 * |
335 * @exception DWTException <ul> | 355 * @exception DWTException <ul> |
336 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 356 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
337 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 357 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
338 * </ul> | 358 * </ul> |
339 * | 359 * |
340 * @since 2.0 | 360 * @since 2.0 |
341 * | 361 * |
342 */ | 362 */ |
343 public Color getForeground () { | 363 public Color getForeground () { |
344 checkWidget (); | 364 checkWidget (); |
345 return (foreground is null) ? parent.getForeground() : foreground; | 365 return (foreground is null) ? parent.getForeground() : foreground; |
346 } | 366 } |
349 * <p> | 369 * <p> |
350 * The image in column 0 is reserved for the [+] and [-] | 370 * The image in column 0 is reserved for the [+] and [-] |
351 * images of the tree, therefore getImage(0) will return null. | 371 * images of the tree, therefore getImage(0) will return null. |
352 * | 372 * |
353 * @return the image at index 0 | 373 * @return the image at index 0 |
354 * | 374 * |
355 * @exception DWTException <ul> | 375 * @exception DWTException <ul> |
356 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 376 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
357 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 377 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
358 * </ul> | 378 * </ul> |
359 */ | 379 */ |
360 public Image getImage () { | 380 public override Image getImage () { |
361 checkWidget(); | 381 checkWidget(); |
362 return getImage(0); | 382 return getImage(0); |
363 } | 383 } |
364 | 384 |
365 /** | 385 /** |
396 * </ul> | 416 * </ul> |
397 * @exception DWTException <ul> | 417 * @exception DWTException <ul> |
398 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 418 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
399 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 419 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
400 * </ul> | 420 * </ul> |
401 * | 421 * |
402 * @since 3.1 | 422 * @since 3.1 |
403 */ | 423 */ |
404 public TableTreeItem getItem (int index) { | 424 public TableTreeItem getItem (int index) { |
405 checkWidget(); | 425 checkWidget(); |
406 int count = items.length; | 426 int count = items.length; |
423 * Returns an array of <code>TableTreeItem</code>s which are the | 443 * Returns an array of <code>TableTreeItem</code>s which are the |
424 * direct item children of the receiver. | 444 * direct item children of the receiver. |
425 * <p> | 445 * <p> |
426 * Note: This is not the actual structure used by the receiver | 446 * Note: This is not the actual structure used by the receiver |
427 * to maintain its list of items, so modifying the array will | 447 * to maintain its list of items, so modifying the array will |
428 * not affect the receiver. | 448 * not affect the receiver. |
429 * </p> | 449 * </p> |
430 * | 450 * |
431 * @return the receiver's items | 451 * @return the receiver's items |
432 */ | 452 */ |
433 public TableTreeItem[] getItems () { | 453 public TableTreeItem[] getItems () { |
466 */ | 486 */ |
467 public TableTreeItem getParentItem () { | 487 public TableTreeItem getParentItem () { |
468 //checkWidget(); | 488 //checkWidget(); |
469 return parentItem; | 489 return parentItem; |
470 } | 490 } |
471 public String getText () { | 491 public override String getText () { |
472 checkWidget(); | 492 checkWidget(); |
473 return getText(0); | 493 return getText(0); |
474 } | 494 } |
475 | 495 |
476 /** | 496 /** |
495 return tableItem !is null; | 515 return tableItem !is null; |
496 } | 516 } |
497 | 517 |
498 /** | 518 /** |
499 * Gets the index of the specified item. | 519 * Gets the index of the specified item. |
500 * | 520 * |
501 * <p>The widget is searched starting at 0 until an | 521 * <p>The widget is searched starting at 0 until an |
502 * item is found that is equal to the search item. | 522 * item is found that is equal to the search item. |
503 * If no item is found, -1 is returned. Indexing | 523 * If no item is found, -1 is returned. Indexing |
504 * is zero based. This index is relative to the parent only. | 524 * is zero based. This index is relative to the parent only. |
505 * | 525 * |
506 * @param item the search item | 526 * @param item the search item |
507 * @return the index of the item or -1 if the item is not found | 527 * @return the index of the item or -1 if the item is not found |
508 * | 528 * |
509 */ | 529 */ |
510 public int indexOf (TableTreeItem item) { | 530 public int indexOf (TableTreeItem item) { |
511 //checkWidget(); | 531 //checkWidget(); |
512 for (int i = 0; i < items.length; i++) { | 532 for (int i = 0; i < items.length; i++) { |
513 if (items[i] is item) return i; | 533 if (items[i] is item) return i; |
514 } | 534 } |
515 return -1; | 535 return -1; |
516 } | 536 } |
527 } | 547 } |
528 for (int i = 0; i < items.length; i++) { | 548 for (int i = 0; i < items.length; i++) { |
529 items[i].expandAll(notify); | 549 items[i].expandAll(notify); |
530 } | 550 } |
531 } | 551 } |
532 int expandedIndexOf (TableTreeItem item) { | 552 int expandedIndexOf (TableTreeItem item) { |
533 int index = 0; | 553 int index = 0; |
534 for (int i = 0; i < items.length; i++) { | 554 for (int i = 0; i < items.length; i++) { |
535 if (items[i] is item) return index; | 555 if (items[i] is item) return index; |
536 if (items[i].expanded) index += items[i].visibleChildrenCount (); | 556 if (items[i].expanded) index += items[i].visibleChildrenCount (); |
537 index++; | 557 index++; |
547 } | 567 } |
548 } | 568 } |
549 return count; | 569 return count; |
550 } | 570 } |
551 | 571 |
552 public void dispose () { | 572 public override void dispose () { |
553 if (isDisposed()) return; | 573 if (isDisposed()) return; |
554 for (int i = items.length - 1; i >= 0; i--) { | 574 for (int i = items.length - 1; i >= 0; i--) { |
555 items[i].dispose(); | 575 items[i].dispose(); |
556 } | 576 } |
557 super.dispose(); | 577 super.dispose(); |
591 * Sets the receiver's background color to the color specified | 611 * Sets the receiver's background color to the color specified |
592 * by the argument, or to the default system color for the item | 612 * by the argument, or to the default system color for the item |
593 * if the argument is null. | 613 * if the argument is null. |
594 * | 614 * |
595 * @param color the new color (or null) | 615 * @param color the new color (or null) |
596 * | 616 * |
597 * @exception IllegalArgumentException <ul> | 617 * @exception IllegalArgumentException <ul> |
598 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> | 618 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> |
599 * </ul> | 619 * </ul> |
600 * @exception DWTException <ul> | 620 * @exception DWTException <ul> |
601 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 621 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
602 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 622 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
603 * </ul> | 623 * </ul> |
604 * | 624 * |
605 * @since 2.0 | 625 * @since 2.0 |
606 * | 626 * |
607 */ | 627 */ |
608 public void setBackground (Color color) { | 628 public void setBackground (Color color) { |
609 checkWidget (); | 629 checkWidget (); |
610 if (color !is null && color.isDisposed ()) { | 630 if (color !is null && color.isDisposed ()) { |
611 DWT.error (DWT.ERROR_INVALID_ARGUMENT); | 631 DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
615 } | 635 } |
616 background = color; | 636 background = color; |
617 } | 637 } |
618 | 638 |
619 /** | 639 /** |
620 * Sets the checked state of the checkbox for this item. This state change | 640 * Sets the checked state of the checkbox for this item. This state change |
621 * only applies if the Table was created with the DWT.CHECK style. | 641 * only applies if the Table was created with the DWT.CHECK style. |
622 * | 642 * |
623 * @param checked the new checked state of the checkbox | 643 * @param checked the new checked state of the checkbox |
624 * | 644 * |
625 * @exception DWTException <ul> | 645 * @exception DWTException <ul> |
636 } | 656 } |
637 this.checked = checked; | 657 this.checked = checked; |
638 } | 658 } |
639 | 659 |
640 /** | 660 /** |
641 * Sets the grayed state of the checkbox for this item. This state change | 661 * Sets the grayed state of the checkbox for this item. This state change |
642 * only applies if the Table was created with the DWT.CHECK style. | 662 * only applies if the Table was created with the DWT.CHECK style. |
643 * | 663 * |
644 * @param grayed the new grayed state of the checkbox; | 664 * @param grayed the new grayed state of the checkbox; |
645 * | 665 * |
646 * @exception DWTException <ul> | 666 * @exception DWTException <ul> |
647 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 667 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
648 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 668 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
649 * </ul> | 669 * </ul> |
650 * | 670 * |
651 * @since 2.1 | 671 * @since 2.1 |
652 */ | 672 */ |
653 public void setGrayed (bool grayed) { | 673 public void setGrayed (bool grayed) { |
654 checkWidget(); | 674 checkWidget(); |
655 Table table = parent.getTable(); | 675 Table table = parent.getTable(); |
691 * for that kind of control if the argument is null. | 711 * for that kind of control if the argument is null. |
692 * | 712 * |
693 * @param font the new font (or null) | 713 * @param font the new font (or null) |
694 * | 714 * |
695 * @exception IllegalArgumentException <ul> | 715 * @exception IllegalArgumentException <ul> |
696 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> | 716 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> |
697 * </ul> | 717 * </ul> |
698 * @exception DWTException <ul> | 718 * @exception DWTException <ul> |
699 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 719 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
700 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 720 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
701 * </ul> | 721 * </ul> |
702 * | 722 * |
703 * @since 3.0 | 723 * @since 3.0 |
704 */ | 724 */ |
705 public void setFont (Font font){ | 725 public void setFont (Font font){ |
706 checkWidget (); | 726 checkWidget (); |
707 if (font !is null && font.isDisposed ()) { | 727 if (font !is null && font.isDisposed ()) { |
718 * if the argument is null. | 738 * if the argument is null. |
719 * | 739 * |
720 * @param color the new color (or null) | 740 * @param color the new color (or null) |
721 * | 741 * |
722 * @since 2.0 | 742 * @since 2.0 |
723 * | 743 * |
724 * @exception IllegalArgumentException <ul> | 744 * @exception IllegalArgumentException <ul> |
725 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> | 745 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> |
726 * </ul> | 746 * </ul> |
727 * @exception DWTException <ul> | 747 * @exception DWTException <ul> |
728 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 748 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
729 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 749 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
730 * </ul> | 750 * </ul> |
731 * | 751 * |
732 * @since 2.0 | 752 * @since 2.0 |
733 * | 753 * |
734 */ | 754 */ |
735 public void setForeground (Color color) { | 755 public void setForeground (Color color) { |
736 checkWidget (); | 756 checkWidget (); |
737 if (color !is null && color.isDisposed ()) { | 757 if (color !is null && color.isDisposed ()) { |
738 DWT.error (DWT.ERROR_INVALID_ARGUMENT); | 758 DWT.error (DWT.ERROR_INVALID_ARGUMENT); |
776 * The image can be null. | 796 * The image can be null. |
777 * The image in column 0 is reserved for the [+] and [-] | 797 * The image in column 0 is reserved for the [+] and [-] |
778 * images of the tree, therefore do nothing. | 798 * images of the tree, therefore do nothing. |
779 * | 799 * |
780 * @param image the new image or null | 800 * @param image the new image or null |
781 * | 801 * |
782 * @exception DWTException <ul> | 802 * @exception DWTException <ul> |
783 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 803 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
784 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 804 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
785 * </ul> | 805 * </ul> |
786 */ | 806 */ |
787 public void setImage (Image image) { | 807 public override void setImage (Image image) { |
788 setImage(0, image); | 808 setImage(0, image); |
789 } | 809 } |
790 | 810 |
791 /** | 811 /** |
792 * Sets the widget text. | 812 * Sets the widget text. |
797 * number. | 817 * number. |
798 * | 818 * |
799 * @param index the column number | 819 * @param index the column number |
800 * @param text the new text | 820 * @param text the new text |
801 * | 821 * |
802 * @exception IllegalArgumentException <ul> | |
803 * <li>ERROR_NULL_ARGUMENT - if the text is null</li> | |
804 * </ul> | |
805 * @exception DWTException <ul> | 822 * @exception DWTException <ul> |
806 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> | 823 * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
807 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> | 824 * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li> |
808 * </ul> | 825 * </ul> |
809 */ | 826 */ |
810 public void setText(int index, String text) { | 827 public void setText(int index, String text) { |
811 checkWidget(); | 828 checkWidget(); |
812 if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | 829 // DWT extension: allow null for zero length string |
830 //if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); | |
813 int columnCount = Math.max(parent.getTable().getColumnCount(), 1); | 831 int columnCount = Math.max(parent.getTable().getColumnCount(), 1); |
814 if (index < 0 || index >= columnCount) return; | 832 if (index < 0 || index >= columnCount) return; |
815 if (texts.length < columnCount) { | 833 if (texts.length < columnCount) { |
816 String[] newTexts = new String[columnCount]; | 834 String[] newTexts = new String[columnCount]; |
817 System.arraycopy(texts, 0, newTexts, 0, texts.length); | 835 System.arraycopy(texts, 0, newTexts, 0, texts.length); |
818 texts = newTexts; | 836 texts = newTexts; |
819 } | 837 } |
820 texts[index] = text; | 838 texts[index] = text; |
821 if (tableItem !is null) tableItem.setText(index, text); | 839 if (tableItem !is null) tableItem.setText(index, text); |
822 } | 840 } |
823 public void setText (String String) { | 841 public override void setText (String string) { |
824 setText(0, String); | 842 setText(0, string); |
825 } | 843 } |
826 | 844 |
827 void setVisible (bool show) { | 845 void setVisible (bool show) { |
828 if (parentItem is null) return; // this is a root and can not be toggled between visible and hidden | 846 if (parentItem is null) return; // this is a root and can not be toggled between visible and hidden |
829 if (getVisible() is show) return; | 847 if (getVisible() is show) return; |
860 } | 878 } |
861 } else { | 879 } else { |
862 tableItem.setImage(0, parent.getPlusImage()); | 880 tableItem.setImage(0, parent.getPlusImage()); |
863 } | 881 } |
864 } | 882 } |
865 | 883 |
866 } else { | 884 } else { |
867 | 885 |
868 for (int i = 0, length = items.length; i < length; i++) { | 886 for (int i = 0, length = items.length; i < length; i++) { |
869 items[i].setVisible(false); | 887 items[i].setVisible(false); |
870 } | 888 } |