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