org.eclipse.swt.widgets.Control Maven / Gradle / Ivy
Show all versions of org.eclipse.swt.gtk.linux.ppc64 Show documentation
/******************************************************************************* * Copyright (c) 2000, 2012 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.accessibility.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cairo.*; import org.eclipse.swt.internal.gtk.*; /** * Control is the abstract superclass of all windowed user interface classes. *
if the receiver is enabled and all * ancestors up to and including the receiver's nearest ancestor * shell are enabled. Otherwise,*
*
*- Styles: *
- BORDER
*- LEFT_TO_RIGHT, RIGHT_TO_LEFT, FLIP_TEXT_DIRECTION
*- Events: *
- DragDetect, FocusIn, FocusOut, Help, KeyDown, KeyUp, MenuDetect, MouseDoubleClick, MouseDown, MouseEnter, * MouseExit, MouseHover, MouseUp, MouseMove, MouseWheel, MouseHorizontalWheel, MouseVerticalWheel, Move, * Paint, Resize, Traverse
** Only one of LEFT_TO_RIGHT or RIGHT_TO_LEFT may be specified. *
* IMPORTANT: This class is intended to be subclassed only * within the SWT implementation. *
* * @see Control snippets * @see SWT Example: ControlExample * @see Sample code and further information * @noextend This class is not intended to be subclassed by clients. */ public abstract class Control extends Widget implements Drawable { long /*int*/ fixedHandle; long /*int*/ redrawWindow, enableWindow, provider; int drawCount; Composite parent; Cursor cursor; Menu menu; Image backgroundImage; Font font; Region region; String toolTipText; Object layoutData; Accessible accessible; Control labelRelation; Control () { } /** * 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 composite control which will be the parent of the new instance (cannot be null) * @param style the style of control 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
**
* * @see SWT#BORDER * @see SWT#LEFT_TO_RIGHT * @see SWT#RIGHT_TO_LEFT * @see Widget#checkSubclass * @see Widget#getStyle */ public Control (Composite parent, int style) { super (parent, style); this.parent = parent; createWidget (0); } Font defaultFont () { return display.getSystemFont (); } void deregister () { super.deregister (); if (fixedHandle != 0) display.removeWidget (fixedHandle); long /*int*/ imHandle = imHandle (); if (imHandle != 0) display.removeWidget (imHandle); } void drawBackground (Control control, long /*int*/ window, long /*int*/ region, int x, int y, int width, int height) { drawBackground(control, window, 0, region, x, y, width, height); } void drawBackground (Control control, long /*int*/ window, long /*int*/ cr, long /*int*/ region, int x, int y, int width, int height) { if (OS.USE_CAIRO) { long /*int*/ cairo = cr != 0 ? cr : OS.gdk_cairo_create(window); if (cairo == 0) error (SWT.ERROR_NO_HANDLES); if (region != 0) { OS.gdk_cairo_region(cairo, region); Cairo.cairo_clip(cairo); } if (control.backgroundImage != null) { Point pt = display.map (this, control, 0, 0); Cairo.cairo_translate (cairo, -pt.x, -pt.y); x += pt.x; y += pt.y; long /*int*/ pattern = Cairo.cairo_pattern_create_for_surface (control.backgroundImage.surface); if (pattern == 0) error (SWT.ERROR_NO_HANDLES); Cairo.cairo_pattern_set_extend (pattern, Cairo.CAIRO_EXTEND_REPEAT); if ((style & SWT.MIRRORED) != 0) { double[] matrix = {-1, 0, 0, 1, 0, 0}; Cairo.cairo_pattern_set_matrix(pattern, matrix); } Cairo.cairo_set_source (cairo, pattern); Cairo.cairo_pattern_destroy (pattern); } else { GdkColor color = control.getBackgroundColor (); Cairo.cairo_set_source_rgba (cairo, (color.red & 0xFFFF) / (float)0xFFFF, (color.green & 0xFFFF) / (float)0xFFFF, (color.blue & 0xFFFF) / (float)0xFFFF, 1); } Cairo.cairo_rectangle (cairo, x, y, width, height); Cairo.cairo_fill (cairo); if (cairo != cr) Cairo.cairo_destroy(cairo); return; } long /*int*/ gdkGC = OS.gdk_gc_new (window); if (region != 0) OS.gdk_gc_set_clip_region (gdkGC, region); if (control.backgroundImage != null) { Point pt = display.map (this, control, 0, 0); OS.gdk_gc_set_fill (gdkGC, OS.GDK_TILED); OS.gdk_gc_set_ts_origin (gdkGC, -pt.x, -pt.y); OS.gdk_gc_set_tile (gdkGC, control.backgroundImage.pixmap); OS.gdk_draw_rectangle (window, gdkGC, 1, x, y, width, height); } else { GdkColor color = control.getBackgroundColor (); OS.gdk_gc_set_foreground (gdkGC, color); OS.gdk_draw_rectangle (window, gdkGC, 1, x, y, width, height); } OS.g_object_unref (gdkGC); } boolean drawGripper (GC gc, int x, int y, int width, int height, boolean vertical) { long /*int*/ paintHandle = paintHandle (); long /*int*/ window = gtk_widget_get_window (paintHandle); if (window == 0) return false; int orientation = vertical ? OS.GTK_ORIENTATION_HORIZONTAL : OS.GTK_ORIENTATION_VERTICAL; if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - width - x; if (OS.GTK3) { long /*int*/ context = OS.gtk_widget_get_style_context (paintHandle); OS.gtk_style_context_save (context); OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_PANE_SEPARATOR); OS.gtk_style_context_set_state (context, OS.GTK_STATE_FLAG_NORMAL); OS.gtk_render_handle (context, gc.handle, x, y, width, height); OS.gtk_style_context_restore (context); } else { OS.gtk_paint_handle (OS.gtk_widget_get_style (paintHandle), window, OS.GTK_STATE_NORMAL, OS.GTK_SHADOW_OUT, null, paintHandle, new byte [1], x, y, width, height, orientation); } return true; } void drawWidget (GC gc) { } void enableWidget (boolean enabled) { OS.gtk_widget_set_sensitive (handle, enabled); } long /*int*/ enterExitHandle () { return eventHandle (); } long /*int*/ eventHandle () { return handle; } long /*int*/ eventWindow () { long /*int*/ eventHandle = eventHandle (); OS.gtk_widget_realize (eventHandle); return gtk_widget_get_window (eventHandle); } void fixFocus (Control focusControl) { Shell shell = getShell (); Control control = this; while (control != shell && (control = control.parent) != null) { if (control.setFocus ()) return; } shell.setSavedFocus (focusControl); long /*int*/ focusHandle = shell.vboxHandle; gtk_widget_set_can_focus (focusHandle, true); OS.gtk_widget_grab_focus (focusHandle); // widget could be disposed at this point if (isDisposed ()) return; gtk_widget_set_can_focus (focusHandle, false); } void fixStyle () { if (fixedHandle != 0) fixStyle (fixedHandle); } void fixStyle (long /*int*/ handle) { /* * Feature in GTK. Some GTK themes apply a different background to * the contents of a GtkNotebook. However, in an SWT TabFolder, the * children are not parented below the GtkNotebook widget, and usually * have their own GtkFixed. The fix is to look up the correct style * for a child of a GtkNotebook and apply its background to any GtkFixed * widgets that are direct children of an SWT TabFolder. * * Note that this has to be when the theme settings changes and that it * should not override the application background. */ if ((state & BACKGROUND) != 0) return; if ((state & THEME_BACKGROUND) == 0) return; if (!OS.GTK3) { long /*int*/ childStyle = parent.childStyle (); if (childStyle != 0) { GdkColor color = new GdkColor(); OS.gtk_style_get_bg (childStyle, 0, color); setBackgroundColor (color); } } } long /*int*/ focusHandle () { return handle; } long /*int*/ fontHandle () { return handle; } /** * Returns the orientation of the receiver, which will be one of the * constants- 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
*SWT.LEFT_TO_RIGHT
orSWT.RIGHT_TO_LEFT
. * * @return the orientation style * * @exception SWTException*
* * @since 3.7 */ public int getOrientation () { checkWidget(); return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); } /** * Returns the text direction of the receiver, which will be one of the * constants- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*SWT.LEFT_TO_RIGHT
orSWT.RIGHT_TO_LEFT
. * * @return the text direction style * * @exception SWTException*
* * @since 3.102 */ public int getTextDirection() { checkWidget (); /* return the widget orientation */ return style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); } boolean hasFocus () { return this == display.getFocusControl(); } void hookEvents () { /* Connect the keyboard signals */ long /*int*/ focusHandle = focusHandle (); int focusMask = OS.GDK_KEY_PRESS_MASK | OS.GDK_KEY_RELEASE_MASK | OS.GDK_FOCUS_CHANGE_MASK; OS.gtk_widget_add_events (focusHandle, focusMask); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [POPUP_MENU], 0, display.closures [POPUP_MENU], false); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [SHOW_HELP], 0, display.closures [SHOW_HELP], false); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_PRESS_EVENT], 0, display.closures [KEY_PRESS_EVENT], false); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [KEY_RELEASE_EVENT], 0, display.closures [KEY_RELEASE_EVENT], false); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS], 0, display.closures [FOCUS], false); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_IN_EVENT], 0, display.closures [FOCUS_IN_EVENT], false); OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [FOCUS_OUT_EVENT], 0, display.closures [FOCUS_OUT_EVENT], false); /* Connect the mouse signals */ long /*int*/ eventHandle = eventHandle (); int eventMask = OS.GDK_POINTER_MOTION_MASK | OS.GDK_BUTTON_PRESS_MASK | OS.GDK_BUTTON_RELEASE_MASK | OS.GDK_SCROLL_MASK | OS.GDK_SMOOTH_SCROLL_MASK; OS.gtk_widget_add_events (eventHandle, eventMask); OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT], false); OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT], false); OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT], false); OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [SCROLL_EVENT], 0, display.closures [SCROLL_EVENT], false); /* Connect enter/exit signals */ long /*int*/ enterExitHandle = enterExitHandle (); int enterExitMask = OS.GDK_ENTER_NOTIFY_MASK | OS.GDK_LEAVE_NOTIFY_MASK; OS.gtk_widget_add_events (enterExitHandle, enterExitMask); OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [ENTER_NOTIFY_EVENT], 0, display.closures [ENTER_NOTIFY_EVENT], false); OS.g_signal_connect_closure_by_id (enterExitHandle, display.signalIds [LEAVE_NOTIFY_EVENT], 0, display.closures [LEAVE_NOTIFY_EVENT], false); /* * Feature in GTK. Events such as mouse move are propagate up * the widget hierarchy and are seen by the parent. This is the * correct GTK behavior but not correct for SWT. The fix is to * hook a signal after and stop the propagation using a negative * event number to distinguish this case. * * The signal is hooked to the fixedHandle to catch events sent to * lightweight widgets. */ long /*int*/ blockHandle = fixedHandle != 0 ? fixedHandle : eventHandle; OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_PRESS_EVENT], 0, display.closures [BUTTON_PRESS_EVENT_INVERSE], true); OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [BUTTON_RELEASE_EVENT], 0, display.closures [BUTTON_RELEASE_EVENT_INVERSE], true); OS.g_signal_connect_closure_by_id (blockHandle, display.signalIds [MOTION_NOTIFY_EVENT], 0, display.closures [MOTION_NOTIFY_EVENT_INVERSE], true); /* Connect the event_after signal for both key and mouse */ OS.g_signal_connect_closure_by_id (eventHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); if (focusHandle != eventHandle) { OS.g_signal_connect_closure_by_id (focusHandle, display.signalIds [EVENT_AFTER], 0, display.closures [EVENT_AFTER], false); } /* Connect the paint signal */ long /*int*/ paintHandle = paintHandle (); int paintMask = OS.GDK_EXPOSURE_MASK | OS.GDK_VISIBILITY_NOTIFY_MASK; OS.gtk_widget_add_events (paintHandle, paintMask); OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT_INVERSE], false); /* * As of GTK 2.17.11, obscured controls no longer send expose * events. It is no longer necessary to track visiblity notify * events. */ if (OS.GTK_VERSION < OS.VERSION (2, 17, 11)) { OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [VISIBILITY_NOTIFY_EVENT], 0, display.closures [VISIBILITY_NOTIFY_EVENT], false); } OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [EXPOSE_EVENT], 0, display.closures [EXPOSE_EVENT], true); /* Connect the Input Method signals */ OS.g_signal_connect_closure_by_id (handle, display.signalIds [REALIZE], 0, display.closures [REALIZE], true); OS.g_signal_connect_closure_by_id (handle, display.signalIds [UNREALIZE], 0, display.closures [UNREALIZE], false); long /*int*/ imHandle = imHandle (); if (imHandle != 0) { OS.g_signal_connect_closure (imHandle, OS.commit, display.closures [COMMIT], false); OS.g_signal_connect_closure (imHandle, OS.preedit_changed, display.closures [PREEDIT_CHANGED], false); } OS.g_signal_connect_closure_by_id (paintHandle, display.signalIds [STYLE_SET], 0, display.closures [STYLE_SET], false); long /*int*/ topHandle = topHandle (); OS.g_signal_connect_closure_by_id (topHandle, display.signalIds [MAP], 0, display.closures [MAP], true); } boolean hooksPaint () { return hooks (SWT.Paint) || filters (SWT.Paint); } long /*int*/ hoverProc (long /*int*/ widget) { int [] x = new int [1], y = new int [1], mask = new int [1]; gdk_window_get_device_position (0, x, y, mask); sendMouseEvent (SWT.MouseHover, 0, /*time*/0, x [0], y [0], false, mask [0]); /* Always return zero in order to cancel the hover timer */ return 0; } long /*int*/ topHandle() { if (fixedHandle != 0) return fixedHandle; return super.topHandle (); } long /*int*/ paintHandle () { long /*int*/ topHandle = topHandle (); long /*int*/ paintHandle = handle; while (paintHandle != topHandle) { if (gtk_widget_get_has_window (paintHandle)) break; paintHandle = OS.gtk_widget_get_parent (paintHandle); } return paintHandle; } long /*int*/ paintWindow () { long /*int*/ paintHandle = paintHandle (); OS.gtk_widget_realize (paintHandle); return gtk_widget_get_window (paintHandle); } /** * Prints the receiver and all children. * * @param gc the gc where the drawing occurs * @return- 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 operation was successful andfalse
otherwise * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the gc is null
*- ERROR_INVALID_ARGUMENT - if the gc has been disposed
**
* * @since 3.4 */ public boolean print (GC gc) { checkWidget (); if (gc == null) error (SWT.ERROR_NULL_ARGUMENT); if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); long /*int*/ topHandle = topHandle (); OS.gtk_widget_realize (topHandle); if (OS.GTK3) { OS.gtk_widget_draw(topHandle, gc.handle); return true; } long /*int*/ window = gtk_widget_get_window (topHandle); GCData data = gc.getGCData (); OS.gdk_window_process_updates (window, true); long /*int*/ drawable = data.drawable; if (drawable == 0) drawable = OS.gdk_get_default_root_window(); printWidget (gc, drawable, OS.gdk_drawable_get_depth (drawable), 0, 0); return true; } void printWidget (GC gc, long /*int*/ drawable, int depth, int x, int y) { boolean obscured = (state & OBSCURED) != 0; state &= ~OBSCURED; long /*int*/ topHandle = topHandle (); long /*int*/ window = gtk_widget_get_window (topHandle); printWindow (true, this, gc, drawable, depth, window, x, y); if (obscured) state |= OBSCURED; } void printWindow (boolean first, Control control, GC gc, long /*int*/ drawable, int depth, long /*int*/ window, int x, int y) { if (OS.gdk_drawable_get_depth (window) != depth) return; GdkRectangle rect = new GdkRectangle (); int [] width = new int [1], height = new int [1]; gdk_window_get_size (window, width, height); rect.width = width [0]; rect.height = height [0]; OS.gdk_window_begin_paint_rect (window, rect); long /*int*/ [] real_drawable = new long /*int*/ [1]; int [] x_offset = new int [1], y_offset = new int [1]; OS.gdk_window_get_internal_paint_info (window, real_drawable, x_offset, y_offset); long /*int*/ [] userData = new long /*int*/ [1]; OS.gdk_window_get_user_data (window, userData); if (userData [0] != 0) { long /*int*/ eventPtr = OS.gdk_event_new (OS.GDK_EXPOSE); GdkEventExpose event = new GdkEventExpose (); event.type = OS.GDK_EXPOSE; event.window = OS.g_object_ref (window); event.area_width = rect.width; event.area_height = rect.height; event.region = OS.gdk_region_rectangle (rect); OS.memmove (eventPtr, event, GdkEventExpose.sizeof); OS.gtk_widget_send_expose (userData [0], eventPtr); OS.gdk_event_free (eventPtr); } int srcX = x_offset [0], srcY = y_offset [0]; int destX = x, destY = y, destWidth = width [0], destHeight = height [0]; if (!first) { int [] cX = new int [1], cY = new int [1]; OS.gdk_window_get_position (window, cX, cY); long /*int*/ parentWindow = OS.gdk_window_get_parent (window); int [] pW = new int [1], pH = new int [1]; gdk_window_get_size (parentWindow, pW, pH); srcX = x_offset [0] - cX [0]; srcY = y_offset [0] - cY [0]; destX = x - cX [0]; destY = y - cY [0]; destWidth = Math.min (cX [0] + width [0], pW [0]); destHeight = Math.min (cY [0] + height [0], pH [0]); } GCData gcData = gc.getGCData(); long /*int*/ cairo = gcData.cairo; if (cairo != 0) { long /*int*/ xDisplay = OS.gdk_x11_display_get_xdisplay(OS.gdk_display_get_default()); long /*int*/ xVisual = OS.gdk_x11_visual_get_xvisual(OS.gdk_visual_get_system()); long /*int*/ xDrawable = OS.GDK_PIXMAP_XID(real_drawable [0]); long /*int*/ surface = Cairo.cairo_xlib_surface_create(xDisplay, xDrawable, xVisual, width [0], height [0]); if (surface == 0) error(SWT.ERROR_NO_HANDLES); Cairo.cairo_save(cairo); Cairo.cairo_rectangle(cairo, destX , destY, destWidth, destHeight); Cairo.cairo_clip(cairo); Cairo.cairo_translate(cairo, destX, destY); long /*int*/ pattern = Cairo.cairo_pattern_create_for_surface(surface); if (pattern == 0) error(SWT.ERROR_NO_HANDLES); Cairo.cairo_pattern_set_filter(pattern, Cairo.CAIRO_FILTER_BEST); Cairo.cairo_set_source(cairo, pattern); if (gcData.alpha != 0xFF) { Cairo.cairo_paint_with_alpha(cairo, gcData.alpha / (float)0xFF); } else { Cairo.cairo_paint(cairo); } Cairo.cairo_restore(cairo); Cairo.cairo_pattern_destroy(pattern); Cairo.cairo_surface_destroy(surface); } else { OS.gdk_draw_drawable (drawable, gc.handle, real_drawable [0], srcX, srcY, destX, destY, destWidth, destHeight); } OS.gdk_window_end_paint (window); long /*int*/ children = OS.gdk_window_get_children (window); if (children != 0) { long /*int*/ windows = children; while (windows != 0) { long /*int*/ child = OS.g_list_data (windows); if (OS.gdk_window_is_visible (child)) { long /*int*/ [] data = new long /*int*/ [1]; OS.gdk_window_get_user_data (child, data); if (data [0] != 0) { Widget widget = display.findWidget (data [0]); if (widget == null || widget == control) { int [] x_pos = new int [1], y_pos = new int [1]; OS.gdk_window_get_position (child, x_pos, y_pos); printWindow (false, control, gc, drawable, depth, child, x + x_pos [0], y + y_pos [0]); } } } windows = OS.g_list_next (windows); } OS.g_list_free (children); } } /** * Returns the preferred size of the receiver. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** The preferred size of a control is the size that it would * best be displayed at. The width hint and height hint arguments * allow the caller to ask a control questions such as "Given a particular * width, how high does the control need to be to show all of the contents?" * To indicate that the caller does not wish to constrain a particular * dimension, the constant
* * @param wHint the width hint (can beSWT.DEFAULT
is passed for the hint. *SWT.DEFAULT
) * @param hHint the height hint (can beSWT.DEFAULT
) * @return the preferred size of the control * * @exception SWTException*
* * @see Layout * @see #getBorderWidth * @see #getBounds * @see #getSize * @see #pack(boolean) * @see "computeTrim, getClientArea for controls that implement them" */ public Point computeSize (int wHint, int hHint) { return computeSize (wHint, hHint, true); } Widget computeTabGroup () { if (isTabGroup()) return this; return parent.computeTabGroup (); } Widget[] computeTabList() { if (isTabGroup()) { if (getVisible() && getEnabled()) { return new Widget[] {this}; } } return new Widget[0]; } Control computeTabRoot () { Control[] tabList = parent._getTabList(); if (tabList != null) { int index = 0; while (index < tabList.length) { if (tabList [index] == this) break; index++; } if (index == tabList.length) { if (isTabGroup ()) return this; } } return parent.computeTabRoot (); } void checkBuffered () { style |= SWT.DOUBLE_BUFFERED; } void checkBackground () { Shell shell = getShell (); if (this == shell) return; state &= ~PARENT_BACKGROUND; Composite composite = parent; do { int mode = composite.backgroundMode; if (mode != SWT.INHERIT_NONE) { if (mode == SWT.INHERIT_DEFAULT) { Control control = this; do { if ((control.state & THEME_BACKGROUND) == 0) { return; } control = control.parent; } while (control != composite); } state |= PARENT_BACKGROUND; return; } if (composite == shell) break; composite = composite.parent; } while (true); } void checkForeground () { /* * Feature in GTK 3. The widget foreground is inherited from the immediate * parent. This is not the expected behavior for SWT. The fix is to avoid * the inheritance by explicitly setting the default foreground on the widget. */ if (OS.GTK3) { setForegroundColor (topHandle (), display.COLOR_WIDGET_FOREGROUND); } } void checkBorder () { if (getBorderWidth () == 0) style &= ~SWT.BORDER; } void checkMirrored () { if ((style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.MIRRORED; } long /*int*/ childStyle () { return parent.childStyle (); } void createWidget (int index) { state |= DRAG_DETECT; checkOrientation (parent); super.createWidget (index); checkBackground (); checkForeground (); if ((state & PARENT_BACKGROUND) != 0) setParentBackground (); checkBuffered (); showWidget (); setInitialBounds (); setZOrder (null, false, false); setRelations (); checkMirrored (); checkBorder (); } /** * Returns the preferred size of the receiver. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** The preferred size of a control is the size that it would * best be displayed at. The width hint and height hint arguments * allow the caller to ask a control questions such as "Given a particular * width, how high does the control need to be to show all of the contents?" * To indicate that the caller does not wish to constrain a particular * dimension, the constant
SWT.DEFAULT
is passed for the hint. ** If the changed flag is
* * @param wHint the width hint (can betrue
, it indicates that the receiver's * contents have changed, therefore any caches that a layout manager * containing the control may have been keeping need to be flushed. When the * control is resized, the changed flag will befalse
, so layout * manager caches can be retained. *SWT.DEFAULT
) * @param hHint the height hint (can beSWT.DEFAULT
) * @param changedtrue
if the control's contents have changed, andfalse
otherwise * @return the preferred size of the control. * * @exception SWTException*
* * @see Layout * @see #getBorderWidth * @see #getBounds * @see #getSize * @see #pack(boolean) * @see "computeTrim, getClientArea for controls that implement them" */ public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget(); if (wHint != SWT.DEFAULT && wHint < 0) wHint = 0; if (hHint != SWT.DEFAULT && hHint < 0) hHint = 0; return computeNativeSize (handle, wHint, hHint, changed); } Point computeNativeSize (long /*int*/ h, int wHint, int hHint, boolean changed) { int width = wHint, height = hHint; if (OS.GTK3){ if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { GtkRequisition requisition = new GtkRequisition (); OS.gtk_widget_get_preferred_size (h, requisition, null); width = requisition.width; height = requisition.height; } else if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) { int [] minimum_size = new int [1]; if (wHint == SWT.DEFAULT) { OS.gtk_widget_get_preferred_width_for_height (h, height, minimum_size, null); width = minimum_size [0]; } else { OS.gtk_widget_get_preferred_height_for_width (h, width, minimum_size, null); height = minimum_size [0]; } } return new Point(width, height); } if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { GtkRequisition requisition = new GtkRequisition (); gtk_widget_size_request (h, requisition); width = OS.GTK_WIDGET_REQUISITION_WIDTH (h); height = OS.GTK_WIDGET_REQUISITION_HEIGHT (h); } else if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) { int [] reqWidth = new int [1], reqHeight = new int [1]; OS.gtk_widget_get_size_request (h, reqWidth, reqHeight); OS.gtk_widget_set_size_request (h, wHint, hHint); GtkRequisition requisition = new GtkRequisition (); gtk_widget_size_request (h, requisition); OS.gtk_widget_set_size_request (h, reqWidth [0], reqHeight [0]); width = wHint == SWT.DEFAULT ? requisition.width : wHint; height = hHint == SWT.DEFAULT ? requisition.height : hHint; } return new Point (width, height); } void forceResize () { /* * Force size allocation on all children of this widget's * topHandle. Note that all calls to gtk_widget_size_allocate() * must be preceded by a call to gtk_widget_size_request(). */ long /*int*/ topHandle = topHandle (); GtkRequisition requisition = new GtkRequisition (); gtk_widget_size_request (topHandle, requisition); GtkAllocation allocation = new GtkAllocation (); gtk_widget_get_allocation(topHandle, allocation); OS.gtk_widget_size_allocate (topHandle, allocation); } /** * Returns the accessible object for the receiver. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** If this is the first time this object is requested, * then the object is created and returned. The object * returned by getAccessible() does not need to be disposed. *
* * @return the accessible object * * @exception SWTException*
* * @see Accessible#addAccessibleListener * @see Accessible#addAccessibleControlListener * * @since 2.0 */ public Accessible getAccessible () { checkWidget (); return _getAccessible (); } Accessible _getAccessible () { if (accessible == null) { accessible = Accessible.internal_new_Accessible (this); } return accessible; } /** * Returns a rectangle describing the receiver's size and location * relative to its parent (or its display if its parent is null), * unless the receiver is a shell. In this case, the location is * relative to the display. * * @return the receiver's bounding rectangle * * @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
**
*/ public Rectangle getBounds () { checkWidget(); long /*int*/ topHandle = topHandle (); GtkAllocation allocation = new GtkAllocation (); gtk_widget_get_allocation (topHandle, allocation); int x = allocation.x; int y = allocation.y; int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; int height = (state & ZERO_HEIGHT) != 0 ? 0 :allocation.height; if ((parent.style & SWT.MIRRORED) != 0) x = parent.getClientWidth () - width - x; return new Rectangle (x, y, width, height); } /** * Sets the receiver's size and location to the rectangular * area specified by the argument. The- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*x
and *y
fields of the rectangle are relative to * the receiver's parent (or its display if its parent is null). ** Note: Attempting to set the width or height of the * receiver to a negative number will cause that * value to be set to zero instead. *
* * @param rect the new bounds for the receiver * * @exception SWTException*
*/ public void setBounds (Rectangle rect) { checkWidget (); if (rect == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (rect.x, rect.y, Math.max (0, rect.width), Math.max (0, rect.height), true, true); } /** * Sets the receiver's size and location to the rectangular * area specified by the arguments. The- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*x
and *y
arguments are relative to the receiver's * parent (or its display if its parent is null), unless * the receiver is a shell. In this case, thex
* andy
arguments are relative to the display. ** Note: Attempting to set the width or height of the * receiver to a negative number will cause that * value to be set to zero instead. *
* * @param x the new x coordinate for the receiver * @param y the new y coordinate for the receiver * @param width the new width for the receiver * @param height the new height for the receiver * * @exception SWTException*
*/ public void setBounds (int x, int y, int width, int height) { checkWidget(); setBounds (x, y, Math.max (0, width), Math.max (0, height), true, true); } void markLayout (boolean changed, boolean all) { /* Do nothing */ } void modifyStyle (long /*int*/ handle, long /*int*/ style) { super.modifyStyle(handle, style); /* * Bug in GTK. When changing the style of a control that * has had a region set on it, the region is lost. The * fix is to set the region again. */ if (region != null) OS.gdk_window_shape_combine_region (gtk_widget_get_window (topHandle ()), region.handle, 0, 0); } void moveHandle (int x, int y) { long /*int*/ topHandle = topHandle (); long /*int*/ parentHandle = parent.parentingHandle (); if (OS.GTK3) { OS.swt_fixed_move (parentHandle, topHandle, x, y); } else { /* * Feature in GTK. Calling gtk_fixed_move() to move a child causes * the whole parent to redraw. This is a performance problem. The * fix is temporarily mark the parent not visible during the move. * * NOTE: Because every widget in SWT has an X window, the new and * old bounds of the child are correctly redrawn. * * NOTE: There is no API in GTK 3 to only set the GTK_VISIBLE bit. */ boolean reset = gtk_widget_get_visible (parentHandle); gtk_widget_set_visible (parentHandle, false); OS.gtk_fixed_move (parentHandle, topHandle, x, y); gtk_widget_set_visible (parentHandle, reset); } } void resizeHandle (int width, int height) { long /*int*/ topHandle = topHandle (); if (OS.GTK3) { OS.swt_fixed_resize (OS.gtk_widget_get_parent (topHandle), topHandle, width, height); if (topHandle != handle) { OS.swt_fixed_resize (OS.gtk_widget_get_parent (handle), handle, width, height); } } else { OS.gtk_widget_set_size_request (topHandle, width, height); if (topHandle != handle) OS.gtk_widget_set_size_request (handle, width, height); } } int setBounds (int x, int y, int width, int height, boolean move, boolean resize) { long /*int*/ topHandle = topHandle (); boolean sendMove = move; GtkAllocation allocation = new GtkAllocation (); gtk_widget_get_allocation (topHandle, allocation); if ((parent.style & SWT.MIRRORED) != 0) { int clientWidth = parent.getClientWidth (); int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; int oldX = clientWidth - oldWidth - allocation.x; if (move) { sendMove &= x != oldX; x = clientWidth - (resize ? width : oldWidth) - x; } else { move = true; x = clientWidth - (resize ? width : oldWidth) - oldX; y = allocation.y; } } boolean sameOrigin = true, sameExtent = true; if (move) { int oldX = allocation.x; int oldY = allocation.y; sameOrigin = x == oldX && y == oldY; if (!sameOrigin) { if (enableWindow != 0) { OS.gdk_window_move (enableWindow, x, y); } moveHandle (x, y); } } int clientWidth = 0; if (resize) { int oldWidth = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; int oldHeight = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; sameExtent = width == oldWidth && height == oldHeight; if (!sameExtent && (style & SWT.MIRRORED) != 0) clientWidth = getClientWidth (); if (!sameExtent && !(width == 0 && height == 0)) { int newWidth = Math.max (1, width); int newHeight = Math.max (1, height); if (redrawWindow != 0) { OS.gdk_window_resize (redrawWindow, newWidth, newHeight); } if (enableWindow != 0) { OS.gdk_window_resize (enableWindow, newWidth, newHeight); } resizeHandle (newWidth, newHeight); } } if (!sameOrigin || !sameExtent) { /* * Cause a size allocation this widget's topHandle. Note that * all calls to gtk_widget_size_allocate() must be preceded by * a call to gtk_widget_size_request(). */ GtkRequisition requisition = new GtkRequisition (); gtk_widget_size_request (topHandle, requisition); if (move) { allocation.x = x; allocation.y = y; } if (resize) { allocation.width = width; allocation.height = height; } OS.gtk_widget_size_allocate (topHandle, allocation); } /* * Bug in GTK. Widgets cannot be sized smaller than 1x1. * The fix is to hide zero-sized widgets and show them again * when they are resized larger. */ if (!sameExtent) { state = (width == 0) ? state | ZERO_WIDTH : state & ~ZERO_WIDTH; state = (height == 0) ? state | ZERO_HEIGHT : state & ~ZERO_HEIGHT; if ((state & (ZERO_WIDTH | ZERO_HEIGHT)) != 0) { if (enableWindow != 0) { OS.gdk_window_hide (enableWindow); } OS.gtk_widget_hide (topHandle); } else { if ((state & HIDDEN) == 0) { if (enableWindow != 0) { OS.gdk_window_show_unraised (enableWindow); } OS.gtk_widget_show (topHandle); } } if ((style & SWT.MIRRORED) != 0) moveChildren (clientWidth); } int result = 0; if (move && !sameOrigin) { Control control = findBackgroundControl (); if (control != null && control.backgroundImage != null) { if (isVisible ()) redrawWidget (0, 0, 0, 0, true, true, true); } if (sendMove) sendEvent (SWT.Move); result |= MOVED; } if (resize && !sameExtent) { sendEvent (SWT.Resize); result |= RESIZED; } return result; } /** * Returns a point describing the receiver's location relative * to its parent (or its display if its parent is null), unless * the receiver is a shell. In this case, the point is * relative to the display. * * @return the receiver's location * * @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
**
*/ public Point getLocation () { checkWidget(); long /*int*/ topHandle = topHandle (); GtkAllocation allocation = new GtkAllocation (); gtk_widget_get_allocation (topHandle, allocation); int x = allocation.x; int y = allocation.y; if ((parent.style & SWT.MIRRORED) != 0) { int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; x = parent.getClientWidth () - width - x; } return new Point (x, y); } /** * Sets the receiver's location to the point specified by * the arguments which are relative to the receiver's * parent (or its display if its parent is null), unless * the receiver is a shell. In this case, the point is * relative to the display. * * @param location the new location for the receiver * * @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
**
*/ public void setLocation (Point location) { checkWidget (); if (location == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (location.x, location.y, 0, 0, true, false); } /** * Sets the receiver's location to the point specified by * the arguments which are relative to the receiver's * parent (or its display if its parent is null), unless * the receiver is a shell. In this case, the point is * relative to the display. * * @param x the new x coordinate for the receiver * @param y the new y coordinate for the receiver * * @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
**
*/ public void setLocation(int x, int y) { checkWidget(); setBounds (x, y, 0, 0, true, false); } /** * Returns a point describing the receiver's size. The * x coordinate of the result is the width of the receiver. * The y coordinate of the result is the height of the * receiver. * * @return the receiver's size * * @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
**
*/ public Point getSize () { checkWidget(); long /*int*/ topHandle = topHandle (); GtkAllocation allocation = new GtkAllocation (); gtk_widget_get_allocation (topHandle, allocation); int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width; int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height; return new Point (width, height); } /** * Sets the receiver's size to the point specified by the argument. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Note: Attempting to set the width or height of the * receiver to a negative number will cause them to be * set to zero instead. *
* * @param size the new size for the receiver * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the point is null
**
*/ public void setSize (Point size) { checkWidget (); if (size == null) error (SWT.ERROR_NULL_ARGUMENT); setBounds (0, 0, Math.max (0, size.x), Math.max (0, size.y), false, true); } /** * Sets the shape of the control to the region specified * by the argument. When the argument is null, the * default shape of the control is restored. * * @param region the region that defines the shape of the control (or null) * * @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_INVALID_ARGUMENT - if the region has been disposed
**
* * @since 3.4 */ public void setRegion (Region region) { checkWidget (); if (region != null && region.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT); long /*int*/ window = gtk_widget_get_window (topHandle ()); long /*int*/ shape_region = (region == null) ? 0 : region.handle; OS.gdk_window_shape_combine_region (window, shape_region, 0, 0); this.region = region; } void setRelations () { long /*int*/ parentHandle = parent.parentingHandle (); long /*int*/ list = OS.gtk_container_get_children (parentHandle); if (list == 0) return; int count = OS.g_list_length (list); if (count > 1) { /* * the receiver is the last item in the list, so its predecessor will * be the second-last item in the list */ long /*int*/ handle = OS.g_list_nth_data (list, count - 2); if (handle != 0) { Widget widget = display.getWidget (handle); if (widget != null && widget != this) { if (widget instanceof Control) { Control sibling = (Control)widget; sibling.addRelation (this); } } } } OS.g_list_free (list); } /** * Sets the receiver's size to the point specified by the arguments. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Note: Attempting to set the width or height of the * receiver to a negative number will cause that * value to be set to zero instead. *
* * @param width the new width for the receiver * @param height the new height for the receiver * * @exception SWTException*
*/ public void setSize (int width, int height) { checkWidget(); setBounds (0, 0, Math.max (0, width), Math.max (0, height), false, true); } boolean isActive () { return getShell ().getModalShell () == null && display.getModalDialog () == null; } /* * Answers a boolean indicating whether a Label that precedes the receiver in * a layout should be read by screen readers as the recevier's label. */ boolean isDescribedByLabel () { return true; } boolean isFocusHandle (long /*int*/ widget) { return widget == focusHandle (); } /** * Moves the receiver above the specified control in the * drawing order. If the argument is null, then the receiver * is moved to the top of the drawing order. The control at * the top of the drawing order will not be covered by other * controls even if they occupy intersecting areas. * * @param control the sibling control (or null) * * @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_INVALID_ARGUMENT - if the control has been disposed
**
* * @see Control#moveBelow * @see Composite#getChildren */ public void moveAbove (Control control) { checkWidget(); if (control != null) { if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); if (parent != control.parent) return; if (this == control) return; } setZOrder (control, true, true); } /** * Moves the receiver below the specified control in the * drawing order. If the argument is null, then the receiver * is moved to the bottom of the drawing order. The control at * the bottom of the drawing order will be covered by all other * controls which occupy intersecting areas. * * @param control the sibling control (or null) * * @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_INVALID_ARGUMENT - if the control has been disposed
**
* * @see Control#moveAbove * @see Composite#getChildren */ public void moveBelow (Control control) { checkWidget(); if (control != null) { if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT); if (parent != control.parent) return; if (this == control) return; } setZOrder (control, false, true); } void moveChildren (int oldWidth) { } /** * Causes the receiver to be resized to its preferred size. * For a composite, this involves computing the preferred size * from its layout, if there is one. * * @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
**
* * @see #computeSize(int, int, boolean) */ public void pack () { pack (true); } /** * Causes the receiver to be resized to its preferred size. * For a composite, this involves computing the preferred size * from its layout, if there is one. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** If the changed flag is
* * @param changed whether or not the receiver's contents have changed * * @exception SWTExceptiontrue
, it indicates that the receiver's * contents have changed, therefore any caches that a layout manager * containing the control may have been keeping need to be flushed. When the * control is resized, the changed flag will befalse
, so layout * manager caches can be retained. **
* * @see #computeSize(int, int, boolean) */ public void pack (boolean changed) { setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed)); } /** * Sets the layout data associated with the receiver to the argument. * * @param layoutData the new layout data for the receiver. * * @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
**
*/ public void setLayoutData (Object layoutData) { checkWidget(); this.layoutData = layoutData; } /** * Returns a point which is the result of converting the * argument, which is specified in display relative coordinates, * to coordinates relative to the receiver. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** @param x the x coordinate to be translated * @param y the y coordinate to be translated * @return the translated coordinates * * @exception SWTException
*
* * @since 2.1 */ public Point toControl (int x, int y) { checkWidget (); long /*int*/ window = eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; OS.gdk_window_get_origin (window, origin_x, origin_y); x -= origin_x [0]; y -= origin_y [0]; if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x; return new Point (x, y); } /** * Returns a point which is the result of converting the * argument, which is specified in display relative coordinates, * to coordinates relative to the receiver. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** @param point the point to be translated (must not be null) * @return the translated coordinates * * @exception IllegalArgumentException
*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the point is null
**
*/ public Point toControl (Point point) { checkWidget (); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); return toControl (point.x, point.y); } /** * Returns a point which is the result of converting the * argument, which is specified in coordinates relative to * the receiver, to display relative coordinates. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** @param x the x coordinate to be translated * @param y the y coordinate to be translated * @return the translated coordinates * * @exception SWTException
*
* * @since 2.1 */ public Point toDisplay (int x, int y) { checkWidget(); long /*int*/ window = eventWindow (); int [] origin_x = new int [1], origin_y = new int [1]; OS.gdk_window_get_origin (window, origin_x, origin_y); if ((style & SWT.MIRRORED) != 0) x = getClientWidth () - x; x += origin_x [0]; y += origin_y [0]; return new Point (x, y); } /** * Returns a point which is the result of converting the * argument, which is specified in coordinates relative to * the receiver, to display relative coordinates. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** @param point the point to be translated (must not be null) * @return the translated coordinates * * @exception IllegalArgumentException
*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the point is null
**
*/ public Point toDisplay (Point point) { checkWidget(); if (point == null) error (SWT.ERROR_NULL_ARGUMENT); return toDisplay (point.x, point.y); } /** * Adds the listener to the collection of listeners who will * be notified when the control is moved or resized, by sending * it one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*ControlListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see ControlListener * @see #removeControlListener */ public void addControlListener(ControlListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Resize,typedListener); addListener (SWT.Move,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when a drag gesture occurs, by sending it * one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*DragDetectListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see DragDetectListener * @see #removeDragDetectListener * * @since 3.3 */ public void addDragDetectListener (DragDetectListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.DragDetect,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when the control gains or loses focus, by sending * it one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*FocusListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see FocusListener * @see #removeFocusListener */ public void addFocusListener(FocusListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener(SWT.FocusIn,typedListener); addListener(SWT.FocusOut,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when gesture events are generated for the control, * by sending it one of the messages defined in the *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*GestureListener
interface. ** NOTE: If
* * @param listener the listener which should be notified * * @exception IllegalArgumentExceptionsetTouchEnabled(true)
has previously been * invoked on the receiver thensetTouchEnabled(false)
* must be invoked on it to specify that gesture events should be * sent instead of touch events. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see GestureListener * @see #removeGestureListener * @see #setTouchEnabled * * @since 3.7 */ public void addGestureListener (GestureListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Gesture, typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when help events are generated for the control, * by sending it one of the messages defined in the *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*HelpListener
interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see HelpListener * @see #removeHelpListener */ public void addHelpListener (HelpListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Help, typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when keys are pressed and released on the system keyboard, by sending * it one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*KeyListener
* interface. ** When a key listener is added to a control, the control * will take part in widget traversal. By default, all * traversal keys (such as the tab key and so on) are * delivered to the control. In order for a control to take * part in traversal, it should listen for traversal events. * Otherwise, the user can traverse into a control but not * out. Note that native controls such as table and tree * implement key traversal in the operating system. It is * not necessary to add traversal listeners for these controls, * unless you want to override the default traversal. *
* @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see KeyListener * @see #removeKeyListener */ public void addKeyListener(KeyListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener(SWT.KeyUp,typedListener); addListener(SWT.KeyDown,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when the platform-specific context menu trigger * has occurred, by sending it one of the messages defined in * the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*MenuDetectListener
interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see MenuDetectListener * @see #removeMenuDetectListener * * @since 3.3 */ public void addMenuDetectListener (MenuDetectListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.MenuDetect, typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when mouse buttons are pressed and released, by sending * it one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*MouseListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see MouseListener * @see #removeMouseListener */ public void addMouseListener(MouseListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener(SWT.MouseDown,typedListener); addListener(SWT.MouseUp,typedListener); addListener(SWT.MouseDoubleClick,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when the mouse moves, by sending it one of the * messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*MouseMoveListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see MouseMoveListener * @see #removeMouseMoveListener */ public void addMouseMoveListener(MouseMoveListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener(SWT.MouseMove,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when the mouse passes or hovers over controls, by sending * it one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*MouseTrackListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see MouseTrackListener * @see #removeMouseTrackListener */ public void addMouseTrackListener (MouseTrackListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.MouseEnter,typedListener); addListener (SWT.MouseExit,typedListener); addListener (SWT.MouseHover,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when the mouse wheel is scrolled, by sending * it one of the messages defined in the *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*MouseWheelListener
interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see MouseWheelListener * @see #removeMouseWheelListener * * @since 3.3 */ public void addMouseWheelListener (MouseWheelListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.MouseWheel, typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when the receiver needs to be painted, by sending it * one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*PaintListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see PaintListener * @see #removePaintListener */ public void addPaintListener(PaintListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener(SWT.Paint,typedListener); } void addRelation (Control control) { } /** * Adds the listener to the collection of listeners who will * be notified when touch events occur, by sending it * one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*TouchListener
* interface. ** NOTE: You must also call
* * @param listener the listener which should be notified * * @exception IllegalArgumentExceptionsetTouchEnabled(true)
to * specify that touch events should be sent, which will cause gesture * events to not be sent. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see TouchListener * @see #removeTouchListener * @see #setTouchEnabled * * @since 3.7 */ public void addTouchListener (TouchListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Touch,typedListener); } /** * Adds the listener to the collection of listeners who will * be notified when traversal events occur, by sending it * one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*TraverseListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see TraverseListener * @see #removeTraverseListener */ public void addTraverseListener (TraverseListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Traverse,typedListener); } /** * Removes the listener from the collection of listeners who will * be notified when the control is moved or resized. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see ControlListener * @see #addControlListener */ public void removeControlListener (ControlListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.Move, listener); eventTable.unhook (SWT.Resize, listener); } /** * Removes the listener from the collection of listeners who will * be notified when a drag gesture occurs. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see DragDetectListener * @see #addDragDetectListener * * @since 3.3 */ public void removeDragDetectListener(DragDetectListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.DragDetect, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the control gains or loses focus. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see FocusListener * @see #addFocusListener */ public void removeFocusListener(FocusListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.FocusIn, listener); eventTable.unhook (SWT.FocusOut, listener); } /** * Removes the listener from the collection of listeners who will * be notified when gesture events are generated for the control. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see GestureListener * @see #addGestureListener * * @since 3.7 */ public void removeGestureListener (GestureListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook(SWT.Gesture, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the help events are generated for the control. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see HelpListener * @see #addHelpListener */ public void removeHelpListener (HelpListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.Help, listener); } /** * Removes the listener from the collection of listeners who will * be notified when keys are pressed and released on the system keyboard. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see KeyListener * @see #addKeyListener */ public void removeKeyListener(KeyListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.KeyUp, listener); eventTable.unhook (SWT.KeyDown, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the platform-specific context menu trigger has * occurred. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see MenuDetectListener * @see #addMenuDetectListener * * @since 3.3 */ public void removeMenuDetectListener (MenuDetectListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.MenuDetect, listener); } /** * Removes the listener from the collection of listeners who will * be notified when mouse buttons are pressed and released. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see MouseListener * @see #addMouseListener */ public void removeMouseListener (MouseListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.MouseDown, listener); eventTable.unhook (SWT.MouseUp, listener); eventTable.unhook (SWT.MouseDoubleClick, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the mouse moves. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see MouseMoveListener * @see #addMouseMoveListener */ public void removeMouseMoveListener(MouseMoveListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.MouseMove, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the mouse passes or hovers over controls. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see MouseTrackListener * @see #addMouseTrackListener */ public void removeMouseTrackListener(MouseTrackListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.MouseEnter, listener); eventTable.unhook (SWT.MouseExit, listener); eventTable.unhook (SWT.MouseHover, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the mouse wheel is scrolled. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see MouseWheelListener * @see #addMouseWheelListener * * @since 3.3 */ public void removeMouseWheelListener (MouseWheelListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.MouseWheel, listener); } /** * Removes the listener from the collection of listeners who will * be notified when the receiver needs to be painted. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see PaintListener * @see #addPaintListener */ public void removePaintListener(PaintListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook(SWT.Paint, listener); } /* * Remove "Labelled by" relation from the receiver. */ void removeRelation () { if (!isDescribedByLabel ()) return; /* there will not be any */ if (labelRelation != null) { _getAccessible().removeRelation (ACC.RELATION_LABELLED_BY, labelRelation._getAccessible()); labelRelation = null; } } /** * Removes the listener from the collection of listeners who will * be notified when touch events occur. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see TouchListener * @see #addTouchListener * * @since 3.7 */ public void removeTouchListener(TouchListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.Touch, listener); } /** * Removes the listener from the collection of listeners who will * be notified when traversal events occur. * * @param listener the listener which should no longer be notified * * @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 listener is null
**
* * @see TraverseListener * @see #addTraverseListener */ public void removeTraverseListener(TraverseListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); if (eventTable == null) return; eventTable.unhook (SWT.Traverse, listener); } /** * Detects a drag and drop gesture. This method is used * to detect a drag gesture when called from within a mouse * down listener. * *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*By default, a drag is detected when the gesture * occurs anywhere within the client area of a control. * Some controls, such as tables and trees, override this * behavior. In addition to the operating system specific * drag gesture, they require the mouse to be inside an * item. Custom widget writers can use
* * @param event the mouse down event * * @returnsetDragDetect
* to disable the default detection, listen for mouse down, * and then calldragDetect()
from within the * listener to conditionally detect a drag. *true
if the gesture occurred, andfalse
otherwise. * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT if the event is null
**
* * @see DragDetectListener * @see #addDragDetectListener * * @see #getDragDetect * @see #setDragDetect * * @since 3.3 */ public boolean dragDetect (Event event) { checkWidget (); if (event == null) error (SWT.ERROR_NULL_ARGUMENT); return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); } /** * Detects a drag and drop gesture. This method is used * to detect a drag gesture when called from within a mouse * down listener. * *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*By default, a drag is detected when the gesture * occurs anywhere within the client area of a control. * Some controls, such as tables and trees, override this * behavior. In addition to the operating system specific * drag gesture, they require the mouse to be inside an * item. Custom widget writers can use
* * @param event the mouse down event * * @returnsetDragDetect
* to disable the default detection, listen for mouse down, * and then calldragDetect()
from within the * listener to conditionally detect a drag. *true
if the gesture occurred, andfalse
otherwise. * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT if the event is null
**
* * @see DragDetectListener * @see #addDragDetectListener * * @see #getDragDetect * @see #setDragDetect * * @since 3.3 */ public boolean dragDetect (MouseEvent event) { checkWidget (); if (event == null) error (SWT.ERROR_NULL_ARGUMENT); return dragDetect (event.button, event.count, event.stateMask, event.x, event.y); } boolean dragDetect (int button, int count, int stateMask, int x, int y) { if (button != 1 || count != 1) return false; if (!dragDetect (x, y, false, true, null)) return false; return sendDragEvent (button, stateMask, x, y, true); } boolean dragDetect (int x, int y, boolean filter, boolean dragOnTimeout, boolean [] consume) { boolean quit = false, dragging = false; while (!quit) { long /*int*/ eventPtr = 0; /* * There should be an event on the queue already, but * in cases where there isn't one, stop trying after * half a second. */ long timeout = System.currentTimeMillis() + 500; while (System.currentTimeMillis() < timeout) { eventPtr = OS.gdk_event_get (); if (eventPtr != 0) { break; } else { try {Thread.sleep(50);} catch (Exception ex) {} } } if (eventPtr == 0) return dragOnTimeout; switch (OS.GDK_EVENT_TYPE (eventPtr)) { case OS.GDK_MOTION_NOTIFY: { GdkEventMotion gdkMotionEvent = new GdkEventMotion (); OS.memmove (gdkMotionEvent, eventPtr, GdkEventMotion.sizeof); if ((gdkMotionEvent.state & OS.GDK_BUTTON1_MASK) != 0) { if (OS.gtk_drag_check_threshold (handle, x, y, (int) gdkMotionEvent.x, (int) gdkMotionEvent.y)) { dragging = true; quit = true; } } else { quit = true; } int [] newX = new int [1], newY = new int [1]; gdk_window_get_device_position (gdkMotionEvent.window, newX, newY, null); break; } case OS.GDK_KEY_PRESS: case OS.GDK_KEY_RELEASE: { GdkEventKey gdkEvent = new GdkEventKey (); OS.memmove (gdkEvent, eventPtr, GdkEventKey.sizeof); if (gdkEvent.keyval == OS.GDK_Escape) quit = true; break; } case OS.GDK_BUTTON_RELEASE: case OS.GDK_BUTTON_PRESS: case OS.GDK_2BUTTON_PRESS: case OS.GDK_3BUTTON_PRESS: { OS.gdk_event_put (eventPtr); quit = true; break; } default: OS.gtk_main_do_event (eventPtr); } OS.gdk_event_free (eventPtr); } return dragging; } boolean filterKey (int keyval, long /*int*/ event) { long /*int*/ imHandle = imHandle (); if (imHandle != 0) { return OS.gtk_im_context_filter_keypress (imHandle, event); } return false; } Control findBackgroundControl () { if ((state & BACKGROUND) != 0 || backgroundImage != null) return this; return (state & PARENT_BACKGROUND) != 0 ? parent.findBackgroundControl () : null; } Menu [] findMenus (Control control) { if (menu != null && this != control) return new Menu [] {menu}; return new Menu [0]; } void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) { oldShell.fixShell (newShell, this); oldDecorations.fixDecorations (newDecorations, this, menus); } long /*int*/ fixedMapProc (long /*int*/ widget) { gtk_widget_set_mapped (widget, true); long /*int*/ widgetList = OS.gtk_container_get_children (widget); if (widgetList != 0) { long /*int*/ widgets = widgetList; while (widgets != 0) { long /*int*/ child = OS.g_list_data (widgets); if (gtk_widget_get_visible (child) && OS.gtk_widget_get_child_visible (child) && !gtk_widget_get_mapped (child)) { OS.gtk_widget_map (child); } widgets = OS.g_list_next (widgets); } OS.g_list_free (widgetList); } if (gtk_widget_get_has_window (widget)) { OS.gdk_window_show_unraised (gtk_widget_get_window (widget)); } return 0; } void fixModal(long /*int*/ group, long /*int*/ modalGroup) { } /** * Forces the receiver to have the keyboard focus, causing * all keyboard events to be delivered to it. * * @return- 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 control got focus, andfalse
if it was unable to. * * @exception SWTException*
* * @see #setFocus */ public boolean forceFocus () { checkWidget(); if (display.focusEvent == SWT.FocusOut) return false; Shell shell = getShell (); shell.setSavedFocus (this); if (!isEnabled () || !isVisible ()) return false; shell.bringToTop (false); return forceFocus (focusHandle ()); } boolean forceFocus (long /*int*/ focusHandle) { if (gtk_widget_has_focus (focusHandle)) return true; /* When the control is zero sized it must be realized */ OS.gtk_widget_realize (focusHandle); OS.gtk_widget_grab_focus (focusHandle); // widget could be disposed at this point if (isDisposed ()) return false; Shell shell = getShell (); long /*int*/ shellHandle = shell.shellHandle; long /*int*/ handle = OS.gtk_window_get_focus (shellHandle); while (handle != 0) { if (handle == focusHandle) { /* Cancel any previous ignoreFocus requests */ display.ignoreFocus = false; return true; } Widget widget = display.getWidget (handle); if (widget != null && widget instanceof Control) { return widget == this; } handle = OS.gtk_widget_get_parent (handle); } return false; } /** * Returns the receiver's background color. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Note: This operation is a hint and may be overridden by the platform. * For example, on some versions of Windows the background of a TabFolder, * is a gradient rather than a solid color. *
* @return the background color * * @exception SWTException*
*/ public Color getBackground () { checkWidget(); Control control = findBackgroundControl (); if (control == null) control = this; return Color.gtk_new (display, control.getBackgroundColor ()); } GdkColor getBackgroundColor () { return getBgColor (); } /** * Returns the receiver's background image. * * @return the background image * * @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
**
* * @since 3.2 */ public Image getBackgroundImage () { checkWidget (); Control control = findBackgroundControl (); if (control == null) control = this; return control.backgroundImage; } GdkColor getContextBackground () { long /*int*/ fontHandle = fontHandle (); long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); GdkRGBA rgba = new GdkRGBA (); OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); if (rgba.alpha == 0) { return display.COLOR_WIDGET_BACKGROUND; } GdkColor color = new GdkColor (); color.red = (short)(rgba.red * 0xFFFF); color.green = (short)(rgba.green * 0xFFFF); color.blue = (short)(rgba.blue * 0xFFFF); return color; } GdkColor getContextColor () { long /*int*/ fontHandle = fontHandle (); long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); GdkRGBA rgba = new GdkRGBA (); OS.gtk_style_context_get_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba); GdkColor color = new GdkColor (); color.red = (short)(rgba.red * 0xFFFF); color.green = (short)(rgba.green * 0xFFFF); color.blue = (short)(rgba.blue * 0xFFFF); return color; } GdkColor getBgColor () { if (OS.GTK3) { return getContextBackground (); } long /*int*/ fontHandle = fontHandle (); OS.gtk_widget_realize (fontHandle); GdkColor color = new GdkColor (); OS.gtk_style_get_bg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); return color; } GdkColor getBaseColor () { if (OS.GTK3) { return getContextBackground (); } long /*int*/ fontHandle = fontHandle (); OS.gtk_widget_realize (fontHandle); GdkColor color = new GdkColor (); OS.gtk_style_get_base (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); return color; } /** * Returns the receiver's border width. * * @return the border width * * @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
**
*/ public int getBorderWidth () { checkWidget(); return 0; } int getClientWidth () { return 0; } /** * Returns the receiver's cursor, or null if it has not been set. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** When the mouse pointer passes over a control its appearance * is changed to match the control's cursor. *
* * @return the receiver's cursor ornull
* * @exception SWTException*
* * @since 3.3 */ public Cursor getCursor () { checkWidget (); return cursor; } /** * Returns- 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 receiver is detecting * drag gestures, andfalse
otherwise. * * @return the receiver's drag detect state * * @exception SWTException*
* * @since 3.3 */ public boolean getDragDetect () { checkWidget (); return (state & DRAG_DETECT) != 0; } /** * Returns- 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 receiver is enabled, and *false
otherwise. A disabled control is typically * not selectable from the user interface and draws with an * inactive or "grayed" look. * * @return the receiver's enabled state * * @exception SWTException*
* * @see #isEnabled */ public boolean getEnabled () { checkWidget (); return (state & DISABLED) == 0; } /** * Returns the font that the receiver will use to paint textual information. * * @return the receiver's font * * @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
**
*/ public Font getFont () { checkWidget(); return font != null ? font : defaultFont (); } long /*int*/ getFontDescription () { long /*int*/ fontHandle = fontHandle (); if (OS.GTK3) { long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle); return OS.gtk_style_context_get_font(context, OS.GTK_STATE_FLAG_NORMAL); } OS.gtk_widget_realize (fontHandle); return OS.gtk_style_get_font_desc (OS.gtk_widget_get_style (fontHandle)); } /** * Returns the foreground color that the receiver will use to draw. * * @return the receiver's foreground color * * @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
**
*/ public Color getForeground () { checkWidget(); return Color.gtk_new (display, getForegroundColor ()); } GdkColor getForegroundColor () { return getFgColor (); } GdkColor getFgColor () { if (OS.GTK3) { return getContextColor (); } long /*int*/ fontHandle = fontHandle (); OS.gtk_widget_realize (fontHandle); GdkColor color = new GdkColor (); OS.gtk_style_get_fg (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); return color; } Point getIMCaretPos () { return new Point (0, 0); } GdkColor getTextColor () { if (OS.GTK3) { return getContextColor (); } long /*int*/ fontHandle = fontHandle (); OS.gtk_widget_realize (fontHandle); GdkColor color = new GdkColor (); OS.gtk_style_get_text (OS.gtk_widget_get_style (fontHandle), OS.GTK_STATE_NORMAL, color); return color; } /** * Returns layout data which is associated with the receiver. * * @return the receiver's layout 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
**
*/ public Object getLayoutData () { checkWidget(); return layoutData; } /** * Returns the receiver's pop up menu if it has one, or null * if it does not. All controls may optionally have a pop up * menu that is displayed when the user requests one for * the control. The sequence of key strokes, button presses * and/or button releases that are used to request a pop up * menu is platform specific. * * @return the receiver's menu * * @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
**
*/ public Menu getMenu () { checkWidget(); return menu; } /** * Returns the receiver's monitor. * * @return the receiver's monitor * * @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
**
* * @since 3.0 */ public Monitor getMonitor () { checkWidget(); Monitor monitor = null; long /*int*/ screen = OS.gdk_screen_get_default (); if (screen != 0) { int monitorNumber = OS.gdk_screen_get_monitor_at_window (screen, paintWindow ()); GdkRectangle dest = new GdkRectangle (); OS.gdk_screen_get_monitor_geometry (screen, monitorNumber, dest); monitor = new Monitor (); monitor.handle = monitorNumber; monitor.x = dest.x; monitor.y = dest.y; monitor.width = dest.width; monitor.height = dest.height; Rectangle workArea = null; if (monitorNumber == 0) workArea = display.getWorkArea (); if (workArea != null) { monitor.clientX = workArea.x; monitor.clientY = workArea.y; monitor.clientWidth = workArea.width; monitor.clientHeight = workArea.height; } else { monitor.clientX = monitor.x; monitor.clientY = monitor.y; monitor.clientWidth = monitor.width; monitor.clientHeight = monitor.height; } } else { monitor = display.getPrimaryMonitor (); } return monitor; } /** * Returns the receiver's parent, which must be a- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*Composite
* or null when the receiver is a shell that was created with null or * a display for a parent. * * @return the receiver's parent * * @exception SWTException*
*/ public Composite getParent () { checkWidget(); return parent; } Control [] getPath () { int count = 0; Shell shell = getShell (); Control control = this; while (control != shell) { count++; control = control.parent; } control = this; Control [] result = new Control [count]; while (control != shell) { result [--count] = control; control = control.parent; } return result; } /** * Returns the region that defines the shape of the control, * or null if the control has the default shape. * * @return the region that defines the shape of the shell (or null) * * @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
**
* * @since 3.4 */ public Region getRegion () { checkWidget (); return region; } /** * Returns the receiver's shell. For all controls other than * shells, this simply returns the control's nearest ancestor * shell. Shells return themselves, even if they are children * of other shells. * * @return the receiver's shell * * @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
**
* * @see #getParent */ public Shell getShell() { checkWidget(); return _getShell(); } Shell _getShell() { return parent._getShell(); } /** * Returns the receiver's tool tip text, or null if it has * not been set. * * @return the receiver's tool tip text * * @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
**
*/ public String getToolTipText () { checkWidget(); return toolTipText; } /** * Returns- 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 this control is set to send touch events, or *false
if it is set to send gesture events instead. This method * also returnsfalse
if a touch-based input device is not detected * (this can be determined withDisplay#getTouchEnabled()
). Use * {@link #setTouchEnabled(boolean)} to switch the events that a control sends * between touch events and gesture events. * * @returntrue
if the control is set to send touch events, orfalse
otherwise * * @exception SWTException*
* * @see #setTouchEnabled * @see Display#getTouchEnabled * * @since 3.7 */ public boolean getTouchEnabled() { checkWidget(); return false; } /** * Returns- 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 receiver is visible, and *false
otherwise. ** If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, this method * may still indicate that it is considered visible even though * it may not actually be showing. *
* * @return the receiver's visibility state * * @exception SWTException*
*/ public boolean getVisible () { checkWidget(); return (state & HIDDEN) == 0; } Point getThickness (long /*int*/ widget) { if (OS.GTK3) { int xthickness = 0, ythickness = 0; GtkBorder tmp = new GtkBorder(); long /*int*/ context = OS.gtk_widget_get_style_context (widget); OS.gtk_style_context_save (context); OS.gtk_style_context_add_class (context, OS.GTK_STYLE_CLASS_FRAME); OS.gtk_style_context_get_padding (context, OS.GTK_STATE_FLAG_NORMAL, tmp); xthickness += tmp.left; ythickness += tmp.top; OS.gtk_style_context_get_border (context, OS.GTK_STATE_FLAG_NORMAL, tmp); xthickness += tmp.left; ythickness += tmp.top; OS.gtk_style_context_restore (context); return new Point (xthickness, ythickness); } long /*int*/ style = OS.gtk_widget_get_style (widget); return new Point (OS.gtk_style_get_xthickness (style), OS.gtk_style_get_ythickness (style)); } long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event) { return gtk_button_press_event (widget, event, true); } long /*int*/ gtk_button_press_event (long /*int*/ widget, long /*int*/ event, boolean sendMouseDown) { GdkEventButton gdkEvent = new GdkEventButton (); OS.memmove (gdkEvent, event, GdkEventButton.sizeof); if (gdkEvent.type == OS.GDK_3BUTTON_PRESS) return 0; /* * When a shell is created with SWT.ON_TOP and SWT.NO_FOCUS, * do not activate the shell when the user clicks on the * the client area or on the border or a control within the * shell that does not take focus. */ Shell shell = _getShell (); if (((shell.style & SWT.ON_TOP) != 0) && (((shell.style & SWT.NO_FOCUS) == 0) || ((style & SWT.NO_FOCUS) == 0))) { shell.forceActive(); } long /*int*/ result = 0; if (gdkEvent.type == OS.GDK_BUTTON_PRESS) { display.clickCount = 1; long /*int*/ nextEvent = OS.gdk_event_peek (); if (nextEvent != 0) { int eventType = OS.GDK_EVENT_TYPE (nextEvent); if (eventType == OS.GDK_2BUTTON_PRESS) display.clickCount = 2; if (eventType == OS.GDK_3BUTTON_PRESS) display.clickCount = 3; OS.gdk_event_free (nextEvent); } boolean dragging = false; if ((state & DRAG_DETECT) != 0 && hooks (SWT.DragDetect)) { if (gdkEvent.button == 1) { boolean [] consume = new boolean [1]; if (dragDetect ((int) gdkEvent.x, (int) gdkEvent.y, true, true, consume)) { dragging = true; if (consume [0]) result = 1; } if (isDisposed ()) return 1; } } if (sendMouseDown && !sendMouseEvent (SWT.MouseDown, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state)) { result = 1; } if (isDisposed ()) return 1; if (dragging) { sendDragEvent (gdkEvent.button, gdkEvent.state, (int) gdkEvent.x, (int) gdkEvent.y, false); if (isDisposed ()) return 1; } /* * Pop up the context menu in the button press event for widgets * that have default operating system menus in order to stop the * operating system from displaying the menu if necessary. */ if ((state & MENU) != 0) { if (gdkEvent.button == 3) { if (showMenu ((int)gdkEvent.x_root, (int)gdkEvent.y_root)) { result = 1; } } } } else { display.clickCount = 2; result = sendMouseEvent (SWT.MouseDoubleClick, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; if (isDisposed ()) return 1; } if (!shell.isDisposed ()) shell.setActiveControl (this, SWT.MouseDown); return result; } long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event) { GdkEventButton gdkEvent = new GdkEventButton (); OS.memmove (gdkEvent, event, GdkEventButton.sizeof); return sendMouseEvent (SWT.MouseUp, gdkEvent.button, display.clickCount, 0, false, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; } long /*int*/ gtk_commit (long /*int*/ imcontext, long /*int*/ text) { if (text == 0) return 0; int length = OS.strlen (text); if (length == 0) return 0; byte [] buffer = new byte [length]; OS.memmove (buffer, text, length); char [] chars = Converter.mbcsToWcs (null, buffer); sendIMKeyEvent (SWT.KeyDown, null, chars); return 0; } long /*int*/ gtk_enter_notify_event (long /*int*/ widget, long /*int*/ event) { if (OS.GTK_VERSION >= OS.VERSION (2, 12, 0)) { /* * Feature in GTK. Children of a shell will inherit and display the shell's * tooltip if they do not have a tooltip of their own. The fix is to use the * new tooltip API in GTK 2.12 to null the shell's tooltip when the control * being entered does not have any tooltip text set. */ byte [] buffer = null; if (toolTipText != null && toolTipText.length() != 0) { char [] chars = fixMnemonic (toolTipText, false); buffer = Converter.wcsToMbcs (null, chars, true); } long /*int*/ toolHandle = getShell().handle; OS.gtk_widget_set_tooltip_text (toolHandle, buffer); } if (display.currentControl == this) return 0; GdkEventCrossing gdkEvent = new GdkEventCrossing (); OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof); /* * It is possible to send out too many enter/exit events if entering a * control through a subwindow. The fix is to return without sending any * events if the GdkEventCrossing subwindow field is set and the control * requests to check the field. */ if (gdkEvent.subwindow != 0 && checkSubwindow ()) return 0; if (gdkEvent.mode != OS.GDK_CROSSING_NORMAL && gdkEvent.mode != OS.GDK_CROSSING_UNGRAB) return 0; if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) != 0) return 0; if (display.currentControl != null && !display.currentControl.isDisposed ()) { display.removeMouseHoverTimeout (display.currentControl.handle); display.currentControl.sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state); } if (!isDisposed ()) { display.currentControl = this; return sendMouseEvent (SWT.MouseEnter, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; } return 0; } boolean checkSubwindow () { return false; } long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) { GdkEvent event = new GdkEvent (); OS.memmove (event, gdkEvent, GdkEvent.sizeof); switch (event.type) { case OS.GDK_BUTTON_PRESS: { if (widget != eventHandle ()) break; /* * Pop up the context menu in the event_after signal to allow * the widget to process the button press. This allows widgets * such as GtkTreeView to select items before a menu is shown. */ if ((state & MENU) == 0) { GdkEventButton gdkEventButton = new GdkEventButton (); OS.memmove (gdkEventButton, gdkEvent, GdkEventButton.sizeof); if (gdkEventButton.button == 3) { showMenu ((int) gdkEventButton.x_root, (int) gdkEventButton.y_root); } } break; } case OS.GDK_FOCUS_CHANGE: { if (!isFocusHandle (widget)) break; GdkEventFocus gdkEventFocus = new GdkEventFocus (); OS.memmove (gdkEventFocus, gdkEvent, GdkEventFocus.sizeof); /* * Feature in GTK. The GTK combo box popup under some window managers * is implemented as a GTK_MENU. When it pops up, it causes the combo * box to lose focus when focus is received for the menu. The * fix is to check the current grab handle and see if it is a GTK_MENU * and ignore the focus event when the menu is both shown and hidden. * * NOTE: This code runs for all menus. */ Display display = this.display; if (gdkEventFocus.in != 0) { if (display.ignoreFocus) { display.ignoreFocus = false; break; } } else { display.ignoreFocus = false; long /*int*/ grabHandle = OS.gtk_grab_get_current (); if (grabHandle != 0) { if (OS.G_OBJECT_TYPE (grabHandle) == OS.GTK_TYPE_MENU ()) { display.ignoreFocus = true; break; } } } sendFocusEvent (gdkEventFocus.in != 0 ? SWT.FocusIn : SWT.FocusOut); break; } } return 0; } long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) { if ((state & OBSCURED) != 0) return 0; if (!hooksPaint ()) return 0; GdkRectangle rect = new GdkRectangle (); OS.gdk_cairo_get_clip_rectangle (cairo, rect); Event event = new Event (); event.count = 1; event.x = rect.x; event.y = rect.y; event.width = rect.width; event.height = rect.height; if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x; GCData data = new GCData (); // data.damageRgn = gdkEvent.region; data.cairo = cairo; GC gc = event.gc = GC.gtk_new (this, data); drawWidget (gc); sendEvent (SWT.Paint, event); gc.dispose (); event.gc = null; return 0; } long /*int*/ gtk_expose_event (long /*int*/ widget, long /*int*/ eventPtr) { if ((state & OBSCURED) != 0) return 0; if (!hooksPaint ()) return 0; GdkEventExpose gdkEvent = new GdkEventExpose (); OS.memmove(gdkEvent, eventPtr, GdkEventExpose.sizeof); Event event = new Event (); event.count = gdkEvent.count; event.x = gdkEvent.area_x; event.y = gdkEvent.area_y; event.width = gdkEvent.area_width; event.height = gdkEvent.area_height; if ((style & SWT.MIRRORED) != 0) event.x = getClientWidth () - event.width - event.x; GCData data = new GCData (); data.damageRgn = gdkEvent.region; GC gc = event.gc = GC.gtk_new (this, data); drawWidget (gc); sendEvent (SWT.Paint, event); gc.dispose (); event.gc = null; return 0; } long /*int*/ gtk_focus (long /*int*/ widget, long /*int*/ directionType) { /* Stop GTK traversal for every widget */ return 1; } long /*int*/ gtk_focus_in_event (long /*int*/ widget, long /*int*/ event) { // widget could be disposed at this point if (handle != 0) { Control oldControl = display.imControl; if (oldControl != this) { if (oldControl != null && !oldControl.isDisposed ()) { long /*int*/ oldIMHandle = oldControl.imHandle (); if (oldIMHandle != 0) OS.gtk_im_context_reset (oldIMHandle); } } if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { long /*int*/ imHandle = imHandle (); if (imHandle != 0) OS.gtk_im_context_focus_in (imHandle); } } return 0; } long /*int*/ gtk_focus_out_event (long /*int*/ widget, long /*int*/ event) { // widget could be disposed at this point if (handle != 0) { if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) { long /*int*/ imHandle = imHandle (); if (imHandle != 0) { OS.gtk_im_context_focus_out (imHandle); } } } return 0; } long /*int*/ gtk_key_press_event (long /*int*/ widget, long /*int*/ event) { if (!hasFocus ()) { /* * Feature in GTK. On AIX, the IME window deactivates the current shell and even * though the widget receiving the key event is not in focus, it should filter the input in * order to get it committed. The fix is to detect that the widget shell is not active * and call filterKey() only. */ if (display.getActiveShell () == null) { GdkEventKey gdkEvent = new GdkEventKey (); OS.memmove (gdkEvent, event, GdkEventKey.sizeof); if (filterKey (gdkEvent.keyval, event)) return 1; } return 0; } GdkEventKey gdkEvent = new GdkEventKey (); OS.memmove (gdkEvent, event, GdkEventKey.sizeof); if (translateMnemonic (gdkEvent.keyval, gdkEvent)) return 1; // widget could be disposed at this point if (isDisposed ()) return 0; if (filterKey (gdkEvent.keyval, event)) return 1; // widget could be disposed at this point if (isDisposed ()) return 0; if (translateTraversal (gdkEvent)) return 1; // widget could be disposed at this point if (isDisposed ()) return 0; return super.gtk_key_press_event (widget, event); } long /*int*/ gtk_key_release_event (long /*int*/ widget, long /*int*/ event) { if (!hasFocus ()) return 0; long /*int*/ imHandle = imHandle (); if (imHandle != 0) { if (OS.gtk_im_context_filter_keypress (imHandle, event)) return 1; } return super.gtk_key_release_event (widget, event); } long /*int*/ gtk_leave_notify_event (long /*int*/ widget, long /*int*/ event) { if (display.currentControl != this) return 0; display.removeMouseHoverTimeout (handle); int result = 0; if (sendLeaveNotify () || display.getCursorControl () == null) { GdkEventCrossing gdkEvent = new GdkEventCrossing (); OS.memmove (gdkEvent, event, GdkEventCrossing.sizeof); if (gdkEvent.mode != OS.GDK_CROSSING_NORMAL && gdkEvent.mode != OS.GDK_CROSSING_UNGRAB) return 0; if ((gdkEvent.state & (OS.GDK_BUTTON1_MASK | OS.GDK_BUTTON2_MASK | OS.GDK_BUTTON3_MASK)) != 0) return 0; result = sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; display.currentControl = null; } return result; } long /*int*/ gtk_mnemonic_activate (long /*int*/ widget, long /*int*/ arg1) { int result = 0; long /*int*/ eventPtr = OS.gtk_get_current_event (); if (eventPtr != 0) { GdkEventKey keyEvent = new GdkEventKey (); OS.memmove (keyEvent, eventPtr, GdkEventKey.sizeof); if (keyEvent.type == OS.GDK_KEY_PRESS) { Control focusControl = display.getFocusControl (); long /*int*/ focusHandle = focusControl != null ? focusControl.focusHandle () : 0; if (focusHandle != 0) { display.mnemonicControl = this; OS.gtk_widget_event (focusHandle, eventPtr); display.mnemonicControl = null; } result = 1; } OS.gdk_event_free (eventPtr); } return result; } long /*int*/ gtk_motion_notify_event (long /*int*/ widget, long /*int*/ event) { GdkEventMotion gdkEvent = new GdkEventMotion (); OS.memmove (gdkEvent, event, GdkEventMotion.sizeof); if (this == display.currentControl && (hooks (SWT.MouseHover) || filters (SWT.MouseHover))) { display.addMouseHoverTimeout (handle); } double x = gdkEvent.x_root, y = gdkEvent.y_root; int state = gdkEvent.state; if (gdkEvent.is_hint != 0) { int [] pointer_x = new int [1], pointer_y = new int [1], mask = new int [1]; long /*int*/ window = eventWindow (); gdk_window_get_device_position (window, pointer_x, pointer_y, mask); x = pointer_x [0]; y = pointer_y [0]; state = mask [0]; } if (OS.GTK3 && this != display.currentControl) { if (display.currentControl != null && !display.currentControl.isDisposed ()) { display.removeMouseHoverTimeout (display.currentControl.handle); display.currentControl.sendMouseEvent (SWT.MouseExit, 0, gdkEvent.time, x, y, false, state); } if (!isDisposed ()) { display.currentControl = this; sendMouseEvent (SWT.MouseEnter, 0, gdkEvent.time, x, y, false, state); } } int result = sendMouseEvent (SWT.MouseMove, 0, gdkEvent.time, x, y, gdkEvent.is_hint != 0, state) ? 0 : 1; return result; } long /*int*/ gtk_popup_menu (long /*int*/ widget) { if (!hasFocus()) return 0; int [] x = new int [1], y = new int [1]; gdk_window_get_device_position (0, x, y, null); return showMenu (x [0], y [0], SWT.MENU_KEYBOARD) ? 1 : 0; } long /*int*/ gtk_preedit_changed (long /*int*/ imcontext) { display.showIMWindow (this); return 0; } long /*int*/ gtk_realize (long /*int*/ widget) { long /*int*/ imHandle = imHandle (); if (imHandle != 0) { long /*int*/ window = gtk_widget_get_window (paintHandle ()); OS.gtk_im_context_set_client_window (imHandle, window); } if (backgroundImage != null) { setBackgroundPixmap (backgroundImage); } return 0; } long /*int*/ gtk_scroll_event (long /*int*/ widget, long /*int*/ eventPtr) { GdkEventScroll gdkEvent = new GdkEventScroll (); OS.memmove (gdkEvent, eventPtr, GdkEventScroll.sizeof); switch (gdkEvent.direction) { case OS.GDK_SCROLL_UP: return sendMouseEvent (SWT.MouseWheel, 0, 3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; case OS.GDK_SCROLL_DOWN: return sendMouseEvent (SWT.MouseWheel, 0, -3, SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; case OS.GDK_SCROLL_LEFT: return sendMouseEvent (SWT.MouseHorizontalWheel, 0, 3, 0, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; case OS.GDK_SCROLL_RIGHT: return sendMouseEvent (SWT.MouseHorizontalWheel, 0, -3, 0, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1; case OS.GDK_SCROLL_SMOOTH: long /*int*/ result = 0; double[] delta_x = new double[1], delta_y = new double [1]; if (OS.gdk_event_get_scroll_deltas (eventPtr, delta_x, delta_y)) { if (delta_x [0] != 0) { result = (sendMouseEvent (SWT.MouseHorizontalWheel, 0, (int)(3 * delta_x [0]), 0, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1); } if (delta_y [0] != 0) { result = (sendMouseEvent (SWT.MouseWheel, 0, (int)(3 * delta_y [0]), SWT.SCROLL_LINE, true, gdkEvent.time, gdkEvent.x_root, gdkEvent.y_root, false, gdkEvent.state) ? 0 : 1); } } return result; } return 0; } long /*int*/ gtk_show_help (long /*int*/ widget, long /*int*/ helpType) { if (!hasFocus ()) return 0; return sendHelpEvent (helpType) ? 1 : 0; } long /*int*/ gtk_style_set (long /*int*/ widget, long /*int*/ previousStyle) { if (backgroundImage != null) { setBackgroundPixmap (backgroundImage); } return 0; } long /*int*/ gtk_unrealize (long /*int*/ widget) { long /*int*/ imHandle = imHandle (); if (imHandle != 0) OS.gtk_im_context_set_client_window (imHandle, 0); return 0; } long /*int*/ gtk_visibility_notify_event (long /*int*/ widget, long /*int*/ event) { /* * As of GTK 2.17.11, obscured controls no longer send expose * events. It is no longer necessary to track visiblity notify * events. */ if (OS.GTK_VERSION >= OS.VERSION (2, 17, 11)) return 0; GdkEventVisibility gdkEvent = new GdkEventVisibility (); OS.memmove (gdkEvent, event, GdkEventVisibility.sizeof); long /*int*/ paintWindow = paintWindow(); long /*int*/ window = gdkEvent.window; if (window == paintWindow) { if (gdkEvent.state == OS.GDK_VISIBILITY_FULLY_OBSCURED) { state |= OBSCURED; } else { if ((state & OBSCURED) != 0) { int [] width = new int [1], height = new int [1]; gdk_window_get_size (window, width, height); GdkRectangle rect = new GdkRectangle (); rect.width = width [0]; rect.height = height [0]; OS.gdk_window_invalidate_rect (window, rect, false); } state &= ~OBSCURED; } } return 0; } void gtk_widget_set_has_window (long /*int*/ fixedHandle, boolean value) { if (OS.GTK_VERSION >= OS.VERSION (2, 18, 0)) { OS.gtk_widget_set_has_window (fixedHandle, value); } else { OS.gtk_fixed_set_has_window (fixedHandle, value); } } void gtk_widget_size_request (long /*int*/ widget, GtkRequisition requisition) { gtk_widget_get_preferred_size (widget, requisition); } /** * Invokes platform specific functionality to allocate a new GC handle. *- 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 public * API for
* * @param data the platform specific GC data * @return the platform specific GC handle * * @noreference This method is not intended to be referenced by clients. */ public long /*int*/ internal_new_GC (GCData data) { checkWidget (); long /*int*/ window = paintWindow (); if (window == 0) error (SWT.ERROR_NO_HANDLES); long /*int*/ gc = data.cairo; if (gc != 0) { Cairo.cairo_reference (gc); } else { if (OS.USE_CAIRO) { gc = OS.gdk_cairo_create (window); } else { gc = OS.gdk_gc_new (window); } } if (gc == 0) error (SWT.ERROR_NO_HANDLES); if (data != null) { int mask = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; if ((data.style & mask) == 0) { data.style |= style & (mask | SWT.MIRRORED); } else { if ((data.style & SWT.RIGHT_TO_LEFT) != 0) { data.style |= SWT.MIRRORED; } } data.drawable = window; data.device = display; data.foreground = getForegroundColor (); Control control = findBackgroundControl (); if (control == null) control = this; data.background = control.getBackgroundColor (); data.font = font != null ? font : defaultFont (); } return gc; } long /*int*/ imHandle () { return 0; } /** * Invokes platform specific functionality to dispose a GC handle. *Control
. 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
* * @param hDC the platform specific GC handle * @param data the platform specific GC data * * @noreference This method is not intended to be referenced by clients. */ public void internal_dispose_GC (long /*int*/ hDC, GCData data) { checkWidget (); long /*int*/ gc = hDC; if (OS.USE_CAIRO) { Cairo.cairo_destroy (gc); } else { OS.g_object_unref (gc); } } /** * ReturnsControl
. 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. *true
if the underlying operating * system supports this reparenting, otherwisefalse
* * @returntrue
if the widget can be reparented, otherwisefalse
* * @exception SWTException*
*/ public boolean isReparentable () { checkWidget(); return true; } boolean isShowing () { /* * This is not complete. Need to check if the * widget is obscurred by a parent or sibling. */ if (!isVisible ()) return false; Control control = this; while (control != null) { Point size = control.getSize (); if (size.x == 0 || size.y == 0) { return false; } control = control.parent; } return true; } boolean isTabGroup () { Control [] tabList = parent._getTabList (); if (tabList != null) { for (int i=0; i- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*true false
is returned. * A disabled control is typically not selectable from the user * interface and draws with an inactive or "grayed" look. * * @return the receiver's enabled state * * @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 receiver has the user-interface
* focus, and false
otherwise.
*
* @return the receiver's focus state
*
* @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 receiver is visible and all
* ancestors up to and including the receiver's nearest ancestor
* shell are visible. Otherwise, false
is returned.
*
* @return the receiver's visibility state
*
* @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 *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
all
flag is true
, any
* children of the receiver which intersect with the specified
* area will also paint their intersecting areas. If the
* all
flag is false
, the children
* will not be painted.
*
* @param x the x coordinate of the area to draw
* @param y the y coordinate of the area to draw
* @param width the width of the area to draw
* @param height the height of the area to draw
* @param all true
if children should redraw, and false
otherwise
*
* @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: This operation is a hint and may be overridden by the platform. * For example, on Windows the background of a Button cannot be changed. *
* @param color the new color (or null) * * @exception IllegalArgumentException-
*
- ERROR_INVALID_ARGUMENT - if the argument has been disposed *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note: This operation is a hint and may be overridden by the platform. * For example, on Windows the background of a Button cannot be changed. *
* @param image the new image (or null) * * @exception IllegalArgumentException-
*
- ERROR_INVALID_ARGUMENT - if the argument has been disposed *
- ERROR_INVALID_ARGUMENT - if the argument is not a bitmap *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
true
, causes the receiver to have
* all mouse events delivered to it until the method is called with
* false
as the argument. Note that on some platforms,
* a mouse button must currently be down for capture to be assigned.
*
* @param capture true
to capture the mouse, and false
to release it
*
* @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 *
* When the mouse pointer passes over a control its appearance * is changed to match the control's cursor. *
* * @param cursor the new cursor (or null) * * @exception IllegalArgumentException-
*
- ERROR_INVALID_ARGUMENT - if the argument has been disposed *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
true
, the receiver will detect drag gestures,
* otherwise these gestures will be ignored.
*
* @param dragDetect the new drag detect state
*
* @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
,
* and disables it otherwise. A disabled control is typically
* not selectable from the user interface and draws with an
* inactive or "grayed" look.
*
* @param enabled the new enabled state
*
* @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 control got focus, and false
if it was unable to.
*
* @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 *
-
*
- ERROR_INVALID_ARGUMENT - if the argument has been disposed *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note: This operation is a hint and may be overridden by the platform. *
* @param color the new color (or null) * * @exception IllegalArgumentException-
*
- ERROR_INVALID_ARGUMENT - if the argument has been disposed *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note: Disposing of a control that has a pop up menu will * dispose of the menu. To avoid this behavior, set the * menu to null before the control is disposed. *
* * @param menu the new pop up menu * * @exception IllegalArgumentException-
*
- ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu *
- ERROR_INVALID_PARENT - if the menu is not in the same widget tree *
- ERROR_INVALID_ARGUMENT - if the menu has been disposed *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
* * * @param orientation new orientation style * * @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 parent is successfully changed.
*
* @param parent the new parent for the control.
* @return true
if the parent is changed and false
otherwise.
*
* @exception IllegalArgumentException -
*
- ERROR_INVALID_ARGUMENT - if the argument has been disposed *
- ERROR_NULL_ARGUMENT - if the parent 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 *
false
, causes subsequent drawing
* operations in the receiver to be ignored. No drawing of any kind
* can occur in the receiver until the flag is set to true.
* Graphics operations that occurred while the flag was
* false
are lost. When the flag is set to true
,
* the entire widget is marked as needing to be redrawn. Nested calls
* to this method are stacked.
* * Note: This operation is a hint and may not be supported on some * platforms or for some widgets. *
* * @param redraw the new redraw state * * @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.LEFT_TO_RIGHT
or
* SWT.RIGHT_TO_LEFT
.
*
* setOrientation
would override this value with the text direction
* that is consistent with the new orientation.
*
* Warning: This API is currently only implemented on Windows. * It doesn't set the base text direction on GTK and Cocoa. *
* * @param textDirection the base text direction style * * @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 *
* The mnemonic indicator (character '&') is not displayed in a tool tip. * To display a single '&' in the tool tip, the character '&' can be * escaped by doubling it in the string. *
* * @param string the new tool tip text (or null) * * @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 *
false
causes the receiver to send gesture events
* instead. No exception is thrown if a touch-based input device is not
* detected (this can be determined with Display#getTouchEnabled()
).
*
* @param enabled the new touch-enabled state
*
* @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 * * @see Display#getTouchEnabled * * @since 3.7 */ public void setTouchEnabled(boolean enabled) { checkWidget(); } /** * Marks the receiver as visible if the argument is
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
- 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 event 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 *
- ERROR_NULL_ARGUMENT if the event 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 *
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
true
,
* and marks it invisible otherwise.
* * If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, marking * it visible may not actually cause it to be displayed. *
* * @param visible the new visibility state * * @exception SWTException-
*
SWT.TRAVERSE_ESCAPE
, SWT.TRAVERSE_RETURN
,
* SWT.TRAVERSE_TAB_NEXT
, SWT.TRAVERSE_TAB_PREVIOUS
,
* SWT.TRAVERSE_ARROW_NEXT
, SWT.TRAVERSE_ARROW_PREVIOUS
,
* SWT.TRAVERSE_PAGE_NEXT
and SWT.TRAVERSE_PAGE_PREVIOUS
.
*
* @param traversal the type of traversal
* @return true if the traversal succeeded
*
* @exception SWTException -
*
KeyDown
event.
*
* Valid traversal values are
* SWT.TRAVERSE_NONE
, SWT.TRAVERSE_MNEMONIC
,
* SWT.TRAVERSE_ESCAPE
, SWT.TRAVERSE_RETURN
,
* SWT.TRAVERSE_TAB_NEXT
, SWT.TRAVERSE_TAB_PREVIOUS
,
* SWT.TRAVERSE_ARROW_NEXT
, SWT.TRAVERSE_ARROW_PREVIOUS
,
* SWT.TRAVERSE_PAGE_NEXT
and SWT.TRAVERSE_PAGE_PREVIOUS
.
* If traversal
is SWT.TRAVERSE_NONE
then the Traverse
* event is created with standard values based on the KeyDown event. If
* traversal
is one of the other traversal constants then the Traverse
* event is created with this detail, and its doit
is taken from the
* KeyDown event.
*
SWT.TRAVERSE_NONE
to compute
* this from event
* @param event the KeyDown event
*
* @return true
if the traversal succeeded
*
* @exception IllegalArgumentException -
*
-
*
KeyDown
event.
*
* Valid traversal values are
* SWT.TRAVERSE_NONE
, SWT.TRAVERSE_MNEMONIC
,
* SWT.TRAVERSE_ESCAPE
, SWT.TRAVERSE_RETURN
,
* SWT.TRAVERSE_TAB_NEXT
, SWT.TRAVERSE_TAB_PREVIOUS
,
* SWT.TRAVERSE_ARROW_NEXT
, SWT.TRAVERSE_ARROW_PREVIOUS
,
* SWT.TRAVERSE_PAGE_NEXT
and SWT.TRAVERSE_PAGE_PREVIOUS
.
* If traversal
is SWT.TRAVERSE_NONE
then the Traverse
* event is created with standard values based on the KeyDown event. If
* traversal
is one of the other traversal constants then the Traverse
* event is created with this detail, and its doit
is taken from the
* KeyDown event.
*
SWT.TRAVERSE_NONE
to compute
* this from event
* @param event the KeyDown event
*
* @return true
if the traversal succeeded
*
* @exception IllegalArgumentException -
*
-
*
* Note: This method does not cause a redraw. *
* * @exception SWTException-
*