org.eclipse.swt.widgets.Widget Maven / Gradle / Ivy
/******************************************************************************* * Copyright (c) 2000, 2015 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.events.*; import org.eclipse.swt.internal.*; import org.eclipse.swt.internal.cocoa.*; /** * This class is the abstract superclass of all user interface objects. * Widgets are created, disposed and issue notification to listeners * when events occur which affect them. *
that is associated with * the receiver. **
*- Styles:
*- (none)
*- Events:
*- Dispose
** IMPORTANT: This class is intended to be subclassed only * within the SWT implementation. However, it has not been marked * final to allow those outside of the SWT development team to implement * patched versions of the class in order to get around specific * limitations in advance of when those limitations can be addressed * by the team. Any class built using subclassing to access the internals * of this class will likely fail to compile or run between releases and * may be strongly platform specific. Subclassing should not be attempted * without an intimate and detailed understanding of the workings of the * hierarchy. No support is provided for user-written classes which are * implemented as subclasses of this class. *
* * @see #checkSubclass * @see Sample code and further information */ public abstract class Widget { int style, state; Display display; EventTable eventTable; Object data; long /*int*/ jniRef; /* Global state flags */ static final int DISPOSED = 1 << 0; static final int CANVAS = 1 << 1; static final int KEYED_DATA = 1 << 2; static final int DISABLED = 1 << 3; static final int HIDDEN = 1 << 4; static final int HOT = 1 << 5; static final int MOVED = 1 << 6; static final int RESIZED = 1 << 7; static final int EXPANDING = 1 << 8; static final int IGNORE_WHEEL = 1 << 9; static final int PARENT_BACKGROUND = 1 << 10; static final int THEME_BACKGROUND = 1 << 11; /* A layout was requested on this widget */ static final int LAYOUT_NEEDED = 1<<12; /* The preferred size of a child has changed */ static final int LAYOUT_CHANGED = 1<<13; /* A layout was requested in this widget hierachy */ static final int LAYOUT_CHILD = 1<<14; /* More global state flags */ static final int RELEASED = 1<<15; static final int DISPOSE_SENT = 1<<16; static final int FOREIGN_HANDLE = 1<<17; static final int DRAG_DETECT = 1<<18; static final int RESIZING = 1<<19; /* WebKit fixes */ static final int WEBKIT_EVENTS_FIX = 1<<20; static final String WEBKIT_EVENTS_FIX_KEY = "org.eclipse.swt.internal.webKitEventsFix"; //$NON-NLS-1$ static final String GLCONTEXT_KEY = "org.eclipse.swt.internal.cocoa.glcontext"; //$NON-NLS-1$ static final String IS_ACTIVE = "org.eclipse.swt.internal.isActive"; //$NON-NLS-1$ /* Notify of the opportunity to skin this widget */ static final int SKIN_NEEDED = 1<<21; /* Bidi "auto" text direction */ static final int HAS_AUTO_DIRECTION = 0; /* Bidi flag and for auto text direction */ static final int AUTO_TEXT_DIRECTION = SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; /* Default size for widgets */ static final int DEFAULT_WIDTH = 64; static final int DEFAULT_HEIGHT = 64; Widget () { /* Do nothing */ } /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. ** The style value is either one of the style constants defined in * class
* * @param parent a widget which will be the parent of the new instance (cannot be null) * @param style the style of widget to construct * * @exception IllegalArgumentExceptionSWT
which is applicable to instances of this * class, or must be built by bitwise OR'ing together * (that is, using theint
"|" operator) two or more * of thoseSWT
style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the parent is null
*- ERROR_INVALID_ARGUMENT - if the parent is disposed
**
* * @see SWT * @see #checkSubclass * @see #getStyle */ public Widget (Widget parent, int style) { checkSubclass (); checkParent (parent); this.style = style; display = parent.display; reskinWidget (); } long /*int*/ accessibleHandle() { return 0; } long /*int*/ accessibilityActionDescription(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { return callSuperObject(id, sel, arg0); } long /*int*/ accessibilityActionNames(long /*int*/ id, long /*int*/ sel) { return callSuperObject(id, sel); } long /*int*/ accessibilityAttributeNames(long /*int*/ id, long /*int*/ sel) { return callSuperObject(id, sel); } long /*int*/ accessibilityAttributeValue(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { return callSuperObject(id, sel, arg0); } long /*int*/ accessibilityAttributeValue_forParameter(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, arg0, arg1); } long /*int*/ accessibilityFocusedUIElement(long /*int*/ id, long /*int*/ sel) { return callSuperObject(id, sel); } long /*int*/ accessibilityHitTest(long /*int*/ id, long /*int*/ sel, NSPoint point) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, point); } boolean accessibilityIsAttributeSettable(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { return callSuperBoolean(id, sel, arg0); } boolean accessibilityIsIgnored(long /*int*/ id, long /*int*/ sel) { return callSuperBoolean(id, sel); } long /*int*/ accessibilityParameterizedAttributeNames(long /*int*/ id, long /*int*/ sel) { return callSuperObject(id, sel); } void accessibilityPerformAction(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { callSuper(id, sel, arg0); } void accessibilitySetValue_forAttribute(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) { callSuper(id, sel, arg0, arg1); } String getClipboardText () { NSPasteboard pasteboard = NSPasteboard.generalPasteboard (); if (pasteboard == null) return ""; NSString string = pasteboard.stringForType (OS.NSStringPboardType); return string != null ? string.getString () : null; } void setClipRegion (NSView view) { } long /*int*/ attributedSubstringFromRange (long /*int*/ id, long /*int*/ sel, long /*int*/ range) { return 0; } void callSuper(long /*int*/ id, long /*int*/ sel) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel); } void callSuper(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, arg0); } void callSuper(long /*int*/ id, long /*int*/ sel, NSRect arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, arg0); } void callSuper(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, arg0, arg1); } void callSuper(long /*int*/ id, long /*int*/ sel, NSRect arg0, long /*int*/ arg1) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, arg0, arg1); } long /*int*/ callSuper(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, NSRect arg1, long /*int*/ arg2) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, arg0, arg1, arg2); } boolean callSuperBoolean(long /*int*/ id, long /*int*/ sel) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel) != 0; } boolean canBecomeKeyWindow (long /*int*/ id, long /*int*/ sel) { return callSuperBoolean (id, sel); } boolean needsPanelToBecomeKey (long /*int*/ id, long /*int*/ sel) { return callSuperBoolean (id, sel); } void cancelOperation(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { } NSSize cellSize (long /*int*/ id, long /*int*/ sel) { NSSize result = new NSSize(); objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper_stret(result, super_struct, sel); return result; } NSSize cellSizeForBounds (long /*int*/ id, long /*int*/ sel, NSRect cellFrame) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSSize result = new NSSize(); OS.objc_msgSendSuper_stret(result, super_struct, sel, cellFrame); return result; } boolean callSuperBoolean(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, arg0) != 0; } boolean callSuperBoolean(long /*int*/ id, long /*int*/ sel, NSRange range, long /*int*/ arg1) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper_bool(super_struct, sel, range, arg1); } long /*int*/ callSuperObject(long /*int*/ id, long /*int*/ sel) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel); } long /*int*/ callSuperObject(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, arg0); } long /*int*/ callSuperObject(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, arg0, arg1); } NSRect callSuperRect(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSRect result = new NSRect(); OS.objc_msgSendSuper_stret(result, super_struct, sel, arg0); return result; } NSRect callSuperRect(long /*int*/ id, long /*int*/ sel, NSRect rect, long /*int*/ arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSRect result = new NSRect(); OS.objc_msgSendSuper_stret(result, super_struct, sel, rect, arg0); return result; } boolean canDragRowsWithIndexes_atPoint(long /*int*/ id, long /*int*/ sel, long /*int*/ rowIndexes, NSPoint mouseDownPoint) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper_bool(super_struct, sel, rowIndexes, mouseDownPoint); } long /*int*/ characterIndexForPoint (long /*int*/ id, long /*int*/ sel, long /*int*/ point) { return OS.NSNotFound; } long /*int*/ columnAtPoint(long /*int*/ id, long /*int*/ sel, NSPoint point) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, point); } boolean acceptsFirstMouse (long /*int*/ id, long /*int*/ sel, long /*int*/ theEvent) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); return OS.objc_msgSendSuper(super_struct, sel, theEvent) != 0; } boolean acceptsFirstResponder (long /*int*/ id, long /*int*/ sel) { return callSuperBoolean(id, sel); } boolean becomeFirstResponder (long /*int*/ id, long /*int*/ sel) { return callSuperBoolean(id, sel); } void becomeKeyWindow (long /*int*/ id, long /*int*/ sel) { callSuper(id, sel); } /** * Marks the widget to be skinned. *- 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
** The skin event is sent to the receiver's display when appropriate (usually before the next event * is handled). Widgets are automatically marked for skinning upon creation as well as when its skin * id or class changes. The skin id and/or class can be changed by calling {@link Display#setData(String, Object)} * with the keys {@link SWT#SKIN_ID} and/or {@link SWT#SKIN_CLASS}. Once the skin event is sent to a widget, it * will not be sent again unless
*reskin(int)
is called on the widget or on an ancestor * while specifying theSWT.ALL
flag. ** The parameter
flags
may be either: **
* * @param flags the flags specifying how to reskin * * @exception SWTException *- {@link SWT#ALL}
*- all children in the receiver's widget tree should be skinned
*- {@link SWT#NONE}
*- only the receiver should be skinned
**
* @since 3.6 */ public void reskin (int flags) { checkWidget (); reskinWidget (); if ((flags & SWT.ALL) != 0) reskinChildren (flags); } void reskinChildren (int flags) { } void reskinWidget() { if ((state & SKIN_NEEDED) != SKIN_NEEDED) { this.state |= SKIN_NEEDED; display.addSkinnableWidget(this); } } boolean resignFirstResponder (long /*int*/ id, long /*int*/ sel) { return callSuperBoolean(id, sel); } /** * Adds the listener to the collection of listeners who will * be notified when an event of the given type occurs. When the * event does occur in the widget, the listener is notified by * sending it the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*handleEvent()
message. The event * type is one of the event constants defined in classSWT
. * * @param eventType the type of event to listen for * @param listener the listener which should be notified when the event occurs * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see Listener * @see SWT * @see #getListeners(int) * @see #removeListener(int, Listener) * @see #notifyListeners */ public void addListener (int eventType, Listener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); _addListener (eventType, listener); } void _addListener (int eventType, Listener listener) { if (eventTable == null) eventTable = new EventTable (); eventTable.hook (eventType, listener); } /** * Adds the listener to the collection of listeners who will * be notified when the widget is disposed. When the widget is * disposed, the listener is notified by sending it the *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*widgetDisposed()
message. * * @param listener the listener which should be notified when the receiver is disposed * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see DisposeListener * @see #removeDisposeListener */ public void addDisposeListener (DisposeListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Dispose, typedListener); } boolean canBecomeKeyView(long /*int*/ id, long /*int*/ sel) { return true; } static int checkBits (int style, int int0, int int1, int int2, int int3, int int4, int int5) { int mask = int0 | int1 | int2 | int3 | int4 | int5; if ((style & mask) == 0) style |= int0; if ((style & int0) != 0) style = (style & ~mask) | int0; if ((style & int1) != 0) style = (style & ~mask) | int1; if ((style & int2) != 0) style = (style & ~mask) | int2; if ((style & int3) != 0) style = (style & ~mask) | int3; if ((style & int4) != 0) style = (style & ~mask) | int4; if ((style & int5) != 0) style = (style & ~mask) | int5; return style; } void checkOpen () { /* Do nothing */ } void checkOrientation (Widget parent) { style &= ~SWT.MIRRORED; if ((style & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT)) == 0) { if (parent != null) { if ((parent.style & SWT.LEFT_TO_RIGHT) != 0) style |= SWT.LEFT_TO_RIGHT; if ((parent.style & SWT.RIGHT_TO_LEFT) != 0) style |= SWT.RIGHT_TO_LEFT; } } style = checkBits (style, SWT.LEFT_TO_RIGHT, SWT.RIGHT_TO_LEFT, 0, 0, 0, 0); } void checkParent (Widget parent) { if (parent == null) error (SWT.ERROR_NULL_ARGUMENT); if (parent.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); parent.checkWidget (); parent.checkOpen (); } /** * Checks that this class can be subclassed. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** The SWT class library is intended to be subclassed * only at specific, controlled points (most notably, *
Composite
andCanvas
when * implementing new widgets). This method enforces this * rule unless it is overridden. ** IMPORTANT: By providing an implementation of this * method that allows a subclass of a class which does not * normally allow subclassing to be created, the implementer * agrees to be fully responsible for the fact that any such * subclass will likely fail between SWT releases and will be * strongly platform specific. No support is provided for * user-written classes which are implemented in this fashion. *
* The ability to subclass outside of the allowed SWT classes * is intended purely to enable those not on the SWT development * team to implement patches in order to get around specific * limitations in advance of when those limitations can be * addressed by the team. Subclassing should not be attempted * without an intimate and detailed understanding of the hierarchy. *
* * @exception SWTException*
*/ protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } /** * Throws an- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
*SWTException
if the receiver can not * be accessed by the caller. This may include both checks on * the state of the receiver and more generally on the entire * execution context. This method should be called by * widget implementors to enforce the standard SWT invariants. ** Currently, it is an error to invoke any method (other than *
isDisposed()
) on a widget that has had its *dispose()
method called. It is also an error * to call widget methods from any thread that is different * from the thread that created the widget. ** In future releases of SWT, there may be more or fewer error * checks and exceptions may be thrown for different reasons. *
* * @exception SWTException*
*/ protected void checkWidget () { Display display = this.display; if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED); } void clearDeferFlushing (long /*int*/ id, long /*int*/ sel) { } boolean textView_clickOnLink_atIndex(long /*int*/ id, long /*int*/ sel, long /*int*/ textView, long /*int*/ link, long /*int*/ charIndex) { return true; } void collapseItem_collapseChildren (long /*int*/ id, long /*int*/ sel, long /*int*/ item, boolean children) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, item, children); } void copyToClipboard (char [] buffer) { if (buffer.length == 0) return; NSPasteboard pasteboard = NSPasteboard.generalPasteboard (); if (pasteboard == null) return; pasteboard.declareTypes (NSArray.arrayWithObject (OS.NSStringPboardType), null); pasteboard.setString (NSString.stringWithCharacters (buffer, buffer.length), OS.NSStringPboardType); } void createHandle () { } void createJNIRef () { jniRef = OS.NewGlobalRef(this); if (jniRef == 0) error (SWT.ERROR_NO_HANDLES); } void createWidget () { createJNIRef (); createHandle (); setOrientation(); register (); } void comboBoxSelectionDidChange(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { } void comboBoxWillDismiss(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { } void comboBoxWillPopUp(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { } void dealloc (long /*int*/id, long /*int*/sel) { callSuper (id, sel); } void deregister () { } void destroyJNIRef () { if (jniRef != 0) OS.DeleteGlobalRef (jniRef); jniRef = 0; } void destroyWidget () { releaseHandle (); } /** * Disposes of the operating system resources associated with * the receiver and all its descendants. After this method has * been invoked, the receiver and all descendants will answer *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*true
when sent the messageisDisposed()
. * Any internal connections between the widgets in the tree will * have been removed to facilitate garbage collection. * This method does nothing if the widget is already disposed. ** NOTE: This method is not called recursively on the descendants * of the receiver. This means that, widget implementers can not * detect when a widget is being disposed of by re-implementing * this method, but should instead listen for the
* * @exception SWTExceptionDispose
* event. **
* * @see #addDisposeListener * @see #removeDisposeListener * @see #checkWidget */ public void dispose () { /* * Note: It is valid to attempt to dispose a widget * more than once. If this happens, fail silently. */ if (isDisposed ()) return; if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); release (true); } void deselectAll(long /*int*/ id, long /*int*/ sel, long /*int*/ sender) { callSuper(id, sel, sender); } void deselectRow(long /*int*/ id, long /*int*/ sel, long /*int*/ index) { callSuper(id, sel, index); } void doCommandBySelector (long /*int*/ id, long /*int*/ sel, long /*int*/ aSelector) { callSuper (id, sel, aSelector); } boolean dragSelectionWithEvent(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0, long /*int*/ arg1, long /*int*/ arg2) { return false; } void drawBackground (long /*int*/ id, NSGraphicsContext context, NSRect rect) { /* Do nothing */ } void drawBackgroundInClipRect(long /*int*/ id, long /*int*/ sel, NSRect rect) { callSuper(id, sel, rect); } void drawImageWithFrameInView (long /*int*/ id, long /*int*/ sel, long /*int*/ image, NSRect rect, long /*int*/ view) { callSuper(id, sel, image, rect, view); } NSRect drawTitleWithFrameInView (long /*int*/ id, long /*int*/ sel, long /*int*/ title, NSRect rect, long /*int*/ view) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSRect result = new NSRect(); OS.objc_msgSendSuper_stret(result, super_struct, sel, title, rect, view); return result; } void drawInteriorWithFrame_inView (long /*int*/ id, long /*int*/ sel, NSRect cellFrame, long /*int*/ view) { callSuper(id, sel, cellFrame, view); } void drawLabelInRect(long /*int*/ id, long /*int*/ sel, boolean shouldTruncateLabel, NSRect rect) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, shouldTruncateLabel, rect); } void drawViewBackgroundInRect(long /*int*/ id, long /*int*/ sel, NSRect rect) { callSuper(id, sel, rect); } void drawWithExpansionFrame_inView (long /*int*/ id, long /*int*/ sel, NSRect cellFrame, long /*int*/ view) { callSuper(id, sel, cellFrame, view); } void drawRect (long /*int*/ id, long /*int*/ sel, NSRect rect) { if (!isDrawing()) return; Display display = this.display; NSView view = new NSView(id); display.isPainting.addObject(view); NSGraphicsContext context = NSGraphicsContext.currentContext(); context.saveGraphicsState(); setClipRegion(view); drawBackground (id, context, rect); objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, rect); if (!isDisposed()) { /* * Feature in Cocoa. There are widgets that draw outside of the UI thread, * such as the progress bar and default button. The fix is to draw the * widget but not send paint events. */ drawWidget (id, context, rect); } context.restoreGraphicsState(); display.isPainting.removeObjectIdenticalTo(view); } void _drawThemeProgressArea (long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, arg0); } void drawWidget (long /*int*/ id, NSGraphicsContext context, NSRect rect) { } long /*int*/ imageView () { return 0; } void redrawWidget (NSView view, boolean children) { view.setNeedsDisplay(true); } void redrawWidget (NSView view, long /*int*/ x, long /*int*/ y, long /*int*/ width, long /*int*/ height, boolean children) { NSRect rect = new NSRect(); rect.x = x; rect.y = y; rect.width = width; rect.height = height; view.setNeedsDisplayInRect(rect); } void error (int code) { SWT.error(code); } void expandItem_expandChildren (long /*int*/ id, long /*int*/ sel, long /*int*/ item, boolean children) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); OS.objc_msgSendSuper(super_struct, sel, item, children); } NSRect expansionFrameWithFrame_inView(long /*int*/ id, long /*int*/ sel, NSRect cellRect, long /*int*/ view) { objc_super super_struct = new objc_super(); super_struct.receiver = id; super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass); NSRect result = new NSRect(); OS.objc_msgSendSuper_stret(result, super_struct, sel, cellRect, view); return result; } boolean filters (int eventType) { return display.filters (eventType); } NSRect firstRectForCharacterRange(long /*int*/ id, long /*int*/ sel, long /*int*/ range) { return new NSRect (); } int fixMnemonic (char [] buffer) { int i=0, j=0; while (i < buffer.length) { if ((buffer [j++] = buffer [i++]) == '&') { if (i == buffer.length) {continue;} if (buffer [i] == '&') {i++; continue;} j--; } } return j; } NSRect focusRingMaskBoundsForFrame(long /*int*/ id, long /*int*/ sel, NSRect cellFrame, long /*int*/ view) { return callSuperRect(id, sel, cellFrame, view); } /** * Returns the application defined widget data associated * with the receiver, or null if it has not been set. The * widget data is a single, unnamed field that is * stored with every widget. *- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Applications may put arbitrary objects in this field. If * the object stored in the widget data needs to be notified * when the widget is disposed of, it is the application's * responsibility to hook the Dispose event on the widget and * do so. *
* * @return the widget data * * @exception SWTException*
* * @see #setData(Object) */ public Object getData () { checkWidget(); return (state & KEYED_DATA) != 0 ? ((Object []) data) [0] : data; } /** * Returns the application defined property of the receiver * with the specified name, or null if it has not been set. *- ERROR_WIDGET_DISPOSED - when the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread
** Applications may have associated arbitrary objects with the * receiver in this fashion. If the objects stored in the * properties need to be notified when the widget is disposed * of, it is the application's responsibility to hook the * Dispose event on the widget and do so. *
* * @param key the name of the property * @return the value of the property or null if it has not been set * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the key is null
**
* * @see #setData(String, Object) */ public Object getData (String key) { checkWidget(); if (key == null) error (SWT.ERROR_NULL_ARGUMENT); if (key.equals(IS_ACTIVE)) return Boolean.valueOf(isActive()); if ((state & KEYED_DATA) != 0) { Object [] table = (Object []) data; for (int i=1; i- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*Display * A widget's display is either provided when it is created * (for example, top level
* * @return the receiver's display * * @exception SWTExceptionShell
s) or is the * same as its parent's display. *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
SWT
.
*
* @param eventType the type of event to listen for
* @return an array of listeners that will be notified when the event occurs
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note that the value which is returned by this method may
* not match the value which was provided to the constructor
* when the receiver was created. This can occur when the underlying
* operating system does not support a particular combination of
* requested styles. For example, if the platform widget used to
* implement a particular SWT widget always has scroll bars, the
* result of calling this method would always have the
* SWT.H_SCROLL
and SWT.V_SCROLL
bits set.
*
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
true
if the widget has auto text direction,
* and false
otherwise.
*
* @return true
when the widget has auto direction and false
otherwise
*
* @see SWT#AUTO_TEXT_DIRECTION
*
* @since 3.105
*/
public boolean isAutoDirection () {
return false;
}
/**
* Returns true
if the widget has been disposed,
* and false
otherwise.
* * This method gets the dispose state for the widget. * When a widget has been disposed, it is an error to * invoke any other method (except {@link #dispose()}) using the widget. *
* * @returntrue
when the widget is disposed and false
otherwise
*/
public boolean isDisposed () {
return (state & DISPOSED) != 0;
}
boolean isDrawing () {
return true;
}
boolean isFlipped(long /*int*/ id, long /*int*/ sel) {
objc_super super_struct = new objc_super();
super_struct.receiver = id;
super_struct.super_class = OS.objc_msgSend(id, OS.sel_superclass);
return OS.objc_msgSendSuper(super_struct, sel) != 0;
}
/**
* Returns true
if there are any listeners
* for the specified event type associated with the receiver,
* and false
otherwise. The event type is one of
* the event constants defined in class SWT
.
*
* @param eventType the type of event
* @return true if the event is hooked
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
handleEvent()
method. The
* event type is one of the event constants defined in class
* SWT
.
*
* @param eventType the type of event which has occurred
* @param event the event data
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
SWT
.
*
* @param eventType the type of event to listen for
* @param listener the listener which should no longer be notified
*
* @exception IllegalArgumentException -
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* IMPORTANT: This method is not part of the SWT * public API. It is marked public only so that it can be shared * within the packages provided by SWT. It should never be * referenced from application code. *
* * @param eventType the type of event to listen for * @param listener the listener which should no longer be notified * * @exception IllegalArgumentException-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Applications may put arbitrary objects in this field. If * the object stored in the widget data needs to be notified * when the widget is disposed of, it is the application's * responsibility to hook the Dispose event on the widget and * do so. *
* * @param data the widget data * * @exception SWTException-
*
- ERROR_WIDGET_DISPOSED - when the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread *
* Applications may associate arbitrary objects with the * receiver in this fashion. If the objects stored in the * properties need to be notified when the widget is disposed * of, it is the application's responsibility to hook the * Dispose event on the widget and do so. *
* * @param key the name of the property * @param value the new value for the property * * @exception IllegalArgumentException-
*
- ERROR_NULL_ARGUMENT - if the key is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *