
org.eclipse.swt.widgets.Widget Maven / Gradle / Ivy
/******************************************************************************* * Copyright (c) 2000, 2018 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.gtk.*; /** * This class is the abstract superclass of all user interface objects. * Widgets are created, disposed and issue notification to listeners * when events occur which affect them. *
that is associated with * the receiver. **
*- Styles:
*- (none)
*- Events:
*- Dispose
** IMPORTANT: This class is intended to be subclassed only * within the SWT implementation. However, it has not been marked * final to allow those outside of the SWT development team to implement * patched versions of the class in order to get around specific * limitations in advance of when those limitations can be addressed * by the team. Any class built using subclassing to access the internals * of this class will likely fail to compile or run between releases and * may be strongly platform specific. Subclassing should not be attempted * without an intimate and detailed understanding of the workings of the * hierarchy. No support is provided for user-written classes which are * implemented as subclasses of this class. *
* * @see #checkSubclass * @see Sample code and further information */ public abstract class Widget { /** * the handle to the OS resource * (Warning: This field is platform dependent) ** IMPORTANT: This field is not part of the SWT * public API. 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 accessed from application code. *
* * @noreference This field is not intended to be referenced by clients. */ public int /*long*/ handle; int style, state; Display display; EventTable eventTable; Object data; /* Global state flags * * Common code pattern: * & - think of AND as removing. * | - think of OR as adding. * state & ~flag -- Think as "removing flag" * state | flag -- Think as "adding flag" * * state |= flag -- Flag is being added to state. * state &= ~flag -- Flag is being removed from state. * state & flag != 0 -- true if flag is present (think >0 = true) * state & flag == 0 -- true if flag is absent (think 0 = false) * * (state & (flag1 | flag2)) != 0 -- true if either of the flags are present. * (state & (flag1 | flag2)) == 0 -- true if both flag1 & flag2 are absent. */ static final int DISPOSED = 1<<0; static final int CANVAS = 1<<1; static final int KEYED_DATA = 1<<2; static final int HANDLE = 1<<3; static final int DISABLED = 1<<4; static final int MENU = 1<<5; static final int OBSCURED = 1<<6; static final int MOVED = 1<<7; static final int RESIZED = 1<<8; static final int ZERO_WIDTH = 1<<9; static final int ZERO_HEIGHT = 1<<10; static final int HIDDEN = 1<<11; static final int FOREGROUND = 1<<12; static final int BACKGROUND = 1<<13; static final int FONT = 1<<14; static final int PARENT_BACKGROUND = 1<<15; static final int THEME_BACKGROUND = 1<<16; /* A layout was requested on this widget */ static final int LAYOUT_NEEDED = 1<<17; /* The preferred size of a child has changed */ static final int LAYOUT_CHANGED = 1<<18; /* A layout was requested in this widget hierachy */ static final int LAYOUT_CHILD = 1<<19; /* More global state flags */ static final int RELEASED = 1<<20; static final int DISPOSE_SENT = 1<<21; static final int FOREIGN_HANDLE = 1<<22; static final int DRAG_DETECT = 1<<23; /* Notify of the opportunity to skin this widget */ static final int SKIN_NEEDED = 1<<24; /* Should sub-windows be checked when EnterNotify received */ static final int CHECK_SUBWINDOW = 1<<25; /* Bidi "auto" text direction */ static final int HAS_AUTO_DIRECTION = 0; /* Bidi flag and for auto text direction */ static final int AUTO_TEXT_DIRECTION = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; /* Default size for widgets */ static final int DEFAULT_WIDTH = 64; static final int DEFAULT_HEIGHT = 64; /* GTK signals data */ static final int ACTIVATE = 1; static final int BUTTON_PRESS_EVENT = 2; static final int BUTTON_PRESS_EVENT_INVERSE = 3; static final int BUTTON_RELEASE_EVENT = 4; static final int BUTTON_RELEASE_EVENT_INVERSE = 5; static final int CHANGED = 6; static final int CHANGE_VALUE = 7; static final int CLICKED = 8; static final int COMMIT = 9; static final int CONFIGURE_EVENT = 10; static final int DELETE_EVENT = 11; static final int DELETE_RANGE = 12; static final int DELETE_TEXT = 13; static final int ENTER_NOTIFY_EVENT = 14; static final int EVENT = 15; static final int EVENT_AFTER = 16; static final int EXPAND_COLLAPSE_CURSOR_ROW = 17; static final int EXPOSE_EVENT = 18; static final int DRAW = EXPOSE_EVENT; static final int EXPOSE_EVENT_INVERSE = 19; static final int FOCUS = 20; static final int FOCUS_IN_EVENT = 21; static final int FOCUS_OUT_EVENT = 22; static final int GRAB_FOCUS = 23; static final int HIDE = 24; static final int INPUT = 25; static final int INSERT_TEXT = 26; static final int KEY_PRESS_EVENT = 27; static final int KEY_RELEASE_EVENT = 28; static final int LEAVE_NOTIFY_EVENT = 29; static final int MAP = 30; static final int MAP_EVENT = 31; static final int MNEMONIC_ACTIVATE = 32; static final int MOTION_NOTIFY_EVENT = 33; static final int MOTION_NOTIFY_EVENT_INVERSE = 34; static final int MOVE_FOCUS = 35; static final int OUTPUT = 36; static final int POPULATE_POPUP = 37; static final int POPUP_MENU = 38; static final int PREEDIT_CHANGED = 39; static final int REALIZE = 40; static final int ROW_ACTIVATED = 41; static final int SCROLL_CHILD = 42; static final int SCROLL_EVENT = 43; static final int SELECT = 44; static final int SHOW = 45; static final int SHOW_HELP = 46; static final int SIZE_ALLOCATE = 47; static final int STYLE_SET = 48; static final int SWITCH_PAGE = 49; static final int TEST_COLLAPSE_ROW = 50; static final int TEST_EXPAND_ROW = 51; static final int TEXT_BUFFER_INSERT_TEXT = 52; static final int TOGGLED = 53; static final int UNMAP = 54; static final int UNMAP_EVENT = 55; static final int UNREALIZE = 56; static final int VALUE_CHANGED = 57; static final int WINDOW_STATE_EVENT = 59; static final int ACTIVATE_INVERSE = 60; static final int DAY_SELECTED = 61; static final int MONTH_CHANGED = 62; static final int STATUS_ICON_POPUP_MENU = 63; static final int ROW_INSERTED = 64; static final int ROW_DELETED = 65; static final int DAY_SELECTED_DOUBLE_CLICK = 66; static final int ICON_RELEASE = 67; static final int SELECTION_DONE = 68; static final int START_INTERACTIVE_SEARCH = 69; static final int BACKSPACE = 70; static final int BACKSPACE_INVERSE = 71; static final int COPY_CLIPBOARD = 72; static final int COPY_CLIPBOARD_INVERSE = 73; static final int CUT_CLIPBOARD = 74; static final int CUT_CLIPBOARD_INVERSE = 75; static final int PASTE_CLIPBOARD = 76; static final int PASTE_CLIPBOARD_INVERSE = 77; static final int DELETE_FROM_CURSOR = 78; static final int DELETE_FROM_CURSOR_INVERSE = 79; static final int MOVE_CURSOR = 80; static final int MOVE_CURSOR_INVERSE = 81; static final int DIRECTION_CHANGED = 82; static final int CREATE_MENU_PROXY = 83; static final int ROW_HAS_CHILD_TOGGLED = 84; static final int POPPED_UP = 85; static final int LAST_SIGNAL = 86; static final String IS_ACTIVE = "org.eclipse.swt.internal.control.isactive"; //$NON-NLS-1$ static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$ static final String KEY_GTK_CSS = "org.eclipse.swt.internal.gtk.css"; //$NON-NLS-1$ /** * Prevents uninitialized instances from being created outside the package. */ Widget () {} /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. ** The style value is either one of the style constants defined in * class
* * @param parent a widget which will be the parent of the new instance (cannot be null) * @param style the style of widget to construct * * @exception IllegalArgumentExceptionSWT
which is applicable to instances of this * class, or must be built by bitwise OR'ing together * (that is, using theint
"|" operator) two or more * of thoseSWT
style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the parent is null
*- ERROR_INVALID_ARGUMENT - if the parent is disposed
**
* * @see SWT * @see #checkSubclass * @see #getStyle */ public Widget (Widget parent, int style) { checkSubclass (); checkParent (parent); this.style = style; display = parent.display; reskinWidget (); } void _addListener (int eventType, Listener listener) { if (eventTable == null) eventTable = new EventTable (); eventTable.hook (eventType, listener); } /** * Adds the listener to the collection of listeners who will * be notified when an event of the given type occurs. When the * event does occur in the widget, the listener is notified by * sending it the- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
*- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
*handleEvent()
message. The event * type is one of the event constants defined in classSWT
. * * @param eventType the type of event to listen for * @param listener the listener which should be notified when the event occurs * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see Listener * @see SWT * @see #getListeners(int) * @see #removeListener(int, Listener) * @see #notifyListeners */ public void addListener (int eventType, Listener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); _addListener (eventType, listener); } /** * Adds the listener to the collection of listeners who will * be notified when the widget is disposed. When the widget is * disposed, the listener is notified by sending it the *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*widgetDisposed()
message. * * @param listener the listener which should be notified when the receiver is disposed * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see DisposeListener * @see #removeDisposeListener */ public void addDisposeListener (DisposeListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Dispose, typedListener); } int /*long*/ paintWindow () { return 0; } int /*long*/ cssHandle() { return handle; } static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) { int mask = int0 | int1 | int2 | int3 | int4 | int5; if ((style & mask) == 0) style |= int0; if ((style & int0) != 0) style = (style & ~mask) | int0; if ((style & int1) != 0) style = (style & ~mask) | int1; if ((style & int2) != 0) style = (style & ~mask) | int2; if ((style & int3) != 0) style = (style & ~mask) | int3; if ((style & int4) != 0) style = (style & ~mask) | int4; if ((style & int5) != 0) style = (style & ~mask) | int5; return style; } int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*long*/ tree_model, int /*long*/ iter, int /*long*/ data) { return 0; } void checkOpen () { /* Do nothing */ } void checkOrientation (Widget parent) { style &= ~SWT.MIRRORED; if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) { if (parent != null) { if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT; if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT; } } style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0); } /** * Throws an exception if the specified widget can not be * used as a parent for the receiver. * * @exception IllegalArgumentException- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
**
* @exception SWTException- ERROR_NULL_ARGUMENT - if the parent is null
*- ERROR_INVALID_ARGUMENT - if the parent is disposed
**
*/ void checkParent (Widget parent) { if (parent == null) error (SWT.ERROR_NULL_ARGUMENT); if (parent.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); parent.checkWidget (); parent.checkOpen (); } /** * Checks that this class can be subclassed. *- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
** The SWT class library is intended to be subclassed * only at specific, controlled points (most notably, *
Composite
andCanvas
when * implementing new widgets). This method enforces this * rule unless it is overridden. ** IMPORTANT: By providing an implementation of this * method that allows a subclass of a class which does not * normally allow subclassing to be created, the implementer * agrees to be fully responsible for the fact that any such * subclass will likely fail between SWT releases and will be * strongly platform specific. No support is provided for * user-written classes which are implemented in this fashion. *
* The ability to subclass outside of the allowed SWT classes * is intended purely to enable those not on the SWT development * team to implement patches in order to get around specific * limitations in advance of when those limitations can be * addressed by the team. Subclassing should not be attempted * without an intimate and detailed understanding of the hierarchy. *
* * @exception SWTException*
*/ protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } /** * Throws an- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
*SWTException
if the receiver can not * be accessed by the caller. This may include both checks on * the state of the receiver and more generally on the entire * execution context. This method should be called by * widget implementors to enforce the standard SWT invariants. ** Currently, it is an error to invoke any method (other than *
isDisposed()
) on a widget that has had its *dispose()
method called. It is also an error * to call widget methods from any thread that is different * from the thread that created the widget. ** In future releases of SWT, there may be more or fewer error * checks and exceptions may be thrown for different reasons. *
* * @exception SWTException*
*/ protected void checkWidget () { Display display = this.display; if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED); } void createHandle (int index) { } void createWidget (int index) { createHandle (index); setOrientation (true); hookEvents (); register (); } void deregister () { if (handle == 0) return; if ((state & HANDLE) != 0) display.removeWidget (handle); } void destroyWidget () { int /*long*/ topHandle = topHandle (); releaseHandle (); if (topHandle != 0 && (state & HANDLE) != 0) { GTK.gtk_widget_destroy (topHandle); } } /** * Disposes of the operating system resources associated with * the receiver and all its descendants. After this method has * been invoked, the receiver and all descendants will answer *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*true
when sent the messageisDisposed()
. * Any internal connections between the widgets in the tree will * have been removed to facilitate garbage collection. * This method does nothing if the widget is already disposed. ** NOTE: This method is not called recursively on the descendants * of the receiver. This means that, widget implementers can not * detect when a widget is being disposed of by re-implementing * this method, but should instead listen for the
* * @exception SWTExceptionDispose
* event. **
* * @see #addDisposeListener * @see #removeDisposeListener * @see #checkWidget */ public void dispose () { /* * Note: It is valid to attempt to dispose a widget * more than once. If this happens, fail silently. */ if (isDisposed ()) return; if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); release (true); } void error (int code) { SWT.error (code); } /** * Returns the application defined widget data associated * with the receiver, or null if it has not been set. The * widget data is a single, unnamed field that is * stored with every widget. *- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Applications may put arbitrary objects in this field. If * the object stored in the widget data needs to be notified * when the widget is disposed of, it is the application's * responsibility to hook the Dispose event on the widget and * do so. *
* * @return the widget data * * @exception SWTException*
* * @see #setData(Object) */ public Object getData () { checkWidget(); return (state & KEYED_DATA) != 0 ? ((Object []) data) [0] : data; } /** * Returns the application defined property of the receiver * with the specified name, or null if it has not been set. *- ERROR_WIDGET_DISPOSED - when the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread
** 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 widget is disposed * of, it is the application's responsibility to hook the * Dispose event on the widget and do so. *
* * @param key the name of the property * @return the value of the property or null if it has not been set * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the key is null
**
* * @see #setData(String, Object) */ public Object getData (String key) { checkWidget(); if (key == null) error (SWT.ERROR_NULL_ARGUMENT); if (key.equals (KEY_CHECK_SUBWINDOW)) { return new Boolean ((state & CHECK_SUBWINDOW) != 0); } if (key.equals(IS_ACTIVE)) return Boolean.valueOf(isActive ()); if ((state & KEYED_DATA) != 0) { Object [] table = (Object []) data; for (int i=1; i- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*Display * A widget's display is either provided when it is created * (for example, top level
* * @return the receiver's display * * @exception SWTExceptionShell
s) or is the * same as its parent's display. *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
SWT
.
*
* @param eventType the type of event to listen for
* @return an array of listeners that will be notified when the event occurs
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note that the value which is returned by this method may
* not match the value which was provided to the constructor
* when the receiver was created. This can occur when the underlying
* operating system does not support a particular combination of
* requested styles. For example, if the platform widget used to
* implement a particular SWT widget always has scroll bars, the
* result of calling this method would always have the
* SWT.H_SCROLL
and SWT.V_SCROLL
bits set.
*
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
GTK3.22+ has API which allows clients of GTK to connect a menu to the "popped-up" signal. * This callback is triggered after the menu is popped up/shown to the user, and provides * information about the actual position and size of the menu, as shown to the user.
* *SWT clients can enable this functionality by launching their application with the * SWT_MENU_LOCATION_DEBUGGING environment variable set to 1. If enabled, the previously mentioned * positioning and size information will be printed to the console. The information comes from GTK * internals and is stored in the method parameters.
* * @param widget the memory address of the menu which was popped up * @param flipped_rect a pointer to the GdkRectangle containing the flipped location and size of the menu * @param final_rect a pointer to the GdkRectangle containing the final (after all internal adjustments) * location and size of the menu * @param flipped_x a boolean flag indicating whether the menu has been inverted along the X-axis * @param flipped_y a boolean flag indicating whether the menu has been inverted along the Y-axis */ int /*long*/ gtk_menu_popped_up (int /*long*/ widget, int /*long*/ flipped_rect, int /*long*/ final_rect, int /*long*/ flipped_x, int /*long*/ flipped_y) { return 0; } int /*long*/ gtk_mnemonic_activate (int /*long*/ widget, int /*long*/ arg1) { return 0; } int /*long*/ gtk_month_changed (int /*long*/ widget) { return 0; } int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ event) { return 0; } int /*long*/ gtk_move_focus (int /*long*/ widget, int /*long*/ event) { return 0; } int /*long*/ gtk_output (int /*long*/ widget) { return 0; } int /*long*/ gtk_populate_popup (int /*long*/ widget, int /*long*/ menu) { return 0; } int /*long*/ gtk_popup_menu (int /*long*/ widget) { return 0; } int /*long*/ gtk_preedit_changed (int /*long*/ imcontext) { return 0; } int /*long*/ gtk_realize (int /*long*/ widget) { return 0; } int /*long*/ gtk_row_activated (int /*long*/ tree, int /*long*/ path, int /*long*/ column) { return 0; // Note on SWT Tree/Table/List. This signal is no longer used for sending events, instead // Send DefaultSelection is manually emitted. We use this function to know whether a // 'row-activated' is triggered. See Bug 312568, 518414. } int /*long*/ gtk_row_deleted (int /*long*/ model, int /*long*/ path) { return 0; } int /*long*/ gtk_row_inserted (int /*long*/ model, int /*long*/ path, int /*long*/ iter) { return 0; } int /*long*/ gtk_row_has_child_toggled (int /*long*/ model, int /*long*/ path, int /*long*/ iter) { return 0; } int /*long*/ gtk_scroll_child (int /*long*/ widget, int /*long*/ scrollType, int /*long*/ horizontal) { return 0; } int /*long*/ gtk_scroll_event (int /*long*/ widget, int /*long*/ event) { return 0; } int /*long*/ gtk_select (int /*long*/ item) { return 0; } int /*long*/ gtk_selection_done (int /*long*/ menushell) { return 0; } int /*long*/ gtk_show (int /*long*/ widget) { return 0; } int /*long*/ gtk_show_help (int /*long*/ widget, int /*long*/ helpType) { return 0; } int /*long*/ gtk_size_allocate (int /*long*/ widget, int /*long*/ allocation) { return 0; } int /*long*/ gtk_status_icon_popup_menu (int /*long*/ handle, int /*long*/ button, int /*long*/ activate_time) { return 0; } int /*long*/ gtk_start_interactive_search (int /*long*/ widget) { return 0; } int /*long*/ gtk_style_set (int /*long*/ widget, int /*long*/ previousStyle) { return 0; } int /*long*/ gtk_switch_page (int /*long*/ widget, int /*long*/ page, int /*long*/ page_num) { return 0; } int /*long*/ gtk_test_collapse_row (int /*long*/ tree, int /*long*/ iter, int /*long*/ path) { return 0; } int /*long*/ gtk_test_expand_row (int /*long*/ tree, int /*long*/ iter, int /*long*/ path) { return 0; } int /*long*/ gtk_text_buffer_insert_text (int /*long*/ widget, int /*long*/ iter, int /*long*/ text, int /*long*/ length) { return 0; } int /*long*/ gtk_timer () { return 0; } int /*long*/ gtk_toggled (int /*long*/ renderer, int /*long*/ pathStr) { return 0; } /* * Bug 498165: gtk_tree_view_column_cell_get_position() sets off rendererGetPreferredWidthCallback in GTK3 which is an issue * if there is an ongoing MeasureEvent listener. Disabling it and re-enabling the callback after the method is called * prevents a stack overflow from occurring. */ boolean gtk_tree_view_column_cell_get_position (int /*long*/ column, int /*long*/ cell_renderer, int[] start_pos, int[] width) { if (GTK.GTK3) { Callback.setEnabled(false); boolean result = GTK.gtk_tree_view_column_cell_get_position (column, cell_renderer, start_pos, width); Callback.setEnabled(true); return result; } else { return GTK.gtk_tree_view_column_cell_get_position (column, cell_renderer, start_pos, width); } } int /*long*/ gtk_unmap (int /*long*/ widget) { return 0; } int /*long*/ gtk_unmap_event (int /*long*/ widget, int /*long*/ event) { return 0; } int /*long*/ gtk_unrealize (int /*long*/ widget) { return 0; } int /*long*/ gtk_value_changed (int /*long*/ adjustment) { return 0; } int /*long*/ gtk_window_state_event (int /*long*/ widget, int /*long*/ event) { return 0; } int fontHeight (int /*long*/ font, int /*long*/ widgetHandle) { int /*long*/ context = GTK.gtk_widget_get_pango_context (widgetHandle); int /*long*/ lang = OS.pango_context_get_language (context); int /*long*/ metrics = OS.pango_context_get_metrics (context, font, lang); int ascent = OS.pango_font_metrics_get_ascent (metrics); int descent = OS.pango_font_metrics_get_descent (metrics); OS.pango_font_metrics_unref (metrics); return OS.PANGO_PIXELS (ascent + descent); } int /*long*/ filterProc(int /*long*/ xEvent, int /*long*/ gdkEvent, int /*long*/ data2) { return 0; } boolean filters (int eventType) { return display.filters (eventType); } int /*long*/ fixedMapProc (int /*long*/ widget) { return 0; } int /*long*/ fixedSizeAllocateProc(int /*long*/ widget, int /*long*/ allocationPtr) { return OS.Call (Display.oldFixedSizeAllocateProc, widget, allocationPtr); } char [] fixMnemonic (String string) { return fixMnemonic (string, true); } char [] fixMnemonic (String string, boolean replace) { int length = string.length (); char [] text = new char [length]; string.getChars (0, length, text, 0); int i = 0, j = 0; char [] result = new char [length * 2]; while (i < length) { switch (text [i]) { case '&': if (i + 1 < length && text [i + 1] == '&') { result [j++] = text [i++]; } else { if (replace) result [j++] = '_'; } i++; break; case '_': if (replace) result [j++] = '_'; //FALL THROUGH default: result [j++] = text [i++]; } } return result; } boolean isActive () { return true; } /** * Returnstrue
if the widget has auto text direction,
* and false
otherwise.
*
* @return true
when the widget has auto direction and false
otherwise
*
* @see SWT#AUTO_TEXT_DIRECTION
*
* @since 3.105
*/
public boolean isAutoDirection () {
return false;
}
/**
* Returns true
if the widget has been disposed,
* and false
otherwise.
* * This method gets the dispose state for the widget. * When a widget has been disposed, it is an error to * invoke any other method (except {@link #dispose()}) using the widget. *
* * @returntrue
when the widget is disposed and false
otherwise
*/
public boolean isDisposed () {
return (state & DISPOSED) != 0;
}
/**
* Returns true
if there are any listeners
* for the specified event type associated with the receiver,
* and false
otherwise. The event type is one of
* the event constants defined in class SWT
.
*
* @param eventType the type of event
* @return true if the event is hooked
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
true
if the specified eventType is
* hooked, and false
otherwise. Implementations
* of SWT can avoid creating objects and sending events
* when an event happens in the operating system but
* there are no listeners hooked for the event.
*
* @param eventType the event to be checked
*
* @return true
when the eventType is hooked and false
otherwise
*
* @see #isListening
*/
boolean hooks (int eventType) {
if (eventTable == null) return false;
return eventTable.hooks (eventType);
}
int /*long*/ hoverProc (int /*long*/ widget) {
return 0;
}
boolean mnemonicHit (int /*long*/ mnemonicHandle, char key) {
if (!mnemonicMatch (mnemonicHandle, key)) return false;
OS.g_signal_handlers_block_matched (mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, MNEMONIC_ACTIVATE);
boolean result = GTK.gtk_widget_mnemonic_activate (mnemonicHandle, false);
OS.g_signal_handlers_unblock_matched (mnemonicHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, MNEMONIC_ACTIVATE);
return result;
}
boolean mnemonicMatch (int /*long*/ mnemonicHandle, char key) {
long keyval1 = GDK.gdk_keyval_to_lower (GDK.gdk_unicode_to_keyval (key));
long keyval2 = GDK.gdk_keyval_to_lower (GTK.gtk_label_get_mnemonic_keyval (mnemonicHandle));
return keyval1 == keyval2;
}
void modifyStyle (int /*long*/ handle, int /*long*/ style) {
GTK.gtk_widget_modify_style (handle, style);
}
/**
* Notifies all of the receiver's listeners for events
* of the given type that one such event has occurred by
* invoking their handleEvent()
method. The
* event type is one of the event constants defined in class
* SWT
.
*
* @param eventType the type of event which has occurred
* @param event the event data
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
SWT
.
*
* @param eventType the type of event to listen for
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException -
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* IMPORTANT: This method is not part of the SWT * public API. It is marked public only so that it can be shared * within the packages provided by SWT. It should never be * referenced from application code. *
* * @param eventType the type of event to listen for * @param listener the listener which should no longer be notified * * @exception IllegalArgumentException-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* The skin event is sent to the receiver's display when appropriate (usually before the next event
* is handled). Widgets are automatically marked for skinning upon creation as well as when its skin
* id or class changes. The skin id and/or class can be changed by calling {@link Display#setData(String, Object)}
* with the keys {@link SWT#SKIN_ID} and/or {@link SWT#SKIN_CLASS}. Once the skin event is sent to a widget, it
* will not be sent again unless reskin(int)
is called on the widget or on an ancestor
* while specifying the SWT.ALL
flag.
*
* The parameter flags
may be either:
*
-
*
- {@link SWT#ALL} *
- all children in the receiver's widget tree should be skinned *
- {@link SWT#NONE} *
- only the receiver should be skinned *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Applications may put arbitrary objects in this field. If * the object stored in the widget data needs to be notified * when the widget is disposed of, it is the application's * responsibility to hook the Dispose event on the widget and * do so. *
* * @param data the widget data * * @exception SWTException-
*
- ERROR_WIDGET_DISPOSED - when the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread *
* Applications may associate arbitrary objects with the * receiver in this fashion. If the objects stored in the * properties need to be notified when the widget is disposed * of, it is the application's responsibility to hook the * Dispose event on the widget and do so. *
* * @param key the name of the property * @param value the new value for the property * * @exception IllegalArgumentException-
*
- ERROR_NULL_ARGUMENT - if the key is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *