Changeset 213:36f5cb12e1a2 for dwt/custom/CTabItem.d
- Timestamp:
- 05/17/08 11:34:28 (8 months ago)
- Files:
-
- dwt/custom/CTabItem.d (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
dwt/custom/CTabItem.d
r212 r213 24 24 import dwt.graphics.RGB; 25 25 import dwt.graphics.Rectangle; 26 import dwt.graphics.TextLayout; 26 27 import dwt.widgets.Control; 27 28 import dwt.widgets.Display; … … 135 136 public this (CTabFolder parent, int style, int index) { 136 137 closeRect = new Rectangle(0, 0, 0, 0); 137 super (parent, checkStyle(style));138 super (parent, style); 138 139 showClose = (style & DWT.CLOSE) !is 0; 139 140 parent.createItem (this, index); 140 }141 static int checkStyle(int style) {142 return DWT.NONE;143 141 } 144 142 … … 160 158 int ellipseWidth = gc.textExtent(ellipses, FLAGS).x; 161 159 int length = text.length; 162 int end = length - 1; 160 TextLayout layout = new TextLayout(getDisplay()); 161 layout.setText(text); 162 int end = layout.getPreviousOffset(length, DWT.MOVEMENT_CLUSTER); 163 163 while (end > 0) { 164 164 text = text[ 0 .. end ]; 165 165 int l = gc.textExtent(text, FLAGS).x; 166 166 if (l + ellipseWidth <= width) { 167 return text ~ ellipses; 168 } 169 end--; 170 } 171 return text[ 0 .. 1 ]; 167 break; 168 } 169 end = layout.getPreviousOffset(end, DWT.MOVEMENT_CLUSTER); 170 } 171 layout.dispose(); 172 return end is 0 ? text.substring(0, 1) : text ~ ellipses; 172 173 } 173 174 … … 768 769 } 769 770 /** 771 * Returns <code>true</code> to indicate that the receiver's close button should be shown. 772 * Otherwise return <code>false</code>. The initial value is defined by the style (DWT.CLOSE) 773 * that was used to create the receiver. 774 * 775 * @return <code>true</code> if the close button should be shown 776 * 777 * @exception DWTException <ul> 778 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 779 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 780 * </ul> 781 * 782 * @since 3.4 783 */ 784 public bool getShowClose() { 785 checkWidget(); 786 return showClose; 787 } 788 /** 770 789 * Returns the receiver's tool tip text, or null if it has 771 790 * not been set. … … 998 1017 } 999 1018 } 1019 /** 1020 * Sets to <code>true</code> to indicate that the receiver's close button should be shown. 1021 * If the parent (CTabFolder) was created with DWT.CLOSE style, changing this value has 1022 * no effect. 1023 * 1024 * @param close the new state of the close button 1025 * 1026 * @exception DWTException <ul> 1027 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 1028 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1029 * </ul> 1030 * 1031 * @since 3.4 1032 */ 1033 public void setShowClose(bool close) { 1034 checkWidget(); 1035 if (showClose is close) return; 1036 showClose = close; 1037 parent.updateItems(); 1038 parent.redrawTabs(); 1039 } 1000 1040 public override void setText (String string) { 1001 1041 checkWidget(); … … 1025 1065 toolTipText = string; 1026 1066 } 1027 } 1067 1068 }
