Changeset 213:36f5cb12e1a2 for dwt/custom/TableCursor.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/custom/TableCursor.d (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/custom/TableCursor.d
r212 r213 161 161 Listener tableListener, resizeListener, disposeItemListener, disposeColumnListener; 162 162 163 Color background = null; 164 Color foreground = null; 165 163 166 // By default, invert the list selection colors 164 167 static final int BACKGROUND = DWT.COLOR_LIST_SELECTION_TEXT; … … 254 257 disposeItemListener = new class() Listener { 255 258 public void handleEvent(Event event) { 259 unhookRowColumnListeners(); 256 260 row = null; 257 261 column = null; … … 261 265 disposeColumnListener = new class() Listener { 262 266 public void handleEvent(Event event) { 267 unhookRowColumnListeners(); 263 268 row = null; 264 269 column = null; … … 320 325 table.removeListener(DWT.FocusIn, tableListener); 321 326 table.removeListener(DWT.MouseDown, tableListener); 322 if (column !is null) { 323 column.removeListener(DWT.Dispose, disposeColumnListener); 324 column.removeListener(DWT.Move, resizeListener); 325 column.removeListener(DWT.Resize, resizeListener); 326 column = null; 327 } 328 if (row !is null) { 329 row.removeListener(DWT.Dispose, disposeItemListener); 330 row = null; 331 } 327 unhookRowColumnListeners(); 332 328 ScrollBar hBar = table.getHorizontalBar(); 333 329 if (hBar !is null) { … … 493 489 494 490 void tableFocusIn(Event event) { 495 if (isDisposed()) 496 return;497 if (isVisible())491 if (isDisposed()) return; 492 if (isVisible()) { 493 if (row is null && column is null) return; 498 494 setFocus(); 495 } 499 496 } 500 497 … … 523 520 TableColumn newColumn = null; 524 521 int columnCount = table.getColumnCount(); 525 if (columnCount > 0) { 522 if (columnCount is 0) { 523 if ((table.getStyle() & DWT.FULL_SELECTION) is 0) { 524 Rectangle rect = item.getBounds(0); 525 rect.width += lineWidth; 526 rect.height += lineWidth; 527 if (!rect.contains(pt)) return; 528 } 529 } else { 526 530 for (int i = 0; i < columnCount; i++) { 527 531 Rectangle rect = item.getBounds(i); … … 534 538 } 535 539 if (newColumn is null) { 540 if ((table.getStyle() & DWT.FULL_SELECTION) is 0) return; 536 541 newColumn = table.getColumn(0); 537 542 } … … 639 644 } 640 645 /** 646 * Returns the background color that the receiver will use to draw. 647 * 648 * @return the receiver's background color 649 */ 650 public Color getBackground() { 651 checkWidget(); 652 if (background is null) { 653 return getDisplay().getSystemColor(BACKGROUND); 654 } 655 return background; 656 } 657 /** 658 * Returns the foreground color that the receiver will use to draw. 659 * 660 * @return the receiver's foreground color 661 */ 662 public Color getForeground() { 663 checkWidget(); 664 if (foreground is null) { 665 return getDisplay().getSystemColor(FOREGROUND); 666 } 667 return foreground; 668 } 669 /** 641 670 * Returns the row over which the TableCursor is positioned. 642 671 * … … 652 681 return row; 653 682 } 683 /** 684 * Sets the receiver's background color to the color specified 685 * by the argument, or to the default system color for the control 686 * if the argument is null. 687 * <p> 688 * Note: This operation is a hint and may be overridden by the platform. 689 * For example, on Windows the background of a Button cannot be changed. 690 * </p> 691 * @param color the new color (or null) 692 * 693 * @exception IllegalArgumentException <ul> 694 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 695 * </ul> 696 * @exception DWTException <ul> 697 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 698 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 699 * </ul> 700 */ 654 701 public override void setBackground (Color color) { 655 if (color is null) color = getDisplay().getSystemColor(BACKGROUND);656 super.setBackground( color);702 background = color; 703 super.setBackground(getBackground()); 657 704 redraw(); 658 705 } 706 /** 707 * Sets the receiver's foreground color to the color specified 708 * by the argument, or to the default system color for the control 709 * if the argument is null. 710 * <p> 711 * Note: This operation is a hint and may be overridden by the platform. 712 * </p> 713 * @param color the new color (or null) 714 * 715 * @exception IllegalArgumentException <ul> 716 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> 717 * </ul> 718 * @exception DWTException <ul> 719 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 720 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 721 * </ul> 722 */ 659 723 public override void setForeground (Color color) { 660 if (color is null) color = getDisplay().getSystemColor(FOREGROUND);661 super.setForeground( color);724 foreground = color; 725 super.setForeground(getForeground()); 662 726 redraw(); 663 727 } … … 708 772 setRowColumn(table.indexOf(row), column, false); 709 773 } 710 } 774 void unhookRowColumnListeners() { 775 if (column !is null) { 776 column.removeListener(DWT.Dispose, disposeColumnListener); 777 column.removeListener(DWT.Move, resizeListener); 778 column.removeListener(DWT.Resize, resizeListener); 779 column = null; 780 } 781 if (row !is null) { 782 row.removeListener(DWT.Dispose, disposeItemListener); 783 row = null; 784 } 785 } 786 }
