Mercurial > projects > dwt-linux
annotate dwt/widgets/TreeColumn.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | f2e04420fd6c |
children | ce446666f5a2 |
rev | line source |
---|---|
115
52b32f5cb1e0
many file checked for switch default
Frank Benoit <benoit@tionex.de>
parents:
108
diff
changeset
|
1 /******************************************************************************* |
90 | 2 * Copyright (c) 2000, 2007 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 | |
108 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
90 | 12 *******************************************************************************/ |
13 module dwt.widgets.TreeColumn; | |
14 | |
238 | 15 import dwt.dwthelper.utils; |
16 | |
90 | 17 |
18 | |
19 import dwt.DWT; | |
20 import dwt.DWTException; | |
21 import dwt.events.ControlListener; | |
22 import dwt.events.SelectionEvent; | |
23 import dwt.events.SelectionListener; | |
24 import dwt.graphics.Image; | |
25 import dwt.internal.gtk.OS; | |
26 import dwt.widgets.Item; | |
27 import dwt.widgets.Tree; | |
28 import dwt.widgets.Shell; | |
29 import dwt.widgets.ImageList; | |
30 import dwt.widgets.TypedListener; | |
31 | |
32 import Math = tango.math.Math; | |
33 static import tango.stdc.stringz; | |
34 | |
35 /** | |
36 * Instances of this class represent a column in a tree widget. | |
37 * <p><dl> | |
38 * <dt><b>Styles:</b></dt> | |
39 * <dd>LEFT, RIGHT, CENTER</dd> | |
40 * <dt><b>Events:</b></dt> | |
41 * <dd> Move, Resize, Selection</dd> | |
42 * </dl> | |
43 * </p><p> | |
44 * Note: Only one of the styles LEFT, RIGHT and CENTER may be specified. | |
45 * </p><p> | |
46 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | |
47 * </p> | |
48 * | |
49 * @since 3.1 | |
50 */ | |
51 public class TreeColumn : Item { | |
52 GtkWidget* labelHandle, imageHandle, buttonHandle; | |
53 Tree parent; | |
54 int modelIndex, lastButton, lastTime, lastX, lastWidth; | |
55 bool customDraw, useFixedWidth; | |
238 | 56 String toolTipText; |
90 | 57 |
58 /** | |
59 * Constructs a new instance of this class given its parent | |
60 * (which must be a <code>Tree</code>) and a style value | |
61 * describing its behavior and appearance. The item is added | |
62 * to the end of the items maintained by its parent. | |
63 * <p> | |
64 * The style value is either one of the style constants defined in | |
65 * class <code>DWT</code> which is applicable to instances of this | |
66 * class, or must be built by <em>bitwise OR</em>'ing together | |
67 * (that is, using the <code>int</code> "|" operator) two or more | |
68 * of those <code>DWT</code> style constants. The class description | |
69 * lists the style constants that are applicable to the class. | |
70 * Style bits are also inherited from superclasses. | |
71 * </p> | |
72 * | |
73 * @param parent a composite control which will be the parent of the new instance (cannot be null) | |
74 * @param style the style of control to construct | |
75 * | |
76 * @exception IllegalArgumentException <ul> | |
77 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
78 * </ul> | |
79 * @exception DWTException <ul> | |
80 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
81 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | |
82 * </ul> | |
83 * | |
84 * @see DWT#LEFT | |
85 * @see DWT#RIGHT | |
86 * @see DWT#CENTER | |
87 * @see Widget#checkSubclass | |
88 * @see Widget#getStyle | |
89 */ | |
90 public this (Tree parent, int style) { | |
91 super (parent, checkStyle (style)); | |
92 this.parent = parent; | |
93 createWidget (parent.getColumnCount ()); | |
94 } | |
95 | |
96 /** | |
97 * Constructs a new instance of this class given its parent | |
98 * (which must be a <code>Tree</code>), a style value | |
99 * describing its behavior and appearance, and the index | |
100 * at which to place it in the items maintained by its parent. | |
101 * <p> | |
102 * The style value is either one of the style constants defined in | |
103 * class <code>DWT</code> which is applicable to instances of this | |
104 * class, or must be built by <em>bitwise OR</em>'ing together | |
105 * (that is, using the <code>int</code> "|" operator) two or more | |
106 * of those <code>DWT</code> style constants. The class description | |
107 * lists the style constants that are applicable to the class. | |
108 * Style bits are also inherited from superclasses. | |
109 * </p> | |
110 * | |
111 * @param parent a composite control which will be the parent of the new instance (cannot be null) | |
112 * @param style the style of control to construct | |
113 * @param index the zero-relative index to store the receiver in its parent | |
114 * | |
115 * @exception IllegalArgumentException <ul> | |
116 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
117 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li> | |
118 * </ul> | |
119 * @exception DWTException <ul> | |
120 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
121 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | |
122 * </ul> | |
123 * | |
124 * @see DWT#LEFT | |
125 * @see DWT#RIGHT | |
126 * @see DWT#CENTER | |
127 * @see Widget#checkSubclass | |
128 * @see Widget#getStyle | |
129 */ | |
130 public this (Tree parent, int style, int index) { | |
131 super (parent, checkStyle (style)); | |
132 this.parent = parent; | |
133 createWidget (index); | |
134 } | |
135 | |
136 /** | |
137 * Adds the listener to the collection of listeners who will | |
138 * be notified when the control is moved or resized, by sending | |
139 * it one of the messages defined in the <code>ControlListener</code> | |
140 * interface. | |
141 * | |
142 * @param listener the listener which should be notified | |
143 * | |
144 * @exception IllegalArgumentException <ul> | |
145 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
146 * </ul> | |
147 * @exception DWTException <ul> | |
148 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
149 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
150 * </ul> | |
151 * | |
152 * @see ControlListener | |
153 * @see #removeControlListener | |
154 */ | |
155 public void addControlListener(ControlListener listener) { | |
156 checkWidget(); | |
157 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); | |
158 TypedListener typedListener = new TypedListener (listener); | |
159 addListener (DWT.Resize,typedListener); | |
160 addListener (DWT.Move,typedListener); | |
161 } | |
162 | |
163 /** | |
164 * Adds the listener to the collection of listeners who will | |
165 * be notified when the control is selected by the user, by sending | |
166 * it one of the messages defined in the <code>SelectionListener</code> | |
167 * interface. | |
168 * <p> | |
169 * <code>widgetSelected</code> is called when the column header is selected. | |
170 * <code>widgetDefaultSelected</code> is not called. | |
171 * </p> | |
172 * | |
173 * @param listener the listener which should be notified when the control is selected by the user | |
174 * | |
175 * @exception IllegalArgumentException <ul> | |
176 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
177 * </ul> | |
178 * @exception DWTException <ul> | |
179 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
180 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
181 * </ul> | |
182 * | |
183 * @see SelectionListener | |
184 * @see #removeSelectionListener | |
185 * @see SelectionEvent | |
186 */ | |
187 public void addSelectionListener (SelectionListener listener) { | |
188 checkWidget(); | |
189 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); | |
190 TypedListener typedListener = new TypedListener (listener); | |
191 addListener (DWT.Selection,typedListener); | |
192 addListener (DWT.DefaultSelection,typedListener); | |
193 } | |
194 | |
195 static int checkStyle (int style) { | |
196 return checkBits (style, DWT.LEFT, DWT.CENTER, DWT.RIGHT, 0, 0, 0); | |
197 } | |
198 | |
199 protected void checkSubclass () { | |
200 if (!isValidSubclass ()) error (DWT.ERROR_INVALID_SUBCLASS); | |
201 } | |
202 | |
203 void createWidget (int index) { | |
204 parent.createItem (this, index); | |
205 hookEvents (); | |
206 register (); | |
207 text = ""; | |
208 } | |
209 | |
210 void deregister() { | |
211 super.deregister (); | |
212 display.removeWidget (handle); | |
213 if (buttonHandle !is null) display.removeWidget (buttonHandle); | |
214 if (labelHandle !is null) display.removeWidget (labelHandle); | |
215 } | |
216 | |
217 void destroyWidget () { | |
218 parent.destroyItem (this); | |
219 releaseHandle (); | |
220 } | |
221 | |
222 /** | |
223 * Returns a value which describes the position of the | |
224 * text or image in the receiver. The value will be one of | |
225 * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>. | |
226 * | |
227 * @return the alignment | |
228 * | |
229 * @exception DWTException <ul> | |
230 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
231 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
232 * </ul> | |
233 */ | |
234 public int getAlignment () { | |
235 checkWidget(); | |
236 if ((style & DWT.LEFT) !is 0) return DWT.LEFT; | |
237 if ((style & DWT.CENTER) !is 0) return DWT.CENTER; | |
238 if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT; | |
239 return DWT.LEFT; | |
240 } | |
241 | |
242 /** | |
243 * Gets the moveable attribute. A column that is | |
244 * not moveable cannot be reordered by the user | |
245 * by dragging the header but may be reordered | |
246 * by the programmer. | |
247 * | |
248 * @return the moveable attribute | |
249 * | |
250 * @exception DWTException <ul> | |
251 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
252 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
253 * </ul> | |
254 * | |
255 * @see Tree#getColumnOrder() | |
256 * @see Tree#setColumnOrder(int[]) | |
257 * @see TreeColumn#setMoveable(bool) | |
258 * @see DWT#Move | |
259 * | |
260 * @since 3.2 | |
261 */ | |
262 public bool getMoveable() { | |
263 checkWidget(); | |
264 return cast(bool)OS.gtk_tree_view_column_get_reorderable (handle); | |
265 } | |
266 | |
267 /** | |
268 * Returns the receiver's parent, which must be a <code>Tree</code>. | |
269 * | |
270 * @return the receiver's parent | |
271 * | |
272 * @exception DWTException <ul> | |
273 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
274 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
275 * </ul> | |
276 */ | |
277 public Tree getParent () { | |
278 checkWidget(); | |
279 return parent; | |
280 } | |
281 | |
282 /** | |
283 * Gets the resizable attribute. A column that is | |
284 * not resizable cannot be dragged by the user but | |
285 * may be resized by the programmer. | |
286 * | |
287 * @return the resizable attribute | |
288 * | |
289 * @exception DWTException <ul> | |
290 * <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> | |
292 * </ul> | |
293 */ | |
294 public bool getResizable () { | |
295 checkWidget(); | |
296 return cast(bool)OS.gtk_tree_view_column_get_resizable (handle); | |
297 } | |
298 | |
299 /** | |
300 * Returns the receiver's tool tip text, or null if it has | |
301 * not been set. | |
302 * | |
303 * @return the receiver's tool tip text | |
304 * | |
305 * @exception DWTException <ul> | |
306 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
307 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
308 * </ul> | |
309 * | |
310 * @since 3.2 | |
311 */ | |
238 | 312 public String getToolTipText () { |
90 | 313 checkWidget(); |
314 return toolTipText; | |
315 } | |
316 | |
317 /** | |
318 * Gets the width of the receiver. | |
319 * | |
320 * @return the width | |
321 * | |
322 * @exception DWTException <ul> | |
323 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
324 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
325 * </ul> | |
326 */ | |
327 public int getWidth () { | |
328 checkWidget(); | |
329 if (!OS.gtk_tree_view_column_get_visible (handle)) { | |
330 return 0; | |
331 } | |
332 if (useFixedWidth) return OS.gtk_tree_view_column_get_fixed_width (handle); | |
333 return OS.gtk_tree_view_column_get_width (handle); | |
334 } | |
335 | |
336 override int gtk_clicked (GtkWidget* widget) { | |
337 /* | |
338 * There is no API to get a double click on a table column. Normally, when | |
339 * the mouse is double clicked, this is indicated by GDK_2BUTTON_PRESS | |
340 * but the table column sends the click signal on button release. The fix is to | |
341 * test for double click by remembering the last click time and mouse button | |
342 * and testing for the double click interval. | |
343 */ | |
344 bool doubleClick = false; | |
345 bool postEvent_ = true; | |
346 auto eventPtr = OS.gtk_get_current_event (); | |
347 if (eventPtr !is null) { | |
348 GdkEventButton* gdkEvent = cast(GdkEventButton*)eventPtr; | |
349 scope(exit) OS.gdk_event_free (eventPtr); | |
350 switch (gdkEvent.type) { | |
351 case OS.GDK_BUTTON_RELEASE: { | |
352 int clickTime = display.getDoubleClickTime (); | |
353 int eventTime = gdkEvent.time, eventButton = gdkEvent.button; | |
354 if (lastButton is eventButton && lastTime !is 0 && Math.abs (lastTime - eventTime) <= clickTime) { | |
355 doubleClick = true; | |
356 } | |
357 lastTime = eventTime is 0 ? 1: eventTime; | |
358 lastButton = eventButton; | |
359 break; | |
360 } | |
361 case OS.GDK_MOTION_NOTIFY: { | |
362 /* | |
363 * Bug in GTK. Dragging a column in a GtkTreeView causes a clicked | |
364 * signal to be emitted even though the mouse button was never released. | |
365 * The fix to ignore the signal if the current GDK event is a motion notify. | |
366 * The GTK bug was fixed in version 2.6 | |
367 */ | |
368 if (OS.GTK_VERSION < OS.buildVERSION (2, 6, 0)) postEvent_ = false; | |
369 break; | |
370 } | |
115
52b32f5cb1e0
many file checked for switch default
Frank Benoit <benoit@tionex.de>
parents:
108
diff
changeset
|
371 default: |
90 | 372 } |
373 } | |
374 if (postEvent_) postEvent (doubleClick ? DWT.DefaultSelection : DWT.Selection); | |
375 return 0; | |
376 } | |
377 | |
378 override int gtk_mnemonic_activate (GtkWidget* widget, int /*long*/ arg1) { | |
379 return parent.gtk_mnemonic_activate (widget, arg1); | |
380 } | |
381 | |
382 override int gtk_size_allocate (GtkWidget* widget, int allocation) { | |
383 useFixedWidth = false; | |
384 int x = OS.GTK_WIDGET_X (widget); | |
385 int width = OS.GTK_WIDGET_WIDTH (widget); | |
386 if (x !is lastX) { | |
387 lastX = x; | |
388 sendEvent (DWT.Move); | |
389 } | |
390 if (width !is lastWidth) { | |
391 lastWidth = width; | |
392 sendEvent (DWT.Resize); | |
393 } | |
394 return 0; | |
395 } | |
396 | |
397 void hookEvents () { | |
398 super.hookEvents (); | |
399 OS.g_signal_connect_closure (handle, OS.clicked.ptr, display.closures [CLICKED], false); | |
400 if (buttonHandle !is null) OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [SIZE_ALLOCATE], 0, display.closures [SIZE_ALLOCATE], false); | |
401 if (labelHandle !is null) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false); | |
402 } | |
403 | |
404 /** | |
405 * Causes the receiver to be resized to its preferred size. | |
406 * For a composite, this involves computing the preferred size | |
407 * from its layout, if there is one. | |
408 * | |
409 * @exception DWTException <ul> | |
410 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
411 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
412 * </ul> | |
413 * | |
414 */ | |
415 public void pack () { | |
416 checkWidget(); | |
417 int width = 0; | |
418 if (buttonHandle !is null) { | |
419 GtkRequisition requisition; | |
420 OS.gtk_widget_size_request (buttonHandle, &requisition); | |
421 width = requisition.width; | |
422 } | |
423 if ((parent.style & DWT.VIRTUAL) !is 0) { | |
424 //NOT DONE | |
425 } else { | |
426 GtkTreeIter iter; | |
427 if (OS.gtk_tree_model_get_iter_first (parent.modelHandle, &iter)) { | |
428 do { | |
429 width = Math.max (width, parent.calculateWidth (cast(GtkTreeViewColumn*)handle, &iter)); | |
430 } while (OS.gtk_tree_model_iter_next(parent.modelHandle, &iter)); | |
431 } | |
432 } | |
433 setWidth(width); | |
434 } | |
435 | |
436 void register () { | |
437 super.register (); | |
438 display.addWidget (handle, this); | |
439 if (buttonHandle !is null) display.addWidget (buttonHandle, this); | |
440 if (labelHandle !is null) display.addWidget (labelHandle, this); | |
441 } | |
442 | |
443 void releaseHandle () { | |
444 super.releaseHandle (); | |
445 handle = buttonHandle = labelHandle = imageHandle = null; | |
446 modelIndex = -1; | |
447 parent = null; | |
448 } | |
449 | |
450 void releaseParent () { | |
451 super.releaseParent (); | |
452 if (parent.sortColumn is this) { | |
453 parent.sortColumn = null; | |
454 } | |
455 } | |
456 | |
457 /** | |
458 * Removes the listener from the collection of listeners who will | |
459 * be notified when the control is moved or resized. | |
460 * | |
461 * @param listener the listener which should no longer be notified | |
462 * | |
463 * @exception IllegalArgumentException <ul> | |
464 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
465 * </ul> | |
466 * @exception DWTException <ul> | |
467 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
468 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
469 * </ul> | |
470 * | |
471 * @see ControlListener | |
472 * @see #addControlListener | |
473 */ | |
474 public void removeControlListener (ControlListener listener) { | |
475 checkWidget(); | |
476 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); | |
477 if (eventTable is null) return; | |
478 eventTable.unhook (DWT.Move, listener); | |
479 eventTable.unhook (DWT.Resize, listener); | |
480 } | |
481 | |
482 /** | |
483 * Removes the listener from the collection of listeners who will | |
484 * be notified when the control is selected by the user. | |
485 * | |
486 * @param listener the listener which should no longer be notified | |
487 * | |
488 * @exception IllegalArgumentException <ul> | |
489 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
490 * </ul> | |
491 * @exception DWTException <ul> | |
492 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
493 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
494 * </ul> | |
495 * | |
496 * @see SelectionListener | |
497 * @see #addSelectionListener | |
498 */ | |
499 public void removeSelectionListener(SelectionListener listener) { | |
500 checkWidget(); | |
501 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); | |
502 if (eventTable is null) return; | |
503 eventTable.unhook (DWT.Selection, listener); | |
504 eventTable.unhook (DWT.DefaultSelection,listener); | |
505 } | |
506 | |
507 /** | |
508 * Controls how text and images will be displayed in the receiver. | |
509 * The argument should be one of <code>LEFT</code>, <code>RIGHT</code> | |
510 * or <code>CENTER</code>. | |
511 * | |
512 * @param alignment the new alignment | |
513 * | |
514 * @exception DWTException <ul> | |
515 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
516 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
517 * </ul> | |
518 */ | |
519 public void setAlignment (int alignment) { | |
520 checkWidget(); | |
521 if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return; | |
522 int index = parent.indexOf (this); | |
523 if (index is -1 || index is 0) return; | |
524 style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER); | |
525 style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER); | |
526 parent.createRenderers (cast(GtkTreeViewColumn*)handle, modelIndex, index is 0, style); | |
527 } | |
528 | |
529 void setFontDescription (PangoFontDescription* font) { | |
530 OS.gtk_widget_modify_font (labelHandle, font); | |
531 OS.gtk_widget_modify_font (imageHandle, font); | |
532 } | |
533 | |
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
115
diff
changeset
|
534 public override void setImage (Image image) { |
90 | 535 checkWidget (); |
536 super.setImage (image); | |
537 if (image !is null) { | |
538 ImageList headerImageList = parent.headerImageList; | |
539 if (headerImageList is null) { | |
540 headerImageList = parent.headerImageList = new ImageList (); | |
541 } | |
542 int imageIndex = headerImageList.indexOf (image); | |
543 if (imageIndex is -1) imageIndex = headerImageList.add (image); | |
544 auto pixbuf = headerImageList.getPixbuf (imageIndex); | |
545 OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf); | |
546 OS.gtk_widget_show (imageHandle); | |
547 } else { | |
548 OS.gtk_image_set_from_pixbuf (imageHandle, null); | |
549 OS.gtk_widget_hide (imageHandle); | |
550 } | |
551 } | |
552 | |
553 /** | |
554 * Sets the moveable attribute. A column that is | |
555 * moveable can be reordered by the user by dragging | |
556 * the header. A column that is not moveable cannot be | |
557 * dragged by the user but may be reordered | |
558 * by the programmer. | |
559 * | |
560 * @param moveable the moveable attribute | |
561 * | |
562 * @exception DWTException <ul> | |
563 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
564 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
565 * </ul> | |
566 * | |
567 * @see Tree#setColumnOrder(int[]) | |
568 * @see Tree#getColumnOrder() | |
569 * @see TreeColumn#getMoveable() | |
570 * @see DWT#Move | |
571 * | |
572 * @since 3.2 | |
573 */ | |
574 public void setMoveable (bool moveable) { | |
575 checkWidget(); | |
576 OS.gtk_tree_view_column_set_reorderable (handle, moveable); | |
577 } | |
578 | |
579 /** | |
580 * Sets the resizable attribute. A column that is | |
581 * not resizable cannot be dragged by the user but | |
582 * may be resized by the programmer. | |
583 * | |
584 * @param resizable the resize attribute | |
585 * | |
586 * @exception DWTException <ul> | |
587 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
588 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
589 * </ul> | |
590 */ | |
591 public void setResizable (bool resizable) { | |
592 checkWidget(); | |
593 OS.gtk_tree_view_column_set_resizable (handle, resizable); | |
594 } | |
595 | |
238 | 596 public override void setText (String string) { |
90 | 597 checkWidget(); |
598 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | |
599 super.setText (string); | |
600 char [] chars = fixMnemonic (string); | |
601 char* buffer = tango.stdc.stringz.toStringz(chars); | |
602 OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer); | |
603 if (string.length !is 0) { | |
604 OS.gtk_widget_show (labelHandle); | |
605 } else { | |
606 OS.gtk_widget_hide (labelHandle); | |
607 } | |
608 } | |
609 | |
610 /** | |
611 * Sets the receiver's tool tip text to the argument, which | |
612 * may be null indicating that no tool tip text should be shown. | |
613 * | |
614 * @param string the new tool tip text (or null) | |
615 * | |
616 * @exception DWTException <ul> | |
617 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
618 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
619 * </ul> | |
620 * | |
621 * @since 3.2 | |
622 */ | |
238 | 623 public void setToolTipText (String string) { |
90 | 624 checkWidget(); |
625 Shell shell = parent._getShell (); | |
626 setToolTipText (shell, string); | |
627 toolTipText = string; | |
628 } | |
629 | |
238 | 630 void setToolTipText (Shell shell, String newString) { |
90 | 631 shell.setToolTipText (buttonHandle, newString); |
632 } | |
633 | |
634 /** | |
635 * Sets the width of the receiver. | |
636 * | |
637 * @param width the new width | |
638 * | |
639 * @exception DWTException <ul> | |
640 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
641 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
642 * </ul> | |
643 */ | |
644 public void setWidth (int width) { | |
645 checkWidget(); | |
646 if (width < 0) return; | |
647 if (width is lastWidth) return; | |
648 if (width > 0) { | |
649 useFixedWidth = true; | |
650 OS.gtk_tree_view_column_set_fixed_width (handle, width); | |
651 } | |
652 /* | |
653 * Bug in GTK. For some reason, calling gtk_tree_view_column_set_visible() | |
654 * when the parent is not realized fails to show the column. The fix is to | |
655 * ensure that the table has been realized. | |
656 */ | |
657 if (width !is 0) OS.gtk_widget_realize (parent.handle); | |
658 OS.gtk_tree_view_column_set_visible (handle, width !is 0); | |
659 lastWidth = width; | |
660 sendEvent (DWT.Resize); | |
661 } | |
662 | |
663 } |