Mercurial > projects > dwt2
annotate org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/CTabItem.d @ 49:7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 12:59:54 +0100 |
parents | f713da8bc051 |
children | c01d033c633a |
rev | line source |
---|---|
25 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.custom.CTabItem; | |
14 | |
15 import java.lang.all; | |
16 | |
17 | |
18 | |
19 import org.eclipse.swt.SWT; | |
20 import org.eclipse.swt.SWTException; | |
21 import org.eclipse.swt.graphics.Color; | |
22 import org.eclipse.swt.graphics.Font; | |
23 import org.eclipse.swt.graphics.GC; | |
24 import org.eclipse.swt.graphics.Image; | |
25 import org.eclipse.swt.graphics.Point; | |
26 import org.eclipse.swt.graphics.RGB; | |
27 import org.eclipse.swt.graphics.Rectangle; | |
28 import org.eclipse.swt.graphics.TextLayout; | |
29 import org.eclipse.swt.widgets.Control; | |
30 import org.eclipse.swt.widgets.Display; | |
31 import org.eclipse.swt.widgets.Item; | |
32 import org.eclipse.swt.widgets.Widget; | |
33 import org.eclipse.swt.custom.CTabFolder; | |
34 | |
35 /** | |
36 * Instances of this class represent a selectable user interface object | |
37 * that represent a page in a notebook widget. | |
38 * | |
39 * <dl> | |
40 * <dt><b>Styles:</b></dt> | |
41 * <dd>SWT.CLOSE</dd> | |
42 * <dt><b>Events:</b></dt> | |
43 * <dd>(none)</dd> | |
44 * </dl> | |
45 * <p> | |
46 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | |
47 * </p> | |
48 * | |
49 * @see <a href="http://www.eclipse.org/swt/snippets/#ctabfolder">CTabFolder, CTabItem snippets</a> | |
50 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
51 */ | |
52 public class CTabItem : Item { | |
53 CTabFolder parent; | |
54 int x,y,width,height = 0; | |
55 Control control; // the tab page | |
56 | |
57 String toolTipText; | |
58 String shortenedText; | |
59 int shortenedTextWidth; | |
60 | |
61 // Appearance | |
62 Font font; | |
63 Image disabledImage; | |
64 | |
65 Rectangle closeRect; | |
66 int closeImageState = CTabFolder.NONE; | |
67 bool showClose = false; | |
68 bool showing = false; | |
69 | |
70 // internal constants | |
49
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
71 static const int TOP_MARGIN = 2; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
72 static const int BOTTOM_MARGIN = 2; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
73 static const int LEFT_MARGIN = 4; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
74 static const int RIGHT_MARGIN = 4; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
75 static const int INTERNAL_SPACING = 4; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
76 static const int FLAGS = SWT.DRAW_TRANSPARENT | SWT.DRAW_MNEMONIC; |
7a2dd761a8b2
more work until dmd 2.026 linux segfaults.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
77 static const String ELLIPSIS = "..."; //$NON-NLS-1$ // could use the ellipsis glyph on some platforms "\u2026" |
25 | 78 |
79 /** | |
80 * Constructs a new instance of this class given its parent | |
81 * (which must be a <code>CTabFolder</code>) and a style value | |
82 * describing its behavior and appearance. The item is added | |
83 * to the end of the items maintained by its parent. | |
84 * <p> | |
85 * The style value is either one of the style constants defined in | |
86 * class <code>SWT</code> which is applicable to instances of this | |
87 * class, or must be built by <em>bitwise OR</em>'ing together | |
88 * (that is, using the <code>int</code> "|" operator) two or more | |
89 * of those <code>SWT</code> style constants. The class description | |
90 * lists the style constants that are applicable to the class. | |
91 * Style bits are also inherited from superclasses. | |
92 * </p> | |
93 * | |
94 * @param parent a CTabFolder which will be the parent of the new instance (cannot be null) | |
95 * @param style the style of control to construct | |
96 * | |
97 * @exception IllegalArgumentException <ul> | |
98 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
99 * </ul> | |
100 * @exception SWTException <ul> | |
101 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
102 * </ul> | |
103 * | |
104 * @see SWT | |
105 * @see Widget#getStyle() | |
106 */ | |
107 public this (CTabFolder parent, int style) { | |
108 this(parent, style, parent.getItemCount()); | |
109 } | |
110 /** | |
111 * Constructs a new instance of this class given its parent | |
112 * (which must be a <code>CTabFolder</code>), a style value | |
113 * describing its behavior and appearance, and the index | |
114 * at which to place it in the items maintained by its parent. | |
115 * <p> | |
116 * The style value is either one of the style constants defined in | |
117 * class <code>SWT</code> which is applicable to instances of this | |
118 * class, or must be built by <em>bitwise OR</em>'ing together | |
119 * (that is, using the <code>int</code> "|" operator) two or more | |
120 * of those <code>SWT</code> style constants. The class description | |
121 * lists the style constants that are applicable to the class. | |
122 * Style bits are also inherited from superclasses. | |
123 * </p> | |
124 * | |
125 * @param parent a CTabFolder which will be the parent of the new instance (cannot be null) | |
126 * @param style the style of control to construct | |
127 * @param index the zero-relative index to store the receiver in its parent | |
128 * | |
129 * @exception IllegalArgumentException <ul> | |
130 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
131 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li> | |
132 * </ul> | |
133 * @exception SWTException <ul> | |
134 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
135 * </ul> | |
136 * | |
137 * @see SWT | |
138 * @see Widget#getStyle() | |
139 */ | |
140 public this (CTabFolder parent, int style, int index) { | |
141 closeRect = new Rectangle(0, 0, 0, 0); | |
142 super (parent, style); | |
143 showClose = (style & SWT.CLOSE) !is 0; | |
144 parent.createItem (this, index); | |
145 } | |
146 | |
147 /* | |
148 * Return whether to use ellipses or just truncate labels | |
149 */ | |
150 bool useEllipses() { | |
151 return parent.simple; | |
152 } | |
153 | |
154 String shortenText(GC gc, String text, int width) { | |
155 return useEllipses() | |
156 ? shortenText(gc, text, width, ELLIPSIS) | |
157 : shortenText(gc, text, width, ""); //$NON-NLS-1$ | |
158 } | |
159 | |
160 String shortenText(GC gc, String text, int width, String ellipses) { | |
161 if (gc.textExtent(text, FLAGS).x <= width) return text; | |
162 int ellipseWidth = gc.textExtent(ellipses, FLAGS).x; | |
163 int length = text.length; | |
164 TextLayout layout = new TextLayout(getDisplay()); | |
165 layout.setText(text); | |
166 int end = layout.getPreviousOffset(length, SWT.MOVEMENT_CLUSTER); | |
167 while (end > 0) { | |
168 text = text[ 0 .. end ]; | |
169 int l = gc.textExtent(text, FLAGS).x; | |
170 if (l + ellipseWidth <= width) { | |
171 break; | |
172 } | |
173 end = layout.getPreviousOffset(end, SWT.MOVEMENT_CLUSTER); | |
174 } | |
175 layout.dispose(); | |
176 return end is 0 ? text.substring(0, 1) : text ~ ellipses; | |
177 } | |
178 | |
179 public override void dispose() { | |
180 if (isDisposed ()) return; | |
181 //if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); | |
182 parent.destroyItem(this); | |
183 super.dispose(); | |
184 parent = null; | |
185 control = null; | |
186 toolTipText = null; | |
187 shortenedText = null; | |
188 font = null; | |
189 } | |
190 void drawClose(GC gc) { | |
191 if (closeRect.width is 0 || closeRect.height is 0) return; | |
192 Display display = getDisplay(); | |
193 | |
194 // draw X 9x9 | |
195 int indent = Math.max(1, (CTabFolder.BUTTON_SIZE-9)/2); | |
196 int x = closeRect.x + indent; | |
197 int y = closeRect.y + indent; | |
198 y += parent.onBottom ? -1 : 1; | |
199 | |
200 Color closeBorder = display.getSystemColor(CTabFolder.BUTTON_BORDER); | |
201 switch (closeImageState) { | |
202 case CTabFolder.NORMAL: { | |
203 int[] shape = [x,y, x+2,y, x+4,y+2, x+5,y+2, x+7,y, x+9,y, | |
204 x+9,y+2, x+7,y+4, x+7,y+5, x+9,y+7, x+9,y+9, | |
205 x+7,y+9, x+5,y+7, x+4,y+7, x+2,y+9, x,y+9, | |
206 x,y+7, x+2,y+5, x+2,y+4, x,y+2]; | |
207 gc.setBackground(display.getSystemColor(CTabFolder.BUTTON_FILL)); | |
208 gc.fillPolygon(shape); | |
209 gc.setForeground(closeBorder); | |
210 gc.drawPolygon(shape); | |
211 break; | |
212 } | |
213 case CTabFolder.HOT: { | |
214 int[] shape = [x,y, x+2,y, x+4,y+2, x+5,y+2, x+7,y, x+9,y, | |
215 x+9,y+2, x+7,y+4, x+7,y+5, x+9,y+7, x+9,y+9, | |
216 x+7,y+9, x+5,y+7, x+4,y+7, x+2,y+9, x,y+9, | |
217 x,y+7, x+2,y+5, x+2,y+4, x,y+2]; | |
218 Color fill = new Color(display, CTabFolder.CLOSE_FILL); | |
219 gc.setBackground(fill); | |
220 gc.fillPolygon(shape); | |
221 fill.dispose(); | |
222 gc.setForeground(closeBorder); | |
223 gc.drawPolygon(shape); | |
224 break; | |
225 } | |
226 case CTabFolder.SELECTED: { | |
227 int[] shape = [x+1,y+1, x+3,y+1, x+5,y+3, x+6,y+3, x+8,y+1, x+10,y+1, | |
228 x+10,y+3, x+8,y+5, x+8,y+6, x+10,y+8, x+10,y+10, | |
229 x+8,y+10, x+6,y+8, x+5,y+8, x+3,y+10, x+1,y+10, | |
230 x+1,y+8, x+3,y+6, x+3,y+5, x+1,y+3]; | |
231 Color fill = new Color(display, CTabFolder.CLOSE_FILL); | |
232 gc.setBackground(fill); | |
233 gc.fillPolygon(shape); | |
234 fill.dispose(); | |
235 gc.setForeground(closeBorder); | |
236 gc.drawPolygon(shape); | |
237 break; | |
238 } | |
239 case CTabFolder.NONE: { | |
240 int[] shape = [x,y, x+10,y, x+10,y+10, x,y+10]; | |
241 if (parent.gradientColors !is null && !parent.gradientVertical) { | |
242 parent.drawBackground(gc, shape, false); | |
243 } else { | |
244 Color defaultBackground = parent.getBackground(); | |
245 Image image = parent.bgImage; | |
246 Color[] colors = parent.gradientColors; | |
247 int[] percents = parent.gradientPercents; | |
248 bool vertical = parent.gradientVertical; | |
249 parent.drawBackground(gc, shape, x, y, 10, 10, defaultBackground, image, colors, percents, vertical); | |
250 } | |
251 break; | |
252 } | |
253 default: | |
254 } | |
255 } | |
256 void drawSelected(GC gc ) { | |
257 Point size = parent.getSize(); | |
258 int rightEdge = Math.min (x + width, parent.getRightItemEdge()); | |
259 | |
260 // Draw selection border across all tabs | |
261 int xx = parent.borderLeft; | |
262 int yy = parent.onBottom ? size.y - parent.borderBottom - parent.tabHeight - parent.highlight_header : parent.borderTop + parent.tabHeight + 1; | |
263 int ww = size.x - parent.borderLeft - parent.borderRight; | |
264 int hh = parent.highlight_header - 1; | |
265 int[] shape = [xx,yy, xx+ww,yy, xx+ww,yy+hh, xx,yy+hh]; | |
266 if (parent.selectionGradientColors !is null && !parent.selectionGradientVertical) { | |
267 parent.drawBackground(gc, shape, true); | |
268 } else { | |
269 gc.setBackground(parent.selectionBackground); | |
270 gc.fillRectangle(xx, yy, ww, hh); | |
271 } | |
272 | |
273 if (parent.single) { | |
274 if (!showing) return; | |
275 } else { | |
276 // if selected tab scrolled out of view or partially out of view | |
277 // just draw bottom line | |
278 if (!showing){ | |
279 int x1 = Math.max(0, parent.borderLeft - 1); | |
280 int y1 = (parent.onBottom) ? y - 1 : y + height; | |
281 int x2 = size.x - parent.borderRight; | |
282 gc.setForeground(CTabFolder.borderColor); | |
283 gc.drawLine(x1, y1, x2, y1); | |
284 return; | |
285 } | |
286 | |
287 // draw selected tab background and outline | |
288 shape = null; | |
289 if (this.parent.onBottom) { | |
290 int[] left = parent.simple ? CTabFolder.SIMPLE_BOTTOM_LEFT_CORNER : CTabFolder.BOTTOM_LEFT_CORNER; | |
291 int[] right = parent.simple ? CTabFolder.SIMPLE_BOTTOM_RIGHT_CORNER : parent.curve; | |
292 if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) { | |
293 left = [x, y+height]; | |
294 } | |
295 shape = new int[left.length+right.length+8]; | |
296 int index = 0; | |
297 shape[index++] = x; // first point repeated here because below we reuse shape to draw outline | |
298 shape[index++] = y - 1; | |
299 shape[index++] = x; | |
300 shape[index++] = y - 1; | |
301 for (int i = 0; i < left.length/2; i++) { | |
302 shape[index++] = x + left[2*i]; | |
303 shape[index++] = y + height + left[2*i+1] - 1; | |
304 } | |
305 for (int i = 0; i < right.length/2; i++) { | |
306 shape[index++] = parent.simple ? rightEdge - 1 + right[2*i] : rightEdge - parent.curveIndent + right[2*i]; | |
307 shape[index++] = parent.simple ? y + height + right[2*i+1] - 1 : y + right[2*i+1] - 2; | |
308 } | |
309 shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; | |
310 shape[index++] = y - 1; | |
311 shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; | |
312 shape[index++] = y - 1; | |
313 } else { | |
314 int[] left = parent.simple ? CTabFolder.SIMPLE_TOP_LEFT_CORNER : CTabFolder.TOP_LEFT_CORNER; | |
315 int[] right = parent.simple ? CTabFolder.SIMPLE_TOP_RIGHT_CORNER : parent.curve; | |
316 if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) { | |
317 left = [x, y]; | |
318 } | |
319 shape = new int[left.length+right.length+8]; | |
320 int index = 0; | |
321 shape[index++] = x; // first point repeated here because below we reuse shape to draw outline | |
322 shape[index++] = y + height + 1; | |
323 shape[index++] = x; | |
324 shape[index++] = y + height + 1; | |
325 for (int i = 0; i < left.length/2; i++) { | |
326 shape[index++] = x + left[2*i]; | |
327 shape[index++] = y + left[2*i+1]; | |
328 } | |
329 for (int i = 0; i < right.length/2; i++) { | |
330 shape[index++] = parent.simple ? rightEdge - 1 + right[2*i] : rightEdge - parent.curveIndent + right[2*i]; | |
331 shape[index++] = y + right[2*i+1]; | |
332 } | |
333 shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; | |
334 shape[index++] = y + height + 1; | |
335 shape[index++] = parent.simple ? rightEdge - 1 : rightEdge + parent.curveWidth - parent.curveIndent; | |
336 shape[index++] = y + height + 1; | |
337 } | |
338 | |
339 Rectangle clipping = gc.getClipping(); | |
340 Rectangle bounds = getBounds(); | |
341 bounds.height += 1; | |
342 if (parent.onBottom) bounds.y -= 1; | |
343 bool tabInPaint = clipping.intersects(bounds); | |
344 | |
345 if (tabInPaint) { | |
346 // fill in tab background | |
347 if (parent.selectionGradientColors !is null && !parent.selectionGradientVertical) { | |
348 parent.drawBackground(gc, shape, true); | |
349 } else { | |
350 Color defaultBackground = parent.selectionBackground; | |
351 Image image = parent.selectionBgImage; | |
352 Color[] colors = parent.selectionGradientColors; | |
353 int[] percents = parent.selectionGradientPercents; | |
354 bool vertical = parent.selectionGradientVertical; | |
355 xx = x; | |
356 yy = parent.onBottom ? y -1 : y + 1; | |
357 ww = width; | |
358 hh = height; | |
359 if (!parent.single && !parent.simple) ww += parent.curveWidth - parent.curveIndent; | |
360 parent.drawBackground(gc, shape, xx, yy, ww, hh, defaultBackground, image, colors, percents, vertical); | |
361 } | |
362 } | |
363 | |
364 //Highlight MUST be drawn before the outline so that outline can cover it in the right spots (start of swoop) | |
365 //otherwise the curve looks jagged | |
366 drawHighlight(gc, rightEdge); | |
367 | |
368 // draw outline | |
369 shape[0] = Math.max(0, parent.borderLeft - 1); | |
370 if (parent.borderLeft is 0 && parent.indexOf(this) is parent.firstIndex) { | |
371 shape[1] = parent.onBottom ? y + height - 1 : y; | |
372 shape[5] = shape[3] = shape[1]; | |
373 } | |
374 shape[shape.length - 2] = size.x - parent.borderRight + 1; | |
375 for (int i = 0; i < shape.length/2; i++) { | |
376 if (shape[2*i + 1] is y + height + 1) shape[2*i + 1] -= 1; | |
377 } | |
378 RGB inside = parent.selectionBackground.getRGB(); | |
379 if (parent.selectionBgImage !is null || | |
380 (parent.selectionGradientColors !is null && parent.selectionGradientColors.length > 1)) { | |
381 inside = null; | |
382 } | |
383 RGB outside = parent.getBackground().getRGB(); | |
384 if (parent.bgImage !is null || | |
385 (parent.gradientColors !is null && parent.gradientColors.length > 1)) { | |
386 outside = null; | |
387 } | |
388 parent.antialias(shape, CTabFolder.borderColor.getRGB(), inside, outside, gc); | |
389 gc.setForeground(CTabFolder.borderColor); | |
390 gc.drawPolyline(shape); | |
391 | |
392 if (!tabInPaint) return; | |
393 } | |
394 | |
395 // draw Image | |
396 int xDraw = x + LEFT_MARGIN; | |
397 if (parent.single && (parent.showClose || showClose)) xDraw += CTabFolder.BUTTON_SIZE; | |
398 Image image = getImage(); | |
399 if (image !is null) { | |
400 Rectangle imageBounds = image.getBounds(); | |
401 // only draw image if it won't overlap with close button | |
402 int maxImageWidth = rightEdge - xDraw - RIGHT_MARGIN; | |
403 if (!parent.single && closeRect.width > 0) maxImageWidth -= closeRect.width + INTERNAL_SPACING; | |
404 if (imageBounds.width < maxImageWidth) { | |
405 int imageX = xDraw; | |
406 int imageY = y + (height - imageBounds.height) / 2; | |
407 imageY += parent.onBottom ? -1 : 1; | |
408 gc.drawImage(image, imageX, imageY); | |
409 xDraw += imageBounds.width + INTERNAL_SPACING; | |
410 } | |
411 } | |
412 | |
413 // draw Text | |
414 int textWidth = rightEdge - xDraw - RIGHT_MARGIN; | |
415 if (!parent.single && closeRect.width > 0) textWidth -= closeRect.width + INTERNAL_SPACING; | |
416 if (textWidth > 0) { | |
417 Font gcFont = gc.getFont(); | |
418 gc.setFont(font is null ? parent.getFont() : font); | |
419 | |
420 if (shortenedText is null || shortenedTextWidth !is textWidth) { | |
421 shortenedText = shortenText(gc, getText(), textWidth); | |
422 shortenedTextWidth = textWidth; | |
423 } | |
424 Point extent = gc.textExtent(shortenedText, FLAGS); | |
425 int textY = y + (height - extent.y) / 2; | |
426 textY += parent.onBottom ? -1 : 1; | |
427 | |
428 gc.setForeground(parent.selectionForeground); | |
429 gc.drawText(shortenedText, xDraw, textY, FLAGS); | |
430 gc.setFont(gcFont); | |
431 | |
432 // draw a Focus rectangle | |
433 if (parent.isFocusControl()) { | |
434 Display display = getDisplay(); | |
435 if (parent.simple || parent.single) { | |
436 gc.setBackground(display.getSystemColor(SWT.COLOR_BLACK)); | |
437 gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); | |
438 gc.drawFocus(xDraw-1, textY-1, extent.x+2, extent.y+2); | |
439 } else { | |
440 gc.setForeground(display.getSystemColor(CTabFolder.BUTTON_BORDER)); | |
441 gc.drawLine(xDraw, textY+extent.y+1, xDraw+extent.x+1, textY+extent.y+1); | |
442 } | |
443 } | |
444 } | |
445 if (parent.showClose || showClose) drawClose(gc); | |
446 } | |
447 | |
448 /* | |
449 * Draw a highlight effect along the left, top, and right edges of the tab. | |
450 * Only for curved tabs, on top. | |
451 * Do not draw if insufficient colors. | |
452 */ | |
453 void drawHighlight(GC gc, int rightEdge) { | |
454 //only draw for curvy tabs and only draw for top tabs | |
455 if(parent.simple || this.parent.onBottom) | |
456 return; | |
457 | |
458 if(parent.selectionHighlightGradientBegin is null) | |
459 return; | |
460 | |
461 Color[] gradients = parent.selectionHighlightGradientColorsCache; | |
462 if(gradients is null) | |
463 return; | |
464 int gradientsSize = gradients.length; | |
465 if(gradientsSize is 0) | |
466 return; //shouldn't happen but just to be tidy | |
467 | |
468 gc.setForeground(gradients[0]); | |
469 | |
470 //draw top horizontal line | |
471 gc.drawLine( | |
472 CTabFolder.TOP_LEFT_CORNER_HILITE[0] + x + 1, //rely on fact that first pair is top/right of curve | |
473 1 + y, | |
474 rightEdge - parent.curveIndent, | |
475 1 + y); | |
476 | |
477 int[] leftHighlightCurve = CTabFolder.TOP_LEFT_CORNER_HILITE; | |
478 | |
479 int d = parent.tabHeight - parent.topCurveHighlightEnd.length /2; | |
480 | |
481 int lastX = 0; | |
482 int lastY = 0; | |
483 int lastColorIndex = 0; | |
484 | |
485 //draw upper left curve highlight | |
486 for (int i = 0; i < leftHighlightCurve.length /2; i++) { | |
487 int rawX = leftHighlightCurve[i * 2]; | |
488 int rawY = leftHighlightCurve[i * 2 + 1]; | |
489 lastX = rawX + x; | |
490 lastY = rawY + y; | |
491 lastColorIndex = rawY - 1; | |
492 gc.setForeground(gradients[lastColorIndex]); | |
493 gc.drawPoint(lastX, lastY); | |
494 } | |
495 //draw left vertical line highlight | |
496 for(int i = lastColorIndex; i < gradientsSize; i++) { | |
497 gc.setForeground(gradients[i]); | |
498 gc.drawPoint(lastX, 1 + lastY++); | |
499 } | |
500 | |
501 int rightEdgeOffset = rightEdge - parent.curveIndent; | |
502 | |
503 //draw right swoop highlight up to diagonal portion | |
504 for (int i = 0; i < parent.topCurveHighlightStart.length /2; i++) { | |
505 int rawX = parent.topCurveHighlightStart[i * 2]; | |
506 int rawY = parent.topCurveHighlightStart[i * 2 + 1]; | |
507 lastX = rawX + rightEdgeOffset; | |
508 lastY = rawY + y; | |
509 lastColorIndex = rawY - 1; | |
510 if(lastColorIndex >= gradientsSize) | |
511 break; //can happen if tabs are unusually short and cut off the curve | |
512 gc.setForeground(gradients[lastColorIndex]); | |
513 gc.drawPoint(lastX, lastY); | |
514 } | |
515 //draw right diagonal line highlight | |
516 for(int i = lastColorIndex; i < lastColorIndex + d; i++) { | |
517 if(i >= gradientsSize) | |
518 break; //can happen if tabs are unusually short and cut off the curve | |
519 gc.setForeground(gradients[i]); | |
520 gc.drawPoint(1 + lastX++, 1 + lastY++); | |
521 } | |
522 | |
523 //draw right swoop highlight from diagonal portion to end | |
524 for (int i = 0; i < parent.topCurveHighlightEnd.length /2; i++) { | |
525 int rawX = parent.topCurveHighlightEnd[i * 2]; //d is already encoded in this value | |
526 int rawY = parent.topCurveHighlightEnd[i * 2 + 1]; //d already encoded | |
527 lastX = rawX + rightEdgeOffset; | |
528 lastY = rawY + y; | |
529 lastColorIndex = rawY - 1; | |
530 if(lastColorIndex >= gradientsSize) | |
531 break; //can happen if tabs are unusually short and cut off the curve | |
532 gc.setForeground(gradients[lastColorIndex]); | |
533 gc.drawPoint(lastX, lastY); | |
534 } | |
535 } | |
536 | |
537 /* | |
538 * Draw the unselected border for the receiver on the right. | |
539 * | |
540 * @param gc | |
541 */ | |
542 void drawRightUnselectedBorder(GC gc) { | |
543 | |
544 int[] shape = null; | |
545 int startX = x + width - 1; | |
546 | |
547 if (this.parent.onBottom) { | |
548 int[] right = parent.simple | |
549 ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER | |
550 : CTabFolder.BOTTOM_RIGHT_CORNER; | |
551 | |
552 shape = new int[right.length + 2]; | |
553 int index = 0; | |
554 | |
555 for (int i = 0; i < right.length / 2; i++) { | |
556 shape[index++] = startX + right[2 * i]; | |
557 shape[index++] = y + height + right[2 * i + 1] - 1; | |
558 } | |
559 shape[index++] = startX; | |
560 shape[index++] = y - 1; | |
561 } else { | |
562 int[] right = parent.simple | |
563 ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER | |
564 : CTabFolder.TOP_RIGHT_CORNER; | |
565 | |
566 shape = new int[right.length + 2]; | |
567 int index = 0; | |
568 | |
569 for (int i = 0; i < right.length / 2; i++) { | |
570 shape[index++] = startX + right[2 * i]; | |
571 shape[index++] = y + right[2 * i + 1]; | |
572 } | |
573 | |
574 shape[index++] = startX; | |
575 shape[index++] = y + height; | |
576 | |
577 } | |
578 | |
579 drawBorder(gc, shape); | |
580 | |
581 } | |
582 | |
583 /* | |
584 * Draw the border of the tab | |
585 * | |
586 * @param gc | |
587 * @param shape | |
588 */ | |
589 void drawBorder(GC gc, int[] shape) { | |
590 | |
591 gc.setForeground(CTabFolder.borderColor); | |
592 gc.drawPolyline(shape); | |
593 } | |
594 | |
595 /* | |
596 * Draw the unselected border for the receiver on the left. | |
597 * | |
598 * @param gc | |
599 */ | |
600 void drawLeftUnselectedBorder(GC gc) { | |
601 | |
602 int[] shape = null; | |
603 if (this.parent.onBottom) { | |
604 int[] left = parent.simple | |
605 ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER | |
606 : CTabFolder.BOTTOM_LEFT_CORNER; | |
607 | |
608 shape = new int[left.length + 2]; | |
609 int index = 0; | |
610 shape[index++] = x; | |
611 shape[index++] = y - 1; | |
612 for (int i = 0; i < left.length / 2; i++) { | |
613 shape[index++] = x + left[2 * i]; | |
614 shape[index++] = y + height + left[2 * i + 1] - 1; | |
615 } | |
616 } else { | |
617 int[] left = parent.simple | |
618 ? CTabFolder.SIMPLE_UNSELECTED_INNER_CORNER | |
619 : CTabFolder.TOP_LEFT_CORNER; | |
620 | |
621 shape = new int[left.length + 2]; | |
622 int index = 0; | |
623 shape[index++] = x; | |
624 shape[index++] = y + height; | |
625 for (int i = 0; i < left.length / 2; i++) { | |
626 shape[index++] = x + left[2 * i]; | |
627 shape[index++] = y + left[2 * i + 1]; | |
628 } | |
629 | |
630 } | |
631 | |
632 drawBorder(gc, shape); | |
633 } | |
634 | |
635 void drawUnselected(GC gc) { | |
636 // Do not draw partial items | |
637 if (!showing) return; | |
638 | |
639 Rectangle clipping = gc.getClipping(); | |
640 Rectangle bounds = getBounds(); | |
641 if (!clipping.intersects(bounds)) return; | |
642 | |
643 // draw border | |
644 int index = parent.indexOf(this); | |
645 | |
646 if (index > 0 && index < parent.selectedIndex) | |
647 drawLeftUnselectedBorder(gc); | |
648 // If it is the last one then draw a line | |
649 if (index > parent.selectedIndex) | |
650 drawRightUnselectedBorder(gc); | |
651 | |
652 // draw Image | |
653 int xDraw = x + LEFT_MARGIN; | |
654 Image image = getImage(); | |
655 if (image !is null && parent.showUnselectedImage) { | |
656 Rectangle imageBounds = image.getBounds(); | |
657 // only draw image if it won't overlap with close button | |
658 int maxImageWidth = x + width - xDraw - RIGHT_MARGIN; | |
659 if (parent.showUnselectedClose && (parent.showClose || showClose)) { | |
660 maxImageWidth -= closeRect.width + INTERNAL_SPACING; | |
661 } | |
662 if (imageBounds.width < maxImageWidth) { | |
663 int imageX = xDraw; | |
664 int imageHeight = imageBounds.height; | |
665 int imageY = y + (height - imageHeight) / 2; | |
666 imageY += parent.onBottom ? -1 : 1; | |
667 int imageWidth = imageBounds.width * imageHeight / imageBounds.height; | |
668 gc.drawImage(image, | |
669 imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height, | |
670 imageX, imageY, imageWidth, imageHeight); | |
671 xDraw += imageWidth + INTERNAL_SPACING; | |
672 } | |
673 } | |
674 // draw Text | |
675 int textWidth = x + width - xDraw - RIGHT_MARGIN; | |
676 if (parent.showUnselectedClose && (parent.showClose || showClose)) { | |
677 textWidth -= closeRect.width + INTERNAL_SPACING; | |
678 } | |
679 if (textWidth > 0) { | |
680 Font gcFont = gc.getFont(); | |
681 gc.setFont(font is null ? parent.getFont() : font); | |
682 if (shortenedText is null || shortenedTextWidth !is textWidth) { | |
683 shortenedText = shortenText(gc, getText(), textWidth); | |
684 shortenedTextWidth = textWidth; | |
685 } | |
686 Point extent = gc.textExtent(shortenedText, FLAGS); | |
687 int textY = y + (height - extent.y) / 2; | |
688 textY += parent.onBottom ? -1 : 1; | |
689 gc.setForeground(parent.getForeground()); | |
690 gc.drawText(shortenedText, xDraw, textY, FLAGS); | |
691 gc.setFont(gcFont); | |
692 } | |
693 // draw close | |
694 if (parent.showUnselectedClose && (parent.showClose || showClose)) drawClose(gc); | |
695 } | |
696 /** | |
697 * Returns a rectangle describing the receiver's size and location | |
698 * relative to its parent. | |
699 * | |
700 * @return the receiver's bounding column rectangle | |
701 * | |
702 * @exception SWTException <ul> | |
703 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
704 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
705 * </ul> | |
706 */ | |
707 public Rectangle getBounds () { | |
708 //checkWidget(); | |
709 int w = width; | |
710 if (!parent.simple && !parent.single && parent.indexOf(this) is parent.selectedIndex) w += parent.curveWidth - parent.curveIndent; | |
711 return new Rectangle(x, y, w, height); | |
712 } | |
713 /** | |
714 * Gets the control that is displayed in the content area of the tab item. | |
715 * | |
716 * @return the control | |
717 * | |
718 * @exception SWTException <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 */ | |
723 public Control getControl () { | |
724 checkWidget(); | |
725 return control; | |
726 } | |
727 /** | |
728 * Get the image displayed in the tab if the tab is disabled. | |
729 * | |
730 * @return the disabled image or null | |
731 * | |
732 * @exception SWTException <ul> | |
733 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
734 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
735 * </ul> | |
736 * | |
737 * @deprecated the disabled image is not used | |
738 */ | |
739 public Image getDisabledImage(){ | |
740 checkWidget(); | |
741 return disabledImage; | |
742 } | |
743 /** | |
744 * Returns the font that the receiver will use to paint textual information. | |
745 * | |
746 * @return the receiver's font | |
747 * | |
748 * @exception SWTException <ul> | |
749 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
750 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
751 * </ul> | |
752 * | |
753 * @since 3.0 | |
754 */ | |
755 public Font getFont() { | |
756 checkWidget(); | |
757 if (font !is null) return font; | |
758 return parent.getFont(); | |
759 } | |
760 /** | |
761 * Returns the receiver's parent, which must be a <code>CTabFolder</code>. | |
762 * | |
763 * @return the receiver's parent | |
764 * | |
765 * @exception SWTException <ul> | |
766 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
767 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
768 * </ul> | |
769 */ | |
770 public CTabFolder getParent () { | |
771 //checkWidget(); | |
772 return parent; | |
773 } | |
774 /** | |
775 * Returns <code>true</code> to indicate that the receiver's close button should be shown. | |
776 * Otherwise return <code>false</code>. The initial value is defined by the style (SWT.CLOSE) | |
777 * that was used to create the receiver. | |
778 * | |
779 * @return <code>true</code> if the close button should be shown | |
780 * | |
781 * @exception SWTException <ul> | |
782 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
783 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
784 * </ul> | |
785 * | |
786 * @since 3.4 | |
787 */ | |
788 public bool getShowClose() { | |
789 checkWidget(); | |
790 return showClose; | |
791 } | |
792 /** | |
793 * Returns the receiver's tool tip text, or null if it has | |
794 * not been set. | |
795 * | |
796 * @return the receiver's tool tip text | |
797 * | |
798 * @exception SWTException <ul> | |
799 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
800 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
801 * </ul> | |
802 */ | |
803 public String getToolTipText () { | |
804 checkWidget(); | |
805 if (toolTipText is null && shortenedText !is null) { | |
806 String text = getText(); | |
807 if (shortenedText!=text) return text; | |
808 } | |
809 return toolTipText; | |
810 } | |
811 /** | |
812 * Returns <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise. | |
813 * | |
814 * @return <code>true</code> if the item will be rendered in the visible area of the CTabFolder. Returns false otherwise. | |
815 * | |
816 * @exception SWTException <ul> | |
817 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
818 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
819 * </ul> | |
820 * | |
821 * @since 3.0 | |
822 */ | |
823 public bool isShowing () { | |
824 checkWidget(); | |
825 return showing; | |
826 } | |
827 void onPaint(GC gc, bool isSelected) { | |
828 if (width is 0 || height is 0) return; | |
829 if (isSelected) { | |
830 drawSelected(gc); | |
831 } else { | |
832 drawUnselected(gc); | |
833 } | |
834 } | |
835 int preferredHeight(GC gc) { | |
836 Image image = getImage(); | |
837 int h = (image is null) ? 0 : image.getBounds().height; | |
838 String text = getText(); | |
839 if (font is null) { | |
840 h = Math.max(h, gc.textExtent(text, FLAGS).y); | |
841 } else { | |
842 Font gcFont = gc.getFont(); | |
843 gc.setFont(font); | |
844 h = Math.max(h, gc.textExtent(text, FLAGS).y); | |
845 gc.setFont(gcFont); | |
846 } | |
847 return h + TOP_MARGIN + BOTTOM_MARGIN; | |
848 } | |
849 int preferredWidth(GC gc, bool isSelected, bool minimum) { | |
850 // NOTE: preferred width does not include the "dead space" caused | |
851 // by the curve. | |
852 if (isDisposed()) return 0; | |
853 int w = 0; | |
854 Image image = getImage(); | |
855 if (image !is null && (isSelected || parent.showUnselectedImage)) { | |
856 w += image.getBounds().width; | |
857 } | |
858 String text = null; | |
859 if (minimum) { | |
860 int minChars = parent.minChars; | |
861 text = minChars is 0 ? null : getText(); | |
862 if (text !is null && text.length > minChars) { | |
863 if (useEllipses()) { | |
864 int end = minChars < ELLIPSIS.length + 1 ? minChars : minChars - ELLIPSIS.length; | |
865 text = text[ 0 .. end ]; | |
866 if (minChars > ELLIPSIS.length + 1) text ~= ELLIPSIS; | |
867 } else { | |
868 int end = minChars; | |
869 text = text[ 0 .. end ]; | |
870 } | |
871 } | |
872 } else { | |
873 text = getText(); | |
874 } | |
875 if (text !is null) { | |
876 if (w > 0) w += INTERNAL_SPACING; | |
877 if (font is null) { | |
878 w += gc.textExtent(text, FLAGS).x; | |
879 } else { | |
880 Font gcFont = gc.getFont(); | |
881 gc.setFont(font); | |
882 w += gc.textExtent(text, FLAGS).x; | |
883 gc.setFont(gcFont); | |
884 } | |
885 } | |
886 if (parent.showClose || showClose) { | |
887 if (isSelected || parent.showUnselectedClose) { | |
888 if (w > 0) w += INTERNAL_SPACING; | |
889 w += CTabFolder.BUTTON_SIZE; | |
890 } | |
891 } | |
892 return w + LEFT_MARGIN + RIGHT_MARGIN; | |
893 } | |
894 /** | |
895 * Sets the control that is used to fill the client area of | |
896 * the tab folder when the user selects the tab item. | |
897 * | |
898 * @param control the new control (or null) | |
899 * | |
900 * @exception IllegalArgumentException <ul> | |
901 * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li> | |
902 * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li> | |
903 * </ul> | |
904 * @exception SWTException <ul> | |
905 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
906 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
907 * </ul> | |
908 */ | |
909 public void setControl (Control control) { | |
910 checkWidget(); | |
911 if (control !is null) { | |
912 if (control.isDisposed()) SWT.error (SWT.ERROR_INVALID_ARGUMENT); | |
913 if (control.getParent() !is parent) SWT.error (SWT.ERROR_INVALID_PARENT); | |
914 } | |
915 if (this.control !is null && !this.control.isDisposed()) { | |
916 this.control.setVisible(false); | |
917 } | |
918 this.control = control; | |
919 if (this.control !is null) { | |
920 int index = parent.indexOf (this); | |
921 if (index is parent.getSelectionIndex ()){ | |
922 this.control.setBounds(parent.getClientArea ()); | |
923 this.control.setVisible(true); | |
924 } else { | |
925 this.control.setVisible(false); | |
926 } | |
927 } | |
928 } | |
929 /** | |
930 * Sets the image that is displayed if the tab item is disabled. | |
931 * Null will clear the image. | |
932 * | |
933 * @param image the image to be displayed when the item is disabled or null | |
934 * | |
935 * @exception SWTException <ul> | |
936 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
937 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
938 * </ul> | |
939 * | |
940 * @deprecated This image is not used | |
941 */ | |
942 public void setDisabledImage (Image image) { | |
943 checkWidget(); | |
944 if (image !is null && image.isDisposed ()) { | |
945 SWT.error(SWT.ERROR_INVALID_ARGUMENT); | |
946 } | |
947 this.disabledImage = image; | |
948 } | |
949 /** | |
950 * Sets the font that the receiver will use to paint textual information | |
951 * for this item to the font specified by the argument, or to the default font | |
952 * for that kind of control if the argument is null. | |
953 * | |
954 * @param font the new font (or null) | |
955 * | |
956 * @exception IllegalArgumentException <ul> | |
957 * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> | |
958 * </ul> | |
959 * @exception SWTException <ul> | |
960 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
961 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
962 * </ul> | |
963 * | |
964 * @since 3.0 | |
965 */ | |
966 public void setFont (Font font){ | |
967 checkWidget(); | |
968 if (font !is null && font.isDisposed ()) { | |
969 SWT.error(SWT.ERROR_INVALID_ARGUMENT); | |
970 } | |
971 if (font is null && this.font is null) return; | |
972 if (font !is null && font==this.font) return; | |
973 this.font = font; | |
974 if (!parent.updateTabHeight(false)) { | |
975 parent.updateItems(); | |
976 parent.redrawTabs(); | |
977 } | |
978 } | |
979 public override void setImage (Image image) { | |
980 checkWidget(); | |
981 if (image !is null && image.isDisposed ()) { | |
982 SWT.error(SWT.ERROR_INVALID_ARGUMENT); | |
983 } | |
984 Image oldImage = getImage(); | |
985 if (image is null && oldImage is null) return; | |
986 if (image !is null && image==oldImage) return; | |
987 super.setImage(image); | |
988 if (!parent.updateTabHeight(false)) { | |
989 // If image is the same size as before, | |
990 // redraw only the image | |
991 if (oldImage !is null && image !is null) { | |
992 Rectangle oldBounds = oldImage.getBounds(); | |
993 Rectangle bounds = image.getBounds(); | |
994 if (bounds.width is oldBounds.width && bounds.height is oldBounds.height) { | |
995 if (showing) { | |
996 bool selected = parent.indexOf(this) is parent.selectedIndex; | |
997 if (selected || parent.showUnselectedImage) { | |
998 int imageX = x + LEFT_MARGIN, maxImageWidth; | |
999 if (selected) { | |
1000 if (parent.single && (parent.showClose || showClose)) imageX += CTabFolder.BUTTON_SIZE; | |
1001 int rightEdge = Math.min (x + width, parent.getRightItemEdge()); | |
1002 maxImageWidth = rightEdge - imageX - RIGHT_MARGIN; | |
1003 if (!parent.single && closeRect.width > 0) maxImageWidth -= closeRect.width + INTERNAL_SPACING; | |
1004 } else { | |
1005 maxImageWidth = x + width - imageX - RIGHT_MARGIN; | |
1006 if (parent.showUnselectedClose && (parent.showClose || showClose)) { | |
1007 maxImageWidth -= closeRect.width + INTERNAL_SPACING; | |
1008 } | |
1009 } | |
1010 if (bounds.width < maxImageWidth) { | |
1011 int imageY = y + (height - bounds.height) / 2 + (parent.onBottom ? -1 : 1); | |
1012 parent.redraw(imageX, imageY, bounds.width, bounds.height, false); | |
1013 } | |
1014 } | |
1015 } | |
1016 return; | |
1017 } | |
1018 } | |
1019 parent.updateItems(); | |
1020 parent.redrawTabs(); | |
1021 } | |
1022 } | |
1023 /** | |
1024 * Sets to <code>true</code> to indicate that the receiver's close button should be shown. | |
1025 * If the parent (CTabFolder) was created with SWT.CLOSE style, changing this value has | |
1026 * no effect. | |
1027 * | |
1028 * @param close the new state of the close button | |
1029 * | |
1030 * @exception SWTException <ul> | |
1031 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1032 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1033 * </ul> | |
1034 * | |
1035 * @since 3.4 | |
1036 */ | |
1037 public void setShowClose(bool close) { | |
1038 checkWidget(); | |
1039 if (showClose is close) return; | |
1040 showClose = close; | |
1041 parent.updateItems(); | |
1042 parent.redrawTabs(); | |
1043 } | |
1044 public override void setText (String string) { | |
1045 checkWidget(); | |
1046 // SWT extension: allow null for zero length string | |
1047 //if (string is null) SWT.error (SWT.ERROR_NULL_ARGUMENT); | |
1048 if (string.equals (getText())) return; | |
1049 super.setText(string); | |
1050 shortenedText = null; | |
1051 shortenedTextWidth = 0; | |
1052 if (!parent.updateTabHeight(false)) { | |
1053 parent.updateItems(); | |
1054 parent.redrawTabs(); | |
1055 } | |
1056 } | |
1057 /** | |
1058 * Sets the receiver's tool tip text to the argument, which | |
1059 * may be null indicating that no tool tip text should be shown. | |
1060 * | |
1061 * @param string the new tool tip text (or null) | |
1062 * | |
1063 * @exception SWTException <ul> | |
1064 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1065 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1066 * </ul> | |
1067 */ | |
1068 public void setToolTipText (String string) { | |
1069 checkWidget(); | |
1070 toolTipText = string; | |
1071 } | |
1072 | |
1073 } |