/******************************************************************************* * Copyright (c) 2000, 2009 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.gtk.*; import org.eclipse.swt.graphics.*; /** * Instances of this class are responsible for managing the * connection between SWT and the underlying operating * system. Their most important function is to implement * the SWT event loop in terms of the platform event model. * They also provide various methods for accessing information * about the operating system, and have overall control over * the operating system resources which SWT allocates. *
* Applications which are built with SWT will almost always
* require only a single display. In particular, some platforms
* which SWT supports will not allow more than one active
* display. In other words, some platforms do not support
* creating a new display if one already exists that has not been
* sent the dispose()
message.
*
* In SWT, the thread which creates a Display
* instance is distinguished as the user-interface thread
* for that display.
*
Widget
and its subclasses), may only be called
* from the thread. (To support multi-threaded user-interface
* applications, class Display
provides inter-thread
* communication methods which allow threads other than the
* user-interface thread to request that it perform operations
* on their behalf.)
* Display
s until that display has been disposed.
* (Note that, this is in addition to the restriction mentioned
* above concerning platform support for multiple displays. Thus,
* the only way to have multiple simultaneously active displays,
* even on platforms which support it, is to have multiple threads.)
*
* All SWT API methods which may only be called from the user-interface
* thread are distinguished in their documentation by indicating that
* they throw the "ERROR_THREAD_INVALID_ACCESS
"
* SWT exception.
*
* IMPORTANT: This class is not intended to be subclassed. *
* @see #syncExec * @see #asyncExec * @see #wake * @see #readAndDispatch * @see #sleep * @see Device#dispose * @see Display snippets * @see Sample code and further information * @noextend This class is not intended to be subclassed by clients. */ public class Display extends Device { /* Events Dispatching and Callback */ int gdkEventCount; int /*long*/ [] gdkEvents; Widget [] gdkEventWidgets; int [] dispatchEvents; Event [] eventQueue; int /*long*/ fds; int allocated_nfds; boolean wake; int [] max_priority = new int [1], timeout = new int [1]; Callback eventCallback, filterCallback; int /*long*/ eventProc, filterProc, windowProc2, windowProc3, windowProc4, windowProc5; Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5; EventTable eventTable, filterTable; static String APP_NAME = "SWT"; //$NON-NLS-1$ static final String DISPATCH_EVENT_KEY = "org.eclipse.swt.internal.gtk.dispatchEvent"; //$NON-NLS-1$ static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; //$NON-NLS-1$ int /*long*/ [] closures; int [] signalIds; int /*long*/ shellMapProcClosure; /* Widget Table */ int [] indexTable; int freeSlot; int /*long*/ lastHandle; Widget lastWidget; Widget [] widgetTable; final static int GROW_SIZE = 1024; static final int SWT_OBJECT_INDEX; static final int SWT_OBJECT_INDEX1; static final int SWT_OBJECT_INDEX2; static { byte [] buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX", true); //$NON-NLS-1$ SWT_OBJECT_INDEX = OS.g_quark_from_string (buffer); buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX1", true); //$NON-NLS-1$ SWT_OBJECT_INDEX1 = OS.g_quark_from_string (buffer); buffer = Converter.wcsToMbcs (null, "SWT_OBJECT_INDEX2", true); //$NON-NLS-1$ SWT_OBJECT_INDEX2 = OS.g_quark_from_string (buffer); } /* Modality */ Shell [] modalShells; Dialog modalDialog; static final String GET_MODAL_DIALOG = "org.eclipse.swt.internal.gtk.getModalDialog"; //$NON-NLS-1$ static final String SET_MODAL_DIALOG = "org.eclipse.swt.internal.gtk.setModalDialog"; //$NON-NLS-1$ /* Focus */ int focusEvent; Control focusControl; Shell activeShell; boolean activePending; boolean ignoreActivate, ignoreFocus; /* Input method resources */ Control imControl; int /*long*/ preeditWindow, preeditLabel; /* Sync/Async Widget Communication */ Synchronizer synchronizer = new Synchronizer (this); Thread thread; /* Display Shutdown */ Runnable [] disposeList; /* System Tray */ Tray tray; /* Timers */ int [] timerIds; Runnable [] timerList; Callback timerCallback; int /*long*/ timerProc; Callback windowTimerCallback; int /*long*/ windowTimerProc; /* Caret */ Caret currentCaret; Callback caretCallback; int caretId; int /*long*/ caretProc; /* Mnemonics */ Control mnemonicControl; /* Mouse hover */ int mouseHoverId; int /*long*/ mouseHoverHandle, mouseHoverProc; Callback mouseHoverCallback; /* Menu position callback */ int /*long*/ menuPositionProc; Callback menuPositionCallback; /* Tooltip size allocate callback */ int /*long*/ sizeAllocateProc; Callback sizeAllocateCallback; int /*long*/ sizeRequestProc; Callback sizeRequestCallback; /* Shell map callback */ int /*long*/ shellMapProc; Callback shellMapCallback; /* Idle proc callback */ int /*long*/ idleProc; int idleHandle; Callback idleCallback; static final String ADD_IDLE_PROC_KEY = "org.eclipse.swt.internal.gtk.addIdleProc"; //$NON-NLS-1$ static final String REMOVE_IDLE_PROC_KEY = "org.eclipse.swt.internal.gtk.removeIdleProc"; //$NON-NLS-1$ Object idleLock = new Object(); boolean idleNeeded; /* GtkTreeView callbacks */ int[] treeSelection; int treeSelectionLength; int /*long*/ treeSelectionProc; Callback treeSelectionCallback; int /*long*/ cellDataProc; Callback cellDataCallback; /* Set direction callback */ int /*long*/ setDirectionProc; Callback setDirectionCallback; static final String GET_DIRECTION_PROC_KEY = "org.eclipse.swt.internal.gtk.getDirectionProc"; //$NON-NLS-1$ /* Set emissionProc callback */ int /*long*/ emissionProc; Callback emissionProcCallback; static final String GET_EMISSION_PROC_KEY = "org.eclipse.swt.internal.gtk.getEmissionProc"; //$NON-NLS-1$ /* Get all children callback */ int /*long*/ allChildrenProc, allChildren; Callback allChildrenCallback; /* Settings callbacks */ int /*long*/ styleSetProc; Callback styleSetCallback; int /*long*/ shellHandle; boolean settingsChanged, runSettings; /* Entry focus behaviour */ boolean entrySelectOnFocus; /* Enter/Exit events */ Control currentControl; /* Flush exposes */ int /*long*/ checkIfEventProc; Callback checkIfEventCallback; int /*long*/ flushWindow; boolean flushAll; GdkRectangle flushRect = new GdkRectangle (); XExposeEvent exposeEvent = new XExposeEvent (); XVisibilityEvent visibilityEvent = new XVisibilityEvent (); int /*long*/ [] flushData = new int /*long*/ [1]; /* System Resources */ Font systemFont; Image errorImage, infoImage, questionImage, warningImage; Cursor [] cursors = new Cursor [SWT.CURSOR_HAND + 1]; Resource [] resources; static final int RESOURCE_SIZE = 1 + 4 + SWT.CURSOR_HAND + 1; /* Colors */ GdkColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW; GdkColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_FOREGROUND, COLOR_WIDGET_BORDER; GdkColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT; GdkColor COLOR_INFO_BACKGROUND, COLOR_INFO_FOREGROUND; GdkColor COLOR_TITLE_FOREGROUND, COLOR_TITLE_BACKGROUND, COLOR_TITLE_BACKGROUND_GRADIENT; GdkColor COLOR_TITLE_INACTIVE_FOREGROUND, COLOR_TITLE_INACTIVE_BACKGROUND, COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; /* Popup Menus */ Menu [] popups; /* Click count*/ int clickCount = 1; /* Entry inner border */ static final int INNER_BORDER = 2; /* Timestamp of the Last Received Events */ int lastEventTime, lastUserEventTime; /* Pango layout constructor */ int /*long*/ pangoLayoutNewProc, pangoLayoutNewDefaultProc; Callback pangoLayoutNewCallback; /* Fixed Subclass */ static int /*long*/ fixed_type; static int /*long*/ fixed_info_ptr; static Callback fixedClassInitCallback, fixedMapCallback, fixedSizeAllocateCallback; static int /*long*/ fixedClassInitProc, fixedMapProc, fixedSizeAllocateProc, oldFixedSizeAllocateProc; /* Renderer Subclass */ static int /*long*/ text_renderer_type, pixbuf_renderer_type, toggle_renderer_type; static int /*long*/ text_renderer_info_ptr, pixbuf_renderer_info_ptr, toggle_renderer_info_ptr; static Callback rendererClassInitCallback, rendererRenderCallback, rendererGetSizeCallback; static int /*long*/ rendererClassInitProc, rendererRenderProc, rendererGetSizeProc; /* Key Mappings */ static final int [] [] KeyTable = { /* Keyboard and Mouse Masks */ {OS.GDK_Alt_L, SWT.ALT}, {OS.GDK_Alt_R, SWT.ALT}, {OS.GDK_Meta_L, SWT.ALT}, {OS.GDK_Meta_R, SWT.ALT}, {OS.GDK_Shift_L, SWT.SHIFT}, {OS.GDK_Shift_R, SWT.SHIFT}, {OS.GDK_Control_L, SWT.CONTROL}, {OS.GDK_Control_R, SWT.CONTROL}, // {OS.GDK_????, SWT.COMMAND}, // {OS.GDK_????, SWT.COMMAND}, /* Non-Numeric Keypad Keys */ {OS.GDK_Up, SWT.ARROW_UP}, {OS.GDK_KP_Up, SWT.ARROW_UP}, {OS.GDK_Down, SWT.ARROW_DOWN}, {OS.GDK_KP_Down, SWT.ARROW_DOWN}, {OS.GDK_Left, SWT.ARROW_LEFT}, {OS.GDK_KP_Left, SWT.ARROW_LEFT}, {OS.GDK_Right, SWT.ARROW_RIGHT}, {OS.GDK_KP_Right, SWT.ARROW_RIGHT}, {OS.GDK_Page_Up, SWT.PAGE_UP}, {OS.GDK_KP_Page_Up, SWT.PAGE_UP}, {OS.GDK_Page_Down, SWT.PAGE_DOWN}, {OS.GDK_KP_Page_Down, SWT.PAGE_DOWN}, {OS.GDK_Home, SWT.HOME}, {OS.GDK_KP_Home, SWT.HOME}, {OS.GDK_End, SWT.END}, {OS.GDK_KP_End, SWT.END}, {OS.GDK_Insert, SWT.INSERT}, {OS.GDK_KP_Insert, SWT.INSERT}, /* Virtual and Ascii Keys */ {OS.GDK_BackSpace, SWT.BS}, {OS.GDK_Return, SWT.CR}, {OS.GDK_Delete, SWT.DEL}, {OS.GDK_KP_Delete, SWT.DEL}, {OS.GDK_Escape, SWT.ESC}, {OS.GDK_Linefeed, SWT.LF}, {OS.GDK_Tab, SWT.TAB}, {OS.GDK_ISO_Left_Tab, SWT.TAB}, /* Functions Keys */ {OS.GDK_F1, SWT.F1}, {OS.GDK_F2, SWT.F2}, {OS.GDK_F3, SWT.F3}, {OS.GDK_F4, SWT.F4}, {OS.GDK_F5, SWT.F5}, {OS.GDK_F6, SWT.F6}, {OS.GDK_F7, SWT.F7}, {OS.GDK_F8, SWT.F8}, {OS.GDK_F9, SWT.F9}, {OS.GDK_F10, SWT.F10}, {OS.GDK_F11, SWT.F11}, {OS.GDK_F12, SWT.F12}, {OS.GDK_F13, SWT.F13}, {OS.GDK_F14, SWT.F14}, {OS.GDK_F15, SWT.F15}, /* Numeric Keypad Keys */ {OS.GDK_KP_Multiply, SWT.KEYPAD_MULTIPLY}, {OS.GDK_KP_Add, SWT.KEYPAD_ADD}, {OS.GDK_KP_Enter, SWT.KEYPAD_CR}, {OS.GDK_KP_Subtract, SWT.KEYPAD_SUBTRACT}, {OS.GDK_KP_Decimal, SWT.KEYPAD_DECIMAL}, {OS.GDK_KP_Divide, SWT.KEYPAD_DIVIDE}, {OS.GDK_KP_0, SWT.KEYPAD_0}, {OS.GDK_KP_1, SWT.KEYPAD_1}, {OS.GDK_KP_2, SWT.KEYPAD_2}, {OS.GDK_KP_3, SWT.KEYPAD_3}, {OS.GDK_KP_4, SWT.KEYPAD_4}, {OS.GDK_KP_5, SWT.KEYPAD_5}, {OS.GDK_KP_6, SWT.KEYPAD_6}, {OS.GDK_KP_7, SWT.KEYPAD_7}, {OS.GDK_KP_8, SWT.KEYPAD_8}, {OS.GDK_KP_9, SWT.KEYPAD_9}, {OS.GDK_KP_Equal, SWT.KEYPAD_EQUAL}, /* Other keys */ {OS.GDK_Caps_Lock, SWT.CAPS_LOCK}, {OS.GDK_Num_Lock, SWT.NUM_LOCK}, {OS.GDK_Scroll_Lock, SWT.SCROLL_LOCK}, {OS.GDK_Pause, SWT.PAUSE}, {OS.GDK_Break, SWT.BREAK}, {OS.GDK_Print, SWT.PRINT_SCREEN}, {OS.GDK_Help, SWT.HELP}, }; /* Multiple Displays. */ static Display Default; static Display [] Displays = new Display [4]; /* Package name */ static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$ /* This code is intentionally commented. * ".class" can not be used on CLDC. */ // static { // String name = Display.class.getName (); // int index = name.lastIndexOf ('.'); // PACKAGE_NAME = name.substring (0, index + 1); // } /* GTK Version */ static final int MAJOR = 2; static final int MINOR = 2; static final int MICRO = 0; /* Display Data */ Object data; String [] keys; Object [] values; /* Initial Guesses for Shell Trimmings. */ int borderTrimWidth = 4, borderTrimHeight = 4; int resizeTrimWidth = 6, resizeTrimHeight = 6; int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28; int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29; int titleTrimWidth = 0, titleTrimHeight = 23; boolean ignoreTrim; /* Window Manager */ String windowManager; /* * TEMPORARY CODE. Install the runnable that * gets the current display. This code will * be removed in the future. */ static { DeviceFinder = new Runnable () { public void run () { Device device = getCurrent (); if (device == null) { device = getDefault (); } setDevice (device); } }; } /* * TEMPORARY CODE. */ static void setDevice (Device device) { CurrentDevice = device; } /** * Constructs a new instance of this class. ** Note: The resulting display is marked as the current * display. If this is the first display which has been * constructed since the application started, it is also * marked as the default display. *
* * @exception SWTExceptionSWT
. When the event does occur,
* the listener is notified by sending it the handleEvent()
* message.
*
* Setting the type of an event to SWT.None
from
* within the handleEvent()
method can be used to
* change the event type and stop subsequent Java listeners
* from running. Because event filters run before other listeners,
* event filters can both block other listeners and set arbitrary
* fields within an event. For this reason, event filters are both
* powerful and dangerous. They should generally be avoided for
* performance, debugging and code maintenance reasons.
*
SWT
.
* When the event does occur in the display, the listener is notified by
* sending it the handleEvent()
message.
*
* @param eventType the type of event to listen for
* @param listener the listener which should be notified when the event occurs
*
* @exception IllegalArgumentException null
as the
* runnable simply wakes the user-interface thread when run.
* * Note that at the time the runnable is invoked, widgets * that have the receiver as their display may have been * disposed. Therefore, it is necessary to check for this * case inside the runnable before accessing the widget. *
* * @param runnable code to run on the user-interface thread ornull
*
* @exception SWTException Widget.checkSubclass()
.
*
*
* @exception SWTException
* This method is called before init
.
*
release
.
*
* @see Device#dispose
* @see #release
*/
protected void destroy () {
if (this == Default) Default = null;
deregister (this);
destroyDisplay ();
}
void destroyDisplay () {
}
int /*long*/ emissionProc (int /*long*/ ihint, int /*long*/ n_param_values, int /*long*/ param_values, int /*long*/ data) {
if (OS.gtk_widget_get_toplevel (OS.g_value_peek_pointer(param_values)) == data) {
OS.gtk_widget_set_direction (OS.g_value_peek_pointer(param_values), OS.GTK_TEXT_DIR_RTL);
}
return 1;
}
/**
* Returns the display which the given thread is the
* user-interface thread for, or null if the given thread
* is not a user-interface thread for any display. Specifying
* null
as the thread will return null
* for the display.
*
* @param thread the user-interface thread
* @return the display for the given thread
*/
public static Display findDisplay (Thread thread) {
synchronized (Device.class) {
for (int i=0; inull
runnable
* is ignored.
*
* @param runnable code to run at dispose time.
*
* @exception SWTException Widget
subclass which
* represents it in the currently running application, if
* such exists, or null if no matching widget can be found.
* * IMPORTANT: This method should not be called from * application code. The arguments are platform-specific. *
* * @param handle the handle for the widget * @return the SWT widget that the handle represents * * @exception SWTExceptionWidget
subclass which represents
* the handle/id pair in the currently running application,
* if such exists, or null if no matching widget can be found.
* * IMPORTANT: This method should not be called from * application code. The arguments are platform-specific. *
* * @param handle the handle for the widget * @param id the id for the subwidget (usually an item) * @return the SWT widget that the handle/id pair represents * * @exception SWTExceptionWidget
subclass which represents
* the widget/id pair in the currently running application,
* if such exists, or null if no matching widget can be found.
*
* @param widget the widget
* @param id the id for the subwidget (usually an item)
* @return the SWT subwidget (usually an item) that the widget/id pair represents
*
* @exception SWTException Shell
, or null
* if no shell belonging to the currently running application
* is active.
*
* @return the active shell or null
*
* @exception SWTException
* Applications may have associated arbitrary objects with the
* receiver in this fashion. If the objects stored in the
* properties need to be notified when the display is disposed
* of, it is the application's responsibility to provide a
* disposeExec()
handler which does so.
*
* Applications may put arbitrary objects in this field. If
* the object stored in the display specific data needs to
* be notified when the display is disposed of, it is the
* application's responsibility to provide a
* disposeExec()
handler which does so.
*
LEFT
or RIGHT
.
* The button dismissal alignment is the ordering that should be used when positioning the
* default dismissal button for a dialog. For example, in a dialog that contains an OK and
* CANCEL button, on platforms where the button dismissal alignment is LEFT
, the
* button ordering should be OK/CANCEL. When button dismissal alignment is RIGHT
,
* the button ordering should be CANCEL/OK.
*
* @return the button dismissal order
*
* @exception SWTException * Note: This operation is a hint and is not supported on * platforms that do not have this concept. *
* * @return the high contrast mode * * @exception SWTExceptionsyncExec
* or null if no such runnable is currently being invoked by
* the user-interface thread.
* * Note: If a runnable invoked by asyncExec is currently * running, this method will return null. *
* * @return the receiver's sync-interface thread * * @exception SWTExceptionSWT
. Any value other
* than one of the SWT color constants which is passed
* in will result in the color black. This color should
* not be free'd because it was allocated by the system,
* not the application.
*
* @param id the color constant
* @return the matching color
*
* @exception SWTException SWT
. This cursor should
* not be free'd because it was allocated by the system,
* not the application. A value of null
will
* be returned if the supplied constant is not an SWT cursor
* constant.
*
* @param id the SWT cursor constant
* @return the corresponding cursor or null
*
* @exception SWTException SWT
. This image should
* not be free'd because it was allocated by the system,
* not the application. A value of null
will
* be returned either if the supplied constant is not an
* SWT icon constant or if the platform does not define an
* image that corresponds to the constant.
*
* @param id the SWT icon constant
* @return the corresponding image or null
*
* @exception SWTException * Typically, applications which want the default look * should simply not set the font on the widgets they * create. Widgets are always created with the correct * default font for the class of user-interface component * they represent. *
* * @return a font * * @exception SWTExceptionnull
*
* @exception SWTException
* This method is called after create
.
*
* IMPORTANT: This method is not part of the public
* API for Display
. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
*
* IMPORTANT: This method is not part of the public
* API for Display
. It is marked public only so that it
* can be shared within the packages provided by SWT. It is not
* available on all platforms, and should never be called from
* application code.
*
* NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. *
* * @param from the sourceControl
or null
* @param to the destination Control
or null
* @param point to be mapped
* @return point with mapped coordinates
*
* @exception IllegalArgumentException * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. *
* * @param from the sourceControl
or null
* @param to the destination Control
or null
* @param x coordinates to be mapped
* @param y coordinates to be mapped
* @return point with mapped coordinates
*
* @exception IllegalArgumentException * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. *
* * @param from the sourceControl
or null
* @param to the destination Control
or null
* @param rectangle to be mapped
* @return rectangle with mapped coordinates
*
* @exception IllegalArgumentException * NOTE: On right-to-left platforms where the coordinate * systems are mirrored, special care needs to be taken * when mapping coordinates from one control to another * to ensure the result is correctly mirrored. * * Mapping a point that is the origin of a rectangle and * then adding the width and height is not equivalent to * mapping the rectangle. When one control is mirrored * and the other is not, adding the width and height to a * point that was mapped causes the rectangle to extend * in the wrong direction. Mapping the entire rectangle * instead of just one point causes both the origin and * the corner of the rectangle to be mapped. *
* * @param from the sourceControl
or null
* @param to the destination Control
or null
* @param x coordinates to be mapped
* @param y coordinates to be mapped
* @param width coordinates to be mapped
* @param height coordinates to be mapped
* @return rectangle with mapped coordinates
*
* @exception IllegalArgumentException post
is used to generate low level keyboard
* and mouse events. The intent is to enable automated UI
* testing by simulating the input from the user. Most
* SWT applications should never need to call this method.
* * Note that this operation can fail when the operating system * fails to generate the event for any reason. For example, * this can happen when there is no such key or mouse button * or when the system event queue is full. *
** Event Types: *
KeyDown, KeyUp *
The following fields in the Event
apply:
*
Either one of: *
SWT
MouseDown, MouseUp
*The following fields in the Event
apply:
*
MouseMove
*The following fields in the Event
apply:
*
MouseWheel
*The following fields in the Event
apply:
*
true
* if there is potentially more work to do, or false
* if the caller can sleep until another event is placed on
* the event queue.
*
* In addition to checking the system event queue, this method also
* checks if any inter-thread messages (created by syncExec()
* or asyncExec()
) are waiting to be processed, and if
* so handles them before returning.
*
false
if the caller can sleep upon return from this method
*
* @exception SWTException true
when sent the message
* isDisposed()
.
*
* When a device is destroyed, resources that were acquired
* on behalf of the programmer need to be returned to the
* operating system. For example, if the device allocated a
* font to be used as the system font, this font would be
* freed in release
. Also,to assist the garbage
* collector and minimize the amount of memory that is not
* reclaimed when the programmer keeps a reference to a
* disposed device, all fields except the handle are zero'd.
* The handle is needed by destroy
.
*
destroy
.
*
* @see Device#dispose
* @see #destroy
*/
protected void release () {
sendEvent (SWT.Dispose, new Event ());
Shell [] shells = getShells ();
for (int i=0; iSWT
.
*
* @param eventType the type of event to listen for
* @param listener the listener which should no longer be notified when the event occurs
*
* @exception IllegalArgumentException SWT
.
*
* @param eventType the type of event to listen for
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException null
*/
public static void setAppName (String name) {
APP_NAME = name;
}
/**
* Sets the location of the on-screen pointer relative to the top left corner
* of the screen. Note: It is typically considered bad practice for a
* program to move the on-screen pointer location.
*
* @param x the new x coordinate for the cursor
* @param y the new y coordinate for the cursor
*
* @exception SWTException
* Applications may have associated arbitrary objects with the
* receiver in this fashion. If the objects stored in the
* properties need to be notified when the display is disposed
* of, it is the application's responsibility provide a
* disposeExec()
handler which does so.
*
* Applications may put arbitrary objects in this field. If
* the object stored in the display specific data needs to
* be notified when the display is disposed of, it is the
* application's responsibility provide a
* disposeExec()
handler which does so.
*
true
if an event requiring dispatching was placed on the queue.
*
* @exception SWTException run()
method of the runnable to
* be invoked by the user-interface thread after the specified
* number of milliseconds have elapsed. If milliseconds is less
* than zero, the runnable is not executed.
* * Note that at the time the runnable is invoked, widgets * that have the receiver as their display may have been * disposed. Therefore, it is necessary to check for this * case inside the runnable before accessing the widget. *
* * @param milliseconds the delay before running the runnable * @param runnable code to run on the user-interface thread * * @exception IllegalArgumentExceptionnull
* as the runnable simply wakes the user-interface thread.
* * Note that at the time the runnable is invoked, widgets * that have the receiver as their display may have been * disposed. Therefore, it is necessary to check for this * case inside the runnable before accessing the widget. *
* * @param runnable code to run on the user-interface thread ornull
*
* @exception SWTException sleep
ing,
* causes it to be awakened and start running again. Note that this
* method may be called from any thread.
*
* @exception SWTException