Mercurial > projects > dwt-linux
annotate dwt/widgets/Composite.d @ 58:a5c274fa5af9
extended helloworld crashing
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sat, 12 Jan 2008 07:02:08 +0100 |
parents | 93981635e709 |
children | 8cec8f536af3 |
rev | line source |
---|---|
30 | 1 /******************************************************************************* |
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 | |
10 *******************************************************************************/ | |
11 module dwt.widgets.Composite; | |
12 | |
34 | 13 import dwt.widgets.Control; |
14 import dwt.widgets.Scrollable; | |
15 import dwt.widgets.Layout; | |
16 import dwt.widgets.Decorations; | |
17 import dwt.widgets.ScrollBar; | |
18 import dwt.widgets.Shell; | |
19 import dwt.widgets.Menu; | |
20 import dwt.widgets.Event; | |
21 import dwt.widgets.Widget; | |
22 import dwt.widgets.Display; | |
23 import dwt.graphics.GCData; | |
30 | 24 |
34 | 25 import dwt.internal.gtk.OS; |
26 import dwt.graphics.GC; | |
27 import dwt.SWT; | |
28 import dwt.internal.cairo.Cairo; | |
29 import dwt.internal.gtk.OS; | |
30 import dwt.graphics.Rectangle; | |
30 | 31 |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
32 import tango.io.Stdout; |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
33 |
30 | 34 /** |
35 * Instances of this class are controls which are capable | |
36 * of containing other controls. | |
37 * <dl> | |
38 * <dt><b>Styles:</b></dt> | |
39 * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP, EMBEDDED, DOUBLE_BUFFERED</dd> | |
40 * <dt><b>Events:</b></dt> | |
41 * <dd>(none)</dd> | |
42 * </dl> | |
43 * <p> | |
44 * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>, | |
45 * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>. | |
46 * They can be used with <code>Composite</code> if you are drawing your own, but their | |
47 * behavior is undefined if they are used with subclasses of <code>Composite</code> other | |
48 * than <code>Canvas</code>. | |
49 * </p><p> | |
50 * Note: The <code>CENTER</code> style, although undefined for composites, has the | |
51 * same value as <code>EMBEDDED</code> (which is used to embed widgets from other | |
52 * widget toolkits into SWT). On some operating systems (GTK, Motif), this may cause | |
53 * the children of this composite to be obscured. The <code>EMBEDDED</code> style | |
54 * is for use by other widget toolkits and should normally never be used. | |
55 * </p><p> | |
56 * This class may be subclassed by custom control implementors | |
57 * who are building controls that are constructed from aggregates | |
58 * of other controls. | |
59 * </p> | |
60 * | |
61 * @see Canvas | |
62 */ | |
34 | 63 public class Composite : Scrollable { |
64 public int embeddedHandle; | |
65 GtkIMContext* imHandle_; | |
66 GtkWidget* socketHandle; | |
67 Layout layout_; | |
30 | 68 Control[] tabList; |
69 int layoutCount, backgroundMode; | |
70 | |
34 | 71 static const char[] NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ |
30 | 72 |
34 | 73 this () { |
30 | 74 /* Do nothing */ |
75 } | |
76 | |
77 /** | |
78 * Constructs a new instance of this class given its parent | |
79 * and a style value describing its behavior and appearance. | |
80 * <p> | |
81 * The style value is either one of the style constants defined in | |
82 * class <code>SWT</code> which is applicable to instances of this | |
83 * class, or must be built by <em>bitwise OR</em>'ing together | |
84 * (that is, using the <code>int</code> "|" operator) two or more | |
85 * of those <code>SWT</code> style constants. The class description | |
86 * lists the style constants that are applicable to the class. | |
87 * Style bits are also inherited from superclasses. | |
88 * </p> | |
89 * | |
90 * @param parent a widget which will be the parent of the new instance (cannot be null) | |
91 * @param style the style of widget to construct | |
92 * | |
93 * @exception IllegalArgumentException <ul> | |
94 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
95 * </ul> | |
96 * @exception SWTException <ul> | |
97 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
98 * </ul> | |
99 * | |
100 * @see SWT#NO_BACKGROUND | |
101 * @see SWT#NO_FOCUS | |
102 * @see SWT#NO_MERGE_PAINTS | |
103 * @see SWT#NO_REDRAW_RESIZE | |
104 * @see SWT#NO_RADIO_GROUP | |
105 * @see Widget#getStyle | |
106 */ | |
34 | 107 public this (Composite parent, int style) { |
30 | 108 super (parent, style); |
109 } | |
110 | |
111 Control [] _getChildren () { | |
34 | 112 auto parentHandle = parentingHandle (); |
113 auto list = OS.gtk_container_get_children (cast(GtkContainer*)parentHandle); | |
114 if (list is null) return new Control [0]; | |
30 | 115 int count = OS.g_list_length (list); |
116 Control [] children = new Control [count]; | |
117 int i = 0; | |
34 | 118 auto temp = list; |
119 while (temp !is null) { | |
120 auto handle = cast(GtkWidget*)OS.g_list_data (temp); | |
121 if (handle !is null) { | |
30 | 122 Widget widget = display.getWidget (handle); |
34 | 123 if (widget !is null && widget !is this) { |
124 if (auto c = cast(Control)widget) { | |
125 children [i++] = c; | |
30 | 126 } |
127 } | |
128 } | |
34 | 129 temp = cast(GList*)OS.g_list_next (temp); |
30 | 130 } |
131 OS.g_list_free (list); | |
34 | 132 if (i is count) return children; |
30 | 133 Control [] newChildren = new Control [i]; |
134 System.arraycopy (children, 0, newChildren, 0, i); | |
135 return newChildren; | |
136 } | |
137 | |
138 Control [] _getTabList () { | |
34 | 139 if (tabList is null) return tabList; |
30 | 140 int count = 0; |
141 for (int i=0; i<tabList.length; i++) { | |
142 if (!tabList [i].isDisposed ()) count++; | |
143 } | |
34 | 144 if (count is tabList.length) return tabList; |
30 | 145 Control [] newList = new Control [count]; |
146 int index = 0; | |
147 for (int i=0; i<tabList.length; i++) { | |
148 if (!tabList [i].isDisposed ()) { | |
149 newList [index++] = tabList [i]; | |
150 } | |
151 } | |
152 tabList = newList; | |
153 return tabList; | |
154 } | |
155 | |
156 /** | |
157 * Clears any data that has been cached by a Layout for all widgets that | |
158 * are in the parent hierarchy of the changed control up to and including the | |
159 * receiver. If an ancestor does not have a layout, it is skipped. | |
160 * | |
161 * @param changed an array of controls that changed state and require a recalculation of size | |
162 * | |
163 * @exception IllegalArgumentException <ul> | |
164 * <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> | |
165 * <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li> | |
166 * </ul> | |
167 * @exception SWTException <ul> | |
168 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
169 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
170 * </ul> | |
171 * | |
172 * @since 3.1 | |
173 */ | |
174 public void changed (Control[] changed) { | |
175 checkWidget (); | |
34 | 176 if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); |
30 | 177 for (int i=0; i<changed.length; i++) { |
178 Control control = changed [i]; | |
34 | 179 if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); |
30 | 180 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); |
34 | 181 bool ancestor = false; |
30 | 182 Composite composite = control.parent; |
34 | 183 while (composite !is null) { |
184 ancestor = composite is this; | |
30 | 185 if (ancestor) break; |
186 composite = composite.parent; | |
187 } | |
188 if (!ancestor) error (SWT.ERROR_INVALID_PARENT); | |
189 } | |
190 for (int i=0; i<changed.length; i++) { | |
191 Control child = changed [i]; | |
192 Composite composite = child.parent; | |
34 | 193 while (child !is this) { |
194 if (composite.layout_ is null || !composite.layout_.flushCache (child)) { | |
30 | 195 composite.state |= LAYOUT_CHANGED; |
196 } | |
197 child = composite; | |
198 composite = child.parent; | |
199 } | |
200 } | |
201 } | |
202 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
203 override void checkBuffered () { |
34 | 204 if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { |
30 | 205 return; |
206 } | |
207 super.checkBuffered(); | |
208 } | |
209 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
210 override protected void checkSubclass () { |
30 | 211 /* Do nothing - Subclassing is allowed */ |
212 } | |
213 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
214 override GtkStyle* childStyle () { |
34 | 215 if (scrolledHandle !is null) return null; |
30 | 216 return super.childStyle (); |
217 } | |
218 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
219 override public Point computeSize (int wHint, int hHint, bool changed) { |
30 | 220 checkWidget (); |
34 | 221 if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0; |
222 if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0; | |
30 | 223 Point size; |
34 | 224 if (layout_ !is null) { |
225 if (wHint is SWT.DEFAULT || hHint is SWT.DEFAULT) { | |
226 changed |= (state & LAYOUT_CHANGED) !is 0; | |
227 size = layout_.computeSize (this, wHint, hHint, changed); | |
30 | 228 state &= ~LAYOUT_CHANGED; |
229 } else { | |
230 size = new Point (wHint, hHint); | |
231 } | |
232 } else { | |
233 size = minimumSize (wHint, hHint, changed); | |
234 } | |
34 | 235 if (size.x is 0) size.x = DEFAULT_WIDTH; |
236 if (size.y is 0) size.y = DEFAULT_HEIGHT; | |
237 if (wHint !is SWT.DEFAULT) size.x = wHint; | |
238 if (hHint !is SWT.DEFAULT) size.y = hHint; | |
30 | 239 Rectangle trim = computeTrim (0, 0, size.x, size.y); |
240 return new Point (trim.width, trim.height); | |
241 } | |
242 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
243 override Control [] computeTabList () { |
30 | 244 Control result [] = super.computeTabList (); |
34 | 245 if (result.length is 0) return result; |
246 Control [] list = tabList !is null ? _getTabList () : _getChildren (); | |
30 | 247 for (int i=0; i<list.length; i++) { |
248 Control child = list [i]; | |
249 Control [] childList = child.computeTabList (); | |
34 | 250 if (childList.length !is 0) { |
30 | 251 Control [] newResult = new Control [result.length + childList.length]; |
252 System.arraycopy (result, 0, newResult, 0, result.length); | |
253 System.arraycopy (childList, 0, newResult, result.length, childList.length); | |
254 result = newResult; | |
255 } | |
256 } | |
257 return result; | |
258 } | |
259 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
260 override void createHandle (int index) { |
30 | 261 state |= HANDLE | CANVAS; |
34 | 262 bool scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) !is 0; |
30 | 263 if (!scrolled) state |= THEME_BACKGROUND; |
34 | 264 createHandle (index, true, scrolled || (style & SWT.BORDER) !is 0); |
30 | 265 } |
266 | |
34 | 267 void createHandle (int index, bool fixed, bool scrolled) { |
30 | 268 if (scrolled) { |
269 if (fixed) { | |
34 | 270 fixedHandle = cast(GtkWidget*) OS.g_object_new (display.gtk_fixed_get_type (), null); |
271 if (fixedHandle is null) error (SWT.ERROR_NO_HANDLES); | |
272 OS.gtk_fixed_set_has_window (cast(GtkFixed*)fixedHandle, true); | |
30 | 273 } |
34 | 274 auto vadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); |
275 if (vadj is null) error (SWT.ERROR_NO_HANDLES); | |
276 auto hadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); | |
277 if (hadj is null) error (SWT.ERROR_NO_HANDLES); | |
278 scrolledHandle = cast(GtkWidget*) OS.gtk_scrolled_window_new (hadj, vadj); | |
279 if (scrolledHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); | |
30 | 280 } |
34 | 281 handle = cast(GtkWidget*)OS.g_object_new (display.gtk_fixed_get_type (), null); |
282 if (handle is null) SWT.error (SWT.ERROR_NO_HANDLES); | |
283 OS.gtk_fixed_set_has_window (cast(GtkFixed*)handle, true); | |
30 | 284 OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS); |
34 | 285 if ((style & SWT.EMBEDDED) is 0) { |
286 if ((state & CANVAS) !is 0 && (style & SWT.NO_FOCUS) is 0) { | |
30 | 287 /* Prevent an input method context from being created for the Browser widget */ |
34 | 288 if (display.getData (NO_INPUT_METHOD) is null) { |
289 imHandle_ = OS.gtk_im_multicontext_new (); | |
290 if (imHandle_ is null) error (SWT.ERROR_NO_HANDLES); | |
30 | 291 } |
292 } | |
293 } | |
294 if (scrolled) { | |
34 | 295 if (fixed) OS.gtk_container_add (cast(GtkContainer*)fixedHandle, scrolledHandle); |
30 | 296 /* |
297 * Force the scrolledWindow to have a single child that is | |
298 * not scrolled automatically. Calling gtk_container_add() | |
299 * seems to add the child correctly but cause a warning. | |
300 */ | |
34 | 301 bool warnings = display.getWarnings (); |
30 | 302 display.setWarnings (false); |
34 | 303 OS.gtk_container_add (cast(GtkContainer*)scrolledHandle, handle); |
30 | 304 display.setWarnings (warnings); |
305 | |
34 | 306 int hsp = (style & SWT.H_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; |
307 int vsp = (style & SWT.V_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; | |
308 OS.gtk_scrolled_window_set_policy (cast(GtkScrolledWindow*)scrolledHandle, hsp, vsp); | |
30 | 309 if (hasBorder ()) { |
34 | 310 OS.gtk_scrolled_window_set_shadow_type (cast(GtkScrolledWindow*)scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); |
30 | 311 } |
312 } | |
34 | 313 if ((style & SWT.EMBEDDED) !is 0) { |
30 | 314 socketHandle = OS.gtk_socket_new (); |
34 | 315 if (socketHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); |
316 OS.gtk_container_add (cast(GtkContainer*)handle, cast(GtkWidget*)socketHandle); | |
30 | 317 } |
34 | 318 if ((style & SWT.NO_REDRAW_RESIZE) !is 0) { |
30 | 319 OS.gtk_widget_set_redraw_on_allocate (handle, false); |
320 } | |
321 /* | |
322 * Bug in GTK. When a widget is double buffered and the back | |
323 * pixmap is null, the double buffer pixmap is filled with the | |
324 * background of the widget rather than the current contents of | |
325 * the screen. If nothing is drawn during an expose event, | |
326 * the pixels are altered. The fix is to clear double buffering | |
327 * when NO_BACKGROUND is set and DOUBLE_BUFFERED | |
328 * is not explicitly set. | |
329 */ | |
34 | 330 if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { |
30 | 331 OS.gtk_widget_set_double_buffered (handle, false); |
332 } | |
333 } | |
334 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
335 override void deregister () { |
30 | 336 super.deregister (); |
34 | 337 if (socketHandle !is null) display.removeWidget (cast(GtkWidget*)socketHandle); |
30 | 338 } |
339 | |
340 void drawBackground (GC gc, int x, int y, int width, int height) { | |
341 Control control = findBackgroundControl (); | |
34 | 342 if (control !is null) { |
30 | 343 GCData data = gc.getGCData (); |
34 | 344 auto cairo = data.cairo; |
345 if (cairo !is null) { | |
30 | 346 Cairo.cairo_save (cairo); |
34 | 347 if (control.backgroundImage !is null) { |
30 | 348 Point pt = display.map (this, control, 0, 0); |
349 Cairo.cairo_translate (cairo, -pt.x, -pt.y); | |
350 x += pt.x; | |
351 y += pt.y; | |
34 | 352 auto xDisplay = OS.GDK_DISPLAY (); |
353 auto xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system()); | |
354 auto drawable = control.backgroundImage.pixmap; | |
355 auto xDrawable = OS.GDK_PIXMAP_XID (drawable); | |
356 int w, h; | |
357 OS.gdk_drawable_get_size (cast(GdkDrawable*)drawable, &w, &h); | |
358 auto surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w, h); | |
359 if (surface is null) error (SWT.ERROR_NO_HANDLES); | |
360 auto pattern = Cairo.cairo_pattern_create_for_surface (surface); | |
361 if (pattern is null) error (SWT.ERROR_NO_HANDLES); | |
30 | 362 Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); |
363 Cairo.cairo_set_source (cairo, pattern); | |
364 Cairo.cairo_surface_destroy (surface); | |
365 Cairo.cairo_pattern_destroy (pattern); | |
366 } else { | |
34 | 367 GdkColor* color = control.getBackgroundColor (); |
368 Cairo.cairo_set_source_rgba (cairo, (color.red & 0xFFFF) / cast(float)0xFFFF, (color.green & 0xFFFF) / cast(float)0xFFFF, (color.blue & 0xFFFF) / cast(float)0xFFFF, data.alpha / cast(float)0xFF); | |
30 | 369 } |
370 Cairo.cairo_rectangle (cairo, x, y, width, height); | |
371 Cairo.cairo_fill (cairo); | |
372 Cairo.cairo_restore (cairo); | |
373 } else { | |
34 | 374 auto gdkGC = gc.handle; |
375 GdkGCValues* values = new GdkGCValues (); | |
30 | 376 OS.gdk_gc_get_values (gdkGC, values); |
34 | 377 if (control.backgroundImage !is null) { |
30 | 378 Point pt = display.map (this, control, 0, 0); |
379 OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); | |
380 OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y); | |
381 OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap); | |
382 OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); | |
383 OS.gdk_gc_set_fill (gdkGC, values.fill); | |
384 OS.gdk_gc_set_ts_origin (gdkGC, values.ts_x_origin, values.ts_y_origin); | |
385 } else { | |
34 | 386 GdkColor* color = control.getBackgroundColor (); |
30 | 387 OS.gdk_gc_set_foreground (gdkGC, color); |
388 OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); | |
34 | 389 color.pixel = values.foreground.pixel; |
30 | 390 OS.gdk_gc_set_foreground (gdkGC, color); |
391 } | |
392 } | |
393 } else { | |
394 gc.fillRectangle (x, y, width, height); | |
395 } | |
396 } | |
397 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
398 override void enableWidget (bool enabled) { |
34 | 399 if ((state & CANVAS) !is 0) return; |
30 | 400 super.enableWidget (enabled); |
401 } | |
402 | |
403 Composite findDeferredControl () { | |
404 return layoutCount > 0 ? this : parent.findDeferredControl (); | |
405 } | |
406 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
407 override Menu [] findMenus (Control control) { |
34 | 408 if (control is this) return new Menu [0]; |
30 | 409 Menu result [] = super.findMenus (control); |
410 Control [] children = _getChildren (); | |
411 for (int i=0; i<children.length; i++) { | |
412 Control child = children [i]; | |
413 Menu [] menuList = child.findMenus (control); | |
34 | 414 if (menuList.length !is 0) { |
30 | 415 Menu [] newResult = new Menu [result.length + menuList.length]; |
416 System.arraycopy (result, 0, newResult, 0, result.length); | |
417 System.arraycopy (menuList, 0, newResult, result.length, menuList.length); | |
418 result = newResult; | |
419 } | |
420 } | |
421 return result; | |
422 } | |
423 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
424 override void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) { |
30 | 425 super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); |
426 Control [] children = _getChildren (); | |
427 for (int i=0; i<children.length; i++) { | |
428 children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); | |
429 } | |
430 } | |
431 | |
34 | 432 alias Scrollable.fixStyle fixStyle; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
433 override void fixStyle () { |
30 | 434 super.fixStyle (); |
34 | 435 if (scrolledHandle is null) fixStyle (handle); |
30 | 436 Control[] children = _getChildren (); |
437 for (int i = 0; i < children.length; i++) { | |
438 children [i].fixStyle (); | |
439 } | |
440 } | |
441 | |
442 void fixTabList (Control control) { | |
34 | 443 if (tabList is null) return; |
30 | 444 int count = 0; |
445 for (int i=0; i<tabList.length; i++) { | |
34 | 446 if (tabList [i] is control) count++; |
30 | 447 } |
34 | 448 if (count is 0) return; |
30 | 449 Control [] newList = null; |
450 int length = tabList.length - count; | |
34 | 451 if (length !is 0) { |
30 | 452 newList = new Control [length]; |
453 int index = 0; | |
454 for (int i=0; i<tabList.length; i++) { | |
34 | 455 if (tabList [i] !is control) { |
30 | 456 newList [index++] = tabList [i]; |
457 } | |
458 } | |
459 } | |
460 tabList = newList; | |
461 } | |
462 | |
463 void fixZOrder () { | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
464 Stdout.formatln( "{}: parent.fixZOrder gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
465 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
34 | 466 if ((state & CANVAS) !is 0) return; |
467 auto parentHandle = parentingHandle (); | |
468 auto parentWindow = OS.GTK_WIDGET_WINDOW (cast(GtkWidget*)parentHandle); | |
469 if (parentWindow is null) return; | |
470 GObject* userData; | |
471 auto windowList = OS.gdk_window_get_children (parentWindow); | |
472 if (windowList !is null) { | |
473 auto windows = windowList; | |
474 while (windows !is null) { | |
475 auto window = cast(GdkDrawable*)OS.g_list_data (windows); | |
476 if (window !is redrawWindow) { | |
477 OS.gdk_window_get_user_data (window, cast(void**)&userData); | |
40
7fb1ab011933
made macro implementations active, one compile problem in OS.d:2554
Frank Benoit <benoit@tionex.de>
parents:
38
diff
changeset
|
478 if (userData is null || OS.G_OBJECT_TYPE (cast(GTypeInstance*)userData) !is display.gtk_fixed_get_type ()) { |
30 | 479 OS.gdk_window_lower (window); |
480 } | |
481 } | |
34 | 482 windows = cast(GList*)OS.g_list_next (windows); |
30 | 483 } |
484 OS.g_list_free (windowList); | |
485 } | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
486 Stdout.formatln( "{}: parent.fixZOrder gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
487 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
30 | 488 } |
489 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
490 override GtkWidget* focusHandle () { |
34 | 491 if (socketHandle !is null) return socketHandle; |
30 | 492 return super.focusHandle (); |
493 } | |
494 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
495 override bool forceFocus (GtkWidget* focusHandle) { |
34 | 496 if (socketHandle !is null) OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); |
497 bool result = super.forceFocus (focusHandle); | |
498 if (socketHandle !is null) OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); | |
30 | 499 return result; |
500 } | |
501 | |
502 /** | |
503 * Returns the receiver's background drawing mode. This | |
504 * will be one of the following constants defined in class | |
505 * <code>SWT</code>: | |
506 * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>, | |
507 * <code>INHERTIT_FORCE</code>. | |
508 * | |
509 * @return the background mode | |
510 * | |
511 * @exception SWTException <ul> | |
512 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
513 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
514 * </ul> | |
515 * | |
516 * @see SWT | |
517 * | |
518 * @since 3.2 | |
519 */ | |
520 public int getBackgroundMode () { | |
521 checkWidget (); | |
522 return backgroundMode; | |
523 } | |
524 | |
525 /** | |
526 * Returns a (possibly empty) array containing the receiver's children. | |
527 * Children are returned in the order that they are drawn. The topmost | |
528 * control appears at the beginning of the array. Subsequent controls | |
529 * draw beneath this control and appear later in the array. | |
530 * <p> | |
531 * Note: This is not the actual structure used by the receiver | |
532 * to maintain its list of children, so modifying the array will | |
533 * not affect the receiver. | |
534 * </p> | |
535 * | |
536 * @return an array of children | |
537 * | |
538 * @see Control#moveAbove | |
539 * @see Control#moveBelow | |
540 * | |
541 * @exception SWTException <ul> | |
542 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
543 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
544 * </ul> | |
545 */ | |
546 public Control [] getChildren () { | |
547 checkWidget(); | |
548 return _getChildren (); | |
549 } | |
550 | |
551 int getChildrenCount () { | |
552 /* | |
553 * NOTE: The current implementation will count | |
554 * non-registered children. | |
555 */ | |
34 | 556 auto list = OS.gtk_container_get_children (cast(GtkContainer*)handle); |
557 if (list is null) return 0; | |
30 | 558 int count = OS.g_list_length (list); |
559 OS.g_list_free (list); | |
560 return count; | |
561 } | |
562 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
563 override public Rectangle getClientArea () { |
30 | 564 checkWidget(); |
34 | 565 if ((state & CANVAS) !is 0) { |
566 if ((state & ZERO_WIDTH) !is 0 && (state & ZERO_HEIGHT) !is 0) { | |
30 | 567 return new Rectangle (0, 0, 0, 0); |
568 } | |
569 forceResize (); | |
34 | 570 auto clientHandle = clientHandle (); |
571 int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); | |
572 int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); | |
30 | 573 return new Rectangle (0, 0, width, height); |
574 } | |
575 return super.getClientArea(); | |
576 } | |
577 | |
578 /** | |
579 * Returns layout which is associated with the receiver, or | |
580 * null if one has not been set. | |
581 * | |
582 * @return the receiver's layout or null | |
583 * | |
584 * @exception SWTException <ul> | |
585 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
586 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
587 * </ul> | |
588 */ | |
589 public Layout getLayout () { | |
590 checkWidget(); | |
34 | 591 return layout_; |
30 | 592 } |
593 | |
594 /** | |
595 * Returns <code>true</code> if the receiver has deferred | |
596 * the performing of layout, and <code>false</code> otherwise. | |
597 * | |
598 * @return the receiver's deferred layout state | |
599 * | |
600 * @exception SWTException <ul> | |
601 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
602 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
603 * </ul> | |
604 * | |
34 | 605 * @see #setLayoutDeferred(bool) |
30 | 606 * @see #isLayoutDeferred() |
607 * | |
608 * @since 3.1 | |
609 */ | |
34 | 610 public bool getLayoutDeferred () { |
30 | 611 checkWidget (); |
612 return layoutCount > 0 ; | |
613 } | |
614 | |
615 /** | |
616 * Gets the (possibly empty) tabbing order for the control. | |
617 * | |
618 * @return tabList the ordered list of controls representing the tab order | |
619 * | |
620 * @exception SWTException <ul> | |
621 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
622 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
623 * </ul> | |
624 * | |
625 * @see #setTabList | |
626 */ | |
627 public Control [] getTabList () { | |
628 checkWidget (); | |
629 Control [] tabList = _getTabList (); | |
34 | 630 if (tabList is null) { |
30 | 631 int count = 0; |
632 Control [] list =_getChildren (); | |
633 for (int i=0; i<list.length; i++) { | |
634 if (list [i].isTabGroup ()) count++; | |
635 } | |
636 tabList = new Control [count]; | |
637 int index = 0; | |
638 for (int i=0; i<list.length; i++) { | |
639 if (list [i].isTabGroup ()) { | |
640 tabList [index++] = list [i]; | |
641 } | |
642 } | |
643 } | |
644 return tabList; | |
645 } | |
646 | |
34 | 647 override int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* event) { |
648 auto result = super.gtk_button_press_event (widget, event); | |
649 if (result !is 0) return result; | |
650 if ((state & CANVAS) !is 0) { | |
651 if ((style & SWT.NO_FOCUS) is 0 && hooksKeys ()) { | |
652 if (event.button is 1) { | |
653 if (getChildrenCount () is 0) setFocus (); | |
30 | 654 } |
655 } | |
656 } | |
657 return result; | |
658 } | |
659 | |
34 | 660 override int /*long*/ gtk_expose_event (GtkWidget* widget, GdkEventExpose* eventPtr) { |
661 if ((state & OBSCURED) !is 0) return 0; | |
662 if ((state & CANVAS) is 0) { | |
30 | 663 return super.gtk_expose_event (widget, eventPtr); |
664 } | |
34 | 665 if ((style & SWT.NO_MERGE_PAINTS) is 0) { |
30 | 666 return super.gtk_expose_event (widget, eventPtr); |
667 } | |
668 if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; | |
34 | 669 GdkEventExpose* gdkEvent = eventPtr; |
670 GdkRectangle* rectangles; | |
671 int n_rectangles; | |
672 OS.gdk_region_get_rectangles (gdkEvent.region, &rectangles, &n_rectangles); | |
673 for (int i=0; i<n_rectangles; i++) { | |
30 | 674 Event event = new Event (); |
34 | 675 event.x = rectangles[i].x; |
676 event.y = rectangles[i].y; | |
677 event.width = rectangles[i].width; | |
678 event.height = rectangles[i].height; | |
679 auto damageRgn = OS.gdk_region_new (); | |
680 OS.gdk_region_union_with_rect (damageRgn, rectangles + i ); | |
30 | 681 GCData data = new GCData (); |
682 data.damageRgn = damageRgn; | |
683 GC gc = event.gc = GC.gtk_new (this, data); | |
684 OS.gdk_gc_set_clip_region (gc.handle, damageRgn); | |
685 sendEvent (SWT.Paint, event); | |
686 gc.dispose (); | |
687 OS.gdk_region_destroy (damageRgn); | |
688 event.gc = null; | |
689 } | |
34 | 690 OS.g_free (rectangles); |
30 | 691 return 0; |
692 } | |
693 | |
34 | 694 override int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* event) { |
695 auto result = super.gtk_key_press_event (widget, event); | |
696 if (result !is 0) return result; | |
30 | 697 /* |
698 * Feature in GTK. The default behavior when the return key | |
699 * is pressed is to select the default button. This is not the | |
700 * expected behavior for Composite and its subclasses. The | |
701 * fix is to avoid calling the default handler. | |
702 */ | |
34 | 703 if ((state & CANVAS) !is 0 && socketHandle is null) { |
704 GdkEventKey* keyEvent = event; | |
30 | 705 int key = keyEvent.keyval; |
706 switch (key) { | |
707 case OS.GDK_Return: | |
708 case OS.GDK_KP_Enter: return 1; | |
55
93981635e709
Checked and inserted missing default switch cases.
Frank Benoit <benoit@tionex.de>
parents:
40
diff
changeset
|
709 default: |
30 | 710 } |
711 } | |
712 return result; | |
713 } | |
714 | |
38 | 715 override int /*long*/ gtk_focus (GtkWidget* widget, int directionType) { |
34 | 716 if (widget is socketHandle) return 0; |
30 | 717 return super.gtk_focus (widget, directionType); |
718 } | |
719 | |
37 | 720 override int /*long*/ gtk_focus_in_event (GtkWidget* widget, GdkEventFocus* event) { |
30 | 721 int /*long*/ result = super.gtk_focus_in_event (widget, event); |
34 | 722 return (state & CANVAS) !is 0 ? 1 : result; |
30 | 723 } |
724 | |
37 | 725 override int /*long*/ gtk_focus_out_event (GtkWidget* widget, GdkEventFocus* event) { |
34 | 726 auto result = super.gtk_focus_out_event (widget, event); |
727 return (state & CANVAS) !is 0 ? 1 : result; | |
30 | 728 } |
729 | |
34 | 730 override int /*long*/ gtk_map (GtkWidget* widget) { |
30 | 731 fixZOrder (); |
732 return 0; | |
733 } | |
734 | |
34 | 735 override int /*long*/ gtk_realize (GtkWidget* widget) { |
736 auto result = super.gtk_realize (widget); | |
737 if ((style & SWT.NO_BACKGROUND) !is 0) { | |
738 auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); | |
739 if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); | |
30 | 740 } |
34 | 741 if (socketHandle !is null) { |
742 embeddedHandle = OS.gtk_socket_get_id (cast(GtkSocket*)socketHandle); | |
30 | 743 } |
744 return result; | |
745 } | |
746 | |
34 | 747 override int /*long*/ gtk_scroll_child (GtkWidget* widget, int /*long*/ scrollType, int /*long*/ horizontal) { |
30 | 748 /* Stop GTK scroll child signal for canvas */ |
34 | 749 OS.g_signal_stop_emission_by_name (widget, OS.scroll_child.ptr); |
30 | 750 return 1; |
751 } | |
752 | |
34 | 753 override int /*long*/ gtk_style_set (GtkWidget* widget, int /*long*/ previousStyle) { |
754 auto result = super.gtk_style_set (widget, previousStyle); | |
755 if ((style & SWT.NO_BACKGROUND) !is 0) { | |
756 auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); | |
757 if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); | |
30 | 758 } |
759 return result; | |
760 } | |
761 | |
34 | 762 bool hasBorder () { |
763 return (style & SWT.BORDER) !is 0; | |
30 | 764 } |
765 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
766 override void hookEvents () { |
30 | 767 super.hookEvents (); |
34 | 768 if ((state & CANVAS) !is 0) { |
30 | 769 OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK); |
34 | 770 if (scrolledHandle !is null) { |
771 OS.g_signal_connect_closure (scrolledHandle, OS.scroll_child.ptr, display.closures [SCROLL_CHILD], false); | |
30 | 772 } |
773 } | |
774 } | |
775 | |
34 | 776 bool hooksKeys () { |
30 | 777 return hooks (SWT.KeyDown) || hooks (SWT.KeyUp); |
778 } | |
779 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
780 override GtkIMContext* imHandle () { |
34 | 781 return imHandle_; |
30 | 782 } |
783 | |
784 /** | |
785 * Returns <code>true</code> if the receiver or any ancestor | |
786 * up to and including the receiver's nearest ancestor shell | |
787 * has deferred the performing of layouts. Otherwise, <code>false</code> | |
788 * is returned. | |
789 * | |
790 * @return the receiver's deferred layout state | |
791 * | |
792 * @exception SWTException <ul> | |
793 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
794 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
795 * </ul> | |
796 * | |
34 | 797 * @see #setLayoutDeferred(bool) |
30 | 798 * @see #getLayoutDeferred() |
799 * | |
800 * @since 3.1 | |
801 */ | |
34 | 802 public bool isLayoutDeferred () { |
30 | 803 checkWidget (); |
34 | 804 return findDeferredControl () !is null; |
30 | 805 } |
806 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
807 override bool isTabGroup() { |
34 | 808 if ((state & CANVAS) !is 0) return true; |
30 | 809 return super.isTabGroup(); |
810 } | |
811 | |
812 /** | |
813 * If the receiver has a layout, asks the layout to <em>lay out</em> | |
814 * (that is, set the size and location of) the receiver's children. | |
815 * If the receiver does not have a layout, do nothing. | |
816 * <p> | |
817 * This is equivalent to calling <code>layout(true)</code>. | |
818 * </p> | |
819 * <p> | |
820 * Note: Layout is different from painting. If a child is | |
821 * moved or resized such that an area in the parent is | |
822 * exposed, then the parent will paint. If no child is | |
823 * affected, the parent will not paint. | |
824 * </p> | |
825 * | |
826 * @exception SWTException <ul> | |
827 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
828 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
829 * </ul> | |
830 */ | |
831 public void layout () { | |
832 checkWidget (); | |
833 layout (true); | |
834 } | |
835 | |
836 /** | |
837 * If the receiver has a layout, asks the layout to <em>lay out</em> | |
838 * (that is, set the size and location of) the receiver's children. | |
839 * If the argument is <code>true</code> the layout must not rely | |
840 * on any information it has cached about the immediate children. If it | |
841 * is <code>false</code> the layout may (potentially) optimize the | |
842 * work it is doing by assuming that none of the receiver's | |
843 * children has changed state since the last layout. | |
844 * If the receiver does not have a layout, do nothing. | |
845 * <p> | |
846 * If a child is resized as a result of a call to layout, the | |
847 * resize event will invoke the layout of the child. The layout | |
848 * will cascade down through all child widgets in the receiver's widget | |
849 * tree until a child is encountered that does not resize. Note that | |
850 * a layout due to a resize will not flush any cached information | |
851 * (same as <code>layout(false)</code>). | |
852 * </p> | |
853 * <p> | |
854 * Note: Layout is different from painting. If a child is | |
855 * moved or resized such that an area in the parent is | |
856 * exposed, then the parent will paint. If no child is | |
857 * affected, the parent will not paint. | |
858 * </p> | |
859 * | |
860 * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise | |
861 * | |
862 * @exception SWTException <ul> | |
863 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
864 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
865 * </ul> | |
866 */ | |
34 | 867 public void layout (bool changed) { |
30 | 868 checkWidget (); |
34 | 869 if (layout_ is null) return; |
30 | 870 layout (changed, false); |
871 } | |
872 | |
873 /** | |
874 * If the receiver has a layout, asks the layout to <em>lay out</em> | |
875 * (that is, set the size and location of) the receiver's children. | |
876 * If the changed argument is <code>true</code> the layout must not rely | |
877 * on any information it has cached about its children. If it | |
878 * is <code>false</code> the layout may (potentially) optimize the | |
879 * work it is doing by assuming that none of the receiver's | |
880 * children has changed state since the last layout. | |
881 * If the all argument is <code>true</code> the layout will cascade down | |
882 * through all child widgets in the receiver's widget tree, regardless of | |
883 * whether the child has changed size. The changed argument is applied to | |
884 * all layouts. If the all argument is <code>false</code>, the layout will | |
885 * <em>not</em> cascade down through all child widgets in the receiver's widget | |
886 * tree. However, if a child is resized as a result of a call to layout, the | |
887 * resize event will invoke the layout of the child. Note that | |
888 * a layout due to a resize will not flush any cached information | |
889 * (same as <code>layout(false)</code>). | |
890 * </p> | |
891 * <p> | |
892 * Note: Layout is different from painting. If a child is | |
893 * moved or resized such that an area in the parent is | |
894 * exposed, then the parent will paint. If no child is | |
895 * affected, the parent will not paint. | |
896 * </p> | |
897 * | |
898 * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise | |
899 * @param all <code>true</code> if all children in the receiver's widget tree should be laid out, and <code>false</code> otherwise | |
900 * | |
901 * @exception SWTException <ul> | |
902 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
903 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
904 * </ul> | |
905 * | |
906 * @since 3.1 | |
907 */ | |
34 | 908 public void layout (bool changed, bool all) { |
30 | 909 checkWidget (); |
34 | 910 if (layout_ is null && !all) return; |
30 | 911 markLayout (changed, all); |
912 updateLayout (all); | |
913 } | |
914 | |
915 /** | |
916 * Forces a lay out (that is, sets the size and location) of all widgets that | |
917 * are in the parent hierarchy of the changed control up to and including the | |
918 * receiver. The layouts in the hierarchy must not rely on any information | |
919 * cached about the changed control or any of its ancestors. The layout may | |
920 * (potentially) optimize the work it is doing by assuming that none of the | |
921 * peers of the changed control have changed state since the last layout. | |
922 * If an ancestor does not have a layout, skip it. | |
923 * <p> | |
924 * Note: Layout is different from painting. If a child is | |
925 * moved or resized such that an area in the parent is | |
926 * exposed, then the parent will paint. If no child is | |
927 * affected, the parent will not paint. | |
928 * </p> | |
929 * | |
930 * @param changed a control that has had a state change which requires a recalculation of its size | |
931 * | |
932 * @exception IllegalArgumentException <ul> | |
933 * <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li> | |
934 * <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li> | |
935 * </ul> | |
936 * @exception SWTException <ul> | |
937 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
938 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
939 * </ul> | |
940 * | |
941 * @since 3.1 | |
942 */ | |
943 public void layout (Control [] changed) { | |
944 checkWidget (); | |
34 | 945 if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); |
30 | 946 for (int i=0; i<changed.length; i++) { |
947 Control control = changed [i]; | |
34 | 948 if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); |
30 | 949 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); |
34 | 950 bool ancestor = false; |
30 | 951 Composite composite = control.parent; |
34 | 952 while (composite !is null) { |
953 ancestor = composite is this; | |
30 | 954 if (ancestor) break; |
955 composite = composite.parent; | |
956 } | |
957 if (!ancestor) error (SWT.ERROR_INVALID_PARENT); | |
958 } | |
959 int updateCount = 0; | |
960 Composite [] update = new Composite [16]; | |
961 for (int i=0; i<changed.length; i++) { | |
962 Control child = changed [i]; | |
963 Composite composite = child.parent; | |
34 | 964 while (child !is this) { |
965 if (composite.layout_ !is null) { | |
30 | 966 composite.state |= LAYOUT_NEEDED; |
34 | 967 if (!composite.layout_.flushCache (child)) { |
30 | 968 composite.state |= LAYOUT_CHANGED; |
969 } | |
970 } | |
34 | 971 if (updateCount is update.length) { |
30 | 972 Composite [] newUpdate = new Composite [update.length + 16]; |
973 System.arraycopy (update, 0, newUpdate, 0, update.length); | |
974 update = newUpdate; | |
975 } | |
976 child = update [updateCount++] = composite; | |
977 composite = child.parent; | |
978 } | |
979 } | |
980 for (int i=updateCount-1; i>=0; i--) { | |
981 update [i].updateLayout (false); | |
982 } | |
983 } | |
984 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
985 override void markLayout (bool changed, bool all) { |
34 | 986 if (layout_ !is null) { |
30 | 987 state |= LAYOUT_NEEDED; |
988 if (changed) state |= LAYOUT_CHANGED; | |
989 } | |
990 if (all) { | |
991 Control [] children = _getChildren (); | |
992 for (int i=0; i<children.length; i++) { | |
993 children [i].markLayout (changed, all); | |
994 } | |
995 } | |
996 } | |
997 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
998 alias Scrollable.moveAbove moveAbove; |
34 | 999 void moveAbove (GtkWidget* child, GtkWidget* sibling) { |
1000 if (child is sibling) return; | |
1001 auto parentHandle = parentingHandle (); | |
1002 auto fixed = cast(GtkFixed*)parentHandle; | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1003 GList* children = fixed.children; |
34 | 1004 if (children is null) return; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1005 void* data; |
34 | 1006 GtkWidget* widget; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1007 void* childData; |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1008 GList* childLink, siblingLink; |
34 | 1009 GList* temp = children; |
1010 while (temp !is null) { | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1011 data = temp.data; |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1012 widget = *cast(GtkWidget**) data; |
34 | 1013 if (child is widget) { |
30 | 1014 childLink = temp; |
34 | 1015 childData = data; |
1016 } else if (sibling is widget) { | |
30 | 1017 siblingLink = temp; |
1018 } | |
34 | 1019 if (childData !is null && (sibling is null || siblingLink !is null)) break; |
1020 temp = cast(GList*)OS.g_list_next (temp); | |
30 | 1021 } |
1022 children = OS.g_list_remove_link (children, childLink); | |
34 | 1023 if (siblingLink is null || siblingLink.prev is null) { |
30 | 1024 OS.g_list_free_1 (childLink); |
1025 children = OS.g_list_prepend (children, childData); | |
1026 } else { | |
34 | 1027 temp = siblingLink.prev; |
1028 childLink.prev = temp; | |
1029 temp.next = childLink; | |
1030 childLink.next = siblingLink; | |
1031 siblingLink.prev = childLink; | |
30 | 1032 } |
1033 fixed.children = children; | |
34 | 1034 parentHandle = cast(GtkWidget*)fixed; |
30 | 1035 } |
1036 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1037 alias Scrollable.moveBelow moveBelow; |
34 | 1038 void moveBelow (GtkWidget* child, GtkWidget* sibling) { |
1039 if (child is sibling) return; | |
1040 auto parentHandle = parentingHandle (); | |
1041 if (sibling is null && cast(GtkWidget*)parentHandle is cast(GtkWidget*)fixedHandle) { | |
1042 moveAbove (child, scrolledHandle !is null ? cast(GtkWidget*)scrolledHandle : handle); | |
30 | 1043 return; |
1044 } | |
34 | 1045 auto fixed = cast(GtkFixed*)parentHandle; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1046 GList* children = fixed.children; |
34 | 1047 if (children is null) return; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1048 void* data; |
34 | 1049 GtkWidget* widget; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1050 void* childData; |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1051 GList* childLink, siblingLink, temp = children; |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1052 Stdout.formatln( "{}: before loop child={} sibling={}", __LINE__, child, sibling ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1053 Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1054 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
34 | 1055 while (temp !is null) { |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1056 Stdout.formatln( "{}: loop start {}->{}", __LINE__, temp, cast(void*)temp.data ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1057 data = (*temp).data; |
34 | 1058 widget = cast(GtkWidget*) data; |
1059 if (child is widget) { | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1060 Stdout.formatln( "{}: child is widget", __LINE__ ); |
30 | 1061 childLink = temp; |
34 | 1062 childData = data; |
1063 } else if (sibling is widget) { | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1064 Stdout.formatln( "{}: sibling is widget", __LINE__ ); |
30 | 1065 siblingLink = temp; |
1066 } | |
34 | 1067 if (childData !is null && (sibling is null || siblingLink !is null)) break; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1068 temp = OS.g_list_next(temp); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1069 Stdout.formatln( "{}: loop end", __LINE__ ); |
30 | 1070 } |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1071 Stdout.formatln( "{}: after loop childLink={}", __LINE__, childLink ); |
30 | 1072 children = OS.g_list_remove_link (children, childLink); |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1073 if (siblingLink is null || OS.g_list_next(siblingLink) is null) { |
30 | 1074 OS.g_list_free_1 (childLink); |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1075 Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1076 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1077 Stdout.formatln( " {} {}", children, childData ); |
30 | 1078 children = OS.g_list_append (children, childData); |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1079 Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1080 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
30 | 1081 } else { |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1082 Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1083 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1084 temp = OS.g_list_next( siblingLink ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1085 OS.g_list_set_next (childLink, temp); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1086 OS.g_list_set_previous (temp, childLink); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1087 OS.g_list_set_previous (childLink, siblingLink); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1088 OS.g_list_set_next (siblingLink, childLink); |
30 | 1089 } |
1090 fixed.children = children; | |
34 | 1091 parentHandle = cast(GtkWidget*)fixed; |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1092 Stdout.formatln( "{}: parent.moveBelow gtk_container_get_children {:x}", __LINE__, parentingHandle() ); |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1093 Stdout.formatln( "=> {}", OS.gtk_container_get_children (cast(GtkContainer*)parentingHandle()) ); |
30 | 1094 } |
1095 | |
34 | 1096 Point minimumSize (int wHint, int hHint, bool changed) { |
30 | 1097 Control [] children = _getChildren (); |
1098 int width = 0, height = 0; | |
1099 for (int i=0; i<children.length; i++) { | |
1100 Rectangle rect = children [i].getBounds (); | |
1101 width = Math.max (width, rect.x + rect.width); | |
1102 height = Math.max (height, rect.y + rect.height); | |
1103 } | |
1104 return new Point (width, height); | |
1105 } | |
1106 | |
34 | 1107 GtkWidget* parentingHandle () { |
1108 if ((state & CANVAS) !is 0) return handle; | |
1109 return fixedHandle !is null ? fixedHandle : handle; | |
30 | 1110 } |
1111 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1112 override void redrawChildren () { |
30 | 1113 super.redrawChildren (); |
1114 Control [] children = _getChildren (); | |
1115 for (int i = 0; i < children.length; i++) { | |
1116 Control child = children [i]; | |
34 | 1117 if ((child.state & PARENT_BACKGROUND) !is 0) { |
30 | 1118 child.redrawWidget (0, 0, 0, 0, true, false, true); |
1119 child.redrawChildren (); | |
1120 } | |
1121 } | |
1122 } | |
1123 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1124 override void register () { |
30 | 1125 super.register (); |
34 | 1126 if (socketHandle !is null) display.addWidget (socketHandle, this); |
30 | 1127 } |
1128 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1129 override void releaseChildren (bool destroy) { |
30 | 1130 Control [] children = _getChildren (); |
1131 for (int i=0; i<children.length; i++) { | |
1132 Control child = children [i]; | |
34 | 1133 if (child !is null && !child.isDisposed ()) { |
30 | 1134 child.release (false); |
1135 } | |
1136 } | |
1137 super.releaseChildren (destroy); | |
1138 } | |
1139 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1140 override void releaseHandle () { |
30 | 1141 super.releaseHandle (); |
34 | 1142 socketHandle = null; |
1143 embeddedHandle = 0; | |
30 | 1144 } |
1145 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1146 override void releaseWidget () { |
30 | 1147 super.releaseWidget (); |
34 | 1148 if (imHandle_ !is null) OS.g_object_unref (imHandle_); |
1149 imHandle_ = null; | |
1150 layout_ = null; | |
30 | 1151 tabList = null; |
1152 } | |
1153 | |
1154 void removeControl (Control control) { | |
1155 fixTabList (control); | |
1156 } | |
1157 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1158 override void resizeHandle (int width, int height) { |
30 | 1159 super.resizeHandle (width, height); |
34 | 1160 if (socketHandle !is null) OS.gtk_widget_set_size_request (socketHandle, width, height); |
30 | 1161 } |
1162 | |
1163 /** | |
1164 * Sets the background drawing mode to the argument which should | |
1165 * be one of the following constants defined in class <code>SWT</code>: | |
1166 * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>, | |
1167 * <code>INHERIT_FORCE</code>. | |
1168 * | |
1169 * @param mode the new background mode | |
1170 * | |
1171 * @exception SWTException <ul> | |
1172 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1173 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1174 * </ul> | |
1175 * | |
1176 * @see SWT | |
1177 * | |
1178 * @since 3.2 | |
1179 */ | |
1180 public void setBackgroundMode (int mode) { | |
1181 checkWidget (); | |
1182 backgroundMode = mode; | |
1183 Control[] children = _getChildren (); | |
1184 for (int i = 0; i < children.length; i++) { | |
1185 children [i].updateBackgroundMode (); | |
1186 } | |
1187 } | |
1188 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1189 alias Scrollable.setBounds setBounds; |
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1190 override int setBounds (int x, int y, int width, int height, bool move, bool resize) { |
30 | 1191 int result = super.setBounds (x, y, width, height, move, resize); |
34 | 1192 if ((result & RESIZED) !is 0 && layout_ !is null) { |
30 | 1193 markLayout (false, false); |
1194 updateLayout (false); | |
1195 } | |
1196 return result; | |
1197 } | |
1198 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1199 override public bool setFocus () { |
30 | 1200 checkWidget(); |
1201 Control [] children = _getChildren (); | |
1202 for (int i=0; i<children.length; i++) { | |
1203 Control child = children [i]; | |
1204 if (child.getVisible () && child.setFocus ()) return true; | |
1205 } | |
1206 return super.setFocus (); | |
1207 } | |
1208 | |
1209 /** | |
1210 * Sets the layout which is associated with the receiver to be | |
1211 * the argument which may be null. | |
1212 * | |
1213 * @param layout the receiver's new layout or null | |
1214 * | |
1215 * @exception SWTException <ul> | |
1216 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1217 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1218 * </ul> | |
1219 */ | |
1220 public void setLayout (Layout layout) { | |
1221 checkWidget(); | |
34 | 1222 this.layout_ = layout; |
30 | 1223 } |
1224 | |
1225 /** | |
1226 * If the argument is <code>true</code>, causes subsequent layout | |
1227 * operations in the receiver or any of its children to be ignored. | |
1228 * No layout of any kind can occur in the receiver or any of its | |
1229 * children until the flag is set to false. | |
1230 * Layout operations that occurred while the flag was | |
1231 * <code>true</code> are remembered and when the flag is set to | |
1232 * <code>false</code>, the layout operations are performed in an | |
1233 * optimized manner. Nested calls to this method are stacked. | |
1234 * | |
1235 * @param defer the new defer state | |
1236 * | |
1237 * @exception SWTException <ul> | |
1238 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1239 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1240 * </ul> | |
1241 * | |
34 | 1242 * @see #layout(bool) |
30 | 1243 * @see #layout(Control[]) |
1244 * | |
1245 * @since 3.1 | |
1246 */ | |
34 | 1247 public void setLayoutDeferred (bool defer) { |
30 | 1248 if (!defer) { |
34 | 1249 if (--layoutCount is 0) { |
1250 if ((state & LAYOUT_CHILD) !is 0 || (state & LAYOUT_NEEDED) !is 0) { | |
30 | 1251 updateLayout (true); |
1252 } | |
1253 } | |
1254 } else { | |
1255 layoutCount++; | |
1256 } | |
1257 } | |
1258 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1259 override bool setScrollBarVisible (ScrollBar bar, bool visible) { |
34 | 1260 bool changed = super.setScrollBarVisible (bar, visible); |
1261 if (changed && layout_ !is null) { | |
30 | 1262 markLayout (false, false); |
1263 updateLayout (false); | |
1264 } | |
1265 return changed; | |
1266 } | |
1267 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1268 override bool setTabGroupFocus (bool next) { |
30 | 1269 if (isTabItem ()) return setTabItemFocus (next); |
34 | 1270 bool takeFocus = (style & SWT.NO_FOCUS) is 0; |
1271 if ((state & CANVAS) !is 0) takeFocus = hooksKeys (); | |
1272 if (socketHandle !is null) takeFocus = true; | |
30 | 1273 if (takeFocus && setTabItemFocus (next)) return true; |
1274 Control [] children = _getChildren (); | |
1275 for (int i=0; i<children.length; i++) { | |
1276 Control child = children [i]; | |
1277 if (child.isTabItem () && child.setTabItemFocus (next)) return true; | |
1278 } | |
1279 return false; | |
1280 } | |
1281 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1282 override bool setTabItemFocus (bool next) { |
30 | 1283 if (!super.setTabItemFocus (next)) return false; |
34 | 1284 if (socketHandle !is null) { |
30 | 1285 int direction = next ? OS.GTK_DIR_TAB_FORWARD : OS.GTK_DIR_TAB_BACKWARD; |
1286 OS.GTK_WIDGET_UNSET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); | |
1287 OS.gtk_widget_child_focus (socketHandle, direction); | |
1288 OS.GTK_WIDGET_SET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); | |
1289 } | |
1290 return true; | |
1291 } | |
1292 | |
1293 /** | |
1294 * Sets the tabbing order for the specified controls to | |
1295 * match the order that they occur in the argument list. | |
1296 * | |
1297 * @param tabList the ordered list of controls representing the tab order or null | |
1298 * | |
1299 * @exception IllegalArgumentException <ul> | |
1300 * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li> | |
1301 * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li> | |
1302 * </ul> | |
1303 * @exception SWTException <ul> | |
1304 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1305 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1306 * </ul> | |
1307 */ | |
1308 public void setTabList (Control [] tabList) { | |
1309 checkWidget (); | |
34 | 1310 if (tabList !is null) { |
30 | 1311 for (int i=0; i<tabList.length; i++) { |
1312 Control control = tabList [i]; | |
34 | 1313 if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); |
30 | 1314 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); |
34 | 1315 if (control.parent !is this) error (SWT.ERROR_INVALID_PARENT); |
30 | 1316 } |
1317 Control [] newList = new Control [tabList.length]; | |
1318 System.arraycopy (tabList, 0, newList, 0, tabList.length); | |
1319 tabList = newList; | |
1320 } | |
1321 this.tabList = tabList; | |
1322 } | |
1323 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1324 override void showWidget () { |
30 | 1325 super.showWidget (); |
34 | 1326 if (socketHandle !is null) { |
30 | 1327 OS.gtk_widget_show (socketHandle); |
34 | 1328 embeddedHandle = OS.gtk_socket_get_id (cast(GtkSocket*)socketHandle); |
30 | 1329 } |
34 | 1330 if (scrolledHandle is null) fixStyle (handle); |
30 | 1331 } |
1332 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1333 override bool translateMnemonic (Event event, Control control) { |
30 | 1334 if (super.translateMnemonic (event, control)) return true; |
34 | 1335 if (control !is null) { |
30 | 1336 Control [] children = _getChildren (); |
1337 for (int i=0; i<children.length; i++) { | |
1338 Control child = children [i]; | |
1339 if (child.translateMnemonic (event, control)) return true; | |
1340 } | |
1341 } | |
1342 return false; | |
1343 } | |
1344 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1345 override int traversalCode(int key, GdkEventKey* event) { |
34 | 1346 if ((state & CANVAS) !is 0) { |
1347 if ((style & SWT.NO_FOCUS) !is 0) return 0; | |
30 | 1348 if (hooksKeys ()) return 0; |
1349 } | |
1350 return super.traversalCode (key, event); | |
1351 } | |
1352 | |
58
a5c274fa5af9
extended helloworld crashing
Frank Benoit <benoit@tionex.de>
parents:
55
diff
changeset
|
1353 override bool translateTraversal (GdkEventKey* keyEvent) { |
34 | 1354 if (socketHandle !is null) return false; |
30 | 1355 return super.translateTraversal (keyEvent); |
1356 } | |
1357 | |
1358 void updateBackgroundMode () { | |
1359 super.updateBackgroundMode (); | |
1360 Control [] children = _getChildren (); | |
1361 for (int i = 0; i < children.length; i++) { | |
1362 children [i].updateBackgroundMode (); | |
1363 } | |
1364 } | |
1365 | |
34 | 1366 void updateLayout (bool all) { |
30 | 1367 Composite parent = findDeferredControl (); |
34 | 1368 if (parent !is null) { |
30 | 1369 parent.state |= LAYOUT_CHILD; |
1370 return; | |
1371 } | |
34 | 1372 if ((state & LAYOUT_NEEDED) !is 0) { |
1373 bool changed = (state & LAYOUT_CHANGED) !is 0; | |
30 | 1374 state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED); |
34 | 1375 layout_.layout (this, changed); |
30 | 1376 } |
1377 if (all) { | |
1378 state &= ~LAYOUT_CHILD; | |
1379 Control [] children = _getChildren (); | |
1380 for (int i=0; i<children.length; i++) { | |
1381 children [i].updateLayout (all); | |
1382 } | |
1383 } | |
1384 } | |
1385 } |