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