Mercurial > projects > dwt-linux
annotate dwt/widgets/TreeColumn.d @ 248:34409a2fc053
Fix call OS.gtk_label_set_text_with_mnemonic with valid ptr, even for zero length strings.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 19:00:47 +0200 |
parents | ce446666f5a2 |
children | 5a30aa9820f3 |
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); | |
240 | 205 setOrientation (); |
90 | 206 hookEvents (); |
207 register (); | |
208 text = ""; | |
209 } | |
210 | |
211 void deregister() { | |
212 super.deregister (); | |
213 display.removeWidget (handle); | |
214 if (buttonHandle !is null) display.removeWidget (buttonHandle); | |
215 if (labelHandle !is null) display.removeWidget (labelHandle); | |
216 } | |
217 | |
218 void destroyWidget () { | |
219 parent.destroyItem (this); | |
220 releaseHandle (); | |
221 } | |
222 | |
223 /** | |
224 * Returns a value which describes the position of the | |
225 * text or image in the receiver. The value will be one of | |
226 * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>. | |
227 * | |
228 * @return the alignment | |
229 * | |
230 * @exception DWTException <ul> | |
231 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
232 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
233 * </ul> | |
234 */ | |
235 public int getAlignment () { | |
236 checkWidget(); | |
237 if ((style & DWT.LEFT) !is 0) return DWT.LEFT; | |
238 if ((style & DWT.CENTER) !is 0) return DWT.CENTER; | |
239 if ((style & DWT.RIGHT) !is 0) return DWT.RIGHT; | |
240 return DWT.LEFT; | |
241 } | |
242 | |
243 /** | |
244 * Gets the moveable attribute. A column that is | |
245 * not moveable cannot be reordered by the user | |
246 * by dragging the header but may be reordered | |
247 * by the programmer. | |
248 * | |
249 * @return the moveable attribute | |
250 * | |
251 * @exception DWTException <ul> | |
252 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
253 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
254 * </ul> | |
255 * | |
256 * @see Tree#getColumnOrder() | |
257 * @see Tree#setColumnOrder(int[]) | |
258 * @see TreeColumn#setMoveable(bool) | |
259 * @see DWT#Move | |
260 * | |
261 * @since 3.2 | |
262 */ | |
263 public bool getMoveable() { | |
264 checkWidget(); | |
265 return cast(bool)OS.gtk_tree_view_column_get_reorderable (handle); | |
266 } | |
267 | |
268 /** | |
269 * Returns the receiver's parent, which must be a <code>Tree</code>. | |
270 * | |
271 * @return the receiver's parent | |
272 * | |
273 * @exception DWTException <ul> | |
274 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
275 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
276 * </ul> | |
277 */ | |
278 public Tree getParent () { | |
279 checkWidget(); | |
280 return parent; | |
281 } | |
282 | |
283 /** | |
284 * Gets the resizable attribute. A column that is | |
285 * not resizable cannot be dragged by the user but | |
286 * may be resized by the programmer. | |
287 * | |
288 * @return the resizable attribute | |
289 * | |
290 * @exception DWTException <ul> | |
291 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
292 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
293 * </ul> | |
294 */ | |
295 public bool getResizable () { | |
296 checkWidget(); | |
297 return cast(bool)OS.gtk_tree_view_column_get_resizable (handle); | |
298 } | |
299 | |
300 /** | |
301 * Returns the receiver's tool tip text, or null if it has | |
302 * not been set. | |
303 * | |
304 * @return the receiver's tool tip text | |
305 * | |
306 * @exception DWTException <ul> | |
307 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
308 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
309 * </ul> | |
310 * | |
311 * @since 3.2 | |
312 */ | |
238 | 313 public String getToolTipText () { |
90 | 314 checkWidget(); |
315 return toolTipText; | |
316 } | |
317 | |
318 /** | |
319 * Gets the width of the receiver. | |
320 * | |
321 * @return the width | |
322 * | |
323 * @exception DWTException <ul> | |
324 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
325 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
326 * </ul> | |
327 */ | |
328 public int getWidth () { | |
329 checkWidget(); | |
330 if (!OS.gtk_tree_view_column_get_visible (handle)) { | |
331 return 0; | |
332 } | |
333 if (useFixedWidth) return OS.gtk_tree_view_column_get_fixed_width (handle); | |
334 return OS.gtk_tree_view_column_get_width (handle); | |
335 } | |
336 | |
337 override int gtk_clicked (GtkWidget* widget) { | |
338 /* | |
339 * There is no API to get a double click on a table column. Normally, when | |
340 * the mouse is double clicked, this is indicated by GDK_2BUTTON_PRESS | |
341 * but the table column sends the click signal on button release. The fix is to | |
342 * test for double click by remembering the last click time and mouse button | |
343 * and testing for the double click interval. | |
344 */ | |
345 bool doubleClick = false; | |
346 bool postEvent_ = true; | |
347 auto eventPtr = OS.gtk_get_current_event (); | |
348 if (eventPtr !is null) { | |
349 GdkEventButton* gdkEvent = cast(GdkEventButton*)eventPtr; | |
350 scope(exit) OS.gdk_event_free (eventPtr); | |
351 switch (gdkEvent.type) { | |
352 case OS.GDK_BUTTON_RELEASE: { | |
353 int clickTime = display.getDoubleClickTime (); | |
354 int eventTime = gdkEvent.time, eventButton = gdkEvent.button; | |
355 if (lastButton is eventButton && lastTime !is 0 && Math.abs (lastTime - eventTime) <= clickTime) { | |
356 doubleClick = true; | |
357 } | |
358 lastTime = eventTime is 0 ? 1: eventTime; | |
359 lastButton = eventButton; | |
360 break; | |
361 } | |
362 case OS.GDK_MOTION_NOTIFY: { | |
363 /* | |
364 * Bug in GTK. Dragging a column in a GtkTreeView causes a clicked | |
365 * signal to be emitted even though the mouse button was never released. | |
366 * The fix to ignore the signal if the current GDK event is a motion notify. | |
367 * The GTK bug was fixed in version 2.6 | |
368 */ | |
369 if (OS.GTK_VERSION < OS.buildVERSION (2, 6, 0)) postEvent_ = false; | |
370 break; | |
371 } | |
115
52b32f5cb1e0
many file checked for switch default
Frank Benoit <benoit@tionex.de>
parents:
108
diff
changeset
|
372 default: |
90 | 373 } |
374 } | |
375 if (postEvent_) postEvent (doubleClick ? DWT.DefaultSelection : DWT.Selection); | |
376 return 0; | |
377 } | |
378 | |
379 override int gtk_mnemonic_activate (GtkWidget* widget, int /*long*/ arg1) { | |
380 return parent.gtk_mnemonic_activate (widget, arg1); | |
381 } | |
382 | |
383 override int gtk_size_allocate (GtkWidget* widget, int allocation) { | |
384 useFixedWidth = false; | |
385 int x = OS.GTK_WIDGET_X (widget); | |
386 int width = OS.GTK_WIDGET_WIDTH (widget); | |
387 if (x !is lastX) { | |
388 lastX = x; | |
389 sendEvent (DWT.Move); | |
390 } | |
391 if (width !is lastWidth) { | |
392 lastWidth = width; | |
393 sendEvent (DWT.Resize); | |
394 } | |
395 return 0; | |
396 } | |
397 | |
398 void hookEvents () { | |
399 super.hookEvents (); | |
400 OS.g_signal_connect_closure (handle, OS.clicked.ptr, display.closures [CLICKED], false); | |
401 if (buttonHandle !is null) OS.g_signal_connect_closure_by_id (buttonHandle, display.signalIds [SIZE_ALLOCATE], 0, display.closures [SIZE_ALLOCATE], false); | |
402 if (labelHandle !is null) OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false); | |
403 } | |
404 | |
405 /** | |
406 * Causes the receiver to be resized to its preferred size. | |
407 * For a composite, this involves computing the preferred size | |
408 * from its layout, if there is one. | |
409 * | |
410 * @exception DWTException <ul> | |
411 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
412 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
413 * </ul> | |
414 * | |
415 */ | |
416 public void pack () { | |
417 checkWidget(); | |
418 int width = 0; | |
419 if (buttonHandle !is null) { | |
420 GtkRequisition requisition; | |
421 OS.gtk_widget_size_request (buttonHandle, &requisition); | |
422 width = requisition.width; | |
423 } | |
424 if ((parent.style & DWT.VIRTUAL) !is 0) { | |
425 //NOT DONE | |
426 } else { | |
427 GtkTreeIter iter; | |
428 if (OS.gtk_tree_model_get_iter_first (parent.modelHandle, &iter)) { | |
429 do { | |
240 | 430 width = Math.max (width, parent.calculateWidth (cast(GtkTreeViewColumn*)handle, &iter, true)); |
90 | 431 } while (OS.gtk_tree_model_iter_next(parent.modelHandle, &iter)); |
432 } | |
433 } | |
434 setWidth(width); | |
435 } | |
436 | |
437 void register () { | |
438 super.register (); | |
439 display.addWidget (handle, this); | |
440 if (buttonHandle !is null) display.addWidget (buttonHandle, this); | |
441 if (labelHandle !is null) display.addWidget (labelHandle, this); | |
442 } | |
443 | |
444 void releaseHandle () { | |
445 super.releaseHandle (); | |
446 handle = buttonHandle = labelHandle = imageHandle = null; | |
447 modelIndex = -1; | |
448 parent = null; | |
449 } | |
450 | |
451 void releaseParent () { | |
452 super.releaseParent (); | |
453 if (parent.sortColumn is this) { | |
454 parent.sortColumn = null; | |
455 } | |
456 } | |
457 | |
458 /** | |
459 * Removes the listener from the collection of listeners who will | |
460 * be notified when the control is moved or resized. | |
461 * | |
462 * @param listener the listener which should no longer be notified | |
463 * | |
464 * @exception IllegalArgumentException <ul> | |
465 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
466 * </ul> | |
467 * @exception DWTException <ul> | |
468 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
469 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
470 * </ul> | |
471 * | |
472 * @see ControlListener | |
473 * @see #addControlListener | |
474 */ | |
475 public void removeControlListener (ControlListener listener) { | |
476 checkWidget(); | |
477 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); | |
478 if (eventTable is null) return; | |
479 eventTable.unhook (DWT.Move, listener); | |
480 eventTable.unhook (DWT.Resize, listener); | |
481 } | |
482 | |
483 /** | |
484 * Removes the listener from the collection of listeners who will | |
485 * be notified when the control is selected by the user. | |
486 * | |
487 * @param listener the listener which should no longer be notified | |
488 * | |
489 * @exception IllegalArgumentException <ul> | |
490 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
491 * </ul> | |
492 * @exception DWTException <ul> | |
493 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
494 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
495 * </ul> | |
496 * | |
497 * @see SelectionListener | |
498 * @see #addSelectionListener | |
499 */ | |
500 public void removeSelectionListener(SelectionListener listener) { | |
501 checkWidget(); | |
502 if (listener is null) error (DWT.ERROR_NULL_ARGUMENT); | |
503 if (eventTable is null) return; | |
504 eventTable.unhook (DWT.Selection, listener); | |
505 eventTable.unhook (DWT.DefaultSelection,listener); | |
506 } | |
507 | |
508 /** | |
509 * Controls how text and images will be displayed in the receiver. | |
510 * The argument should be one of <code>LEFT</code>, <code>RIGHT</code> | |
511 * or <code>CENTER</code>. | |
512 * | |
513 * @param alignment the new alignment | |
514 * | |
515 * @exception DWTException <ul> | |
516 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
517 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
518 * </ul> | |
519 */ | |
520 public void setAlignment (int alignment) { | |
521 checkWidget(); | |
522 if ((alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER)) is 0) return; | |
523 int index = parent.indexOf (this); | |
524 if (index is -1 || index is 0) return; | |
525 style &= ~(DWT.LEFT | DWT.RIGHT | DWT.CENTER); | |
526 style |= alignment & (DWT.LEFT | DWT.RIGHT | DWT.CENTER); | |
527 parent.createRenderers (cast(GtkTreeViewColumn*)handle, modelIndex, index is 0, style); | |
528 } | |
529 | |
530 void setFontDescription (PangoFontDescription* font) { | |
531 OS.gtk_widget_modify_font (labelHandle, font); | |
532 OS.gtk_widget_modify_font (imageHandle, font); | |
533 } | |
534 | |
150
f2e04420fd6c
reworked overrides and superclass aliases
Frank Benoit <benoit@tionex.de>
parents:
115
diff
changeset
|
535 public override void setImage (Image image) { |
90 | 536 checkWidget (); |
537 super.setImage (image); | |
538 if (image !is null) { | |
539 ImageList headerImageList = parent.headerImageList; | |
540 if (headerImageList is null) { | |
541 headerImageList = parent.headerImageList = new ImageList (); | |
542 } | |
543 int imageIndex = headerImageList.indexOf (image); | |
544 if (imageIndex is -1) imageIndex = headerImageList.add (image); | |
545 auto pixbuf = headerImageList.getPixbuf (imageIndex); | |
546 OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf); | |
547 OS.gtk_widget_show (imageHandle); | |
548 } else { | |
549 OS.gtk_image_set_from_pixbuf (imageHandle, null); | |
550 OS.gtk_widget_hide (imageHandle); | |
551 } | |
552 } | |
553 | |
554 /** | |
555 * Sets the moveable attribute. A column that is | |
556 * moveable can be reordered by the user by dragging | |
557 * the header. A column that is not moveable cannot be | |
558 * dragged by the user but may be reordered | |
559 * by the programmer. | |
560 * | |
561 * @param moveable the moveable attribute | |
562 * | |
563 * @exception DWTException <ul> | |
564 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
565 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
566 * </ul> | |
567 * | |
568 * @see Tree#setColumnOrder(int[]) | |
569 * @see Tree#getColumnOrder() | |
570 * @see TreeColumn#getMoveable() | |
571 * @see DWT#Move | |
572 * | |
573 * @since 3.2 | |
574 */ | |
575 public void setMoveable (bool moveable) { | |
576 checkWidget(); | |
577 OS.gtk_tree_view_column_set_reorderable (handle, moveable); | |
578 } | |
579 | |
240 | 580 void setOrientation() { |
581 if ((parent.style & DWT.RIGHT_TO_LEFT) !is 0) { | |
582 if (buttonHandle !is null) { | |
583 OS.gtk_widget_set_direction (buttonHandle, OS.GTK_TEXT_DIR_RTL); | |
584 display.doSetDirectionProc(buttonHandle, OS.GTK_TEXT_DIR_RTL); | |
585 } | |
586 } | |
587 } | |
588 | |
90 | 589 /** |
590 * Sets the resizable attribute. A column that is | |
591 * not resizable cannot be dragged by the user but | |
592 * may be resized by the programmer. | |
593 * | |
594 * @param resizable the resize attribute | |
595 * | |
596 * @exception DWTException <ul> | |
597 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
598 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
599 * </ul> | |
600 */ | |
601 public void setResizable (bool resizable) { | |
602 checkWidget(); | |
603 OS.gtk_tree_view_column_set_resizable (handle, resizable); | |
604 } | |
605 | |
238 | 606 public override void setText (String string) { |
90 | 607 checkWidget(); |
608 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | |
609 super.setText (string); | |
610 char [] chars = fixMnemonic (string); | |
248
34409a2fc053
Fix call OS.gtk_label_set_text_with_mnemonic with valid ptr, even for zero length strings.
Frank Benoit <benoit@tionex.de>
parents:
240
diff
changeset
|
611 OS.gtk_label_set_text_with_mnemonic (labelHandle, chars.toStringzValidPtr()); |
90 | 612 if (string.length !is 0) { |
613 OS.gtk_widget_show (labelHandle); | |
614 } else { | |
615 OS.gtk_widget_hide (labelHandle); | |
616 } | |
617 } | |
618 | |
619 /** | |
620 * Sets the receiver's tool tip text to the argument, which | |
621 * may be null indicating that no tool tip text should be shown. | |
622 * | |
623 * @param string the new tool tip text (or null) | |
624 * | |
625 * @exception DWTException <ul> | |
626 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
627 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
628 * </ul> | |
629 * | |
630 * @since 3.2 | |
631 */ | |
238 | 632 public void setToolTipText (String string) { |
90 | 633 checkWidget(); |
634 Shell shell = parent._getShell (); | |
635 setToolTipText (shell, string); | |
636 toolTipText = string; | |
637 } | |
638 | |
238 | 639 void setToolTipText (Shell shell, String newString) { |
90 | 640 shell.setToolTipText (buttonHandle, newString); |
641 } | |
642 | |
643 /** | |
644 * Sets the width of the receiver. | |
645 * | |
646 * @param width the new width | |
647 * | |
648 * @exception DWTException <ul> | |
649 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
650 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
651 * </ul> | |
652 */ | |
653 public void setWidth (int width) { | |
654 checkWidget(); | |
655 if (width < 0) return; | |
656 if (width is lastWidth) return; | |
657 if (width > 0) { | |
658 useFixedWidth = true; | |
659 OS.gtk_tree_view_column_set_fixed_width (handle, width); | |
660 } | |
661 /* | |
662 * Bug in GTK. For some reason, calling gtk_tree_view_column_set_visible() | |
663 * when the parent is not realized fails to show the column. The fix is to | |
664 * ensure that the table has been realized. | |
665 */ | |
666 if (width !is 0) OS.gtk_widget_realize (parent.handle); | |
667 OS.gtk_tree_view_column_set_visible (handle, width !is 0); | |
668 lastWidth = width; | |
669 sendEvent (DWT.Resize); | |
670 } | |
671 | |
672 } |