Mercurial > projects > dwt-linux
annotate dwt/widgets/Display.d @ 25:fc2b263b8a3f
Merged back the System.arraycopy and use a System class
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 08 Jan 2008 01:23:25 +0100 |
parents | 92223a4ecca7 |
children | 09f5459a5014 |
rev | line source |
---|---|
18 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 *******************************************************************************/ | |
11 module dwt.widgets.Display; | |
12 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
13 import dwt.SWT; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
14 import dwt.graphics.Color; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
15 import dwt.graphics.Cursor; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
16 import dwt.graphics.Device; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
17 import dwt.graphics.DeviceData; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
18 import dwt.graphics.Font; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
19 import dwt.graphics.GCData; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
20 import dwt.graphics.Image; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
21 import dwt.graphics.ImageData; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
22 import dwt.graphics.PaletteData; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
23 import dwt.graphics.Point; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
24 import dwt.graphics.Rectangle; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
25 import dwt.graphics.Resource; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
26 import dwt.internal.Compatibility; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
27 import dwt.internal.Converter; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
28 import dwt.internal.Lock; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
29 import dwt.internal.gtk.c.gdktypes; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
30 import dwt.internal.gtk.c.gtktypes; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
31 import dwt.internal.gtk.OS; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
32 import dwt.widgets.Caret; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
33 import dwt.widgets.Control; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
34 import dwt.widgets.Event; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
35 import dwt.widgets.EventTable; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
36 import dwt.widgets.Listener; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
37 import dwt.widgets.Menu; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
38 import dwt.widgets.Monitor; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
39 import dwt.widgets.Shell; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
40 import dwt.widgets.Synchronizer; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
41 import dwt.widgets.Tray; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
42 import dwt.widgets.Widget; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
43 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
44 class Display{ |
18 | 45 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
46 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
47 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
48 /++ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
49 |
18 | 50 |
51 /** | |
52 * Instances of this class are responsible for managing the | |
53 * connection between SWT and the underlying operating | |
54 * system. Their most important function is to implement | |
55 * the SWT event loop in terms of the platform event model. | |
56 * They also provide various methods for accessing information | |
57 * about the operating system, and have overall control over | |
58 * the operating system resources which SWT allocates. | |
59 * <p> | |
60 * Applications which are built with SWT will <em>almost always</em> | |
61 * require only a single display. In particular, some platforms | |
62 * which SWT supports will not allow more than one <em>active</em> | |
63 * display. In other words, some platforms do not support | |
64 * creating a new display if one already exists that has not been | |
65 * sent the <code>dispose()</code> message. | |
66 * <p> | |
67 * In SWT, the thread which creates a <code>Display</code> | |
68 * instance is distinguished as the <em>user-interface thread</em> | |
69 * for that display. | |
70 * </p> | |
71 * The user-interface thread for a particular display has the | |
72 * following special attributes: | |
73 * <ul> | |
74 * <li> | |
75 * The event loop for that display must be run from the thread. | |
76 * </li> | |
77 * <li> | |
78 * Some SWT API methods (notably, most of the public methods in | |
79 * <code>Widget</code> and its subclasses), may only be called | |
80 * from the thread. (To support multi-threaded user-interface | |
81 * applications, class <code>Display</code> provides inter-thread | |
82 * communication methods which allow threads other than the | |
83 * user-interface thread to request that it perform operations | |
84 * on their behalf.) | |
85 * </li> | |
86 * <li> | |
87 * The thread is not allowed to construct other | |
88 * <code>Display</code>s until that display has been disposed. | |
89 * (Note that, this is in addition to the restriction mentioned | |
90 * above concerning platform support for multiple displays. Thus, | |
91 * the only way to have multiple simultaneously active displays, | |
92 * even on platforms which support it, is to have multiple threads.) | |
93 * </li> | |
94 * </ul> | |
95 * Enforcing these attributes allows SWT to be implemented directly | |
96 * on the underlying operating system's event model. This has | |
97 * numerous benefits including smaller footprint, better use of | |
98 * resources, safer memory management, clearer program logic, | |
99 * better performance, and fewer overall operating system threads | |
100 * required. The down side however, is that care must be taken | |
101 * (only) when constructing multi-threaded applications to use the | |
102 * inter-thread communication mechanisms which this class provides | |
103 * when required. | |
104 * </p><p> | |
105 * All SWT API methods which may only be called from the user-interface | |
106 * thread are distinguished in their documentation by indicating that | |
107 * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>" | |
108 * SWT exception. | |
109 * </p> | |
110 * <dl> | |
111 * <dt><b>Styles:</b></dt> | |
112 * <dd>(none)</dd> | |
113 * <dt><b>Events:</b></dt> | |
114 * <dd>Close, Dispose, Settings</dd> | |
115 * </dl> | |
116 * <p> | |
117 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | |
118 * </p> | |
119 * @see #syncExec | |
120 * @see #asyncExec | |
121 * @see #wake | |
122 * @see #readAndDispatch | |
123 * @see #sleep | |
124 * @see Device#dispose | |
125 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
126 public class Display : Device { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
127 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
128 /* Events Dispatching and void*/*Callback*/ */ |
18 | 129 int gdkEventCount; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
130 GdkEvent* [] gdkEvents; |
18 | 131 Widget [] gdkEventWidgets; |
132 int [] dispatchEvents; | |
133 Event [] eventQueue; | |
134 int /*long*/ fds; | |
135 int allocated_nfds; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
136 bool wake; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
137 int max_priority, timeout; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
138 void*/*Callback*/ eventCallback, filterCallback; |
18 | 139 int /*long*/ eventProc, filterProc, windowProc2, windowProc3, windowProc4, windowProc5; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
140 void*/*Callback*/ windowCallback2, windowCallback3, windowCallback4, windowCallback5; |
18 | 141 EventTable eventTable, filterTable; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
142 static char[] APP_NAME = "SWT"; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
143 static const char[] DISPATCH_EVENT_KEY = "dwt.internal.gtk.dispatchEvent"; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
144 static const char[] ADD_WIDGET_KEY = "dwt.internal.addWidget"; |
18 | 145 int /*long*/ [] closures; |
146 int [] signalIds; | |
147 int /*long*/ shellMapProcClosure; | |
148 | |
149 /* Widget Table */ | |
150 int [] indexTable; | |
151 int freeSlot; | |
152 int /*long*/ lastHandle; | |
153 Widget lastWidget; | |
154 Widget [] widgetTable; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
155 const static int GROW_SIZE = 1024; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
156 static const int SWT_OBJECT_INDEX; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
157 static const int SWT_OBJECT_INDEX1; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
158 static const int SWT_OBJECT_INDEX2; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
159 static this(){ |
18 | 160 byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true); |
161 SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer); | |
162 buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX1", true); | |
163 SWT_OBJECT_INDEX1 = OS.g_quark_from_string (buffer); | |
164 buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX2", true); | |
165 SWT_OBJECT_INDEX2 = OS.g_quark_from_string (buffer); | |
166 } | |
167 | |
168 /* Focus */ | |
169 int focusEvent; | |
170 Control focusControl; | |
171 Shell activeShell; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
172 bool activePending; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
173 bool ignoreActivate, ignoreFocus; |
18 | 174 |
175 /* Input method resources */ | |
176 Control imControl; | |
177 int /*long*/ preeditWindow, preeditLabel; | |
178 | |
179 /* Sync/Async Widget Communication */ | |
180 Synchronizer synchronizer = new Synchronizer (this); | |
181 Thread thread; | |
182 | |
183 /* Display Shutdown */ | |
184 Runnable [] disposeList; | |
185 | |
186 /* System Tray */ | |
187 Tray tray; | |
188 | |
189 /* Timers */ | |
190 int [] timerIds; | |
191 Runnable [] timerList; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
192 void*/*Callback*/ timerCallback; |
18 | 193 int /*long*/ timerProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
194 void*/*Callback*/ windowTimerCallback; |
18 | 195 int /*long*/ windowTimerProc; |
196 | |
197 /* Caret */ | |
198 Caret currentCaret; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
199 void*/*Callback*/ caretCallback; |
18 | 200 int caretId; |
201 int /*long*/ caretProc; | |
202 | |
203 /* Mnemonics */ | |
204 Control mnemonicControl; | |
205 | |
206 /* Mouse hover */ | |
207 int mouseHoverId; | |
208 int /*long*/ mouseHoverHandle, mouseHoverProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
209 void*/*Callback*/ mouseHoverCallback; |
18 | 210 |
211 /* Menu position callback */ | |
212 int /*long*/ menuPositionProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
213 void*/*Callback*/ menuPositionCallback; |
18 | 214 |
215 /* Tooltip size allocate callback */ | |
216 int /*long*/ sizeAllocateProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
217 void*/*Callback*/ sizeAllocateCallback; |
18 | 218 int /*long*/ sizeRequestProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
219 void*/*Callback*/ sizeRequestCallback; |
18 | 220 |
221 /* Shell map callback */ | |
222 int /*long*/ shellMapProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
223 void*/*Callback*/ shellMapCallback; |
18 | 224 |
225 /* Idle proc callback */ | |
226 int /*long*/ idleProc; | |
227 int idleHandle; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
228 void*/*Callback*/ idleCallback; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
229 static const char[] ADD_IDLE_PROC_KEY = "dwt.internal.gtk2.addIdleProc"; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
230 static const char[] REMOVE_IDLE_PROC_KEY = "dwt.internal.gtk2.removeIdleProc"; |
18 | 231 Object idleLock = new Object(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
232 bool idleNeeded; |
18 | 233 |
234 /* GtkTreeView callbacks */ | |
235 int[] treeSelection; | |
236 int treeSelectionLength; | |
237 int /*long*/ treeSelectionProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
238 void*/*Callback*/ treeSelectionCallback; |
18 | 239 int /*long*/ cellDataProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
240 void*/*Callback*/ cellDataCallback; |
18 | 241 |
242 /* Set direction callback */ | |
243 int /*long*/ setDirectionProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
244 void*/*Callback*/ setDirectionCallback; |
18 | 245 |
246 /* Get all children callback */ | |
247 int /*long*/ allChildrenProc, allChildren; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
248 void*/*Callback*/ allChildrenCallback; |
18 | 249 |
250 /* Settings callbacks */ | |
251 int /*long*/ styleSetProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
252 void*/*Callback*/ styleSetCallback; |
18 | 253 int /*long*/ shellHandle; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
254 bool settingsChanged, runSettings; |
18 | 255 |
256 /* Entry focus behaviour */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
257 bool entrySelectOnFocus; |
18 | 258 |
259 /* Enter/Exit events */ | |
260 Control currentControl; | |
261 | |
262 /* Flush exposes */ | |
263 int /*long*/ checkIfEventProc; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
264 void*/*Callback*/ checkIfEventCallback; |
18 | 265 int /*long*/ flushWindow; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
266 bool flushAll; |
18 | 267 GdkRectangle flushRect = new GdkRectangle (); |
268 XExposeEvent exposeEvent = new XExposeEvent (); | |
269 XVisibilityEvent visibilityEvent = new XVisibilityEvent (); | |
270 int /*long*/ [] flushData = new int /*long*/ [1]; | |
271 | |
272 /* System Resources */ | |
273 Font systemFont; | |
274 Image errorImage, infoImage, questionImage, warningImage; | |
275 Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1]; | |
276 Resource [] resources; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
277 static const int RESOURCE_SIZE = 1 + 4 + SWT.CURSOR_HAND + 1; |
18 | 278 |
279 /* Colors */ | |
280 GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW; | |
281 GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER; | |
282 GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT; | |
283 GdkColor COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND; | |
284 GdkColor COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT; | |
285 GdkColor COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; | |
286 | |
287 /* Popup Menus */ | |
288 Menu [] popups; | |
289 | |
290 /* Click count*/ | |
291 int clickCount = 1; | |
292 | |
293 /* Timestamp of the Last Received Events */ | |
294 int lastEventTime, lastUserEventTime; | |
295 | |
296 /* Fixed Subclass */ | |
297 static int /*long*/ fixed_type; | |
298 static int /*long*/ fixed_info_ptr; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
299 static void*/*Callback*/ fixedClassInitCallback, fixedMapCallback; |
18 | 300 static int /*long*/ fixedClassInitProc, fixedMapProc; |
301 | |
302 /* Renderer Subclass */ | |
303 static int /*long*/ text_renderer_type, pixbuf_renderer_type, toggle_renderer_type; | |
304 static int /*long*/ text_renderer_info_ptr, pixbuf_renderer_info_ptr, toggle_renderer_info_ptr; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
305 static void*/*Callback*/ rendererClassInitCallback, rendererRenderCallback, rendererGetSizeCallback; |
18 | 306 static int /*long*/ rendererClassInitProc, rendererRenderProc, rendererGetSizeProc; |
307 | |
308 /* Key Mappings */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
309 static const int [] [] KeyTable = [ |
18 | 310 |
311 /* Keyboard and Mouse Masks */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
312 [OS.GDK_Alt_L, SWT.ALT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
313 [OS.GDK_Alt_R, SWT.ALT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
314 [OS.GDK_Meta_L, SWT.ALT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
315 [OS.GDK_Meta_R, SWT.ALT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
316 [OS.GDK_Shift_L, SWT.SHIFT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
317 [OS.GDK_Shift_R, SWT.SHIFT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
318 [OS.GDK_Control_L, SWT.CONTROL], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
319 [OS.GDK_Control_R, SWT.CONTROL], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
320 // [OS.GDK_????, SWT.COMMAND], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
321 // [OS.GDK_????, SWT.COMMAND], |
18 | 322 |
323 /* Non-Numeric Keypad Keys */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
324 [OS.GDK_Up, SWT.ARROW_UP], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
325 [OS.GDK_KP_Up, SWT.ARROW_UP], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
326 [OS.GDK_Down, SWT.ARROW_DOWN], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
327 [OS.GDK_KP_Down, SWT.ARROW_DOWN], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
328 [OS.GDK_Left, SWT.ARROW_LEFT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
329 [OS.GDK_KP_Left, SWT.ARROW_LEFT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
330 [OS.GDK_Right, SWT.ARROW_RIGHT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
331 [OS.GDK_KP_Right, SWT.ARROW_RIGHT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
332 [OS.GDK_Page_Up, SWT.PAGE_UP], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
333 [OS.GDK_KP_Page_Up, SWT.PAGE_UP], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
334 [OS.GDK_Page_Down, SWT.PAGE_DOWN], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
335 [OS.GDK_KP_Page_Down, SWT.PAGE_DOWN], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
336 [OS.GDK_Home, SWT.HOME], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
337 [OS.GDK_KP_Home, SWT.HOME], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
338 [OS.GDK_End, SWT.END], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
339 [OS.GDK_KP_End, SWT.END], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
340 [OS.GDK_Insert, SWT.INSERT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
341 [OS.GDK_KP_Insert, SWT.INSERT], |
18 | 342 |
343 /* Virtual and Ascii Keys */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
344 [OS.GDK_BackSpace, SWT.BS], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
345 [OS.GDK_Return, SWT.CR], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
346 [OS.GDK_Delete, SWT.DEL], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
347 [OS.GDK_KP_Delete, SWT.DEL], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
348 [OS.GDK_Escape, SWT.ESC], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
349 [OS.GDK_Linefeed, SWT.LF], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
350 [OS.GDK_Tab, SWT.TAB], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
351 [OS.GDK_ISO_Left_Tab, SWT.TAB], |
18 | 352 |
353 /* Functions Keys */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
354 [OS.GDK_F1, SWT.F1], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
355 [OS.GDK_F2, SWT.F2], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
356 [OS.GDK_F3, SWT.F3], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
357 [OS.GDK_F4, SWT.F4], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
358 [OS.GDK_F5, SWT.F5], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
359 [OS.GDK_F6, SWT.F6], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
360 [OS.GDK_F7, SWT.F7], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
361 [OS.GDK_F8, SWT.F8], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
362 [OS.GDK_F9, SWT.F9], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
363 [OS.GDK_F10, SWT.F10], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
364 [OS.GDK_F11, SWT.F11], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
365 [OS.GDK_F12, SWT.F12], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
366 [OS.GDK_F13, SWT.F13], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
367 [OS.GDK_F14, SWT.F14], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
368 [OS.GDK_F15, SWT.F15], |
18 | 369 |
370 /* Numeric Keypad Keys */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
371 [OS.GDK_KP_Multiply, SWT.KEYPAD_MULTIPLY], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
372 [OS.GDK_KP_Add, SWT.KEYPAD_ADD], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
373 [OS.GDK_KP_Enter, SWT.KEYPAD_CR], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
374 [OS.GDK_KP_Subtract, SWT.KEYPAD_SUBTRACT], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
375 [OS.GDK_KP_Decimal, SWT.KEYPAD_DECIMAL], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
376 [OS.GDK_KP_Divide, SWT.KEYPAD_DIVIDE], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
377 [OS.GDK_KP_0, SWT.KEYPAD_0], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
378 [OS.GDK_KP_1, SWT.KEYPAD_1], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
379 [OS.GDK_KP_2, SWT.KEYPAD_2], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
380 [OS.GDK_KP_3, SWT.KEYPAD_3], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
381 [OS.GDK_KP_4, SWT.KEYPAD_4], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
382 [OS.GDK_KP_5, SWT.KEYPAD_5], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
383 [OS.GDK_KP_6, SWT.KEYPAD_6], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
384 [OS.GDK_KP_7, SWT.KEYPAD_7], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
385 [OS.GDK_KP_8, SWT.KEYPAD_8], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
386 [OS.GDK_KP_9, SWT.KEYPAD_9], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
387 [OS.GDK_KP_Equal, SWT.KEYPAD_EQUAL], |
18 | 388 |
389 /* Other keys */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
390 [OS.GDK_Caps_Lock, SWT.CAPS_LOCK], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
391 [OS.GDK_Num_Lock, SWT.NUM_LOCK], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
392 [OS.GDK_Scroll_Lock, SWT.SCROLL_LOCK], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
393 [OS.GDK_Pause, SWT.PAUSE], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
394 [OS.GDK_Break, SWT.BREAK], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
395 [OS.GDK_Print, SWT.PRINT_SCREEN], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
396 [OS.GDK_Help, SWT.HELP], |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
397 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
398 ]; |
18 | 399 |
400 /* Multiple Displays. */ | |
401 static Display Default; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
402 static Display [] Displays; |
18 | 403 |
404 /* Package name */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
405 static const char[] PACKAGE_PREFIX = "dwt.widgets."; |
18 | 406 /* This code is intentionally commented. |
407 * ".class" can not be used on CLDC. | |
408 */ | |
409 // static { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
410 // char[] name = Display.class.getName (); |
18 | 411 // int index = name.lastIndexOf ('.'); |
412 // PACKAGE_NAME = name.substring (0, index + 1); | |
413 // } | |
414 | |
415 /* | |
416 * In order to support CLDC, .class cannot be used because | |
417 * it does not compile on some Java compilers when they are | |
418 * targeted for CLDC. Use Class.forName() instead. | |
419 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
420 static const Class OS_LOCK; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
421 static this(){ |
18 | 422 Class lock = null; |
423 try { | |
424 lock = Class.forName ("dwt.internal.gtk.OS"); | |
425 } catch (Throwable th) { | |
426 } | |
427 OS_LOCK = lock; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
428 Displays = new Display [4]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
429 initDeviceFinder(); |
18 | 430 } |
431 | |
432 /* GTK Version */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
433 static const int MAJOR = 2; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
434 static const int MINOR = 0; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
435 static const int MICRO = 6; |
18 | 436 |
437 /* Display Data */ | |
438 Object data; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
439 char[] [] keys; |
18 | 440 Object [] values; |
441 | |
442 /* Initial Guesses for Shell Trimmings. */ | |
443 int borderTrimWidth = 4, borderTrimHeight = 4; | |
444 int resizeTrimWidth = 6, resizeTrimHeight = 6; | |
445 int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28; | |
446 int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29; | |
447 int titleTrimWidth = 0, titleTrimHeight = 23; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
448 bool ignoreTrim; |
18 | 449 |
450 /* Window Manager */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
451 char[] windowManager; |
18 | 452 |
453 /* | |
454 * TEMPORARY CODE. Install the runnable that | |
455 * gets the current display. This code will | |
456 * be removed in the future. | |
457 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
458 private static void initDeviceFinder(){ |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
459 DeviceFinder = new class() Runnable { |
18 | 460 public void run () { |
461 Device device = getCurrent (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
462 if (device is null) { |
18 | 463 device = getDefault (); |
464 } | |
465 setDevice (device); | |
466 } | |
467 }; | |
468 } | |
469 | |
470 /* | |
471 * TEMPORARY CODE. | |
472 */ | |
473 static void setDevice (Device device) { | |
474 CurrentDevice = device; | |
475 } | |
476 | |
477 /** | |
478 * Constructs a new instance of this class. | |
479 * <p> | |
480 * Note: The resulting display is marked as the <em>current</em> | |
481 * display. If this is the first display which has been | |
482 * constructed since the application started, it is also | |
483 * marked as the <em>default</em> display. | |
484 * </p> | |
485 * | |
486 * @exception SWTException <ul> | |
487 * <li>ERROR_THREAD_INVALID_ACCESS - if called from a thread that already created an existing display</li> | |
488 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | |
489 * </ul> | |
490 * | |
491 * @see #getCurrent | |
492 * @see #getDefault | |
493 * @see Widget#checkSubclass | |
494 * @see Shell | |
495 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
496 public this () { |
18 | 497 this (null); |
498 } | |
499 | |
500 /** | |
501 * Constructs a new instance of this class using the parameter. | |
502 * | |
503 * @param data the device data | |
504 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
505 public this (DeviceData data) { |
18 | 506 super (data); |
507 } | |
508 | |
509 /** | |
510 * Adds the listener to the collection of listeners who will | |
511 * be notified when an event of the given type occurs anywhere | |
512 * in a widget. The event type is one of the event constants | |
513 * defined in class <code>SWT</code>. When the event does occur, | |
514 * the listener is notified by sending it the <code>handleEvent()</code> | |
515 * message. | |
516 * <p> | |
517 * Setting the type of an event to <code>SWT.None</code> from | |
518 * within the <code>handleEvent()</code> method can be used to | |
519 * change the event type and stop subsequent Java listeners | |
520 * from running. Because event filters run before other listeners, | |
521 * event filters can both block other listeners and set arbitrary | |
522 * fields within an event. For this reason, event filters are both | |
523 * powerful and dangerous. They should generally be avoided for | |
524 * performance, debugging and code maintenance reasons. | |
525 * </p> | |
526 * | |
527 * @param eventType the type of event to listen for | |
528 * @param listener the listener which should be notified when the event occurs | |
529 * | |
530 * @exception IllegalArgumentException <ul> | |
531 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
532 * </ul> | |
533 * @exception SWTException <ul> | |
534 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
535 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
536 * </ul> | |
537 * | |
538 * @see Listener | |
539 * @see SWT | |
540 * @see #removeFilter | |
541 * @see #removeListener | |
542 * | |
543 * @since 3.0 | |
544 */ | |
545 public void addFilter (int eventType, Listener listener) { | |
546 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
547 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
548 if (filterTable is null) filterTable = new EventTable (); |
18 | 549 filterTable.hook (eventType, listener); |
550 } | |
551 | |
552 void addGdkEvent (int /*long*/ event) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
553 if (gdkEvents is null) { |
18 | 554 int length = GROW_SIZE; |
555 gdkEvents = new int /*long*/ [length]; | |
556 gdkEventWidgets = new Widget [length]; | |
557 gdkEventCount = 0; | |
558 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
559 if (gdkEventCount is gdkEvents.length) { |
18 | 560 int length = gdkEventCount + GROW_SIZE; |
561 int /*long*/ [] newEvents = new int /*long*/ [length]; | |
562 System.arraycopy (gdkEvents, 0, newEvents, 0, gdkEventCount); | |
563 gdkEvents = newEvents; | |
564 Widget [] newWidgets = new Widget [length]; | |
565 System.arraycopy (gdkEventWidgets, 0, newWidgets, 0, gdkEventCount); | |
566 gdkEventWidgets = newWidgets; | |
567 } | |
568 Widget widget = null; | |
569 int /*long*/ handle = OS.gtk_get_event_widget (event); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
570 if (handle !is null) { |
18 | 571 do { |
572 widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
573 } while (widget is null && (handle = OS.gtk_widget_get_parent (handle)) !is null); |
18 | 574 } |
575 gdkEvents [gdkEventCount] = event; | |
576 gdkEventWidgets [gdkEventCount] = widget; | |
577 gdkEventCount++; | |
578 } | |
579 | |
580 void addIdleProc() { | |
581 synchronized (idleLock){ | |
582 this.idleNeeded = true; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
583 if (idleHandle is null) { |
18 | 584 idleHandle = OS.g_idle_add (idleProc, 0); |
585 } | |
586 } | |
587 } | |
588 | |
589 /** | |
590 * Adds the listener to the collection of listeners who will | |
591 * be notified when an event of the given type occurs. The event | |
592 * type is one of the event constants defined in class <code>SWT</code>. | |
593 * When the event does occur in the display, the listener is notified by | |
594 * sending it the <code>handleEvent()</code> message. | |
595 * | |
596 * @param eventType the type of event to listen for | |
597 * @param listener the listener which should be notified when the event occurs | |
598 * | |
599 * @exception IllegalArgumentException <ul> | |
600 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
601 * </ul> | |
602 * @exception SWTException <ul> | |
603 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
604 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
605 * </ul> | |
606 * | |
607 * @see Listener | |
608 * @see SWT | |
609 * @see #removeListener | |
610 * | |
611 * @since 2.0 | |
612 */ | |
613 public void addListener (int eventType, Listener listener) { | |
614 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
615 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
616 if (eventTable is null) eventTable = new EventTable (); |
18 | 617 eventTable.hook (eventType, listener); |
618 } | |
619 | |
620 int /*long*/ allChildrenProc (int /*long*/ widget, int /*long*/ recurse) { | |
621 allChildren = OS.g_list_append (allChildren, widget); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
622 if (recurse !is null && OS.GTK_IS_CONTAINER (widget)) { |
18 | 623 OS.gtk_container_forall (widget, allChildrenProc, recurse); |
624 } | |
625 return 0; | |
626 } | |
627 | |
628 void addMouseHoverTimeout (int /*long*/ handle) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
629 if (mouseHoverId !is null) OS.gtk_timeout_remove (mouseHoverId); |
18 | 630 mouseHoverId = OS.gtk_timeout_add (400, mouseHoverProc, handle); |
631 mouseHoverHandle = handle; | |
632 } | |
633 | |
634 void addPopup (Menu menu) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
635 if (popups is null) popups = new Menu [4]; |
18 | 636 int length = popups.length; |
637 for (int i=0; i<length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
638 if (popups [i] is menu) return; |
18 | 639 } |
640 int index = 0; | |
641 while (index < length) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
642 if (popups [index] is null) break; |
18 | 643 index++; |
644 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
645 if (index is length) { |
18 | 646 Menu [] newPopups = new Menu [length + 4]; |
647 System.arraycopy (popups, 0, newPopups, 0, length); | |
648 popups = newPopups; | |
649 } | |
650 popups [index] = menu; | |
651 } | |
652 | |
653 void addWidget (int /*long*/ handle, Widget widget) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
654 if (handle is null) return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
655 if (freeSlot is -1) { |
18 | 656 int length = (freeSlot = indexTable.length) + GROW_SIZE; |
657 int[] newIndexTable = new int[length]; | |
658 Widget[] newWidgetTable = new Widget [length]; | |
659 System.arraycopy (indexTable, 0, newIndexTable, 0, freeSlot); | |
660 System.arraycopy (widgetTable, 0, newWidgetTable, 0, freeSlot); | |
661 for (int i = freeSlot; i < length - 1; i++) { | |
662 newIndexTable[i] = i + 1; | |
663 } | |
664 newIndexTable[length - 1] = -1; | |
665 indexTable = newIndexTable; | |
666 widgetTable = newWidgetTable; | |
667 } | |
668 int index = freeSlot + 1; | |
669 OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, index); | |
670 int oldSlot = freeSlot; | |
671 freeSlot = indexTable[oldSlot]; | |
672 indexTable [oldSlot] = -2; | |
673 widgetTable [oldSlot] = widget; | |
674 } | |
675 | |
676 /** | |
677 * Causes the <code>run()</code> method of the runnable to | |
678 * be invoked by the user-interface thread at the next | |
679 * reasonable opportunity. The caller of this method continues | |
680 * to run in parallel, and is not notified when the | |
681 * runnable has completed. Specifying <code>null</code> as the | |
682 * runnable simply wakes the user-interface thread when run. | |
683 * <p> | |
684 * Note that at the time the runnable is invoked, widgets | |
685 * that have the receiver as their display may have been | |
686 * disposed. Therefore, it is necessary to check for this | |
687 * case inside the runnable before accessing the widget. | |
688 * </p> | |
689 * | |
690 * @param runnable code to run on the user-interface thread or <code>null</code> | |
691 * | |
692 * @exception SWTException <ul> | |
693 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
694 * </ul> | |
695 * | |
696 * @see #syncExec | |
697 */ | |
698 public void asyncExec (Runnable runnable) { | |
699 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); | |
700 synchronized (idleLock) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
701 if (idleNeeded && idleHandle is null) { |
18 | 702 //NOTE: calling unlocked function in OS |
703 idleHandle = OS._g_idle_add (idleProc, 0); | |
704 } | |
705 } | |
706 synchronizer.asyncExec (runnable); | |
707 } | |
708 | |
709 /** | |
710 * Causes the system hardware to emit a short sound | |
711 * (if it supports this capability). | |
712 * | |
713 * @exception SWTException <ul> | |
714 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
715 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
716 * </ul> | |
717 */ | |
718 public void beep () { | |
719 if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); | |
720 OS.gdk_beep(); | |
721 if (!OS.GDK_WINDOWING_X11 ()) { | |
722 OS.gdk_flush (); | |
723 } else { | |
724 int /*long*/ xDisplay = OS.GDK_DISPLAY (); | |
725 OS.XFlush (xDisplay); | |
726 } | |
727 } | |
728 | |
729 int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*long*/ tree_model, int /*long*/ iter, int /*long*/ data) { | |
730 Widget widget = getWidget (data); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
731 if (widget is null) return 0; |
18 | 732 return widget.cellDataProc (tree_column, cell, tree_model, iter, data); |
733 } | |
734 | |
735 protected void checkDevice () { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
736 if (thread is null) error (SWT.ERROR_WIDGET_DISPOSED); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
737 if (thread !is Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); |
18 | 738 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); |
739 } | |
740 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
741 static synchronized void checkDisplay (Thread thread, bool multiple) { |
18 | 742 for (int i=0; i<Displays.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
743 if (Displays [i] !is null) { |
18 | 744 if (!multiple) SWT.error (SWT.ERROR_NOT_IMPLEMENTED, null, " [multiple displays]"); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
745 if (Displays [i].thread is thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); |
18 | 746 } |
747 } | |
748 } | |
749 | |
750 int /*long*/ checkIfEventProc (int /*long*/ display, int /*long*/ xEvent, int /*long*/ userData) { | |
751 int type = OS.X_EVENT_TYPE (xEvent); | |
752 switch (type) { | |
753 case OS.VisibilityNotify: | |
754 case OS.Expose: | |
755 case OS.GraphicsExpose: | |
756 break; | |
757 default: | |
758 return 0; | |
759 } | |
760 int /*long*/ window = OS.gdk_window_lookup (OS.X_EVENT_WINDOW (xEvent)); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
761 if (window is null) return 0; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
762 if (flushWindow !is null) { |
18 | 763 if (flushAll) { |
764 int /*long*/ tempWindow = window; | |
765 do { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
766 if (tempWindow is flushWindow) break; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
767 } while ((tempWindow = OS.gdk_window_get_parent (tempWindow)) !is null); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
768 if (tempWindow !is flushWindow) return 0; |
18 | 769 } else { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
770 if (window !is flushWindow) return 0; |
18 | 771 } |
772 } | |
773 OS.memmove (exposeEvent, xEvent, XExposeEvent.sizeof); | |
774 switch (type) { | |
775 case OS.Expose: | |
776 case OS.GraphicsExpose: { | |
777 flushRect.x = exposeEvent.x; | |
778 flushRect.y = exposeEvent.y; | |
779 flushRect.width = exposeEvent.width; | |
780 flushRect.height = exposeEvent.height; | |
781 OS.gdk_window_invalidate_rect (window, flushRect, true); | |
782 exposeEvent.type = -1; | |
783 OS.memmove (xEvent, exposeEvent, XExposeEvent.sizeof); | |
784 break; | |
785 } | |
786 case OS.VisibilityNotify: { | |
787 OS.memmove (visibilityEvent, xEvent, XVisibilityEvent.sizeof); | |
788 OS.gdk_window_get_user_data (window, flushData); | |
789 int /*long*/ handle = flushData [0]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
790 Widget widget = handle !is null ? getWidget (handle) : null; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
791 if (widget !is null && (null !is cast(Control)widget)) { |
18 | 792 Control control = (Control) widget; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
793 if (window is control.paintWindow ()) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
794 if (visibilityEvent.state is OS.VisibilityFullyObscured) { |
18 | 795 control.state |= Widget.OBSCURED; |
796 } else { | |
797 control.state &= ~Widget.OBSCURED; | |
798 } | |
799 } | |
800 } | |
801 break; | |
802 } | |
803 } | |
804 return 0; | |
805 } | |
806 | |
807 /** | |
808 * Checks that this class can be subclassed. | |
809 * <p> | |
810 * IMPORTANT: See the comment in <code>Widget.checkSubclass()</code>. | |
811 * </p> | |
812 * | |
813 * @exception SWTException <ul> | |
814 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li> | |
815 * </ul> | |
816 * | |
817 * @see Widget#checkSubclass | |
818 */ | |
819 protected void checkSubclass () { | |
820 if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS); | |
821 } | |
822 | |
823 /** | |
824 * Requests that the connection between SWT and the underlying | |
825 * operating system be closed. | |
826 * | |
827 * @exception SWTException <ul> | |
828 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
829 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
830 * </ul> | |
831 * | |
832 * @see Device#dispose | |
833 * | |
834 * @since 2.0 | |
835 */ | |
836 public void close () { | |
837 checkDevice (); | |
838 Event event = new Event (); | |
839 sendEvent (SWT.Close, event); | |
840 if (event.doit) dispose (); | |
841 } | |
842 | |
843 /** | |
844 * Creates the device in the operating system. If the device | |
845 * does not have a handle, this method may do nothing depending | |
846 * on the device. | |
847 * <p> | |
848 * This method is called before <code>init</code>. | |
849 * </p> | |
850 * | |
851 * @param data the DeviceData which describes the receiver | |
852 * | |
853 * @see #init | |
854 */ | |
855 protected void create (DeviceData data) { | |
856 checkSubclass (); | |
857 checkDisplay(thread = Thread.currentThread (), false); | |
858 createDisplay (data); | |
859 register (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
860 if (Default is null) Default = this; |
18 | 861 } |
862 | |
863 synchronized void createDisplay (DeviceData data) { | |
864 /* Required for g_main_context_wakeup */ | |
865 if (!OS.g_thread_supported ()) { | |
866 OS.g_thread_init (0); | |
867 } | |
868 OS.gtk_set_locale(); | |
869 if (!OS.gtk_init_check (new int /*long*/ [] {0}, null)) { | |
870 SWT.error (SWT.ERROR_NO_HANDLES, null, " [gtk_init_check() failed]"); | |
871 } | |
872 if (OS.GDK_WINDOWING_X11 ()) xDisplay = OS.GDK_DISPLAY (); | |
873 int /*long*/ ptr = OS.gtk_check_version (MAJOR, MINOR, MICRO); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
874 if (ptr !is null) { |
18 | 875 int length = OS.strlen (ptr); |
876 byte [] buffer = new byte [length]; | |
877 OS.memmove (buffer, ptr, length); | |
878 System.out.println ("***WARNING: " + new String (Converter.mbcsToWcs (null, buffer))); | |
879 System.out.println ("***WARNING: SWT requires GTK " + MAJOR+ "." + MINOR + "." + MICRO); | |
880 int major = OS.gtk_major_version (), minor = OS.gtk_minor_version (), micro = OS.gtk_micro_version (); | |
881 System.out.println ("***WARNING: Detected: " + major + "." + minor + "." + micro); | |
882 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
883 if (fixed_type is null) { |
18 | 884 byte [] type_name = Converter.wcsToMbcs (null, "SwtFixed", true); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
885 fixedClassInitCallback = new void*/*Callback*/ (getClass (), "fixedClassInitProc", 2); |
18 | 886 fixedClassInitProc = fixedClassInitCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
887 if (fixedClassInitProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
888 fixedMapCallback = new void*/*Callback*/ (getClass (), "fixedMapProc", 1); |
18 | 889 fixedMapProc = fixedMapCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
890 if (fixedMapProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 891 GTypeInfo fixed_info = new GTypeInfo (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
892 fixed_info.class_size = cast(short) OS.GtkFixedClass_sizeof (); |
18 | 893 fixed_info.class_init = fixedClassInitProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
894 fixed_info.instance_size = cast(short) OS.GtkFixed_sizeof (); |
18 | 895 fixed_info_ptr = OS.g_malloc (GTypeInfo.sizeof); |
896 OS.memmove (fixed_info_ptr, fixed_info, GTypeInfo.sizeof); | |
897 fixed_type = OS.g_type_register_static (OS.GTK_TYPE_FIXED (), type_name, fixed_info_ptr, 0); | |
898 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
899 if (rendererClassInitProc is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
900 rendererClassInitCallback = new void*/*Callback*/ (getClass (), "rendererClassInitProc", 2); |
18 | 901 rendererClassInitProc = rendererClassInitCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
902 if (rendererClassInitProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 903 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
904 if (rendererRenderProc is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
905 rendererRenderCallback = new void*/*Callback*/ (getClass (), "rendererRenderProc", 7); |
18 | 906 rendererRenderProc = rendererRenderCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
907 if (rendererRenderProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 908 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
909 if (rendererGetSizeProc is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
910 rendererGetSizeCallback = new void*/*Callback*/ (getClass (), "rendererGetSizeProc", 7); |
18 | 911 rendererGetSizeProc = rendererGetSizeCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
912 if (rendererGetSizeProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 913 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
914 if (text_renderer_type is null) { |
18 | 915 GTypeInfo renderer_info = new GTypeInfo (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
916 renderer_info.class_size = cast(short) OS.GtkCellRendererTextClass_sizeof (); |
18 | 917 renderer_info.class_init = rendererClassInitProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
918 renderer_info.instance_size = cast(short) OS.GtkCellRendererText_sizeof (); |
18 | 919 text_renderer_info_ptr = OS.g_malloc (GTypeInfo.sizeof); |
920 OS.memmove (text_renderer_info_ptr, renderer_info, GTypeInfo.sizeof); | |
921 byte [] type_name = Converter.wcsToMbcs (null, "SwtTextRenderer", true); | |
922 text_renderer_type = OS.g_type_register_static (OS.GTK_TYPE_CELL_RENDERER_TEXT (), type_name, text_renderer_info_ptr, 0); | |
923 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
924 if (pixbuf_renderer_type is null) { |
18 | 925 GTypeInfo renderer_info = new GTypeInfo (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
926 renderer_info.class_size = cast(short) OS.GtkCellRendererPixbufClass_sizeof (); |
18 | 927 renderer_info.class_init = rendererClassInitProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
928 renderer_info.instance_size = cast(short) OS.GtkCellRendererPixbuf_sizeof (); |
18 | 929 pixbuf_renderer_info_ptr = OS.g_malloc (GTypeInfo.sizeof); |
930 OS.memmove (pixbuf_renderer_info_ptr, renderer_info, GTypeInfo.sizeof); | |
931 byte [] type_name = Converter.wcsToMbcs (null, "SwtPixbufRenderer", true); | |
932 pixbuf_renderer_type = OS.g_type_register_static (OS.GTK_TYPE_CELL_RENDERER_PIXBUF (), type_name, pixbuf_renderer_info_ptr, 0); | |
933 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
934 if (toggle_renderer_type is null) { |
18 | 935 GTypeInfo renderer_info = new GTypeInfo (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
936 renderer_info.class_size = cast(short) OS.GtkCellRendererToggleClass_sizeof (); |
18 | 937 renderer_info.class_init = rendererClassInitProc; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
938 renderer_info.instance_size = cast(short) OS.GtkCellRendererToggle_sizeof (); |
18 | 939 toggle_renderer_info_ptr = OS.g_malloc (GTypeInfo.sizeof); |
940 OS.memmove (toggle_renderer_info_ptr, renderer_info, GTypeInfo.sizeof); | |
941 byte [] type_name = Converter.wcsToMbcs (null, "SwtToggleRenderer", true); | |
942 toggle_renderer_type = OS.g_type_register_static (OS.GTK_TYPE_CELL_RENDERER_TOGGLE (), type_name, toggle_renderer_info_ptr, 0); | |
943 } | |
944 | |
945 OS.gtk_widget_set_default_direction (OS.GTK_TEXT_DIR_LTR); | |
946 OS.gdk_rgb_init (); | |
947 byte [] buffer = Converter.wcsToMbcs (null, APP_NAME, true); | |
948 OS.g_set_prgname (buffer); | |
949 OS.gdk_set_program_class (buffer); | |
950 byte [] flatStyle = Converter.wcsToMbcs (null, "style \"swt-flat\" { GtkToolbar::shadow-type = none } widget \"*.swt-toolbar-flat\" style : highest \"swt-flat\"", true); | |
951 OS.gtk_rc_parse_string (flatStyle); | |
952 | |
953 /* Initialize the hidden shell */ | |
954 shellHandle = OS.gtk_window_new (OS.GTK_WINDOW_TOPLEVEL); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
955 if (shellHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); |
18 | 956 OS.gtk_widget_realize (shellHandle); |
957 | |
958 /* Initialize the filter and event callback */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
959 eventCallback = new void*/*Callback*/ (this, "eventProc", 2); |
18 | 960 eventProc = eventCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
961 if (eventProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 962 OS.gdk_event_handler_set (eventProc, 0, 0); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
963 filterCallback = new void*/*Callback*/ (this, "filterProc", 3); |
18 | 964 filterProc = filterCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
965 if (filterProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 966 OS.gdk_window_add_filter (0, filterProc, 0); |
967 } | |
968 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
969 Image createImage (char[] name) { |
18 | 970 int /*long*/ style = OS.gtk_widget_get_default_style (); |
971 byte[] buffer = Converter.wcsToMbcs (null, name, true); | |
972 int /*long*/ pixbuf = OS.gtk_icon_set_render_icon ( | |
973 OS.gtk_icon_factory_lookup_default (buffer), style, | |
974 OS.GTK_TEXT_DIR_NONE, OS.GTK_STATE_NORMAL, OS.GTK_ICON_SIZE_DIALOG, 0, 0); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
975 if (pixbuf is null) return null; |
18 | 976 int width = OS.gdk_pixbuf_get_width (pixbuf); |
977 int height = OS.gdk_pixbuf_get_height (pixbuf); | |
978 int stride = OS.gdk_pixbuf_get_rowstride (pixbuf); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
979 bool hasAlpha = OS.gdk_pixbuf_get_has_alpha (pixbuf); |
18 | 980 int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf); |
981 byte [] data = new byte [stride * height]; | |
982 OS.memmove (data, pixels, data.length); | |
983 OS.g_object_unref (pixbuf); | |
984 ImageData imageData = null; | |
985 if (hasAlpha) { | |
986 PaletteData palette = new PaletteData (0xFF000000, 0xFF0000, 0xFF00); | |
987 imageData = new ImageData (width, height, 32, palette); | |
988 byte [] alpha = new byte [stride * height]; | |
989 for (int y=0; y<height; y++) { | |
990 for (int x=0; x<width; x++) { | |
991 alpha [y*width+x] = data [y*stride+x*4+3]; | |
992 data [y*stride+x*4+3] = 0; | |
993 } | |
994 } | |
995 imageData.setAlphas (0, 0, width * height, alpha, 0); | |
996 } else { | |
997 PaletteData palette = new PaletteData (0xFF0000, 0xFF00, 0xFF); | |
998 imageData = new ImageData (width, height, 24, palette); | |
999 } | |
1000 imageData.data = data; | |
1001 imageData.bytesPerLine = stride; | |
1002 return new Image (this, imageData); | |
1003 } | |
1004 | |
1005 static int /*long*/ createPixbuf(Image image) { | |
1006 int [] w = new int [1], h = new int [1]; | |
1007 OS.gdk_drawable_get_size (image.pixmap, w, h); | |
1008 int /*long*/ colormap = OS.gdk_colormap_get_system (); | |
1009 int /*long*/ pixbuf; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1010 bool hasMask = image.mask !is null && OS.gdk_drawable_get_depth (image.mask) is 1; |
18 | 1011 if (hasMask) { |
1012 pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, true, 8, w [0], h [0]); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1013 if (pixbuf is null) SWT.error (SWT.ERROR_NO_HANDLES); |
18 | 1014 OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); |
1015 int /*long*/ maskPixbuf = OS.gdk_pixbuf_new(OS.GDK_COLORSPACE_RGB, false, 8, w [0], h [0]); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1016 if (maskPixbuf is null) SWT.error (SWT.ERROR_NO_HANDLES); |
18 | 1017 OS.gdk_pixbuf_get_from_drawable(maskPixbuf, image.mask, 0, 0, 0, 0, 0, w [0], h [0]); |
1018 int stride = OS.gdk_pixbuf_get_rowstride(pixbuf); | |
1019 int /*long*/ pixels = OS.gdk_pixbuf_get_pixels(pixbuf); | |
1020 byte[] line = new byte[stride]; | |
1021 int maskStride = OS.gdk_pixbuf_get_rowstride(maskPixbuf); | |
1022 int /*long*/ maskPixels = OS.gdk_pixbuf_get_pixels(maskPixbuf); | |
1023 byte[] maskLine = new byte[maskStride]; | |
1024 for (int y=0; y<h[0]; y++) { | |
1025 int /*long*/ offset = pixels + (y * stride); | |
1026 OS.memmove(line, offset, stride); | |
1027 int /*long*/ maskOffset = maskPixels + (y * maskStride); | |
1028 OS.memmove(maskLine, maskOffset, maskStride); | |
1029 for (int x=0; x<w[0]; x++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1030 if (maskLine[x * 3] is 0) { |
18 | 1031 line[x * 4 + 3] = 0; |
1032 } | |
1033 } | |
1034 OS.memmove(offset, line, stride); | |
1035 } | |
1036 OS.g_object_unref(maskPixbuf); | |
1037 } else { | |
1038 ImageData data = image.getImageData (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1039 bool hasAlpha = data.getTransparencyType () is SWT.TRANSPARENCY_ALPHA; |
18 | 1040 pixbuf = OS.gdk_pixbuf_new (OS.GDK_COLORSPACE_RGB, hasAlpha, 8, w [0], h [0]); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1041 if (pixbuf is null) SWT.error (SWT.ERROR_NO_HANDLES); |
18 | 1042 OS.gdk_pixbuf_get_from_drawable (pixbuf, image.pixmap, colormap, 0, 0, 0, 0, w [0], h [0]); |
1043 if (hasAlpha) { | |
1044 byte [] alpha = data.alphaData; | |
1045 int stride = OS.gdk_pixbuf_get_rowstride (pixbuf); | |
1046 int /*long*/ pixels = OS.gdk_pixbuf_get_pixels (pixbuf); | |
1047 byte [] line = new byte [stride]; | |
1048 for (int y = 0; y < h [0]; y++) { | |
1049 int /*long*/ offset = pixels + (y * stride); | |
1050 OS.memmove (line, offset, stride); | |
1051 for (int x = 0; x < w [0]; x++) { | |
1052 line [x*4+3] = alpha [y*w [0]+x]; | |
1053 } | |
1054 OS.memmove (offset, line, stride); | |
1055 } | |
1056 } | |
1057 } | |
1058 return pixbuf; | |
1059 } | |
1060 | |
1061 synchronized void deregister () { | |
1062 for (int i=0; i<Displays.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1063 if (this is Displays [i]) Displays [i] = null; |
18 | 1064 } |
1065 } | |
1066 | |
1067 /** | |
1068 * Destroys the device in the operating system and releases | |
1069 * the device's handle. If the device does not have a handle, | |
1070 * this method may do nothing depending on the device. | |
1071 * <p> | |
1072 * This method is called after <code>release</code>. | |
1073 * </p> | |
1074 * @see Device#dispose | |
1075 * @see #release | |
1076 */ | |
1077 protected void destroy () { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1078 if (this is Default) Default = null; |
18 | 1079 deregister (); |
1080 destroyDisplay (); | |
1081 } | |
1082 | |
1083 void destroyDisplay () { | |
1084 } | |
1085 | |
1086 /** | |
1087 * Returns the display which the given thread is the | |
1088 * user-interface thread for, or null if the given thread | |
1089 * is not a user-interface thread for any display. Specifying | |
1090 * <code>null</code> as the thread will return <code>null</code> | |
1091 * for the display. | |
1092 * | |
1093 * @param thread the user-interface thread | |
1094 * @return the display for the given thread | |
1095 */ | |
1096 public static synchronized Display findDisplay (Thread thread) { | |
1097 for (int i=0; i<Displays.length; i++) { | |
1098 Display display = Displays [i]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1099 if (display !is null && display.thread is thread) { |
18 | 1100 return display; |
1101 } | |
1102 } | |
1103 return null; | |
1104 } | |
1105 | |
1106 /** | |
1107 * Causes the <code>run()</code> method of the runnable to | |
1108 * be invoked by the user-interface thread just before the | |
1109 * receiver is disposed. Specifying a <code>null</code> runnable | |
1110 * is ignored. | |
1111 * | |
1112 * @param runnable code to run at dispose time. | |
1113 * | |
1114 * @exception SWTException <ul> | |
1115 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1116 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1117 * </ul> | |
1118 */ | |
1119 public void disposeExec (Runnable runnable) { | |
1120 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1121 if (disposeList is null) disposeList = new Runnable [4]; |
18 | 1122 for (int i=0; i<disposeList.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1123 if (disposeList [i] is null) { |
18 | 1124 disposeList [i] = runnable; |
1125 return; | |
1126 } | |
1127 } | |
1128 Runnable [] newDisposeList = new Runnable [disposeList.length + 4]; | |
1129 System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length); | |
1130 newDisposeList [disposeList.length] = runnable; | |
1131 disposeList = newDisposeList; | |
1132 } | |
1133 | |
1134 /** | |
1135 * Does whatever display specific cleanup is required, and then | |
1136 * uses the code in <code>SWTError.error</code> to handle the error. | |
1137 * | |
1138 * @param code the descriptive error code | |
1139 * | |
1140 * @see SWTError#error | |
1141 */ | |
1142 void error (int code) { | |
1143 SWT.error (code); | |
1144 } | |
1145 | |
1146 int /*long*/ eventProc (int /*long*/ event, int /*long*/ data) { | |
1147 /* | |
1148 * Use gdk_event_get_time() rather than event.time or | |
1149 * gtk_get_current_event_time(). If the event does not | |
1150 * have a time stamp, then the field will contain garbage. | |
1151 * Note that calling gtk_get_current_event_time() from | |
1152 * outside of gtk_main_do_event() seems to always | |
1153 * return zero. | |
1154 */ | |
1155 int time = OS.gdk_event_get_time (event); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1156 if (time !is 0) lastEventTime = time; |
18 | 1157 |
1158 int eventType = OS.GDK_EVENT_TYPE (event); | |
1159 switch (eventType) { | |
1160 case OS.GDK_BUTTON_PRESS: | |
1161 case OS.GDK_KEY_PRESS: | |
1162 lastUserEventTime = time; | |
1163 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1164 bool dispatch = true; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1165 if (dispatchEvents !is null) { |
18 | 1166 dispatch = false; |
1167 for (int i = 0; i < dispatchEvents.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1168 if (eventType is dispatchEvents [i]) { |
18 | 1169 dispatch = true; |
1170 break; | |
1171 } | |
1172 } | |
1173 } | |
1174 if (!dispatch) { | |
1175 addGdkEvent (OS.gdk_event_copy (event)); | |
1176 return 0; | |
1177 } | |
1178 /* | |
1179 * Feature in GTK. GTK implements modality by adding a grab | |
1180 * to the GTK top level window. Normally, all mouse and | |
1181 * keyboard events are delivered to child widgets and the | |
1182 * shell when the grab is active. When an override redirect | |
1183 * shell is created as a child of a dialog, then events are | |
1184 * grabbed by the dialog instead of the override redirect | |
1185 * shell. The fix is to add a temporary grab to the override | |
1186 * redirect window when there is not already a grab in a | |
1187 * child widget of the override redirect shell (for example, | |
1188 * in a scroll bar). | |
1189 */ | |
1190 Shell shell = null; | |
1191 Control control = null; | |
1192 int /*long*/ grabHandle = OS.gtk_grab_get_current (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1193 if (grabHandle !is null && OS.GTK_IS_WINDOW (grabHandle) && OS.gtk_window_get_modal (grabHandle)) { |
18 | 1194 switch (eventType) { |
1195 case OS.GDK_KEY_PRESS: | |
1196 case OS.GDK_KEY_RELEASE: | |
1197 case OS.GDK_ENTER_NOTIFY: | |
1198 case OS.GDK_LEAVE_NOTIFY: | |
1199 case OS.GDK_BUTTON_PRESS: | |
1200 case OS.GDK_2BUTTON_PRESS: | |
1201 case OS.GDK_3BUTTON_PRESS: | |
1202 case OS.GDK_BUTTON_RELEASE: | |
1203 case OS.GDK_MOTION_NOTIFY: { | |
1204 int /*long*/ window = OS.GDK_EVENT_WINDOW (event); | |
1205 int /*long*/ [] user_data = new int /*long*/ [1]; | |
1206 do { | |
1207 OS.gdk_window_get_user_data (window, user_data); | |
1208 int /*long*/ handle = user_data [0]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1209 if (handle !is null) { |
18 | 1210 Widget widget = getWidget (handle); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1211 if (widget !is null && (null !is cast(Control)widget)) { |
18 | 1212 control = (Control) widget; |
1213 break; | |
1214 } | |
1215 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1216 } while ((window = OS.gdk_window_get_parent (window)) !is null); |
18 | 1217 } |
1218 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1219 if (control !is null) { |
18 | 1220 shell = control.getShell (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1221 if ((shell.style & SWT.ON_TOP) !is 0) { |
18 | 1222 OS.gtk_grab_add (shell.shellHandle); |
1223 } | |
1224 } | |
1225 } | |
1226 OS.gtk_main_do_event (event); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1227 if (dispatchEvents is null) putGdkEvents (); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1228 if (control !is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1229 if (shell !is null && !shell.isDisposed () && (shell.style & SWT.ON_TOP) !is 0) { |
18 | 1230 OS.gtk_grab_remove (shell.shellHandle); |
1231 } | |
1232 } | |
1233 return 0; | |
1234 } | |
1235 | |
1236 /** | |
1237 * Given the operating system handle for a widget, returns | |
1238 * the instance of the <code>Widget</code> subclass which | |
1239 * represents it in the currently running application, if | |
1240 * such exists, or null if no matching widget can be found. | |
1241 * <p> | |
1242 * <b>IMPORTANT:</b> This method should not be called from | |
1243 * application code. The arguments are platform-specific. | |
1244 * </p> | |
1245 * | |
1246 * @param handle the handle for the widget | |
1247 * @return the SWT widget that the handle represents | |
1248 * | |
1249 * @exception SWTException <ul> | |
1250 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1251 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1252 * </ul> | |
1253 */ | |
1254 public Widget findWidget (int /*long*/ handle) { | |
1255 checkDevice (); | |
1256 return getWidget (handle); | |
1257 } | |
1258 | |
1259 /** | |
1260 * Given the operating system handle for a widget, | |
1261 * and widget-specific id, returns the instance of | |
1262 * the <code>Widget</code> subclass which represents | |
1263 * the handle/id pair in the currently running application, | |
1264 * if such exists, or null if no matching widget can be found. | |
1265 * <p> | |
1266 * <b>IMPORTANT:</b> This method should not be called from | |
1267 * application code. The arguments are platform-specific. | |
1268 * </p> | |
1269 * | |
1270 * @param handle the handle for the widget | |
1271 * @param id the id for the subwidget (usually an item) | |
1272 * @return the SWT widget that the handle/id pair represents | |
1273 * | |
1274 * @exception SWTException <ul> | |
1275 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1276 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1277 * </ul> | |
1278 * | |
1279 * @since 3.1 | |
1280 */ | |
1281 public Widget findWidget (int /*long*/ handle, int id) { | |
1282 checkDevice (); | |
1283 return null; | |
1284 } | |
1285 | |
1286 /** | |
1287 * Given a widget and a widget-specific id, returns the | |
1288 * instance of the <code>Widget</code> subclass which represents | |
1289 * the widget/id pair in the currently running application, | |
1290 * if such exists, or null if no matching widget can be found. | |
1291 * | |
1292 * @param widget the widget | |
1293 * @param id the id for the subwidget (usually an item) | |
1294 * @return the SWT subwidget (usually an item) that the widget/id pair represents | |
1295 * | |
1296 * @exception SWTException <ul> | |
1297 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1298 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1299 * </ul> | |
1300 * | |
1301 * @since 3.3 | |
1302 */ | |
1303 public Widget findWidget (Widget widget, int id) { | |
1304 checkDevice (); | |
1305 return null; | |
1306 } | |
1307 | |
1308 static int /*long*/ fixedClassInitProc (int /*long*/ g_class, int /*long*/ class_data) { | |
1309 GtkWidgetClass klass = new GtkWidgetClass (); | |
1310 OS.memmove (klass, g_class); | |
1311 klass.map = fixedMapProc; | |
1312 OS.memmove (g_class, klass); | |
1313 return 0; | |
1314 } | |
1315 | |
1316 static int /*long*/ fixedMapProc (int /*long*/ handle) { | |
1317 Display display = getCurrent (); | |
1318 Widget widget = display.getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1319 if (widget !is null) return widget.fixedMapProc (handle); |
18 | 1320 return 0; |
1321 } | |
1322 | |
1323 static int /*long*/ rendererClassInitProc (int /*long*/ g_class, int /*long*/ class_data) { | |
1324 GtkCellRendererClass klass = new GtkCellRendererClass (); | |
1325 OS.memmove (klass, g_class); | |
1326 klass.render = rendererRenderProc; | |
1327 klass.get_size = rendererGetSizeProc; | |
1328 OS.memmove (g_class, klass); | |
1329 return 0; | |
1330 } | |
1331 | |
1332 static int /*long*/ rendererGetSizeProc (int /*long*/ cell, int /*long*/ handle, int /*long*/ cell_area, int /*long*/ x_offset, int /*long*/ y_offset, int /*long*/ width, int /*long*/ height) { | |
1333 Display display = getCurrent (); | |
1334 Widget widget = display.getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1335 if (widget !is null) return widget.rendererGetSizeProc (cell, handle, cell_area, x_offset, y_offset, width, height); |
18 | 1336 return 0; |
1337 } | |
1338 | |
1339 static int /*long*/ rendererRenderProc (int /*long*/ cell, int /*long*/ window, int /*long*/ handle, int /*long*/ background_area, int /*long*/ cell_area, int /*long*/ expose_area, int /*long*/ flags) { | |
1340 Display display = getCurrent (); | |
1341 Widget widget = display.getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1342 if (widget !is null) return widget.rendererRenderProc (cell, window, handle, background_area, cell_area, expose_area, flags); |
18 | 1343 return 0; |
1344 } | |
1345 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1346 void flushExposes (int /*long*/ window, bool all) { |
18 | 1347 OS.gdk_flush (); |
1348 OS.gdk_flush (); | |
1349 if (OS.GDK_WINDOWING_X11 ()) { | |
1350 this.flushWindow = window; | |
1351 this.flushAll = all; | |
1352 int /*long*/ xDisplay = OS.GDK_DISPLAY (); | |
1353 int /*long*/ xEvent = OS.g_malloc (XEvent.sizeof); | |
1354 OS.XCheckIfEvent (xDisplay, xEvent, checkIfEventProc, 0); | |
1355 OS.g_free (xEvent); | |
1356 this.flushWindow = 0; | |
1357 } | |
1358 } | |
1359 | |
1360 /** | |
1361 * Returns the currently active <code>Shell</code>, or null | |
1362 * if no shell belonging to the currently running application | |
1363 * is active. | |
1364 * | |
1365 * @return the active shell or null | |
1366 * | |
1367 * @exception SWTException <ul> | |
1368 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1369 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1370 * </ul> | |
1371 */ | |
1372 public Shell getActiveShell () { | |
1373 checkDevice (); | |
1374 return activeShell; | |
1375 } | |
1376 | |
1377 /** | |
1378 * Returns a rectangle describing the receiver's size and location. | |
1379 * | |
1380 * @return the bounding rectangle | |
1381 * | |
1382 * @exception SWTException <ul> | |
1383 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1384 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1385 * </ul> | |
1386 */ | |
1387 public Rectangle getBounds () { | |
1388 checkDevice (); | |
1389 return new Rectangle (0, 0, OS.gdk_screen_width (), OS.gdk_screen_height ()); | |
1390 } | |
1391 | |
1392 /** | |
1393 * Returns the display which the currently running thread is | |
1394 * the user-interface thread for, or null if the currently | |
1395 * running thread is not a user-interface thread for any display. | |
1396 * | |
1397 * @return the current display | |
1398 */ | |
1399 public static synchronized Display getCurrent () { | |
1400 Thread current = Thread.currentThread (); | |
1401 for (int i=0; i<Displays.length; i++) { | |
1402 Display display = Displays [i]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1403 if (display !is null && display.thread is current) return display; |
18 | 1404 } |
1405 return null; | |
1406 } | |
1407 | |
1408 int getCaretBlinkTime () { | |
1409 // checkDevice (); | |
1410 int /*long*/ settings = OS.gtk_settings_get_default (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1411 if (settings is null) return 500; |
18 | 1412 int [] buffer = new int [1]; |
1413 OS.g_object_get (settings, OS.gtk_cursor_blink, buffer, 0); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1414 if (buffer [0] is 0) return 0; |
18 | 1415 OS.g_object_get (settings, OS.gtk_cursor_blink_time, buffer, 0); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1416 if (buffer [0] is 0) return 500; |
18 | 1417 /* |
1418 * By experimentation, GTK application don't use the whole | |
1419 * blink cycle time. Instead, they divide up the time, using | |
1420 * an effective blink rate of about 1/2 the total time. | |
1421 */ | |
1422 return buffer [0] / 2; | |
1423 } | |
1424 | |
1425 /** | |
1426 * Returns the control which the on-screen pointer is currently | |
1427 * over top of, or null if it is not currently over one of the | |
1428 * controls built by the currently running application. | |
1429 * | |
1430 * @return the control under the cursor | |
1431 * | |
1432 * @exception SWTException <ul> | |
1433 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1434 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1435 * </ul> | |
1436 */ | |
1437 public Control getCursorControl () { | |
1438 checkDevice(); | |
1439 int[] x = new int[1], y = new int[1]; | |
1440 int /*long*/ window = OS.gdk_window_at_pointer (x,y); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1441 if (window is null) return null; |
18 | 1442 int /*long*/ [] user_data = new int /*long*/ [1]; |
1443 OS.gdk_window_get_user_data (window, user_data); | |
1444 int /*long*/ handle = user_data [0]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1445 if (handle is null) return null; |
18 | 1446 do { |
1447 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1448 if (widget !is null && (null !is cast(Control)widget)) { |
18 | 1449 Control control = (Control) widget; |
1450 if (control.isEnabled ()) return control; | |
1451 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1452 } while ((handle = OS.gtk_widget_get_parent (handle)) !is null); |
18 | 1453 return null; |
1454 } | |
1455 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1456 bool filterEvent (Event event) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1457 if (filterTable !is null) filterTable.sendEvent (event); |
18 | 1458 return false; |
1459 } | |
1460 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1461 bool filters (int eventType) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1462 if (filterTable is null) return false; |
18 | 1463 return filterTable.hooks (eventType); |
1464 } | |
1465 | |
1466 int /*long*/ filterProc (int /*long*/ xEvent, int /*long*/ gdkEvent, int /*long*/ data) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1467 if (data is null) { |
18 | 1468 /* |
1469 * Feature in GTK. When button 4, 5, 6, or 7 is released, GTK | |
1470 * does not deliver a corresponding GTK event. Button 6 and 7 | |
1471 * are mapped to buttons 4 and 5 in SWT. The fix is to change | |
1472 * the button number of the event to a negative number so that | |
1473 * it gets dispatched by GTK. SWT has been modified to look | |
1474 * for negative button numbers. | |
1475 */ | |
1476 XButtonEvent mouseEvent = new XButtonEvent (); | |
1477 OS.memmove (mouseEvent, xEvent, 4); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1478 if (mouseEvent.type is OS.ButtonRelease) { |
18 | 1479 OS.memmove (mouseEvent, xEvent, XButtonEvent.sizeof); |
1480 switch (mouseEvent.button) { | |
1481 case 6: | |
1482 case 7: | |
1483 mouseEvent.button = -mouseEvent.button; | |
1484 OS.memmove (xEvent, mouseEvent, XButtonEvent.sizeof); | |
1485 break; | |
1486 } | |
1487 } | |
1488 } | |
1489 Widget widget = getWidget (data); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1490 if (widget is null) return 0; |
18 | 1491 return widget.filterProc (xEvent, gdkEvent, data); |
1492 } | |
1493 | |
1494 /** | |
1495 * Returns the location of the on-screen pointer relative | |
1496 * to the top left corner of the screen. | |
1497 * | |
1498 * @return the cursor location | |
1499 * | |
1500 * @exception SWTException <ul> | |
1501 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1502 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1503 * </ul> | |
1504 */ | |
1505 public Point getCursorLocation () { | |
1506 checkDevice (); | |
1507 int [] x = new int [1], y = new int [1]; | |
1508 OS.gdk_window_get_pointer (0, x, y, null); | |
1509 return new Point (x [0], y [0]); | |
1510 } | |
1511 | |
1512 /** | |
1513 * Returns an array containing the recommended cursor sizes. | |
1514 * | |
1515 * @return the array of cursor sizes | |
1516 * | |
1517 * @exception SWTException <ul> | |
1518 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1519 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1520 * </ul> | |
1521 * | |
1522 * @since 3.0 | |
1523 */ | |
1524 public Point [] getCursorSizes () { | |
1525 checkDevice (); | |
1526 return new Point [] {new Point (16, 16), new Point (32, 32)}; | |
1527 } | |
1528 | |
1529 /** | |
1530 * Returns the application defined property of the receiver | |
1531 * with the specified name, or null if it has not been set. | |
1532 * <p> | |
1533 * Applications may have associated arbitrary objects with the | |
1534 * receiver in this fashion. If the objects stored in the | |
1535 * properties need to be notified when the display is disposed | |
1536 * of, it is the application's responsibility to provide a | |
1537 * <code>disposeExec()</code> handler which does so. | |
1538 * </p> | |
1539 * | |
1540 * @param key the name of the property | |
1541 * @return the value of the property or null if it has not been set | |
1542 * | |
1543 * @exception IllegalArgumentException <ul> | |
1544 * <li>ERROR_NULL_ARGUMENT - if the key is null</li> | |
1545 * </ul> | |
1546 * @exception SWTException <ul> | |
1547 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1548 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1549 * </ul> | |
1550 * | |
1551 * @see #setData(String, Object) | |
1552 * @see #disposeExec(Runnable) | |
1553 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1554 public Object getData (char[] key) { |
18 | 1555 checkDevice (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1556 if (key is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1557 if (key ==/*eq*/ DISPATCH_EVENT_KEY) { |
18 | 1558 return dispatchEvents; |
1559 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1560 if (keys is null) return null; |
18 | 1561 for (int i=0; i<keys.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1562 if (keys [i] ==/*eq*/ key) return values [i]; |
18 | 1563 } |
1564 return null; | |
1565 } | |
1566 | |
1567 /** | |
1568 * Returns the application defined, display specific data | |
1569 * associated with the receiver, or null if it has not been | |
1570 * set. The <em>display specific data</em> is a single, | |
1571 * unnamed field that is stored with every display. | |
1572 * <p> | |
1573 * Applications may put arbitrary objects in this field. If | |
1574 * the object stored in the display specific data needs to | |
1575 * be notified when the display is disposed of, it is the | |
1576 * application's responsibility to provide a | |
1577 * <code>disposeExec()</code> handler which does so. | |
1578 * </p> | |
1579 * | |
1580 * @return the display specific data | |
1581 * | |
1582 * @exception SWTException <ul> | |
1583 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1584 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1585 * </ul> | |
1586 * | |
1587 * @see #setData(Object) | |
1588 * @see #disposeExec(Runnable) | |
1589 */ | |
1590 public Object getData () { | |
1591 checkDevice (); | |
1592 return data; | |
1593 } | |
1594 | |
1595 /** | |
1596 * Returns a point whose x coordinate is the horizontal | |
1597 * dots per inch of the display, and whose y coordinate | |
1598 * is the vertical dots per inch of the display. | |
1599 * | |
1600 * @return the horizontal and vertical DPI | |
1601 * | |
1602 * @exception SWTException <ul> | |
1603 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1604 * </ul> | |
1605 */ | |
1606 public Point getDPI () { | |
1607 checkDevice (); | |
1608 int widthMM = OS.gdk_screen_width_mm (); | |
1609 int width = OS.gdk_screen_width (); | |
1610 int dpi = Compatibility.round (254 * width, widthMM * 10); | |
1611 return new Point (dpi, dpi); | |
1612 } | |
1613 | |
1614 int /*long*/ gtk_fixed_get_type () { | |
1615 return fixed_type; | |
1616 } | |
1617 | |
1618 int /*long*/ gtk_cell_renderer_text_get_type () { | |
1619 return text_renderer_type; | |
1620 } | |
1621 | |
1622 int /*long*/ gtk_cell_renderer_pixbuf_get_type () { | |
1623 return pixbuf_renderer_type; | |
1624 } | |
1625 | |
1626 int /*long*/ gtk_cell_renderer_toggle_get_type () { | |
1627 return toggle_renderer_type; | |
1628 } | |
1629 | |
1630 /** | |
1631 * Returns the default display. One is created (making the | |
1632 * thread that invokes this method its user-interface thread) | |
1633 * if it did not already exist. | |
1634 * | |
1635 * @return the default display | |
1636 */ | |
1637 public static synchronized Display getDefault () { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1638 if (Default is null) Default = new Display (); |
18 | 1639 return Default; |
1640 } | |
1641 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1642 static bool isValidClass (Class clazz) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1643 char[] name = clazz.getName (); |
18 | 1644 int index = name.lastIndexOf ('.'); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1645 return name.substring (0, index + 1)==/*eq*/ PACKAGE_PREFIX; |
18 | 1646 } |
1647 | |
1648 /** | |
1649 * Returns the button dismissal alignment, one of <code>LEFT</code> or <code>RIGHT</code>. | |
1650 * The button dismissal alignment is the ordering that should be used when positioning the | |
1651 * default dismissal button for a dialog. For example, in a dialog that contains an OK and | |
1652 * CANCEL button, on platforms where the button dismissal alignment is <code>LEFT</code>, the | |
1653 * button ordering should be OK/CANCEL. When button dismissal alignment is <code>RIGHT</code>, | |
1654 * the button ordering should be CANCEL/OK. | |
1655 * | |
1656 * @return the button dismissal order | |
1657 * | |
1658 * @exception SWTException <ul> | |
1659 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1660 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1661 * </ul> | |
1662 * | |
1663 * @since 2.1 | |
1664 */ | |
1665 public int getDismissalAlignment () { | |
1666 checkDevice (); | |
1667 return SWT.RIGHT; | |
1668 } | |
1669 | |
1670 /** | |
1671 * Returns the longest duration, in milliseconds, between | |
1672 * two mouse button clicks that will be considered a | |
1673 * <em>double click</em> by the underlying operating system. | |
1674 * | |
1675 * @return the double click time | |
1676 * | |
1677 * @exception SWTException <ul> | |
1678 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1679 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1680 * </ul> | |
1681 */ | |
1682 public int getDoubleClickTime () { | |
1683 checkDevice (); | |
1684 int /*long*/ settings = OS.gtk_settings_get_default (); | |
1685 int [] buffer = new int [1]; | |
1686 OS.g_object_get (settings, OS.gtk_double_click_time, buffer, 0); | |
1687 return buffer [0]; | |
1688 } | |
1689 | |
1690 /** | |
1691 * Returns the control which currently has keyboard focus, | |
1692 * or null if keyboard events are not currently going to | |
1693 * any of the controls built by the currently running | |
1694 * application. | |
1695 * | |
1696 * @return the control under the cursor | |
1697 * | |
1698 * @exception SWTException <ul> | |
1699 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1700 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1701 * </ul> | |
1702 */ | |
1703 public Control getFocusControl () { | |
1704 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1705 if (focusControl !is null && !focusControl.isDisposed ()) { |
18 | 1706 return focusControl; |
1707 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1708 if (activeShell is null) return null; |
18 | 1709 int /*long*/ shellHandle = activeShell.shellHandle; |
1710 int /*long*/ handle = OS.gtk_window_get_focus (shellHandle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1711 if (handle is null) return null; |
18 | 1712 do { |
1713 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1714 if (widget !is null && (null !is cast(Control)widget)) { |
18 | 1715 Control control = (Control) widget; |
1716 return control.isEnabled () ? control : null; | |
1717 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1718 } while ((handle = OS.gtk_widget_get_parent (handle)) !is null); |
18 | 1719 return null; |
1720 } | |
1721 | |
1722 /** | |
1723 * Returns true when the high contrast mode is enabled. | |
1724 * Otherwise, false is returned. | |
1725 * <p> | |
1726 * Note: This operation is a hint and is not supported on | |
1727 * platforms that do not have this concept. | |
1728 * </p> | |
1729 * | |
1730 * @return the high contrast mode | |
1731 * | |
1732 * @exception SWTException <ul> | |
1733 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1734 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1735 * </ul> | |
1736 * | |
1737 * @since 3.0 | |
1738 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1739 public bool getHighContrast () { |
18 | 1740 checkDevice (); |
1741 return false; | |
1742 } | |
1743 | |
1744 public int getDepth () { | |
1745 checkDevice (); | |
1746 GdkVisual visual = new GdkVisual (); | |
1747 OS.memmove (visual, OS.gdk_visual_get_system()); | |
1748 return visual.depth; | |
1749 } | |
1750 | |
1751 /** | |
1752 * Returns the maximum allowed depth of icons on this display, in bits per pixel. | |
1753 * On some platforms, this may be different than the actual depth of the display. | |
1754 * | |
1755 * @return the maximum icon depth | |
1756 * | |
1757 * @exception SWTException <ul> | |
1758 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1759 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1760 * </ul> | |
1761 * | |
1762 * @see Device#getDepth | |
1763 */ | |
1764 public int getIconDepth () { | |
1765 checkDevice (); | |
1766 return getDepth (); | |
1767 } | |
1768 | |
1769 /** | |
1770 * Returns an array containing the recommended icon sizes. | |
1771 * | |
1772 * @return the array of icon sizes | |
1773 * | |
1774 * @exception SWTException <ul> | |
1775 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1776 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1777 * </ul> | |
1778 * | |
1779 * @see Decorations#setImages(Image[]) | |
1780 * | |
1781 * @since 3.0 | |
1782 */ | |
1783 public Point [] getIconSizes () { | |
1784 checkDevice (); | |
1785 return new Point [] {new Point (16, 16), new Point (32, 32)}; | |
1786 } | |
1787 | |
1788 int getLastEventTime () { | |
1789 return lastEventTime; | |
1790 } | |
1791 | |
1792 int getMessageCount () { | |
1793 return synchronizer.getMessageCount (); | |
1794 } | |
1795 | |
1796 /** | |
1797 * Returns the work area, an EWMH property to store the size | |
1798 * and position of the screen not covered by dock and panel | |
1799 * windows. See http://freedesktop.org/Standards/wm-spec. | |
1800 */ | |
1801 Rectangle getWorkArea() { | |
1802 byte[] name = Converter.wcsToMbcs (null, "_NET_WORKAREA", true); | |
1803 int /*long*/ atom = OS.gdk_atom_intern (name, true); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1804 if (atom is OS.GDK_NONE) return null; |
18 | 1805 int /*long*/[] actualType = new int /*long*/[1]; |
1806 int[] actualFormat = new int[1]; | |
1807 int[] actualLength = new int[1]; | |
1808 int /*long*/[] data = new int /*long*/[1]; | |
1809 if (!OS.gdk_property_get (OS.GDK_ROOT_PARENT (), atom, OS.GDK_NONE, 0, 16, 0, actualType, actualFormat, actualLength, data)) { | |
1810 return null; | |
1811 } | |
1812 Rectangle result = null; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1813 if (data [0] !is 0) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1814 if (actualLength [0] is 16) { |
18 | 1815 int values [] = new int [4]; |
1816 OS.memmove (values, data[0], 16); | |
1817 result = new Rectangle (values [0],values [1],values [2],values [3]); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1818 } else if (actualLength [0] is 32) { |
18 | 1819 long values [] = new long [4]; |
1820 OS.memmove (values, data[0], 32); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1821 result = new Rectangle (cast(int)values [0],cast(int)values [1],cast(int)values [2],cast(int)values [3]); |
18 | 1822 } |
1823 OS.g_free (data [0]); | |
1824 } | |
1825 return result; | |
1826 } | |
1827 | |
1828 /** | |
1829 * Returns an array of monitors attached to the device. | |
1830 * | |
1831 * @return the array of monitors | |
1832 * | |
1833 * @since 3.0 | |
1834 */ | |
1835 public Monitor [] getMonitors () { | |
1836 checkDevice (); | |
1837 Monitor [] monitors = null; | |
1838 Rectangle workArea = getWorkArea(); | |
1839 int /*long*/ screen = OS.gdk_screen_get_default (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1840 if (screen !is null) { |
18 | 1841 int monitorCount = OS.gdk_screen_get_n_monitors (screen); |
1842 if (monitorCount > 0) { | |
1843 monitors = new Monitor [monitorCount]; | |
1844 GdkRectangle dest = new GdkRectangle (); | |
1845 for (int i = 0; i < monitorCount; i++) { | |
1846 OS.gdk_screen_get_monitor_geometry (screen, i, dest); | |
1847 Monitor monitor = new Monitor (); | |
1848 monitor.handle = i; | |
1849 monitor.x = dest.x; | |
1850 monitor.y = dest.y; | |
1851 monitor.width = dest.width; | |
1852 monitor.height = dest.height; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1853 if (i is 0 && workArea !is null) { |
18 | 1854 monitor.clientX = workArea.x; |
1855 monitor.clientY = workArea.y; | |
1856 monitor.clientWidth = workArea.width; | |
1857 monitor.clientHeight = workArea.height; | |
1858 } else { | |
1859 monitor.clientX = monitor.x; | |
1860 monitor.clientY = monitor.y; | |
1861 monitor.clientWidth = monitor.width; | |
1862 monitor.clientHeight = monitor.height; | |
1863 } | |
1864 monitors [i] = monitor; | |
1865 } | |
1866 } | |
1867 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1868 if (monitors is null) { |
18 | 1869 /* No multimonitor support detected, default to one monitor */ |
1870 Monitor monitor = new Monitor (); | |
1871 Rectangle bounds = getBounds (); | |
1872 monitor.x = bounds.x; | |
1873 monitor.y = bounds.y; | |
1874 monitor.width = bounds.width; | |
1875 monitor.height = bounds.height; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1876 if (workArea !is null) { |
18 | 1877 monitor.clientX = workArea.x; |
1878 monitor.clientY = workArea.y; | |
1879 monitor.clientWidth = workArea.width; | |
1880 monitor.clientHeight = workArea.height; | |
1881 } else { | |
1882 monitor.clientX = monitor.x; | |
1883 monitor.clientY = monitor.y; | |
1884 monitor.clientWidth = monitor.width; | |
1885 monitor.clientHeight = monitor.height; | |
1886 } | |
1887 monitors = new Monitor [] { monitor }; | |
1888 } | |
1889 return monitors; | |
1890 } | |
1891 | |
1892 /** | |
1893 * Returns the primary monitor for that device. | |
1894 * | |
1895 * @return the primary monitor | |
1896 * | |
1897 * @since 3.0 | |
1898 */ | |
1899 public Monitor getPrimaryMonitor () { | |
1900 checkDevice (); | |
1901 Monitor [] monitors = getMonitors (); | |
1902 return monitors [0]; | |
1903 } | |
1904 | |
1905 /** | |
1906 * Returns a (possibly empty) array containing all shells which have | |
1907 * not been disposed and have the receiver as their display. | |
1908 * | |
1909 * @return the receiver's shells | |
1910 * | |
1911 * @exception SWTException <ul> | |
1912 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1913 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1914 * </ul> | |
1915 */ | |
1916 public Shell [] getShells () { | |
1917 checkDevice (); | |
1918 int index = 0; | |
1919 Shell [] result = new Shell [16]; | |
1920 for (int i = 0; i < widgetTable.length; i++) { | |
1921 Widget widget = widgetTable [i]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1922 if (widget !is null && (null !is cast(Shell)widget)) { |
18 | 1923 int j = 0; |
1924 while (j < index) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1925 if (result [j] is widget) break; |
18 | 1926 j++; |
1927 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1928 if (j is index) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1929 if (index is result.length) { |
18 | 1930 Shell [] newResult = new Shell [index + 16]; |
1931 System.arraycopy (result, 0, newResult, 0, index); | |
1932 result = newResult; | |
1933 } | |
1934 result [index++] = (Shell) widget; | |
1935 } | |
1936 } | |
1937 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
1938 if (index is result.length) return result; |
18 | 1939 Shell [] newResult = new Shell [index]; |
1940 System.arraycopy (result, 0, newResult, 0, index); | |
1941 return newResult; | |
1942 } | |
1943 | |
1944 /** | |
1945 * Returns the thread that has invoked <code>syncExec</code> | |
1946 * or null if no such runnable is currently being invoked by | |
1947 * the user-interface thread. | |
1948 * <p> | |
1949 * Note: If a runnable invoked by asyncExec is currently | |
1950 * running, this method will return null. | |
1951 * </p> | |
1952 * | |
1953 * @return the receiver's sync-interface thread | |
1954 * | |
1955 * @exception SWTException <ul> | |
1956 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1957 * </ul> | |
1958 */ | |
1959 public Thread getSyncThread () { | |
1960 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); | |
1961 return synchronizer.syncThread; | |
1962 } | |
1963 | |
1964 /** | |
1965 * Returns the matching standard color for the given | |
1966 * constant, which should be one of the color constants | |
1967 * specified in class <code>SWT</code>. Any value other | |
1968 * than one of the SWT color constants which is passed | |
1969 * in will result in the color black. This color should | |
1970 * not be free'd because it was allocated by the system, | |
1971 * not the application. | |
1972 * | |
1973 * @param id the color constant | |
1974 * @return the matching color | |
1975 * | |
1976 * @exception SWTException <ul> | |
1977 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
1978 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
1979 * </ul> | |
1980 * | |
1981 * @see SWT | |
1982 */ | |
1983 public Color getSystemColor (int id) { | |
1984 checkDevice (); | |
1985 GdkColor gdkColor = null; | |
1986 switch (id) { | |
1987 case SWT.COLOR_INFO_FOREGROUND: gdkColor = COLOR_INFO_FOREGROUND; break; | |
1988 case SWT.COLOR_INFO_BACKGROUND: gdkColor = COLOR_INFO_BACKGROUND; break; | |
1989 case SWT.COLOR_TITLE_FOREGROUND: gdkColor = COLOR_TITLE_FOREGROUND; break; | |
1990 case SWT.COLOR_TITLE_BACKGROUND: gdkColor = COLOR_TITLE_BACKGROUND; break; | |
1991 case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_BACKGROUND_GRADIENT; break; | |
1992 case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: gdkColor = COLOR_TITLE_INACTIVE_FOREGROUND; break; | |
1993 case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND; break; | |
1994 case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: gdkColor = COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; break; | |
1995 case SWT.COLOR_WIDGET_DARK_SHADOW: gdkColor = COLOR_WIDGET_DARK_SHADOW; break; | |
1996 case SWT.COLOR_WIDGET_NORMAL_SHADOW: gdkColor = COLOR_WIDGET_NORMAL_SHADOW; break; | |
1997 case SWT.COLOR_WIDGET_LIGHT_SHADOW: gdkColor = COLOR_WIDGET_LIGHT_SHADOW; break; | |
1998 case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: gdkColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break; | |
1999 case SWT.COLOR_WIDGET_BACKGROUND: gdkColor = COLOR_WIDGET_BACKGROUND; break; | |
2000 case SWT.COLOR_WIDGET_FOREGROUND: gdkColor = COLOR_WIDGET_FOREGROUND; break; | |
2001 case SWT.COLOR_WIDGET_BORDER: gdkColor = COLOR_WIDGET_BORDER; break; | |
2002 case SWT.COLOR_LIST_FOREGROUND: gdkColor = COLOR_LIST_FOREGROUND; break; | |
2003 case SWT.COLOR_LIST_BACKGROUND: gdkColor = COLOR_LIST_BACKGROUND; break; | |
2004 case SWT.COLOR_LIST_SELECTION: gdkColor = COLOR_LIST_SELECTION; break; | |
2005 case SWT.COLOR_LIST_SELECTION_TEXT: gdkColor = COLOR_LIST_SELECTION_TEXT; break; | |
2006 default: | |
2007 return super.getSystemColor (id); | |
2008 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2009 if (gdkColor is null) return super.getSystemColor (SWT.COLOR_BLACK); |
18 | 2010 return Color.gtk_new (this, gdkColor); |
2011 } | |
2012 | |
2013 /** | |
2014 * Returns the matching standard platform cursor for the given | |
2015 * constant, which should be one of the cursor constants | |
2016 * specified in class <code>SWT</code>. This cursor should | |
2017 * not be free'd because it was allocated by the system, | |
2018 * not the application. A value of <code>null</code> will | |
2019 * be returned if the supplied constant is not an SWT cursor | |
2020 * constant. | |
2021 * | |
2022 * @param id the SWT cursor constant | |
2023 * @return the corresponding cursor or <code>null</code> | |
2024 * | |
2025 * @exception SWTException <ul> | |
2026 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2027 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2028 * </ul> | |
2029 * | |
2030 * @see SWT#CURSOR_ARROW | |
2031 * @see SWT#CURSOR_WAIT | |
2032 * @see SWT#CURSOR_CROSS | |
2033 * @see SWT#CURSOR_APPSTARTING | |
2034 * @see SWT#CURSOR_HELP | |
2035 * @see SWT#CURSOR_SIZEALL | |
2036 * @see SWT#CURSOR_SIZENESW | |
2037 * @see SWT#CURSOR_SIZENS | |
2038 * @see SWT#CURSOR_SIZENWSE | |
2039 * @see SWT#CURSOR_SIZEWE | |
2040 * @see SWT#CURSOR_SIZEN | |
2041 * @see SWT#CURSOR_SIZES | |
2042 * @see SWT#CURSOR_SIZEE | |
2043 * @see SWT#CURSOR_SIZEW | |
2044 * @see SWT#CURSOR_SIZENE | |
2045 * @see SWT#CURSOR_SIZESE | |
2046 * @see SWT#CURSOR_SIZESW | |
2047 * @see SWT#CURSOR_SIZENW | |
2048 * @see SWT#CURSOR_UPARROW | |
2049 * @see SWT#CURSOR_IBEAM | |
2050 * @see SWT#CURSOR_NO | |
2051 * @see SWT#CURSOR_HAND | |
2052 * | |
2053 * @since 3.0 | |
2054 */ | |
2055 public Cursor getSystemCursor (int id) { | |
2056 checkDevice (); | |
2057 if (!(0 <= id && id < cursors.length)) return null; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2058 if (cursors [id] is null) { |
18 | 2059 cursors [id] = new Cursor (this, id); |
2060 } | |
2061 return cursors [id]; | |
2062 } | |
2063 | |
2064 /** | |
2065 * Returns the matching standard platform image for the given | |
2066 * constant, which should be one of the icon constants | |
2067 * specified in class <code>SWT</code>. This image should | |
2068 * not be free'd because it was allocated by the system, | |
2069 * not the application. A value of <code>null</code> will | |
2070 * be returned either if the supplied constant is not an | |
2071 * SWT icon constant or if the platform does not define an | |
2072 * image that corresponds to the constant. | |
2073 * | |
2074 * @param id the SWT icon constant | |
2075 * @return the corresponding image or <code>null</code> | |
2076 * | |
2077 * @exception SWTException <ul> | |
2078 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2079 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2080 * </ul> | |
2081 * | |
2082 * @see SWT#ICON_ERROR | |
2083 * @see SWT#ICON_INFORMATION | |
2084 * @see SWT#ICON_QUESTION | |
2085 * @see SWT#ICON_WARNING | |
2086 * @see SWT#ICON_WORKING | |
2087 * | |
2088 * @since 3.0 | |
2089 */ | |
2090 public Image getSystemImage (int id) { | |
2091 checkDevice (); | |
2092 switch (id) { | |
2093 case SWT.ICON_ERROR: | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2094 if (errorImage is null) { |
18 | 2095 errorImage = createImage ("gtk-dialog-error"); |
2096 } | |
2097 return errorImage; | |
2098 case SWT.ICON_INFORMATION: | |
2099 case SWT.ICON_WORKING: | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2100 if (infoImage is null) { |
18 | 2101 infoImage = createImage ("gtk-dialog-info"); |
2102 } | |
2103 return infoImage; | |
2104 case SWT.ICON_QUESTION: | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2105 if (questionImage is null) { |
18 | 2106 questionImage = createImage ("gtk-dialog-question"); |
2107 } | |
2108 return questionImage; | |
2109 case SWT.ICON_WARNING: | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2110 if (warningImage is null) { |
18 | 2111 warningImage = createImage ("gtk-dialog-warning"); |
2112 } | |
2113 return warningImage; | |
2114 } | |
2115 return null; | |
2116 } | |
2117 | |
2118 void initializeSystemColors () { | |
2119 GdkColor gdkColor; | |
2120 | |
2121 /* Get Tooltip resources */ | |
2122 int /*long*/ tooltipShellHandle = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2123 if (tooltipShellHandle is null) SWT.error (SWT.ERROR_NO_HANDLES); |
18 | 2124 byte[] gtk_tooltips = Converter.wcsToMbcs (null, "gtk-tooltips", true); |
2125 OS.gtk_widget_set_name (tooltipShellHandle, gtk_tooltips); | |
2126 OS.gtk_widget_realize (tooltipShellHandle); | |
2127 int /*long*/ tooltipStyle = OS.gtk_widget_get_style (tooltipShellHandle); | |
2128 gdkColor = new GdkColor(); | |
2129 OS.gtk_style_get_fg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor); | |
2130 COLOR_INFO_FOREGROUND = gdkColor; | |
2131 gdkColor = new GdkColor(); | |
2132 OS.gtk_style_get_bg (tooltipStyle, OS.GTK_STATE_NORMAL, gdkColor); | |
2133 COLOR_INFO_BACKGROUND = gdkColor; | |
2134 OS.gtk_widget_destroy (tooltipShellHandle); | |
2135 | |
2136 /* Get Shell resources */ | |
2137 int /*long*/ style = OS.gtk_widget_get_style (shellHandle); | |
2138 gdkColor = new GdkColor(); | |
2139 OS.gtk_style_get_black (style, gdkColor); | |
2140 COLOR_WIDGET_DARK_SHADOW = gdkColor; | |
2141 gdkColor = new GdkColor(); | |
2142 OS.gtk_style_get_dark (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2143 COLOR_WIDGET_NORMAL_SHADOW = gdkColor; | |
2144 gdkColor = new GdkColor(); | |
2145 OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2146 COLOR_WIDGET_LIGHT_SHADOW = gdkColor; | |
2147 gdkColor = new GdkColor(); | |
2148 OS.gtk_style_get_light (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2149 COLOR_WIDGET_HIGHLIGHT_SHADOW = gdkColor; | |
2150 gdkColor = new GdkColor(); | |
2151 OS.gtk_style_get_fg (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2152 COLOR_WIDGET_FOREGROUND = gdkColor; | |
2153 gdkColor = new GdkColor(); | |
2154 OS.gtk_style_get_bg (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2155 COLOR_WIDGET_BACKGROUND = gdkColor; | |
2156 //gdkColor = new GdkColor(); | |
2157 //OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2158 //COLOR_TEXT_FOREGROUND = gdkColor; | |
2159 //gdkColor = new GdkColor(); | |
2160 //OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2161 //COLOR_TEXT_BACKGROUND = gdkColor; | |
2162 gdkColor = new GdkColor(); | |
2163 OS.gtk_style_get_text (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2164 COLOR_LIST_FOREGROUND = gdkColor; | |
2165 gdkColor = new GdkColor(); | |
2166 OS.gtk_style_get_base (style, OS.GTK_STATE_NORMAL, gdkColor); | |
2167 COLOR_LIST_BACKGROUND = gdkColor; | |
2168 gdkColor = new GdkColor(); | |
2169 OS.gtk_style_get_text (style, OS.GTK_STATE_SELECTED, gdkColor); | |
2170 COLOR_LIST_SELECTION_TEXT = gdkColor; | |
2171 gdkColor = new GdkColor(); | |
2172 OS.gtk_style_get_base (style, OS.GTK_STATE_SELECTED, gdkColor); | |
2173 COLOR_LIST_SELECTION = gdkColor; | |
2174 gdkColor = new GdkColor(); | |
2175 OS.gtk_style_get_bg (style, OS.GTK_STATE_SELECTED, gdkColor); | |
2176 COLOR_TITLE_BACKGROUND = gdkColor; | |
2177 gdkColor = new GdkColor(); | |
2178 OS.gtk_style_get_fg (style, OS.GTK_STATE_SELECTED, gdkColor); | |
2179 COLOR_TITLE_FOREGROUND = gdkColor; | |
2180 gdkColor = new GdkColor(); | |
2181 OS.gtk_style_get_light (style, OS.GTK_STATE_SELECTED, gdkColor); | |
2182 COLOR_TITLE_BACKGROUND_GRADIENT = gdkColor; | |
2183 gdkColor = new GdkColor(); | |
2184 OS.gtk_style_get_bg (style, OS.GTK_STATE_INSENSITIVE, gdkColor); | |
2185 COLOR_TITLE_INACTIVE_BACKGROUND = gdkColor; | |
2186 gdkColor = new GdkColor(); | |
2187 OS.gtk_style_get_fg (style, OS.GTK_STATE_INSENSITIVE, gdkColor); | |
2188 COLOR_TITLE_INACTIVE_FOREGROUND = gdkColor; | |
2189 gdkColor = new GdkColor(); | |
2190 OS.gtk_style_get_light (style, OS.GTK_STATE_INSENSITIVE, gdkColor); | |
2191 COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = gdkColor; | |
2192 } | |
2193 | |
2194 /** | |
2195 * Returns a reasonable font for applications to use. | |
2196 * On some platforms, this will match the "default font" | |
2197 * or "system font" if such can be found. This font | |
2198 * should not be free'd because it was allocated by the | |
2199 * system, not the application. | |
2200 * <p> | |
2201 * Typically, applications which want the default look | |
2202 * should simply not set the font on the widgets they | |
2203 * create. Widgets are always created with the correct | |
2204 * default font for the class of user-interface component | |
2205 * they represent. | |
2206 * </p> | |
2207 * | |
2208 * @return a font | |
2209 * | |
2210 * @exception SWTException <ul> | |
2211 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2212 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2213 * </ul> | |
2214 */ | |
2215 public Font getSystemFont () { | |
2216 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2217 if (systemFont !is null) return systemFont; |
18 | 2218 int /*long*/ style = OS.gtk_widget_get_style (shellHandle); |
2219 int /*long*/ defaultFont = OS.pango_font_description_copy (OS.gtk_style_get_font_desc (style)); | |
2220 return systemFont = Font.gtk_new (this, defaultFont); | |
2221 } | |
2222 | |
2223 /** | |
2224 * Returns the single instance of the system tray or null | |
2225 * when there is no system tray available for the platform. | |
2226 * | |
2227 * @return the system tray or <code>null</code> | |
2228 * | |
2229 * @exception SWTException <ul> | |
2230 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2231 * </ul> | |
2232 * | |
2233 * @since 3.0 | |
2234 */ | |
2235 public Tray getSystemTray () { | |
2236 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2237 if (tray !is null) return tray; |
18 | 2238 return tray = new Tray (this, SWT.NONE); |
2239 } | |
2240 | |
2241 /** | |
2242 * Returns the user-interface thread for the receiver. | |
2243 * | |
2244 * @return the receiver's user-interface thread | |
2245 * | |
2246 * @exception SWTException <ul> | |
2247 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2248 * </ul> | |
2249 */ | |
2250 public Thread getThread () { | |
2251 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); | |
2252 return thread; | |
2253 } | |
2254 | |
2255 Widget getWidget (int /*long*/ handle) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2256 if (handle is null) return null; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2257 if (lastWidget !is null && lastHandle is handle) return lastWidget; |
18 | 2258 int /*long*/ index = OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1; |
2259 if (0 <= index && index < widgetTable.length) { | |
2260 lastHandle = handle; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2261 return lastWidget = widgetTable [cast(int)/*64*/index]; |
18 | 2262 } |
2263 return null; | |
2264 } | |
2265 | |
2266 int /*long*/ idleProc (int /*long*/ data) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2267 bool result = runAsyncMessages (false); |
18 | 2268 if (!result) { |
2269 synchronized (idleLock) { | |
2270 idleHandle = 0; | |
2271 } | |
2272 } | |
2273 return result ? 1 : 0; | |
2274 } | |
2275 | |
2276 /** | |
2277 * Initializes any internal resources needed by the | |
2278 * device. | |
2279 * <p> | |
2280 * This method is called after <code>create</code>. | |
2281 * </p> | |
2282 * | |
2283 * @see #create | |
2284 */ | |
2285 protected void init () { | |
2286 super.init (); | |
2287 initializeCallbacks (); | |
2288 initializeSystemColors (); | |
2289 initializeSystemSettings (); | |
2290 initializeWidgetTable (); | |
2291 initializeWindowManager (); | |
2292 } | |
2293 | |
2294 void initializeCallbacks () { | |
2295 closures = new int /*long*/ [Widget.LAST_SIGNAL]; | |
2296 signalIds = new int [Widget.LAST_SIGNAL]; | |
2297 | |
2298 /* Cache signals for GtkWidget */ | |
2299 signalIds [Widget.BUTTON_PRESS_EVENT] = OS.g_signal_lookup (OS.button_press_event, OS.GTK_TYPE_WIDGET ()); | |
2300 signalIds [Widget.BUTTON_RELEASE_EVENT] = OS.g_signal_lookup (OS.button_release_event, OS.GTK_TYPE_WIDGET ()); | |
2301 signalIds [Widget.CONFIGURE_EVENT] = OS.g_signal_lookup (OS.configure_event, OS.GTK_TYPE_WIDGET ()); | |
2302 signalIds [Widget.DELETE_EVENT] = OS.g_signal_lookup (OS.delete_event, OS.GTK_TYPE_WIDGET ()); | |
2303 signalIds [Widget.ENTER_NOTIFY_EVENT] = OS.g_signal_lookup (OS.enter_notify_event, OS.GTK_TYPE_WIDGET ()); | |
2304 signalIds [Widget.EVENT] = OS.g_signal_lookup (OS.event, OS.GTK_TYPE_WIDGET ()); | |
2305 signalIds [Widget.EVENT_AFTER] = OS.g_signal_lookup (OS.event_after, OS.GTK_TYPE_WIDGET ()); | |
2306 signalIds [Widget.EXPOSE_EVENT] = OS.g_signal_lookup (OS.expose_event, OS.GTK_TYPE_WIDGET ()); | |
2307 signalIds [Widget.FOCUS] = OS.g_signal_lookup (OS.focus, OS.GTK_TYPE_WIDGET ()); | |
2308 signalIds [Widget.FOCUS_IN_EVENT] = OS.g_signal_lookup (OS.focus_in_event, OS.GTK_TYPE_WIDGET ()); | |
2309 signalIds [Widget.FOCUS_OUT_EVENT] = OS.g_signal_lookup (OS.focus_out_event, OS.GTK_TYPE_WIDGET ()); | |
2310 signalIds [Widget.GRAB_FOCUS] = OS.g_signal_lookup (OS.grab_focus, OS.GTK_TYPE_WIDGET ()); | |
2311 signalIds [Widget.HIDE] = OS.g_signal_lookup (OS.hide, OS.GTK_TYPE_WIDGET ()); | |
2312 signalIds [Widget.KEY_PRESS_EVENT] = OS.g_signal_lookup (OS.key_press_event, OS.GTK_TYPE_WIDGET ()); | |
2313 signalIds [Widget.KEY_RELEASE_EVENT] = OS.g_signal_lookup (OS.key_release_event, OS.GTK_TYPE_WIDGET ()); | |
2314 signalIds [Widget.LEAVE_NOTIFY_EVENT] = OS.g_signal_lookup (OS.leave_notify_event, OS.GTK_TYPE_WIDGET ()); | |
2315 signalIds [Widget.MAP] = OS.g_signal_lookup (OS.map, OS.GTK_TYPE_WIDGET ()); | |
2316 signalIds [Widget.MAP_EVENT] = OS.g_signal_lookup (OS.map_event, OS.GTK_TYPE_WIDGET ()); | |
2317 signalIds [Widget.MNEMONIC_ACTIVATE] = OS.g_signal_lookup (OS.mnemonic_activate, OS.GTK_TYPE_WIDGET ()); | |
2318 signalIds [Widget.MOTION_NOTIFY_EVENT] = OS.g_signal_lookup (OS.motion_notify_event, OS.GTK_TYPE_WIDGET ()); | |
2319 signalIds [Widget.POPUP_MENU] = OS.g_signal_lookup (OS.popup_menu, OS.GTK_TYPE_WIDGET ()); | |
2320 signalIds [Widget.REALIZE] = OS.g_signal_lookup (OS.realize, OS.GTK_TYPE_WIDGET ()); | |
2321 signalIds [Widget.SCROLL_EVENT] = OS.g_signal_lookup (OS.scroll_event, OS.GTK_TYPE_WIDGET ()); | |
2322 signalIds [Widget.SHOW] = OS.g_signal_lookup (OS.show, OS.GTK_TYPE_WIDGET ()); | |
2323 signalIds [Widget.SHOW_HELP] = OS.g_signal_lookup (OS.show_help, OS.GTK_TYPE_WIDGET ()); | |
2324 signalIds [Widget.SIZE_ALLOCATE] = OS.g_signal_lookup (OS.size_allocate, OS.GTK_TYPE_WIDGET ()); | |
2325 signalIds [Widget.STYLE_SET] = OS.g_signal_lookup (OS.style_set, OS.GTK_TYPE_WIDGET ()); | |
2326 signalIds [Widget.UNMAP] = OS.g_signal_lookup (OS.unmap, OS.GTK_TYPE_WIDGET ()); | |
2327 signalIds [Widget.UNMAP_EVENT] = OS.g_signal_lookup (OS.unmap_event, OS.GTK_TYPE_WIDGET ()); | |
2328 signalIds [Widget.UNREALIZE] = OS.g_signal_lookup (OS.realize, OS.GTK_TYPE_WIDGET ()); | |
2329 signalIds [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_signal_lookup (OS.visibility_notify_event, OS.GTK_TYPE_WIDGET ()); | |
2330 signalIds [Widget.WINDOW_STATE_EVENT] = OS.g_signal_lookup (OS.window_state_event, OS.GTK_TYPE_WIDGET ()); | |
2331 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2332 windowCallback2 = new void*/*Callback*/ (this, "windowProc", 2); |
18 | 2333 windowProc2 = windowCallback2.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2334 if (windowProc2 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2335 |
2336 closures [Widget.ACTIVATE] = OS.g_cclosure_new (windowProc2, Widget.ACTIVATE, 0); | |
2337 closures [Widget.ACTIVATE_INVERSE] = OS.g_cclosure_new (windowProc2, Widget.ACTIVATE_INVERSE, 0); | |
2338 closures [Widget.CHANGED] = OS.g_cclosure_new (windowProc2, Widget.CHANGED, 0); | |
2339 closures [Widget.CLICKED] = OS.g_cclosure_new (windowProc2, Widget.CLICKED, 0); | |
2340 closures [Widget.DAY_SELECTED] = OS.g_cclosure_new (windowProc2, Widget.DAY_SELECTED, 0); | |
2341 closures [Widget.HIDE] = OS.g_cclosure_new (windowProc2, Widget.HIDE, 0); | |
2342 closures [Widget.GRAB_FOCUS] = OS.g_cclosure_new (windowProc2, Widget.GRAB_FOCUS, 0); | |
2343 closures [Widget.MAP] = OS.g_cclosure_new (windowProc2, Widget.MAP, 0); | |
2344 closures [Widget.MONTH_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.MONTH_CHANGED, 0); | |
2345 closures [Widget.OUTPUT] = OS.g_cclosure_new (windowProc2, Widget.OUTPUT, 0); | |
2346 closures [Widget.POPUP_MENU] = OS.g_cclosure_new (windowProc2, Widget.POPUP_MENU, 0); | |
2347 closures [Widget.PREEDIT_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.PREEDIT_CHANGED, 0); | |
2348 closures [Widget.REALIZE] = OS.g_cclosure_new (windowProc2, Widget.REALIZE, 0); | |
2349 closures [Widget.SELECT] = OS.g_cclosure_new (windowProc2, Widget.SELECT, 0); | |
2350 closures [Widget.SHOW] = OS.g_cclosure_new (windowProc2, Widget.SHOW, 0); | |
2351 closures [Widget.VALUE_CHANGED] = OS.g_cclosure_new (windowProc2, Widget.VALUE_CHANGED, 0); | |
2352 closures [Widget.UNMAP] = OS.g_cclosure_new (windowProc2, Widget.UNMAP, 0); | |
2353 closures [Widget.UNREALIZE] = OS.g_cclosure_new (windowProc2, Widget.UNREALIZE, 0); | |
2354 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2355 windowCallback3 = new void*/*Callback*/ (this, "windowProc", 3); |
18 | 2356 windowProc3 = windowCallback3.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2357 if (windowProc3 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2358 |
2359 closures [Widget.BUTTON_PRESS_EVENT] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT, 0); | |
2360 closures [Widget.BUTTON_PRESS_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_PRESS_EVENT_INVERSE, 0); | |
2361 closures [Widget.BUTTON_RELEASE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT, 0); | |
2362 closures [Widget.BUTTON_RELEASE_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.BUTTON_RELEASE_EVENT_INVERSE, 0); | |
2363 closures [Widget.COMMIT] = OS.g_cclosure_new (windowProc3, Widget.COMMIT, 0); | |
2364 closures [Widget.CONFIGURE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.CONFIGURE_EVENT, 0); | |
2365 closures [Widget.DELETE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.DELETE_EVENT, 0); | |
2366 closures [Widget.ENTER_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.ENTER_NOTIFY_EVENT, 0); | |
2367 closures [Widget.EVENT] = OS.g_cclosure_new (windowProc3, Widget.EVENT, 0); | |
2368 closures [Widget.EVENT_AFTER] = OS.g_cclosure_new (windowProc3, Widget.EVENT_AFTER, 0); | |
2369 closures [Widget.EXPOSE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.EXPOSE_EVENT, 0); | |
2370 closures [Widget.EXPOSE_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.EXPOSE_EVENT_INVERSE, 0); | |
2371 closures [Widget.FOCUS] = OS.g_cclosure_new (windowProc3, Widget.FOCUS, 0); | |
2372 closures [Widget.FOCUS_IN_EVENT] = OS.g_cclosure_new (windowProc3, Widget.FOCUS_IN_EVENT, 0); | |
2373 closures [Widget.FOCUS_OUT_EVENT] = OS.g_cclosure_new (windowProc3, Widget.FOCUS_OUT_EVENT, 0); | |
2374 closures [Widget.KEY_PRESS_EVENT] = OS.g_cclosure_new (windowProc3, Widget.KEY_PRESS_EVENT, 0); | |
2375 closures [Widget.KEY_RELEASE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.KEY_RELEASE_EVENT, 0); | |
2376 closures [Widget.INPUT] = OS.g_cclosure_new (windowProc3, Widget.INPUT, 0); | |
2377 closures [Widget.LEAVE_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.LEAVE_NOTIFY_EVENT, 0); | |
2378 closures [Widget.MAP_EVENT] = OS.g_cclosure_new (windowProc3, Widget.MAP_EVENT, 0); | |
2379 closures [Widget.MNEMONIC_ACTIVATE] = OS.g_cclosure_new (windowProc3, Widget.MNEMONIC_ACTIVATE, 0); | |
2380 closures [Widget.MOTION_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT, 0); | |
2381 closures [Widget.MOTION_NOTIFY_EVENT_INVERSE] = OS.g_cclosure_new (windowProc3, Widget.MOTION_NOTIFY_EVENT_INVERSE, 0); | |
2382 closures [Widget.MOVE_FOCUS] = OS.g_cclosure_new (windowProc3, Widget.MOVE_FOCUS, 0); | |
2383 closures [Widget.SCROLL_EVENT] = OS.g_cclosure_new (windowProc3, Widget.SCROLL_EVENT, 0); | |
2384 closures [Widget.SHOW_HELP] = OS.g_cclosure_new (windowProc3, Widget.SHOW_HELP, 0); | |
2385 closures [Widget.SIZE_ALLOCATE] = OS.g_cclosure_new (windowProc3, Widget.SIZE_ALLOCATE, 0); | |
2386 closures [Widget.STYLE_SET] = OS.g_cclosure_new (windowProc3, Widget.STYLE_SET, 0); | |
2387 closures [Widget.TOGGLED] = OS.g_cclosure_new (windowProc3, Widget.TOGGLED, 0); | |
2388 closures [Widget.UNMAP_EVENT] = OS.g_cclosure_new (windowProc3, Widget.UNMAP_EVENT, 0); | |
2389 closures [Widget.VISIBILITY_NOTIFY_EVENT] = OS.g_cclosure_new (windowProc3, Widget.VISIBILITY_NOTIFY_EVENT, 0); | |
2390 closures [Widget.WINDOW_STATE_EVENT] = OS.g_cclosure_new (windowProc3, Widget.WINDOW_STATE_EVENT, 0); | |
2391 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2392 windowCallback4 = new void*/*Callback*/ (this, "windowProc", 4); |
18 | 2393 windowProc4 = windowCallback4.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2394 if (windowProc4 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2395 |
2396 closures [Widget.DELETE_RANGE] = OS.g_cclosure_new (windowProc4, Widget.DELETE_RANGE, 0); | |
2397 closures [Widget.DELETE_TEXT] = OS.g_cclosure_new (windowProc4, Widget.DELETE_TEXT, 0); | |
2398 closures [Widget.ROW_ACTIVATED] = OS.g_cclosure_new (windowProc4, Widget.ROW_ACTIVATED, 0); | |
2399 closures [Widget.SCROLL_CHILD] = OS.g_cclosure_new (windowProc4, Widget.SCROLL_CHILD, 0); | |
2400 closures [Widget.SWITCH_PAGE] = OS.g_cclosure_new (windowProc4, Widget.SWITCH_PAGE, 0); | |
2401 closures [Widget.TEST_COLLAPSE_ROW] = OS.g_cclosure_new (windowProc4, Widget.TEST_COLLAPSE_ROW, 0); | |
2402 closures [Widget.TEST_EXPAND_ROW] = OS.g_cclosure_new (windowProc4, Widget.TEST_EXPAND_ROW, 0); | |
2403 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2404 windowCallback5 = new void*/*Callback*/ (this, "windowProc", 5); |
18 | 2405 windowProc5 = windowCallback5.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2406 if (windowProc5 is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2407 |
2408 closures [Widget.CHANGE_VALUE] = OS.g_cclosure_new (windowProc5, Widget.CHANGE_VALUE, 0); | |
2409 closures [Widget.EXPAND_COLLAPSE_CURSOR_ROW] = OS.g_cclosure_new (windowProc5, Widget.EXPAND_COLLAPSE_CURSOR_ROW, 0); | |
2410 closures [Widget.INSERT_TEXT] = OS.g_cclosure_new (windowProc5, Widget.INSERT_TEXT, 0); | |
2411 closures [Widget.TEXT_BUFFER_INSERT_TEXT] = OS.g_cclosure_new (windowProc5, Widget.TEXT_BUFFER_INSERT_TEXT, 0); | |
2412 | |
2413 for (int i = 0; i < Widget.LAST_SIGNAL; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2414 if (closures [i] !is null) OS.g_closure_ref (closures [i]); |
18 | 2415 } |
2416 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2417 timerCallback = new void*/*Callback*/ (this, "timerProc", 1); |
18 | 2418 timerProc = timerCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2419 if (timerProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2420 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2421 windowTimerCallback = new void*/*Callback*/ (this, "windowTimerProc", 1); |
18 | 2422 windowTimerProc = windowTimerCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2423 if (windowTimerProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2424 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2425 mouseHoverCallback = new void*/*Callback*/ (this, "mouseHoverProc", 1); |
18 | 2426 mouseHoverProc = mouseHoverCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2427 if (mouseHoverProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2428 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2429 caretCallback = new void*/*Callback*/(this, "caretProc", 1); |
18 | 2430 caretProc = caretCallback.getAddress(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2431 if (caretProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2432 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2433 menuPositionCallback = new void*/*Callback*/(this, "menuPositionProc", 5); |
18 | 2434 menuPositionProc = menuPositionCallback.getAddress(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2435 if (menuPositionProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2436 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2437 sizeAllocateCallback = new void*/*Callback*/(this, "sizeAllocateProc", 3); |
18 | 2438 sizeAllocateProc = sizeAllocateCallback.getAddress(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2439 if (sizeAllocateProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2440 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2441 sizeRequestCallback = new void*/*Callback*/(this, "sizeRequestProc", 3); |
18 | 2442 sizeRequestProc = sizeRequestCallback.getAddress(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2443 if (sizeRequestProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2444 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2445 shellMapCallback = new void*/*Callback*/(this, "shellMapProc", 3); |
18 | 2446 shellMapProc = shellMapCallback.getAddress(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2447 if (shellMapProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2448 |
2449 shellMapProcClosure = OS.g_cclosure_new (shellMapProc, 0, 0); | |
2450 OS.g_closure_ref (shellMapProcClosure); | |
2451 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2452 treeSelectionCallback = new void*/*Callback*/(this, "treeSelectionProc", 4); |
18 | 2453 treeSelectionProc = treeSelectionCallback.getAddress(); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2454 if (treeSelectionProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2455 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2456 cellDataCallback = new void*/*Callback*/ (this, "cellDataProc", 5); |
18 | 2457 cellDataProc = cellDataCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2458 if (cellDataProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2459 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2460 setDirectionCallback = new void*/*Callback*/ (this, "setDirectionProc", 2); |
18 | 2461 setDirectionProc = setDirectionCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2462 if (setDirectionProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2463 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2464 allChildrenCallback = new void*/*Callback*/ (this, "allChildrenProc", 2); |
18 | 2465 allChildrenProc = allChildrenCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2466 if (allChildrenProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2467 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2468 checkIfEventCallback = new void*/*Callback*/ (this, "checkIfEventProc", 3); |
18 | 2469 checkIfEventProc = checkIfEventCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2470 if (checkIfEventProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2471 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2472 idleCallback = new void*/*Callback*/ (this, "idleProc", 1); |
18 | 2473 idleProc = idleCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2474 if (idleProc is null) error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2475 } |
2476 | |
2477 void initializeSystemSettings () { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2478 styleSetCallback = new void*/*Callback*/ (this, "styleSetProc", 3); |
18 | 2479 styleSetProc = styleSetCallback.getAddress (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2480 if (styleSetProc is null) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS); |
18 | 2481 OS.g_signal_connect (shellHandle, OS.style_set, styleSetProc, 0); |
2482 | |
2483 /* | |
2484 * Feature in GTK. Despite the fact that the | |
2485 * gtk-entry-select-on-focus property is a global | |
2486 * setting, it is initialized when the GtkEntry | |
2487 * is initialized. This means that it cannot be | |
2488 * accessed before a GtkEntry is created. The | |
2489 * fix is to for the initializaion by creating | |
2490 * a temporary GtkEntry. | |
2491 */ | |
2492 int /*long*/ entry = OS.gtk_entry_new (); | |
2493 OS.gtk_widget_destroy (entry); | |
2494 int [] buffer2 = new int [1]; | |
2495 int /*long*/ settings = OS.gtk_settings_get_default (); | |
2496 OS.g_object_get (settings, OS.gtk_entry_select_on_focus, buffer2, 0); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2497 entrySelectOnFocus = buffer2 [0] !is 0; |
18 | 2498 } |
2499 | |
2500 void initializeWidgetTable () { | |
2501 indexTable = new int [GROW_SIZE]; | |
2502 widgetTable = new Widget [GROW_SIZE]; | |
2503 for (int i=0; i<GROW_SIZE-1; i++) indexTable [i] = i + 1; | |
2504 indexTable [GROW_SIZE - 1] = -1; | |
2505 } | |
2506 | |
2507 void initializeWindowManager () { | |
2508 /* Get the window manager name */ | |
2509 windowManager = ""; | |
2510 if (OS.GTK_VERSION >= OS.VERSION (2, 2, 0)) { | |
2511 int /*long*/ screen = OS.gdk_screen_get_default (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2512 if (screen !is null) { |
18 | 2513 int /*long*/ ptr2 = OS.gdk_x11_screen_get_window_manager_name (screen); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2514 if (ptr2 !is null) { |
18 | 2515 int length = OS.strlen (ptr2); |
2516 if (length > 0) { | |
2517 byte [] buffer2 = new byte [length]; | |
2518 OS.memmove (buffer2, ptr2, length); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2519 windowManager = new char[] (Converter.mbcsToWcs (null, buffer2)); |
18 | 2520 } |
2521 } | |
2522 } | |
2523 } | |
2524 } | |
2525 | |
2526 /** | |
2527 * Invokes platform specific functionality to dispose a GC handle. | |
2528 * <p> | |
2529 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public | |
2530 * API for <code>Display</code>. It is marked public only so that it | |
2531 * can be shared within the packages provided by SWT. It is not | |
2532 * available on all platforms, and should never be called from | |
2533 * application code. | |
2534 * </p> | |
2535 * | |
2536 * @param hDC the platform specific GC handle | |
2537 * @param data the platform specific GC data | |
2538 */ | |
2539 public void internal_dispose_GC (int /*long*/ gdkGC, GCData data) { | |
2540 OS.g_object_unref (gdkGC); | |
2541 } | |
2542 | |
2543 /** | |
2544 * Invokes platform specific functionality to allocate a new GC handle. | |
2545 * <p> | |
2546 * <b>IMPORTANT:</b> This method is <em>not</em> part of the public | |
2547 * API for <code>Display</code>. It is marked public only so that it | |
2548 * can be shared within the packages provided by SWT. It is not | |
2549 * available on all platforms, and should never be called from | |
2550 * application code. | |
2551 * </p> | |
2552 * | |
2553 * @param data the platform specific GC data | |
2554 * @return the platform specific GC handle | |
2555 * | |
2556 * @exception SWTException <ul> | |
2557 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2558 * </ul> | |
2559 * @exception SWTError <ul> | |
2560 * <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li> | |
2561 * </ul> | |
2562 */ | |
2563 public int /*long*/ internal_new_GC (GCData data) { | |
2564 if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED); | |
2565 int /*long*/ root = OS.GDK_ROOT_PARENT (); | |
2566 int /*long*/ gdkGC = OS.gdk_gc_new (root); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2567 if (gdkGC is null) SWT.error (SWT.ERROR_NO_HANDLES); |
18 | 2568 OS.gdk_gc_set_subwindow (gdkGC, OS.GDK_INCLUDE_INFERIORS); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2569 if (data !is null) { |
18 | 2570 int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2571 if ((data.style & mask) is 0) { |
18 | 2572 data.style |= SWT.LEFT_TO_RIGHT; |
2573 } | |
2574 data.device = this; | |
2575 data.drawable = root; | |
2576 data.background = getSystemColor (SWT.COLOR_WHITE).handle; | |
2577 data.foreground = getSystemColor (SWT.COLOR_BLACK).handle; | |
2578 data.font = getSystemFont ().handle; | |
2579 } | |
2580 return gdkGC; | |
2581 } | |
2582 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2583 bool isValidThread () { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2584 return thread is Thread.currentThread (); |
18 | 2585 } |
2586 | |
2587 /** | |
2588 * Maps a point from one coordinate system to another. | |
2589 * When the control is null, coordinates are mapped to | |
2590 * the display. | |
2591 * <p> | |
2592 * NOTE: On right-to-left platforms where the coordinate | |
2593 * systems are mirrored, special care needs to be taken | |
2594 * when mapping coordinates from one control to another | |
2595 * to ensure the result is correctly mirrored. | |
2596 * | |
2597 * Mapping a point that is the origin of a rectangle and | |
2598 * then adding the width and height is not equivalent to | |
2599 * mapping the rectangle. When one control is mirrored | |
2600 * and the other is not, adding the width and height to a | |
2601 * point that was mapped causes the rectangle to extend | |
2602 * in the wrong direction. Mapping the entire rectangle | |
2603 * instead of just one point causes both the origin and | |
2604 * the corner of the rectangle to be mapped. | |
2605 * </p> | |
2606 * | |
2607 * @param from the source <code>Control</code> or <code>null</code> | |
2608 * @param to the destination <code>Control</code> or <code>null</code> | |
2609 * @param point to be mapped | |
2610 * @return point with mapped coordinates | |
2611 * | |
2612 * @exception IllegalArgumentException <ul> | |
2613 * <li>ERROR_NULL_ARGUMENT - if the point is null</li> | |
2614 * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> | |
2615 * </ul> | |
2616 * @exception SWTException <ul> | |
2617 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2618 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2619 * </ul> | |
2620 * | |
2621 * @since 2.1.2 | |
2622 */ | |
2623 public Point map (Control from, Control to, Point point) { | |
2624 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2625 if (point is null) error (SWT.ERROR_NULL_ARGUMENT); |
18 | 2626 return map (from, to, point.x, point.y); |
2627 } | |
2628 | |
2629 /** | |
2630 * Maps a point from one coordinate system to another. | |
2631 * When the control is null, coordinates are mapped to | |
2632 * the display. | |
2633 * <p> | |
2634 * NOTE: On right-to-left platforms where the coordinate | |
2635 * systems are mirrored, special care needs to be taken | |
2636 * when mapping coordinates from one control to another | |
2637 * to ensure the result is correctly mirrored. | |
2638 * | |
2639 * Mapping a point that is the origin of a rectangle and | |
2640 * then adding the width and height is not equivalent to | |
2641 * mapping the rectangle. When one control is mirrored | |
2642 * and the other is not, adding the width and height to a | |
2643 * point that was mapped causes the rectangle to extend | |
2644 * in the wrong direction. Mapping the entire rectangle | |
2645 * instead of just one point causes both the origin and | |
2646 * the corner of the rectangle to be mapped. | |
2647 * </p> | |
2648 * | |
2649 * @param from the source <code>Control</code> or <code>null</code> | |
2650 * @param to the destination <code>Control</code> or <code>null</code> | |
2651 * @param x coordinates to be mapped | |
2652 * @param y coordinates to be mapped | |
2653 * @return point with mapped coordinates | |
2654 * | |
2655 * @exception IllegalArgumentException <ul> | |
2656 * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> | |
2657 * </ul> | |
2658 * @exception SWTException <ul> | |
2659 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2660 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2661 * </ul> | |
2662 * | |
2663 * @since 2.1.2 | |
2664 */ | |
2665 public Point map (Control from, Control to, int x, int y) { | |
2666 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2667 if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2668 if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); |
18 | 2669 Point point = new Point (x, y); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2670 if (from is to) return point; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2671 if (from !is null) { |
18 | 2672 int /*long*/ window = from.eventWindow (); |
2673 int [] origin_x = new int [1], origin_y = new int [1]; | |
2674 OS.gdk_window_get_origin (window, origin_x, origin_y); | |
2675 point.x += origin_x [0]; | |
2676 point.y += origin_y [0]; | |
2677 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2678 if (to !is null) { |
18 | 2679 int /*long*/ window = to.eventWindow (); |
2680 int [] origin_x = new int [1], origin_y = new int [1]; | |
2681 OS.gdk_window_get_origin (window, origin_x, origin_y); | |
2682 point.x -= origin_x [0]; | |
2683 point.y -= origin_y [0]; | |
2684 } | |
2685 return point; | |
2686 } | |
2687 | |
2688 /** | |
2689 * Maps a point from one coordinate system to another. | |
2690 * When the control is null, coordinates are mapped to | |
2691 * the display. | |
2692 * <p> | |
2693 * NOTE: On right-to-left platforms where the coordinate | |
2694 * systems are mirrored, special care needs to be taken | |
2695 * when mapping coordinates from one control to another | |
2696 * to ensure the result is correctly mirrored. | |
2697 * | |
2698 * Mapping a point that is the origin of a rectangle and | |
2699 * then adding the width and height is not equivalent to | |
2700 * mapping the rectangle. When one control is mirrored | |
2701 * and the other is not, adding the width and height to a | |
2702 * point that was mapped causes the rectangle to extend | |
2703 * in the wrong direction. Mapping the entire rectangle | |
2704 * instead of just one point causes both the origin and | |
2705 * the corner of the rectangle to be mapped. | |
2706 * </p> | |
2707 * | |
2708 * @param from the source <code>Control</code> or <code>null</code> | |
2709 * @param to the destination <code>Control</code> or <code>null</code> | |
2710 * @param rectangle to be mapped | |
2711 * @return rectangle with mapped coordinates | |
2712 * | |
2713 * @exception IllegalArgumentException <ul> | |
2714 * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li> | |
2715 * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> | |
2716 * </ul> | |
2717 * @exception SWTException <ul> | |
2718 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2719 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2720 * </ul> | |
2721 * | |
2722 * @since 2.1.2 | |
2723 */ | |
2724 public Rectangle map (Control from, Control to, Rectangle rectangle) { | |
2725 checkDevice(); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2726 if (rectangle is null) error (SWT.ERROR_NULL_ARGUMENT); |
18 | 2727 return map (from, to, rectangle.x, rectangle.y, rectangle.width, rectangle.height); |
2728 } | |
2729 | |
2730 static char mbcsToWcs (char ch) { | |
2731 int key = ch & 0xFFFF; | |
2732 if (key <= 0x7F) return ch; | |
2733 byte [] buffer; | |
2734 if (key <= 0xFF) { | |
2735 buffer = new byte [1]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2736 buffer [0] = cast(byte) key; |
18 | 2737 } else { |
2738 buffer = new byte [2]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2739 buffer [0] = cast(byte) ((key >> 8) & 0xFF); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2740 buffer [1] = cast(byte) (key & 0xFF); |
18 | 2741 } |
2742 char [] result = Converter.mbcsToWcs (null, buffer); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2743 if (result.length is 0) return 0; |
18 | 2744 return result [0]; |
2745 } | |
2746 | |
2747 int /*long*/ menuPositionProc (int /*long*/ menu, int /*long*/ x, int /*long*/ y, int /*long*/ push_in, int /*long*/ user_data) { | |
2748 Widget widget = getWidget (menu); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2749 if (widget is null) return 0; |
18 | 2750 return widget.menuPositionProc (menu, x, y, push_in, user_data); |
2751 } | |
2752 | |
2753 /** | |
2754 * Maps a point from one coordinate system to another. | |
2755 * When the control is null, coordinates are mapped to | |
2756 * the display. | |
2757 * <p> | |
2758 * NOTE: On right-to-left platforms where the coordinate | |
2759 * systems are mirrored, special care needs to be taken | |
2760 * when mapping coordinates from one control to another | |
2761 * to ensure the result is correctly mirrored. | |
2762 * | |
2763 * Mapping a point that is the origin of a rectangle and | |
2764 * then adding the width and height is not equivalent to | |
2765 * mapping the rectangle. When one control is mirrored | |
2766 * and the other is not, adding the width and height to a | |
2767 * point that was mapped causes the rectangle to extend | |
2768 * in the wrong direction. Mapping the entire rectangle | |
2769 * instead of just one point causes both the origin and | |
2770 * the corner of the rectangle to be mapped. | |
2771 * </p> | |
2772 * | |
2773 * @param from the source <code>Control</code> or <code>null</code> | |
2774 * @param to the destination <code>Control</code> or <code>null</code> | |
2775 * @param x coordinates to be mapped | |
2776 * @param y coordinates to be mapped | |
2777 * @param width coordinates to be mapped | |
2778 * @param height coordinates to be mapped | |
2779 * @return rectangle with mapped coordinates | |
2780 * | |
2781 * @exception IllegalArgumentException <ul> | |
2782 * <li>ERROR_INVALID_ARGUMENT - if the Control from or the Control to have been disposed</li> | |
2783 * </ul> | |
2784 * @exception SWTException <ul> | |
2785 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2786 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2787 * </ul> | |
2788 * | |
2789 * @since 2.1.2 | |
2790 */ | |
2791 public Rectangle map (Control from, Control to, int x, int y, int width, int height) { | |
2792 checkDevice(); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2793 if (from !is null && from.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2794 if (to !is null && to.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); |
18 | 2795 Rectangle rect = new Rectangle (x, y, width, height); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2796 if (from is to) return rect; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2797 if (from !is null) { |
18 | 2798 int /*long*/ window = from.eventWindow (); |
2799 int [] origin_x = new int [1], origin_y = new int [1]; | |
2800 OS.gdk_window_get_origin (window, origin_x, origin_y); | |
2801 rect.x += origin_x [0]; | |
2802 rect.y += origin_y [0]; | |
2803 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2804 if (to !is null) { |
18 | 2805 int /*long*/ window = to.eventWindow (); |
2806 int [] origin_x = new int [1], origin_y = new int [1]; | |
2807 OS.gdk_window_get_origin (window, origin_x, origin_y); | |
2808 rect.x -= origin_x [0]; | |
2809 rect.y -= origin_y [0]; | |
2810 } | |
2811 return rect; | |
2812 } | |
2813 | |
2814 int /*long*/ mouseHoverProc (int /*long*/ handle) { | |
2815 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2816 if (widget is null) return 0; |
18 | 2817 return widget.hoverProc (handle); |
2818 } | |
2819 | |
2820 /** | |
2821 * Generate a low level system event. | |
2822 * | |
2823 * <code>post</code> is used to generate low level keyboard | |
2824 * and mouse events. The intent is to enable automated UI | |
2825 * testing by simulating the input from the user. Most | |
2826 * SWT applications should never need to call this method. | |
2827 * <p> | |
2828 * Note that this operation can fail when the operating system | |
2829 * fails to generate the event for any reason. For example, | |
2830 * this can happen when there is no such key or mouse button | |
2831 * or when the system event queue is full. | |
2832 * </p> | |
2833 * <p> | |
2834 * <b>Event Types:</b> | |
2835 * <p>KeyDown, KeyUp | |
2836 * <p>The following fields in the <code>Event</code> apply: | |
2837 * <ul> | |
2838 * <li>(in) type KeyDown or KeyUp</li> | |
2839 * <p> Either one of: | |
2840 * <li>(in) character a character that corresponds to a keyboard key</li> | |
2841 * <li>(in) keyCode the key code of the key that was typed, | |
2842 * as defined by the key code constants in class <code>SWT</code></li> | |
2843 * </ul> | |
2844 * <p>MouseDown, MouseUp</p> | |
2845 * <p>The following fields in the <code>Event</code> apply: | |
2846 * <ul> | |
2847 * <li>(in) type MouseDown or MouseUp | |
2848 * <li>(in) button the button that is pressed or released | |
2849 * </ul> | |
2850 * <p>MouseMove</p> | |
2851 * <p>The following fields in the <code>Event</code> apply: | |
2852 * <ul> | |
2853 * <li>(in) type MouseMove | |
2854 * <li>(in) x the x coordinate to move the mouse pointer to in screen coordinates | |
2855 * <li>(in) y the y coordinate to move the mouse pointer to in screen coordinates | |
2856 * </ul> | |
2857 * </dl> | |
2858 * | |
2859 * @param event the event to be generated | |
2860 * | |
2861 * @return true if the event was generated or false otherwise | |
2862 * | |
2863 * @exception IllegalArgumentException <ul> | |
2864 * <li>ERROR_NULL_ARGUMENT - if the event is null</li> | |
2865 * </ul> | |
2866 * @exception SWTException <ul> | |
2867 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2868 * </ul> | |
2869 * | |
2870 * @since 3.0 | |
2871 * | |
2872 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2873 public bool post (Event event) { |
18 | 2874 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2875 if (event is null) error (SWT.ERROR_NULL_ARGUMENT); |
18 | 2876 if (!OS.GDK_WINDOWING_X11()) return false; |
2877 int /*long*/ xDisplay = OS.GDK_DISPLAY (); | |
2878 int type = event.type; | |
2879 switch (type) { | |
2880 case SWT.KeyDown: | |
2881 case SWT.KeyUp: { | |
2882 int keyCode = 0; | |
2883 int /*long*/ keysym = untranslateKey (event.keyCode); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2884 if (keysym !is 0) keyCode = OS.XKeysymToKeycode (xDisplay, keysym); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2885 if (keyCode is 0) { |
18 | 2886 char key = event.character; |
2887 switch (key) { | |
2888 case SWT.BS: keysym = OS.GDK_BackSpace; break; | |
2889 case SWT.CR: keysym = OS.GDK_Return; break; | |
2890 case SWT.DEL: keysym = OS.GDK_Delete; break; | |
2891 case SWT.ESC: keysym = OS.GDK_Escape; break; | |
2892 case SWT.TAB: keysym = OS.GDK_Tab; break; | |
2893 case SWT.LF: keysym = OS.GDK_Linefeed; break; | |
2894 default: | |
2895 keysym = wcsToMbcs (key); | |
2896 } | |
2897 keyCode = OS.XKeysymToKeycode (xDisplay, keysym); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2898 if (keyCode is 0) return false; |
18 | 2899 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2900 OS.XTestFakeKeyEvent (xDisplay, keyCode, type is SWT.KeyDown, 0); |
18 | 2901 return true; |
2902 } | |
2903 case SWT.MouseDown: | |
2904 case SWT.MouseMove: | |
2905 case SWT.MouseUp: { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2906 if (type is SWT.MouseMove) { |
18 | 2907 OS.XTestFakeMotionEvent (xDisplay, -1, event.x, event.y, 0); |
2908 } else { | |
2909 int button = event.button; | |
2910 switch (button) { | |
2911 case 1: | |
2912 case 2: | |
2913 case 3: break; | |
2914 case 4: button = 6; break; | |
2915 case 5: button = 7; break; | |
2916 default: return false; | |
2917 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2918 OS.XTestFakeButtonEvent (xDisplay, button, type is SWT.MouseDown, 0); |
18 | 2919 } |
2920 return true; | |
2921 } | |
2922 /* | |
2923 * This code is intentionally commented. After posting a | |
2924 * mouse wheel event the system may respond unpredictably | |
2925 * to subsequent mouse actions. | |
2926 */ | |
2927 // case SWT.MouseWheel: { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2928 // if (event.count is 0) return false; |
18 | 2929 // int button = event.count < 0 ? 5 : 4; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2930 // OS.XTestFakeButtonEvent (xDisplay, button, type is SWT.MouseWheel, 0); |
18 | 2931 // } |
2932 } | |
2933 return false; | |
2934 } | |
2935 | |
2936 void postEvent (Event event) { | |
2937 /* | |
2938 * Place the event at the end of the event queue. | |
2939 * This code is always called in the Display's | |
2940 * thread so it must be re-enterant but does not | |
2941 * need to be synchronized. | |
2942 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2943 if (eventQueue is null) eventQueue = new Event [4]; |
18 | 2944 int index = 0; |
2945 int length = eventQueue.length; | |
2946 while (index < length) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2947 if (eventQueue [index] is null) break; |
18 | 2948 index++; |
2949 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2950 if (index is length) { |
18 | 2951 Event [] newQueue = new Event [length + 4]; |
2952 System.arraycopy (eventQueue, 0, newQueue, 0, length); | |
2953 eventQueue = newQueue; | |
2954 } | |
2955 eventQueue [index] = event; | |
2956 } | |
2957 | |
2958 void putGdkEvents () { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2959 if (gdkEventCount !is 0) { |
18 | 2960 for (int i = 0; i < gdkEventCount; i++) { |
2961 int /*long*/ event = gdkEvents [i]; | |
2962 Widget widget = gdkEventWidgets [i]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2963 if (widget is null || !widget.isDisposed ()) { |
18 | 2964 OS.gdk_event_put (event); |
2965 } | |
2966 OS.gdk_event_free (event); | |
2967 gdkEvents [i] = 0; | |
2968 gdkEventWidgets [i] = null; | |
2969 } | |
2970 gdkEventCount = 0; | |
2971 } | |
2972 } | |
2973 | |
2974 /** | |
2975 * Reads an event from the operating system's event queue, | |
2976 * dispatches it appropriately, and returns <code>true</code> | |
2977 * if there is potentially more work to do, or <code>false</code> | |
2978 * if the caller can sleep until another event is placed on | |
2979 * the event queue. | |
2980 * <p> | |
2981 * In addition to checking the system event queue, this method also | |
2982 * checks if any inter-thread messages (created by <code>syncExec()</code> | |
2983 * or <code>asyncExec()</code>) are waiting to be processed, and if | |
2984 * so handles them before returning. | |
2985 * </p> | |
2986 * | |
2987 * @return <code>false</code> if the caller can sleep upon return from this method | |
2988 * | |
2989 * @exception SWTException <ul> | |
2990 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
2991 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
2992 * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li> | |
2993 * </ul> | |
2994 * | |
2995 * @see #sleep | |
2996 * @see #wake | |
2997 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
2998 public bool readAndDispatch () { |
18 | 2999 checkDevice (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3000 bool events = false; |
18 | 3001 events |= runSettings (); |
3002 events |= runPopups (); | |
3003 events |= OS.g_main_context_iteration (0, false); | |
3004 if (events) { | |
3005 runDeferredEvents (); | |
3006 return true; | |
3007 } | |
3008 return runAsyncMessages (false); | |
3009 } | |
3010 | |
3011 synchronized void register () { | |
3012 for (int i=0; i<Displays.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3013 if (Displays [i] is null) { |
18 | 3014 Displays [i] = this; |
3015 return; | |
3016 } | |
3017 } | |
3018 Display [] newDisplays = new Display [Displays.length + 4]; | |
3019 System.arraycopy (Displays, 0, newDisplays, 0, Displays.length); | |
3020 newDisplays [Displays.length] = this; | |
3021 Displays = newDisplays; | |
3022 } | |
3023 | |
3024 /** | |
3025 * Releases any internal resources back to the operating | |
3026 * system and clears all fields except the device handle. | |
3027 * <p> | |
3028 * Disposes all shells which are currently open on the display. | |
3029 * After this method has been invoked, all related related shells | |
3030 * will answer <code>true</code> when sent the message | |
3031 * <code>isDisposed()</code>. | |
3032 * </p><p> | |
3033 * When a device is destroyed, resources that were acquired | |
3034 * on behalf of the programmer need to be returned to the | |
3035 * operating system. For example, if the device allocated a | |
3036 * font to be used as the system font, this font would be | |
3037 * freed in <code>release</code>. Also,to assist the garbage | |
3038 * collector and minimize the amount of memory that is not | |
3039 * reclaimed when the programmer keeps a reference to a | |
3040 * disposed device, all fields except the handle are zero'd. | |
3041 * The handle is needed by <code>destroy</code>. | |
3042 * </p> | |
3043 * This method is called before <code>destroy</code>. | |
3044 * | |
3045 * @see Device#dispose | |
3046 * @see #destroy | |
3047 */ | |
3048 protected void release () { | |
3049 sendEvent (SWT.Dispose, new Event ()); | |
3050 Shell [] shells = getShells (); | |
3051 for (int i=0; i<shells.length; i++) { | |
3052 Shell shell = shells [i]; | |
3053 if (!shell.isDisposed ()) shell.dispose (); | |
3054 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3055 if (tray !is null) tray.dispose (); |
18 | 3056 tray = null; |
3057 while (readAndDispatch ()) {} | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3058 if (disposeList !is null) { |
18 | 3059 for (int i=0; i<disposeList.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3060 if (disposeList [i] !is null) disposeList [i].run (); |
18 | 3061 } |
3062 } | |
3063 disposeList = null; | |
3064 synchronizer.releaseSynchronizer (); | |
3065 synchronizer = null; | |
3066 releaseDisplay (); | |
3067 super.release (); | |
3068 } | |
3069 | |
3070 void releaseDisplay () { | |
3071 windowCallback2.dispose (); windowCallback2 = null; | |
3072 windowCallback3.dispose (); windowCallback3 = null; | |
3073 windowCallback4.dispose (); windowCallback4 = null; | |
3074 windowCallback5.dispose (); windowCallback5 = null; | |
3075 windowProc2 = windowProc3 = windowProc4 = windowProc5 = 0; | |
3076 | |
3077 /* Dispose xfilter callback */ | |
3078 filterCallback.dispose(); filterCallback = null; | |
3079 filterProc = 0; | |
3080 | |
3081 /* Dispose checkIfEvent callback */ | |
3082 checkIfEventCallback.dispose(); checkIfEventCallback = null; | |
3083 checkIfEventProc = 0; | |
3084 | |
3085 /* Dispose preedit window */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3086 if (preeditWindow !is null) OS.gtk_widget_destroy (preeditWindow); |
18 | 3087 imControl = null; |
3088 | |
3089 /* Dispose the menu callback */ | |
3090 menuPositionCallback.dispose (); menuPositionCallback = null; | |
3091 menuPositionProc = 0; | |
3092 | |
3093 /* Dispose the tooltip map callback */ | |
3094 sizeAllocateCallback.dispose (); sizeAllocateCallback = null; | |
3095 sizeAllocateProc = 0; | |
3096 sizeRequestCallback.dispose (); sizeRequestCallback = null; | |
3097 sizeRequestProc = 0; | |
3098 | |
3099 /* Dispose the shell map callback */ | |
3100 shellMapCallback.dispose (); shellMapCallback = null; | |
3101 shellMapProc = 0; | |
3102 | |
3103 /* Dispose the run async messages callback */ | |
3104 idleCallback.dispose (); idleCallback = null; | |
3105 idleProc = 0; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3106 if (idleHandle !is null) OS.g_source_remove (idleHandle); |
18 | 3107 idleHandle = 0; |
3108 | |
3109 /* Dispose GtkTreeView callbacks */ | |
3110 treeSelectionCallback.dispose (); treeSelectionCallback = null; | |
3111 treeSelectionProc = 0; | |
3112 cellDataCallback.dispose (); cellDataCallback = null; | |
3113 cellDataProc = 0; | |
3114 | |
3115 /* Dispose the set direction callback */ | |
3116 setDirectionCallback.dispose (); setDirectionCallback = null; | |
3117 setDirectionProc = 0; | |
3118 | |
3119 /* Dispose the set direction callback */ | |
3120 allChildrenCallback.dispose (); allChildrenCallback = null; | |
3121 allChildrenProc = 0; | |
3122 | |
3123 /* Dispose the caret callback */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3124 if (caretId !is null) OS.gtk_timeout_remove (caretId); |
18 | 3125 caretId = 0; |
3126 caretProc = 0; | |
3127 caretCallback.dispose (); | |
3128 caretCallback = null; | |
3129 | |
3130 /* Release closures */ | |
3131 for (int i = 0; i < Widget.LAST_SIGNAL; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3132 if (closures [i] !is null) OS.g_closure_unref (closures [i]); |
18 | 3133 } |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3134 if (shellMapProcClosure !is null) OS.g_closure_unref (shellMapProcClosure); |
18 | 3135 |
3136 /* Dispose the timer callback */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3137 if (timerIds !is null) { |
18 | 3138 for (int i=0; i<timerIds.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3139 if (timerIds [i] !is null) OS.gtk_timeout_remove (timerIds [i]); |
18 | 3140 } |
3141 } | |
3142 timerIds = null; | |
3143 timerList = null; | |
3144 timerProc = 0; | |
3145 timerCallback.dispose (); | |
3146 timerCallback = null; | |
3147 windowTimerProc = 0; | |
3148 windowTimerCallback.dispose (); | |
3149 windowTimerCallback = null; | |
3150 | |
3151 /* Dispose mouse hover callback */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3152 if (mouseHoverId !is null) OS.gtk_timeout_remove (mouseHoverId); |
18 | 3153 mouseHoverId = 0; |
3154 mouseHoverHandle = mouseHoverProc = 0; | |
3155 mouseHoverCallback.dispose (); | |
3156 mouseHoverCallback = null; | |
3157 | |
3158 /* Dispose the default font */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3159 if (systemFont !is null) systemFont.dispose (); |
18 | 3160 systemFont = null; |
3161 | |
3162 /* Dispose the System Images */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3163 if (errorImage !is null) errorImage.dispose(); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3164 if (infoImage !is null) infoImage.dispose(); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3165 if (questionImage !is null) questionImage.dispose(); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3166 if (warningImage !is null) warningImage.dispose(); |
18 | 3167 errorImage = infoImage = questionImage = warningImage = null; |
3168 | |
3169 /* Release the System Cursors */ | |
3170 for (int i = 0; i < cursors.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3171 if (cursors [i] !is null) cursors [i].dispose (); |
18 | 3172 } |
3173 cursors = null; | |
3174 | |
3175 /* Release Acquired Resources */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3176 if (resources !is null) { |
18 | 3177 for (int i=0; i<resources.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3178 if (resources [i] !is null) resources [i].dispose (); |
18 | 3179 } |
3180 resources = null; | |
3181 } | |
3182 | |
3183 /* Release the System Colors */ | |
3184 COLOR_WIDGET_DARK_SHADOW = COLOR_WIDGET_NORMAL_SHADOW = COLOR_WIDGET_LIGHT_SHADOW = | |
3185 COLOR_WIDGET_HIGHLIGHT_SHADOW = COLOR_WIDGET_BACKGROUND = COLOR_WIDGET_BORDER = | |
3186 COLOR_LIST_FOREGROUND = COLOR_LIST_BACKGROUND = COLOR_LIST_SELECTION = COLOR_LIST_SELECTION_TEXT = | |
3187 COLOR_INFO_BACKGROUND = COLOR_INFO_FOREGROUND = null; | |
3188 | |
3189 /* Dispose the event callback */ | |
3190 OS.gdk_event_handler_set (0, 0, 0); | |
3191 eventCallback.dispose (); eventCallback = null; | |
3192 | |
3193 /* Dispose the hidden shell */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3194 if (shellHandle !is null) OS.gtk_widget_destroy (shellHandle); |
18 | 3195 shellHandle = 0; |
3196 | |
3197 /* Dispose the settings callback */ | |
3198 styleSetCallback.dispose(); styleSetCallback = null; | |
3199 styleSetProc = 0; | |
3200 | |
3201 /* Release the sleep resources */ | |
3202 max_priority = timeout = null; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3203 if (fds !is null) OS.g_free (fds); |
18 | 3204 fds = 0; |
3205 | |
3206 /* Release references */ | |
3207 popups = null; | |
3208 thread = null; | |
3209 activeShell = null; | |
3210 lastWidget = null; | |
3211 indexTable = null; | |
3212 widgetTable = null; | |
3213 } | |
3214 | |
3215 /** | |
3216 * Removes the listener from the collection of listeners who will | |
3217 * be notified when an event of the given type occurs anywhere in | |
3218 * a widget. The event type is one of the event constants defined | |
3219 * in class <code>SWT</code>. | |
3220 * | |
3221 * @param eventType the type of event to listen for | |
3222 * @param listener the listener which should no longer be notified when the event occurs | |
3223 * | |
3224 * @exception IllegalArgumentException <ul> | |
3225 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
3226 * </ul> | |
3227 * @exception SWTException <ul> | |
3228 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3229 * </ul> | |
3230 * | |
3231 * @see Listener | |
3232 * @see SWT | |
3233 * @see #addFilter | |
3234 * @see #addListener | |
3235 * | |
3236 * @since 3.0 | |
3237 */ | |
3238 public void removeFilter (int eventType, Listener listener) { | |
3239 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3240 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3241 if (filterTable is null) return; |
18 | 3242 filterTable.unhook (eventType, listener); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3243 if (filterTable.size () is 0) filterTable = null; |
18 | 3244 } |
3245 | |
3246 int /*long*/ removeGdkEvent () { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3247 if (gdkEventCount is 0) return 0; |
18 | 3248 int /*long*/ event = gdkEvents [0]; |
3249 --gdkEventCount; | |
3250 System.arraycopy (gdkEvents, 1, gdkEvents, 0, gdkEventCount); | |
3251 System.arraycopy (gdkEventWidgets, 1, gdkEventWidgets, 0, gdkEventCount); | |
3252 gdkEvents [gdkEventCount] = 0; | |
3253 gdkEventWidgets [gdkEventCount] = null; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3254 if (gdkEventCount is 0) { |
18 | 3255 gdkEvents = null; |
3256 gdkEventWidgets = null; | |
3257 } | |
3258 return event; | |
3259 } | |
3260 | |
3261 void removeIdleProc () { | |
3262 synchronized(idleLock) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3263 if (idleHandle !is null) OS.g_source_remove (idleHandle); |
18 | 3264 idleNeeded = false; |
3265 idleHandle = 0; | |
3266 } | |
3267 } | |
3268 /** | |
3269 * Removes the listener from the collection of listeners who will | |
3270 * be notified when an event of the given type occurs. The event type | |
3271 * is one of the event constants defined in class <code>SWT</code>. | |
3272 * | |
3273 * @param eventType the type of event to listen for | |
3274 * @param listener the listener which should no longer be notified when the event occurs | |
3275 * | |
3276 * @exception IllegalArgumentException <ul> | |
3277 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> | |
3278 * </ul> | |
3279 * @exception SWTException <ul> | |
3280 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3281 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3282 * </ul> | |
3283 * | |
3284 * @see Listener | |
3285 * @see SWT | |
3286 * @see #addListener | |
3287 * | |
3288 * @since 2.0 | |
3289 */ | |
3290 public void removeListener (int eventType, Listener listener) { | |
3291 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3292 if (listener is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3293 if (eventTable is null) return; |
18 | 3294 eventTable.unhook (eventType, listener); |
3295 } | |
3296 | |
3297 void removeMouseHoverTimeout (int /*long*/ handle) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3298 if (handle !is mouseHoverHandle) return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3299 if (mouseHoverId !is null) OS.gtk_timeout_remove (mouseHoverId); |
18 | 3300 mouseHoverId = 0; |
3301 mouseHoverHandle = 0; | |
3302 } | |
3303 | |
3304 void removePopup (Menu menu) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3305 if (popups is null) return; |
18 | 3306 for (int i=0; i<popups.length; i++) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3307 if (popups [i] is menu) { |
18 | 3308 popups [i] = null; |
3309 return; | |
3310 } | |
3311 } | |
3312 } | |
3313 | |
3314 Widget removeWidget (int /*long*/ handle) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3315 if (handle is null) return null; |
18 | 3316 lastWidget = null; |
3317 Widget widget = null; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3318 int index = cast(int)/*64*/ OS.g_object_get_qdata (handle, SWT_OBJECT_INDEX) - 1; |
18 | 3319 if (0 <= index && index < widgetTable.length) { |
3320 widget = widgetTable [index]; | |
3321 widgetTable [index] = null; | |
3322 indexTable [index] = freeSlot; | |
3323 freeSlot = index; | |
3324 OS.g_object_set_qdata (handle, SWT_OBJECT_INDEX, 0); | |
3325 } | |
3326 return widget; | |
3327 } | |
3328 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3329 bool runAsyncMessages (bool all) { |
18 | 3330 return synchronizer.runAsyncMessages (all); |
3331 } | |
3332 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3333 bool runDeferredEvents () { |
18 | 3334 /* |
3335 * Run deferred events. This code is always | |
3336 * called in the Display's thread so it must | |
3337 * be re-enterant but need not be synchronized. | |
3338 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3339 while (eventQueue !is null) { |
18 | 3340 |
3341 /* Take an event off the queue */ | |
3342 Event event = eventQueue [0]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3343 if (event is null) break; |
18 | 3344 int length = eventQueue.length; |
3345 System.arraycopy (eventQueue, 1, eventQueue, 0, --length); | |
3346 eventQueue [length] = null; | |
3347 | |
3348 /* Run the event */ | |
3349 Widget widget = event.widget; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3350 if (widget !is null && !widget.isDisposed ()) { |
18 | 3351 Widget item = event.item; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3352 if (item is null || !item.isDisposed ()) { |
18 | 3353 widget.sendEvent (event); |
3354 } | |
3355 } | |
3356 | |
3357 /* | |
3358 * At this point, the event queue could | |
3359 * be null due to a recursive invokation | |
3360 * when running the event. | |
3361 */ | |
3362 } | |
3363 | |
3364 /* Clear the queue */ | |
3365 eventQueue = null; | |
3366 return true; | |
3367 } | |
3368 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3369 bool runPopups () { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3370 if (popups is null) return false; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3371 bool result = false; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3372 while (popups !is null) { |
18 | 3373 Menu menu = popups [0]; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3374 if (menu is null) break; |
18 | 3375 int length = popups.length; |
3376 System.arraycopy (popups, 1, popups, 0, --length); | |
3377 popups [length] = null; | |
3378 runDeferredEvents (); | |
3379 if (!menu.isDisposed ()) menu._setVisible (true); | |
3380 result = true; | |
3381 } | |
3382 popups = null; | |
3383 return result; | |
3384 } | |
3385 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3386 bool runSettings () { |
18 | 3387 if (!runSettings) return false; |
3388 runSettings = false; | |
3389 saveResources (); | |
3390 initializeSystemColors (); | |
3391 sendEvent (SWT.Settings, null); | |
3392 Shell [] shells = getShells (); | |
3393 for (int i=0; i<shells.length; i++) { | |
3394 Shell shell = shells [i]; | |
3395 if (!shell.isDisposed ()) { | |
3396 shell.fixStyle (); | |
3397 shell.redraw (true); | |
3398 shell.layout (true, true); | |
3399 } | |
3400 } | |
3401 return true; | |
3402 } | |
3403 | |
3404 /** | |
3405 * On platforms which support it, sets the application name | |
3406 * to be the argument. On Motif, for example, this can be used | |
3407 * to set the name used for resource lookup. Specifying | |
3408 * <code>null</code> for the name clears it. | |
3409 * | |
3410 * @param name the new app name or <code>null</code> | |
3411 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3412 public static void setAppName (char[] name) { |
18 | 3413 APP_NAME = name; |
3414 } | |
3415 | |
3416 /** | |
3417 * Sets the location of the on-screen pointer relative to the top left corner | |
3418 * of the screen. <b>Note: It is typically considered bad practice for a | |
3419 * program to move the on-screen pointer location.</b> | |
3420 * | |
3421 * @param x the new x coordinate for the cursor | |
3422 * @param y the new y coordinate for the cursor | |
3423 * | |
3424 * @exception SWTException <ul> | |
3425 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3426 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3427 * </ul> | |
3428 * | |
3429 * @since 2.1 | |
3430 */ | |
3431 public void setCursorLocation (int x, int y) { | |
3432 checkDevice (); | |
3433 if (OS.GDK_WINDOWING_X11 ()) { | |
3434 int /*long*/ xDisplay = OS.GDK_DISPLAY (); | |
3435 int /*long*/ xWindow = OS.XDefaultRootWindow (xDisplay); | |
3436 OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, x, y); | |
3437 } | |
3438 } | |
3439 | |
3440 /** | |
3441 * Sets the location of the on-screen pointer relative to the top left corner | |
3442 * of the screen. <b>Note: It is typically considered bad practice for a | |
3443 * program to move the on-screen pointer location.</b> | |
3444 * | |
3445 * @param point new position | |
3446 * | |
3447 * @exception SWTException <ul> | |
3448 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3449 * <li>ERROR_NULL_ARGUMENT - if the point is null | |
3450 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3451 * </ul> | |
3452 * | |
3453 * @since 2.0 | |
3454 */ | |
3455 public void setCursorLocation (Point point) { | |
3456 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3457 if (point is null) error (SWT.ERROR_NULL_ARGUMENT); |
18 | 3458 setCursorLocation (point.x, point.y); |
3459 } | |
3460 | |
3461 /** | |
3462 * Sets the application defined property of the receiver | |
3463 * with the specified name to the given argument. | |
3464 * <p> | |
3465 * Applications may have associated arbitrary objects with the | |
3466 * receiver in this fashion. If the objects stored in the | |
3467 * properties need to be notified when the display is disposed | |
3468 * of, it is the application's responsibility provide a | |
3469 * <code>disposeExec()</code> handler which does so. | |
3470 * </p> | |
3471 * | |
3472 * @param key the name of the property | |
3473 * @param value the new value for the property | |
3474 * | |
3475 * @exception IllegalArgumentException <ul> | |
3476 * <li>ERROR_NULL_ARGUMENT - if the key is null</li> | |
3477 * </ul> | |
3478 * @exception SWTException <ul> | |
3479 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3480 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3481 * </ul> | |
3482 * | |
3483 * @see #getData(String) | |
3484 * @see #disposeExec(Runnable) | |
3485 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3486 public void setData (char[] key, Object value) { |
18 | 3487 checkDevice (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3488 if (key is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3489 |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3490 if (key==/*eq*/ DISPATCH_EVENT_KEY) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3491 if (value is null || value instanceof int []) { |
18 | 3492 dispatchEvents = (int []) value; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3493 if (value is null) putGdkEvents (); |
18 | 3494 return; |
3495 } | |
3496 } | |
3497 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3498 if (key==/*eq*/ ADD_WIDGET_KEY) { |
18 | 3499 Object [] data = (Object []) value; |
3500 int /*long*/ handle = ((LONG) data [0]).value; | |
3501 Widget widget = (Widget) data [1]; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3502 if (widget !is null) { |
18 | 3503 addWidget (handle, widget); |
3504 } else { | |
3505 removeWidget (handle); | |
3506 } | |
3507 } | |
3508 | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3509 if (key==/*eq*/ ADD_IDLE_PROC_KEY) { |
18 | 3510 addIdleProc (); |
3511 return; | |
3512 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3513 if (key==/*eq*/ REMOVE_IDLE_PROC_KEY) { |
18 | 3514 removeIdleProc (); |
3515 return; | |
3516 } | |
3517 | |
3518 /* Remove the key/value pair */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3519 if (value is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3520 if (keys is null) return; |
18 | 3521 int index = 0; |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3522 while (index < keys.length && !keys [index]==/*eq*/ key) index++; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3523 if (index is keys.length) return; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3524 if (keys.length is 1) { |
18 | 3525 keys = null; |
3526 values = null; | |
3527 } else { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3528 char[] [] newKeys = new char[] [keys.length - 1]; |
18 | 3529 Object [] newValues = new Object [values.length - 1]; |
3530 System.arraycopy (keys, 0, newKeys, 0, index); | |
3531 System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index); | |
3532 System.arraycopy (values, 0, newValues, 0, index); | |
3533 System.arraycopy (values, index + 1, newValues, index, newValues.length - index); | |
3534 keys = newKeys; | |
3535 values = newValues; | |
3536 } | |
3537 return; | |
3538 } | |
3539 | |
3540 /* Add the key/value pair */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3541 if (keys is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3542 keys = new char[] [] {key}; |
18 | 3543 values = new Object [] {value}; |
3544 return; | |
3545 } | |
3546 for (int i=0; i<keys.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3547 if (keys [i]==/*eq*/ key) { |
18 | 3548 values [i] = value; |
3549 return; | |
3550 } | |
3551 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3552 char[] [] newKeys = new char[] [keys.length + 1]; |
18 | 3553 Object [] newValues = new Object [values.length + 1]; |
3554 System.arraycopy (keys, 0, newKeys, 0, keys.length); | |
3555 System.arraycopy (values, 0, newValues, 0, values.length); | |
3556 newKeys [keys.length] = key; | |
3557 newValues [values.length] = value; | |
3558 keys = newKeys; | |
3559 values = newValues; | |
3560 } | |
3561 | |
3562 /** | |
3563 * Sets the application defined, display specific data | |
3564 * associated with the receiver, to the argument. | |
3565 * The <em>display specific data</em> is a single, | |
3566 * unnamed field that is stored with every display. | |
3567 * <p> | |
3568 * Applications may put arbitrary objects in this field. If | |
3569 * the object stored in the display specific data needs to | |
3570 * be notified when the display is disposed of, it is the | |
3571 * application's responsibility provide a | |
3572 * <code>disposeExec()</code> handler which does so. | |
3573 * </p> | |
3574 * | |
3575 * @param data the new display specific data | |
3576 * | |
3577 * @exception SWTException <ul> | |
3578 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3579 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3580 * </ul> | |
3581 * | |
3582 * @see #getData() | |
3583 * @see #disposeExec(Runnable) | |
3584 */ | |
3585 public void setData (Object data) { | |
3586 checkDevice (); | |
3587 this.data = data; | |
3588 } | |
3589 | |
3590 int /*long*/ setDirectionProc (int /*long*/ widget, int /*long*/ direction) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3591 OS.gtk_widget_set_direction (widget, cast(int)/*64*/ direction); |
18 | 3592 if (OS.GTK_IS_CONTAINER (widget)) { |
3593 OS.gtk_container_forall (widget, setDirectionProc, direction); | |
3594 } | |
3595 return 0; | |
3596 } | |
3597 | |
3598 /** | |
3599 * Sets the synchronizer used by the display to be | |
3600 * the argument, which can not be null. | |
3601 * | |
3602 * @param synchronizer the new synchronizer for the display (must not be null) | |
3603 * | |
3604 * @exception IllegalArgumentException <ul> | |
3605 * <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li> | |
3606 * </ul> | |
3607 * @exception SWTException <ul> | |
3608 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3609 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3610 * <li>ERROR_FAILED_EXEC - if an exception occurred while running an inter-thread message</li> | |
3611 * </ul> | |
3612 */ | |
3613 public void setSynchronizer (Synchronizer synchronizer) { | |
3614 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3615 if (synchronizer is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3616 if (this.synchronizer !is null) { |
18 | 3617 this.synchronizer.runAsyncMessages(true); |
3618 } | |
3619 this.synchronizer = synchronizer; | |
3620 } | |
3621 | |
3622 void showIMWindow (Control control) { | |
3623 imControl = control; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3624 if (preeditWindow is null) { |
18 | 3625 preeditWindow = OS.gtk_window_new (OS.GTK_WINDOW_POPUP); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3626 if (preeditWindow is null) error (SWT.ERROR_NO_HANDLES); |
18 | 3627 preeditLabel = OS.gtk_label_new (null); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3628 if (preeditLabel is null) error (SWT.ERROR_NO_HANDLES); |
18 | 3629 OS.gtk_container_add (preeditWindow, preeditLabel); |
3630 OS.gtk_widget_show (preeditLabel); | |
3631 } | |
3632 int /*long*/ [] preeditString = new int /*long*/ [1]; | |
3633 int /*long*/ [] pangoAttrs = new int /*long*/ [1]; | |
3634 int /*long*/ imHandle = control.imHandle (); | |
3635 OS.gtk_im_context_get_preedit_string (imHandle, preeditString, pangoAttrs, null); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3636 if (preeditString [0] !is null && OS.strlen (preeditString [0]) > 0) { |
18 | 3637 Control widget = control.findBackgroundControl (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3638 if (widget is null) widget = control; |
18 | 3639 OS.gtk_widget_modify_bg (preeditWindow, OS.GTK_STATE_NORMAL, widget.getBackgroundColor ()); |
3640 widget.setForegroundColor (preeditLabel, control.getForegroundColor()); | |
3641 OS.gtk_widget_modify_font (preeditLabel, control.getFontDescription ()); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3642 if (pangoAttrs [0] !is null) OS.gtk_label_set_attributes (preeditLabel, pangoAttrs[0]); |
18 | 3643 OS.gtk_label_set_text (preeditLabel, preeditString [0]); |
3644 Point point = control.toDisplay (control.getIMCaretPos ()); | |
3645 OS.gtk_window_move (preeditWindow, point.x, point.y); | |
3646 GtkRequisition requisition = new GtkRequisition (); | |
3647 OS.gtk_widget_size_request (preeditLabel, requisition); | |
3648 OS.gtk_window_resize (preeditWindow, requisition.width, requisition.height); | |
3649 OS.gtk_widget_show (preeditWindow); | |
3650 } else { | |
3651 OS.gtk_widget_hide (preeditWindow); | |
3652 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3653 if (preeditString [0] !is null) OS.g_free (preeditString [0]); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3654 if (pangoAttrs [0] !is null) OS.pango_attr_list_unref (pangoAttrs [0]); |
18 | 3655 } |
3656 | |
3657 /** | |
3658 * Causes the user-interface thread to <em>sleep</em> (that is, | |
3659 * to be put in a state where it does not consume CPU cycles) | |
3660 * until an event is received or it is otherwise awakened. | |
3661 * | |
3662 * @return <code>true</code> if an event requiring dispatching was placed on the queue. | |
3663 * | |
3664 * @exception SWTException <ul> | |
3665 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3666 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3667 * </ul> | |
3668 * | |
3669 * @see #wake | |
3670 */ | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3671 public bool sleep () { |
18 | 3672 checkDevice (); |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3673 if (gdkEventCount is 0) { |
18 | 3674 gdkEvents = null; |
3675 gdkEventWidgets = null; | |
3676 } | |
3677 if (settingsChanged) { | |
3678 settingsChanged = false; | |
3679 runSettings = true; | |
3680 return false; | |
3681 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3682 if (getMessageCount () !is 0) return true; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3683 if (fds is null) { |
18 | 3684 allocated_nfds = 2; |
3685 fds = OS.g_malloc (OS.GPollFD_sizeof () * allocated_nfds); | |
3686 } | |
3687 max_priority [0] = timeout [0] = 0; | |
3688 int /*long*/ context = OS.g_main_context_default (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3689 bool result = false; |
18 | 3690 do { |
3691 if (OS.g_main_context_acquire (context)) { | |
3692 result = OS.g_main_context_prepare (context, max_priority); | |
3693 int nfds; | |
3694 while ((nfds = OS.g_main_context_query (context, max_priority [0], timeout, fds, allocated_nfds)) > allocated_nfds) { | |
3695 OS.g_free (fds); | |
3696 allocated_nfds = nfds; | |
3697 fds = OS.g_malloc (OS.GPollFD_sizeof() * allocated_nfds); | |
3698 } | |
3699 int /*long*/ poll = OS.g_main_context_get_poll_func (context); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3700 if (poll !is null) { |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3701 if (nfds > 0 || timeout [0] !is 0) { |
18 | 3702 /* |
3703 * Bug in GTK. For some reason, g_main_context_wakeup() may | |
3704 * fail to wake up the UI thread from the polling function. | |
3705 * The fix is to sleep for a maximum of 50 milliseconds. | |
3706 */ | |
3707 if (timeout [0] < 0) timeout [0] = 50; | |
3708 | |
3709 /* Exit the OS lock to allow other threads to enter GTK */ | |
3710 Lock lock = OS.lock; | |
3711 int count = lock.lock (); | |
3712 for (int i = 0; i < count; i++) lock.unlock (); | |
3713 try { | |
3714 wake = false; | |
3715 OS.Call (poll, fds, nfds, timeout [0]); | |
3716 } finally { | |
3717 for (int i = 0; i < count; i++) lock.lock (); | |
3718 lock.unlock (); | |
3719 } | |
3720 } | |
3721 } | |
3722 OS.g_main_context_check (context, max_priority [0], fds, nfds); | |
3723 OS.g_main_context_release (context); | |
3724 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3725 } while (!result && getMessageCount () is null && !wake); |
18 | 3726 wake = false; |
3727 return true; | |
3728 } | |
3729 | |
3730 /** | |
3731 * Causes the <code>run()</code> method of the runnable to | |
3732 * be invoked by the user-interface thread after the specified | |
3733 * number of milliseconds have elapsed. If milliseconds is less | |
3734 * than zero, the runnable is not executed. | |
3735 * <p> | |
3736 * Note that at the time the runnable is invoked, widgets | |
3737 * that have the receiver as their display may have been | |
3738 * disposed. Therefore, it is necessary to check for this | |
3739 * case inside the runnable before accessing the widget. | |
3740 * </p> | |
3741 * | |
3742 * @param milliseconds the delay before running the runnable | |
3743 * @param runnable code to run on the user-interface thread | |
3744 * | |
3745 * @exception IllegalArgumentException <ul> | |
3746 * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li> | |
3747 * </ul> | |
3748 * @exception SWTException <ul> | |
3749 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3750 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3751 * </ul> | |
3752 * | |
3753 * @see #asyncExec | |
3754 */ | |
3755 public void timerExec (int milliseconds, Runnable runnable) { | |
3756 checkDevice (); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3757 if (runnable is null) error (SWT.ERROR_NULL_ARGUMENT); |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3758 if (timerList is null) timerList = new Runnable [4]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3759 if (timerIds is null) timerIds = new int [4]; |
18 | 3760 int index = 0; |
3761 while (index < timerList.length) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3762 if (timerList [index] is runnable) break; |
18 | 3763 index++; |
3764 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3765 if (index !is timerList.length) { |
18 | 3766 OS.gtk_timeout_remove (timerIds [index]); |
3767 timerList [index] = null; | |
3768 timerIds [index] = 0; | |
3769 if (milliseconds < 0) return; | |
3770 } else { | |
3771 if (milliseconds < 0) return; | |
3772 index = 0; | |
3773 while (index < timerList.length) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3774 if (timerList [index] is null) break; |
18 | 3775 index++; |
3776 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3777 if (index is timerList.length) { |
18 | 3778 Runnable [] newTimerList = new Runnable [timerList.length + 4]; |
3779 System.arraycopy (timerList, 0, newTimerList, 0, timerList.length); | |
3780 timerList = newTimerList; | |
3781 int [] newTimerIds = new int [timerIds.length + 4]; | |
3782 System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length); | |
3783 timerIds = newTimerIds; | |
3784 } | |
3785 } | |
3786 int timerId = OS.gtk_timeout_add (milliseconds, timerProc, index); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3787 if (timerId !is null) { |
18 | 3788 timerIds [index] = timerId; |
3789 timerList [index] = runnable; | |
3790 } | |
3791 } | |
3792 | |
3793 int /*long*/ timerProc (int /*long*/ i) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3794 if (timerList is null) return 0; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3795 int index = cast(int)/*64*/i; |
18 | 3796 if (0 <= index && index < timerList.length) { |
3797 Runnable runnable = timerList [index]; | |
3798 timerList [index] = null; | |
3799 timerIds [index] = 0; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3800 if (runnable !is null) runnable.run (); |
18 | 3801 } |
3802 return 0; | |
3803 } | |
3804 | |
3805 int /*long*/ caretProc (int /*long*/ clientData) { | |
3806 caretId = 0; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3807 if (currentCaret is null) { |
18 | 3808 return 0; |
3809 } | |
3810 if (currentCaret.blinkCaret()) { | |
3811 int blinkRate = currentCaret.blinkRate; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3812 if (blinkRate is 0) return 0; |
18 | 3813 caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0); |
3814 } else { | |
3815 currentCaret = null; | |
3816 } | |
3817 return 0; | |
3818 } | |
3819 | |
3820 int /*long*/ sizeAllocateProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) { | |
3821 Widget widget = getWidget (user_data); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3822 if (widget is null) return 0; |
18 | 3823 return widget.sizeAllocateProc (handle, arg0, user_data); |
3824 } | |
3825 | |
3826 int /*long*/ sizeRequestProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) { | |
3827 Widget widget = getWidget (user_data); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3828 if (widget is null) return 0; |
18 | 3829 return widget.sizeRequestProc (handle, arg0, user_data); |
3830 } | |
3831 | |
3832 int /*long*/ treeSelectionProc (int /*long*/ model, int /*long*/ path, int /*long*/ iter, int /*long*/ data) { | |
3833 Widget widget = getWidget (data); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3834 if (widget is null) return 0; |
18 | 3835 return widget.treeSelectionProc (model, path, iter, treeSelection, treeSelectionLength++); |
3836 } | |
3837 | |
3838 void saveResources () { | |
3839 int resourceCount = 0; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3840 if (resources is null) { |
18 | 3841 resources = new Resource [RESOURCE_SIZE]; |
3842 } else { | |
3843 resourceCount = resources.length; | |
3844 Resource [] newResources = new Resource [resourceCount + RESOURCE_SIZE]; | |
3845 System.arraycopy (resources, 0, newResources, 0, resourceCount); | |
3846 resources = newResources; | |
3847 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3848 if (systemFont !is null) { |
18 | 3849 resources [resourceCount++] = systemFont; |
3850 systemFont = null; | |
3851 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3852 if (errorImage !is null) resources [resourceCount++] = errorImage; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3853 if (infoImage !is null) resources [resourceCount++] = infoImage; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3854 if (questionImage !is null) resources [resourceCount++] = questionImage; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3855 if (warningImage !is null) resources [resourceCount++] = warningImage; |
18 | 3856 errorImage = infoImage = questionImage = warningImage = null; |
3857 for (int i=0; i<cursors.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3858 if (cursors [i] !is null) resources [resourceCount++] = cursors [i]; |
18 | 3859 cursors [i] = null; |
3860 } | |
3861 if (resourceCount < RESOURCE_SIZE) { | |
3862 Resource [] newResources = new Resource [resourceCount]; | |
3863 System.arraycopy (resources, 0, newResources, 0, resourceCount); | |
3864 resources = newResources; | |
3865 } | |
3866 } | |
3867 | |
3868 void sendEvent (int eventType, Event event) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3869 if (eventTable is null && filterTable is null) { |
18 | 3870 return; |
3871 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3872 if (event is null) event = new Event (); |
18 | 3873 event.display = this; |
3874 event.type = eventType; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3875 if (event.time is 0) event.time = getLastEventTime (); |
18 | 3876 if (!filterEvent (event)) { |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3877 if (eventTable !is null) eventTable.sendEvent (event); |
18 | 3878 } |
3879 } | |
3880 | |
3881 void setCurrentCaret (Caret caret) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3882 if (caretId !is null) OS.gtk_timeout_remove(caretId); |
18 | 3883 caretId = 0; |
3884 currentCaret = caret; | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3885 if (caret is null) return; |
18 | 3886 int blinkRate = currentCaret.blinkRate; |
3887 caretId = OS.gtk_timeout_add (blinkRate, caretProc, 0); | |
3888 } | |
3889 | |
3890 int /*long*/ shellMapProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) { | |
3891 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3892 if (widget is null) return 0; |
18 | 3893 return widget.shellMapProc (handle, arg0, user_data); |
3894 } | |
3895 | |
3896 int /*long*/ styleSetProc (int /*long*/ gobject, int /*long*/ arg1, int /*long*/ user_data) { | |
3897 settingsChanged = true; | |
3898 return 0; | |
3899 } | |
3900 | |
3901 /** | |
3902 * Causes the <code>run()</code> method of the runnable to | |
3903 * be invoked by the user-interface thread at the next | |
3904 * reasonable opportunity. The thread which calls this method | |
3905 * is suspended until the runnable completes. Specifying <code>null</code> | |
3906 * as the runnable simply wakes the user-interface thread. | |
3907 * <p> | |
3908 * Note that at the time the runnable is invoked, widgets | |
3909 * that have the receiver as their display may have been | |
3910 * disposed. Therefore, it is necessary to check for this | |
3911 * case inside the runnable before accessing the widget. | |
3912 * </p> | |
3913 * | |
3914 * @param runnable code to run on the user-interface thread or <code>null</code> | |
3915 * | |
3916 * @exception SWTException <ul> | |
3917 * <li>ERROR_FAILED_EXEC - if an exception occurred when executing the runnable</li> | |
3918 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3919 * </ul> | |
3920 * | |
3921 * @see #asyncExec | |
3922 */ | |
3923 public void syncExec (Runnable runnable) { | |
3924 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); | |
3925 synchronized (idleLock) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3926 if (idleNeeded && idleHandle is null) { |
18 | 3927 //NOTE: calling unlocked function in OS |
3928 idleHandle = OS._g_idle_add (idleProc, 0); | |
3929 } | |
3930 } | |
3931 synchronizer.syncExec (runnable); | |
3932 } | |
3933 | |
3934 static int translateKey (int key) { | |
3935 for (int i=0; i<KeyTable.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3936 if (KeyTable [i] [0] is key) return KeyTable [i] [1]; |
18 | 3937 } |
3938 return 0; | |
3939 } | |
3940 | |
3941 static int untranslateKey (int key) { | |
3942 for (int i=0; i<KeyTable.length; i++) { | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3943 if (KeyTable [i] [1] is key) return KeyTable [i] [0]; |
18 | 3944 } |
3945 return 0; | |
3946 } | |
3947 | |
3948 /** | |
3949 * Forces all outstanding paint requests for the display | |
3950 * to be processed before this method returns. | |
3951 * | |
3952 * @exception SWTException <ul> | |
3953 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
3954 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3955 * </ul> | |
3956 * | |
3957 * @see Control#update() | |
3958 */ | |
3959 public void update () { | |
3960 checkDevice (); | |
3961 flushExposes (0, true); | |
3962 OS.gdk_window_process_all_updates (); | |
3963 } | |
3964 | |
3965 /** | |
3966 * If the receiver's user-interface thread was <code>sleep</code>ing, | |
3967 * causes it to be awakened and start running again. Note that this | |
3968 * method may be called from any thread. | |
3969 * | |
3970 * @exception SWTException <ul> | |
3971 * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> | |
3972 * </ul> | |
3973 * | |
3974 * @see #sleep | |
3975 */ | |
3976 public void wake () { | |
3977 if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3978 if (thread is Thread.currentThread ()) return; |
18 | 3979 wakeThread (); |
3980 } | |
3981 | |
3982 void wakeThread () { | |
3983 OS.g_main_context_wakeup (0); | |
3984 wake = true; | |
3985 } | |
3986 | |
3987 static char wcsToMbcs (char ch) { | |
3988 int key = ch & 0xFFFF; | |
3989 if (key <= 0x7F) return ch; | |
3990 byte [] buffer = Converter.wcsToMbcs (null, new char [] {ch}, false); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3991 if (buffer.length is 1) return (char) buffer [0]; |
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
3992 if (buffer.length is 2) { |
18 | 3993 return (char) (((buffer [0] & 0xFF) << 8) | (buffer [1] & 0xFF)); |
3994 } | |
3995 return 0; | |
3996 } | |
3997 | |
3998 int /*long*/ windowProc (int /*long*/ handle, int /*long*/ user_data) { | |
3999 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
4000 if (widget is null) return 0; |
18 | 4001 return widget.windowProc (handle, user_data); |
4002 } | |
4003 | |
4004 int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ user_data) { | |
4005 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
4006 if (widget is null) return 0; |
18 | 4007 return widget.windowProc (handle, arg0, user_data); |
4008 } | |
4009 | |
4010 int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ user_data) { | |
4011 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
4012 if (widget is null) return 0; |
18 | 4013 return widget.windowProc (handle, arg0, arg1, user_data); |
4014 } | |
4015 | |
4016 int /*long*/ windowProc (int /*long*/ handle, int /*long*/ arg0, int /*long*/ arg1, int /*long*/ arg2, int /*long*/ user_data) { | |
4017 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
4018 if (widget is null) return 0; |
18 | 4019 return widget.windowProc (handle, arg0, arg1, arg2, user_data); |
4020 } | |
4021 | |
4022 int /*long*/ windowTimerProc (int /*long*/ handle) { | |
4023 Widget widget = getWidget (handle); | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
4024 if (widget is null) return 0; |
18 | 4025 return widget.timerProc (handle); |
4026 } | |
4027 | |
4028 } | |
25
fc2b263b8a3f
Merged back the System.arraycopy and use a System class
Frank Benoit <benoit@tionex.de>
parents:
18
diff
changeset
|
4029 ++/ |