Mercurial > projects > dwt2
annotate org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/widgets/Widget.d @ 47:65761bc28ab2
swt linux again compilable for d1.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 27 Mar 2009 11:43:53 +0100 |
parents | f713da8bc051 |
children | ddbfe84d86df |
rev | line source |
---|---|
25 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2008 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 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module org.eclipse.swt.widgets.Widget; | |
14 | |
15 import org.eclipse.swt.SWT; | |
16 import java.lang.all; | |
17 | |
18 import org.eclipse.swt.events.DisposeListener; | |
19 import org.eclipse.swt.internal.Converter; | |
20 import org.eclipse.swt.internal.SWTEventListener; | |
21 import org.eclipse.swt.internal.gtk.OS; | |
22 import org.eclipse.swt.widgets.Display; | |
23 import org.eclipse.swt.widgets.Event; | |
24 import org.eclipse.swt.widgets.EventTable; | |
25 import org.eclipse.swt.widgets.Listener; | |
26 import org.eclipse.swt.widgets.TypedListener; | |
27 | |
28 import tango.stdc.string; | |
47
65761bc28ab2
swt linux again compilable for d1.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
29 import java.lang.Thread; |
25 | 30 |
31 | |
32 /** | |
33 * This class is the abstract superclass of all user interface objects. | |
34 * Widgets are created, disposed and issue notification to listeners | |
35 * when events occur which affect them. | |
36 * <dl> | |
37 * <dt><b>Styles:</b></dt> | |
38 * <dd>(none)</dd> | |
39 * <dt><b>Events:</b></dt> | |
40 * <dd>Dispose</dd> | |
41 * </dl> | |
42 * <p> | |
43 * IMPORTANT: This class is intended to be subclassed <em>only</em> | |
44 * within the SWT implementation. However, it has not been marked | |
45 * final to allow those outside of the SWT development team to implement | |
46 * patched versions of the class in order to get around specific | |
47 * limitations in advance of when those limitations can be addressed | |
48 * by the team. Any class built using subclassing to access the internals | |
49 * of this class will likely fail to compile or run between releases and | |
50 * may be strongly platform specific. Subclassing should not be attempted | |
51 * without an intimate and detailed understanding of the workings of the | |
52 * hierarchy. No support is provided for user-written classes which are | |
53 * implemented as subclasses of this class. | |
54 * </p> | |
55 * | |
56 * @see #checkSubclass | |
57 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
58 */ | |
59 public abstract class Widget { | |
60 /** | |
61 * the handle to the OS resource | |
62 * (Warning: This field is platform dependent) | |
63 * <p> | |
64 * <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT | |
65 * public API. It is marked public only so that it can be shared | |
66 * within the packages provided by SWT. It is not available on all | |
67 * platforms and should never be accessed from application code. | |
68 * </p> | |
69 */ | |
70 public GtkWidget* handle; | |
71 int style, state; | |
72 Display display; | |
73 EventTable eventTable; | |
74 Object data; | |
75 | |
76 /* Global state flags */ | |
77 static const int DISPOSED = 1<<0; | |
78 static const int CANVAS = 1<<1; | |
79 static const int KEYED_DATA = 1<<2; | |
80 static const int HANDLE = 1<<3; | |
81 static const int DISABLED = 1<<4; | |
82 static const int MENU = 1<<5; | |
83 static const int OBSCURED = 1<<6; | |
84 static const int MOVED = 1<<7; | |
85 static const int RESIZED = 1<<8; | |
86 static const int ZERO_WIDTH = 1<<9; | |
87 static const int ZERO_HEIGHT = 1<<10; | |
88 static const int HIDDEN = 1<<11; | |
89 static const int FOREGROUND = 1<<12; | |
90 static const int BACKGROUND = 1<<13; | |
91 static const int FONT = 1<<14; | |
92 static const int PARENT_BACKGROUND = 1<<15; | |
93 static const int THEME_BACKGROUND = 1<<16; | |
94 | |
95 /* A layout was requested on this widget */ | |
96 static const int LAYOUT_NEEDED = 1<<17; | |
97 | |
98 /* The preferred size of a child has changed */ | |
99 static const int LAYOUT_CHANGED = 1<<18; | |
100 | |
101 /* A layout was requested in this widget hierachy */ | |
102 static const int LAYOUT_CHILD = 1<<19; | |
103 | |
104 /* More global state flags */ | |
105 static const int RELEASED = 1<<20; | |
106 static const int DISPOSE_SENT = 1<<21; | |
107 static const int FOREIGN_HANDLE = 1<<22; | |
108 static const int DRAG_DETECT = 1<<23; | |
109 | |
110 /* Default size for widgets */ | |
111 static const int DEFAULT_WIDTH = 64; | |
112 static const int DEFAULT_HEIGHT = 64; | |
113 | |
114 /* GTK signals data */ | |
115 static const int ACTIVATE = 1; | |
116 static const int BUTTON_PRESS_EVENT = 2; | |
117 static const int BUTTON_PRESS_EVENT_INVERSE = 3; | |
118 static const int BUTTON_RELEASE_EVENT = 4; | |
119 static const int BUTTON_RELEASE_EVENT_INVERSE = 5; | |
120 static const int CHANGED = 6; | |
121 static const int CHANGE_VALUE = 7; | |
122 static const int CLICKED = 8; | |
123 static const int COMMIT = 9; | |
124 static const int CONFIGURE_EVENT = 10; | |
125 static const int DELETE_EVENT = 11; | |
126 static const int DELETE_RANGE = 12; | |
127 static const int DELETE_TEXT = 13; | |
128 static const int ENTER_NOTIFY_EVENT = 14; | |
129 static const int EVENT = 15; | |
130 static const int EVENT_AFTER = 16; | |
131 static const int EXPAND_COLLAPSE_CURSOR_ROW = 17; | |
132 static const int EXPOSE_EVENT = 18; | |
133 static const int EXPOSE_EVENT_INVERSE = 19; | |
134 static const int FOCUS = 20; | |
135 static const int FOCUS_IN_EVENT = 21; | |
136 static const int FOCUS_OUT_EVENT = 22; | |
137 static const int GRAB_FOCUS = 23; | |
138 static const int HIDE = 24; | |
139 static const int INPUT = 25; | |
140 static const int INSERT_TEXT = 26; | |
141 static const int KEY_PRESS_EVENT = 27; | |
142 static const int KEY_RELEASE_EVENT = 28; | |
143 static const int LEAVE_NOTIFY_EVENT = 29; | |
144 static const int MAP = 30; | |
145 static const int MAP_EVENT = 31; | |
146 static const int MNEMONIC_ACTIVATE = 32; | |
147 static const int MOTION_NOTIFY_EVENT = 33; | |
148 static const int MOTION_NOTIFY_EVENT_INVERSE = 34; | |
149 static const int MOVE_FOCUS = 35; | |
150 static const int OUTPUT = 36; | |
151 static const int POPULATE_POPUP = 37; | |
152 static const int POPUP_MENU = 38; | |
153 static const int PREEDIT_CHANGED = 39; | |
154 static const int REALIZE = 40; | |
155 static const int ROW_ACTIVATED = 41; | |
156 static const int SCROLL_CHILD = 42; | |
157 static const int SCROLL_EVENT = 43; | |
158 static const int SELECT = 44; | |
159 static const int SHOW = 45; | |
160 static const int SHOW_HELP = 46; | |
161 static const int SIZE_ALLOCATE = 47; | |
162 static const int STYLE_SET = 48; | |
163 static const int SWITCH_PAGE = 49; | |
164 static const int TEST_COLLAPSE_ROW = 50; | |
165 static const int TEST_EXPAND_ROW = 51; | |
166 static const int TEXT_BUFFER_INSERT_TEXT = 52; | |
167 static const int TOGGLED = 53; | |
168 static const int UNMAP = 54; | |
169 static const int UNMAP_EVENT = 55; | |
170 static const int UNREALIZE = 56; | |
171 static const int VALUE_CHANGED = 57; | |
172 static const int VISIBILITY_NOTIFY_EVENT = 58; | |
173 static const int WINDOW_STATE_EVENT = 59; | |
174 static const int ACTIVATE_INVERSE = 60; | |
175 static const int DAY_SELECTED = 61; | |
176 static const int MONTH_CHANGED = 62; | |
177 static const int LAST_SIGNAL = 63; | |
178 | |
179 template UD_Getter( String name ){ | |
180 const String UD_Getter = "void* ud"~name~"(){ return getDisplay().getWindowProcUserData( "~name~"); }\n"; | |
181 } | |
182 | |
183 mixin ( UD_Getter!( "ACTIVATE" )); | |
184 mixin ( UD_Getter!( "BUTTON_PRESS_EVENT" )); | |
185 mixin ( UD_Getter!( "BUTTON_PRESS_EVENT_INVERSE" )); | |
186 mixin ( UD_Getter!( "BUTTON_RELEASE_EVENT" )); | |
187 mixin ( UD_Getter!( "BUTTON_RELEASE_EVENT_INVERSE" )); | |
188 mixin ( UD_Getter!( "CHANGED" )); | |
189 mixin ( UD_Getter!( "CHANGE_VALUE" )); | |
190 mixin ( UD_Getter!( "CLICKED" )); | |
191 mixin ( UD_Getter!( "COMMIT" )); | |
192 mixin ( UD_Getter!( "CONFIGURE_EVENT" )); | |
193 mixin ( UD_Getter!( "DELETE_EVENT" )); | |
194 mixin ( UD_Getter!( "DELETE_RANGE" )); | |
195 mixin ( UD_Getter!( "DELETE_TEXT" )); | |
196 mixin ( UD_Getter!( "ENTER_NOTIFY_EVENT" )); | |
197 mixin ( UD_Getter!( "EVENT" )); | |
198 mixin ( UD_Getter!( "EVENT_AFTER" )); | |
199 mixin ( UD_Getter!( "EXPAND_COLLAPSE_CURSOR_ROW" )); | |
200 mixin ( UD_Getter!( "EXPOSE_EVENT" )); | |
201 mixin ( UD_Getter!( "EXPOSE_EVENT_INVERSE" )); | |
202 mixin ( UD_Getter!( "FOCUS" )); | |
203 mixin ( UD_Getter!( "FOCUS_IN_EVENT" )); | |
204 mixin ( UD_Getter!( "FOCUS_OUT_EVENT" )); | |
205 mixin ( UD_Getter!( "GRAB_FOCUS" )); | |
206 mixin ( UD_Getter!( "HIDE" )); | |
207 mixin ( UD_Getter!( "INPUT" )); | |
208 mixin ( UD_Getter!( "INSERT_TEXT" )); | |
209 mixin ( UD_Getter!( "KEY_PRESS_EVENT" )); | |
210 mixin ( UD_Getter!( "KEY_RELEASE_EVENT" )); | |
211 mixin ( UD_Getter!( "LEAVE_NOTIFY_EVENT" )); | |
212 mixin ( UD_Getter!( "MAP" )); | |
213 mixin ( UD_Getter!( "MAP_EVENT" )); | |
214 mixin ( UD_Getter!( "MNEMONIC_ACTIVATE" )); | |
215 mixin ( UD_Getter!( "MOTION_NOTIFY_EVENT" )); | |
216 mixin ( UD_Getter!( "MOTION_NOTIFY_EVENT_INVERSE" )); | |
217 mixin ( UD_Getter!( "MOVE_FOCUS" )); | |
218 mixin ( UD_Getter!( "OUTPUT" )); | |
219 mixin ( UD_Getter!( "POPULATE_POPUP" )); | |
220 mixin ( UD_Getter!( "POPUP_MENU" )); | |
221 mixin ( UD_Getter!( "PREEDIT_CHANGED" )); | |
222 mixin ( UD_Getter!( "REALIZE" )); | |
223 mixin ( UD_Getter!( "ROW_ACTIVATED" )); | |
224 mixin ( UD_Getter!( "SCROLL_CHILD" )); | |
225 mixin ( UD_Getter!( "SCROLL_EVENT" )); | |
226 mixin ( UD_Getter!( "SELECT" )); | |
227 mixin ( UD_Getter!( "SHOW" )); | |
228 mixin ( UD_Getter!( "SHOW_HELP" )); | |
229 mixin ( UD_Getter!( "SIZE_ALLOCATE" )); | |
230 mixin ( UD_Getter!( "STYLE_SET" )); | |
231 mixin ( UD_Getter!( "SWITCH_PAGE" )); | |
232 mixin ( UD_Getter!( "TEST_COLLAPSE_ROW" )); | |
233 mixin ( UD_Getter!( "TEST_EXPAND_ROW" )); | |
234 mixin ( UD_Getter!( "TEXT_BUFFER_INSERT_TEXT" )); | |
235 mixin ( UD_Getter!( "TOGGLED" )); | |
236 mixin ( UD_Getter!( "UNMAP" )); | |
237 mixin ( UD_Getter!( "UNMAP_EVENT" )); | |
238 mixin ( UD_Getter!( "UNREALIZE" )); | |
239 mixin ( UD_Getter!( "VALUE_CHANGED" )); | |
240 mixin ( UD_Getter!( "VISIBILITY_NOTIFY_EVENT" )); | |
241 mixin ( UD_Getter!( "WINDOW_STATE_EVENT" )); | |
242 mixin ( UD_Getter!( "ACTIVATE_INVERSE" )); | |
243 mixin ( UD_Getter!( "DAY_SELECTED" )); | |
244 mixin ( UD_Getter!( "MONTH_CHANGED" )); | |
245 mixin ( UD_Getter!( "LAST_SIGNAL" )); | |
246 | |
247 /** | |
248 * Prevents uninitialized instances from being created outside the package. | |
249 */ | |
250 this () {} | |
251 | |
252 /** | |
253 * Constructs a new instance of this class given its parent | |
254 * and a style value describing its behavior and appearance. | |
255 * <p> | |
256 * The style value is either one of the style constants defined in | |
257 * class <code>SWT</code> which is applicable to instances of this | |
258 * class, or must be built by <em>bitwise OR</em>'ing together | |
259 * (that is, using the <code>int</code> "|" operator) two or more | |
260 * of those <code>SWT</code> style constants. The class description | |
261 * lists the style constants that are applicable to the class. | |
262 * Style bits are also inherited from superclasses. | |
263 * </p> | |
264 * | |
265 * @param parent a widget which will be the parent of the new instance (cannot be null) | |
266 * @param style the style of widget to construct | |
267 * | |
268 * @exception IllegalArgumentException <ul> | |
269 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
270 * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> | |
271 * </ul> | |
272 * @exception SWTException <ul> | |
273 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
274 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | |
275 * </ul> | |
276 * | |
277 * @see SWT | |
278 * @see #checkSubclass | |
279 * @see #getStyle | |
280 */ | |
281 public this (Widget parent, int style) { | |
282 checkSubclass (); | |
283 checkParent (parent); | |
284 this.style = style; | |
285 display = parent.display; | |
286 } | |
287 | |
288 void _addListener (int eventType, Listener listener) { | |
289 if (eventTable is null) eventTable = new EventTable (); | |
290 eventTable.hook (eventType, listener); | |
291 } | |
292 | |
293 /** | |
294 * Adds the listener to the collection of listeners who will | |
295 * be notified when an event of the given type occurs. When the | |
296 * event does occur in the widget, the listener is notified by | |
297 * sending it the <code>handleEvent()</code> message. The event | |
298 * type is one of the event constants defined in class <code>SWT</code>. | |
299 * | |
300 * @param eventType the type of event to listen for | |
301 * @param listener the listener which should be notified when the event occurs | |
302 * | |
303 * @exception IllegalArgumentException <ul> | |
304 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
305 * </ul> | |
306 * @exception SWTException <ul> | |
307 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
308 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
309 * </ul> | |
310 * | |
311 * @see Listener | |
312 * @see SWT | |
313 * @see #getListeners(int) | |
314 * @see #removeListener(int, Listener) | |
315 * @see #notifyListeners | |
316 */ | |
317 public void addListener (int eventType, Listener listener) { | |
318 checkWidget (); | |
319 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); | |
320 _addListener (eventType, listener); | |
321 } | |
322 | |
323 /** | |
324 * Adds the listener to the collection of listeners who will | |
325 * be notified when the widget is disposed. When the widget is | |
326 * disposed, the listener is notified by sending it the | |
327 * <code>widgetDisposed()</code> message. | |
328 * | |
329 * @param listener the listener which should be notified when the receiver is disposed | |
330 * | |
331 * @exception IllegalArgumentException <ul> | |
332 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
333 * </ul> | |
334 * @exception SWTException <ul> | |
335 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
336 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
337 * </ul> | |
338 * | |
339 * @see DisposeListener | |
340 * @see #removeDisposeListener | |
341 */ | |
342 public void addDisposeListener (DisposeListener listener) { | |
343 checkWidget (); | |
344 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); | |
345 TypedListener typedListener = new TypedListener (listener); | |
346 addListener (SWT.Dispose, typedListener); | |
347 } | |
348 | |
349 GdkWindow* paintWindow () { | |
350 return null; | |
351 } | |
352 | |
353 static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) { | |
354 int mask = int0 | int1 | int2 | int3 | int4 | int5; | |
355 if ((style & mask) is 0) style |= int0; | |
356 if ((style & int0) !is 0) style = (style & ~mask) | int0; | |
357 if ((style & int1) !is 0) style = (style & ~mask) | int1; | |
358 if ((style & int2) !is 0) style = (style & ~mask) | int2; | |
359 if ((style & int3) !is 0) style = (style & ~mask) | int3; | |
360 if ((style & int4) !is 0) style = (style & ~mask) | int4; | |
361 if ((style & int5) !is 0) style = (style & ~mask) | int5; | |
362 return style; | |
363 } | |
364 | |
365 void cellDataProc ( | |
366 GtkTreeViewColumn *tree_column, | |
367 GtkCellRenderer *cell, | |
368 GtkTreeModel *tree_model, | |
369 GtkTreeIter *iter, | |
370 void* data) | |
371 { | |
372 } | |
373 | |
374 void checkOpen () { | |
375 /* Do nothing */ | |
376 } | |
377 | |
378 void checkOrientation (Widget parent) { | |
379 style &= ~SWT.MIRRORED; | |
380 if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) is 0) { | |
381 if (parent !is null) { | |
382 if ((parent.style & SWT.LEFT_TO_RIGHT) !is 0) style |= SWT.LEFT_TO_RIGHT; | |
383 if ((parent.style & SWT.RIGHT_TO_LEFT) !is 0) style |= SWT.RIGHT_TO_LEFT; | |
384 } | |
385 } | |
386 style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0); | |
387 /* Versions of GTK prior to 2.8 do not render RTL text properly */ | |
388 if (OS.GTK_VERSION < OS.buildVERSION (2, 8, 0)) { | |
389 style &= ~SWT.RIGHT_TO_LEFT; | |
390 style |= SWT.LEFT_TO_RIGHT; | |
391 } | |
392 } | |
393 | |
394 /** | |
395 * Throws an exception if the specified widget can not be | |
396 * used as a parent for the receiver. | |
397 * | |
398 * @exception IllegalArgumentException <ul> | |
399 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
400 * <li>ERROR_INVALID_ARGUMENT - if the parent is disposed</li> | |
401 * </ul> | |
402 * @exception SWTException <ul> | |
403 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> | |
404 * </ul> | |
405 */ | |
406 void checkParent (Widget parent) { | |
407 if (parent is null) error (SWT.ERROR_NULL_ARGUMENT); | |
408 if (parent.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); | |
409 parent.checkWidget (); | |
410 parent.checkOpen (); | |
411 } | |
412 | |
413 /** | |
414 * Checks that this class can be subclassed. | |
415 * <p> | |
416 * The SWT class library is intended to be subclassed | |
417 * only at specific, controlled points (most notably, | |
418 * <code>Composite</code> and <code>Canvas</code> when | |
419 * implementing new widgets). This method enforces this | |
420 * rule unless it is overridden. | |
421 * </p><p> | |
422 * <em>IMPORTANT:</em> By providing an implementation of this | |
423 * method that allows a subclass of a class which does not | |
424 * normally allow subclassing to be created, the implementer | |
425 * agrees to be fully responsible for the fact that any such | |
426 * subclass will likely fail between SWT releases and will be | |
427 * strongly platform specific. No support is provided for | |
428 * user-written classes which are implemented in this fashion. | |
429 * </p><p> | |
430 * The ability to subclass outside of the allowed SWT classes | |
431 * is intended purely to enable those not on the SWT development | |
432 * team to implement patches in order to get around specific | |
433 * limitations in advance of when those limitations can be | |
434 * addressed by the team. Subclassing should not be attempted | |
435 * without an intimate and detailed understanding of the hierarchy. | |
436 * </p> | |
437 * | |
438 * @exception SWTException <ul> | |
439 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | |
440 * </ul> | |
441 */ | |
442 protected void checkSubclass () { | |
443 if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); | |
444 } | |
445 | |
446 /** | |
447 * Throws an <code>SWTException</code> if the receiver can not | |
448 * be accessed by the caller. This may include both checks on | |
449 * the state of the receiver and more generally on the entire | |
450 * execution context. This method <em>should</em> be called by | |
451 * widget implementors to enforce the standard SWT invariants. | |
452 * <p> | |
453 * Currently, it is an error to invoke any method (other than | |
454 * <code>isDisposed()</code>) on a widget that has had its | |
455 * <code>dispose()</code> method called. It is also an error | |
456 * to call widget methods from any thread that is different | |
457 * from the thread that created the widget. | |
458 * </p><p> | |
459 * In future releases of SWT, there may be more or fewer error | |
460 * checks and exceptions may be thrown for different reasons. | |
461 * </p> | |
462 * | |
463 * @exception SWTException <ul> | |
464 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
465 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
466 * </ul> | |
467 */ | |
468 public void checkWidget () { | |
469 Display display = this.display; | |
470 if (display is null) error (SWT.ERROR_WIDGET_DISPOSED); | |
47
65761bc28ab2
swt linux again compilable for d1.
Frank Benoit <benoit@tionex.de>
parents:
25
diff
changeset
|
471 if (display.thread !is Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); |
25 | 472 if ((state & DISPOSED) !is 0) error (SWT.ERROR_WIDGET_DISPOSED); |
473 } | |
474 | |
475 void createHandle (int index) { | |
476 } | |
477 | |
478 void createWidget (int index) { | |
479 createHandle (index); | |
480 setOrientation (); | |
481 hookEvents (); | |
482 register (); | |
483 } | |
484 | |
485 void deregister () { | |
486 if (handle is null) return; | |
487 if ((state & HANDLE) !is 0) display.removeWidget (handle); | |
488 } | |
489 | |
490 void destroyWidget () { | |
491 GtkWidget* h = topHandle (); | |
492 releaseHandle (); | |
493 if (h !is null && (state & HANDLE) !is 0) { | |
494 OS.gtk_widget_destroy (h); | |
495 } | |
496 } | |
497 | |
498 /** | |
499 * Disposes of the operating system resources associated with | |
500 * the receiver and all its descendants. After this method has | |
501 * been invoked, the receiver and all descendants will answer | |
502 * <code>true</code> when sent the message <code>isDisposed()</code>. | |
503 * Any internal connections between the widgets in the tree will | |
504 * have been removed to facilitate garbage collection. | |
505 * <p> | |
506 * NOTE: This method is not called recursively on the descendants | |
507 * of the receiver. This means that, widget implementers can not | |
508 * detect when a widget is being disposed of by re-implementing | |
509 * this method, but should instead listen for the <code>Dispose</code> | |
510 * event. | |
511 * </p> | |
512 * | |
513 * @exception SWTException <ul> | |
514 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
515 * </ul> | |
516 * | |
517 * @see #addDisposeListener | |
518 * @see #removeDisposeListener | |
519 * @see #checkWidget | |
520 */ | |
521 public void dispose () { | |
522 /* | |
523 * Note: It is valid to attempt to dispose a widget | |
524 * more than once. If this happens, fail silently. | |
525 */ | |
526 if (isDisposed ()) return; | |
527 if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); | |
528 release (true); | |
529 } | |
530 | |
531 void error (int code) { | |
532 SWT.error (code); | |
533 } | |
534 | |
535 /** | |
536 * Returns the application defined widget data associated | |
537 * with the receiver, or null if it has not been set. The | |
538 * <em>widget data</em> is a single, unnamed field that is | |
539 * stored with every widget. | |
540 * <p> | |
541 * Applications may put arbitrary objects in this field. If | |
542 * the object stored in the widget data needs to be notified | |
543 * when the widget is disposed of, it is the application's | |
544 * responsibility to hook the Dispose event on the widget and | |
545 * do so. | |
546 * </p> | |
547 * | |
548 * @return the widget data | |
549 * | |
550 * @exception SWTException <ul> | |
551 * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li> | |
552 * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> | |
553 * </ul> | |
554 * | |
555 * @see #setData(Object) | |
556 */ | |
557 public Object getData () { | |
558 checkWidget(); | |
559 return (state & KEYED_DATA) !is 0 ? (cast(ArrayWrapperObject)data).array[0] : data; | |
560 } | |
561 public String getDataStr () { | |
562 return stringcast( getData() ); | |
563 } | |
564 | |
565 /** | |
566 * Returns the application defined property of the receiver | |
567 * with the specified name, or null if it has not been set. | |
568 * <p> | |
569 * Applications may have associated arbitrary objects with the | |
570 * receiver in this fashion. If the objects stored in the | |
571 * properties need to be notified when the widget is disposed | |
572 * of, it is the application's responsibility to hook the | |
573 * Dispose event on the widget and do so. | |
574 * </p> | |
575 * | |
576 * @param key the name of the property | |
577 * @return the value of the property or null if it has not been set | |
578 * | |
579 * @exception SWTException <ul> | |
580 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
581 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
582 * </ul> | |
583 * | |
584 * @see #setData(String, Object) | |
585 */ | |
586 public Object getData (String key) { | |
587 checkWidget(); | |
588 // SWT extension: allow null for zero length string | |
589 //if (key is null) error (SWT.ERROR_NULL_ARGUMENT); | |
590 if ((state & KEYED_DATA) !is 0) { | |
591 Object[] table = (cast(ArrayWrapperObject) data).array; | |
592 for (int i=1; i<table.length; i+=2) { | |
593 String tablekey = (cast(ArrayWrapperString) table[i]).array; | |
594 if (key ==/*eq*/ tablekey ) return table [i+1]; | |
595 } | |
596 } | |
597 return null; | |
598 } | |
599 public String getDataStr (String key) { | |
600 return stringcast( getData(key) ); | |
601 } | |
602 | |
603 /** | |
604 * Returns the <code>Display</code> that is associated with | |
605 * the receiver. | |
606 * <p> | |
607 * A widget's display is either provided when it is created | |
608 * (for example, top level <code>Shell</code>s) or is the | |
609 * same as its parent's display. | |
610 * </p> | |
611 * | |
612 * @return the receiver's display | |
613 * | |
614 * @exception SWTException <ul> | |
615 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
616 * </ul> | |
617 */ | |
618 public Display getDisplay () { | |
619 Display display = this.display; | |
620 if (display is null) error (SWT.ERROR_WIDGET_DISPOSED); | |
621 return display; | |
622 } | |
623 | |
624 /** | |
625 * Returns an array of listeners who will be notified when an event | |
626 * of the given type occurs. The event type is one of the event constants | |
627 * defined in class <code>SWT</code>. | |
628 * | |
629 * @param eventType the type of event to listen for | |
630 * @return an array of listeners that will be notified when the event occurs | |
631 * | |
632 * @exception SWTException <ul> | |
633 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
634 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
635 * </ul> | |
636 * | |
637 * @see Listener | |
638 * @see SWT | |
639 * @see #addListener(int, Listener) | |
640 * @see #removeListener(int, Listener) | |
641 * @see #notifyListeners | |
642 * | |
643 * @since 3.4 | |
644 */ | |
645 public Listener[] getListeners (int eventType) { | |
646 checkWidget(); | |
647 if (eventTable is null) return new Listener[0]; | |
648 return eventTable.getListeners(eventType); | |
649 } | |
650 | |
651 String getName () { | |
652 // String str = getClass ().getName (); | |
653 // int index = str.lastIndexOf ('.'); | |
654 // if (index is -1) return str; | |
655 String str = this.classinfo.name; | |
656 int index = str.length; | |
657 while ((--index > 0) && (str[index] !is '.')) {} | |
658 return str[index + 1 .. $ ]; | |
659 } | |
660 | |
661 String getNameText () { | |
662 return ""; | |
663 } | |
664 | |
665 /** | |
666 * Returns the receiver's style information. | |
667 * <p> | |
668 * Note that the value which is returned by this method <em>may | |
669 * not match</em> the value which was provided to the constructor | |
670 * when the receiver was created. This can occur when the underlying | |
671 * operating system does not support a particular combination of | |
672 * requested styles. For example, if the platform widget used to | |
673 * implement a particular SWT widget always has scroll bars, the | |
674 * result of calling this method would always have the | |
675 * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set. | |
676 * </p> | |
677 * | |
678 * @return the style bits | |
679 * | |
680 * @exception SWTException <ul> | |
681 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
682 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
683 * </ul> | |
684 */ | |
685 public int getStyle () { | |
686 checkWidget (); | |
687 return style; | |
688 } | |
689 | |
690 | |
691 int /*long*/ gtk_activate (GtkWidget* widget) { | |
692 return 0; | |
693 } | |
694 | |
695 int /*long*/ gtk_button_press_event (GtkWidget* widget, GdkEventButton* event) { | |
696 return 0; | |
697 } | |
698 | |
699 int /*long*/ gtk_button_release_event (GtkWidget* widget, GdkEventButton* event) { | |
700 return 0; | |
701 } | |
702 | |
703 int /*long*/ gtk_changed (GtkWidget* widget) { | |
704 return 0; | |
705 } | |
706 | |
707 int /*long*/ gtk_change_value (GtkWidget* widget, int /*long*/ scroll, int /*long*/ value1, int /*long*/ value2) { | |
708 return 0; | |
709 } | |
710 | |
711 int /*long*/ gtk_clicked (GtkWidget* widget) { | |
712 return 0; | |
713 } | |
714 | |
715 int /*long*/ gtk_commit (GtkIMContext* imcontext, char* text) { | |
716 return 0; | |
717 } | |
718 | |
719 int /*long*/ gtk_configure_event (GtkWidget* widget, int /*long*/ event) { | |
720 return 0; | |
721 } | |
722 | |
723 int /*long*/ gtk_day_selected (GtkWidget* widget) { | |
724 return 0; | |
725 } | |
726 | |
727 int /*long*/ gtk_delete_event (GtkWidget* widget, int /*long*/ event) { | |
728 return 0; | |
729 } | |
730 | |
731 int /*long*/ gtk_delete_range (GtkWidget* widget, int /*long*/ iter1, int /*long*/ iter2) { | |
732 return 0; | |
733 } | |
734 | |
735 int /*long*/ gtk_delete_text (GtkWidget* widget, int /*long*/ start_pos, int /*long*/ end_pos) { | |
736 return 0; | |
737 } | |
738 | |
739 int /*long*/ gtk_enter_notify_event (GtkWidget* widget, GdkEventCrossing* event) { | |
740 return 0; | |
741 } | |
742 | |
743 int /*long*/ gtk_event (GtkWidget* widget, GdkEvent* event) { | |
744 return 0; | |
745 } | |
746 | |
747 int /*long*/ gtk_event_after (GtkWidget* widget, GdkEvent* event) { | |
748 return 0; | |
749 } | |
750 | |
751 int /*long*/ gtk_expand_collapse_cursor_row (GtkWidget* widget, int /*long*/ logical, int /*long*/ expand, int /*long*/ open_all) { | |
752 return 0; | |
753 } | |
754 | |
755 int /*long*/ gtk_expose_event (GtkWidget* widget, GdkEventExpose* event) { | |
756 return 0; | |
757 } | |
758 | |
759 int /*long*/ gtk_focus (GtkWidget* widget, int directionType) { | |
760 return 0; | |
761 } | |
762 | |
763 int /*long*/ gtk_focus_in_event (GtkWidget* widget, GdkEventFocus* event) { | |
764 return 0; | |
765 } | |
766 | |
767 int /*long*/ gtk_focus_out_event (GtkWidget* widget, GdkEventFocus* event) { | |
768 return 0; | |
769 } | |
770 | |
771 int /*long*/ gtk_grab_focus (GtkWidget* widget) { | |
772 return 0; | |
773 } | |
774 | |
775 int /*long*/ gtk_hide (GtkWidget* widget) { | |
776 return 0; | |
777 } | |
778 | |
779 int /*long*/ gtk_input (GtkWidget* widget, int /*long*/ arg1) { | |
780 return 0; | |
781 } | |
782 | |
783 int /*long*/ gtk_insert_text (GtkEditable* widget, char* new_text, int new_text_length, int position) { | |
784 return 0; | |
785 } | |
786 | |
787 int /*long*/ gtk_key_press_event (GtkWidget* widget, GdkEventKey* event) { | |
788 return sendKeyEvent (SWT.KeyDown, event) ? 0 : 1; | |
789 } | |
790 | |
791 int /*long*/ gtk_key_release_event (GtkWidget* widget, GdkEventKey* event) { | |
792 return sendKeyEvent (SWT.KeyUp, event) ? 0 : 1; | |
793 } | |
794 | |
795 int /*long*/ gtk_leave_notify_event (GtkWidget* widget, GdkEventCrossing* event) { | |
796 return 0; | |
797 } | |
798 | |
799 int /*long*/ gtk_map (GtkWidget* widget) { | |
800 return 0; | |
801 } | |
802 | |
803 int /*long*/ gtk_map_event (GtkWidget* widget, int /*long*/ event) { | |
804 return 0; | |
805 } | |
806 | |
807 int /*long*/ gtk_mnemonic_activate (GtkWidget* widget, int /*long*/ arg1) { | |
808 return 0; | |
809 } | |
810 | |
811 int /*long*/ gtk_month_changed (GtkWidget* widget) { | |
812 return 0; | |
813 } | |
814 | |
815 int /*long*/ gtk_motion_notify_event (GtkWidget* widget, GdkEventMotion* event) { | |
816 return 0; | |
817 } | |
818 | |
819 int /*long*/ gtk_move_focus (GtkWidget* widget, int directionType) { | |
820 return 0; | |
821 } | |
822 | |
823 int /*long*/ gtk_output (GtkWidget* widget) { | |
824 return 0; | |
825 } | |
826 | |
827 int /*long*/ gtk_populate_popup (GtkWidget* widget, GtkWidget* menu) { | |
828 return 0; | |
829 } | |
830 | |
831 int /*long*/ gtk_popup_menu (GtkWidget* widget) { | |
832 return 0; | |
833 } | |
834 | |
835 int /*long*/ gtk_preedit_changed (GtkIMContext* imcontext) { | |
836 return 0; | |
837 } | |
838 | |
839 int /*long*/ gtk_realize (GtkWidget* widget) { | |
840 return 0; | |
841 } | |
842 | |
843 void gtk_row_activated (GtkTreeView* tree, GtkTreePath* path, GtkTreeViewColumn* column) { | |
844 } | |
845 | |
846 int /*long*/ gtk_scroll_child (GtkWidget* widget, int /*long*/ scrollType, int /*long*/ horizontal) { | |
847 return 0; | |
848 } | |
849 | |
850 int /*long*/ gtk_scroll_event (GtkWidget* widget, GdkEventScroll* event) { | |
851 return 0; | |
852 } | |
853 | |
854 int /*long*/ gtk_select (int /*long*/ item) { | |
855 return 0; | |
856 } | |
857 | |
858 int /*long*/ gtk_show (GtkWidget* widget) { | |
859 return 0; | |
860 } | |
861 | |
862 int /*long*/ gtk_show_help (GtkWidget* widget, int /*long*/ helpType) { | |
863 return 0; | |
864 } | |
865 | |
866 int /*long*/ gtk_size_allocate (GtkWidget* widget, int /*long*/ allocation) { | |
867 return 0; | |
868 } | |
869 | |
870 int /*long*/ gtk_style_set (GtkWidget* widget, int /*long*/ previousStyle) { | |
871 return 0; | |
872 } | |
873 | |
874 int /*long*/ gtk_switch_page (GtkWidget* widget, int /*long*/ page, int /*long*/ page_num) { | |
875 return 0; | |
876 } | |
877 | |
878 int gtk_test_collapse_row ( | |
879 GtkTreeView *tree_view, | |
880 GtkTreeIter *iter, | |
881 GtkTreePath *path) | |
882 { | |
883 return 0; | |
884 } | |
885 | |
886 int /*long*/ gtk_test_expand_row ( | |
887 GtkTreeView *tree_view, | |
888 GtkTreeIter *iter, | |
889 GtkTreePath *path) | |
890 { | |
891 return 0; | |
892 } | |
893 | |
894 int /*long*/ gtk_text_buffer_insert_text (GtkTextBuffer *buffer, GtkTextIter *iter, char *text, int len) { | |
895 return 0; | |
896 } | |
897 | |
898 int /*long*/ gtk_timer () { | |
899 return 0; | |
900 } | |
901 | |
902 int /*long*/ gtk_toggled (int /*long*/ renderer, char* pathStr) { | |
903 return 0; | |
904 } | |
905 | |
906 int /*long*/ gtk_unmap (GtkWidget* widget) { | |
907 return 0; | |
908 } | |
909 | |
910 int /*long*/ gtk_unmap_event (GtkWidget* widget, int /*long*/ event) { | |
911 return 0; | |
912 } | |
913 | |
914 int /*long*/ gtk_unrealize (GtkWidget* widget) { | |
915 return 0; | |
916 } | |
917 | |
918 int /*long*/ gtk_value_changed (int /*long*/ adjustment) { | |
919 return 0; | |
920 } | |
921 | |
922 int /*long*/ gtk_visibility_notify_event (GtkWidget* widget, GdkEventVisibility* event) { | |
923 return 0; | |
924 } | |
925 | |
926 int /*long*/ gtk_window_state_event (GtkWidget* widget, GdkEventWindowState* event) { | |
927 return 0; | |
928 } | |
929 | |
930 int fontHeight ( PangoFontDescription* font, GtkWidget* widgetHandle ) { | |
931 auto context = OS.gtk_widget_get_pango_context (widgetHandle); | |
932 auto lang = OS.pango_context_get_language (context); | |
933 auto metrics = OS.pango_context_get_metrics (context, font, lang); | |
934 int ascent = OS.pango_font_metrics_get_ascent (metrics); | |
935 int descent = OS.pango_font_metrics_get_descent (metrics); | |
936 OS.pango_font_metrics_unref (metrics); | |
937 return OS.PANGO_PIXELS (ascent + descent); | |
938 } | |
939 | |
940 int filterProc (XEvent* xEvent, GdkEvent* gdkEvent, void* data) { | |
941 return 0; | |
942 } | |
943 | |
944 bool filters (int eventType) { | |
945 return display.filters (eventType); | |
946 } | |
947 | |
948 int /*long*/ fixedMapProc (GtkWidget* widget) { | |
949 return 0; | |
950 } | |
951 | |
952 void fixedSizeAllocateProc(GtkWidget* widget, GtkAllocation* allocationPtr) { | |
953 return Display.oldFixedSizeAllocateProc(widget, allocationPtr); | |
954 } | |
955 | |
956 char [] fixMnemonic (String str) { | |
957 return fixMnemonic (str, true); | |
958 } | |
959 | |
960 char [] fixMnemonic (String str, bool replace) { | |
961 int len = str.length; | |
962 String text = str[0 .. len].dup; | |
963 int i = 0, j = 0; | |
964 char [] result = new char [len * 2]; | |
965 while (i < len) { | |
966 switch (text [i]) { | |
967 case '&': | |
968 if (i + 1 < len && text [i + 1] is '&') { | |
969 i++; | |
970 } else { | |
971 if (replace) { | |
972 text [i] = '_'; | |
973 } else { | |
974 i++; | |
975 } | |
976 } | |
977 break; | |
978 case '_': | |
979 if (replace) result [j++] = '_'; | |
980 break; | |
981 default: | |
982 } | |
983 result [j++] = text [i++]; | |
984 } | |
985 return result[0..j]; | |
986 } | |
987 | |
988 /** | |
989 * Returns <code>true</code> if the widget has been disposed, | |
990 * and <code>false</code> otherwise. | |
991 * <p> | |
992 * This method gets the dispose state for the widget. | |
993 * When a widget has been disposed, it is an error to | |
994 * invoke any other method using the widget. | |
995 * </p> | |
996 * | |
997 * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise | |
998 */ | |
999 public bool isDisposed () { | |
1000 return (state & DISPOSED) !is 0; | |
1001 } | |
1002 | |
1003 /** | |
1004 * Returns <code>true</code> if there are any listeners | |
1005 * for the specified event type associated with the receiver, | |
1006 * and <code>false</code> otherwise. The event type is one of | |
1007 * the event constants defined in class <code>SWT</code>. | |
1008 * | |
1009 * @param eventType the type of event | |
1010 * @return true if the event is hooked | |
1011 * | |
1012 * @exception SWTException <ul> | |
1013 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1014 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1015 * </ul> | |
1016 * | |
1017 * @see SWT | |
1018 */ | |
1019 public bool isListening (int eventType) { | |
1020 checkWidget (); | |
1021 return hooks (eventType); | |
1022 } | |
1023 | |
1024 bool isValidThread () { | |
1025 return getDisplay ().isValidThread (); | |
1026 } | |
1027 | |
1028 bool isValidSubclass() { | |
1029 return true;//Display.isValidClass(getClass()); | |
1030 } | |
1031 | |
1032 void hookEvents () { | |
1033 } | |
1034 | |
1035 /* | |
1036 * Returns <code>true</code> if the specified eventType is | |
1037 * hooked, and <code>false</code> otherwise. Implementations | |
1038 * of SWT can avoid creating objects and sending events | |
1039 * when an event happens in the operating system but | |
1040 * there are no listeners hooked for the event. | |
1041 * | |
1042 * @param eventType the event to be checked | |
1043 * | |
1044 * @return <code>true</code> when the eventType is hooked and <code>false</code> otherwise | |
1045 * | |
1046 * @see #isListening | |
1047 */ | |
1048 bool hooks (int eventType) { | |
1049 if (eventTable is null) return false; | |
1050 return eventTable.hooks (eventType); | |
1051 } | |
1052 | |
1053 int /*long*/ hoverProc (GtkWidget* widget) { | |
1054 return 0; | |
1055 } | |
1056 | |
1057 void menuPositionProc (GtkMenu* menu, int* x, int* y, int* push_in, void* user_data) { | |
1058 } | |
1059 | |
1060 bool mnemonicHit (GtkWidget* mnemonicHandle, wchar key) { | |
1061 if (!mnemonicMatch (mnemonicHandle, key)) return false; | |
1062 OS.g_signal_handlers_block_matched ( cast(void*)mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udMNEMONIC_ACTIVATE); | |
1063 bool result = cast(bool)OS.gtk_widget_mnemonic_activate (cast(GtkWidget*)mnemonicHandle, false); | |
1064 OS.g_signal_handlers_unblock_matched (cast(void*)mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udMNEMONIC_ACTIVATE); | |
1065 return result; | |
1066 } | |
1067 | |
1068 bool mnemonicMatch (GtkWidget* mnemonicHandle, wchar key) { | |
1069 int keyval1 = OS.gdk_keyval_to_lower (OS.gdk_unicode_to_keyval (key)); | |
1070 int keyval2 = OS.gdk_keyval_to_lower (OS.gtk_label_get_mnemonic_keyval (cast(GtkLabel*)mnemonicHandle)); | |
1071 return keyval1 is keyval2; | |
1072 } | |
1073 | |
1074 void modifyStyle (GtkWidget* handle, GtkRcStyle* style) { | |
1075 OS.gtk_widget_modify_style (handle, style); | |
1076 } | |
1077 | |
1078 /** | |
1079 * Notifies all of the receiver's listeners for events | |
1080 * of the given type that one such event has occurred by | |
1081 * invoking their <code>handleEvent()</code> method. The | |
1082 * event type is one of the event constants defined in class | |
1083 * <code>SWT</code>. | |
1084 * | |
1085 * @param eventType the type of event which has occurred | |
1086 * @param event the event data | |
1087 * | |
1088 * @exception SWTException <ul> | |
1089 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1090 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1091 * </ul> | |
1092 * | |
1093 * @see SWT | |
1094 * @see #addListener | |
1095 * @see #getListeners(int) | |
1096 * @see #removeListener(int, Listener) | |
1097 */ | |
1098 public void notifyListeners (int eventType, Event event) { | |
1099 checkWidget(); | |
1100 if (event is null) event = new Event (); | |
1101 sendEvent (eventType, event); | |
1102 } | |
1103 | |
1104 void postEvent (int eventType) { | |
1105 sendEvent (eventType, null, false); | |
1106 } | |
1107 | |
1108 void postEvent (int eventType, Event event) { | |
1109 sendEvent (eventType, event, false); | |
1110 } | |
1111 | |
1112 void register () { | |
1113 if (handle is null) return; | |
1114 if ((state & HANDLE) !is 0) display.addWidget (handle, this); | |
1115 } | |
1116 | |
1117 void release (bool destroy) { | |
1118 if ((state & DISPOSE_SENT) is 0) { | |
1119 state |= DISPOSE_SENT; | |
1120 sendEvent (SWT.Dispose); | |
1121 } | |
1122 if ((state & DISPOSED) is 0) { | |
1123 releaseChildren (destroy); | |
1124 } | |
1125 if ((state & RELEASED) is 0) { | |
1126 state |= RELEASED; | |
1127 if (destroy) { | |
1128 releaseParent (); | |
1129 releaseWidget (); | |
1130 destroyWidget (); | |
1131 } else { | |
1132 releaseWidget (); | |
1133 releaseHandle (); | |
1134 } | |
1135 } | |
1136 } | |
1137 | |
1138 void releaseChildren (bool destroy) { | |
1139 } | |
1140 | |
1141 void releaseHandle () { | |
1142 handle = null; | |
1143 state |= DISPOSED; | |
1144 display = null; | |
1145 } | |
1146 | |
1147 void releaseParent () { | |
1148 /* Do nothing */ | |
1149 } | |
1150 | |
1151 void releaseWidget () { | |
1152 deregister (); | |
1153 eventTable = null; | |
1154 data = null; | |
1155 } | |
1156 | |
1157 /** | |
1158 * Removes the listener from the collection of listeners who will | |
1159 * be notified when an event of the given type occurs. The event | |
1160 * type is one of the event constants defined in class <code>SWT</code>. | |
1161 * | |
1162 * @param eventType the type of event to listen for | |
1163 * @param listener the listener which should no longer be notified | |
1164 * | |
1165 * @exception IllegalArgumentException <ul> | |
1166 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
1167 * </ul> | |
1168 * @exception SWTException <ul> | |
1169 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1170 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1171 * </ul> | |
1172 * | |
1173 * @see Listener | |
1174 * @see SWT | |
1175 * @see #addListener | |
1176 * @see #getListeners(int) | |
1177 * @see #notifyListeners | |
1178 */ | |
1179 public void removeListener (int eventType, Listener handler) { | |
1180 checkWidget (); | |
1181 if (handler is null) error (SWT.ERROR_NULL_ARGUMENT); | |
1182 if (eventTable is null) return; | |
1183 eventTable.unhook (eventType, handler); | |
1184 } | |
1185 | |
1186 /** | |
1187 * Removes the listener from the collection of listeners who will | |
1188 * be notified when an event of the given type occurs. | |
1189 * <p> | |
1190 * <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT | |
1191 * public API. It is marked public only so that it can be shared | |
1192 * within the packages provided by SWT. It should never be | |
1193 * referenced from application code. | |
1194 * </p> | |
1195 * | |
1196 * @param eventType the type of event to listen for | |
1197 * @param listener the listener which should no longer be notified | |
1198 * | |
1199 * @exception IllegalArgumentException <ul> | |
1200 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
1201 * </ul> | |
1202 * @exception SWTException <ul> | |
1203 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1204 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1205 * </ul> | |
1206 * | |
1207 * @see Listener | |
1208 * @see #addListener | |
1209 */ | |
1210 protected void removeListener (int eventType, SWTEventListener handler) { | |
1211 checkWidget (); | |
1212 if (handler is null) error (SWT.ERROR_NULL_ARGUMENT); | |
1213 if (eventTable is null) return; | |
1214 eventTable.unhook (eventType, handler); | |
1215 } | |
1216 | |
1217 void rendererGetSizeProc ( | |
1218 GtkCellRenderer *cell, | |
1219 GtkWidget *widget, | |
1220 GdkRectangle *cell_area, | |
1221 int *x_offset, | |
1222 int *y_offset, | |
1223 int *width, | |
1224 int *height) | |
1225 { | |
1226 } | |
1227 | |
1228 void rendererRenderProc ( | |
1229 GtkCellRenderer * cell, | |
1230 GdkDrawable * window, | |
1231 GtkWidget * widget, | |
1232 GdkRectangle *background_area, | |
1233 GdkRectangle *cell_area, | |
1234 GdkRectangle *expose_area, | |
1235 int flags) | |
1236 { | |
1237 } | |
1238 | |
1239 /** | |
1240 * Removes the listener from the collection of listeners who will | |
1241 * be notified when the widget is disposed. | |
1242 * | |
1243 * @param listener the listener which should no longer be notified | |
1244 * | |
1245 * @exception IllegalArgumentException <ul> | |
1246 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
1247 * </ul> | |
1248 * @exception SWTException <ul> | |
1249 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1250 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1251 * </ul> | |
1252 * | |
1253 * @see DisposeListener | |
1254 * @see #addDisposeListener | |
1255 */ | |
1256 public void removeDisposeListener (DisposeListener listener) { | |
1257 checkWidget (); | |
1258 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); | |
1259 if (eventTable is null) return; | |
1260 eventTable.unhook (SWT.Dispose, listener); | |
1261 } | |
1262 | |
1263 | |
1264 void sendEvent (Event event) { | |
1265 Display display = event.display; | |
1266 if (!display.filterEvent (event)) { | |
1267 if (eventTable !is null) eventTable.sendEvent (event); | |
1268 } | |
1269 } | |
1270 | |
1271 void sendEvent (int eventType) { | |
1272 sendEvent (eventType, null, true); | |
1273 } | |
1274 | |
1275 void sendEvent (int eventType, Event event) { | |
1276 sendEvent (eventType, event, true); | |
1277 } | |
1278 | |
1279 void sendEvent (int eventType, Event event, bool send) { | |
1280 if (eventTable is null && !display.filters (eventType)) { | |
1281 return; | |
1282 } | |
1283 if (event is null) event = new Event (); | |
1284 event.type = eventType; | |
1285 event.display = display; | |
1286 event.widget = this; | |
1287 if (event.time is 0) { | |
1288 event.time = display.getLastEventTime (); | |
1289 } | |
1290 if (send) { | |
1291 sendEvent (event); | |
1292 } else { | |
1293 display.postEvent (event); | |
1294 } | |
1295 } | |
1296 | |
1297 bool sendKeyEvent (int type, GdkEventKey* keyEvent) { | |
1298 int len = keyEvent.length; | |
1299 if (keyEvent.string is null || OS.g_utf8_strlen (keyEvent.string, len) <= 1) { | |
1300 Event event = new Event (); | |
1301 event.time = keyEvent.time; | |
1302 if (!setKeyState (event, keyEvent)) return true; | |
1303 sendEvent (type, event); | |
1304 // widget could be disposed at this point | |
1305 | |
1306 /* | |
1307 * It is possible (but unlikely), that application | |
1308 * code could have disposed the widget in the key | |
1309 * events. If this happens, end the processing of | |
1310 * the key by returning false. | |
1311 */ | |
1312 if (isDisposed ()) return false; | |
1313 return event.doit; | |
1314 } | |
1315 char [] chars = fromStringz( keyEvent.string ); | |
1316 return sendIMKeyEvent (type, keyEvent, chars) !is null; | |
1317 } | |
1318 | |
1319 char [] sendIMKeyEvent (int type, GdkEventKey* keyEvent, char [] chars) { | |
1320 int index = 0, count = 0, state = 0; | |
1321 GdkEvent* ptr = null; | |
1322 if (keyEvent is null) { | |
1323 ptr = OS.gtk_get_current_event (); | |
1324 if (ptr !is null) { | |
1325 keyEvent = cast(GdkEventKey*)ptr; | |
1326 switch (cast(int)keyEvent.type) { | |
1327 case OS.GDK_KEY_PRESS: | |
1328 case OS.GDK_KEY_RELEASE: | |
1329 state = keyEvent.state; | |
1330 break; | |
1331 default: | |
1332 keyEvent = null; | |
1333 break; | |
1334 } | |
1335 } | |
1336 } | |
1337 if (keyEvent is null) { | |
1338 int buffer; | |
1339 OS.gtk_get_current_event_state (&buffer); | |
1340 state = buffer; | |
1341 } | |
1342 while (index < chars.length) { | |
1343 Event event = new Event (); | |
1344 //PORTING take care of utf8 | |
1345 if (keyEvent !is null && chars.codepointCount() <= 1) { | |
1346 setKeyState (event, keyEvent); | |
1347 } else { | |
1348 setInputState (event, state); | |
1349 } | |
1350 //PORTING take care of utf8 | |
1351 int incr; | |
1352 event.character = firstCodePoint( chars [index..$], incr ); | |
1353 sendEvent (type, event); | |
1354 | |
1355 /* | |
1356 * It is possible (but unlikely), that application | |
1357 * code could have disposed the widget in the key | |
1358 * events. If this happens, end the processing of | |
1359 * the key by returning null. | |
1360 */ | |
1361 if (isDisposed ()) { | |
1362 if (ptr !is null) OS.gdk_event_free (ptr); | |
1363 return null; | |
1364 } | |
1365 | |
1366 //PORTING take care of utf8 | |
1367 if (event.doit) { | |
1368 for( int i = 0; i < incr; i++ ){ | |
1369 chars [count+i] = chars [index+i]; | |
1370 } | |
1371 count+=incr; | |
1372 } | |
1373 index+=incr; | |
1374 } | |
1375 if (ptr !is null) OS.gdk_event_free (ptr); | |
1376 if (count is 0) return null; | |
1377 if (index !is count) { | |
1378 char [] result = new char [count]; | |
1379 System.arraycopy (chars, 0, result, 0, count); | |
1380 return result; | |
1381 } | |
1382 return chars; | |
1383 } | |
1384 | |
1385 /** | |
1386 * Sets the application defined widget data associated | |
1387 * with the receiver to be the argument. The <em>widget | |
1388 * data</em> is a single, unnamed field that is stored | |
1389 * with every widget. | |
1390 * <p> | |
1391 * Applications may put arbitrary objects in this field. If | |
1392 * the object stored in the widget data needs to be notified | |
1393 * when the widget is disposed of, it is the application's | |
1394 * responsibility to hook the Dispose event on the widget and | |
1395 * do so. | |
1396 * </p> | |
1397 * | |
1398 * @param data the widget data | |
1399 * | |
1400 * @exception SWTException <ul> | |
1401 * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li> | |
1402 * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li> | |
1403 * </ul> | |
1404 * | |
1405 * @see #getData() | |
1406 */ | |
1407 public void setData (Object data) { | |
1408 checkWidget(); | |
1409 if ((state & KEYED_DATA) !is 0) { | |
1410 (cast(ArrayWrapperObject) this.data).array[0] = data; | |
1411 } else { | |
1412 this.data = data; | |
1413 } | |
1414 } | |
1415 public void setDataStr (String data) { | |
1416 setData( stringcast(data)); | |
1417 } | |
1418 | |
1419 /** | |
1420 * Sets the application defined property of the receiver | |
1421 * with the specified name to the given value. | |
1422 * <p> | |
1423 * Applications may associate arbitrary objects with the | |
1424 * receiver in this fashion. If the objects stored in the | |
1425 * properties need to be notified when the widget is disposed | |
1426 * of, it is the application's responsibility to hook the | |
1427 * Dispose event on the widget and do so. | |
1428 * </p> | |
1429 * | |
1430 * @param key the name of the property | |
1431 * @param value the new value for the property | |
1432 * | |
1433 * @exception SWTException <ul> | |
1434 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | |
1435 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1436 * </ul> | |
1437 * | |
1438 * @see #getData(String) | |
1439 */ | |
1440 public void setData (String key, Object value) { | |
1441 checkWidget(); | |
1442 // SWT extension: allow null for zero length string | |
1443 //if (key is null) error (SWT.ERROR_NULL_ARGUMENT); | |
1444 int index = 1; | |
1445 Object [] table = null; | |
1446 if ((state & KEYED_DATA) !is 0) { | |
1447 table = (cast(ArrayWrapperObject) data).array; | |
1448 while (index < table.length) { | |
1449 String tablekey = (cast(ArrayWrapperString)table[index]).array; | |
1450 if (key.equals (tablekey) ) break; | |
1451 index += 2; | |
1452 } | |
1453 } | |
1454 if (value !is null) { | |
1455 if ((state & KEYED_DATA) !is 0) { | |
1456 if (index is table.length) { | |
1457 Object [] newTable = new Object [table.length + 2]; | |
1458 System.arraycopy (table, 0, newTable, 0, table.length); | |
1459 table = newTable; | |
1460 data = new ArrayWrapperObject( table ); | |
1461 } | |
1462 } else { | |
1463 table = new Object [3]; | |
1464 table [0] = data; | |
1465 data = new ArrayWrapperObject( table ); | |
1466 state |= KEYED_DATA; | |
1467 } | |
1468 table [index] = new ArrayWrapperString( key ); | |
1469 table [index + 1] = value; | |
1470 } else { | |
1471 if ((state & KEYED_DATA) !is 0) { | |
1472 if (index !is table.length) { | |
1473 int len = table.length - 2; | |
1474 if (len is 1) { | |
1475 data = table [0]; | |
1476 state &= ~KEYED_DATA; | |
1477 } else { | |
1478 Object [] newTable = new Object [len]; | |
1479 System.arraycopy (table, 0, newTable, 0, index); | |
1480 System.arraycopy (table, index + 2, newTable, index, len - index); | |
1481 data = new ArrayWrapperObject( newTable ); | |
1482 } | |
1483 } | |
1484 } | |
1485 } | |
1486 } | |
1487 public void setDataStr (String key, String value) { | |
1488 setData(key, stringcast(value)); | |
1489 } | |
1490 | |
1491 void setForegroundColor (GtkWidget* handle, GdkColor* color) { | |
1492 auto style = OS.gtk_widget_get_modifier_style (handle); | |
1493 OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_NORMAL, color); | |
1494 OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_ACTIVE, color); | |
1495 OS.gtk_rc_style_set_fg (style, OS.GTK_STATE_PRELIGHT, color); | |
1496 int flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL); | |
1497 flags = (color is null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG; | |
1498 OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_NORMAL, flags); | |
1499 flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE); | |
1500 flags = (color is null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG; | |
1501 OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags); | |
1502 flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_PRELIGHT); | |
1503 flags = (color is null) ? flags & ~OS.GTK_RC_FG: flags | OS.GTK_RC_FG; | |
1504 OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_PRELIGHT, flags); | |
1505 | |
1506 OS.gtk_rc_style_set_text (style, OS.GTK_STATE_NORMAL, color); | |
1507 OS.gtk_rc_style_set_text (style, OS.GTK_STATE_ACTIVE, color); | |
1508 OS.gtk_rc_style_set_text (style, OS.GTK_STATE_PRELIGHT, color); | |
1509 flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_NORMAL); | |
1510 flags = (color is null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT; | |
1511 OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_NORMAL, flags); | |
1512 flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_PRELIGHT); | |
1513 flags = (color is null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT; | |
1514 OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_PRELIGHT, flags); | |
1515 flags = OS.gtk_rc_style_get_color_flags (style, OS.GTK_STATE_ACTIVE); | |
1516 flags = (color is null) ? flags & ~OS.GTK_RC_TEXT: flags | OS.GTK_RC_TEXT; | |
1517 OS.gtk_rc_style_set_color_flags (style, OS.GTK_STATE_ACTIVE, flags); | |
1518 modifyStyle (handle, style); | |
1519 } | |
1520 | |
1521 bool setInputState (Event event, int state) { | |
1522 if ((state & OS.GDK_MOD1_MASK) !is 0) event.stateMask |= SWT.ALT; | |
1523 if ((state & OS.GDK_SHIFT_MASK) !is 0) event.stateMask |= SWT.SHIFT; | |
1524 if ((state & OS.GDK_CONTROL_MASK) !is 0) event.stateMask |= SWT.CONTROL; | |
1525 if ((state & OS.GDK_BUTTON1_MASK) !is 0) event.stateMask |= SWT.BUTTON1; | |
1526 if ((state & OS.GDK_BUTTON2_MASK) !is 0) event.stateMask |= SWT.BUTTON2; | |
1527 if ((state & OS.GDK_BUTTON3_MASK) !is 0) event.stateMask |= SWT.BUTTON3; | |
1528 return true; | |
1529 } | |
1530 | |
1531 bool setKeyState (Event event, GdkEventKey* keyEvent) { | |
1532 if (keyEvent.string !is null && OS.g_utf8_strlen (keyEvent.string, keyEvent.length) > 1) return false; | |
1533 bool isNull = false; | |
1534 event.keyCode = Display.translateKey (keyEvent.keyval); | |
1535 switch (keyEvent.keyval) { | |
1536 case OS.GDK_BackSpace: event.character = SWT.BS; break; | |
1537 case OS.GDK_Linefeed: event.character = SWT.LF; break; | |
1538 case OS.GDK_KP_Enter: | |
1539 case OS.GDK_Return: event.character = SWT.CR; break; | |
1540 case OS.GDK_KP_Delete: | |
1541 case OS.GDK_Delete: event.character = SWT.DEL; break; | |
1542 case OS.GDK_Escape: event.character = SWT.ESC; break; | |
1543 case OS.GDK_Tab: | |
1544 case OS.GDK_ISO_Left_Tab: event.character = SWT.TAB; break; | |
1545 default: { | |
1546 if (event.keyCode is 0) { | |
1547 uint keyval; | |
1548 int effective_group, level; | |
1549 int consumed_modifiers; | |
1550 if (OS.gdk_keymap_translate_keyboard_state(OS.gdk_keymap_get_default (), keyEvent.hardware_keycode, 0, keyEvent.group, &keyval, &effective_group, &level, &consumed_modifiers)) { | |
1551 event.keyCode = OS.gdk_keyval_to_unicode (keyval ); | |
1552 } | |
1553 } | |
1554 int key = keyEvent.keyval; | |
1555 if ((keyEvent.state & OS.GDK_CONTROL_MASK) !is 0 && (0 <= key && key <= 0x7F)) { | |
1556 if ('a' <= key && key <= 'z') key -= 'a' - 'A'; | |
1557 if (64 <= key && key <= 95) key -= 64; | |
1558 event.character = cast(char) key; | |
1559 isNull = keyEvent.keyval is '@' && key is 0; | |
1560 } else { | |
1561 event.character = cast(char) OS.gdk_keyval_to_unicode (key); | |
1562 } | |
1563 } | |
1564 } | |
1565 if (event.keyCode is 0 && event.character is 0) { | |
1566 if (!isNull) return false; | |
1567 } | |
1568 return setInputState (event, keyEvent.state); | |
1569 } | |
1570 | |
1571 void setOrientation () { | |
1572 } | |
1573 | |
1574 int /*long*/ shellMapProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ user_data) { | |
1575 return 0; | |
1576 } | |
1577 | |
1578 int /*long*/ sizeAllocateProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ user_data) { | |
1579 return 0; | |
1580 } | |
1581 | |
1582 int /*long*/ sizeRequestProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ user_data) { | |
1583 return 0; | |
1584 } | |
1585 | |
1586 /** | |
1587 * Returns a string containing a concise, human-readable | |
1588 * description of the receiver. | |
1589 * | |
1590 * @return a string representation of the receiver | |
1591 */ | |
1592 public override String toString () { | |
1593 String str = "*Disposed*"; | |
1594 if (!isDisposed ()) { | |
1595 str = "*Wrong Thread*"; | |
1596 if (isValidThread ()) str = getNameText (); | |
1597 } | |
1598 return getName () ~ " {" ~ str ~ "}"; | |
1599 } | |
1600 | |
1601 GtkWidget* topHandle () { | |
1602 return handle; | |
1603 } | |
1604 | |
1605 int /*long*/ timerProc (GtkWidget* widget) { | |
1606 return 0; | |
1607 } | |
1608 | |
1609 void treeSelectionProc ( | |
1610 GtkTreeModel *model, | |
1611 GtkTreePath *path, | |
1612 GtkTreeIter *iter, | |
1613 int[] selection, | |
1614 int length) | |
1615 { | |
1616 } | |
1617 | |
1618 bool translateTraversal (int event) { | |
1619 return false; | |
1620 } | |
1621 | |
1622 int /*long*/ windowProc (GtkWidget* handle, int /*long*/ user_data) { | |
1623 void trace( String str ){ | |
1624 version(LOG) getDwtLogger().error( __FILE__, __LINE__, "Widget windowProc {}", str ).flush; | |
1625 } | |
1626 | |
1627 switch (cast(int)/*64*/user_data) { | |
1628 case ACTIVATE: | |
1629 trace( "ACTIVATE" ); | |
1630 return gtk_activate (handle); | |
1631 case CHANGED: | |
1632 trace( "CHANGED" ); | |
1633 return gtk_changed (handle); | |
1634 case CLICKED: | |
1635 trace( "CLICKED" ); | |
1636 return gtk_clicked (handle); | |
1637 case DAY_SELECTED: | |
1638 trace( "DAY_SELECTED" ); | |
1639 return gtk_day_selected (handle); | |
1640 case HIDE: | |
1641 trace( "HIDE" ); | |
1642 return gtk_hide (handle); | |
1643 case GRAB_FOCUS: | |
1644 trace( "GRAB_FOCUS" ); | |
1645 return gtk_grab_focus (handle); | |
1646 case MAP: | |
1647 trace( "MAP" ); | |
1648 return gtk_map (handle); | |
1649 case MONTH_CHANGED: | |
1650 trace( "MONTH_CHANGED" ); | |
1651 return gtk_month_changed (handle); | |
1652 case OUTPUT: | |
1653 trace( "OUTPUT" ); | |
1654 return gtk_output (handle); | |
1655 case POPUP_MENU: | |
1656 trace( "POPUP_MENU" ); | |
1657 return gtk_popup_menu (handle); | |
1658 case PREEDIT_CHANGED: | |
1659 trace( "PREEDIT_CHANGED" ); | |
1660 return gtk_preedit_changed (cast(GtkIMContext*)handle); | |
1661 case REALIZE: | |
1662 trace( "REALIZE" ); | |
1663 return gtk_realize (handle); | |
1664 case SELECT: | |
1665 trace( "SELECT" ); | |
1666 return gtk_select (cast(int)handle); | |
1667 case SHOW: | |
1668 trace( "SHOW" ); | |
1669 return gtk_show (handle); | |
1670 case VALUE_CHANGED: | |
1671 trace( "VALUE_CHANGED" ); | |
1672 return gtk_value_changed (cast(int)handle); | |
1673 case UNMAP: | |
1674 trace( "UNMAP" ); | |
1675 return gtk_unmap (handle); | |
1676 case UNREALIZE: | |
1677 trace( "UNREALIZE" ); | |
1678 return gtk_unrealize (handle); | |
1679 default: | |
1680 trace( "default" ); | |
1681 return 0; | |
1682 } | |
1683 } | |
1684 | |
1685 int /*long*/ windowProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ user_data) { | |
1686 void trace( String str ){ | |
1687 version(LOG) getDwtLogger().error( __FILE__, __LINE__, "Widget windowProc1 {}", str ).flush; | |
1688 } | |
1689 | |
1690 switch (cast(int)/*64*/user_data) { | |
1691 case EXPOSE_EVENT_INVERSE: { | |
1692 trace( "EXPOSE_EVENT_INVERSE" ); | |
1693 GdkEventExpose* gdkEvent = cast(GdkEventExpose*) arg0; | |
1694 auto paintWindow = paintWindow(); | |
1695 auto window = gdkEvent.window; | |
1696 if (window !is paintWindow) return 0; | |
1697 return (state & OBSCURED) !is 0 ? 1 : 0; | |
1698 } | |
1699 case BUTTON_PRESS_EVENT_INVERSE: | |
1700 case BUTTON_RELEASE_EVENT_INVERSE: | |
1701 case MOTION_NOTIFY_EVENT_INVERSE: { | |
1702 trace( "BUTTON_PRESS_EVENT_INVERSE BUTTON_RELEASE_EVENT_INVERSE MOTION_NOTIFY_EVENT_INVERSE" ); | |
1703 return 1; | |
1704 } | |
1705 case BUTTON_PRESS_EVENT: | |
1706 trace( "BUTTON_PRESS_EVENT" ); | |
1707 return gtk_button_press_event (handle, cast(GdkEventButton*)arg0); | |
1708 case BUTTON_RELEASE_EVENT: | |
1709 trace( "BUTTON_RELEASE_EVENT" ); | |
1710 return gtk_button_release_event (handle, cast(GdkEventButton*)arg0); | |
1711 case COMMIT: | |
1712 trace( "COMMIT" ); | |
1713 return gtk_commit (cast(GtkIMContext*)handle, cast(char*)arg0); | |
1714 case CONFIGURE_EVENT: | |
1715 trace( "CONFIGURE_EVENT" ); | |
1716 return gtk_configure_event (handle, arg0); | |
1717 case DELETE_EVENT: | |
1718 trace( "DELETE_EVENT" ); | |
1719 return gtk_delete_event (handle, arg0); | |
1720 case ENTER_NOTIFY_EVENT: | |
1721 trace( "ENTER_NOTIFY_EVENT" ); | |
1722 return gtk_enter_notify_event (handle, cast(GdkEventCrossing*)arg0); | |
1723 case EVENT: | |
1724 trace( "EVENT" ); | |
1725 return gtk_event (handle, cast(GdkEvent*)arg0); | |
1726 case POPULATE_POPUP: | |
1727 trace( "POPULATE_POPUP" ); | |
1728 return gtk_populate_popup (handle, cast(GtkWidget*)arg0); | |
1729 case EVENT_AFTER: | |
1730 trace( "EVENT_AFTER" ); | |
1731 return gtk_event_after (handle, cast(GdkEvent*)arg0); | |
1732 case EXPOSE_EVENT: | |
1733 trace( "EXPOSE_EVENT" ); | |
1734 return gtk_expose_event (handle, cast(GdkEventExpose*)arg0); | |
1735 case FOCUS: | |
1736 trace( "FOCUS" ); | |
1737 return gtk_focus (handle, arg0); | |
1738 case FOCUS_IN_EVENT: | |
1739 trace( "FOCUS_IN_EVENT" ); | |
1740 return gtk_focus_in_event (handle, cast(GdkEventFocus*)arg0); | |
1741 case FOCUS_OUT_EVENT: | |
1742 trace( "FOCUS_OUT_EVENT" ); | |
1743 return gtk_focus_out_event (handle, cast(GdkEventFocus*)arg0); | |
1744 case KEY_PRESS_EVENT: | |
1745 trace( "KEY_PRESS_EVENT" ); | |
1746 return gtk_key_press_event (handle, cast(GdkEventKey*)arg0); | |
1747 case KEY_RELEASE_EVENT: | |
1748 trace( "KEY_RELEASE_EVENT" ); | |
1749 return gtk_key_release_event (handle, cast(GdkEventKey*)arg0); | |
1750 case INPUT: | |
1751 trace( "INPUT" ); | |
1752 return gtk_input (handle, arg0); | |
1753 case LEAVE_NOTIFY_EVENT: | |
1754 trace( "LEAVE_NOTIFY_EVENT" ); | |
1755 return gtk_leave_notify_event (handle, cast(GdkEventCrossing*)arg0); | |
1756 case MAP_EVENT: | |
1757 trace( "MAP_EVENT" ); | |
1758 return gtk_map_event (handle, arg0); | |
1759 case MNEMONIC_ACTIVATE: | |
1760 trace( "MNEMONIC_ACTIVATE" ); | |
1761 return gtk_mnemonic_activate (handle, arg0); | |
1762 case MOTION_NOTIFY_EVENT: | |
1763 trace( "MOTION_NOTIFY_EVENT" ); | |
1764 return gtk_motion_notify_event (handle, cast(GdkEventMotion*)arg0); | |
1765 case MOVE_FOCUS: | |
1766 trace( "MOVE_FOCUS" ); | |
1767 return gtk_move_focus (handle, arg0); | |
1768 case SCROLL_EVENT: | |
1769 trace( "SCROLL_EVENT" ); | |
1770 return gtk_scroll_event (handle, cast(GdkEventScroll*)arg0); | |
1771 case SHOW_HELP: | |
1772 trace( "SHOW_HELP" ); | |
1773 return gtk_show_help (handle, arg0); | |
1774 case SIZE_ALLOCATE: | |
1775 trace( "SIZE_ALLOCATE" ); | |
1776 return gtk_size_allocate (handle, arg0); | |
1777 case STYLE_SET: | |
1778 trace( "STYLE_SET" ); | |
1779 return gtk_style_set (handle, arg0); | |
1780 case TOGGLED: | |
1781 trace( "TOGGLED" ); | |
1782 return gtk_toggled (cast(int)handle, cast(char*)arg0); | |
1783 case UNMAP_EVENT: | |
1784 trace( "UNMAP_EVENT" ); | |
1785 return gtk_unmap_event (handle, arg0); | |
1786 case VISIBILITY_NOTIFY_EVENT: | |
1787 trace( "VISIBILITY_NOTIFY_EVENT" ); | |
1788 return gtk_visibility_notify_event (handle, cast(GdkEventVisibility*)arg0); | |
1789 case WINDOW_STATE_EVENT: | |
1790 trace( "WINDOW_STATE_EVENT" ); | |
1791 return gtk_window_state_event (handle, cast(GdkEventWindowState*)arg0); | |
1792 default: | |
1793 trace( "default" ); | |
1794 return 0; | |
1795 } | |
1796 } | |
1797 | |
1798 int /*long*/ windowProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ user_data) { | |
1799 void trace( String str ){ | |
1800 version(LOG) getDwtLogger().error( __FILE__, __LINE__, "Widget windowProc2 {}", str ).flush; | |
1801 } | |
1802 | |
1803 switch (cast(int)/*64*/user_data) { | |
1804 case DELETE_RANGE: | |
1805 trace( "DELETE_RANGE" ); | |
1806 return gtk_delete_range (handle, arg0, arg1); | |
1807 case DELETE_TEXT: | |
1808 trace( "DELETE_TEXT" ); | |
1809 return gtk_delete_text (handle, arg0, arg1); | |
1810 case ROW_ACTIVATED: | |
1811 trace( "ROW_ACTIVATED" ); | |
1812 gtk_row_activated (cast(GtkTreeView*)handle, cast(GtkTreePath*)arg0, cast(GtkTreeViewColumn*)arg1); | |
1813 return 0; | |
1814 case SCROLL_CHILD: | |
1815 trace( "SCROLL_CHILD" ); | |
1816 return gtk_scroll_child (handle, arg0, arg1); | |
1817 case SWITCH_PAGE: | |
1818 trace( "SWITCH_PAGE" ); | |
1819 return gtk_switch_page (handle, arg0, arg1); | |
1820 case TEST_COLLAPSE_ROW: | |
1821 trace( "TEST_COLLAPSE_ROW" ); | |
1822 return gtk_test_collapse_row (cast(GtkTreeView*)handle, cast(GtkTreeIter*)arg0, cast(GtkTreePath*)arg1); | |
1823 case TEST_EXPAND_ROW: | |
1824 trace( "TEST_EXPAND_ROW" ); | |
1825 return gtk_test_expand_row(cast(GtkTreeView*)handle, cast(GtkTreeIter*)arg0, cast(GtkTreePath*)arg1); | |
1826 default: | |
1827 trace( "default" ); | |
1828 return 0; | |
1829 } | |
1830 } | |
1831 | |
1832 int /*long*/ windowProc (GtkWidget* handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ user_data) { | |
1833 void trace( String str ){ | |
1834 version(LOG) getDwtLogger().error( __FILE__, __LINE__, "Widget windowProc3 {}", str ).flush; | |
1835 } | |
1836 | |
1837 switch (cast(int)/*64*/user_data) { | |
1838 case CHANGE_VALUE: | |
1839 trace( "CHANGE_VALUE" ); | |
1840 return gtk_change_value (handle, arg0, arg1, arg2); | |
1841 case EXPAND_COLLAPSE_CURSOR_ROW: | |
1842 trace( "EXPAND_COLLAPSE_CURSOR_ROW" ); | |
1843 return gtk_expand_collapse_cursor_row (handle, arg0, arg1, arg2); | |
1844 case INSERT_TEXT: | |
1845 trace( "INSERT_TEXT" ); | |
1846 return gtk_insert_text (cast(GtkEditable*)handle, cast(char*)arg0, arg1, arg2); | |
1847 case TEXT_BUFFER_INSERT_TEXT: | |
1848 trace( "TEXT_BUFFER_INSERT_TEXT" ); | |
1849 return gtk_text_buffer_insert_text (cast(GtkTextBuffer*)handle, cast(GtkTextIter*)arg0, cast(char*)arg1, arg2); | |
1850 default: | |
1851 trace( "default" ); | |
1852 return 0; | |
1853 } | |
1854 } | |
1855 | |
1856 } |