Mercurial > projects > dwt-linux
comparison dwt/widgets/Composite.d @ 34:3a3e3aa76b66
Composite
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 10 Jan 2008 03:51:48 +0100 |
parents | 27324bbbac70 |
children | c86fc3d50cfa |
comparison
equal
deleted
inserted
replaced
33:27324bbbac70 | 34:3a3e3aa76b66 |
---|---|
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 *******************************************************************************/ | 10 *******************************************************************************/ |
11 module dwt.widgets.Composite; | 11 module dwt.widgets.Composite; |
12 | |
12 import dwt.widgets.Control; | 13 import dwt.widgets.Control; |
13 import dwt.internal.c.gtk; | 14 import dwt.widgets.Scrollable; |
14 | 15 import dwt.widgets.Layout; |
15 class Composite : Control { | 16 import dwt.widgets.Decorations; |
16 Control [] _getTabList (); | 17 import dwt.widgets.ScrollBar; |
17 int backgroundMode; | 18 import dwt.widgets.Shell; |
18 GtkWidget* parentingHandle (); | 19 import dwt.widgets.Menu; |
19 Control [] _getChildren () ; | 20 import dwt.widgets.Event; |
20 void removeControl (Control control); | 21 import dwt.widgets.Widget; |
21 void moveAbove (GtkWidget* child, GtkWidget* sibling); | 22 import dwt.widgets.Display; |
22 void moveBelow (GtkWidget* child, GtkWidget* sibling); | 23 import dwt.graphics.GCData; |
23 void fixZOrder () ; | 24 |
24 } | 25 import dwt.internal.gtk.OS; |
25 | 26 import dwt.graphics.GC; |
26 /+ | 27 import dwt.SWT; |
27 import dwt.*; | 28 import dwt.internal.cairo.Cairo; |
28 import dwt.internal.cairo.*; | 29 import dwt.internal.gtk.OS; |
29 import dwt.internal.gtk.*; | 30 import dwt.graphics.Rectangle; |
30 import dwt.graphics.*; | |
31 | 31 |
32 /** | 32 /** |
33 * Instances of this class are controls which are capable | 33 * Instances of this class are controls which are capable |
34 * of containing other controls. | 34 * of containing other controls. |
35 * <dl> | 35 * <dl> |
56 * of other controls. | 56 * of other controls. |
57 * </p> | 57 * </p> |
58 * | 58 * |
59 * @see Canvas | 59 * @see Canvas |
60 */ | 60 */ |
61 public class Composite extends Scrollable { | 61 public class Composite : Scrollable { |
62 public int /*long*/ embeddedHandle; | 62 public int embeddedHandle; |
63 int /*long*/ imHandle, socketHandle; | 63 GtkIMContext* imHandle_; |
64 Layout layout; | 64 GtkWidget* socketHandle; |
65 Layout layout_; | |
65 Control[] tabList; | 66 Control[] tabList; |
66 int layoutCount, backgroundMode; | 67 int layoutCount, backgroundMode; |
67 | 68 |
68 static final String NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ | 69 static const char[] NO_INPUT_METHOD = "dwt.internal.gtk.noInputMethod"; //$NON-NLS-1$ |
69 | 70 |
70 Composite () { | 71 this () { |
71 /* Do nothing */ | 72 /* Do nothing */ |
72 } | 73 } |
73 | 74 |
74 /** | 75 /** |
75 * Constructs a new instance of this class given its parent | 76 * Constructs a new instance of this class given its parent |
99 * @see SWT#NO_MERGE_PAINTS | 100 * @see SWT#NO_MERGE_PAINTS |
100 * @see SWT#NO_REDRAW_RESIZE | 101 * @see SWT#NO_REDRAW_RESIZE |
101 * @see SWT#NO_RADIO_GROUP | 102 * @see SWT#NO_RADIO_GROUP |
102 * @see Widget#getStyle | 103 * @see Widget#getStyle |
103 */ | 104 */ |
104 public Composite (Composite parent, int style) { | 105 public this (Composite parent, int style) { |
105 super (parent, style); | 106 super (parent, style); |
106 } | 107 } |
107 | 108 |
108 Control [] _getChildren () { | 109 Control [] _getChildren () { |
109 int /*long*/ parentHandle = parentingHandle (); | 110 auto parentHandle = parentingHandle (); |
110 int /*long*/ list = OS.gtk_container_get_children (parentHandle); | 111 auto list = OS.gtk_container_get_children (cast(GtkContainer*)parentHandle); |
111 if (list == 0) return new Control [0]; | 112 if (list is null) return new Control [0]; |
112 int count = OS.g_list_length (list); | 113 int count = OS.g_list_length (list); |
113 Control [] children = new Control [count]; | 114 Control [] children = new Control [count]; |
114 int i = 0; | 115 int i = 0; |
115 int /*long*/ temp = list; | 116 auto temp = list; |
116 while (temp != 0) { | 117 while (temp !is null) { |
117 int /*long*/ handle = OS.g_list_data (temp); | 118 auto handle = cast(GtkWidget*)OS.g_list_data (temp); |
118 if (handle != 0) { | 119 if (handle !is null) { |
119 Widget widget = display.getWidget (handle); | 120 Widget widget = display.getWidget (handle); |
120 if (widget != null && widget != this) { | 121 if (widget !is null && widget !is this) { |
121 if (widget instanceof Control) { | 122 if (auto c = cast(Control)widget) { |
122 children [i++] = (Control) widget; | 123 children [i++] = c; |
123 } | 124 } |
124 } | 125 } |
125 } | 126 } |
126 temp = OS.g_list_next (temp); | 127 temp = cast(GList*)OS.g_list_next (temp); |
127 } | 128 } |
128 OS.g_list_free (list); | 129 OS.g_list_free (list); |
129 if (i == count) return children; | 130 if (i is count) return children; |
130 Control [] newChildren = new Control [i]; | 131 Control [] newChildren = new Control [i]; |
131 System.arraycopy (children, 0, newChildren, 0, i); | 132 System.arraycopy (children, 0, newChildren, 0, i); |
132 return newChildren; | 133 return newChildren; |
133 } | 134 } |
134 | 135 |
135 Control [] _getTabList () { | 136 Control [] _getTabList () { |
136 if (tabList == null) return tabList; | 137 if (tabList is null) return tabList; |
137 int count = 0; | 138 int count = 0; |
138 for (int i=0; i<tabList.length; i++) { | 139 for (int i=0; i<tabList.length; i++) { |
139 if (!tabList [i].isDisposed ()) count++; | 140 if (!tabList [i].isDisposed ()) count++; |
140 } | 141 } |
141 if (count == tabList.length) return tabList; | 142 if (count is tabList.length) return tabList; |
142 Control [] newList = new Control [count]; | 143 Control [] newList = new Control [count]; |
143 int index = 0; | 144 int index = 0; |
144 for (int i=0; i<tabList.length; i++) { | 145 for (int i=0; i<tabList.length; i++) { |
145 if (!tabList [i].isDisposed ()) { | 146 if (!tabList [i].isDisposed ()) { |
146 newList [index++] = tabList [i]; | 147 newList [index++] = tabList [i]; |
168 * | 169 * |
169 * @since 3.1 | 170 * @since 3.1 |
170 */ | 171 */ |
171 public void changed (Control[] changed) { | 172 public void changed (Control[] changed) { |
172 checkWidget (); | 173 checkWidget (); |
173 if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT); | 174 if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); |
174 for (int i=0; i<changed.length; i++) { | 175 for (int i=0; i<changed.length; i++) { |
175 Control control = changed [i]; | 176 Control control = changed [i]; |
176 if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); | 177 if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); |
177 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); | 178 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); |
178 boolean ancestor = false; | 179 bool ancestor = false; |
179 Composite composite = control.parent; | 180 Composite composite = control.parent; |
180 while (composite != null) { | 181 while (composite !is null) { |
181 ancestor = composite == this; | 182 ancestor = composite is this; |
182 if (ancestor) break; | 183 if (ancestor) break; |
183 composite = composite.parent; | 184 composite = composite.parent; |
184 } | 185 } |
185 if (!ancestor) error (SWT.ERROR_INVALID_PARENT); | 186 if (!ancestor) error (SWT.ERROR_INVALID_PARENT); |
186 } | 187 } |
187 for (int i=0; i<changed.length; i++) { | 188 for (int i=0; i<changed.length; i++) { |
188 Control child = changed [i]; | 189 Control child = changed [i]; |
189 Composite composite = child.parent; | 190 Composite composite = child.parent; |
190 while (child != this) { | 191 while (child !is this) { |
191 if (composite.layout == null || !composite.layout.flushCache (child)) { | 192 if (composite.layout_ is null || !composite.layout_.flushCache (child)) { |
192 composite.state |= LAYOUT_CHANGED; | 193 composite.state |= LAYOUT_CHANGED; |
193 } | 194 } |
194 child = composite; | 195 child = composite; |
195 composite = child.parent; | 196 composite = child.parent; |
196 } | 197 } |
197 } | 198 } |
198 } | 199 } |
199 | 200 |
200 void checkBuffered () { | 201 void checkBuffered () { |
201 if ((style & SWT.DOUBLE_BUFFERED) == 0 && (style & SWT.NO_BACKGROUND) != 0) { | 202 if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { |
202 return; | 203 return; |
203 } | 204 } |
204 super.checkBuffered(); | 205 super.checkBuffered(); |
205 } | 206 } |
206 | 207 |
207 protected void checkSubclass () { | 208 protected void checkSubclass () { |
208 /* Do nothing - Subclassing is allowed */ | 209 /* Do nothing - Subclassing is allowed */ |
209 } | 210 } |
210 | 211 |
211 int /*long*/ childStyle () { | 212 GtkStyle* childStyle () { |
212 if (scrolledHandle != 0) return 0; | 213 if (scrolledHandle !is null) return null; |
213 return super.childStyle (); | 214 return super.childStyle (); |
214 } | 215 } |
215 | 216 |
216 public Point computeSize (int wHint, int hHint, boolean changed) { | 217 public Point computeSize (int wHint, int hHint, bool changed) { |
217 checkWidget (); | 218 checkWidget (); |
218 if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; | 219 if (wHint !is SWT.DEFAULT && wHint < 0) wHint = 0; |
219 if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; | 220 if (hHint !is SWT.DEFAULT && hHint < 0) hHint = 0; |
220 Point size; | 221 Point size; |
221 if (layout != null) { | 222 if (layout_ !is null) { |
222 if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) { | 223 if (wHint is SWT.DEFAULT || hHint is SWT.DEFAULT) { |
223 changed |= (state & LAYOUT_CHANGED) != 0; | 224 changed |= (state & LAYOUT_CHANGED) !is 0; |
224 size = layout.computeSize (this, wHint, hHint, changed); | 225 size = layout_.computeSize (this, wHint, hHint, changed); |
225 state &= ~LAYOUT_CHANGED; | 226 state &= ~LAYOUT_CHANGED; |
226 } else { | 227 } else { |
227 size = new Point (wHint, hHint); | 228 size = new Point (wHint, hHint); |
228 } | 229 } |
229 } else { | 230 } else { |
230 size = minimumSize (wHint, hHint, changed); | 231 size = minimumSize (wHint, hHint, changed); |
231 } | 232 } |
232 if (size.x == 0) size.x = DEFAULT_WIDTH; | 233 if (size.x is 0) size.x = DEFAULT_WIDTH; |
233 if (size.y == 0) size.y = DEFAULT_HEIGHT; | 234 if (size.y is 0) size.y = DEFAULT_HEIGHT; |
234 if (wHint != SWT.DEFAULT) size.x = wHint; | 235 if (wHint !is SWT.DEFAULT) size.x = wHint; |
235 if (hHint != SWT.DEFAULT) size.y = hHint; | 236 if (hHint !is SWT.DEFAULT) size.y = hHint; |
236 Rectangle trim = computeTrim (0, 0, size.x, size.y); | 237 Rectangle trim = computeTrim (0, 0, size.x, size.y); |
237 return new Point (trim.width, trim.height); | 238 return new Point (trim.width, trim.height); |
238 } | 239 } |
239 | 240 |
240 Control [] computeTabList () { | 241 Control [] computeTabList () { |
241 Control result [] = super.computeTabList (); | 242 Control result [] = super.computeTabList (); |
242 if (result.length == 0) return result; | 243 if (result.length is 0) return result; |
243 Control [] list = tabList != null ? _getTabList () : _getChildren (); | 244 Control [] list = tabList !is null ? _getTabList () : _getChildren (); |
244 for (int i=0; i<list.length; i++) { | 245 for (int i=0; i<list.length; i++) { |
245 Control child = list [i]; | 246 Control child = list [i]; |
246 Control [] childList = child.computeTabList (); | 247 Control [] childList = child.computeTabList (); |
247 if (childList.length != 0) { | 248 if (childList.length !is 0) { |
248 Control [] newResult = new Control [result.length + childList.length]; | 249 Control [] newResult = new Control [result.length + childList.length]; |
249 System.arraycopy (result, 0, newResult, 0, result.length); | 250 System.arraycopy (result, 0, newResult, 0, result.length); |
250 System.arraycopy (childList, 0, newResult, result.length, childList.length); | 251 System.arraycopy (childList, 0, newResult, result.length, childList.length); |
251 result = newResult; | 252 result = newResult; |
252 } | 253 } |
254 return result; | 255 return result; |
255 } | 256 } |
256 | 257 |
257 void createHandle (int index) { | 258 void createHandle (int index) { |
258 state |= HANDLE | CANVAS; | 259 state |= HANDLE | CANVAS; |
259 boolean scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0; | 260 bool scrolled = (style & (SWT.H_SCROLL | SWT.V_SCROLL)) !is 0; |
260 if (!scrolled) state |= THEME_BACKGROUND; | 261 if (!scrolled) state |= THEME_BACKGROUND; |
261 createHandle (index, true, scrolled || (style & SWT.BORDER) != 0); | 262 createHandle (index, true, scrolled || (style & SWT.BORDER) !is 0); |
262 } | 263 } |
263 | 264 |
264 void createHandle (int index, boolean fixed, boolean scrolled) { | 265 void createHandle (int index, bool fixed, bool scrolled) { |
265 if (scrolled) { | 266 if (scrolled) { |
266 if (fixed) { | 267 if (fixed) { |
267 fixedHandle = OS.g_object_new (display.gtk_fixed_get_type (), 0); | 268 fixedHandle = cast(GtkWidget*) OS.g_object_new (display.gtk_fixed_get_type (), null); |
268 if (fixedHandle == 0) error (SWT.ERROR_NO_HANDLES); | 269 if (fixedHandle is null) error (SWT.ERROR_NO_HANDLES); |
269 OS.gtk_fixed_set_has_window (fixedHandle, true); | 270 OS.gtk_fixed_set_has_window (cast(GtkFixed*)fixedHandle, true); |
270 } | 271 } |
271 int /*long*/ vadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); | 272 auto vadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); |
272 if (vadj == 0) error (SWT.ERROR_NO_HANDLES); | 273 if (vadj is null) error (SWT.ERROR_NO_HANDLES); |
273 int /*long*/ hadj = OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); | 274 auto hadj = cast(GtkAdjustment*)OS.gtk_adjustment_new (0, 0, 100, 1, 10, 10); |
274 if (hadj == 0) error (SWT.ERROR_NO_HANDLES); | 275 if (hadj is null) error (SWT.ERROR_NO_HANDLES); |
275 scrolledHandle = OS.gtk_scrolled_window_new (hadj, vadj); | 276 scrolledHandle = cast(GtkWidget*) OS.gtk_scrolled_window_new (hadj, vadj); |
276 if (scrolledHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES); | 277 if (scrolledHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); |
277 } | 278 } |
278 handle = OS.g_object_new (display.gtk_fixed_get_type (), 0); | 279 handle = cast(GtkWidget*)OS.g_object_new (display.gtk_fixed_get_type (), null); |
279 if (handle == 0) SWT.error (SWT.ERROR_NO_HANDLES); | 280 if (handle is null) SWT.error (SWT.ERROR_NO_HANDLES); |
280 OS.gtk_fixed_set_has_window (handle, true); | 281 OS.gtk_fixed_set_has_window (cast(GtkFixed*)handle, true); |
281 OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS); | 282 OS.GTK_WIDGET_SET_FLAGS(handle, OS.GTK_CAN_FOCUS); |
282 if ((style & SWT.EMBEDDED) == 0) { | 283 if ((style & SWT.EMBEDDED) is 0) { |
283 if ((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0) { | 284 if ((state & CANVAS) !is 0 && (style & SWT.NO_FOCUS) is 0) { |
284 /* Prevent an input method context from being created for the Browser widget */ | 285 /* Prevent an input method context from being created for the Browser widget */ |
285 if (display.getData (NO_INPUT_METHOD) == null) { | 286 if (display.getData (NO_INPUT_METHOD) is null) { |
286 imHandle = OS.gtk_im_multicontext_new (); | 287 imHandle_ = OS.gtk_im_multicontext_new (); |
287 if (imHandle == 0) error (SWT.ERROR_NO_HANDLES); | 288 if (imHandle_ is null) error (SWT.ERROR_NO_HANDLES); |
288 } | 289 } |
289 } | 290 } |
290 } | 291 } |
291 if (scrolled) { | 292 if (scrolled) { |
292 if (fixed) OS.gtk_container_add (fixedHandle, scrolledHandle); | 293 if (fixed) OS.gtk_container_add (cast(GtkContainer*)fixedHandle, scrolledHandle); |
293 /* | 294 /* |
294 * Force the scrolledWindow to have a single child that is | 295 * Force the scrolledWindow to have a single child that is |
295 * not scrolled automatically. Calling gtk_container_add() | 296 * not scrolled automatically. Calling gtk_container_add() |
296 * seems to add the child correctly but cause a warning. | 297 * seems to add the child correctly but cause a warning. |
297 */ | 298 */ |
298 boolean warnings = display.getWarnings (); | 299 bool warnings = display.getWarnings (); |
299 display.setWarnings (false); | 300 display.setWarnings (false); |
300 OS.gtk_container_add (scrolledHandle, handle); | 301 OS.gtk_container_add (cast(GtkContainer*)scrolledHandle, handle); |
301 display.setWarnings (warnings); | 302 display.setWarnings (warnings); |
302 | 303 |
303 int hsp = (style & SWT.H_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; | 304 int hsp = (style & SWT.H_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; |
304 int vsp = (style & SWT.V_SCROLL) != 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; | 305 int vsp = (style & SWT.V_SCROLL) !is 0 ? OS.GTK_POLICY_ALWAYS : OS.GTK_POLICY_NEVER; |
305 OS.gtk_scrolled_window_set_policy (scrolledHandle, hsp, vsp); | 306 OS.gtk_scrolled_window_set_policy (cast(GtkScrolledWindow*)scrolledHandle, hsp, vsp); |
306 if (hasBorder ()) { | 307 if (hasBorder ()) { |
307 OS.gtk_scrolled_window_set_shadow_type (scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); | 308 OS.gtk_scrolled_window_set_shadow_type (cast(GtkScrolledWindow*)scrolledHandle, OS.GTK_SHADOW_ETCHED_IN); |
308 } | 309 } |
309 } | 310 } |
310 if ((style & SWT.EMBEDDED) != 0) { | 311 if ((style & SWT.EMBEDDED) !is 0) { |
311 socketHandle = OS.gtk_socket_new (); | 312 socketHandle = OS.gtk_socket_new (); |
312 if (socketHandle == 0) SWT.error (SWT.ERROR_NO_HANDLES); | 313 if (socketHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); |
313 OS.gtk_container_add (handle, socketHandle); | 314 OS.gtk_container_add (cast(GtkContainer*)handle, cast(GtkWidget*)socketHandle); |
314 } | 315 } |
315 if ((style & SWT.NO_REDRAW_RESIZE) != 0) { | 316 if ((style & SWT.NO_REDRAW_RESIZE) !is 0) { |
316 OS.gtk_widget_set_redraw_on_allocate (handle, false); | 317 OS.gtk_widget_set_redraw_on_allocate (handle, false); |
317 } | 318 } |
318 /* | 319 /* |
319 * Bug in GTK. When a widget is double buffered and the back | 320 * Bug in GTK. When a widget is double buffered and the back |
320 * pixmap is null, the double buffer pixmap is filled with the | 321 * pixmap is null, the double buffer pixmap is filled with the |
322 * the screen. If nothing is drawn during an expose event, | 323 * the screen. If nothing is drawn during an expose event, |
323 * the pixels are altered. The fix is to clear double buffering | 324 * the pixels are altered. The fix is to clear double buffering |
324 * when NO_BACKGROUND is set and DOUBLE_BUFFERED | 325 * when NO_BACKGROUND is set and DOUBLE_BUFFERED |
325 * is not explicitly set. | 326 * is not explicitly set. |
326 */ | 327 */ |
327 if ((style & SWT.DOUBLE_BUFFERED) == 0 && (style & SWT.NO_BACKGROUND) != 0) { | 328 if ((style & SWT.DOUBLE_BUFFERED) is 0 && (style & SWT.NO_BACKGROUND) !is 0) { |
328 OS.gtk_widget_set_double_buffered (handle, false); | 329 OS.gtk_widget_set_double_buffered (handle, false); |
329 } | 330 } |
330 } | 331 } |
331 | 332 |
332 void deregister () { | 333 void deregister () { |
333 super.deregister (); | 334 super.deregister (); |
334 if (socketHandle != 0) display.removeWidget (socketHandle); | 335 if (socketHandle !is null) display.removeWidget (cast(GtkWidget*)socketHandle); |
335 } | 336 } |
336 | 337 |
337 void drawBackground (GC gc, int x, int y, int width, int height) { | 338 void drawBackground (GC gc, int x, int y, int width, int height) { |
338 Control control = findBackgroundControl (); | 339 Control control = findBackgroundControl (); |
339 if (control != null) { | 340 if (control !is null) { |
340 GCData data = gc.getGCData (); | 341 GCData data = gc.getGCData (); |
341 int /*long*/ cairo = data.cairo; | 342 auto cairo = data.cairo; |
342 if (cairo != 0) { | 343 if (cairo !is null) { |
343 Cairo.cairo_save (cairo); | 344 Cairo.cairo_save (cairo); |
344 if (control.backgroundImage != null) { | 345 if (control.backgroundImage !is null) { |
345 Point pt = display.map (this, control, 0, 0); | 346 Point pt = display.map (this, control, 0, 0); |
346 Cairo.cairo_translate (cairo, -pt.x, -pt.y); | 347 Cairo.cairo_translate (cairo, -pt.x, -pt.y); |
347 x += pt.x; | 348 x += pt.x; |
348 y += pt.y; | 349 y += pt.y; |
349 int /*long*/ xDisplay = OS.GDK_DISPLAY (); | 350 auto xDisplay = OS.GDK_DISPLAY (); |
350 int /*long*/ xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system()); | 351 auto xVisual = OS.gdk_x11_visual_get_xvisual (OS.gdk_visual_get_system()); |
351 int /*long*/ drawable = control.backgroundImage.pixmap; | 352 auto drawable = control.backgroundImage.pixmap; |
352 int /*long*/ xDrawable = OS.GDK_PIXMAP_XID (drawable); | 353 auto xDrawable = OS.GDK_PIXMAP_XID (drawable); |
353 int [] w = new int [1], h = new int [1]; | 354 int w, h; |
354 OS.gdk_drawable_get_size (drawable, w, h); | 355 OS.gdk_drawable_get_size (cast(GdkDrawable*)drawable, &w, &h); |
355 int /*long*/ surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w [0], h [0]); | 356 auto surface = Cairo.cairo_xlib_surface_create (xDisplay, xDrawable, xVisual, w, h); |
356 if (surface == 0) error (SWT.ERROR_NO_HANDLES); | 357 if (surface is null) error (SWT.ERROR_NO_HANDLES); |
357 int /*long*/ pattern = Cairo.cairo_pattern_create_for_surface (surface); | 358 auto pattern = Cairo.cairo_pattern_create_for_surface (surface); |
358 if (pattern == 0) error (SWT.ERROR_NO_HANDLES); | 359 if (pattern is null) error (SWT.ERROR_NO_HANDLES); |
359 Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); | 360 Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); |
360 Cairo.cairo_set_source (cairo, pattern); | 361 Cairo.cairo_set_source (cairo, pattern); |
361 Cairo.cairo_surface_destroy (surface); | 362 Cairo.cairo_surface_destroy (surface); |
362 Cairo.cairo_pattern_destroy (pattern); | 363 Cairo.cairo_pattern_destroy (pattern); |
363 } else { | 364 } else { |
364 GdkColor color = control.getBackgroundColor (); | 365 GdkColor* color = control.getBackgroundColor (); |
365 Cairo.cairo_set_source_rgba (cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, data.alpha / (float)0xFF); | 366 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); |
366 } | 367 } |
367 Cairo.cairo_rectangle (cairo, x, y, width, height); | 368 Cairo.cairo_rectangle (cairo, x, y, width, height); |
368 Cairo.cairo_fill (cairo); | 369 Cairo.cairo_fill (cairo); |
369 Cairo.cairo_restore (cairo); | 370 Cairo.cairo_restore (cairo); |
370 } else { | 371 } else { |
371 int /*long*/ gdkGC = gc.handle; | 372 auto gdkGC = gc.handle; |
372 GdkGCValues values = new GdkGCValues (); | 373 GdkGCValues* values = new GdkGCValues (); |
373 OS.gdk_gc_get_values (gdkGC, values); | 374 OS.gdk_gc_get_values (gdkGC, values); |
374 if (control.backgroundImage != null) { | 375 if (control.backgroundImage !is null) { |
375 Point pt = display.map (this, control, 0, 0); | 376 Point pt = display.map (this, control, 0, 0); |
376 OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); | 377 OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); |
377 OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y); | 378 OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y); |
378 OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap); | 379 OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap); |
379 OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); | 380 OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); |
380 OS.gdk_gc_set_fill (gdkGC, values.fill); | 381 OS.gdk_gc_set_fill (gdkGC, values.fill); |
381 OS.gdk_gc_set_ts_origin (gdkGC, values.ts_x_origin, values.ts_y_origin); | 382 OS.gdk_gc_set_ts_origin (gdkGC, values.ts_x_origin, values.ts_y_origin); |
382 } else { | 383 } else { |
383 GdkColor color = control.getBackgroundColor (); | 384 GdkColor* color = control.getBackgroundColor (); |
384 OS.gdk_gc_set_foreground (gdkGC, color); | 385 OS.gdk_gc_set_foreground (gdkGC, color); |
385 OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); | 386 OS.gdk_draw_rectangle (data.drawable, gdkGC, 1, x, y, width, height); |
386 color.pixel = values.foreground_pixel; | 387 color.pixel = values.foreground.pixel; |
387 OS.gdk_gc_set_foreground (gdkGC, color); | 388 OS.gdk_gc_set_foreground (gdkGC, color); |
388 } | 389 } |
389 } | 390 } |
390 } else { | 391 } else { |
391 gc.fillRectangle (x, y, width, height); | 392 gc.fillRectangle (x, y, width, height); |
392 } | 393 } |
393 } | 394 } |
394 | 395 |
395 void enableWidget (boolean enabled) { | 396 void enableWidget (bool enabled) { |
396 if ((state & CANVAS) != 0) return; | 397 if ((state & CANVAS) !is 0) return; |
397 super.enableWidget (enabled); | 398 super.enableWidget (enabled); |
398 } | 399 } |
399 | 400 |
400 Composite findDeferredControl () { | 401 Composite findDeferredControl () { |
401 return layoutCount > 0 ? this : parent.findDeferredControl (); | 402 return layoutCount > 0 ? this : parent.findDeferredControl (); |
402 } | 403 } |
403 | 404 |
404 Menu [] findMenus (Control control) { | 405 Menu [] findMenus (Control control) { |
405 if (control == this) return new Menu [0]; | 406 if (control is this) return new Menu [0]; |
406 Menu result [] = super.findMenus (control); | 407 Menu result [] = super.findMenus (control); |
407 Control [] children = _getChildren (); | 408 Control [] children = _getChildren (); |
408 for (int i=0; i<children.length; i++) { | 409 for (int i=0; i<children.length; i++) { |
409 Control child = children [i]; | 410 Control child = children [i]; |
410 Menu [] menuList = child.findMenus (control); | 411 Menu [] menuList = child.findMenus (control); |
411 if (menuList.length != 0) { | 412 if (menuList.length !is 0) { |
412 Menu [] newResult = new Menu [result.length + menuList.length]; | 413 Menu [] newResult = new Menu [result.length + menuList.length]; |
413 System.arraycopy (result, 0, newResult, 0, result.length); | 414 System.arraycopy (result, 0, newResult, 0, result.length); |
414 System.arraycopy (menuList, 0, newResult, result.length, menuList.length); | 415 System.arraycopy (menuList, 0, newResult, result.length, menuList.length); |
415 result = newResult; | 416 result = newResult; |
416 } | 417 } |
424 for (int i=0; i<children.length; i++) { | 425 for (int i=0; i<children.length; i++) { |
425 children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); | 426 children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus); |
426 } | 427 } |
427 } | 428 } |
428 | 429 |
430 alias Scrollable.fixStyle fixStyle; | |
429 void fixStyle () { | 431 void fixStyle () { |
430 super.fixStyle (); | 432 super.fixStyle (); |
431 if (scrolledHandle == 0) fixStyle (handle); | 433 if (scrolledHandle is null) fixStyle (handle); |
432 Control[] children = _getChildren (); | 434 Control[] children = _getChildren (); |
433 for (int i = 0; i < children.length; i++) { | 435 for (int i = 0; i < children.length; i++) { |
434 children [i].fixStyle (); | 436 children [i].fixStyle (); |
435 } | 437 } |
436 } | 438 } |
437 | 439 |
438 void fixTabList (Control control) { | 440 void fixTabList (Control control) { |
439 if (tabList == null) return; | 441 if (tabList is null) return; |
440 int count = 0; | 442 int count = 0; |
441 for (int i=0; i<tabList.length; i++) { | 443 for (int i=0; i<tabList.length; i++) { |
442 if (tabList [i] == control) count++; | 444 if (tabList [i] is control) count++; |
443 } | 445 } |
444 if (count == 0) return; | 446 if (count is 0) return; |
445 Control [] newList = null; | 447 Control [] newList = null; |
446 int length = tabList.length - count; | 448 int length = tabList.length - count; |
447 if (length != 0) { | 449 if (length !is 0) { |
448 newList = new Control [length]; | 450 newList = new Control [length]; |
449 int index = 0; | 451 int index = 0; |
450 for (int i=0; i<tabList.length; i++) { | 452 for (int i=0; i<tabList.length; i++) { |
451 if (tabList [i] != control) { | 453 if (tabList [i] !is control) { |
452 newList [index++] = tabList [i]; | 454 newList [index++] = tabList [i]; |
453 } | 455 } |
454 } | 456 } |
455 } | 457 } |
456 tabList = newList; | 458 tabList = newList; |
457 } | 459 } |
458 | 460 |
459 void fixZOrder () { | 461 void fixZOrder () { |
460 if ((state & CANVAS) != 0) return; | 462 if ((state & CANVAS) !is 0) return; |
461 int /*long*/ parentHandle = parentingHandle (); | 463 auto parentHandle = parentingHandle (); |
462 int /*long*/ parentWindow = OS.GTK_WIDGET_WINDOW (parentHandle); | 464 auto parentWindow = OS.GTK_WIDGET_WINDOW (cast(GtkWidget*)parentHandle); |
463 if (parentWindow == 0) return; | 465 if (parentWindow is null) return; |
464 int /*long*/ [] userData = new int /*long*/ [1]; | 466 GObject* userData; |
465 int /*long*/ windowList = OS.gdk_window_get_children (parentWindow); | 467 auto windowList = OS.gdk_window_get_children (parentWindow); |
466 if (windowList != 0) { | 468 if (windowList !is null) { |
467 int /*long*/ windows = windowList; | 469 auto windows = windowList; |
468 while (windows != 0) { | 470 while (windows !is null) { |
469 int /*long*/ window = OS.g_list_data (windows); | 471 auto window = cast(GdkDrawable*)OS.g_list_data (windows); |
470 if (window != redrawWindow) { | 472 if (window !is redrawWindow) { |
471 OS.gdk_window_get_user_data (window, userData); | 473 OS.gdk_window_get_user_data (window, cast(void**)&userData); |
472 if (userData [0] == 0 || OS.G_OBJECT_TYPE (userData [0]) != display.gtk_fixed_get_type ()) { | 474 if (userData is null || OS.G_OBJECT_TYPE (userData) !is display.gtk_fixed_get_type ()) { |
473 OS.gdk_window_lower (window); | 475 OS.gdk_window_lower (window); |
474 } | 476 } |
475 } | 477 } |
476 windows = OS.g_list_next (windows); | 478 windows = cast(GList*)OS.g_list_next (windows); |
477 } | 479 } |
478 OS.g_list_free (windowList); | 480 OS.g_list_free (windowList); |
479 } | 481 } |
480 } | 482 } |
481 | 483 |
482 int /*long*/ focusHandle () { | 484 GtkWidget* focusHandle () { |
483 if (socketHandle != 0) return socketHandle; | 485 if (socketHandle !is null) return socketHandle; |
484 return super.focusHandle (); | 486 return super.focusHandle (); |
485 } | 487 } |
486 | 488 |
487 boolean forceFocus (int /*long*/ focusHandle) { | 489 bool forceFocus (GtkWidget* focusHandle) { |
488 if (socketHandle != 0) OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); | 490 if (socketHandle !is null) OS.GTK_WIDGET_SET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); |
489 boolean result = super.forceFocus (focusHandle); | 491 bool result = super.forceFocus (focusHandle); |
490 if (socketHandle != 0) OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); | 492 if (socketHandle !is null) OS.GTK_WIDGET_UNSET_FLAGS (focusHandle, OS.GTK_CAN_FOCUS); |
491 return result; | 493 return result; |
492 } | 494 } |
493 | 495 |
494 /** | 496 /** |
495 * Returns the receiver's background drawing mode. This | 497 * Returns the receiver's background drawing mode. This |
543 int getChildrenCount () { | 545 int getChildrenCount () { |
544 /* | 546 /* |
545 * NOTE: The current implementation will count | 547 * NOTE: The current implementation will count |
546 * non-registered children. | 548 * non-registered children. |
547 */ | 549 */ |
548 int /*long*/ list = OS.gtk_container_get_children (handle); | 550 auto list = OS.gtk_container_get_children (cast(GtkContainer*)handle); |
549 if (list == 0) return 0; | 551 if (list is null) return 0; |
550 int count = OS.g_list_length (list); | 552 int count = OS.g_list_length (list); |
551 OS.g_list_free (list); | 553 OS.g_list_free (list); |
552 return count; | 554 return count; |
553 } | 555 } |
554 | 556 |
555 public Rectangle getClientArea () { | 557 public Rectangle getClientArea () { |
556 checkWidget(); | 558 checkWidget(); |
557 if ((state & CANVAS) != 0) { | 559 if ((state & CANVAS) !is 0) { |
558 if ((state & ZERO_WIDTH) != 0 && (state & ZERO_HEIGHT) != 0) { | 560 if ((state & ZERO_WIDTH) !is 0 && (state & ZERO_HEIGHT) !is 0) { |
559 return new Rectangle (0, 0, 0, 0); | 561 return new Rectangle (0, 0, 0, 0); |
560 } | 562 } |
561 forceResize (); | 563 forceResize (); |
562 int /*long*/ clientHandle = clientHandle (); | 564 auto clientHandle = clientHandle (); |
563 int width = (state & ZERO_WIDTH) != 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); | 565 int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); |
564 int height = (state & ZERO_HEIGHT) != 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); | 566 int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); |
565 return new Rectangle (0, 0, width, height); | 567 return new Rectangle (0, 0, width, height); |
566 } | 568 } |
567 return super.getClientArea(); | 569 return super.getClientArea(); |
568 } | 570 } |
569 | 571 |
578 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 580 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
579 * </ul> | 581 * </ul> |
580 */ | 582 */ |
581 public Layout getLayout () { | 583 public Layout getLayout () { |
582 checkWidget(); | 584 checkWidget(); |
583 return layout; | 585 return layout_; |
584 } | 586 } |
585 | 587 |
586 /** | 588 /** |
587 * Returns <code>true</code> if the receiver has deferred | 589 * Returns <code>true</code> if the receiver has deferred |
588 * the performing of layout, and <code>false</code> otherwise. | 590 * the performing of layout, and <code>false</code> otherwise. |
592 * @exception SWTException <ul> | 594 * @exception SWTException <ul> |
593 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 595 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
594 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 596 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
595 * </ul> | 597 * </ul> |
596 * | 598 * |
597 * @see #setLayoutDeferred(boolean) | 599 * @see #setLayoutDeferred(bool) |
598 * @see #isLayoutDeferred() | 600 * @see #isLayoutDeferred() |
599 * | 601 * |
600 * @since 3.1 | 602 * @since 3.1 |
601 */ | 603 */ |
602 public boolean getLayoutDeferred () { | 604 public bool getLayoutDeferred () { |
603 checkWidget (); | 605 checkWidget (); |
604 return layoutCount > 0 ; | 606 return layoutCount > 0 ; |
605 } | 607 } |
606 | 608 |
607 /** | 609 /** |
617 * @see #setTabList | 619 * @see #setTabList |
618 */ | 620 */ |
619 public Control [] getTabList () { | 621 public Control [] getTabList () { |
620 checkWidget (); | 622 checkWidget (); |
621 Control [] tabList = _getTabList (); | 623 Control [] tabList = _getTabList (); |
622 if (tabList == null) { | 624 if (tabList is null) { |
623 int count = 0; | 625 int count = 0; |
624 Control [] list =_getChildren (); | 626 Control [] list =_getChildren (); |
625 for (int i=0; i<list.length; i++) { | 627 for (int i=0; i<list.length; i++) { |
626 if (list [i].isTabGroup ()) count++; | 628 if (list [i].isTabGroup ()) count++; |
627 } | 629 } |
634 } | 636 } |
635 } | 637 } |
636 return tabList; | 638 return tabList; |
637 } | 639 } |
638 | 640 |
639 int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ event) { | 641 override int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* event) { |
640 int /*long*/ result = super.gtk_button_press_event (widget, event); | 642 auto result = super.gtk_button_press_event (widget, event); |
641 if (result != 0) return result; | 643 if (result !is 0) return result; |
642 if ((state & CANVAS) != 0) { | 644 if ((state & CANVAS) !is 0) { |
643 if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) { | 645 if ((style & SWT.NO_FOCUS) is 0 && hooksKeys ()) { |
644 GdkEventButton gdkEvent = new GdkEventButton (); | 646 if (event.button is 1) { |
645 OS.memmove (gdkEvent, event, GdkEventButton.sizeof); | 647 if (getChildrenCount () is 0) setFocus (); |
646 if (gdkEvent.button == 1) { | |
647 if (getChildrenCount () == 0) setFocus (); | |
648 } | 648 } |
649 } | 649 } |
650 } | 650 } |
651 return result; | 651 return result; |
652 } | 652 } |
653 | 653 |
654 int /*long*/ gtk_expose_event (int /*long*/ widget, int /*long*/ eventPtr) { | 654 override int /*long*/ gtk_expose_event (GtkWidget* widget, GdkEventExpose* eventPtr) { |
655 if ((state & OBSCURED) != 0) return 0; | 655 if ((state & OBSCURED) !is 0) return 0; |
656 if ((state & CANVAS) == 0) { | 656 if ((state & CANVAS) is 0) { |
657 return super.gtk_expose_event (widget, eventPtr); | 657 return super.gtk_expose_event (widget, eventPtr); |
658 } | 658 } |
659 if ((style & SWT.NO_MERGE_PAINTS) == 0) { | 659 if ((style & SWT.NO_MERGE_PAINTS) is 0) { |
660 return super.gtk_expose_event (widget, eventPtr); | 660 return super.gtk_expose_event (widget, eventPtr); |
661 } | 661 } |
662 if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; | 662 if (!hooks (SWT.Paint) && !filters (SWT.Paint)) return 0; |
663 GdkEventExpose gdkEvent = new GdkEventExpose (); | 663 GdkEventExpose* gdkEvent = eventPtr; |
664 OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof); | 664 GdkRectangle* rectangles; |
665 int /*long*/ [] rectangles = new int /*long*/ [1]; | 665 int n_rectangles; |
666 int [] n_rectangles = new int [1]; | 666 OS.gdk_region_get_rectangles (gdkEvent.region, &rectangles, &n_rectangles); |
667 OS.gdk_region_get_rectangles (gdkEvent.region, rectangles, n_rectangles); | 667 for (int i=0; i<n_rectangles; i++) { |
668 GdkRectangle rect = new GdkRectangle (); | |
669 for (int i=0; i<n_rectangles[0]; i++) { | |
670 Event event = new Event (); | 668 Event event = new Event (); |
671 OS.memmove (rect, rectangles [0] + i * GdkRectangle.sizeof, GdkRectangle.sizeof); | 669 event.x = rectangles[i].x; |
672 event.x = rect.x; | 670 event.y = rectangles[i].y; |
673 event.y = rect.y; | 671 event.width = rectangles[i].width; |
674 event.width = rect.width; | 672 event.height = rectangles[i].height; |
675 event.height = rect.height; | 673 auto damageRgn = OS.gdk_region_new (); |
676 int /*long*/ damageRgn = OS.gdk_region_new (); | 674 OS.gdk_region_union_with_rect (damageRgn, rectangles + i ); |
677 OS.gdk_region_union_with_rect (damageRgn, rect); | |
678 GCData data = new GCData (); | 675 GCData data = new GCData (); |
679 data.damageRgn = damageRgn; | 676 data.damageRgn = damageRgn; |
680 GC gc = event.gc = GC.gtk_new (this, data); | 677 GC gc = event.gc = GC.gtk_new (this, data); |
681 OS.gdk_gc_set_clip_region (gc.handle, damageRgn); | 678 OS.gdk_gc_set_clip_region (gc.handle, damageRgn); |
682 sendEvent (SWT.Paint, event); | 679 sendEvent (SWT.Paint, event); |
683 gc.dispose (); | 680 gc.dispose (); |
684 OS.gdk_region_destroy (damageRgn); | 681 OS.gdk_region_destroy (damageRgn); |
685 event.gc = null; | 682 event.gc = null; |
686 } | 683 } |
687 OS.g_free (rectangles [0]); | 684 OS.g_free (rectangles); |
688 return 0; | 685 return 0; |
689 } | 686 } |
690 | 687 |
691 int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ event) { | 688 override int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* event) { |
692 int /*long*/ result = super.gtk_key_press_event (widget, event); | 689 auto result = super.gtk_key_press_event (widget, event); |
693 if (result != 0) return result; | 690 if (result !is 0) return result; |
694 /* | 691 /* |
695 * Feature in GTK. The default behavior when the return key | 692 * Feature in GTK. The default behavior when the return key |
696 * is pressed is to select the default button. This is not the | 693 * is pressed is to select the default button. This is not the |
697 * expected behavior for Composite and its subclasses. The | 694 * expected behavior for Composite and its subclasses. The |
698 * fix is to avoid calling the default handler. | 695 * fix is to avoid calling the default handler. |
699 */ | 696 */ |
700 if ((state & CANVAS) != 0 && socketHandle == 0) { | 697 if ((state & CANVAS) !is 0 && socketHandle is null) { |
701 GdkEventKey keyEvent = new GdkEventKey (); | 698 GdkEventKey* keyEvent = event; |
702 OS.memmove (keyEvent, event, GdkEventKey.sizeof); | |
703 int key = keyEvent.keyval; | 699 int key = keyEvent.keyval; |
704 switch (key) { | 700 switch (key) { |
705 case OS.GDK_Return: | 701 case OS.GDK_Return: |
706 case OS.GDK_KP_Enter: return 1; | 702 case OS.GDK_KP_Enter: return 1; |
707 } | 703 } |
708 } | 704 } |
709 return result; | 705 return result; |
710 } | 706 } |
711 | 707 |
712 int /*long*/ gtk_focus (int /*long*/ widget, int /*long*/ directionType) { | 708 override int /*long*/ gtk_focus (GtkWidget* widget, int /*long*/ directionType) { |
713 if (widget == socketHandle) return 0; | 709 if (widget is socketHandle) return 0; |
714 return super.gtk_focus (widget, directionType); | 710 return super.gtk_focus (widget, directionType); |
715 } | 711 } |
716 | 712 |
717 int /*long*/ gtk_focus_in_event (int /*long*/ widget, int /*long*/ event) { | 713 override int /*long*/ gtk_focus_in_event (GtkWidget* widget, int /*long*/ event) { |
718 int /*long*/ result = super.gtk_focus_in_event (widget, event); | 714 int /*long*/ result = super.gtk_focus_in_event (widget, event); |
719 return (state & CANVAS) != 0 ? 1 : result; | 715 return (state & CANVAS) !is 0 ? 1 : result; |
720 } | 716 } |
721 | 717 |
722 int /*long*/ gtk_focus_out_event (int /*long*/ widget, int /*long*/ event) { | 718 override int /*long*/ gtk_focus_out_event (GtkWidget* widget, int /*long*/ event) { |
723 int /*long*/ result = super.gtk_focus_out_event (widget, event); | 719 auto result = super.gtk_focus_out_event (widget, event); |
724 return (state & CANVAS) != 0 ? 1 : result; | 720 return (state & CANVAS) !is 0 ? 1 : result; |
725 } | 721 } |
726 | 722 |
727 int /*long*/ gtk_map (int /*long*/ widget) { | 723 override int /*long*/ gtk_map (GtkWidget* widget) { |
728 fixZOrder (); | 724 fixZOrder (); |
729 return 0; | 725 return 0; |
730 } | 726 } |
731 | 727 |
732 int /*long*/ gtk_realize (int /*long*/ widget) { | 728 override int /*long*/ gtk_realize (GtkWidget* widget) { |
733 int /*long*/ result = super.gtk_realize (widget); | 729 auto result = super.gtk_realize (widget); |
734 if ((style & SWT.NO_BACKGROUND) != 0) { | 730 if ((style & SWT.NO_BACKGROUND) !is 0) { |
735 int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ()); | 731 auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); |
736 if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, false); | 732 if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); |
737 } | 733 } |
738 if (socketHandle != 0) { | 734 if (socketHandle !is null) { |
739 embeddedHandle = OS.gtk_socket_get_id (socketHandle); | 735 embeddedHandle = OS.gtk_socket_get_id (cast(GtkSocket*)socketHandle); |
740 } | 736 } |
741 return result; | 737 return result; |
742 } | 738 } |
743 | 739 |
744 int /*long*/ gtk_scroll_child (int /*long*/ widget, int /*long*/ scrollType, int /*long*/ horizontal) { | 740 override int /*long*/ gtk_scroll_child (GtkWidget* widget, int /*long*/ scrollType, int /*long*/ horizontal) { |
745 /* Stop GTK scroll child signal for canvas */ | 741 /* Stop GTK scroll child signal for canvas */ |
746 OS.g_signal_stop_emission_by_name (widget, OS.scroll_child); | 742 OS.g_signal_stop_emission_by_name (widget, OS.scroll_child.ptr); |
747 return 1; | 743 return 1; |
748 } | 744 } |
749 | 745 |
750 int /*long*/ gtk_style_set (int /*long*/ widget, int /*long*/ previousStyle) { | 746 override int /*long*/ gtk_style_set (GtkWidget* widget, int /*long*/ previousStyle) { |
751 int /*long*/ result = super.gtk_style_set (widget, previousStyle); | 747 auto result = super.gtk_style_set (widget, previousStyle); |
752 if ((style & SWT.NO_BACKGROUND) != 0) { | 748 if ((style & SWT.NO_BACKGROUND) !is 0) { |
753 int /*long*/ window = OS.GTK_WIDGET_WINDOW (paintHandle ()); | 749 auto window = OS.GTK_WIDGET_WINDOW (paintHandle ()); |
754 if (window != 0) OS.gdk_window_set_back_pixmap (window, 0, false); | 750 if (window !is null) OS.gdk_window_set_back_pixmap (window, null, false); |
755 } | 751 } |
756 return result; | 752 return result; |
757 } | 753 } |
758 | 754 |
759 boolean hasBorder () { | 755 bool hasBorder () { |
760 return (style & SWT.BORDER) != 0; | 756 return (style & SWT.BORDER) !is 0; |
761 } | 757 } |
762 | 758 |
763 void hookEvents () { | 759 void hookEvents () { |
764 super.hookEvents (); | 760 super.hookEvents (); |
765 if ((state & CANVAS) != 0) { | 761 if ((state & CANVAS) !is 0) { |
766 OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK); | 762 OS.gtk_widget_add_events (handle, OS.GDK_POINTER_MOTION_HINT_MASK); |
767 if (scrolledHandle != 0) { | 763 if (scrolledHandle !is null) { |
768 OS.g_signal_connect_closure (scrolledHandle, OS.scroll_child, display.closures [SCROLL_CHILD], false); | 764 OS.g_signal_connect_closure (scrolledHandle, OS.scroll_child.ptr, display.closures [SCROLL_CHILD], false); |
769 } | 765 } |
770 } | 766 } |
771 } | 767 } |
772 | 768 |
773 boolean hooksKeys () { | 769 bool hooksKeys () { |
774 return hooks (SWT.KeyDown) || hooks (SWT.KeyUp); | 770 return hooks (SWT.KeyDown) || hooks (SWT.KeyUp); |
775 } | 771 } |
776 | 772 |
777 int /*long*/ imHandle () { | 773 GtkIMContext* imHandle () { |
778 return imHandle; | 774 return imHandle_; |
779 } | 775 } |
780 | 776 |
781 /** | 777 /** |
782 * Returns <code>true</code> if the receiver or any ancestor | 778 * Returns <code>true</code> if the receiver or any ancestor |
783 * up to and including the receiver's nearest ancestor shell | 779 * up to and including the receiver's nearest ancestor shell |
789 * @exception SWTException <ul> | 785 * @exception SWTException <ul> |
790 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 786 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
791 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 787 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
792 * </ul> | 788 * </ul> |
793 * | 789 * |
794 * @see #setLayoutDeferred(boolean) | 790 * @see #setLayoutDeferred(bool) |
795 * @see #getLayoutDeferred() | 791 * @see #getLayoutDeferred() |
796 * | 792 * |
797 * @since 3.1 | 793 * @since 3.1 |
798 */ | 794 */ |
799 public boolean isLayoutDeferred () { | 795 public bool isLayoutDeferred () { |
800 checkWidget (); | 796 checkWidget (); |
801 return findDeferredControl () != null; | 797 return findDeferredControl () !is null; |
802 } | 798 } |
803 | 799 |
804 boolean isTabGroup() { | 800 bool isTabGroup() { |
805 if ((state & CANVAS) != 0) return true; | 801 if ((state & CANVAS) !is 0) return true; |
806 return super.isTabGroup(); | 802 return super.isTabGroup(); |
807 } | 803 } |
808 | 804 |
809 /** | 805 /** |
810 * If the receiver has a layout, asks the layout to <em>lay out</em> | 806 * If the receiver has a layout, asks the layout to <em>lay out</em> |
859 * @exception SWTException <ul> | 855 * @exception SWTException <ul> |
860 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 856 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
861 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 857 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
862 * </ul> | 858 * </ul> |
863 */ | 859 */ |
864 public void layout (boolean changed) { | 860 public void layout (bool changed) { |
865 checkWidget (); | 861 checkWidget (); |
866 if (layout == null) return; | 862 if (layout_ is null) return; |
867 layout (changed, false); | 863 layout (changed, false); |
868 } | 864 } |
869 | 865 |
870 /** | 866 /** |
871 * If the receiver has a layout, asks the layout to <em>lay out</em> | 867 * If the receiver has a layout, asks the layout to <em>lay out</em> |
900 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 896 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
901 * </ul> | 897 * </ul> |
902 * | 898 * |
903 * @since 3.1 | 899 * @since 3.1 |
904 */ | 900 */ |
905 public void layout (boolean changed, boolean all) { | 901 public void layout (bool changed, bool all) { |
906 checkWidget (); | 902 checkWidget (); |
907 if (layout == null && !all) return; | 903 if (layout_ is null && !all) return; |
908 markLayout (changed, all); | 904 markLayout (changed, all); |
909 updateLayout (all); | 905 updateLayout (all); |
910 } | 906 } |
911 | 907 |
912 /** | 908 /** |
937 * | 933 * |
938 * @since 3.1 | 934 * @since 3.1 |
939 */ | 935 */ |
940 public void layout (Control [] changed) { | 936 public void layout (Control [] changed) { |
941 checkWidget (); | 937 checkWidget (); |
942 if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT); | 938 if (changed is null) error (SWT.ERROR_INVALID_ARGUMENT); |
943 for (int i=0; i<changed.length; i++) { | 939 for (int i=0; i<changed.length; i++) { |
944 Control control = changed [i]; | 940 Control control = changed [i]; |
945 if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); | 941 if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); |
946 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); | 942 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); |
947 boolean ancestor = false; | 943 bool ancestor = false; |
948 Composite composite = control.parent; | 944 Composite composite = control.parent; |
949 while (composite != null) { | 945 while (composite !is null) { |
950 ancestor = composite == this; | 946 ancestor = composite is this; |
951 if (ancestor) break; | 947 if (ancestor) break; |
952 composite = composite.parent; | 948 composite = composite.parent; |
953 } | 949 } |
954 if (!ancestor) error (SWT.ERROR_INVALID_PARENT); | 950 if (!ancestor) error (SWT.ERROR_INVALID_PARENT); |
955 } | 951 } |
956 int updateCount = 0; | 952 int updateCount = 0; |
957 Composite [] update = new Composite [16]; | 953 Composite [] update = new Composite [16]; |
958 for (int i=0; i<changed.length; i++) { | 954 for (int i=0; i<changed.length; i++) { |
959 Control child = changed [i]; | 955 Control child = changed [i]; |
960 Composite composite = child.parent; | 956 Composite composite = child.parent; |
961 while (child != this) { | 957 while (child !is this) { |
962 if (composite.layout != null) { | 958 if (composite.layout_ !is null) { |
963 composite.state |= LAYOUT_NEEDED; | 959 composite.state |= LAYOUT_NEEDED; |
964 if (!composite.layout.flushCache (child)) { | 960 if (!composite.layout_.flushCache (child)) { |
965 composite.state |= LAYOUT_CHANGED; | 961 composite.state |= LAYOUT_CHANGED; |
966 } | 962 } |
967 } | 963 } |
968 if (updateCount == update.length) { | 964 if (updateCount is update.length) { |
969 Composite [] newUpdate = new Composite [update.length + 16]; | 965 Composite [] newUpdate = new Composite [update.length + 16]; |
970 System.arraycopy (update, 0, newUpdate, 0, update.length); | 966 System.arraycopy (update, 0, newUpdate, 0, update.length); |
971 update = newUpdate; | 967 update = newUpdate; |
972 } | 968 } |
973 child = update [updateCount++] = composite; | 969 child = update [updateCount++] = composite; |
977 for (int i=updateCount-1; i>=0; i--) { | 973 for (int i=updateCount-1; i>=0; i--) { |
978 update [i].updateLayout (false); | 974 update [i].updateLayout (false); |
979 } | 975 } |
980 } | 976 } |
981 | 977 |
982 void markLayout (boolean changed, boolean all) { | 978 void markLayout (bool changed, bool all) { |
983 if (layout != null) { | 979 if (layout_ !is null) { |
984 state |= LAYOUT_NEEDED; | 980 state |= LAYOUT_NEEDED; |
985 if (changed) state |= LAYOUT_CHANGED; | 981 if (changed) state |= LAYOUT_CHANGED; |
986 } | 982 } |
987 if (all) { | 983 if (all) { |
988 Control [] children = _getChildren (); | 984 Control [] children = _getChildren (); |
990 children [i].markLayout (changed, all); | 986 children [i].markLayout (changed, all); |
991 } | 987 } |
992 } | 988 } |
993 } | 989 } |
994 | 990 |
995 void moveAbove (int /*long*/ child, int /*long*/ sibling) { | 991 void moveAbove (GtkWidget* child, GtkWidget* sibling) { |
996 if (child == sibling) return; | 992 if (child is sibling) return; |
997 int /*long*/ parentHandle = parentingHandle (); | 993 auto parentHandle = parentingHandle (); |
998 GtkFixed fixed = new GtkFixed (); | 994 auto fixed = cast(GtkFixed*)parentHandle; |
999 OS.memmove (fixed, parentHandle); | 995 auto children = fixed.children; |
1000 int /*long*/ children = fixed.children; | 996 if (children is null) return; |
1001 if (children == 0) return; | 997 GList* data; |
1002 int /*long*/ [] data = new int /*long*/ [1]; | 998 GtkWidget* widget; |
1003 int /*long*/ [] widget = new int /*long*/ [1]; | 999 GList* childData, childLink, siblingLink; |
1004 int /*long*/ childData = 0, childLink = 0, siblingLink = 0, temp = children; | 1000 GList* temp = children; |
1005 while (temp != 0) { | 1001 while (temp !is null) { |
1006 OS.memmove (data, temp, OS.PTR_SIZEOF); | 1002 data = temp; |
1007 OS.memmove (widget, data [0], OS.PTR_SIZEOF); | 1003 widget = cast(GtkWidget*) data; |
1008 if (child == widget [0]) { | 1004 if (child is widget) { |
1009 childLink = temp; | 1005 childLink = temp; |
1010 childData = data [0]; | 1006 childData = data; |
1011 } else if (sibling == widget [0]) { | 1007 } else if (sibling is widget) { |
1012 siblingLink = temp; | 1008 siblingLink = temp; |
1013 } | 1009 } |
1014 if (childData != 0 && (sibling == 0 || siblingLink != 0)) break; | 1010 if (childData !is null && (sibling is null || siblingLink !is null)) break; |
1015 temp = OS.g_list_next (temp); | 1011 temp = cast(GList*)OS.g_list_next (temp); |
1016 } | 1012 } |
1017 children = OS.g_list_remove_link (children, childLink); | 1013 children = OS.g_list_remove_link (children, childLink); |
1018 if (siblingLink == 0 || OS.g_list_previous (siblingLink) == 0) { | 1014 if (siblingLink is null || siblingLink.prev is null) { |
1019 OS.g_list_free_1 (childLink); | 1015 OS.g_list_free_1 (childLink); |
1020 children = OS.g_list_prepend (children, childData); | 1016 children = OS.g_list_prepend (children, childData); |
1021 } else { | 1017 } else { |
1022 temp = OS.g_list_previous (siblingLink); | 1018 temp = siblingLink.prev; |
1023 OS.g_list_set_previous (childLink, temp); | 1019 childLink.prev = temp; |
1024 OS.g_list_set_next (temp, childLink); | 1020 temp.next = childLink; |
1025 OS.g_list_set_next (childLink, siblingLink); | 1021 childLink.next = siblingLink; |
1026 OS.g_list_set_previous (siblingLink, childLink); | 1022 siblingLink.prev = childLink; |
1027 } | 1023 } |
1028 fixed.children = children; | 1024 fixed.children = children; |
1029 OS.memmove (parentHandle, fixed); | 1025 parentHandle = cast(GtkWidget*)fixed; |
1030 } | 1026 } |
1031 | 1027 |
1032 void moveBelow (int /*long*/ child, int /*long*/ sibling) { | 1028 void moveBelow (GtkWidget* child, GtkWidget* sibling) { |
1033 if (child == sibling) return; | 1029 if (child is sibling) return; |
1034 int /*long*/ parentHandle = parentingHandle (); | 1030 auto parentHandle = parentingHandle (); |
1035 if (sibling == 0 && parentHandle == fixedHandle) { | 1031 if (sibling is null && cast(GtkWidget*)parentHandle is cast(GtkWidget*)fixedHandle) { |
1036 moveAbove (child, scrolledHandle != 0 ? scrolledHandle : handle); | 1032 moveAbove (child, scrolledHandle !is null ? cast(GtkWidget*)scrolledHandle : handle); |
1037 return; | 1033 return; |
1038 } | 1034 } |
1039 GtkFixed fixed = new GtkFixed (); | 1035 auto fixed = cast(GtkFixed*)parentHandle; |
1040 OS.memmove (fixed, parentHandle); | 1036 auto children = fixed.children; |
1041 int /*long*/ children = fixed.children; | 1037 if (children is null) return; |
1042 if (children == 0) return; | 1038 GList* data; |
1043 int /*long*/ [] data = new int /*long*/ [1]; | 1039 GtkWidget* widget; |
1044 int /*long*/ [] widget = new int /*long*/ [1]; | 1040 GList* childData, childLink, siblingLink, temp = children; |
1045 int /*long*/ childData = 0, childLink = 0, siblingLink = 0, temp = children; | 1041 while (temp !is null) { |
1046 while (temp != 0) { | 1042 data = temp; |
1047 OS.memmove (data, temp, OS.PTR_SIZEOF); | 1043 widget = cast(GtkWidget*) data; |
1048 OS.memmove (widget, data [0], OS.PTR_SIZEOF); | 1044 if (child is widget) { |
1049 if (child == widget [0]) { | |
1050 childLink = temp; | 1045 childLink = temp; |
1051 childData = data [0]; | 1046 childData = data; |
1052 } else if (sibling == widget [0]) { | 1047 } else if (sibling is widget) { |
1053 siblingLink = temp; | 1048 siblingLink = temp; |
1054 } | 1049 } |
1055 if (childData != 0 && (sibling == 0 || siblingLink != 0)) break; | 1050 if (childData !is null && (sibling is null || siblingLink !is null)) break; |
1056 temp = OS.g_list_next (temp); | 1051 temp = temp.next; |
1057 } | 1052 } |
1058 children = OS.g_list_remove_link (children, childLink); | 1053 children = OS.g_list_remove_link (children, childLink); |
1059 if (siblingLink == 0 || OS.g_list_next (siblingLink) == 0) { | 1054 if (siblingLink is null || siblingLink.next is null) { |
1060 OS.g_list_free_1 (childLink); | 1055 OS.g_list_free_1 (childLink); |
1061 children = OS.g_list_append (children, childData); | 1056 children = OS.g_list_append (children, childData); |
1062 } else { | 1057 } else { |
1063 temp = OS.g_list_next (siblingLink); | 1058 temp = siblingLink.next; |
1064 OS.g_list_set_next (childLink, temp); | 1059 childLink.next = temp; |
1065 OS.g_list_set_previous (temp, childLink); | 1060 temp.prev = childLink; |
1066 OS.g_list_set_previous (childLink, siblingLink); | 1061 childLink.prev = siblingLink; |
1067 OS.g_list_set_next (siblingLink, childLink); | 1062 siblingLink.next = childLink; |
1068 } | 1063 } |
1069 fixed.children = children; | 1064 fixed.children = children; |
1070 OS.memmove (parentHandle, fixed); | 1065 parentHandle = cast(GtkWidget*)fixed; |
1071 } | 1066 } |
1072 | 1067 |
1073 Point minimumSize (int wHint, int hHint, boolean changed) { | 1068 Point minimumSize (int wHint, int hHint, bool changed) { |
1074 Control [] children = _getChildren (); | 1069 Control [] children = _getChildren (); |
1075 int width = 0, height = 0; | 1070 int width = 0, height = 0; |
1076 for (int i=0; i<children.length; i++) { | 1071 for (int i=0; i<children.length; i++) { |
1077 Rectangle rect = children [i].getBounds (); | 1072 Rectangle rect = children [i].getBounds (); |
1078 width = Math.max (width, rect.x + rect.width); | 1073 width = Math.max (width, rect.x + rect.width); |
1079 height = Math.max (height, rect.y + rect.height); | 1074 height = Math.max (height, rect.y + rect.height); |
1080 } | 1075 } |
1081 return new Point (width, height); | 1076 return new Point (width, height); |
1082 } | 1077 } |
1083 | 1078 |
1084 int /*long*/ parentingHandle () { | 1079 GtkWidget* parentingHandle () { |
1085 if ((state & CANVAS) != 0) return handle; | 1080 if ((state & CANVAS) !is 0) return handle; |
1086 return fixedHandle != 0 ? fixedHandle : handle; | 1081 return fixedHandle !is null ? fixedHandle : handle; |
1087 } | 1082 } |
1088 | 1083 |
1089 void redrawChildren () { | 1084 void redrawChildren () { |
1090 super.redrawChildren (); | 1085 super.redrawChildren (); |
1091 Control [] children = _getChildren (); | 1086 Control [] children = _getChildren (); |
1092 for (int i = 0; i < children.length; i++) { | 1087 for (int i = 0; i < children.length; i++) { |
1093 Control child = children [i]; | 1088 Control child = children [i]; |
1094 if ((child.state & PARENT_BACKGROUND) != 0) { | 1089 if ((child.state & PARENT_BACKGROUND) !is 0) { |
1095 child.redrawWidget (0, 0, 0, 0, true, false, true); | 1090 child.redrawWidget (0, 0, 0, 0, true, false, true); |
1096 child.redrawChildren (); | 1091 child.redrawChildren (); |
1097 } | 1092 } |
1098 } | 1093 } |
1099 } | 1094 } |
1100 | 1095 |
1101 void register () { | 1096 void register () { |
1102 super.register (); | 1097 super.register (); |
1103 if (socketHandle != 0) display.addWidget (socketHandle, this); | 1098 if (socketHandle !is null) display.addWidget (socketHandle, this); |
1104 } | 1099 } |
1105 | 1100 |
1106 void releaseChildren (boolean destroy) { | 1101 void releaseChildren (bool destroy) { |
1107 Control [] children = _getChildren (); | 1102 Control [] children = _getChildren (); |
1108 for (int i=0; i<children.length; i++) { | 1103 for (int i=0; i<children.length; i++) { |
1109 Control child = children [i]; | 1104 Control child = children [i]; |
1110 if (child != null && !child.isDisposed ()) { | 1105 if (child !is null && !child.isDisposed ()) { |
1111 child.release (false); | 1106 child.release (false); |
1112 } | 1107 } |
1113 } | 1108 } |
1114 super.releaseChildren (destroy); | 1109 super.releaseChildren (destroy); |
1115 } | 1110 } |
1116 | 1111 |
1117 void releaseHandle () { | 1112 void releaseHandle () { |
1118 super.releaseHandle (); | 1113 super.releaseHandle (); |
1119 socketHandle = embeddedHandle = 0; | 1114 socketHandle = null; |
1115 embeddedHandle = 0; | |
1120 } | 1116 } |
1121 | 1117 |
1122 void releaseWidget () { | 1118 void releaseWidget () { |
1123 super.releaseWidget (); | 1119 super.releaseWidget (); |
1124 if (imHandle != 0) OS.g_object_unref (imHandle); | 1120 if (imHandle_ !is null) OS.g_object_unref (imHandle_); |
1125 imHandle = 0; | 1121 imHandle_ = null; |
1126 layout = null; | 1122 layout_ = null; |
1127 tabList = null; | 1123 tabList = null; |
1128 } | 1124 } |
1129 | 1125 |
1130 void removeControl (Control control) { | 1126 void removeControl (Control control) { |
1131 fixTabList (control); | 1127 fixTabList (control); |
1132 } | 1128 } |
1133 | 1129 |
1134 void resizeHandle (int width, int height) { | 1130 void resizeHandle (int width, int height) { |
1135 super.resizeHandle (width, height); | 1131 super.resizeHandle (width, height); |
1136 if (socketHandle != 0) OS.gtk_widget_set_size_request (socketHandle, width, height); | 1132 if (socketHandle !is null) OS.gtk_widget_set_size_request (socketHandle, width, height); |
1137 } | 1133 } |
1138 | 1134 |
1139 /** | 1135 /** |
1140 * Sets the background drawing mode to the argument which should | 1136 * Sets the background drawing mode to the argument which should |
1141 * be one of the following constants defined in class <code>SWT</code>: | 1137 * be one of the following constants defined in class <code>SWT</code>: |
1160 for (int i = 0; i < children.length; i++) { | 1156 for (int i = 0; i < children.length; i++) { |
1161 children [i].updateBackgroundMode (); | 1157 children [i].updateBackgroundMode (); |
1162 } | 1158 } |
1163 } | 1159 } |
1164 | 1160 |
1165 int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { | 1161 int setBounds (int x, int y, int width, int height, bool move, bool resize) { |
1166 int result = super.setBounds (x, y, width, height, move, resize); | 1162 int result = super.setBounds (x, y, width, height, move, resize); |
1167 if ((result & RESIZED) != 0 && layout != null) { | 1163 if ((result & RESIZED) !is 0 && layout_ !is null) { |
1168 markLayout (false, false); | 1164 markLayout (false, false); |
1169 updateLayout (false); | 1165 updateLayout (false); |
1170 } | 1166 } |
1171 return result; | 1167 return result; |
1172 } | 1168 } |
1173 | 1169 |
1174 public boolean setFocus () { | 1170 public bool setFocus () { |
1175 checkWidget(); | 1171 checkWidget(); |
1176 Control [] children = _getChildren (); | 1172 Control [] children = _getChildren (); |
1177 for (int i=0; i<children.length; i++) { | 1173 for (int i=0; i<children.length; i++) { |
1178 Control child = children [i]; | 1174 Control child = children [i]; |
1179 if (child.getVisible () && child.setFocus ()) return true; | 1175 if (child.getVisible () && child.setFocus ()) return true; |
1192 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1188 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1193 * </ul> | 1189 * </ul> |
1194 */ | 1190 */ |
1195 public void setLayout (Layout layout) { | 1191 public void setLayout (Layout layout) { |
1196 checkWidget(); | 1192 checkWidget(); |
1197 this.layout = layout; | 1193 this.layout_ = layout; |
1198 } | 1194 } |
1199 | 1195 |
1200 /** | 1196 /** |
1201 * If the argument is <code>true</code>, causes subsequent layout | 1197 * If the argument is <code>true</code>, causes subsequent layout |
1202 * operations in the receiver or any of its children to be ignored. | 1198 * operations in the receiver or any of its children to be ignored. |
1212 * @exception SWTException <ul> | 1208 * @exception SWTException <ul> |
1213 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1209 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1214 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1210 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1215 * </ul> | 1211 * </ul> |
1216 * | 1212 * |
1217 * @see #layout(boolean) | 1213 * @see #layout(bool) |
1218 * @see #layout(Control[]) | 1214 * @see #layout(Control[]) |
1219 * | 1215 * |
1220 * @since 3.1 | 1216 * @since 3.1 |
1221 */ | 1217 */ |
1222 public void setLayoutDeferred (boolean defer) { | 1218 public void setLayoutDeferred (bool defer) { |
1223 if (!defer) { | 1219 if (!defer) { |
1224 if (--layoutCount == 0) { | 1220 if (--layoutCount is 0) { |
1225 if ((state & LAYOUT_CHILD) != 0 || (state & LAYOUT_NEEDED) != 0) { | 1221 if ((state & LAYOUT_CHILD) !is 0 || (state & LAYOUT_NEEDED) !is 0) { |
1226 updateLayout (true); | 1222 updateLayout (true); |
1227 } | 1223 } |
1228 } | 1224 } |
1229 } else { | 1225 } else { |
1230 layoutCount++; | 1226 layoutCount++; |
1231 } | 1227 } |
1232 } | 1228 } |
1233 | 1229 |
1234 boolean setScrollBarVisible (ScrollBar bar, boolean visible) { | 1230 bool setScrollBarVisible (ScrollBar bar, bool visible) { |
1235 boolean changed = super.setScrollBarVisible (bar, visible); | 1231 bool changed = super.setScrollBarVisible (bar, visible); |
1236 if (changed && layout != null) { | 1232 if (changed && layout_ !is null) { |
1237 markLayout (false, false); | 1233 markLayout (false, false); |
1238 updateLayout (false); | 1234 updateLayout (false); |
1239 } | 1235 } |
1240 return changed; | 1236 return changed; |
1241 } | 1237 } |
1242 | 1238 |
1243 boolean setTabGroupFocus (boolean next) { | 1239 bool setTabGroupFocus (bool next) { |
1244 if (isTabItem ()) return setTabItemFocus (next); | 1240 if (isTabItem ()) return setTabItemFocus (next); |
1245 boolean takeFocus = (style & SWT.NO_FOCUS) == 0; | 1241 bool takeFocus = (style & SWT.NO_FOCUS) is 0; |
1246 if ((state & CANVAS) != 0) takeFocus = hooksKeys (); | 1242 if ((state & CANVAS) !is 0) takeFocus = hooksKeys (); |
1247 if (socketHandle != 0) takeFocus = true; | 1243 if (socketHandle !is null) takeFocus = true; |
1248 if (takeFocus && setTabItemFocus (next)) return true; | 1244 if (takeFocus && setTabItemFocus (next)) return true; |
1249 Control [] children = _getChildren (); | 1245 Control [] children = _getChildren (); |
1250 for (int i=0; i<children.length; i++) { | 1246 for (int i=0; i<children.length; i++) { |
1251 Control child = children [i]; | 1247 Control child = children [i]; |
1252 if (child.isTabItem () && child.setTabItemFocus (next)) return true; | 1248 if (child.isTabItem () && child.setTabItemFocus (next)) return true; |
1253 } | 1249 } |
1254 return false; | 1250 return false; |
1255 } | 1251 } |
1256 | 1252 |
1257 boolean setTabItemFocus (boolean next) { | 1253 bool setTabItemFocus (bool next) { |
1258 if (!super.setTabItemFocus (next)) return false; | 1254 if (!super.setTabItemFocus (next)) return false; |
1259 if (socketHandle != 0) { | 1255 if (socketHandle !is null) { |
1260 int direction = next ? OS.GTK_DIR_TAB_FORWARD : OS.GTK_DIR_TAB_BACKWARD; | 1256 int direction = next ? OS.GTK_DIR_TAB_FORWARD : OS.GTK_DIR_TAB_BACKWARD; |
1261 OS.GTK_WIDGET_UNSET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); | 1257 OS.GTK_WIDGET_UNSET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); |
1262 OS.gtk_widget_child_focus (socketHandle, direction); | 1258 OS.gtk_widget_child_focus (socketHandle, direction); |
1263 OS.GTK_WIDGET_SET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); | 1259 OS.GTK_WIDGET_SET_FLAGS (socketHandle, OS.GTK_HAS_FOCUS); |
1264 } | 1260 } |
1280 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1276 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1281 * </ul> | 1277 * </ul> |
1282 */ | 1278 */ |
1283 public void setTabList (Control [] tabList) { | 1279 public void setTabList (Control [] tabList) { |
1284 checkWidget (); | 1280 checkWidget (); |
1285 if (tabList != null) { | 1281 if (tabList !is null) { |
1286 for (int i=0; i<tabList.length; i++) { | 1282 for (int i=0; i<tabList.length; i++) { |
1287 Control control = tabList [i]; | 1283 Control control = tabList [i]; |
1288 if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); | 1284 if (control is null) error (SWT.ERROR_INVALID_ARGUMENT); |
1289 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); | 1285 if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); |
1290 if (control.parent != this) error (SWT.ERROR_INVALID_PARENT); | 1286 if (control.parent !is this) error (SWT.ERROR_INVALID_PARENT); |
1291 } | 1287 } |
1292 Control [] newList = new Control [tabList.length]; | 1288 Control [] newList = new Control [tabList.length]; |
1293 System.arraycopy (tabList, 0, newList, 0, tabList.length); | 1289 System.arraycopy (tabList, 0, newList, 0, tabList.length); |
1294 tabList = newList; | 1290 tabList = newList; |
1295 } | 1291 } |
1296 this.tabList = tabList; | 1292 this.tabList = tabList; |
1297 } | 1293 } |
1298 | 1294 |
1299 void showWidget () { | 1295 void showWidget () { |
1300 super.showWidget (); | 1296 super.showWidget (); |
1301 if (socketHandle != 0) { | 1297 if (socketHandle !is null) { |
1302 OS.gtk_widget_show (socketHandle); | 1298 OS.gtk_widget_show (socketHandle); |
1303 embeddedHandle = OS.gtk_socket_get_id (socketHandle); | 1299 embeddedHandle = OS.gtk_socket_get_id (cast(GtkSocket*)socketHandle); |
1304 } | 1300 } |
1305 if (scrolledHandle == 0) fixStyle (handle); | 1301 if (scrolledHandle is null) fixStyle (handle); |
1306 } | 1302 } |
1307 | 1303 |
1308 boolean translateMnemonic (Event event, Control control) { | 1304 bool translateMnemonic (Event event, Control control) { |
1309 if (super.translateMnemonic (event, control)) return true; | 1305 if (super.translateMnemonic (event, control)) return true; |
1310 if (control != null) { | 1306 if (control !is null) { |
1311 Control [] children = _getChildren (); | 1307 Control [] children = _getChildren (); |
1312 for (int i=0; i<children.length; i++) { | 1308 for (int i=0; i<children.length; i++) { |
1313 Control child = children [i]; | 1309 Control child = children [i]; |
1314 if (child.translateMnemonic (event, control)) return true; | 1310 if (child.translateMnemonic (event, control)) return true; |
1315 } | 1311 } |
1316 } | 1312 } |
1317 return false; | 1313 return false; |
1318 } | 1314 } |
1319 | 1315 |
1320 int traversalCode(int key, GdkEventKey event) { | 1316 int traversalCode(int key, GdkEventKey* event) { |
1321 if ((state & CANVAS) != 0) { | 1317 if ((state & CANVAS) !is 0) { |
1322 if ((style & SWT.NO_FOCUS) != 0) return 0; | 1318 if ((style & SWT.NO_FOCUS) !is 0) return 0; |
1323 if (hooksKeys ()) return 0; | 1319 if (hooksKeys ()) return 0; |
1324 } | 1320 } |
1325 return super.traversalCode (key, event); | 1321 return super.traversalCode (key, event); |
1326 } | 1322 } |
1327 | 1323 |
1328 boolean translateTraversal (GdkEventKey keyEvent) { | 1324 bool translateTraversal (GdkEventKey* keyEvent) { |
1329 if (socketHandle != 0) return false; | 1325 if (socketHandle !is null) return false; |
1330 return super.translateTraversal (keyEvent); | 1326 return super.translateTraversal (keyEvent); |
1331 } | 1327 } |
1332 | 1328 |
1333 void updateBackgroundMode () { | 1329 void updateBackgroundMode () { |
1334 super.updateBackgroundMode (); | 1330 super.updateBackgroundMode (); |
1336 for (int i = 0; i < children.length; i++) { | 1332 for (int i = 0; i < children.length; i++) { |
1337 children [i].updateBackgroundMode (); | 1333 children [i].updateBackgroundMode (); |
1338 } | 1334 } |
1339 } | 1335 } |
1340 | 1336 |
1341 void updateLayout (boolean all) { | 1337 void updateLayout (bool all) { |
1342 Composite parent = findDeferredControl (); | 1338 Composite parent = findDeferredControl (); |
1343 if (parent != null) { | 1339 if (parent !is null) { |
1344 parent.state |= LAYOUT_CHILD; | 1340 parent.state |= LAYOUT_CHILD; |
1345 return; | 1341 return; |
1346 } | 1342 } |
1347 if ((state & LAYOUT_NEEDED) != 0) { | 1343 if ((state & LAYOUT_NEEDED) !is 0) { |
1348 boolean changed = (state & LAYOUT_CHANGED) != 0; | 1344 bool changed = (state & LAYOUT_CHANGED) !is 0; |
1349 state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED); | 1345 state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED); |
1350 layout.layout (this, changed); | 1346 layout_.layout (this, changed); |
1351 } | 1347 } |
1352 if (all) { | 1348 if (all) { |
1353 state &= ~LAYOUT_CHILD; | 1349 state &= ~LAYOUT_CHILD; |
1354 Control [] children = _getChildren (); | 1350 Control [] children = _getChildren (); |
1355 for (int i=0; i<children.length; i++) { | 1351 for (int i=0; i<children.length; i++) { |
1356 children [i].updateLayout (all); | 1352 children [i].updateLayout (all); |
1357 } | 1353 } |
1358 } | 1354 } |
1359 } | 1355 } |
1360 } | 1356 } |
1361 +/ |