comparison dwt/widgets/Button.d @ 44:dfcb4aee42d4

Button and ImageList
author Frank Benoit <benoit@tionex.de>
date Fri, 11 Jan 2008 06:21:10 +0100
parents c86fc3d50cfa
children 93981635e709
comparison
equal deleted inserted replaced
43:ecf39b275c8d 44:dfcb4aee42d4
10 *******************************************************************************/ 10 *******************************************************************************/
11 module dwt.widgets.Button; 11 module dwt.widgets.Button;
12 12
13 import dwt.widgets.Control; 13 import dwt.widgets.Control;
14 14
15 class Button : Control { 15 import dwt.internal.gtk.OS;
16 } 16 import dwt.SWT;
17 17 import dwt.graphics.Point;
18 /+ 18 import dwt.graphics.Image;
19 import dwt.internal.*; 19 import dwt.widgets.ImageList;
20 import dwt.internal.gtk.*; 20 import dwt.widgets.Composite;
21 import dwt.*; 21 import dwt.events.SelectionListener;
22 import dwt.graphics.*; 22 import dwt.widgets.TypedListener;
23 import dwt.events.*; 23 import dwt.widgets.Decorations;
24
25 import tango.stdc.stringz;
24 26
25 /** 27 /**
26 * Instances of this class represent a selectable user interface object that 28 * Instances of this class represent a selectable user interface object that
27 * issues notification when pressed and released. 29 * issues notification when pressed and released.
28 * <dl> 30 * <dl>
43 * </p><p> 45 * </p><p>
44 * IMPORTANT: This class is intended to be subclassed <em>only</em> 46 * IMPORTANT: This class is intended to be subclassed <em>only</em>
45 * within the SWT implementation. 47 * within the SWT implementation.
46 * </p> 48 * </p>
47 */ 49 */
48 public class Button extends Control { 50 public class Button : Control {
49 int /*long*/ boxHandle, labelHandle, imageHandle, arrowHandle, groupHandle; 51 GtkWidget* boxHandle, labelHandle, imageHandle, arrowHandle, groupHandle;
50 boolean selected; 52 bool selected;
51 ImageList imageList; 53 ImageList imageList;
52 Image image; 54 Image image;
53 String text; 55 char[] text;
54 56
55 /** 57 /**
56 * Constructs a new instance of this class given its parent 58 * Constructs a new instance of this class given its parent
57 * and a style value describing its behavior and appearance. 59 * and a style value describing its behavior and appearance.
58 * <p> 60 * <p>
86 * @see SWT#RIGHT 88 * @see SWT#RIGHT
87 * @see SWT#CENTER 89 * @see SWT#CENTER
88 * @see Widget#checkSubclass 90 * @see Widget#checkSubclass
89 * @see Widget#getStyle 91 * @see Widget#getStyle
90 */ 92 */
91 public Button (Composite parent, int style) { 93 public this (Composite parent, int style) {
92 super (parent, checkStyle (style)); 94 super (parent, checkStyle (style));
93 } 95 }
94 96
95 static int checkStyle (int style) { 97 static int checkStyle (int style) {
96 style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0); 98 style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
97 if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) { 99 if ((style & (SWT.PUSH | SWT.TOGGLE)) !is 0) {
98 return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0); 100 return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
99 } 101 }
100 if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { 102 if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) {
101 return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0); 103 return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
102 } 104 }
103 if ((style & SWT.ARROW) != 0) { 105 if ((style & SWT.ARROW) !is 0) {
104 style |= SWT.NO_FOCUS; 106 style |= SWT.NO_FOCUS;
105 return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0); 107 return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0);
106 } 108 }
107 return style; 109 return style;
108 } 110 }
131 * @see #removeSelectionListener 133 * @see #removeSelectionListener
132 * @see SelectionEvent 134 * @see SelectionEvent
133 */ 135 */
134 public void addSelectionListener (SelectionListener listener) { 136 public void addSelectionListener (SelectionListener listener) {
135 checkWidget (); 137 checkWidget ();
136 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 138 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT);
137 TypedListener typedListener = new TypedListener (listener); 139 TypedListener typedListener = new TypedListener (listener);
138 addListener (SWT.Selection,typedListener); 140 addListener (SWT.Selection,typedListener);
139 addListener (SWT.DefaultSelection,typedListener); 141 addListener (SWT.DefaultSelection,typedListener);
140 } 142 }
141 143
142 public Point computeSize (int wHint, int hHint, boolean changed) { 144 public Point computeSize (int wHint, int hHint, bool changed) {
143 checkWidget (); 145 checkWidget ();
144 if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; 146 if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0;
145 if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; 147 if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0;
146 /* 148 /*
147 * Feature in GTK, GtkCheckButton and GtkRadioButton allocate 149 * Feature in GTK, GtkCheckButton and GtkRadioButton allocate
148 * only the minimum size necessary for its child. This causes the child 150 * only the minimum size necessary for its child. This causes the child
149 * alignment to fail. The fix is to set the child size to the size 151 * alignment to fail. The fix is to set the child size to the size
150 * of the button. 152 * of the button.
151 */ 153 */
152 forceResize (); 154 forceResize ();
153 int [] reqWidth = null, reqHeight = null; 155 int reqWidth = -1, reqHeight = -1;
154 if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { 156 if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) {
155 reqWidth = new int [1]; 157 OS.gtk_widget_get_size_request (boxHandle, &reqWidth, &reqHeight);
156 reqHeight = new int [1];
157 OS.gtk_widget_get_size_request (boxHandle, reqWidth, reqHeight);
158 OS.gtk_widget_set_size_request (boxHandle, -1, -1); 158 OS.gtk_widget_set_size_request (boxHandle, -1, -1);
159 } 159 }
160 Point size = computeNativeSize (handle, wHint, hHint, changed); 160 Point size = computeNativeSize (handle, wHint, hHint, changed);
161 if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { 161 if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) {
162 OS.gtk_widget_set_size_request (boxHandle, reqWidth [0], reqHeight [0]); 162 OS.gtk_widget_set_size_request (boxHandle, reqWidth, reqHeight);
163 } 163 }
164 if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) { 164 if (wHint !is SWT.DEFAULT || hHint !is SWT.DEFAULT) {
165 if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_CAN_DEFAULT) != 0) { 165 if ((OS.GTK_WIDGET_FLAGS (handle) & OS.GTK_CAN_DEFAULT) !is 0) {
166 int /*long*/ [] buffer = new int /*long*/ [1]; 166 GtkBorder* border = new GtkBorder ();
167 GtkBorder border = new GtkBorder (); 167 GtkBorder* buffer;
168 OS.gtk_widget_style_get (handle, OS.default_border, buffer, 0); 168 OS.gtk_widget_style_get1 (handle, OS.default_border.ptr, cast(int*)&buffer );
169 if (buffer[0] != 0) { 169 if (buffer !is null) {
170 OS.memmove (border, buffer[0], GtkBorder.sizeof); 170 border = buffer;
171 } else { 171 } else {
172 /* Use the GTK+ default value of 1 for each. */ 172 /* Use the GTK+ default value of 1 for each. */
173 border.left = border.right = border.top = border.bottom = 1; 173 border.left = border.right = border.top = border.bottom = 1;
174 } 174 }
175 if (wHint != SWT.DEFAULT) size.x += border.left + border.right; 175 if (wHint !is SWT.DEFAULT) size.x += border.left + border.right;
176 if (hHint != SWT.DEFAULT) size.y += border.top + border.bottom; 176 if (hHint !is SWT.DEFAULT) size.y += border.top + border.bottom;
177 } 177 }
178 } 178 }
179 return size; 179 return size;
180 } 180 }
181 181
182 void createHandle (int index) { 182 void createHandle (int index) {
183 state |= HANDLE; 183 state |= HANDLE;
184 if ((style & SWT.PUSH) == 0) state |= THEME_BACKGROUND; 184 if ((style & SWT.PUSH) is 0) state |= THEME_BACKGROUND;
185 int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH; 185 int bits = SWT.ARROW | SWT.TOGGLE | SWT.CHECK | SWT.RADIO | SWT.PUSH;
186 fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); 186 fixedHandle = cast(GtkWidget*)OS.g_object_new (display.gtk_fixed_get_type (), null);
187 if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); 187 if (fixedHandle is null) error (SWT.ERROR_NO_HANDLES);
188 OS.gtk_fixed_set_has_window (fixedHandle, true); 188 OS.gtk_fixed_set_has_window (cast(GtkFixed*)fixedHandle, true);
189 switch (style & bits) { 189 switch (style & bits) {
190 case SWT.ARROW: 190 case SWT.ARROW:
191 int arrow_type = OS.GTK_ARROW_UP; 191 int arrow_type = OS.GTK_ARROW_UP;
192 if ((style & SWT.UP) != 0) arrow_type = OS.GTK_ARROW_UP; 192 if ((style & SWT.UP) !is 0) arrow_type = OS.GTK_ARROW_UP;
193 if ((style & SWT.DOWN) != 0) arrow_type = OS.GTK_ARROW_DOWN; 193 if ((style & SWT.DOWN) !is 0) arrow_type = OS.GTK_ARROW_DOWN;
194 if ((style & SWT.LEFT) != 0) arrow_type = OS.GTK_ARROW_LEFT; 194 if ((style & SWT.LEFT) !is 0) arrow_type = OS.GTK_ARROW_LEFT;
195 if ((style & SWT.RIGHT) != 0) arrow_type = OS.GTK_ARROW_RIGHT; 195 if ((style & SWT.RIGHT) !is 0) arrow_type = OS.GTK_ARROW_RIGHT;
196 handle = OS.gtk_button_new (); 196 handle = OS.gtk_button_new ();
197 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 197 if (handle is null) error (SWT.ERROR_NO_HANDLES);
198 arrowHandle = OS.gtk_arrow_new (arrow_type, OS.GTK_SHADOW_OUT); 198 arrowHandle = OS.gtk_arrow_new (arrow_type, OS.GTK_SHADOW_OUT);
199 if (arrowHandle == 0) error (SWT.ERROR_NO_HANDLES); 199 if (arrowHandle is null) error (SWT.ERROR_NO_HANDLES);
200 break; 200 break;
201 case SWT.TOGGLE: 201 case SWT.TOGGLE:
202 handle = OS.gtk_toggle_button_new (); 202 handle = OS.gtk_toggle_button_new ();
203 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 203 if (handle is null) error (SWT.ERROR_NO_HANDLES);
204 break; 204 break;
205 case SWT.CHECK: 205 case SWT.CHECK:
206 handle = OS.gtk_check_button_new (); 206 handle = OS.gtk_check_button_new ();
207 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 207 if (handle is null) error (SWT.ERROR_NO_HANDLES);
208 break; 208 break;
209 case SWT.RADIO: 209 case SWT.RADIO:
210 /* 210 /*
211 * Feature in GTK. In GTK, radio button must always be part of 211 * Feature in GTK. In GTK, radio button must always be part of
212 * a radio button group. In a GTK radio group, one button is always 212 * a radio button group. In a GTK radio group, one button is always
216 * buttons outside of radio groups. The fix is to create a hidden 216 * buttons outside of radio groups. The fix is to create a hidden
217 * radio button for each radio button we create and add them 217 * radio button for each radio button we create and add them
218 * to the same group. This allows the visible button to be 218 * to the same group. This allows the visible button to be
219 * unselected. 219 * unselected.
220 */ 220 */
221 groupHandle = OS.gtk_radio_button_new (0); 221 groupHandle = cast(GtkWidget*)OS.gtk_radio_button_new (null);
222 if (groupHandle == 0) error (SWT.ERROR_NO_HANDLES); 222 if (groupHandle is null) error (SWT.ERROR_NO_HANDLES);
223 OS.g_object_ref (groupHandle); 223 OS.g_object_ref (groupHandle);
224 OS.gtk_object_sink (groupHandle); 224 OS.gtk_object_sink (cast(GtkObject*)groupHandle);
225 handle = OS.gtk_radio_button_new (OS.gtk_radio_button_get_group (groupHandle)); 225 handle = OS.gtk_radio_button_new ( OS.gtk_radio_button_get_group (cast(GtkRadioButton*)groupHandle));
226 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 226 if (handle is null) error (SWT.ERROR_NO_HANDLES);
227 break; 227 break;
228 case SWT.PUSH: 228 case SWT.PUSH:
229 default: 229 default:
230 handle = OS.gtk_button_new (); 230 handle = OS.gtk_button_new ();
231 if (handle == 0) error (SWT.ERROR_NO_HANDLES); 231 if (handle is null) error (SWT.ERROR_NO_HANDLES);
232 OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_DEFAULT); 232 OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_DEFAULT);
233 break; 233 break;
234 } 234 }
235 if ((style & SWT.ARROW) != 0) { 235 if ((style & SWT.ARROW) !is 0) {
236 OS.gtk_container_add (handle, arrowHandle); 236 OS.gtk_container_add (cast(GtkContainer*)handle, arrowHandle);
237 } else { 237 } else {
238 boxHandle = OS.gtk_hbox_new (false, 4); 238 boxHandle = OS.gtk_hbox_new (false, 4);
239 if (boxHandle == 0) error (SWT.ERROR_NO_HANDLES); 239 if (boxHandle is null) error (SWT.ERROR_NO_HANDLES);
240 labelHandle = OS.gtk_label_new_with_mnemonic (null); 240 labelHandle = OS.gtk_label_new_with_mnemonic (null);
241 if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES); 241 if (labelHandle is null) error (SWT.ERROR_NO_HANDLES);
242 imageHandle = OS.gtk_image_new (); 242 imageHandle = OS.gtk_image_new ();
243 if (imageHandle == 0) error (SWT.ERROR_NO_HANDLES); 243 if (imageHandle is null) error (SWT.ERROR_NO_HANDLES);
244 OS.gtk_container_add (handle, boxHandle); 244 OS.gtk_container_add (cast(GtkContainer*)handle, boxHandle);
245 OS.gtk_container_add (boxHandle, imageHandle); 245 OS.gtk_container_add (cast(GtkContainer*)boxHandle, imageHandle);
246 OS.gtk_container_add (boxHandle, labelHandle); 246 OS.gtk_container_add (cast(GtkContainer*)boxHandle, labelHandle);
247 } 247 }
248 OS.gtk_container_add (fixedHandle, handle); 248 OS.gtk_container_add (cast(GtkContainer*)fixedHandle, handle);
249 249
250 if ((style & SWT.ARROW) != 0) return; 250 if ((style & SWT.ARROW) !is 0) return;
251 _setAlignment (style & (SWT.LEFT | SWT.CENTER | SWT.RIGHT)); 251 _setAlignment (style & (SWT.LEFT | SWT.CENTER | SWT.RIGHT));
252 } 252 }
253 253
254 void createWidget (int index) { 254 void createWidget (int index) {
255 super.createWidget (index); 255 super.createWidget (index);
256 text = ""; 256 text = "";
257 } 257 }
258 258
259 void deregister () { 259 void deregister () {
260 super.deregister (); 260 super.deregister ();
261 if (boxHandle != 0) display.removeWidget (boxHandle); 261 if (boxHandle !is null) display.removeWidget (boxHandle);
262 if (labelHandle != 0) display.removeWidget (labelHandle); 262 if (labelHandle !is null) display.removeWidget (labelHandle);
263 if (imageHandle != 0) display.removeWidget (imageHandle); 263 if (imageHandle !is null) display.removeWidget (imageHandle);
264 if (arrowHandle != 0) display.removeWidget (arrowHandle); 264 if (arrowHandle !is null) display.removeWidget (arrowHandle);
265 } 265 }
266 266
267 int /*long*/ fontHandle () { 267 override GtkWidget* fontHandle () {
268 if (labelHandle != 0) return labelHandle; 268 if (labelHandle !is null) return labelHandle;
269 return super.fontHandle (); 269 return super.fontHandle ();
270 } 270 }
271 271
272 /** 272 /**
273 * Returns a value which describes the position of the 273 * Returns a value which describes the position of the
285 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 285 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
286 * </ul> 286 * </ul>
287 */ 287 */
288 public int getAlignment () { 288 public int getAlignment () {
289 checkWidget (); 289 checkWidget ();
290 if ((style & SWT.ARROW) != 0) { 290 if ((style & SWT.ARROW) !is 0) {
291 if ((style & SWT.UP) != 0) return SWT.UP; 291 if ((style & SWT.UP) !is 0) return SWT.UP;
292 if ((style & SWT.DOWN) != 0) return SWT.DOWN; 292 if ((style & SWT.DOWN) !is 0) return SWT.DOWN;
293 if ((style & SWT.LEFT) != 0) return SWT.LEFT; 293 if ((style & SWT.LEFT) !is 0) return SWT.LEFT;
294 if ((style & SWT.RIGHT) != 0) return SWT.RIGHT; 294 if ((style & SWT.RIGHT) !is 0) return SWT.RIGHT;
295 return SWT.UP; 295 return SWT.UP;
296 } 296 }
297 if ((style & SWT.LEFT) != 0) return SWT.LEFT; 297 if ((style & SWT.LEFT) !is 0) return SWT.LEFT;
298 if ((style & SWT.CENTER) != 0) return SWT.CENTER; 298 if ((style & SWT.CENTER) !is 0) return SWT.CENTER;
299 if ((style & SWT.RIGHT) != 0) return SWT.RIGHT; 299 if ((style & SWT.RIGHT) !is 0) return SWT.RIGHT;
300 return SWT.LEFT; 300 return SWT.LEFT;
301 } 301 }
302 302
303 /** 303 /**
304 * Returns the receiver's image if it has one, or null 304 * Returns the receiver's image if it has one, or null
314 public Image getImage () { 314 public Image getImage () {
315 checkWidget (); 315 checkWidget ();
316 return image; 316 return image;
317 } 317 }
318 318
319 String getNameText () { 319 char[] getNameText () {
320 return getText (); 320 return getText ();
321 } 321 }
322 322
323 /** 323 /**
324 * Returns <code>true</code> if the receiver is selected, 324 * Returns <code>true</code> if the receiver is selected,
334 * @exception SWTException <ul> 334 * @exception SWTException <ul>
335 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 335 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
336 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 336 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
337 * </ul> 337 * </ul>
338 */ 338 */
339 public boolean getSelection () { 339 public bool getSelection () {
340 checkWidget (); 340 checkWidget ();
341 if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false; 341 if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) is 0) return false;
342 return OS.gtk_toggle_button_get_active (handle); 342 return cast(bool)OS.gtk_toggle_button_get_active (cast(GtkToggleButton*)handle);
343 } 343 }
344 344
345 /** 345 /**
346 * Returns the receiver's text, which will be an empty 346 * Returns the receiver's text, which will be an empty
347 * string if it has never been set or if the receiver is 347 * string if it has never been set or if the receiver is
352 * @exception SWTException <ul> 352 * @exception SWTException <ul>
353 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 353 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
354 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 354 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
355 * </ul> 355 * </ul>
356 */ 356 */
357 public String getText () { 357 public char[] getText () {
358 checkWidget(); 358 checkWidget();
359 if ((style & SWT.ARROW) != 0) return ""; 359 if ((style & SWT.ARROW) !is 0) return "";
360 return text; 360 return text;
361 } 361 }
362 362
363 int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { 363 override int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* event) {
364 int /*long*/ result = super.gtk_button_press_event (widget, event); 364 auto result = super.gtk_button_press_event (widget, event);
365 if (result != 0) return result; 365 if (result !is 0) return result;
366 if ((style & SWT.RADIO) != 0) selected = getSelection (); 366 if ((style & SWT.RADIO) !is 0) selected = getSelection ();
367 return result; 367 return result;
368 } 368 }
369 369
370 int /*long*/ gtk_clicked (int /*long*/ widget) { 370 override int /*long*/ gtk_clicked (GtkWidget* widget) {
371 if ((style & SWT.RADIO) != 0) { 371 if ((style & SWT.RADIO) !is 0) {
372 if ((parent.getStyle () & SWT.NO_RADIO_GROUP) != 0) { 372 if ((parent.getStyle () & SWT.NO_RADIO_GROUP) !is 0) {
373 setSelection (!selected); 373 setSelection (!selected);
374 } else { 374 } else {
375 selectRadio (); 375 selectRadio ();
376 } 376 }
377 } 377 }
378 postEvent (SWT.Selection); 378 postEvent (SWT.Selection);
379 return 0; 379 return 0;
380 } 380 }
381 381
382 int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) { 382 override int /*long*/ gtk_focus_in_event (GtkWidget* widget, GdkEventFocus* event) {
383 int /*long*/ result = super.gtk_focus_in_event (widget, event); 383 auto result = super.gtk_focus_in_event (widget, event);
384 // widget could be disposed at this point 384 // widget could be disposed at this point
385 if (handle == 0) return 0; 385 if (handle is null) return 0;
386 if ((style & SWT.PUSH) != 0 && OS.GTK_WIDGET_HAS_DEFAULT (handle)) { 386 if ((style & SWT.PUSH) !is 0 && OS.GTK_WIDGET_HAS_DEFAULT (handle)) {
387 Decorations menuShell = menuShell (); 387 Decorations menuShell = menuShell ();
388 menuShell.defaultButton = this; 388 menuShell.defaultButton = this;
389 } 389 }
390 return result; 390 return result;
391 } 391 }
392 392
393 int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) { 393 override int /*long*/ gtk_focus_out_event (GtkWidget* widget, GdkEventFocus* event) {
394 int /*long*/ result = super.gtk_focus_out_event (widget, event); 394 auto result = super.gtk_focus_out_event (widget, event);
395 // widget could be disposed at this point 395 // widget could be disposed at this point
396 if (handle == 0) return 0; 396 if (handle is null) return 0;
397 if ((style & SWT.PUSH) != 0 && !OS.GTK_WIDGET_HAS_DEFAULT (handle)) { 397 if ((style & SWT.PUSH) !is 0 && !OS.GTK_WIDGET_HAS_DEFAULT (handle)) {
398 Decorations menuShell = menuShell (); 398 Decorations menuShell = menuShell ();
399 if (menuShell.defaultButton == this) { 399 if (menuShell.defaultButton is this) {
400 menuShell.defaultButton = null; 400 menuShell.defaultButton = null;
401 } 401 }
402 } 402 }
403 return result; 403 return result;
404 } 404 }
405 405
406 int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) { 406 override int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* event) {
407 int /*long*/ result = super.gtk_key_press_event (widget, event); 407 auto result = super.gtk_key_press_event (widget, event);
408 if (result != 0) return result; 408 if (result !is 0) return result;
409 if ((style & SWT.RADIO) != 0) selected = getSelection (); 409 if ((style & SWT.RADIO) !is 0) selected = getSelection ();
410 return result; 410 return result;
411 } 411 }
412 412
413 void hookEvents () { 413 void hookEvents () {
414 super.hookEvents(); 414 super.hookEvents();
415 OS.g_signal_connect_closure (handle, OS.clicked, display.closures [CLICKED], false); 415 OS.g_signal_connect_closure (handle, OS.clicked.ptr, display.closures [CLICKED], false);
416 if (labelHandle != 0) { 416 if (labelHandle !is null) {
417 OS.g_signal_connect_closure_by_id (labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false); 417 OS.g_signal_connect_closure_by_id (cast(void*)labelHandle, display.signalIds [MNEMONIC_ACTIVATE], 0, display.closures [MNEMONIC_ACTIVATE], false);
418 } 418 }
419 } 419 }
420 420
421 boolean isDescribedByLabel () { 421 bool isDescribedByLabel () {
422 return false; 422 return false;
423 } 423 }
424 424
425 boolean mnemonicHit (char key) { 425 alias Control.mnemonicHit mnemonicHit;
426 if (labelHandle == 0) return false; 426 bool mnemonicHit (char key) {
427 boolean result = super.mnemonicHit (labelHandle, key); 427 if (labelHandle is null) return false;
428 bool result = super.mnemonicHit (labelHandle, key);
428 if (result) setFocus (); 429 if (result) setFocus ();
429 return result; 430 return result;
430 } 431 }
431 432
432 boolean mnemonicMatch (char key) { 433 alias Control.mnemonicMatch mnemonicMatch;
433 if (labelHandle == 0) return false; 434 bool mnemonicMatch (char key) {
435 if (labelHandle is null) return false;
434 return mnemonicMatch (labelHandle, key); 436 return mnemonicMatch (labelHandle, key);
435 } 437 }
436 438
437 void register () { 439 void register () {
438 super.register (); 440 super.register ();
439 if (boxHandle != 0) display.addWidget (boxHandle, this); 441 if (boxHandle !is null) display.addWidget (boxHandle, this);
440 if (labelHandle != 0) display.addWidget (labelHandle, this); 442 if (labelHandle !is null) display.addWidget (labelHandle, this);
441 if (imageHandle != 0) display.addWidget (imageHandle, this); 443 if (imageHandle !is null) display.addWidget (imageHandle, this);
442 if (arrowHandle != 0) display.addWidget (arrowHandle, this); 444 if (arrowHandle !is null) display.addWidget (arrowHandle, this);
443 } 445 }
444 446
445 void releaseHandle () { 447 void releaseHandle () {
446 super.releaseHandle (); 448 super.releaseHandle ();
447 boxHandle = imageHandle = labelHandle = arrowHandle = 0; 449 boxHandle = imageHandle = labelHandle = arrowHandle = null;
448 } 450 }
449 451
450 void releaseWidget () { 452 void releaseWidget () {
451 super.releaseWidget (); 453 super.releaseWidget ();
452 if (groupHandle != 0) OS.g_object_unref (groupHandle); 454 if (groupHandle !is null) OS.g_object_unref (groupHandle);
453 groupHandle = 0; 455 groupHandle = null;
454 if (imageList != null) imageList.dispose (); 456 if (imageList !is null) imageList.dispose ();
455 imageList = null; 457 imageList = null;
456 image = null; 458 image = null;
457 text = null; 459 text = null;
458 } 460 }
459 461
474 * @see SelectionListener 476 * @see SelectionListener
475 * @see #addSelectionListener 477 * @see #addSelectionListener
476 */ 478 */
477 public void removeSelectionListener (SelectionListener listener) { 479 public void removeSelectionListener (SelectionListener listener) {
478 checkWidget(); 480 checkWidget();
479 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); 481 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT);
480 if (eventTable == null) return; 482 if (eventTable is null) return;
481 eventTable.unhook (SWT.Selection, listener); 483 eventTable.unhook (SWT.Selection, listener);
482 eventTable.unhook (SWT.DefaultSelection,listener); 484 eventTable.unhook (SWT.DefaultSelection,listener);
483 } 485 }
484 486
485 void resizeHandle (int width, int height) { 487 void resizeHandle (int width, int height) {
488 * Feature in GTK, GtkCheckButton and GtkRadioButton allocate 490 * Feature in GTK, GtkCheckButton and GtkRadioButton allocate
489 * only the minimum size necessary for its child. This causes the child 491 * only the minimum size necessary for its child. This causes the child
490 * alignment to fail. The fix is to set the child size to the size 492 * alignment to fail. The fix is to set the child size to the size
491 * of the button. 493 * of the button.
492 */ 494 */
493 if ((style & (SWT.CHECK | SWT.RADIO)) != 0) { 495 if ((style & (SWT.CHECK | SWT.RADIO)) !is 0) {
494 OS.gtk_widget_set_size_request (boxHandle, width, -1); 496 OS.gtk_widget_set_size_request (boxHandle, width, -1);
495 } 497 }
496 } 498 }
497 499
498 void selectRadio () { 500 void selectRadio () {
504 * with radio tool and menu items. The commented code 506 * with radio tool and menu items. The commented code
505 * implements this behavior. 507 * implements this behavior.
506 */ 508 */
507 // int index = 0; 509 // int index = 0;
508 // Control [] children = parent._getChildren (); 510 // Control [] children = parent._getChildren ();
509 // while (index < children.length && children [index] != this) index++; 511 // while (index < children.length && children [index] !is this) index++;
510 // int i = index - 1; 512 // int i = index - 1;
511 // while (i >= 0 && children [i].setRadioSelection (false)) --i; 513 // while (i >= 0 && children [i].setRadioSelection (false)) --i;
512 // int j = index + 1; 514 // int j = index + 1;
513 // while (j < children.length && children [j].setRadioSelection (false)) j++; 515 // while (j < children.length && children [j].setRadioSelection (false)) j++;
514 // setSelection (true); 516 // setSelection (true);
515 Control [] children = parent._getChildren (); 517 Control [] children = parent._getChildren ();
516 for (int i=0; i<children.length; i++) { 518 for (int i=0; i<children.length; i++) {
517 Control child = children [i]; 519 Control child = children [i];
518 if (this != child) child.setRadioSelection (false); 520 if (this !is child) child.setRadioSelection (false);
519 } 521 }
520 setSelection (true); 522 setSelection (true);
521 } 523 }
522 524
523 /** 525 /**
540 checkWidget (); 542 checkWidget ();
541 _setAlignment (alignment); 543 _setAlignment (alignment);
542 } 544 }
543 545
544 void _setAlignment (int alignment) { 546 void _setAlignment (int alignment) {
545 if ((style & SWT.ARROW) != 0) { 547 if ((style & SWT.ARROW) !is 0) {
546 if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) == 0) return; 548 if ((style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) is 0) return;
547 style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT); 549 style &= ~(SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
548 style |= alignment & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT); 550 style |= alignment & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT);
549 int arrow_type = OS.GTK_ARROW_UP; 551 int arrow_type = OS.GTK_ARROW_UP;
550 boolean isRTL = (style & SWT.RIGHT_TO_LEFT) != 0; 552 bool isRTL = (style & SWT.RIGHT_TO_LEFT) !is 0;
551 switch (alignment) { 553 switch (alignment) {
552 case SWT.UP: arrow_type = OS.GTK_ARROW_UP; break; 554 case SWT.UP: arrow_type = OS.GTK_ARROW_UP; break;
553 case SWT.DOWN: arrow_type = OS.GTK_ARROW_DOWN; break; 555 case SWT.DOWN: arrow_type = OS.GTK_ARROW_DOWN; break;
554 case SWT.LEFT: arrow_type = isRTL ? OS.GTK_ARROW_RIGHT : OS.GTK_ARROW_LEFT; break; 556 case SWT.LEFT: arrow_type = isRTL ? OS.GTK_ARROW_RIGHT : OS.GTK_ARROW_LEFT; break;
555 case SWT.RIGHT: arrow_type = isRTL ? OS.GTK_ARROW_LEFT : OS.GTK_ARROW_RIGHT; break; 557 case SWT.RIGHT: arrow_type = isRTL ? OS.GTK_ARROW_LEFT : OS.GTK_ARROW_RIGHT; break;
556 } 558 }
557 OS.gtk_arrow_set (arrowHandle, arrow_type, OS.GTK_SHADOW_OUT); 559 OS.gtk_arrow_set (cast(GtkArrow*)arrowHandle, arrow_type, OS.GTK_SHADOW_OUT);
558 return; 560 return;
559 } 561 }
560 if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return; 562 if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) is 0) return;
561 style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER); 563 style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
562 style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER); 564 style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
563 /* Alignment not honoured when image and text are visible */ 565 /* Alignment not honoured when image and text are visible */
564 boolean bothVisible = OS.GTK_WIDGET_VISIBLE (labelHandle) && OS.GTK_WIDGET_VISIBLE (imageHandle); 566 bool bothVisible = OS.GTK_WIDGET_VISIBLE (labelHandle) && OS.GTK_WIDGET_VISIBLE (imageHandle);
565 if (bothVisible) { 567 if (bothVisible) {
566 if ((style & (SWT.RADIO | SWT.CHECK)) != 0) alignment = SWT.LEFT; 568 if ((style & (SWT.RADIO | SWT.CHECK)) !is 0) alignment = SWT.LEFT;
567 if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) alignment = SWT.CENTER; 569 if ((style & (SWT.PUSH | SWT.TOGGLE)) !is 0) alignment = SWT.CENTER;
568 } 570 }
569 if ((alignment & SWT.LEFT) != 0) { 571 if ((alignment & SWT.LEFT) !is 0) {
570 if (bothVisible) { 572 if (bothVisible) {
571 OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_START); 573 OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_START);
572 OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_START); 574 OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_START);
573 } 575 }
574 OS.gtk_misc_set_alignment (labelHandle, 0.0f, 0.5f); 576 OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.0f, 0.5f);
575 OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_LEFT); 577 OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_LEFT);
576 OS.gtk_misc_set_alignment (imageHandle, 0.0f, 0.5f); 578 OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 0.0f, 0.5f);
577 return; 579 return;
578 } 580 }
579 if ((alignment & SWT.CENTER) != 0) { 581 if ((alignment & SWT.CENTER) !is 0) {
580 if (bothVisible) { 582 if (bothVisible) {
581 OS.gtk_box_set_child_packing (boxHandle, labelHandle, true, true, 0, OS.GTK_PACK_END); 583 OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, labelHandle, true, true, 0, OS.GTK_PACK_END);
582 OS.gtk_box_set_child_packing (boxHandle, imageHandle, true, true, 0, OS.GTK_PACK_START); 584 OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, imageHandle, true, true, 0, OS.GTK_PACK_START);
583 OS.gtk_misc_set_alignment (labelHandle, 0f, 0.5f); 585 OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0f, 0.5f);
584 OS.gtk_misc_set_alignment (imageHandle, 1f, 0.5f); 586 OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 1f, 0.5f);
585 } else { 587 } else {
586 OS.gtk_misc_set_alignment (labelHandle, 0.5f, 0.5f); 588 OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 0.5f, 0.5f);
587 OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_CENTER); 589 OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_CENTER);
588 OS.gtk_misc_set_alignment (imageHandle, 0.5f, 0.5f); 590 OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 0.5f, 0.5f);
589 } 591 }
590 return; 592 return;
591 } 593 }
592 if ((alignment & SWT.RIGHT) != 0) { 594 if ((alignment & SWT.RIGHT) !is 0) {
593 if (bothVisible) { 595 if (bothVisible) {
594 OS.gtk_box_set_child_packing (boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_END); 596 OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, labelHandle, false, false, 0, OS.GTK_PACK_END);
595 OS.gtk_box_set_child_packing (boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_END); 597 OS.gtk_box_set_child_packing (cast(GtkBox*)boxHandle, imageHandle, false, false, 0, OS.GTK_PACK_END);
596 } 598 }
597 OS.gtk_misc_set_alignment (labelHandle, 1.0f, 0.5f); 599 OS.gtk_misc_set_alignment (cast(GtkMisc*)labelHandle, 1.0f, 0.5f);
598 OS.gtk_label_set_justify (labelHandle, OS.GTK_JUSTIFY_RIGHT); 600 OS.gtk_label_set_justify (cast(GtkLabel*)labelHandle, OS.GTK_JUSTIFY_RIGHT);
599 OS.gtk_misc_set_alignment (imageHandle, 1.0f, 0.5f); 601 OS.gtk_misc_set_alignment (cast(GtkMisc*)imageHandle, 1.0f, 0.5f);
600 return; 602 return;
601 } 603 }
602 } 604 }
603 605
604 void setBackgroundColor (GdkColor color) { 606 alias Control.setBackgroundColor setBackgroundColor;
607 override void setBackgroundColor (GdkColor* color) {
605 super.setBackgroundColor (color); 608 super.setBackgroundColor (color);
606 setBackgroundColor(fixedHandle, color); 609 setBackgroundColor(fixedHandle, color);
607 if (labelHandle != 0) setBackgroundColor(labelHandle, color); 610 if (labelHandle !is null) setBackgroundColor(labelHandle, color);
608 if (imageHandle != 0) setBackgroundColor(imageHandle, color); 611 if (imageHandle !is null) setBackgroundColor(imageHandle, color);
609 } 612 }
610 613
611 void setFontDescription (int /*long*/ font) { 614 void setFontDescription (PangoFontDescription* font) {
612 super.setFontDescription (font); 615 super.setFontDescription (font);
613 if (labelHandle != 0) OS.gtk_widget_modify_font (labelHandle, font); 616 if (labelHandle !is null) OS.gtk_widget_modify_font (labelHandle, font);
614 if (imageHandle != 0) OS.gtk_widget_modify_font (imageHandle, font); 617 if (imageHandle !is null) OS.gtk_widget_modify_font (imageHandle, font);
615 } 618 }
616 619
617 boolean setRadioSelection (boolean value) { 620 bool setRadioSelection (bool value) {
618 if ((style & SWT.RADIO) == 0) return false; 621 if ((style & SWT.RADIO) is 0) return false;
619 if (getSelection () != value) { 622 if (getSelection () !is value) {
620 setSelection (value); 623 setSelection (value);
621 postEvent (SWT.Selection); 624 postEvent (SWT.Selection);
622 } 625 }
623 return true; 626 return true;
624 } 627 }
625 628
626 void setForegroundColor (GdkColor color) { 629 alias Control.setForegroundColor setForegroundColor;
630 override void setForegroundColor (GdkColor* color) {
627 super.setForegroundColor (color); 631 super.setForegroundColor (color);
628 setForegroundColor (fixedHandle, color); 632 setForegroundColor (fixedHandle, color);
629 if (labelHandle != 0) setForegroundColor (labelHandle, color); 633 if (labelHandle !is null) setForegroundColor (labelHandle, color);
630 if (imageHandle != 0) setForegroundColor (imageHandle, color); 634 if (imageHandle !is null) setForegroundColor (imageHandle, color);
631 } 635 }
632 636
633 /** 637 /**
634 * Sets the receiver's image to the argument, which may be 638 * Sets the receiver's image to the argument, which may be
635 * <code>null</code> indicating that no image should be displayed. 639 * <code>null</code> indicating that no image should be displayed.
649 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 653 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
650 * </ul> 654 * </ul>
651 */ 655 */
652 public void setImage (Image image) { 656 public void setImage (Image image) {
653 checkWidget (); 657 checkWidget ();
654 if ((style & SWT.ARROW) != 0) return; 658 if ((style & SWT.ARROW) !is 0) return;
655 if (imageList != null) imageList.dispose (); 659 if (imageList !is null) imageList.dispose ();
656 imageList = null; 660 imageList = null;
657 if (image != null) { 661 if (image !is null) {
658 if (image.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); 662 if (image.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
659 imageList = new ImageList (); 663 imageList = new ImageList ();
660 int imageIndex = imageList.add (image); 664 int imageIndex = imageList.add (image);
661 int /*long*/ pixbuf = imageList.getPixbuf (imageIndex); 665 auto pixbuf = imageList.getPixbuf (imageIndex);
662 OS.gtk_image_set_from_pixbuf (imageHandle, pixbuf); 666 OS.gtk_image_set_from_pixbuf (cast(GtkImage*)imageHandle, pixbuf);
663 if (text.length () == 0) OS.gtk_widget_hide (labelHandle); 667 if (text.length is 0) OS.gtk_widget_hide (labelHandle);
664 OS.gtk_widget_show (imageHandle); 668 OS.gtk_widget_show (imageHandle);
665 } else { 669 } else {
666 OS.gtk_image_set_from_pixbuf (imageHandle, 0); 670 OS.gtk_image_set_from_pixbuf (cast(GtkImage*)imageHandle, null);
667 OS.gtk_widget_show (labelHandle); 671 OS.gtk_widget_show (labelHandle);
668 OS.gtk_widget_hide (imageHandle); 672 OS.gtk_widget_hide (imageHandle);
669 } 673 }
670 this.image = image; 674 this.image = image;
671 _setAlignment (style); 675 _setAlignment (style);
672 } 676 }
673 677
674 void setOrientation () { 678 void setOrientation () {
675 super.setOrientation (); 679 super.setOrientation ();
676 if ((style & SWT.RIGHT_TO_LEFT) != 0) { 680 if ((style & SWT.RIGHT_TO_LEFT) !is 0) {
677 if (labelHandle != 0) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL); 681 if (labelHandle !is null) OS.gtk_widget_set_direction (labelHandle, OS.GTK_TEXT_DIR_RTL);
678 if (imageHandle != 0) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL); 682 if (imageHandle !is null) OS.gtk_widget_set_direction (imageHandle, OS.GTK_TEXT_DIR_RTL);
679 if (arrowHandle != 0) { 683 if (arrowHandle !is null) {
680 switch (style & (SWT.LEFT | SWT.RIGHT)) { 684 switch (style & (SWT.LEFT | SWT.RIGHT)) {
681 case SWT.LEFT: OS.gtk_arrow_set (arrowHandle, OS.GTK_ARROW_RIGHT, OS.GTK_SHADOW_OUT); break; 685 case SWT.LEFT: OS.gtk_arrow_set (cast(GtkArrow*)arrowHandle, OS.GTK_ARROW_RIGHT, OS.GTK_SHADOW_OUT); break;
682 case SWT.RIGHT: OS.gtk_arrow_set (arrowHandle, OS.GTK_ARROW_LEFT, OS.GTK_SHADOW_OUT); break; 686 case SWT.RIGHT: OS.gtk_arrow_set (cast(GtkArrow*)arrowHandle, OS.GTK_ARROW_LEFT, OS.GTK_SHADOW_OUT); break;
683 } 687 }
684 } 688 }
685 } 689 }
686 } 690 }
687 691
699 * @exception SWTException <ul> 703 * @exception SWTException <ul>
700 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 704 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
701 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 705 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
702 * </ul> 706 * </ul>
703 */ 707 */
704 public void setSelection (boolean selected) { 708 public void setSelection (bool selected) {
705 checkWidget(); 709 checkWidget();
706 if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return; 710 if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) is 0) return;
707 OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED); 711 OS.g_signal_handlers_block_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, cast(void*)CLICKED);
708 OS.gtk_toggle_button_set_active (handle, selected); 712 OS.gtk_toggle_button_set_active (cast(GtkToggleButton*)handle, selected);
709 if ((style & SWT.RADIO) != 0) OS.gtk_toggle_button_set_active (groupHandle, !selected); 713 if ((style & SWT.RADIO) !is 0) OS.gtk_toggle_button_set_active (cast(GtkToggleButton*)groupHandle, !selected);
710 OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, CLICKED); 714 OS.g_signal_handlers_unblock_matched (handle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, cast(void*)CLICKED);
711 } 715 }
712 716
713 /** 717 /**
714 * Sets the receiver's text. 718 * Sets the receiver's text.
715 * <p> 719 * <p>
739 * @exception SWTException <ul> 743 * @exception SWTException <ul>
740 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 744 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
741 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 745 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
742 * </ul> 746 * </ul>
743 */ 747 */
744 public void setText (String string) { 748 public void setText (char[] string) {
745 checkWidget (); 749 checkWidget ();
746 if (string == null) error (SWT.ERROR_NULL_ARGUMENT); 750 if (string is null) error (SWT.ERROR_NULL_ARGUMENT);
747 if ((style & SWT.ARROW) != 0) return; 751 if ((style & SWT.ARROW) !is 0) return;
748 text = string; 752 text = string;
749 char [] chars = fixMnemonic (string); 753 char [] chars = fixMnemonic (string);
750 byte [] buffer = Converter.wcsToMbcs (null, chars, true); 754 OS.gtk_label_set_text_with_mnemonic (cast(GtkLabel*)labelHandle, toStringz(chars));
751 OS.gtk_label_set_text_with_mnemonic (labelHandle, buffer); 755 if (image is null) OS.gtk_widget_hide (imageHandle);
752 if (image == null) OS.gtk_widget_hide (imageHandle);
753 OS.gtk_widget_show (labelHandle); 756 OS.gtk_widget_show (labelHandle);
754 _setAlignment (style); 757 _setAlignment (style);
755 } 758 }
756 759
757 void showWidget () { 760 void showWidget () {
758 super.showWidget (); 761 super.showWidget ();
759 if (boxHandle != 0) OS.gtk_widget_show (boxHandle); 762 if (boxHandle !is null) OS.gtk_widget_show (boxHandle);
760 if (labelHandle != 0) OS.gtk_widget_show (labelHandle); 763 if (labelHandle !is null) OS.gtk_widget_show (labelHandle);
761 if (arrowHandle != 0) OS.gtk_widget_show (arrowHandle); 764 if (arrowHandle !is null) OS.gtk_widget_show (arrowHandle);
762 } 765 }
763 766
764 int traversalCode (int key, GdkEventKey event) { 767 alias Control.traversalCode traversalCode;
768 override int traversalCode (int key, GdkEventKey* event) {
765 int code = super.traversalCode (key, event); 769 int code = super.traversalCode (key, event);
766 if ((style & SWT.RADIO) != 0) code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS; 770 if ((style & SWT.RADIO) !is 0) code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
767 return code; 771 return code;
768 } 772 }
769 773
770 } 774 }
771 +/