summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine <veronika>2002-10-30 23:19:06 +0000
committerVeronika Irvine <veronika>2002-10-30 23:19:06 +0000
commite9b9610a8d12f5925f58291260d62a8f4c2a1d2d (patch)
tree361a83f5eb408476738da21ded5cce4dcd19dd94
parent60bdd070c5ec14c10c91df7cde237b89fddc0025 (diff)
downloadeclipse.platform.swt-e9b9610a8d12f5925f58291260d62a8f4c2a1d2d.tar.gz
eclipse.platform.swt-e9b9610a8d12f5925f58291260d62a8f4c2a1d2d.tar.xz
eclipse.platform.swt-e9b9610a8d12f5925f58291260d62a8f4c2a1d2d.zip
*** empty log message ***carbon_work_v1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java692
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java43
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java513
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java2311
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java594
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java2025
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java561
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java357
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java1317
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java777
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java52
11 files changed, 460 insertions, 8782 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java
index f4f4e25a40..da2a316dd0 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Button.java
@@ -10,112 +10,12 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
-import org.eclipse.swt.internal.carbon.ControlButtonContentInfo;
-
-/**
- * Instances of this class represent a selectable user interface object that
- * issues notification when pressed and released.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
- * <dd>UP, DOWN, LEFT, RIGHT, CENTER</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles ARROW, CHECK, PUSH, RADIO, and TOGGLE
- * may be specified.
- * </p><p>
- * Note: Only one of the styles LEFT, RIGHT, and CENTER may be specified.
- * </p><p>
- * Note: Only one of the styles UP, DOWN, LEFT, and RIGHT may be specified
- * when the ARROW style is specified.
- * </p><p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
public /*final*/ class Button extends Control {
- Image image;
-
- // AW
- private boolean fImageMode;
- private int fAlignment;
- private int fCIconHandle;
- private int fTopMargin;
- private int fBottomMargin;
-
- private static final int MARGIN= 3; // correct value would be 6; however the shadow is only 2
- private static final int SPACE= 9; // min is 8 or may be 9
- private static final int TOP_MARGIN= 0; //
- private static final int BOTTOM_MARGIN= 5; //
- // AW
-
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#ARROW
- * @see SWT#CHECK
- * @see SWT#PUSH
- * @see SWT#RADIO
- * @see SWT#TOGGLE
- * @see SWT#FLAT
- * @see SWT#LEFT
- * @see SWT#RIGHT
- * @see SWT#CENTER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
+
public Button (Composite parent, int style) {
super (parent, checkStyle (style));
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the control is selected, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * <code>widgetSelected</code> is called when the control is selected.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
+
public void addSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -123,6 +23,7 @@ public void addSelectionListener(SelectionListener listener) {
addListener(SWT.Selection,typedListener);
addListener(SWT.DefaultSelection,typedListener);
}
+
static int checkStyle (int style) {
style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
if ((style & SWT.PUSH) != 0) {
@@ -136,385 +37,39 @@ static int checkStyle (int style) {
}
return style;
}
-void click () {
- short part= 10;
- if ((style & SWT.CHECK) != 0 || (style & SWT.RADIO) != 0)
- part= 11;
- OS.HIViewSimulateClick(handle, part, 0, new short[1]);
-}
+
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
- int border = getBorderWidth ();
- int width = border * 2, height = border * 2;
- if ((style & SWT.ARROW) != 0) {
- Display display = getDisplay ();
- width += display.scrolledMarginX;
- height += display.scrolledMarginY;
- return new Point (width, height);
- }
- /* AW
- XtWidgetGeometry result = new XtWidgetGeometry ();
- result.request_mode = OS.CWWidth | OS.CWHeight;
- int [] argList2 = {OS.XmNrecomputeSize, 1};
- OS.XtSetValues(handle, argList2, argList2.length / 2);
- OS.XtQueryGeometry (handle, null, result);
- int [] argList3 = {OS.XmNrecomputeSize, 0};
- OS.XtSetValues(handle, argList3, argList3.length / 2);
- */
- Point result= MacUtil.computeSize(handle);
- if ((style & SWT.PUSH) != 0) {
- if (image != null) { // is a Bevel button!
- Rectangle bounds= image.getBounds();
- result.x= 4 + bounds.width + 4;
- result.y= 4 + bounds.height + 4;
- } else {
- String s= getText();
- if (s != null && s.length() > 0) {
- result.x= result.x - 2*SPACE + 2*MARGIN;
- result.y= result.y + TOP_MARGIN + BOTTOM_MARGIN;
- }
- }
- }
- width += result.x;
- height += result.y;
- /*
- * Feature in Motif. If a button's labelType is XmSTRING but it
- * has no label set into it yet, recomputing the size will
- * not take into account the height of the font, as we would
- * like it to. Take care of this case.
- */
- /* AW
- int [] argList = {OS.XmNlabelType, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- if (argList [1] == OS.XmSTRING) {
- int [] argList1 = {OS.XmNlabelString, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- int xmString = argList1 [1];
- if (OS.XmStringEmpty (xmString)) height += getFontHeight ();
- }
- */
- if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
- /* AW
- int [] argList4 = new int [] {OS.XmNmarginLeft, 0, OS.XmNmarginRight, 0, OS.XmNmarginTop, 0, OS.XmNmarginBottom, 0};
- OS.XtGetValues (handle, argList4, argList4.length / 2);
- if (wHint != SWT.DEFAULT) width = wHint + argList4 [1] + argList4 [3] + (border * 2);
- if (hHint != SWT.DEFAULT) height = hHint + argList4 [5] + argList4 [7] + (border * 2);
- */
- int left= 0;
- int right= 0;
- int top= 0;
- int bottom= 0;
-
- if (wHint != SWT.DEFAULT) width = wHint + left + right;
- if (hHint != SWT.DEFAULT) height = hHint + top + bottom;
- }
-
- return new Point(width, height);
+ return new Point(0, 0);
}
void createHandle (int index) {
state |= HANDLE;
- /* AW
- int borderWidth = (style & SWT.BORDER) != 0 ? 1 : 0;
- */
- int parentHandle = parent.handle;
-
- /* ARROW button */
- if ((style & SWT.ARROW) != 0) {
- System.out.println("Button.createHandle(Arrow): nyi");
- /*
- int alignment = OS.XmARROW_UP;
- if ((style & SWT.UP) != 0) alignment = OS.XmARROW_UP;
- if ((style & SWT.DOWN) != 0) alignment = OS.XmARROW_DOWN;
- if ((style & SWT.LEFT) != 0) alignment = OS.XmARROW_LEFT;
- if ((style & SWT.RIGHT) != 0) alignment = OS.XmARROW_RIGHT;
- int [] argList = {
- OS.XmNtraversalOn, 0,
- OS.XmNarrowDirection, alignment,
- OS.XmNborderWidth, borderWidth,
- OS.XmNancestorSensitive, 1,
- };
- handle = OS.XmCreateArrowButton (parentHandle, null, argList, argList.length / 2);
- */
- //handle= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)0, (short)OS.kControlPopupArrowEastProc, 0);
- handle= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)0, (short)OS.kControlPushButtonProc, 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- MacUtil.insertControl(handle, parentHandle, -1);
- OS.HIViewSetVisible(handle, true);
- /* AW
- if ((style & SWT.FLAT) != 0) {
- int [] argList1 = {OS.XmNshadowThickness, 1};
- OS.XtSetValues (handle, argList1, argList1.length / 2);
- }
- */
- return;
- }
-
- /* Compute alignment */
- /* AW
- int alignment = OS.XmALIGNMENT_BEGINNING;
- if ((style & SWT.CENTER) != 0) alignment = OS.XmALIGNMENT_CENTER;
- if ((style & SWT.RIGHT) != 0) alignment = OS.XmALIGNMENT_END;
- */
-
- /* TOGGLE button */
- if ((style & SWT.TOGGLE) != 0) {
- /*
- * Bug in Motif. When XmNindicatorOn is set to false,
- * Motif doesn't reset the shadow thickness to give a
- * push button look. The fix is to set the shadow
- * thickness when ever this resource is changed.
- */
- /* AW
- Display display = getDisplay ();
- int thickness = display.buttonShadowThickness;
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNindicatorOn, 0,
- OS.XmNshadowThickness, (style & SWT.FLAT) != 0 ? 1 : thickness,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- };
- handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2);
- */
- handle= OS.NewControl(0, new Rect(), null, false, (short)0, (short)OS.kControlBehaviorToggles, (short)0, (short)OS.kControlBevelButtonNormalBevelProc, 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- MacUtil.insertControl(handle, parentHandle, -1);
- OS.HIViewSetVisible(handle, true);
- setFont(defaultFont());
- return;
- }
-
- /* CHECK or RADIO button */
- if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
- /*
- * Bug in Motif. For some reason, a toggle button
- * with XmNindicatorType XmONE_OF_MANY must have this
- * value set at creation or the highlight color will
- * not be correct. The fix is to set these values
- * on create.
- */
- /* AW
- int indicatorType = OS.XmONE_OF_MANY;
- if ((style & SWT.CHECK) != 0) indicatorType = OS.XmN_OF_MANY;
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNindicatorType, indicatorType,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- };
- handle = OS.XmCreateToggleButton (parentHandle, null, argList, argList.length / 2);
- */
- int type= (style & SWT.CHECK) != 0
- ? OS.kControlCheckBoxAutoToggleProc
- : OS.kControlRadioButtonAutoToggleProc;
- handle= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)100, (short)type, 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- MacUtil.insertControl(handle, parentHandle, -1);
- OS.HIViewSetVisible(handle, true);
- setFont(defaultFont());
- return;
- }
-
- /* PUSH button */
- /* AW
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNrecomputeSize, 0,
- OS.XmNalignment, alignment,
- OS.XmNborderWidth, borderWidth,
- */
- int type= (style & SWT.FLAT) != 0
- ? OS.kControlBevelButtonNormalBevelProc
- : OS.kControlPushButtonProc;
- handle= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)0, (short)type, 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- MacUtil.insertControl(handle, parentHandle, -1);
- OS.HIViewSetVisible(handle, true);
- setFont(defaultFont());
- /* AW
- if ((style & SWT.FLAT) != 0) {
- int [] argList1 = {OS.XmNshadowThickness, 1};
- OS.XtSetValues (handle, argList1, argList1.length / 2);
- }
- */
-}
-int defaultBackground () {
- return getDisplay ().buttonBackground;
}
-Font defaultFont () {
- return getDisplay ().buttonFont;
-}
-int defaultForeground () {
- return getDisplay ().buttonForeground;
-}
-/**
- * Returns a value which describes the position of the
- * text or image in the receiver. The value will be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the alignment will indicate the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>).
- *
- * @return the alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getAlignment () {
checkWidget();
- return fAlignment;
-}
-boolean getDefault () {
- if ((style & SWT.PUSH) == 0) return false;
- int[] control= new int[1];
- OS.GetWindowDefaultButton(OS.GetControlOwner(handle), control);
- return control[0] == handle;
+ return 0;
}
-/**
- * Returns the receiver's image if it has one, or null
- * if it does not.
- *
- * @return the receiver's image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Image getImage () {
checkWidget();
- return image;
+ return null;
}
String getNameText () {
return getText ();
}
-/**
- * Returns <code>true</code> if the receiver is selected,
- * and false otherwise.
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in. If the receiver is of any other type,
- * this method returns false.
- *
- * @return the selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean getSelection () {
checkWidget();
if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
- return OS.GetControl32BitValue(handle) != 0;
+ return false;
}
-/**
- * Returns the receiver's text, which will be an empty
- * string if it has never been set.
- *
- * @return the receiver's text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public String getText () {
checkWidget();
- if ((style & SWT.ARROW) != 0) return "";
- int sHandle[]= new int[1];
- OS.CopyControlTitleAsCFString(handle, sHandle);
- return MacUtil.getStringAndRelease(sHandle[0]);
-}
-void hookEvents () {
- super.hookEvents ();
- /* AW
- int callback = OS.XmNactivateCallback;
- int windowProc = getDisplay ().windowProc;
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) callback = OS.XmNvalueChangedCallback;
- OS.XtAddCallback (handle, callback, windowProc, SWT.Selection);
- */
- Display display= getDisplay();
- OS.SetControlAction(handle, display.fControlActionProc);
-}
-boolean mnemonicHit (char key) {
- if (!setFocus ()) return false;
- click ();
- return true;
-}
-/* AW
-boolean mnemonicMatch (char key) {
- char mnemonic = findMnemonic (getText ());
- if (mnemonic == '\0') return false;
- return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
-}
-*/
-int processFocusIn () {
- super.processFocusIn ();
- // widget could be disposed at this point
- if (handle == 0) return 0;
- if ((style & SWT.PUSH) == 0) return 0;
- getShell ().setDefaultButton (this, false);
- return 0;
+ return "";
}
-int processFocusOut () {
- super.processFocusOut ();
- // widget could be disposed at this point
- if (handle == 0) return 0;
- if ((style & SWT.PUSH) == 0) return 0;
- if (getDefault ()) {
- getShell ().setDefaultButton (null, false);
- }
- return 0;
-}
-int processSelection (Object callData) {
- if ((style & SWT.RADIO) != 0) {
- if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) selectRadio ();
- }
- return super.processSelection (callData);
-}
-void releaseWidget () {
- super.releaseWidget ();
- /*
- int [] argList = {
- OS.XmNlabelPixmap, OS.XmUNSPECIFIED_PIXMAP,
- OS.XmNlabelInsensitivePixmap, OS.XmUNSPECIFIED_PIXMAP,
- };
- OS.XtSetValues (handle, argList, argList.length / 2);
- */
- if (fCIconHandle != 0) {
- if (handle != 0) {
- ControlButtonContentInfo inContent = new ControlButtonContentInfo();
- OS.SetBevelButtonContentInfo(handle, inContent);
- }
- Image.disposeCIcon(fCIconHandle);
- fCIconHandle= 0;
- }
- image = null;
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the control is selected.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
+
public void removeSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -522,232 +77,21 @@ public void removeSelectionListener(SelectionListener listener) {
eventTable.unhook(SWT.Selection, listener);
eventTable.unhook(SWT.DefaultSelection,listener);
}
-void selectRadio () {
- Control [] children = parent._getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (this != child && child instanceof Button) {
- Button button = (Button) child;
- if ((button.getStyle () & SWT.RADIO) != 0) {
- if (button.getSelection ()) {
- button.setSelection (false);
- button.postEvent (SWT.Selection);
- }
- }
- }
- }
- setSelection (true);
-}
-/**
- * Controls how text, images and arrows will be displayed
- * in the receiver. The argument should be one of
- * <code>LEFT</code>, <code>RIGHT</code> or <code>CENTER</code>
- * unless the receiver is an <code>ARROW</code> button, in
- * which case, the argument indicates the direction of
- * the arrow (one of <code>LEFT</code>, <code>RIGHT</code>,
- * <code>UP</code> or <code>DOWN</code>).
- *
- * @param alignment the new alignment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setAlignment (int alignment) {
checkWidget();
- if ((style & SWT.ARROW) != 0) {
- fAlignment= alignment;
- System.out.println("Button.setAlignment: nyi");
- return;
- }
- if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
- fAlignment= alignment;
- System.out.println("Button.setAlignment: nyi");
}
-void setDefault (boolean value) {
- if ((style & SWT.PUSH) == 0) return;
- if (getShell ().parent == null) return;
- OS.SetWindowDefaultButton(OS.GetControlOwner(handle), value ? handle : 0);
-}
-/**
- * Sets the receiver's image to the argument, which may be
- * null indicating that no image should be displayed.
- *
- * @param image the image to display on the receiver (may be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setImage (Image image) {
checkWidget();
-
- this.image = image;
-
- if (fCIconHandle != 0) {
- Image.disposeCIcon(fCIconHandle);
- fCIconHandle= 0;
- }
-
- if (image != null) {
- if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- fCIconHandle= Image.carbon_createCIcon(image);
- if (fCIconHandle != 0)
- setMode(fCIconHandle);
- } else
- setMode(0);
}
-/**
- * Sets the selection state of the receiver, if it is of type <code>CHECK</code>,
- * <code>RADIO</code>, or <code>TOGGLE</code>.
- *
- * <p>
- * When the receiver is of type <code>CHECK</code> or <code>RADIO</code>,
- * it is selected when it is checked. When it is of type <code>TOGGLE</code>,
- * it is selected when it is pushed in.
- *
- * @param selected the new selection state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setSelection (boolean selected) {
checkWidget();
- if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
- OS.SetControl32BitValue(handle, selected ? 1 : 0);
}
-/**
- * Sets the receiver's text.
- * <p>
- * This method sets the button label. The label may include
- * the mnemonic character but must not contain line delimiters.
- * </p>
- *
- * @param string the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the text is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setText (String string) {
checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.ARROW) != 0) return;
-
- int sHandle= 0;
- try {
- sHandle= OS.CFStringCreateWithCharacters(MacUtil.removeMnemonics(string));
- if (OS.SetControlTitleWithCFString(handle, sHandle) != OS.noErr)
- error (SWT.ERROR_CANNOT_SET_TEXT);
- } finally {
- if (sHandle != 0)
- OS.CFRelease(sHandle);
- }
-}
-
-int traversalCode () {
- int code = super.traversalCode ();
- if ((style & SWT.PUSH) != 0) return code;
- return code | SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
-}
-
-////////////////////////////////////////////////////////
-// Mac stuff
-////////////////////////////////////////////////////////
-
-private void setMode(int icon) {
-
- if ((style & SWT.FLAT) != 0 || fImageMode) {
- ControlButtonContentInfo inContent = new ControlButtonContentInfo();
- inContent.contentType = (short)OS.kControlContentCIconHandle;
- inContent.iconRef = icon;
- OS.SetBevelButtonContentInfo(handle, inContent);
- redraw();
- return;
- }
-
- if ((style & SWT.PUSH) == 0)
- return; // we only transmogrify push buttons
-
- fImageMode= true;
-
- int[] ph= new int[1];
- int rc= OS.GetSuperControl(handle, ph);
- if (rc != OS.noErr)
- System.out.println("Button.setMode: " + rc);
- int parentHandle= ph[0];
-
- Rect bounds= new Rect();
- OS.GetControlBounds(handle, bounds);
-
- int index= MacUtil.indexOf(parentHandle, handle);
- if (index < 0)
- System.out.println("Button.setMode: can't find handle");
- Widget w= WidgetTable.get(handle);
- WidgetTable.remove(handle);
- OS.DisposeControl(handle);
-
- int type= icon != 0 ? OS.kControlBevelButtonNormalBevelProc : OS.kControlPushButtonProc;
-
- handle= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)0, (short)type, 0);
- MacUtil.insertControl(handle, parentHandle, index);
- OS.HIViewSetVisible(handle, true);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- WidgetTable.put(handle, w);
-
- OS.SetControlBounds(handle, bounds);
- ControlButtonContentInfo inContent = new ControlButtonContentInfo();
- inContent.contentType = (short)OS.kControlContentCIconHandle;
- inContent.iconRef = icon;
- OS.SetBevelButtonContentInfo(handle, inContent);
-}
-
-/**
- * Overridden from Control.
- * x and y are relative to window!
- */
-void handleResize(int hndl, Rect bounds) {
- fTopMargin= fBottomMargin= 0;
- if ((style & SWT.PUSH) != 0 && image == null) { // for push buttons
- org.eclipse.swt.graphics.Point result= MacUtil.computeSize(hndl);
- int diff= (bounds.bottom-bounds.top)-result.y;
- fTopMargin= diff/2;
- fBottomMargin= diff-fTopMargin;
- bounds.left+= MARGIN;
- bounds.top+= fTopMargin;
- bounds.right-= MARGIN;
- bounds.bottom-= fBottomMargin;
- }
- super.handleResize(hndl, bounds);
-}
-
-void internalGetControlBounds(int hndl, Rect bounds) {
- super.internalGetControlBounds(hndl, bounds);
- if ((style & SWT.PUSH) != 0 && image == null) {
- bounds.left+= -MARGIN;
- bounds.top+= -fTopMargin;
- bounds.right-= -MARGIN;
- bounds.bottom-= -fBottomMargin;
- }
-}
-
-public void setFont (Font font) {
- super.setFont(null);
-}
-
-int sendKeyEvent(int type, MacEvent mEvent, Event event) {
- return OS.CallNextEventHandler(mEvent.getNextHandler(), mEvent.getEventRef());
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java
new file mode 100644
index 0000000000..a488b26219
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Canvas.java
@@ -0,0 +1,43 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
+ * This file is made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+public class Canvas extends Composite {
+
+Canvas () {
+ /* Do nothing */
+}
+
+public Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+
+
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+}
+
+void releaseWidget () {
+ super.releaseWidget();
+}
+
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ checkWidget();
+}
+
+public void setBounds (int x, int y, int width, int height) {
+ checkWidget();
+}
+
+public void setLocation (int x, int y) {
+ checkWidget();
+}
+
+public void setSize (int width, int height) {
+ checkWidget();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java
index 48a931bdfa..597668c640 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java
@@ -8,34 +8,8 @@ package org.eclipse.swt.widgets;
*/
import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
+import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class are controls which are capable
- * of containing other controls.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
- * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
- * They can be used with <code>Composite</code> if you are drawing your own, but their
- * behavior is undefined if they are used with subclasses of <code>Composite</code> other
- * than <code>Canvas</code>.
- * </p><p>
- * This class may be subclassed by custom control implementors
- * who are building controls that are constructed from aggregates
- * of other controls.
- * </p>
- *
- * @see Canvas
- */
public class Composite extends Scrollable {
Layout layout;
Control[] tabList;
@@ -43,70 +17,15 @@ public class Composite extends Scrollable {
Composite () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * </ul>
- *
- * @see SWT#NO_BACKGROUND
- * @see SWT#NO_FOCUS
- * @see SWT#NO_MERGE_PAINTS
- * @see SWT#NO_REDRAW_RESIZE
- * @see SWT#NO_RADIO_GROUP
- * @see Widget#getStyle
- */
+
public Composite (Composite parent, int style) {
super (parent, style);
}
+
Control [] _getChildren () {
- short[] cnt= new short[1];
- OS.CountSubControls(handle, cnt);
- int count= cnt[0];
- if (count == 0) return new Control [0];
- int[] outControl= new int[1];
- Control [] children = new Control [count];
- int i = 0, j = 0;
- while (i < count) {
- if (MacUtil.getChild(handle, outControl, count, i) != OS.noErr)
- error (SWT.ERROR_CANNOT_GET_ITEM);
- int handle = outControl [0];
- if (handle != 0) {
- Widget widget = WidgetTable.get (handle);
- if (widget != null && widget != this) {
- if (widget instanceof Control) {
- children [j++] = (Control) widget;
- }
- }
- }
- i++;
- }
- if (i == j) return children;
- Control [] newChildren = new Control [j];
- System.arraycopy (children, 0, newChildren, 0, j);
- return newChildren;
+ return new Control [0];
}
-/**
- * Returns tabList or null
- */
Control [] _getTabList () {
if (tabList == null) return null;
// ensure to return only non-disposed controls
@@ -129,23 +48,9 @@ Control [] _getTabList () {
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
- Point size;
- if (layout != null) {
- if ((wHint == SWT.DEFAULT) || (hHint == SWT.DEFAULT)) {
- size = layout.computeSize (this, wHint, hHint, changed);
- } else {
- size = new Point (wHint, hHint);
- }
- } else {
- size = minimumSize ();
- }
- if (size.x == 0) size.x = DEFAULT_WIDTH;
- if (size.y == 0) size.y = DEFAULT_HEIGHT;
- if (wHint != SWT.DEFAULT) size.x = wHint;
- if (hHint != SWT.DEFAULT) size.y = hHint;
- Rectangle trim = computeTrim (0, 0, size.x, size.y);
- return new Point (trim.width, trim.height);
+ return new Point (0, 0);
}
+
protected void checkSubclass () {
/* Do nothing - Subclassing is allowed */
}
@@ -169,175 +74,18 @@ Control [] computeTabList () {
void createHandle (int index) {
state |= HANDLE | CANVAS;
- if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) { // no scrollbars
- int border = (style & SWT.BORDER) != 0 ? 1 : 0;
- /* AW
- int [] argList = {
- OS.XmNancestorSensitive, 1,
- OS.XmNborderWidth, border,
- OS.XmNmarginWidth, 0,
- OS.XmNmarginHeight, 0,
- OS.XmNresizePolicy, OS.XmRESIZE_NONE,
- OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1,
- };
- */
- int features= OS.kControlSupportsEmbedding;
- if ((style & SWT.NO_FOCUS) == 0)
- features |= OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick;
- handle= OS.NewControl(0, new Rect(), null, false, (short)features, (short)0, (short)0, (short)OS.kControlUserPaneProc, 0);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- MacUtil.insertControl(handle, parent.handle, -1);
- OS.HIViewSetVisible(handle, true);
- /* AW
- Display display = getDisplay ();
- OS.XtOverrideTranslations (handle, display.tabTranslations);
- OS.XtOverrideTranslations (handle, display.arrowTranslations);
- */
- } else {
- createScrolledHandle (parent.handle);
- }
}
-void createScrolledHandle (int topHandle) {
-
- /* AW
- int [] argList = {OS.XmNancestorSensitive, 1};
- scrolledHandle = OS.XmCreateMainWindow (topHandle, null, argList, argList.length / 2);
- */
- scrolledHandle= createScrollView(topHandle, style);
- if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int features= OS.kControlSupportsEmbedding;
- if ((style & SWT.NO_FOCUS) == 0)
- features |= OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick;
-
- if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
- /* AW
- int thickness = display.buttonShadowThickness;
- int [] argList1 = {
- OS.XmNmarginWidth, 3,
- OS.XmNmarginHeight, 3,
- OS.XmNresizePolicy, OS.XmRESIZE_NONE,
- OS.XmNshadowType, OS.XmSHADOW_IN,
- OS.XmNshadowThickness, thickness,
- };
- formHandle = OS.XmCreateForm (scrolledHandle, null, argList1, argList1.length / 2);
- if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
- int [] argList2 = {
- OS.XmNmarginWidth, 0,
- OS.XmNmarginHeight, 0,
- OS.XmNresizePolicy, OS.XmRESIZE_NONE,
- OS.XmNtopAttachment, OS.XmATTACH_FORM,
- OS.XmNbottomAttachment, OS.XmATTACH_FORM,
- OS.XmNleftAttachment, OS.XmATTACH_FORM,
- OS.XmNrightAttachment, OS.XmATTACH_FORM,
- OS.XmNresizable, 0,
- OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1,
- };
- handle = OS.XmCreateDrawingArea (formHandle, null, argList2, argList2.length / 2);
- */
- handle= OS.NewControl(0, new Rect(), null, false, (short)features, (short)0, (short)0, (short)OS.kControlUserPaneProc, 0);
- } else {
- /* AW
- int [] argList3 = {
- OS.XmNmarginWidth, 0,
- OS.XmNmarginHeight, 0,
- OS.XmNresizePolicy, OS.XmRESIZE_NONE,
- OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1,
- };
- handle = OS.XmCreateDrawingArea (scrolledHandle, null, argList3, argList3.length / 2);
- */
- handle= OS.NewControl(0, new Rect(), null, false, (short)features, (short)0, (short)0, (short)OS.kControlUserPaneProc, 0);
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- MacUtil.insertControl(handle, scrolledHandle, -1);
- OS.HIViewSetVisible(handle, true);
- /* AW
- OS.XtOverrideTranslations (handle, display.tabTranslations);
- OS.XtOverrideTranslations (handle, display.arrowTranslations);
- */
-}
-int defaultBackground () {
- return getDisplay ().compositeBackground;
-}
-int defaultForeground () {
- return getDisplay ().compositeForeground;
-}
-/* AW
-public boolean forceFocus () {
- checkWidget();
- Control [] children = _getChildren ();
- int [] traversals = new int [children.length];
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- for (int i=0; i<children.length; i++) {
- OS.XtGetValues (children [i].handle, argList, argList.length / 2);
- traversals [i] = argList [1];
- argList [1] = 0;
- OS.XtSetValues (children [i].handle, argList, argList.length / 2);
- }
- boolean result = super.forceFocus ();
- for (int i=0; i<children.length; i++) {
- argList [1] = traversals [i];
- OS.XtSetValues (children [i].handle, argList, argList.length / 2);
- }
- return result;
-}
-*/
-/**
- * Returns an array containing the receiver's children.
- * <p>
- * Note: This is not the actual structure used by the receiver
- * to maintain its list of children, so modifying the array will
- * not affect the receiver.
- * </p>
- *
- * @return an array of children
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
public Control [] getChildren () {
checkWidget();
return _getChildren ();
}
-int getChildrenCount () {
- /*
- * NOTE: The current implementation will count
- * non-registered children.
- */
- short[] cnt= new short[1];
- OS.CountSubControls(handle, cnt);
- return cnt[0];
-}
-/**
- * Returns layout which is associated with the receiver, or
- * null if one has not been set.
- *
- * @return the receiver's layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Layout getLayout () {
checkWidget();
return layout;
}
-/**
- * Gets the last specified tabbing order for the control.
- *
- * @return tabList the ordered list of controls representing the tab order
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setTabList
- */
public Control [] getTabList () {
checkWidget ();
Control [] tabList = _getTabList ();
@@ -358,197 +106,27 @@ public Control [] getTabList () {
return tabList;
}
-void hookEvents () {
- super.hookEvents ();
- if ((state & CANVAS) != 0) {
- Display display= getDisplay();
- OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneHitTestProcTag, 4, new int[]{display.fUserPaneHitTestProc});
-
- int[] mask= new int[] {
- OS.kEventClassMouse, OS.kEventMouseDown,
- OS.kEventClassMouse, OS.kEventMouseWheelMoved,
- };
- OS.InstallEventHandler(OS.GetControlEventTarget(handle), display.fMouseProc, mask.length/2, mask, handle, null);
-
- mask= new int[] {
- OS.kEventClassControl, OS.kEventControlDraw,
- };
- OS.InstallEventHandler(OS.GetControlEventTarget(handle), display.fControlProc, mask.length/2, mask, handle, null);
- }
-}
-
boolean hooksKeys () {
return hooks (SWT.KeyDown) || hooks (SWT.KeyUp) || hooks (SWT.Traverse);
}
-/**
- * If the receiver has a layout, asks the layout to <em>lay out</em>
- * (that is, set the size and location of) the receiver's children.
- * If the receiver does not have a layout, do nothing.
- * <p>
- * This is equivalent to calling <code>layout(true)</code>.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
public void layout () {
checkWidget();
layout (true);
}
-/**
- * If the receiver has a layout, asks the layout to <em>lay out</em>
- * (that is, set the size and location of) the receiver's children.
- * If the the argument is <code>true</code> the layout must not rely
- * on any cached information it is keeping about the children. If it
- * is <code>false</code> the layout may (potentially) simplify the
- * work it is doing by assuming that the state of the none of the
- * receiver's children has changed since the last layout.
- * If the receiver does not have a layout, do nothing.
- *
- * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void layout (boolean changed) {
checkWidget();
if (layout == null) return;
- int count = getChildrenCount ();
- if (count == 0) return;
+ //int count = getChildrenCount ();
+ //if (count == 0) return;
layout.layout (this, changed);
}
-Point minimumSize () {
- Control [] children = _getChildren ();
- int width = 0, height = 0;
- for (int i=0; i<children.length; i++) {
- Rectangle rect = children [i].getBounds ();
- width = Math.max (width, rect.x + rect.width);
- height = Math.max (height, rect.y + rect.height);
- }
- return new Point (width, height);
-}
-/* AW
-void moveAbove (int handle1, int handle2) {
- if (handle1 == handle2) return;
- int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int ptr = argList [1], count = argList [3];
- if (count == 0 || ptr == 0) return;
- int [] handles = new int [count];
- OS.memmove (handles, ptr, count * 4);
- if (handle2 == 0) handle2 = handles [0];
- int i = 0, index1 = -1, index2 = -1;
- while (i < count) {
- int handle = handles [i];
- if (handle == handle1) index1 = i;
- if (handle == handle2) index2 = i;
- if (index1 != -1 && index2 != -1) break;
- i++;
- }
- if (index1 == -1 || index2 == -1) return;
- if (index1 == index2) return;
- if (index1 < index2) {
- System.arraycopy (handles, index1 + 1, handles, index1, index2 - index1 - 1);
- handles [index2 - 1] = handle1;
- } else {
- System.arraycopy (handles, index2, handles, index2 + 1, index1 - index2);
- handles [index2] = handle1;
- }
- OS.memmove (ptr, handles, count * 4);
-}
-void moveBelow (int handle1, int handle2) {
- if (handle1 == handle2) return;
- int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- int ptr = argList [1], count = argList [3];
- if (count == 0 || ptr == 0) return;
- int [] handles = new int [count];
- OS.memmove (handles, ptr, count * 4);
- if (handle2 == 0) handle2 = handles [count - 1];
- int i = 0, index1 = -1, index2 = -1;
- while (i < count) {
- int handle = handles [i];
- if (handle == handle1) index1 = i;
- if (handle == handle2) index2 = i;
- if (index1 != -1 && index2 != -1) break;
- i++;
- }
- if (index1 == -1 || index2 == -1) return;
- if (index1 == index2) return;
- if (index1 < index2) {
- System.arraycopy (handles, index1 + 1, handles, index1, index2 - index1);
- handles [index2] = handle1;
- } else {
- System.arraycopy (handles, index2 + 1, handles, index2 + 2, index1 - index2 - 1);
- handles [index2 + 1] = handle1;
- }
- OS.memmove (ptr, handles, count * 4);
-}
-*/
-int processNonMaskable (Object callData) {
- /* AW
- if ((state & CANVAS) != 0) {
- XExposeEvent xEvent = new XExposeEvent ();
- OS.memmove (xEvent, callData, XExposeEvent.sizeof);
- if (xEvent.type == OS.GraphicsExpose) processPaint (callData);
- }
- */
- return 0;
-}
-void propagateChildren (boolean enabled) {
- super.propagateChildren (enabled);
- Control [] children = _getChildren ();
- for (int i = 0; i < children.length; i++) {
- Control child = children [i];
- if (child.getEnabled ()) {
- child.propagateChildren (enabled);
- }
- }
-}
-void realizeChildren () {
- /* AW
- super.realizeChildren ();
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- children [i].realizeChildren ();
- }
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_BACKGROUND) == 0 && (style & SWT.NO_REDRAW_RESIZE) != 0) return;
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- int xWindow = OS.XtWindow (handle);
- if (xWindow == 0) return;
- int flags = 0;
- XSetWindowAttributes attributes = new XSetWindowAttributes ();
- if ((style & SWT.NO_BACKGROUND) != 0) {
- flags |= OS.CWBackPixmap;
- attributes.background_pixmap = OS.None;
- }
- if ((style & SWT.NO_REDRAW_RESIZE) == 0) {
- flags |= OS.CWBitGravity;
- attributes.bit_gravity = OS.ForgetGravity;
- }
- if (flags != 0) {
- OS.XChangeWindowAttributes (xDisplay, xWindow, flags, attributes);
- }
- }
- */
-}
+
void redrawWidget (int x, int y, int width, int height, boolean all) {
super.redrawWidget (x, y, width, height, all);
- if (!all) return;
- Control [] children = _getChildren ();
- for (int i = 0; i < children.length; i++) {
- Control child = children [i];
- Point location = child.getClientLocation ();
- child.redrawWidget (x - location.x, y - location.y, width, height, all);
- }
}
+
void releaseChildren () {
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
@@ -559,36 +137,22 @@ void releaseChildren () {
}
}
}
+
void releaseWidget () {
releaseChildren ();
super.releaseWidget ();
layout = null;
tabList = null;
- /* AW
- if (damagedRegion != 0) OS.XDestroyRegion (damagedRegion);
- damagedRegion = 0;
- */
}
void setBackgroundPixel (int pixel) {
super.setBackgroundPixel (pixel);
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_BACKGROUND) != 0) {
- /* AW
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- int xWindow = OS.XtWindow (handle);
- if (xWindow == 0) return;
- XSetWindowAttributes attributes = new XSetWindowAttributes ();
- attributes.background_pixmap = OS.None;
- OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWBackPixmap, attributes);
- */
- }
- }
}
+
public void setBounds (int x, int y, int width, int height) {
super.setBounds (x, y, width, height);
if (layout != null) layout (false);
}
+
public boolean setFocus() {
checkWidget ();
if ((style & SWT.NO_FOCUS) != 0) return false;
@@ -599,40 +163,17 @@ public boolean setFocus() {
}
return super.setFocus ();
}
-/**
- * Sets the layout which is associated with the receiver to be
- * the argument which may be null.
- *
- * @param layout the receiver's new layout or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setLayout (Layout layout) {
checkWidget();
this.layout = layout;
}
+
public void setSize (int width, int height) {
super.setSize (width, height);
if (layout != null) layout (false);
}
-/**
- * Sets the tabbing order for the specified controls to
- * match the order that they occur in the argument list.
- *
- * @param tabList the ordered list of controls representing the tab order or null
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if a widget in the tabList is null or has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if widget in the tabList is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setTabList (Control [] tabList) {
checkWidget ();
if (tabList != null) {
@@ -658,22 +199,4 @@ public void setTabList (Control [] tabList) {
}
this.tabList = tabList;
}
-int traversalCode () {
- if ((state & CANVAS) != 0) {
- if ((style & SWT.NO_FOCUS) != 0) return 0;
- if (hooksKeys ()) return 0;
- }
- return super.traversalCode ();
-}
-/* AW
-boolean translateMnemonic (char key, XKeyEvent xEvent) {
- if (super.translateMnemonic (key, xEvent)) return true;
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.translateMnemonic (key, xEvent)) return true;
- }
- return false;
-}
-*/
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
index 78e100a6fa..0b9045ca41 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Control.java
@@ -8,95 +8,28 @@ package org.eclipse.swt.widgets;
*/
import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.Accessible;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.carbon.ControlFontStyleRec;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
-
-/**
- * Control is the abstract superclass of all windowed user interface classes.
- * <p>
- * <dl>
- * <dt><b>Styles:</b>
- * <dd>BORDER</dd>
- * <dt><b>Events:</b>
- * <dd>FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDoubleClick, MouseDown, MouseEnter,
- * MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
+
public abstract class Control extends Widget implements Drawable {
Composite parent;
- Font font;
int foreground, background;
- Menu menu;
String toolTipText;
Object layoutData;
- Accessible accessible;
+
int drawCount;
- boolean visible= true;
- Cursor cursor;
+
Control () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
+
public Control (Composite parent, int style) {
super (parent, style);
this.parent = parent;
createWidget (0);
}
-/**
- * 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 <code>ControlListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #removeControlListener
- */
+
public void addControlListener(ControlListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -104,25 +37,7 @@ public void addControlListener(ControlListener listener) {
addListener (SWT.Resize,typedListener);
addListener (SWT.Move,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 <code>FocusListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see FocusListener
- * @see #removeFocusListener
- */
+
public void addFocusListener(FocusListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -130,50 +45,14 @@ public void addFocusListener(FocusListener listener) {
addListener(SWT.FocusIn,typedListener);
addListener(SWT.FocusOut,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
- * <code>HelpListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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 <code>KeyListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #removeKeyListener
- */
+
public void addKeyListener(KeyListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -181,25 +60,7 @@ public void addKeyListener(KeyListener listener) {
addListener(SWT.KeyUp,typedListener);
addListener(SWT.KeyDown,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 <code>MouseListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseListener
- * @see #removeMouseListener
- */
+
public void addMouseListener(MouseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -208,25 +69,7 @@ public void addMouseListener(MouseListener listener) {
addListener(SWT.MouseUp,typedListener);
addListener(SWT.MouseDoubleClick,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 <code>MouseTrackListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseTrackListener
- * @see #removeMouseTrackListener
- */
+
public void addMouseTrackListener (MouseTrackListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -235,145 +78,32 @@ public void addMouseTrackListener (MouseTrackListener listener) {
addListener (SWT.MouseExit,typedListener);
addListener (SWT.MouseHover,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 <code>MouseMoveListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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 receiver needs to be painted, by sending it
- * one of the messages defined in the <code>PaintListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
}
-/**
- * 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 <code>TraverseListener</code>
- * interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
}
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> 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 <code>SWT.DEFAULT</code> is passed for the hint.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @return the preferred size of the control
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack
- * @see "computeTrim, getClientArea for controls that implement them"
- */
+
public Point computeSize (int wHint, int hHint) {
return computeSize (wHint, hHint, true);
}
-/**
- * Returns the preferred size of the receiver.
- * <p>
- * The <em>preferred size</em> 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 <code>SWT.DEFAULT</code> is passed for the hint.
- * </p><p>
- * If the changed flag is <code>true</code>, it indicates that the receiver's
- * <em>contents</em> 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 be <code>false</code>, so layout
- * manager caches can be retained.
- * </p>
- *
- * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
- * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
- * @param changed <code>true</code> if the control's contents have changed, and <code>false</code> otherwise
- * @return the preferred size of the control.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Layout
- * @see #getBorderWidth
- * @see #getBounds
- * @see #getSize
- * @see #pack
- * @see "computeTrim, getClientArea for controls that implement them"
- */
+
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget();
int width = DEFAULT_WIDTH;
@@ -418,176 +148,22 @@ Control computeTabRoot () {
void createWidget (int index) {
super.createWidget (index);
foreground = background = -1;
-
- /*
- * Feature in Motif. When the XmNfontList resource is set for
- * a widget, Motif creates a copy of the fontList and disposes
- * the copy when the widget is disposed. This means that when
- * the programmer queries the font, not only will the handle be
- * different but the font will be unexpectedly disposed when
- * the widget is disposed. This can cause GP's when the font
- * is set in another widget. The fix is to cache the font the
- * the programmer provides. The initial value of the cache is
- * the default font for the widget.
- */
- font = defaultFont ();
-
- /*
- * Explicitly set the tab ordering for XmTAB_GROUP widgets to
- * override the default traversal. This is done so that the
- * traversal order can be changed after the widget tree is
- * created. Unless explicitly changed, the overridded traversal
- * order is the same as the default.
- */
- /* AW
- int [] argList1 = new int [] {OS.XmNnavigationType, 0};
- OS.XtGetValues (handle, argList1, argList1.length / 2);
- if (argList1 [1] == OS.XmTAB_GROUP) {
- int [] argList2 = new int [] {OS.XmNnavigationType, OS.XmEXCLUSIVE_TAB_GROUP};
- OS.XtSetValues (handle, argList2, argList2.length / 2);
- }
- */
}
-int defaultBackground () {
- return getDisplay ().defaultBackground;
-}
-Font defaultFont () {
- return getDisplay ().defaultFont;
-}
-int defaultForeground () {
- return getDisplay ().defaultForeground;
-}
-void enableWidget (boolean enabled) {
- enableHandle (enabled, handle);
-}
-char findMnemonic (String string) {
- int index = 0;
- int length = string.length ();
- do {
- while ((index < length) && (string.charAt (index) != Mnemonic)) index++;
- if (++index >= length) return '\0';
- if (string.charAt (index) != Mnemonic) return string.charAt (index);
- index++;
- } while (index < length);
- return '\0';
-}
-int fontHandle () {
- return handle;
-}
-/**
- * Forces the receiver to have the <em>keyboard focus</em>, causing
- * all keyboard events to be delivered to it.
- *
- * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setFocus
- */
+
public boolean forceFocus () {
checkWidget();
- Decorations shell = menuShell ();
- shell.setSavedFocus (this);
- if (!isEnabled () || !isVisible () /* AW || !isActive () */) return false;
- if (isFocusControl ()) return true;
- shell.bringToTop ();
- /*
- * This code is intentionally commented.
- *
- * When setting focus to a control, it is
- * possible that application code can set
- * the focus to another control inside of
- * WM_SETFOCUS. In this case, the original
- * control will no longer have the focus
- * and the call to setFocus() will return
- * false indicating failure.
- *
- * We are still working on a solution at
- * this time.
- */
-// if (OS.GetFocus () != OS.SetFocus (handle)) return false;
-
- /* AW
- OS.SetFocus (handle);
- */
-
- boolean focus= false;
-
- if (this instanceof Text || this instanceof List || this instanceof Combo || this instanceof Canvas)
- focus= true;
- if (!focus && MacUtil.FULL_KBD_NAV && this instanceof Button)
- focus= true;
-
- if (focus) {
- Display display= getDisplay();
- if (display != null)
- display.setMacFocusHandle(((Shell)shell).shellHandle, handle);
- }
-
return isFocusControl ();
}
-/**
- * Returns the accessible object for the receiver.
- * If this is the first time this object is requested,
- * then the object is created and returned.
- *
- * @return the accessible object
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Accessible#addAccessibleListener
- * @see Accessible#addAccessibleControlListener
- *
- * @since 2.0
- */
-public Accessible getAccessible () {
- checkWidget ();
- if (accessible == null) {
- accessible = Accessible.internal_new_Accessible (this);
- }
- return accessible;
-}
-
-/**
- * Returns the receiver's background color.
- *
- * @return the background color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
public Color getBackground () {
checkWidget();
return Color.carbon_new (getDisplay (), getBackgroundPixel (), false);
}
+
int getBackgroundPixel () {
-/* AW
- int [] argList = {OS.XmNbackground, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
-*/
- if (background == -1) return defaultBackground ();
return background;
}
-/**
- * Returns the receiver's border width.
- *
- * @return the border width
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getBorderWidth () {
checkWidget();
/* AW
@@ -598,215 +174,51 @@ public int getBorderWidth () {
*/
return 0;
}
-/**
- * Returns a rectangle describing the receiver's size and location
- * relative to its parent (or its display if its parent is null).
- *
- * @return the receiver's bounding rectangle
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Rectangle getBounds () {
checkWidget();
- int topHandle = topHandle ();
- /* AW
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- int borders = argList [9] * 2;
- return new Rectangle ((short) argList [1], (short) argList [3], argList [5] + borders, argList [7] + borders);
- */
- Rect bounds= new Rect();
- internalGetControlBounds(topHandle, bounds);
- int width = bounds.right - bounds.left;
- int height = bounds.bottom - bounds.top;
- return new Rectangle(bounds.left, bounds.top, width, height);
+ return new Rectangle(0, 0, 0, 0);
}
-Point getClientLocation () {
- /* AW
- short [] handle_x = new short [1], handle_y = new short [1];
- OS.XtTranslateCoords (handle, (short) 0, (short) 0, handle_x, handle_y);
- short [] topHandle_x = new short [1], topHandle_y = new short [1];
- OS.XtTranslateCoords (parent.handle, (short) 0, (short) 0, topHandle_x, topHandle_y);
- return new Point (handle_x [0] - topHandle_x [0], handle_y [0] - topHandle_y [0]);
- */
- Rect bounds= new Rect();
- OS.GetControlBounds(handle, bounds);
- return new Point(bounds.left, bounds.top);
-}
-/**
- * Returns the display that the receiver was created on.
- *
- * @return the receiver's display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Display getDisplay () {
Composite parent = this.parent;
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean getEnabled () {
checkWidget();
- int h= topHandle();
- if (OS.IsValidControlHandle(h))
- return OS.IsControlEnabled(h);
- System.out.println("Control.getEnabled: fixme for " + getClass().getName());
- return true;
-}
-/**
- * Returns the font that the receiver will use to paint textual information.
- *
- * @return the receiver's font
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+ return false;
+}
+
public Font getFont () {
checkWidget();
- return font;
-}
-
-int getFontAscent () {
- int[] oldPort= new int[1];
- OS.GetPort(oldPort);
- OS.SetPortWindowPort(OS.GetControlOwner(handle));
- if (font != null && font.handle != null)
- font.handle.installInGrafPort();
- short[] fontInfo= new short[4];
- OS.GetFontInfo(fontInfo); // FontInfo
- int height= fontInfo[0];
- OS.SetPort(oldPort[0]);
- return height;
-}
-
-int getFontHeight () {
- int[] oldPort= new int[1];
- OS.GetPort(oldPort);
- OS.SetPortWindowPort(OS.GetControlOwner(handle));
- if (font != null && font.handle != null)
- font.handle.installInGrafPort();
- short[] fontInfo= new short[4];
- OS.GetFontInfo(fontInfo); // FontInfo
- int height= fontInfo[0] + fontInfo[1];
- OS.SetPort(oldPort[0]);
- return height;
-}
-/**
- * Returns the foreground color that the receiver will use to draw.
- *
- * @return the receiver's foreground color
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+ return null;
+}
+
public Color getForeground () {
checkWidget();
return Color.carbon_new (getDisplay (), getForegroundPixel (), false);
}
int getForegroundPixel () {
- /* AW
- int [] argList = {OS.XmNforeground, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- return argList [1];
- */
- if (foreground == -1) return defaultForeground ();
return foreground;
}
-/* AW
-short [] getIMECaretPos () {
- return new short[]{0, 0};
-}
-*/
-/**
- * Returns layout data which is associated with the receiver.
- *
- * @return the receiver's layout data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Object getLayoutData () {
checkWidget();
return layoutData;
}
-/**
- * Returns a point describing the receiver's location relative
- * to its parent (or its display if its parent is null).
- *
- * @return the receiver's location
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Point getLocation () {
checkWidget();
- int topHandle= topHandle ();
- Rect bounds= new Rect();
- internalGetControlBounds(topHandle, bounds);
- return new Point(bounds.left, bounds.top);
-}
-/**
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getMenu () {
- checkWidget();
- return menu;
-}
-/**
- * Returns the receiver's parent, which must be a <code>Composite</code>
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+ return new Point(0, 0);
+}
+
public Composite getParent () {
checkWidget();
return parent;
}
+
Control [] getPath () {
int count = 0;
Shell shell = getShell ();
@@ -823,668 +235,107 @@ Control [] getPath () {
}
return result;
}
-/**
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getParent
- */
+
public Shell getShell () {
checkWidget();
return parent.getShell ();
}
-/**
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Point getSize () {
checkWidget();
- int topHandle = topHandle ();
- /*
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- int borders = argList [5] * 2;
- return new Point (argList [1] + borders, argList [3] + borders);
- */
- Rect bounds= new Rect();
- internalGetControlBounds(topHandle, bounds);
- int width = bounds.right - bounds.left;
- int height = bounds.bottom - bounds.top;
- return new Point(width, height);
-}
-/**
- * Returns the receiver's tool tip text, or null if it has
- * not been set.
- *
- * @return the receiver's tool tip text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+ return new Point(0, 0);
+}
+
public String getToolTipText () {
checkWidget();
return toolTipText;
}
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * 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.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean getVisible () {
checkWidget();
- return visible;
+ return false;
}
+
boolean hasFocus () {
return (this == getDisplay ().getFocusControl ());
}
-void hookEvents () {
- /* AW
- int windowProc = getDisplay ().windowProc;
- OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, SWT.KeyDown);
- OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, SWT.KeyUp);
- OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, SWT.MouseDown);
- OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, SWT.MouseUp);
- OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, SWT.MouseMove);
- OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, SWT.MouseEnter);
- OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit);
- OS.XtAddEventHandler (handle, OS.ExposureMask, false, windowProc, SWT.Paint);
- OS.XtAddEventHandler (handle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn);
- OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, SWT.Help);
- */
- //Display display= getDisplay();
- //OS.SetControlData(handle, OS.kControlEntireControl, OS.kControlUserPaneDrawProcTag, display.fUserPaneDrawProc);
-}
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Control</code>. 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.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- *
- * @private
- */
+
public int internal_new_GC (GCData data) {
checkWidget();
- /* AW
- if (!OS.XtIsRealized (handle)) {
- Shell shell = getShell ();
- shell.realizeWidget ();
- }
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int xWindow = OS.XtWindow (handle);
- if (xWindow == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- int xGC = OS.XCreateGC (xDisplay, xWindow, 0, null);
- if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.XSetGraphicsExposures (xDisplay, xGC, false);
- int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNcolormap, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- */
- if (data != null) {
- data.device = getDisplay ();
- data.foreground = getForegroundPixel();
- data.background = getBackgroundPixel();
- data.font = font.handle;
- data.controlHandle = handle;
- }
+ return 0;
+}
- int wHandle= OS.GetControlOwner(handle);
- int port= OS.GetWindowPort(wHandle);
- if (port == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- return port;
-}
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Control</code>. 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.
- * </p>
- *
- * @param handle the platform specific GC handle
- * @param data the platform specific GC data
- *
- * @private
- */
public void internal_dispose_GC (int xGC, GCData data) {
checkWidget ();
- /* AW
- int xDisplay = 0;
- if (data != null) xDisplay = data.display;
- if (xDisplay == 0 && handle != 0) xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);
- OS.XFreeGC (xDisplay, xGC);
- */
}
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
+
public boolean isEnabled () {
checkWidget();
return getEnabled () && parent.isEnabled ();
}
-/**
- * Returns <code>true</code> if the receiver has the user-interface
- * focus, and <code>false</code> otherwise.
- *
- * @return the receiver's focus state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean isFocusControl () {
checkWidget();
return hasFocus ();
}
-/**
- * Returns <code>true</code> if the underlying operating
- * system supports this reparenting, otherwise <code>false</code>
- *
- * @return <code>true</code> if the widget can be reparented, otherwise <code>false</code>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean isReparentable () {
checkWidget();
return false;
}
-boolean isShowing () {
- if (!isVisible ()) return false;
- // check if the widget is obscurred by a parent or sibling.
- int rgn= 0;
- try {
- rgn= OS.NewRgn();
- MacUtil.getVisibleRegion(handle, rgn, true);
- return !OS.EmptyRgn(rgn);
- } finally {
- if (rgn != 0)
- OS.DisposeRgn(rgn);
- }
-}
-
boolean isTabGroup () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return true;
- }
- }
- /* AW
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- return (bits & OS.WS_TABSTOP) != 0;
- */
- // AW: Motif:
- int code = traversalCode ();
- if ((code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0) return false;
- return (code & (SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT)) != 0;
+ return false;
}
boolean isTabItem () {
- Control [] tabList = parent._getTabList ();
- if (tabList != null) {
- for (int i=0; i<tabList.length; i++) {
- if (tabList [i] == this) return false;
- }
- }
- /* AW
- int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
- if ((bits & OS.WS_TABSTOP) != 0) return false;
- int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0);
- if ((code & OS.DLGC_STATIC) != 0) return false;
- if ((code & OS.DLGC_WANTALLKEYS) != 0) return false;
- if ((code & OS.DLGC_WANTARROWS) != 0) return false;
- if ((code & OS.DLGC_WANTTAB) != 0) return false;
- */
- // AW: Motif
- int code = traversalCode ();
- return (code & (SWT.TRAVERSE_ARROW_PREVIOUS | SWT.TRAVERSE_ARROW_NEXT)) != 0;
-}
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
-public boolean isVisible () {
- checkWidget();
- return getVisible () && parent.isVisible ();
-}
-void manageChildren () {
-/* AW
- OS.XtSetMappedWhenManaged (handle, false);
- OS.XtManageChild (handle);
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XtResizeWidget (handle, 1, 1, argList [1]);
- OS.XtSetMappedWhenManaged (handle, true);
-*/
-}
-Decorations menuShell () {
- return parent.menuShell ();
-}
-boolean mnemonicHit (char key) {
return false;
}
-boolean mnemonicMatch (char key) {
+
+public boolean isVisible () {
+ checkWidget();
return false;
}
-/**
- * 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 the sibling control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void moveAbove (Control control) {
checkWidget();
- if (control != null && control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- setZOrder (control, 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 the sibling control (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void moveBelow (Control control) {
checkWidget();
- if (control != null && control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
- setZOrder (control, false);
-}
-/**
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeSize
- */
+}
+
public void pack () {
checkWidget();
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.
- * <p>
- * If the changed flag is <code>true</code>, it indicates that the receiver's
- * <em>contents</em> 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 be <code>false</code>, so layout
- * manager caches can be retained.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeSize
- */
+
public void pack (boolean changed) {
checkWidget();
setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
}
-int processDefaultSelection (Object callData) {
- postEvent (SWT.DefaultSelection);
- return OS.noErr;
-}
-int processFocusIn () {
- sendEvent (SWT.FocusIn);
- return OS.noErr;
-}
-int processFocusOut () {
- sendEvent (SWT.FocusOut);
- return OS.noErr;
-}
-int processHelp (Object callData) {
- sendHelpEvent (callData);
- return OS.noErr;
-}
-int processKeyDown (Object callData) {
- MacEvent macEvent = (MacEvent) callData;
- if (translateTraversal (macEvent))
- return OS.noErr;
- // widget could be disposed at this point
- if (isDisposed ()) return 0;
- return sendKeyEvent (SWT.KeyDown, macEvent);
-}
-int processKeyUp (Object callData) {
- // widget could be disposed at this point
- if (isDisposed ()) return 0;
- return sendKeyEvent (SWT.KeyUp, (MacEvent) callData);
-}
-int processModify (Object callData) {
- sendEvent (SWT.Modify);
- return OS.noErr;
-}
-int processMouseDown (MacMouseEvent mmEvent) {
- Display display = getDisplay ();
- Shell shell = getShell ();
- display.hideToolTip ();
- int button= mmEvent.getButton();
- sendMouseEvent (SWT.MouseDown, button, mmEvent);
- if (button == 2 && hooks (SWT.DragDetect)) {
- sendEvent (SWT.DragDetect);
- }
- if (button == 3 && menu != null) {
- /* AW
- OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
- menu.setVisible (true);
- */
- }
- int clickTime = display.getDoubleClickTime ();
- int lastTime = display.lastTime, eventTime = mmEvent.getWhen();
- int lastButton = display.lastButton, eventButton = button;
- if (lastButton == eventButton && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
- sendMouseEvent (SWT.MouseDoubleClick, eventButton, mmEvent);
- }
- display.lastTime = eventTime == 0 ? 1 : eventTime;
- display.lastButton = eventButton;
-
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
- return OS.noErr;
-}
-int processMouseEnter (MacMouseEvent mme) {
- sendMouseEvent (SWT.MouseEnter, 0, mme);
- return OS.noErr;
-}
-int processMouseMove (MacMouseEvent mme) {
- Display display = getDisplay ();
- display.addMouseHoverTimeOut (handle);
- sendMouseEvent (SWT.MouseMove, 0, mme);
- return OS.noErr;
-}
-int processMouseExit (MacMouseEvent mme) {
- Display display = getDisplay ();
- display.removeMouseHoverTimeOut ();
- display.hideToolTip ();
- sendMouseEvent (SWT.MouseExit, 0, mme);
- return OS.noErr;
-}
-int processMouseHover (MacMouseEvent mme) {
- Display display = getDisplay ();
- display.showToolTip (handle, toolTipText);
- sendMouseEvent (SWT.MouseHover, 0, mme);
- return OS.noErr;
-}
-int processMouseUp (MacMouseEvent mmEvent) {
- Display display = getDisplay ();
- display.hideToolTip ();
- sendMouseEvent (SWT.MouseUp, mmEvent.getButton(), mmEvent);
- return OS.noErr;
-}
-int processPaint (Object callData) {
- MacControlEvent mce= (MacControlEvent) callData;
- GC gc= new GC (this);
- Rectangle r= gc.carbon_focus(mce.getDamageRegionHandle(), mce.getGCContext());
- if (r == null || !r.isEmpty()) {
- // erase background
- if ((state & CANVAS) != 0 && (style & SWT.NO_BACKGROUND) == 0)
- gc.fillRectangle(r);
- if (hooks (SWT.Paint) || filters (SWT.Paint)) {
- Event event = new Event();
- //event.count = xEvent.count;
- //event.time = OS.XtLastTimestampProcessed (xDisplay);
- event.gc = gc;
- event.x = r.x; event.y = r.y;
- event.width = r.width; event.height = r.height;
- sendEvent (SWT.Paint, event);
- }
- }
- gc.carbon_unfocus ();
- if (!gc.isDisposed ())
- gc.dispose ();
- return OS.noErr;
-}
-int processResize (Object callData) {
- sendEvent (SWT.Resize);
- // widget could be disposed at this point
- return OS.noErr;
-}
-int processSelection (Object callData) {
- postEvent (SWT.Selection);
- return OS.noErr;
-}
-int processSetFocus (Object callData) {
- /*
- * Ignore focus change events when the window getting or losing
- * focus is a menu. Because XmGetFocusWidget() does not answer
- * the menu shell (it answers the menu parent), it is necessary
- * to use XGetInputFocus() to get the real X focus window.
- */
- /* AW
- int xDisplay = xEvent.display;
- if (xDisplay == 0) return 0;
- int [] unused = new int [1], xWindow = new int [1];
- OS.XGetInputFocus (xDisplay, xWindow, unused);
- if (xWindow [0] != 0) {
- int widget = OS.XtWindowToWidget (xDisplay, xWindow [0]);
- if (widget != 0 && OS.XtClass (widget) == OS.XmMenuShellWidgetClass ()) return 0;
- }
- */
- /* Process the focus change for the widget */
- Shell shell = getShell ();
- Boolean b = (Boolean) callData;
- if (b.booleanValue ()) {
-
- processFocusIn ();
- // widget could be disposed at this point
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- shell.setActiveControl (this);
- }
- } else {
- Display display = getDisplay ();
-
- processFocusOut ();
- // widget could be disposed at this point
- /*
- * It is possible that the shell may be
- * disposed at this point. If this happens
- * don't send the activate and deactivate
- * events.
- */
- if (!shell.isDisposed ()) {
- Control control = display.getFocusControl ();
- if (control == null || shell != control.getShell () ) {
- shell.setActiveControl (null);
- }
- }
- }
- return OS.noErr;
-}
-void propagateChildren (boolean enabled) {
- propagateWidget (enabled);
-}
-void propagateWidget (boolean enabled) {
- propagateHandle (enabled, handle);
-}
-void realizeChildren () {
- if (!isEnabled ()) propagateWidget (false);
-}
-/**
- * Causes the entire bounds of the receiver to be marked
- * as needing to be redrawn. The next time a paint request
- * is processed, the control will be completely painted.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #update
- */
public void redraw () {
checkWidget();
redrawWidget (0, 0, 0, 0, false);
}
-/**
- * Causes the rectangular area of the receiver specified by
- * the arguments to be marked as needing to be redrawn.
- * The next time a paint request is processed, that area of
- * the receiver will be painted. If the <code>all</code> flag
- * is <code>true</code>, any children of the receiver which
- * intersect with the specified area will also paint their
- * intersecting areas. If the <code>all</code> flag is
- * <code>false</code>, 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 <code>true</code> if children should redraw, and <code>false</code> otherwise
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #update
- */
+
public void redraw (int x, int y, int width, int height, boolean all) {
checkWidget ();
if (width <= 0 || height <= 0) return;
redrawWidget (x, y, width, height, all);
}
+
void redrawWidget (int x, int y, int width, int height, boolean all) {
- redrawHandle (x, y, width, height, handle, all);
+
}
+
void releaseWidget () {
super.releaseWidget ();
- Display display = getDisplay ();
- display.releaseToolTipHandle (handle);
- toolTipText = null;
- if (menu != null && !menu.isDisposed ()) {
- menu.dispose ();
- }
- menu = null;
parent = null;
layoutData = null;
}
-/**
- * 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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ControlListener
- * @see #addControlListener
- */
+
public void removeControlListener (ControlListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1492,23 +343,7 @@ public void removeControlListener (ControlListener listener) {
eventTable.unhook (SWT.Move, listener);
eventTable.unhook (SWT.Resize, 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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see FocusListener
- * @see #addFocusListener
- */
+
public void removeFocusListener(FocusListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1516,46 +351,14 @@ public void removeFocusListener(FocusListener listener) {
eventTable.unhook(SWT.FocusIn, listener);
eventTable.unhook(SWT.FocusOut, 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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see KeyListener
- * @see #addKeyListener
- */
+
public void removeKeyListener(KeyListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1563,23 +366,7 @@ public void removeKeyListener(KeyListener listener) {
eventTable.unhook(SWT.KeyUp, listener);
eventTable.unhook(SWT.KeyDown, 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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseListener
- * @see #addMouseListener
- */
+
public void removeMouseListener(MouseListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1588,46 +375,14 @@ public void removeMouseListener(MouseListener 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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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 be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see MouseTrackListener
- * @see #addMouseTrackListener
- */
+
public void removeMouseTrackListener(MouseTrackListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1636,97 +391,21 @@ public void removeMouseTrackListener(MouseTrackListener 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 receiver needs to be painted.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
-}/**
- * Removes the listener from the collection of listeners who will
- * be notified when traversal events occur.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
}
-void sendHelpEvent (Object callData) {
- Control control = this;
- while (control != null) {
- if (control.hooks (SWT.Help)) {
- control.postEvent (SWT.Help);
- return;
- }
- control = control.parent;
- }
-}
-final int sendKeyEvent (int type, MacEvent mEvent) {
- Event event = new Event ();
- event.type = type;
- event.time = mEvent.getWhen();
- setKeyState (event, mEvent);
- return sendKeyEvent(type, mEvent, event);
-}
-int sendKeyEvent (int type, MacEvent mEvent, Event event) {
- postEvent (type, event);
- return 0;
-}
-final void sendMouseEvent (int type, int button, MacMouseEvent mme) {
- Event event = new Event ();
- event.type = type;
- event.time = mme.getWhen();
- event.button = button;
- Point ml= MacUtil.toControl(handle, mme.getWhere());
- event.x = ml.x; event.y = ml.y;
- setInputState (event, mme);
- postEvent(type, event);
-}
-/**
- * Sets the receiver's background color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setBackground (Color color) {
checkWidget();
int pixel = -1;
@@ -1737,753 +416,110 @@ public void setBackground (Color color) {
setBackgroundPixel (pixel);
}
void setBackgroundPixel (int pixel) {
- /* AW
- int [] argList = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- OS.XmChangeColor (handle, pixel);
- OS.XtSetValues (handle, argList, argList.length / 2);
- */
- if (background == pixel) return;
- background = pixel;
- redrawHandle(0, 0, 0, 0, handle, false);
-}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the arguments. The <code>x</code> and
- * <code>y</code> arguments are relative to the receiver's
- * parent (or its display if its parent is null).
- * <p>
- * 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.
- * </p>
- *
- * @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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void setBounds (int x, int y, int width, int height) {
checkWidget();
- int topHandle = topHandle ();
- width = Math.max(width, 0);
- height = Math.max(height, 0);
- Rect bounds= new Rect();
- Rect pbounds= new Rect();
- internalGetControlBounds(topHandle, bounds);
- OS.GetControlBounds(parent.handle, pbounds);
- boolean sameOrigin = bounds.left == x && bounds.top == y;
- boolean sameExtent = (bounds.right-bounds.left) == width && (bounds.bottom-bounds.top) == height;
- if (sameOrigin && sameExtent) return;
- internalSetBounds(topHandle, x, y, width, height);
- if (!sameOrigin) sendEvent (SWT.Move);
- if (!sameExtent) sendEvent (SWT.Resize);
-}
-/**
- * Sets the receiver's size and location to the rectangular
- * area specified by the argument. The <code>x</code> and
- * <code>y</code> fields of the rectangle are relative to
- * the receiver's parent (or its display if its parent is null).
- * <p>
- * 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.
- * </p>
- *
- * @param rect the new bounds for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void setBounds (Rectangle rect) {
if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
setBounds (rect.x, rect.y, rect.width, rect.height);
}
-/**
- * If the argument is <code>true</code>, causes the receiver to have
- * all mouse events delivered to it until the method is called with
- * <code>false</code> as the argument.
- *
- * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setCapture (boolean capture) {
checkWidget();
- System.out.println("Control.setCapture: nyi");
- /* AW
- int display = OS.XtDisplay (handle);
- if (display == 0) return;
- if (capture) {
- int window = OS.XtWindow (handle);
- if (window == 0) return;
- OS.XGrabPointer (
- display,
- window,
- 0,
- OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
- OS.GrabModeAsync,
- OS.GrabModeAsync,
- OS.None,
- OS.None,
- OS.CurrentTime);
- } else {
- OS.XUngrabPointer (display, OS.CurrentTime);
- }
- */
}
-/**
- * Sets the receiver's cursor to the cursor specified by the
- * argument, or to the default cursor for that kind of control
- * if the argument is null.
- * <p>
- * When the mouse pointer passes over a control its appearance
- * is changed to match the control's cursor.
- * </p>
- *
- * @param cursor the new cursor (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setCursor (Cursor cursor) {
checkWidget();
- if (cursor == null) {
- cursor= null;
- } else {
- if (cursor.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- cursor= cursor;
- }
}
-/**
- * Enables the receiver if the argument is <code>true</code>,
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setEnabled (boolean enabled) {
checkWidget();
- enableWidget (enabled);
- if (!enabled || (isEnabled () && enabled)) {
- propagateChildren (enabled);
- }
}
-/**
- * Causes the receiver to have the <em>keyboard focus</em>,
- * such that all keyboard events will be delivered to it.
- *
- * @return <code>true</code> if the control got focus, and <code>false</code> if it was unable to.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #forceFocus
- */
+
public boolean setFocus () {
checkWidget();
return forceFocus ();
}
-/**
- * Sets the font that the receiver will use to paint textual information
- * to the font specified by the argument, or to the default font for that
- * kind of control if the argument is null.
- *
- * @param font the new font (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setFont (Font font) {
checkWidget();
- if (font == null) font = defaultFont ();
- if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- this.font = font;
-
- int fontHandle = fontHandle ();
- ControlFontStyleRec fontRec = new ControlFontStyleRec();
- fontRec.flags= (short)(OS.kControlUseFontMask | OS.kControlUseSizeMask | OS.kControlUseFaceMask);
- fontRec.font= font.handle.fID;
- fontRec.size= font.handle.fSize;
- fontRec.style= font.handle.fFace;
- if (OS.SetControlFontStyle(fontHandle, fontRec) != OS.noErr)
- ; //System.out.println("Control.setFont("+this+"): error");
-}
-/**
- * Sets the receiver's foreground color to the color specified
- * by the argument, or to the default system color for the control
- * if the argument is null.
- *
- * @param color the new color (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void setForeground (Color color) {
checkWidget();
- /* AW
- if (color == null) {
- setForegroundPixel (defaultForeground ());
- } else {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- setForegroundPixel (color.handle.pixel);
- }
- */
- int pixel = -1;
- if (color != null) {
- if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- pixel = color.handle;
- }
- setForegroundPixel (pixel);
}
void setForegroundPixel (int pixel) {
- /* AW
- int [] argList = {OS.XmNforeground, pixel};
- OS.XtSetValues (handle, argList, argList.length / 2);
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return;
- int xWindow = OS.XtWindow (handle);
- if (xWindow == 0) return;
- OS.XClearArea (xDisplay, xWindow, 0, 0, 0, 0, true);
- */
- if (foreground == pixel) return;
- foreground = pixel;
- redrawHandle(0, 0, 0, 0, handle, false);
-}
-void setGrabCursor (int cursor) {
- System.out.println("Control.setGrabCursor: nyi");
-}
-/**
- * Sets the layout data associated with the receiver to the argument.
- *
- * @param layoutData the new layout data for the receiver.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void setLayoutData (Object layoutData) {
checkWidget();
this.layoutData = layoutData;
}
-/**
- * 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).
- *
- * @param x the new x coordinate for the receiver
- * @param y the new y coordinate for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setLocation (int x, int y) {
checkWidget();
- /* AW
- int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- boolean sameOrigin = (x == (short) argList [1]) && (y == (short) argList [3]);
- if (sameOrigin) return;
- OS.XtMoveWidget (topHandle, x, y);
- if (!sameOrigin) sendEvent (SWT.Move);
- */
- int topHandle = topHandle ();
- Rect bounds= new Rect();
- Rect pbounds= new Rect();
- internalGetControlBounds(topHandle, bounds);
- OS.GetControlBounds(parent.handle, pbounds);
- boolean sameOrigin = (x == bounds.left) && (y == bounds.top);
- if (sameOrigin) return;
- internalSetBounds(topHandle, x, y, bounds.right-bounds.left, bounds.bottom-bounds.top);
- sendEvent (SWT.Move);
-}
-/**
- * Sets the receiver's location to the point specified by
- * the argument which is relative to the receiver's
- * parent (or its display if its parent is null).
- *
- * @param location the new location for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void setLocation (Point location) {
if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
setLocation (location.x, location.y);
}
-/**
- * Sets the receiver's pop up menu to the argument.
- * 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.
- *
- * @param menu the new pop up menu
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_MENU_NOT_POP_UP - the menu is not a pop up menu</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenu (Menu menu) {
- checkWidget();
- if (menu != null) {
- if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
- if ((menu.style & SWT.POP_UP) == 0) {
- error (SWT.ERROR_MENU_NOT_POP_UP);
- }
- if (menu.parent != menuShell ()) {
- error (SWT.ERROR_INVALID_PARENT);
- }
- }
- this.menu = menu;
-}
-
-/**
- * Changes the parent of the widget to be the one provided if
- * the underlying operating system supports this feature.
- * Answers <code>true</code> if the parent is successfully changed.
- *
- * @param parent the new parent for the control.
- * @return <code>true</code> if the parent is changed and <code>false</code> otherwise.
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li>
- * </ul>
- * @exception SWTError <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * </ul>
- */
+
public boolean setParent (Composite parent) {
checkWidget();
if (parent.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
return false;
}
-/**
- * If the argument is <code>false</code>, 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
- * <code>false</code> are lost. When the flag is set to <code>true</code>,
- * the entire widget is marked as needing to be redrawn.
- * <p>
- * Note: This operation is a hint and may not be supported on some
- * platforms or for some widgets.
- * </p>
- *
- * @param redraw the new redraw state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #redraw
- * @see #update
- */
public void setRedraw (boolean redraw) {
checkWidget();
- if (redraw) {
- if (--drawCount == 0) {
- int topHandle= topHandle();
- OS.HIViewSetDrawingEnabled(topHandle, true);
- OS.HIViewSetNeedsDisplay(topHandle, true);
- }
- } else {
- if (drawCount++ == 0)
- OS.HIViewSetDrawingEnabled(topHandle(), false);
- }
}
-/**
- * Sets the receiver's size to the point specified by the arguments.
- * <p>
- * 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.
- * </p>
- *
- * @param width the new width for the receiver
- * @param height the new height for the receiver
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setSize (int width, int height) {
checkWidget();
- /*
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (topHandle, argList, argList.length / 2);
- int newWidth = Math.max (width - (argList [5] * 2), 1);
- int newHeight = Math.max (height - (argList [5] * 2), 1);
- boolean sameExtent = (newWidth == argList [1]) && (newHeight == argList [3]);
- OS.XtResizeWidget (topHandle, newWidth, newHeight, argList [5]);
- */
- int topHandle = topHandle ();
- width = Math.max(width, 0);
- height = Math.max(height, 0);
- Rect bounds= new Rect();
- internalGetControlBounds(topHandle, bounds);
- boolean sameExtent = (bounds.right-bounds.left) == width && (bounds.bottom-bounds.top) == height;
- if (sameExtent) return;
- internalSetBounds(topHandle, bounds.left, bounds.top, width, height);
- sendEvent (SWT.Resize);
-}
-/**
- * Sets the receiver's size to the point specified by the argument.
- * <p>
- * Note: Attempting to set the width or height of the
- * receiver to a negative number will cause them to be
- * set to zero instead.
- * </p>
- *
- * @param size the new size for the receiver
- * @param height the new height for the receiver
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+}
+
public void setSize (Point size) {
if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
setSize (size.x, size.y);
}
boolean setTabGroupFocus () {
- return setTabItemFocus ();
+ return false;
}
boolean setTabItemFocus () {
- if (!isShowing ()) return false;
- return setFocus ();
-}
-
-/**
- * Sets the receiver's tool tip text to the argument, which
- * may be null indicating that no tool tip text should be shown.
- *
- * @param string the new tool tip text (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+ return false;
+}
+
public void setToolTipText (String string) {
checkWidget();
toolTipText = string;
}
-/**
- * Marks the receiver as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * 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.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setVisible (boolean visible) {
checkWidget();
- if (this.visible != visible) {
- this.visible= visible;
- OS.HIViewSetVisible(topHandle(), visible);
- sendEvent (visible ? SWT.Show : SWT.Hide);
- }
}
-void setZOrder (Control control, boolean above) {
-
- if (control != null && control.parent != parent) return;
-
- int thisHandle= topHandle();
- if (parent == null)
- error (SWT.ERROR_INVALID_PARENT);
- int destHandle= parent.handle;
- int otherHandle= 0;
- if (control != null)
- otherHandle= control.topHandle();
-
- // AW: doesn't handle reparenting case yet!
- OS.HIViewSetZOrder(thisHandle, above ? OS.kHIViewZOrderAbove : OS.kHIViewZOrderBelow, otherHandle);
-}
-/**
- * Returns a point which is the result of converting the
- * argument, which is specified in display relative coordinates,
- * to coordinates relative to the receiver.
- * <p>
- * @param point the point to be translated (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Point toControl (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- /* AW
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (handle, (short) 0, (short) 0, root_x, root_y);
- return new Point (point.x - root_x [0], point.y - root_y [0]);
- */
- return MacUtil.toControl(handle, point);
-}
-/**
- * Returns a point which is the result of converting the
- * argument, which is specified in coordinates relative to
- * the receiver, to display relative coordinates.
- * <p>
- * @param point the point to be translated (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+ return new Point (0, 0);
+}
+
public Point toDisplay (Point point) {
checkWidget();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
- /* AW
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (handle, (short) point.x, (short) point.y, root_x, root_y);
- return new Point (root_x [0], root_y [0]);
- */
- return MacUtil.toDisplay(handle, point);
-}
-/* AW
-boolean translateMnemonic (char key, XKeyEvent xEvent) {
- if (!isVisible () || !isEnabled ()) return false;
- boolean doit = mnemonicMatch (key);
- if (hooks (SWT.Traverse)) {
- Event event = new Event();
- event.doit = doit;
- event.detail = SWT.TRAVERSE_MNEMONIC;
- event.time = xEvent.time;
- setKeyState (event, xEvent);
- sendEvent (SWT.Traverse, event);
- doit = event.doit;
- }
- if (doit) return mnemonicHit (key);
- return false;
+ return new Point (0, 0);
}
-boolean translateMnemonic (int key, XKeyEvent xEvent) {
- if (xEvent.state != OS.Mod1Mask) {
- if (xEvent.state != 0 || !(this instanceof Button)) {
- return false;
- }
- }
- Decorations shell = menuShell ();
- if (shell.isVisible () && shell.isEnabled ()) {
- char ch = mbcsToWcs ((char) key);
- return ch != 0 && shell.translateMnemonic (ch, xEvent);
- }
- return false;
-}
-*/
-boolean translateTraversal (MacEvent mEvent) {
-
- int kind= mEvent.getKind();
- if (kind != OS.kEventRawKeyDown && kind != OS.kEventRawKeyRepeat)
- return false;
-
- int detail = SWT.TRAVERSE_NONE;
- /* AW
- GdkEventKey keyEvent = new GdkEventKey ();
- OS.memmove (keyEvent, gdkEvent, GdkEventKey.sizeof);
- int key = keyEvent.keyval;
- int code = traversalCode (key, gdkEvent);
- int [] state = new int [1];
- OS.gdk_event_get_state (gdkEvent, state);
- */
- int code= traversalCode ();
- int key= mEvent.getKeyCode();
- int state= mEvent.getStateMask();
- boolean all = false;
- switch (key) {
- case 30 /* OS.GDK_Escape:
- case OS.GDK_Cancel */: {
- all = true;
- detail = SWT.TRAVERSE_ESCAPE;
- break;
- }
- case 36 /* OS.GDK_Return */ : {
- all = true;
- detail = SWT.TRAVERSE_RETURN;
- break;
- }
- //case OS.GDK_ISO_Left_Tab:
- case 48 /* OS.GDK_Tab */ : {
- boolean next = (state & SWT.SHIFT) == 0;
- /*
- * NOTE: This code causes Shift+Tab and Ctrl+Tab to
- * always attempt traversal which is not correct.
- * The default should be the same as a plain Tab key.
- * This behavior is currently relied on by StyledText.
- *
- * The correct behavior is to give every key to any
- * control that wants to see every key. The default
- * behavior for a Canvas should be to see every key.
- */
- /* AW
- switch (state [0]) {
- case OS.GDK_SHIFT_MASK:
- case OS.GDK_CONTROL_MASK:
- code |= SWT.TRAVERSE_TAB_PREVIOUS | SWT.TRAVERSE_TAB_NEXT;
- }
- */
- detail = next ? SWT.TRAVERSE_TAB_NEXT : SWT.TRAVERSE_TAB_PREVIOUS;
- break;
- }
- case 126: // OS.GDK_Up:
- case 123: // OS.GDK_Left:
- detail = SWT.TRAVERSE_ARROW_PREVIOUS;
- break;
-
- case 125: // OS.GDK_Down:
- case 124: /* OS.GDK_Right: */
- detail = SWT.TRAVERSE_ARROW_NEXT;
- break;
-
- case 116: // OS.GDK_Page_Up:
- case 121: /* OS.GDK_Page_Down: */ {
- all = true;
- /* AW
- if ((state [0] & OS.GDK_CONTROL_MASK) == 0) return false;
- */
- /*
- * NOTE: This code causes Ctrl+PgUp and Ctrl+PgDn to always
- * attempt traversal which is not correct. This behavior is
- * currently relied on by StyledText.
- *
- * The correct behavior is to give every key to any
- * control that wants to see every key. The default
- * behavior for a Canvas should be to see every key.
- */
- code |= SWT.TRAVERSE_PAGE_NEXT | SWT.TRAVERSE_PAGE_PREVIOUS;
- detail = key == 121 ? SWT.TRAVERSE_PAGE_NEXT : SWT.TRAVERSE_PAGE_PREVIOUS;
- break;
- }
- default:
- return false;
- }
-
- Event event = new Event ();
- event.doit = (code & detail) != 0;
- event.detail = detail;
- /* AW
- event.time = keyEvent.time;
- setInputState (event, gdkEvent);
- */
- Shell shell = getShell ();
- Control control = this;
- do {
- if (control.traverse (event)) return true;
- if (!event.doit && control.hooks (SWT.Traverse)) {
- return false;
- }
- if (control == shell) return false;
- control = control.parent;
- } while (all && control != null);
+
+boolean traverseMnemonic (char key) {
return false;
}
-int traversalCode () {
- /* AW
- int [] argList = new int [] {OS.XmNtraversalOn, 0};
- OS.XtGetValues (handle, argList, argList.length / 2);
- if (argList [1] == 0) return 0;
- */
- int code = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
- Shell shell = getShell ();
- if (shell.parent != null) code |= SWT.TRAVERSE_ESCAPE;
- /* AW
- if (getNavigationType () == OS.XmNONE) {
- code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
- }
- */
- return code;
-}
-boolean traverseMnemonic (char key) {
- if (!isVisible () || !isEnabled ()) return false;
- return mnemonicMatch (key) && mnemonicHit (key);
-}
-/**
- * Based on the argument, perform one of the expected platform
- * traversal action. The argument should be one of the constants:
- * <code>SWT.TRAVERSE_ESCAPE</code>, <code>SWT.TRAVERSE_RETURN</code>,
- * <code>SWT.TRAVERSE_TAB_NEXT</code>, <code>SWT.TRAVERSE_TAB_PREVIOUS</code>,
- * <code>SWT.TRAVERSE_ARROW_NEXT</code> and <code>SWT.TRAVERSE_ARROW_PREVIOUS</code>.
- *
- * @param traversal the type of traversal
- * @return true if the traversal succeeded
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean traverse (int traversal) {
checkWidget();
if (!isFocusControl () && !setFocus ()) return false;
@@ -2513,71 +549,19 @@ boolean traverse (Event event) {
}
boolean traverseEscape () {
- Shell shell = getShell ();
- if (shell.parent == null) return false;
- if (!shell.isVisible () || !shell.isEnabled ()) return false;
- shell.close ();
- return true;
+ return false;
}
boolean traverseGroup (boolean next) {
- Control root = computeTabRoot ();
- Control group = computeTabGroup ();
- Control [] list = root.computeTabList ();
- int length = list.length;
- int index = 0;
- while (index < length) {
- if (list [index] == group) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- if (index == length) return false;
- int start = index, offset = (next) ? 1 : -1;
- while ((index = ((index + offset + length) % length)) != start) {
- Control control = list [index];
- if (!control.isDisposed () && control.setTabGroupFocus ()) {
- if (!isDisposed () && !isFocusControl ()) return true;
- }
- }
- if (group.isDisposed ()) return false;
- return group.setTabGroupFocus ();
+ return false;
}
boolean traverseItem (boolean next) {
- Control [] children = parent._getChildren ();
- int length = children.length;
- int index = 0;
- while (index < length) {
- if (children [index] == this) break;
- index++;
- }
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in focus in
- * or out events. Ensure that a disposed widget is
- * not accessed.
- */
- int start = index, offset = (next) ? 1 : -1;
- while ((index = (index + offset + length) % length) != start) {
- Control child = children [index];
- if (!child.isDisposed () && child.isTabItem ()) {
- if (child.setTabItemFocus ()) return true;
- }
- }
return false;
}
boolean traverseReturn () {
- Button button = menuShell ().getDefaultButton ();
- if (button == null || button.isDisposed ()) return false;
- if (!button.isVisible () || !button.isEnabled ()) return false;
- button.click ();
- return true;
+ return false;
}
boolean traversePage (boolean next) {
@@ -2585,79 +569,10 @@ boolean traversePage (boolean next) {
}
boolean traverseMnemonic (Event event) {
- // This code is intentionally commented.
- // TraverseMnemonic always originates from the OS and
- // never through the API, and on the GTK platform, accels
- // are hooked by the OS before we get the key event.
- // int shellHandle = _getShell ().topHandle ();
- // return OS.gtk_accel_groups_activate (shellHandle, keyCode, stateMask);
- return true;
-}
-/**
- * Forces all outstanding paint requests for the widget tree
- * to be processed before this method returns.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #redraw
- */
+ return false;
+}
+
public void update () {
checkWidget();
- /* AW
- int display = OS.XtDisplay (handle);
- if (display == 0) return;
- int window = OS.XtWindow (handle);
- if (window == 0) return;
- XAnyEvent event = new XAnyEvent ();
- OS.XSync (display, false); OS.XSync (display, false);
- while (OS.XCheckWindowEvent (display, window, OS.ExposureMask, event)) {
- OS.XtDispatchEvent (event);
- }
- */
- getDisplay().update();
-}
-
-//////////////////////////////////////////////////////////////////////
-// Mac stuff
-//////////////////////////////////////////////////////////////////////
- /**
- * Sets the bounds of the given control.
- */
- private void internalSetBounds(int hndl, int x, int y, int width, int height) {
- Rect newBounds= new Rect();
- OS.SetRect(newBounds, (short)x, (short)y, (short)(x+width), (short)(y+height));
- handleResize(hndl, newBounds);
- }
-
- /**
- * subclasses can override if a resize must trigger some internal layout.
- */
- void handleResize(int hndl, Rect bounds) {
- OS.SetControlBounds(hndl, bounds);
- }
-
- /**
- * subclasses can override.
- */
- void internalGetControlBounds(int hndl, Rect bounds) {
- OS.GetControlBounds(hndl, bounds);
- }
-
- /**
- * Hook (overwritten in Text and Combo)
- */
- /*
- final int sendKeyEvent(int type, int nextHandler, int eRefHandle) {
-
- MacEvent mEvent= new MacEvent(eRefHandle);
- if (translateTraversal(mEvent))
- return 0;
-
- processEvent (type, new MacEvent(eRefHandle));
- return OS.kNoErr;
- }
- */
+}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java
index fbfcdbe2d3..48c6c63028 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Decorations.java
@@ -10,345 +10,70 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-/**
- * Instances of this class provide the appearance and
- * behavior of <code>Shells</code>, but are not top
- * level shells or dialogs. Class <code>Shell</code>
- * shares a significant amount of code with this class,
- * and is a subclass.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * Note: The styles supported by this class must be treated
- * as <em>HINT</em>s, since the window manager for the
- * desktop on which the instance is visible has ultimate
- * control over the appearance and behavior of decorations.
- * For example, some window managers only support resizable
- * windows and will always assume the RESIZE style, even if
- * it is not set.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE, ON_TOP, TOOL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>(none)</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- *
- * @see #getMinimized
- * @see #getMaximized
- * @see Shell
- * @see SWT
- */
+
public class Decorations extends Canvas {
- String label;
Image image;
- /* AW
- int dialogHandle;
- */
- // AW
- private static final int FIRST_MENU_ITEM_ID= 1000;
- // AW
- boolean minimized, maximized;
- Menu menuBar;
- Menu [] menus;
- MenuItem [] items;
Control savedFocus;
Button defaultButton, saveDefault;
+
Decorations () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#ON_TOP
- * @see SWT#TOOL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
+
public Decorations (Composite parent, int style) {
super (parent, checkStyle (style));
}
-void add (Menu menu) {
- if (menus == null) menus = new Menu [4];
- for (int i=0; i<menus.length; i++) {
- if (menus [i] == null) {
- menus [i] = menu;
- return;
- }
- }
- Menu [] newMenus = new Menu [menus.length + 4];
- newMenus [menus.length] = menu;
- System.arraycopy (menus, 0, newMenus, 0, menus.length);
- menus = newMenus;
-}
-void add (MenuItem item) {
- if (items == null) items = new MenuItem [12];
- for (int i=0; i<items.length; i++) {
- if (items [i] == null) {
- item.id = FIRST_MENU_ITEM_ID + i;
- items [i] = item;
- return;
- }
- }
- MenuItem [] newItems = new MenuItem [items.length + 12];
- item.id = FIRST_MENU_ITEM_ID + items.length;
- newItems [items.length] = item;
- System.arraycopy (items, 0, newItems, 0, items.length);
- items = newItems;
-}
-void bringToTop () {
- /*
- * Feature in X. Calling XSetInputFocus() when the
- * widget is not viewable causes an X bad match error.
- * The fix is to call XSetInputFocus() when the widget
- * is viewable.
- */
- if (minimized) return;
- if (!isVisible ()) return;
- /* AW
- int display = OS.XtDisplay (handle);
- if (display == 0) return;
- int window = OS.XtWindow (handle);
- if (window == 0) return;
- OS.XSetInputFocus (display, window, OS.RevertToParent, OS.CurrentTime);
- */
-}
+
static int checkStyle (int style) {
if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) {
style |= SWT.TITLE;
}
return style;
}
+
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
+
Control computeTabGroup () {
return this;
}
+
Control computeTabRoot () {
return this;
}
+
void createHandle (int index) {
state |= HANDLE | CANVAS;
- createScrolledHandle (parent.handle);
-}
-void createWidget (int index) {
- super.createWidget (index);
- label = "";
-}
-/* AW
-int dialogHandle () {
- if (dialogHandle != 0) return dialogHandle;
- return dialogHandle = OS.createDialogShell(handle, 0);
-}
-*/
-/* AW
-Menu findMenu (int id) {
- System.out.println("********* Decorator.findMenu *********");
- if (menus == null) return null;
- for (int i= 0; i < menus.length; i++) {
- Menu menu= menus[i];
- if (menu != null) {
- if (OS.GetMenuID(menu.handle) == id)
- return menu;
- }
- }
- return null;
}
-*/
-// AW
-MenuItem findMenuItem (int id) {
- if (items == null) return null;
- id-= FIRST_MENU_ITEM_ID;
- if (0 <= id && id < items.length) return items [id];
- return null;
-}
-// AW
-/**
- * Returns the receiver's default button if one had
- * previously been set, otherwise returns null.
- *
- * @return the default button or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setDefaultButton
- */
+
public Button getDefaultButton () {
checkWidget();
return defaultButton;
}
-/**
- * Returns the receiver's image if it had previously been
- * set using <code>setImage()</code>. The image is typically
- * displayed by the window manager when the instance is
- * marked as iconified, and may also be displayed somewhere
- * in the trim when the instance is in normal or maximized
- * states.
- * <p>
- * Note: This method will return null if called before
- * <code>setImage()</code> is called. It does not provide
- * access to a window manager provided, "default" image
- * even if one exists.
- * </p>
- *
- * @return the image
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Image getImage () {
checkWidget();
return image;
}
-/**
- * Returns <code>true</code> if the receiver is currently
- * maximized, and false otherwise.
- * <p>
- *
- * @return the maximized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMaximized
- */
+
public boolean getMaximized () {
checkWidget();
- return maximized;
-}
-/**
- * Returns the receiver's menu bar if one had previously
- * been set, otherwise returns null.
- *
- * @return the menu bar or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Menu getMenuBar () {
- checkWidget();
- return menuBar;
+ return false;
}
-/**
- * Returns <code>true</code> if the receiver is currently
- * minimized, and false otherwise.
- * <p>
- *
- * @return the minimized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMinimized
- */
+
public boolean getMinimized () {
checkWidget();
- return minimized;
+ return false;
}
+
String getNameText () {
return getText ();
}
-/**
- * Returns the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>. If the text has not previously been set,
- * returns an empty string.
- *
- * @return the text
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public String getText () {
checkWidget();
- return label;
+ return "";
}
boolean isTabGroup () {
return true;
@@ -356,61 +81,10 @@ boolean isTabGroup () {
boolean isTabItem () {
return false;
}
-Decorations menuShell () {
- return this;
-}
-int processSetFocus (Object callData) {
- int result= super.processSetFocus (callData);
-
- Boolean b= (Boolean) callData;
- if (b.booleanValue ()) { // focusIn
- restoreFocus ();
- } else { // focuOut
- saveFocus ();
- }
-
- return result;
-}
-/* AW
-void propagateWidget (boolean enabled) {
- super.propagateWidget (enabled);
- int [] argList = {OS.XmNmenuBar, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- if (argList [1] != 0) propagateHandle (enabled, argList [1]);
-}
-*/
-/* AW
-void releaseHandle () {
- super.releaseHandle ();
- dialogHandle = 0;
-}
-*/
+
void releaseWidget () {
- if (menus != null) {
- for (int i=0; i<menus.length; i++) {
- Menu menu = menus [i];
- if (menu != null && !menu.isDisposed ()) menu.dispose ();
- }
- }
- menuBar = null;
- menus = null;
super.releaseWidget ();
defaultButton = saveDefault = null;
- label = null;
-}
-void remove (Menu menu) {
- if (menus == null) return;
- for (int i=0; i<menus.length; i++) {
- if (menus [i] == menu) {
- menus [i] = null;
- return;
- }
- }
-}
-void remove (MenuItem item) {
- if (items == null) return;
- items [item.id - FIRST_MENU_ITEM_ID] = null;
- item.id = -1;
}
boolean restoreFocus () {
@@ -423,260 +97,42 @@ void saveFocus () {
Control control = getDisplay ().getFocusControl ();
if (control != null) setSavedFocus (control);
}
-/**
- * If the argument is not null, sets the receiver's default
- * button to the argument, and if the argument is null, sets
- * the receiver's default button to the first button which
- * was set as the receiver's default button (called the
- * <em>saved default button</em>). If no default button had
- * previously been set, or the saved default button was
- * disposed, the receiver's default button will be set to
- * null.
- *
- * @param the new default button
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the button has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setDefaultButton (Button button) {
checkWidget();
setDefaultButton (button, true);
}
+
void setDefaultButton (Button button, boolean save) {
- if (button == null) {
- if (defaultButton == saveDefault) {
- if (save) saveDefault = null;
- return;
- }
- } else {
- if (button.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((button.style & SWT.PUSH) == 0) return;
- if (button == defaultButton) return;
- }
- if (defaultButton != null) {
- if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
- }
- if ((defaultButton = button) == null) defaultButton = saveDefault;
- if (defaultButton != null) {
- if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
- }
- if (save || saveDefault == null) saveDefault = defaultButton;
- if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
}
-/**
- * Sets the receiver's image to the argument, which may
- * be null. The image is typically displayed by the window
- * manager when the instance is marked as iconified, and
- * may also be displayed somewhere in the trim when the
- * instance is in normal or maximized states.
- *
- * @param image the new image (or null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setImage (Image image) {
checkWidget();
- /* AW
- int pixmap = 0, mask = 0;
- */
if (image != null) {
if (image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- /* AW
- switch (image.type) {
- case SWT.BITMAP:
- pixmap = image.pixmap;
- break;
- case SWT.ICON:
- pixmap = image.pixmap;
- mask = image.mask;
- break;
- default:
- error (SWT.ERROR_INVALID_IMAGE);
- }
- */
}
this.image = image;
- /* AW
- int [] argList = {
- OS.XmNiconPixmap, pixmap,
- OS.XmNiconMask, mask,
- };
- int topHandle = topHandle ();
- OS.XtSetValues (topHandle, argList, argList.length / 2);
- */
}
-/**
- * Sets the maximized state of the receiver.
- * If the argument is <code>true</code> causes the receiver
- * to switch to the maximized state, and if the argument is
- * <code>false</code> and the receiver was previously maximized,
- * causes the receiver to switch back to either the minimized
- * or normal states.
- * <p>
- * Note: The result of intermixing calls to<code>setMaximized(true)</code>
- * and <code>setMinimized(true)</code> will vary by platform. Typically,
- * the behavior will match the platform user's expectations, but not
- * always. This should be avoided if possible.
- * </p>
- *
- * @param the new maximized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMinimized
- */
+
public void setMaximized (boolean maximized) {
checkWidget();
- this.maximized = maximized;
}
-/**
- * Sets the receiver's menu bar to the argument, which
- * may be null.
- *
- * @param menu the new menu bar
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_INVALID_ARGUMENT - if the menu has been disposed</li>
- * <li>ERROR_INVALID_PARENT - if the menu is not in the same widget tree</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public void setMenuBar (Menu menu) {
- checkWidget();
- if (menuBar == menu) return;
- if (menu != null) {
- if (menu.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
- if ((menu.style & SWT.BAR) == 0) error (SWT.ERROR_MENU_NOT_BAR);
- if (menu.parent != this) error (SWT.ERROR_INVALID_PARENT);
- }
- /* Ensure the new menu bar is correctly enabled */
- if (menuBar != null) {
- if (!isEnabled () && menuBar.getEnabled ()) {
- propagateHandle (true, menuBar.handle);
- }
- }
- if (menu != null) {
- if (!isEnabled ()) {
- propagateHandle (false, menu.handle);
- }
- }
-
- /*
- * Bug in Motif. When a XmMainWindowSetAreas () is used
- * to replace an existing menu, both menus must be managed
- * before the call to XmMainWindowSetAreas () or the new
- * menu will not be layed out properly.
- */
- /* AW
- int newHandle = (menu != null) ? menu.handle : 0;
- int oldHandle = (menuBar != null) ? menuBar.handle : 0;
- */
- menuBar = menu;
- /* AW
- int hHandle = (horizontalBar != null) ? horizontalBar.handle : 0;
- int vHandle = (verticalBar != null) ? verticalBar.handle : 0;
- if (newHandle != 0) {
- OS.XtSetMappedWhenManaged (newHandle, false);
- OS.XtManageChild (newHandle);
- }
- int clientHandle = (formHandle != 0) ? formHandle : handle;
- OS.XmMainWindowSetAreas (scrolledHandle, newHandle, 0, hHandle, vHandle, clientHandle);
- if (oldHandle != 0) OS.XtUnmanageChild (oldHandle);
- if (newHandle != 0) {
- OS.XtSetMappedWhenManaged (newHandle, true);
- }
- */
- /*
- * Bug in Motif. When a menu bar is removed after the
- * main window has been realized, the main window does
- * not layout the new menu bar or the work window.
- * The fix is to force a layout by temporarily resizing
- * the main window.
- */
- /* AW
- if (newHandle == 0 && OS.XtIsRealized (scrolledHandle)) {
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- OS.XtResizeWidget (scrolledHandle, argList [1] + 1, argList [3], argList [5]);
- OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]);
- }
- */
-}
-/**
- * Sets the minimized stated of the receiver.
- * If the argument is <code>true</code> causes the receiver
- * to switch to the minimized state, and if the argument is
- * <code>false</code> and the receiver was previously minimized,
- * causes the receiver to switch back to either the maximized
- * or normal states.
- * <p>
- * Note: The result of intermixing calls to<code>setMaximized(true)</code>
- * and <code>setMinimized(true)</code> will vary by platform. Typically,
- * the behavior will match the platform user's expectations, but not
- * always. This should be avoided if possible.
- * </p>
- *
- * @param the new maximized state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setMaximized
- */
public void setMinimized (boolean minimized) {
checkWidget();
- this.minimized = minimized;
}
+
void setSavedFocus (Control control) {
if (this == control) return;
savedFocus = control;
}
-/**
- * Sets the receiver's text, which is the string that the
- * window manager will typically display as the receiver's
- * <em>title</em>, to the argument, which may not be null.
- *
- * @param text the new text
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setText (String string) {
checkWidget();
if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- label = string;
}
+
public void setVisible (boolean visible) {
super.setVisible (visible);
- if (!visible) return;
- if (savedFocus != null && !savedFocus.isDisposed ()) {
- savedFocus.setFocus ();
- }
- savedFocus = null;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
index 39eebc338a..ab6bd494ea 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Display.java
@@ -7,128 +7,14 @@ package org.eclipse.swt.widgets;
* http://www.eclipse.org/legal/cpl-v10.html
*/
-import java.util.ArrayList;
-import java.util.Iterator;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Callback;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
-import org.eclipse.swt.internal.carbon.EventRecord;
-import org.eclipse.swt.internal.carbon.HICommand;
-/**
- * Instances of this class are responsible for managing the
- * connection between SWT and the underlying operating
- * system. Their most important function is to implement
- * the SWT event loop in terms of the platform event model.
- * They also provide various methods for accessing information
- * about the operating system, and have overall control over
- * the operating system resources which SWT allocates.
- * <p>
- * Applications which are built with SWT will <em>almost always</em>
- * require only a single display. In particular, some platforms
- * which SWT supports will not allow more than one <em>active</em>
- * display. In other words, some platforms do not support
- * creating a new display if one already exists that has not been
- * sent the <code>dispose()</code> message.
- * <p>
- * In SWT, the thread which creates a <code>Display</code>
- * instance is distinguished as the <em>user-interface thread</em>
- * for that display.
- * </p>
- * The user-interface thread for a particular display has the
- * following special attributes:
- * <ul>
- * <li>
- * The event loop for that display must be run from the thread.
- * </li>
- * <li>
- * Some SWT API methods (notably, most of the public methods in
- * <code>Widget</code> and its subclasses), may only be called
- * from the thread. (To support multi-threaded user-interface
- * applications, class <code>Display</code> provides inter-thread
- * communication methods which allow threads other than the
- * user-interface thread to request that it perform operations
- * on their behalf.)
- * </li>
- * <li>
- * The thread is not allowed to construct other
- * <code>Display</code>s until that display has been disposed.
- * (Note that, this is in addition to the restriction mentioned
- * above concerning platform support for multiple displays. Thus,
- * the only way to have multiple simultaneously active displays,
- * even on platforms which support it, is to have multiple threads.)
- * </li>
- * </ul>
- * Enforcing these attributes allows SWT to be implemented directly
- * on the underlying operating system's event model. This has
- * numerous benefits including smaller footprint, better use of
- * resources, safer memory management, clearer program logic,
- * better performance, and fewer overall operating system threads
- * required. The down side however, is that care must be taken
- * (only) when constructing multi-threaded applications to use the
- * inter-thread communication mechanisms which this class provides
- * when required.
- * </p><p>
- * All SWT API methods which may only be called from the user-interface
- * thread are distinguished in their documentation by indicating that
- * they throw the "<code>ERROR_THREAD_INVALID_ACCESS</code>"
- * SWT exception.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Close, Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see #syncExec
- * @see #asyncExec
- * @see #wake
- * @see #readAndDispatch
- * @see #sleep
- * @see #dispose
- */
public class Display extends Device {
- /* Windows, Events and Callbacks */
- static String APP_NAME = "SWT";
Event [] eventQueue;
EventTable eventTable, filterTable;
- /* Default Fonts, Colors, Insets, Widths and Heights. */
- Font defaultFont;
- Font listFont, textFont, buttonFont, labelFont, groupFont;
- private short fHoverThemeFont;
-
- int dialogBackground, dialogForeground;
- int buttonBackground, buttonForeground, buttonShadowThickness;
- int compositeBackground, compositeForeground;
- int compositeTopShadow, compositeBottomShadow, compositeBorder;
- int listBackground, listForeground, listSelect, textBackground, textForeground;
- int labelBackground, labelForeground, scrollBarBackground, scrollBarForeground;
- int scrolledInsetX, scrolledInsetY, scrolledMarginX, scrolledMarginY;
- int defaultBackground, defaultForeground;
- int textHighlightThickness;
-
- /* System Colors */
- Color COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW;
- Color COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_BORDER;
- Color COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT;
- Color COLOR_INFO_FOREGROUND, COLOR_INFO_BACKGROUND;
-
- /* Initial Guesses for Shell Trimmings. */
- int borderTrimWidth = 4, borderTrimHeight = 4;
- int resizeTrimWidth = 6, resizeTrimHeight = 6;
- int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28;
- int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29;
- int titleTrimWidth = 0, titleTrimHeight = 23;
-
/* Sync/Async Widget Communication */
Synchronizer synchronizer = new Synchronizer (this);
Thread thread;
@@ -143,20 +29,6 @@ public class Display extends Device {
/* Key Mappings. */
static int [] [] KeyTable = {
-
- /* Keyboard and Mouse Masks */
-// {OS.XK_Alt_L, SWT.ALT},
-// {OS.XK_Alt_R, SWT.ALT},
-// {OS.XK_Shift_L, SWT.SHIFT},
-// {OS.XK_Shift_R, SWT.SHIFT},
-// {OS.XK_Control_L, SWT.CONTROL},
-// {OS.XK_Control_R, SWT.CONTROL},
-
- /* NOT CURRENTLY USED */
-// {OS.VK_LBUTTON, SWT.BUTTON1},
-// {OS.VK_MBUTTON, SWT.BUTTON3},
-// {OS.VK_RBUTTON, SWT.BUTTON2},
-
/* Non-Numeric Keypad Keys */
{126, SWT.ARROW_UP},
{125, SWT.ARROW_DOWN},
@@ -196,63 +68,15 @@ public class Display extends Device {
/* Multiple Displays. */
static Display Default;
static Display [] Displays = new Display [4];
-
- /* Double Click */
- int lastTime, lastButton;
- short lastGlobalMouseXPos, lastGlobalMouseYPos;
-
- /* Current caret */
- Caret currentCaret;
- int caretID, caretProc;
/* Package Name */
static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets.";
-
- /* Mouse Hover */
- int mouseHoverID, mouseHoverProc;
- int mouseHoverHandle, toolTipWindowHandle;
/* Display Data */
Object data;
String [] keys;
Object [] values;
- /* AW Mac */
- private static final int TOOLTIP_MARGIN= 3;
- private static final int HOVER_TIMEOUT= 500; // in milli seconds
- private static final int SWT_USER_EVENT= ('S'<<24) + ('W'<<16) + ('T'<<8) + '1';
-
- private short fMenuId= 5000;
-
- // Callbacks
- private ArrayList fCallbacks;
- // callback procs
- int fApplicationProc;
- int fWindowProc;
- int fTooltipWindowProc;
- int fMouseProc;
- int fMenuProc;
- int fControlActionProc;
- int fUserPaneHitTestProc;
- int fDataBrowserDataProc, fDataBrowserCompareProc, fDataBrowserItemNotificationProc;
- int fControlProc;
-
- private boolean fMenuIsVisible;
- private int fTrackedControl;
- private int fFocusControl;
- private int fCurrentControl;
- private String fToolTipText;
- private int fLastHoverHandle;
- private boolean fInContextMenu; // true while tracking context menu
- public int fCurrentCursor;
- private Shell fMenuRootShell;
- int fLastModifiers;
- MacMouseEvent fLastMouseEvent;
-
- private static boolean fgCarbonInitialized;
- private static boolean fgInitCursorCalled;
- /* end AW */
-
/*
* TEMPORARY CODE. Install the runnable that
* gets the current display. This code will
@@ -277,54 +101,14 @@ static void setDevice (Device device) {
CurrentDevice = device;
}
-/**
- * Constructs a new instance of this class.
- * <p>
- * Note: The resulting display is marked as the <em>current</em>
- * display. If this is the first display which has been
- * constructed since the application started, it is also
- * marked as the <em>default</em> display.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see #getCurrent
- * @see #getDefault
- * @see Widget#checkSubclass
- * @see Shell
- */
public Display () {
this (null);
}
+
public Display (DeviceData data) {
- super (checkNull (data));
+ super (data);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere
- * in SWT. When the event does occur, the listener is notified
- * by sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeFilter
- * @see #removeListener
- *
- * @since 2.1
- */
public void addFilter (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -332,27 +116,6 @@ public void addFilter (int eventType, Listener listener) {
filterTable.hook (eventType, listener);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs. When the
- * event does occur in the display, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- *
- * @since 2.0
- */
public void addListener (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -360,82 +123,26 @@ public void addListener (int eventType, Listener listener) {
eventTable.hook (eventType, listener);
}
-/**
- * Requests that the connection between SWT and the underlying
- * operating system be closed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- *
- * @since 2.0
- */
-public void close () {
- checkDevice ();
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit) dispose ();
-}
-
-void addMouseHoverTimeOut (int handle) {
- if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID);
- mouseHoverID = 0;
- if (handle == fLastHoverHandle) return;
- int[] timer= new int[1];
- OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), HOVER_TIMEOUT / 1000.0, 0.0, mouseHoverProc, handle, timer);
- mouseHoverID = timer[0];
- mouseHoverHandle = handle;
-}
-static DeviceData checkNull (DeviceData data) {
- if (data == null) data = new DeviceData ();
- return data;
-}
-protected void checkDevice () {
- if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
- if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
-}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The caller of this method continues
- * to run in parallel, and is not notified when the
- * runnable has completed.
- *
- * @param runnable code to run on the user-interface thread.
- *
- * @see #syncExec
- */
public void asyncExec (Runnable runnable) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
synchronizer.asyncExec (runnable);
}
-/**
- * Causes the system hardware to emit a short sound
- * (if it supports this capability).
- */
+
public void beep () {
checkDevice ();
- OS.SysBeep((short)100);
}
-int caretProc (int id, int clientData) {
- if (id != caretID) {
- return 0;
- }
- OS.RemoveEventLoopTimer(id);
- caretID = 0;
- if (currentCaret == null) return 0;
- if (currentCaret.blinkCaret ()) {
- int blinkRate = currentCaret.blinkRate;
- int[] timer= new int[1];
- OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), blinkRate / 1000.0, 0.0, caretProc, 0, timer);
- caretID = timer[0];
- } else {
- currentCaret = null;
+
+protected void checkSubclass () {
+ if (!Display.isValidClass (getClass ())) {
+ error (SWT.ERROR_INVALID_SUBCLASS);
}
- return 0;
}
+
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
static synchronized void checkDisplay (Thread thread) {
for (int i=0; i<Displays.length; i++) {
if (Displays [i] != null && Displays [i].thread == thread) {
@@ -443,11 +150,14 @@ static synchronized void checkDisplay (Thread thread) {
}
}
}
-protected void checkSubclass () {
- if (!Display.isValidClass (getClass ())) {
- error (SWT.ERROR_INVALID_SUBCLASS);
- }
+
+public void close () {
+ checkDevice ();
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (event.doit) dispose ();
}
+
protected void create (DeviceData data) {
checkSubclass ();
checkDisplay (thread = Thread.currentThread ());
@@ -455,58 +165,25 @@ protected void create (DeviceData data) {
register (this);
if (Default == null) Default = this;
}
+
void createDisplay (DeviceData data) {
-
- /* Initialize Carbon */
- synchronized (Display.class) {
- if (!fgCarbonInitialized) {
- OS.RegisterAppearanceClient();
- OS.TXNInitTextension(0, 0, 0);
- //OS.InitCursor();
- OS.QDSwapTextFlags(OS.kQDUseCGTextRendering + OS.kQDUseCGTextMetrics);
- if (OS.InitContextualMenus() != OS.noErr)
- System.out.println("Display.createDisplay: error in OS.InitContextualMenus");
- int[] psn= new int[2];
- if (OS.GetCurrentProcess(psn) == OS.noErr)
- OS.SetFrontProcess(psn);
-
- // workaround for Register problem
- Rect bounds= new Rect();
- int[] ctl = new int[1];
- OS.CreatePushButtonControl(0, bounds, 0, ctl);
- OS.DisposeControl(ctl[0]);
- }
- fgCarbonInitialized = true;
- }
-
- fGDeviceHandle= OS.GetMainDevice();
}
+
synchronized static void deregister (Display display) {
for (int i=0; i<Displays.length; i++) {
if (display == Displays [i]) Displays [i] = null;
}
}
+
protected void destroy () {
if (this == Default) Default = null;
deregister (this);
destroyDisplay ();
}
+
void destroyDisplay () {
- // dispose Callbacks
- Iterator iter= fCallbacks.iterator();
- while (iter.hasNext()) {
- Callback cb= (Callback) iter.next();
- cb.dispose();
- }
- fCallbacks= null;
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread just before the
- * receiver is disposed.
- *
- * @param runnable code to run at dispose time.
- */
+
public void disposeExec (Runnable runnable) {
checkDevice ();
if (disposeList == null) disposeList = new Runnable [4];
@@ -521,69 +198,26 @@ public void disposeExec (Runnable runnable) {
newDisposeList [disposeList.length] = runnable;
disposeList = newDisposeList;
}
+
void error (int code) {
SWT.error(code);
}
+
boolean filterEvent (Event event) {
if (filterTable != null) filterTable.sendEvent (event);
return false;
}
+
boolean filters (int eventType) {
if (filterTable == null) return false;
return filterTable.hooks (eventType);
}
-/**
- * Given the operating system handle for a widget, returns
- * the instance of the <code>Widget</code> subclass which
- * represents it in the currently running application, if
- * such exists, or null if no matching widget can be found.
- *
- * @param handle the handle for the widget
- * @return the SWT widget that the handle represents
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Widget findWidget (int handle) {
checkDevice ();
return WidgetTable.get (handle);
}
-/**
- * Returns the currently active <code>Shell</code>, or null
- * if no shell belonging to the currently running application
- * is active.
- *
- * @return the active shell or null
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
-public Shell getActiveShell () {
- checkDevice ();
- Control control = getFocusControl ();
- if (control == null) return null;
- return control.getShell ();
-}
-/**
- * Returns the display which the currently running thread is
- * the user-interface thread for, or null if the currently
- * running thread is not a user-interface thread for any display.
- *
- * @return the current display
- */
-public static synchronized Display getCurrent () {
- return findDisplay (Thread.currentThread ());
-}
-/**
- * Returns the display which the given thread is the
- * user-interface thread for, or null if the given thread
- * is not a user-interface thread for any display.
- *
- * @param thread the user-interface thread
- * @return the display for the given thread
- */
+
public static synchronized Display findDisplay (Thread thread) {
for (int i=0; i<Displays.length; i++) {
Display display = Displays [i];
@@ -593,93 +227,41 @@ public static synchronized Display findDisplay (Thread thread) {
}
return null;
}
-/**
- * Returns the control which the on-screen pointer is currently
- * over top of, or null if it is not currently over one of the
- * controls built by the currently running application.
- *
- * @return the control under the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
+public Shell getActiveShell () {
+ checkDevice ();
+ return null;
+}
+
+public Rectangle getBounds () {
+ checkDevice ();
+ return new Rectangle (0, 0, 0, 0);
+}
+
+public Rectangle getClientArea () {
+ checkDevice ();
+ return new Rectangle (0, 0, 0, 0);
+}
+
+public static synchronized Display getCurrent () {
+ return findDisplay (Thread.currentThread ());
+}
+
public Control getCursorControl () {
checkDevice ();
- System.out.println("Display.getCursorControl: nyi");
-
- /* AW
- int [] unused = new int [1], buffer = new int [1];
- int xWindow, xParent = OS.XDefaultRootWindow (xDisplay);
- do {
- if (OS.XQueryPointer (
- xDisplay, xParent, unused, buffer,
- unused, unused, unused, unused, unused) == 0) return null;
- if ((xWindow = buffer [0]) != 0) xParent = xWindow;
- } while (xWindow != 0);
- int handle = OS.XtWindowToWidget (xDisplay, xParent);
- if (handle == 0) return null;
- do {
- Widget widget = WidgetTable.get (handle);
- if (widget != null && widget instanceof Control) {
- Control control = (Control) widget;
- if (control.getEnabled ()) return control;
- }
- } while ((handle = OS.XtParent (handle)) != 0);
- */
return null;
}
-/**
- * Returns the location of the on-screen pointer relative
- * to the top left corner of the screen.
- *
- * @return the cursor location
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Point getCursorLocation () {
checkDevice ();
- org.eclipse.swt.internal.carbon.Point loc= new org.eclipse.swt.internal.carbon.Point();
- OS.GetGlobalMouse(loc);
- return new Point (loc.h, loc.v);
+ return new Point (0, 0);
}
-/**
- * Returns the default display. One is created (making the
- * thread that invokes this method its user-interface thread)
- * if it did not already exist.
- *
- * @return the default display
- */
+
public static synchronized Display getDefault () {
if (Default == null) Default = new Display ();
return Default;
}
-/**
- * Returns the application defined property of the receiver
- * with the specified name, or null if it has not been set.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setData
- * @see #disposeExec
- */
+
public Object getData (String key) {
checkDevice ();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -689,110 +271,26 @@ public Object getData (String key) {
}
return null;
}
-/**
- * Returns the application defined, display specific data
- * associated with the receiver, or null if it has not been
- * set. The <em>display specific data</em> is a single,
- * unnamed field that is stored with every display.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the display specific data needs to
- * be notified when the display is disposed of, it is the
- * application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @return the display specific data
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #setData
- * @see #disposeExec
- */
+
public Object getData () {
checkDevice ();
return data;
}
-/**
- * Returns the longest duration, in milliseconds, between
- * two mouse button clicks that will be considered a
- * <em>double click</em> by the underlying operating system.
- *
- * @return the double click time
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getDoubleClickTime () {
checkDevice ();
- return (OS.GetDblTime() * 1000) / 60;
+ return 0;
}
-/**
- * Returns the control which currently has keyboard focus,
- * or null if keyboard events are not currently going to
- * any of the controls built by the currently running
- * application.
- *
- * @return the control under the cursor
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Control getFocusControl () {
checkDevice ();
- /* AW
- int [] buffer1 = new int [1], buffer2 = new int [1];
- OS.XGetInputFocus (xDisplay, buffer1, buffer2);
- int xWindow = buffer1 [0];
- if (xWindow == 0) return null;
- int handle = OS.XtWindowToWidget (xDisplay, xWindow);
- if (handle == 0) return null;
- handle = OS.XmGetFocusWidget (handle);
- */
- int handle= fFocusControl;
- if (handle == 0) return null;
- do {
- Widget widget = WidgetTable.get (handle);
- if (widget instanceof Control) {
- Control window = (Control) widget;
- if (window.getEnabled ()) return window;
- }
- } while ((handle = MacUtil.getSuperControl (handle)) != 0);
return null;
}
-/**
- * Returns the maximum allowed depth of icons on this display.
- * On some platforms, this may be different than the actual
- * depth of the display.
- *
- * @return the maximum icon depth
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getIconDepth () {
- return 8; // we don't support direct icons yet
+ return 0;
}
-int getLastEventTime () {
-// return (int) (OS.GetLastUserEventTime () * 1000.0);
- return (int) System.currentTimeMillis ();
-}
-/**
- * Returns an array containing all shells which have not been
- * disposed and have the receiver as their display.
- *
- * @return the receiver's shells
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
public Shell [] getShells () {
checkDevice ();
/*
@@ -820,308 +318,74 @@ public Shell [] getShells () {
}
return result;
}
-/**
- * Returns the thread that has invoked <code>syncExec</code>
- * or null if no such runnable is currently being invoked by
- * the user-interface thread.
- * <p>
- * Note: If a runnable invoked by asyncExec is currently
- * running, this method will return null.
- * </p>
- *
- * @return the receiver's sync-interface thread
- */
+
public Thread getSyncThread () {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
return synchronizer.syncThread;
}
-/**
- * Returns the matching standard color for the given
- * constant, which should be one of the color constants
- * specified in class <code>SWT</code>. Any value other
- * than one of the SWT color constants which is passed
- * in will result in the color black. This color should
- * not be free'd because it was allocated by the system,
- * not the application.
- *
- * @param id the color constant
- * @return the matching color
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
+
public Color getSystemColor (int id) {
checkDevice ();
- Color xColor = null;
- switch (id) {
- case SWT.COLOR_INFO_FOREGROUND: return COLOR_INFO_FOREGROUND;
- case SWT.COLOR_INFO_BACKGROUND: return COLOR_INFO_BACKGROUND;
- case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
- case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE);
- case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE);
- case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY);
- case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY);
- case SWT.COLOR_WIDGET_DARK_SHADOW: xColor = COLOR_WIDGET_DARK_SHADOW; break;
- case SWT.COLOR_WIDGET_NORMAL_SHADOW: xColor = COLOR_WIDGET_NORMAL_SHADOW; break;
- case SWT.COLOR_WIDGET_LIGHT_SHADOW: xColor = COLOR_WIDGET_LIGHT_SHADOW; break;
- case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: xColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break;
- case SWT.COLOR_WIDGET_BACKGROUND: xColor = COLOR_WIDGET_BACKGROUND; break;
- case SWT.COLOR_WIDGET_FOREGROUND:
- case SWT.COLOR_WIDGET_BORDER: xColor = COLOR_WIDGET_BORDER; break;
- case SWT.COLOR_LIST_FOREGROUND: xColor = COLOR_LIST_FOREGROUND; break;
- case SWT.COLOR_LIST_BACKGROUND: xColor = COLOR_LIST_BACKGROUND; break;
- case SWT.COLOR_LIST_SELECTION: xColor = COLOR_LIST_SELECTION; break;
- case SWT.COLOR_LIST_SELECTION_TEXT: xColor = COLOR_LIST_SELECTION_TEXT; break;
- default:
- return super.getSystemColor (id);
- }
- if (xColor == null)
- System.out.println("Display.getSystemColor: color null " + id);
- if (xColor == null) return super.getSystemColor (SWT.COLOR_BLACK);
- //return Color.carbon_new (this, xColor);
- return xColor;
- // return getSystemColor(this, id);
+
+// switch (id) {
+// case SWT.COLOR_INFO_FOREGROUND: return COLOR_INFO_FOREGROUND;
+// case SWT.COLOR_INFO_BACKGROUND: return COLOR_INFO_BACKGROUND;
+// case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
+// case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE);
+// case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE);
+// case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
+// case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY);
+// case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY);
+// case SWT.COLOR_WIDGET_DARK_SHADOW: xColor = COLOR_WIDGET_DARK_SHADOW; break;
+// case SWT.COLOR_WIDGET_NORMAL_SHADOW: xColor = COLOR_WIDGET_NORMAL_SHADOW; break;
+// case SWT.COLOR_WIDGET_LIGHT_SHADOW: xColor = COLOR_WIDGET_LIGHT_SHADOW; break;
+// case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: xColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break;
+// case SWT.COLOR_WIDGET_BACKGROUND: xColor = COLOR_WIDGET_BACKGROUND; break;
+// case SWT.COLOR_WIDGET_FOREGROUND:
+// case SWT.COLOR_WIDGET_BORDER: xColor = COLOR_WIDGET_BORDER; break;
+// case SWT.COLOR_LIST_FOREGROUND: xColor = COLOR_LIST_FOREGROUND; break;
+// case SWT.COLOR_LIST_BACKGROUND: xColor = COLOR_LIST_BACKGROUND; break;
+// case SWT.COLOR_LIST_SELECTION: xColor = COLOR_LIST_SELECTION; break;
+// case SWT.COLOR_LIST_SELECTION_TEXT: xColor = COLOR_LIST_SELECTION_TEXT; break;
+// default:
+// return super.getSystemColor (id);
+// }
+ return null;
}
-/**
- * Returns a reasonable font for applications to use.
- * On some platforms, this will match the "default font"
- * or "system font" if such can be found. This font
- * should not be free'd because it was allocated by the
- * system, not the application.
- * <p>
- * Typically, applications which want the default look
- * should simply not set the font on the widgets they
- * create. Widgets are always created with the correct
- * default font for the class of user-interface component
- * they represent.
- * </p>
- *
- * @return a font
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Font getSystemFont () {
checkDevice ();
- return defaultFont;
+ return null;
}
-/**
- * Returns the user-interface thread for the receiver.
- *
- * @return the receiver's user-interface thread
- */
+
public Thread getThread () {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
return thread;
}
-void hideToolTip () {
- if (toolTipWindowHandle != 0) {
- OS.HideWindow(toolTipWindowHandle);
- OS.DisposeWindow(toolTipWindowHandle);
- toolTipWindowHandle = 0;
- }
-}
+
protected void init () {
super.init ();
-
- /* Create the callbacks */
- timerProc= createCallback("timerProc", 2);
- caretProc= createCallback("caretProc", 2);
- mouseHoverProc= createCallback("mouseHoverProc", 2);
-
- fWindowProc= createCallback("handleWindowCallback", 3);
- fTooltipWindowProc= createCallback("handleTooltipWindowCallback", 3);
- fMouseProc= createCallback("handleMouseCallback", 3);
-
- fControlActionProc= createCallback("handleControlAction", 2);
- fControlProc= createCallback("handleControlProc", 3);
-
- //fUserPaneDrawProc= createCallback("handleUserPaneDraw", 2);
- fUserPaneHitTestProc= createCallback("handleUserPaneHitTest", 2);
-
- fDataBrowserDataProc= createCallback("handleDataBrowserDataCallback", 5);
- fDataBrowserCompareProc= createCallback("handleDataBrowserCompareCallback", 4);
- fDataBrowserItemNotificationProc= createCallback("handleDataBrowserItemNotificationCallback", 3);
-
- fMenuProc= createCallback("handleMenuCallback", 3);
-
- // create standard event handler
- fApplicationProc= createCallback("handleApplicationCallback", 3);
- int[] mask= new int[] {
- OS.kEventClassCommand, OS.kEventProcessCommand,
-
- //OS.kEventClassAppleEvent, OS.kAEQuitApplication,
- OS.kEventClassAppleEvent, OS.kEventAppleEvent,
-
- // we track down events here because we need to know when the user
- // has clicked in the menu bar
- OS.kEventClassMouse, OS.kEventMouseDown,
- // we track up, dragged, and moved events because
- // we need to get these events even if the mouse is outside of the window.
- OS.kEventClassMouse, OS.kEventMouseDragged,
- OS.kEventClassMouse, OS.kEventMouseUp,
- OS.kEventClassMouse, OS.kEventMouseMoved,
-
- SWT_USER_EVENT, 54321,
- SWT_USER_EVENT, 54322,
- };
- if (OS.InstallEventHandler(OS.GetApplicationEventTarget(), fApplicationProc, mask.length / 2, mask, 0, null) != OS.noErr)
- error (SWT.ERROR_NO_MORE_CALLBACKS);
-
-
- int textInputProc= createCallback("handleTextCallback", 3);
- mask= new int[] {
- OS.kEventClassKeyboard, OS.kEventRawKeyDown,
- OS.kEventClassKeyboard, OS.kEventRawKeyModifiersChanged,
- OS.kEventClassKeyboard, OS.kEventRawKeyRepeat,
- OS.kEventClassKeyboard, OS.kEventRawKeyUp,
- };
- if (OS.InstallEventHandler(OS.GetUserFocusEventTarget(), textInputProc, mask.length / 2, mask, 0, null) != OS.noErr)
- error (SWT.ERROR_NO_MORE_CALLBACKS);
-
-
- buttonFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallSystemFont));
- buttonShadowThickness= 1;
- //scrolledInsetX = scrolledInsetY = 15;
- scrolledMarginX= scrolledMarginY= 15;
- compositeForeground = 0x000000;
- compositeBackground = -1; // 0xEEEEEE;
-
- groupFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallEmphasizedSystemFont));
-
- dialogForeground= 0x000000;
- dialogBackground= 0xffffff;
-
- labelForeground = 0x000000;
- labelBackground = -1;
- labelFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallSystemFont));
-
- listForeground = 0x000000;
- listBackground = 0xffffff;
- listSelect = listForeground; // if reversed colors
- listFont= Font.carbon_new (this, new MacFont((short)1)); // Mac Appl Font
-
- scrollBarForeground = 0x000000;
- scrollBarBackground = 0xffffff;
-
- textForeground = 0x000000;
- textBackground = 0xffffff;
- textHighlightThickness = 1; // ???
- textFont= Font.carbon_new (this, new MacFont((short)1)); // Mac Appl Font
-
- COLOR_WIDGET_DARK_SHADOW = Color.carbon_new(this, 0x333333, true);
- COLOR_WIDGET_NORMAL_SHADOW = Color.carbon_new(this, 0x666666, true);
- COLOR_WIDGET_LIGHT_SHADOW = Color.carbon_new(this, 0x999999, true);
- COLOR_WIDGET_HIGHLIGHT_SHADOW = Color.carbon_new(this, 0xCCCCCC, true);
- COLOR_WIDGET_BACKGROUND = Color.carbon_new(this, 0xFFFFFF, true);
- COLOR_WIDGET_BORDER = Color.carbon_new(this, 0x000000, true);
- COLOR_LIST_FOREGROUND = Color.carbon_new(this, 0x000000, true);
- COLOR_LIST_BACKGROUND = Color.carbon_new(this, 0xFFFFFF, true);
- COLOR_LIST_SELECTION = Color.carbon_new(this, 0x6666CC, true);
- COLOR_LIST_SELECTION_TEXT = Color.carbon_new(this, 0xFFFFFF, true);
- COLOR_INFO_BACKGROUND = Color.carbon_new(this, 0xFFFFE1, true);
- COLOR_INFO_FOREGROUND = Color.carbon_new(this, 0x000000, true);
-
- fHoverThemeFont= (short) OS.kThemeSmallSystemFont;
+}
- defaultFont = Font.carbon_new (this, getThemeFont(OS.kThemeSmallSystemFont));
-
- defaultForeground = compositeForeground;
- defaultBackground = compositeBackground;
-}
-/**
- * Invokes platform specific functionality to allocate a new GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. 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.
- * </p>
- *
- * @param data the platform specific GC data
- * @return the platform specific GC handle
- *
- * @private
- */
public int internal_new_GC (GCData data) {
if (isDisposed()) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
- /* AW
- int xDrawable = OS.XDefaultRootWindow (xDisplay);
- int xGC = OS.XCreateGC (xDisplay, xDrawable, 0, null);
- if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
- OS.XSetSubwindowMode (xDisplay, xGC, OS.IncludeInferiors);
- if (data != null) {
- data.device = this;
- data.display = xDisplay;
- data.drawable = xDrawable;
- data.fontList = defaultFont;
- data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
- }
- return xGC;
- */
-
- if (data != null) {
- data.device = this;
- /* AW
- data.display = xDisplay;
- data.drawable = xWindow;
- data.foreground = argList [1];
- data.background = argList [3];
- data.fontList = fontList;
- data.colormap = argList [5];
- */
- data.foreground = 0x000000;
- data.background = 0xffffff;
- data.font = new MacFont((short)1);
- data.controlHandle = 0;
- }
+ return 0;
+}
- int wHandle= OS.FrontWindow();
- int xGC= OS.GetWindowPort(wHandle);
- if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
-
- return xGC;
-}
-/**
- * Invokes platform specific functionality to dispose a GC handle.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
- * API for <code>Display</code>. 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.
- * </p>
- *
- * @param handle the platform specific GC handle
- * @param data the platform specific GC data
- *
- * @private
- */
public void internal_dispose_GC (int gc, GCData data) {
}
-boolean isValidThread () {
- return thread == Thread.currentThread ();
-}
+
static boolean isValidClass (Class clazz) {
String name = clazz.getName ();
int index = name.lastIndexOf ('.');
return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
}
-int mouseHoverProc (int id, int handle) {
- if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID);
- mouseHoverID = mouseHoverHandle = 0;
- if (fLastMouseEvent == null) return OS.noErr;
- int rc= windowProc (handle, SWT.MouseHover, fLastMouseEvent);
- sendUserEvent(54321);
- return rc;
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
}
+
void postEvent (Event event) {
/*
* Place the event at the end of the event queue.
@@ -1143,63 +407,12 @@ void postEvent (Event event) {
}
eventQueue [index] = event;
}
-/**
- * Reads an event from the operating system's event queue,
- * dispatches it appropriately, and returns <code>true</code>
- * if there is potentially more work to do, or <code>false</code>
- * if the caller can sleep until another event is placed on
- * the event queue.
- * <p>
- * In addition to checking the system event queue, this method also
- * checks if any inter-thread messages (created by <code>syncExec()</code>
- * or <code>asyncExec()</code>) are waiting to be processed, and if
- * so handles them before returning.
- * </p>
- *
- * @return <code>false</code> if the caller can sleep upon return from this method
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #sleep
- * @see #wake
- */
+
public boolean readAndDispatch () {
checkDevice ();
-
- if (!fgInitCursorCalled) {
- OS.InitCursor();
- fgInitCursorCalled= true;
- }
-
- int[] evt= new int[1];
- int rc= OS.ReceiveNextEvent(0, null, OS.kEventDurationNoWait, true, evt);
-
- switch (rc) {
- case OS.noErr:
- int event= evt[0];
- if (OS.GetEventClass(event) == SWT_USER_EVENT && OS.GetEventKind(event) == 54322) {
- //System.out.println("aha");
- OS.ReleaseEvent(event);
- break;
- }
- //System.out.println("event: " + MacUtil.toString(OS.GetEventClass(event)));
- OS.SendEventToEventTarget(event, OS.GetEventDispatcherTarget());
- OS.ReleaseEvent(event);
- runDeferredEvents();
- return true;
-
- case OS.eventLoopTimedOutErr:
- // System.out.println("readAndDispatch: eventLoopTimedOutErr");
- break; // no event: run async
-
- default:
- System.out.println("readAndDispatch: error " + rc);
- break;
- }
- return runAsyncMessages ();
+ return false;
}
+
static synchronized void register (Display display) {
for (int i=0; i<Displays.length; i++) {
if (Displays [i] == null) {
@@ -1212,6 +425,7 @@ static synchronized void register (Display display) {
newDisplays [Displays.length] = display;
Displays = newDisplays;
}
+
protected void release () {
Shell [] shells = WidgetTable.shells ();
for (int i=0; i<shells.length; i++) {
@@ -1232,81 +446,10 @@ protected void release () {
releaseDisplay ();
super.release ();
}
-void releaseDisplay () {
-
- /* Dispose the caret callback */
- /* AW
- if (caretID != 0) OS.XtRemoveTimeOut (caretID);
- */
- if (caretID != 0) OS.RemoveEventLoopTimer(caretID);
- caretID = caretProc = 0;
-
- /* Dispose the timer callback */
- if (timerIDs != null) {
- for (int i=0; i<timerIDs.length; i++) {
- /* AW
- if (timerIDs [i] != 0) OS.XtRemoveTimeOut (timerIDs [i]);
- */
- if (timerIDs [i] != 0) OS.RemoveEventLoopTimer (timerIDs [i]);
- }
- }
- timerIDs = null;
- timerList = null;
- timerProc = 0;
- /* Dispose the mouse hover callback */
- if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID);
- mouseHoverID = mouseHoverProc = mouseHoverHandle = toolTipWindowHandle = 0;
-
- /* Free the font lists */
- /* AW
- if (buttonFont != 0) OS.XmFontListFree (buttonFont);
- if (labelFont != 0) OS.XmFontListFree (labelFont);
- if (textFont != 0) OS.XmFontListFree (textFont);
- if (listFont != 0) OS.XmFontListFree (listFont);
- listFont = textFont = labelFont = buttonFont = 0;
- */
- defaultFont = null;
-
- /* Release references */
- thread = null;
- buttonBackground = buttonForeground = 0;
- defaultBackground = defaultForeground = 0;
- COLOR_WIDGET_DARK_SHADOW = COLOR_WIDGET_NORMAL_SHADOW = COLOR_WIDGET_LIGHT_SHADOW =
- COLOR_WIDGET_HIGHLIGHT_SHADOW = COLOR_WIDGET_BACKGROUND = COLOR_WIDGET_BORDER =
- COLOR_LIST_FOREGROUND = COLOR_LIST_BACKGROUND = COLOR_LIST_SELECTION = COLOR_LIST_SELECTION_TEXT = null;
- COLOR_INFO_BACKGROUND = null;
-}
-void releaseToolTipHandle (int handle) {
- if (mouseHoverHandle == handle) removeMouseHoverTimeOut ();
- if (toolTipWindowHandle != 0) {
- /* AW
- int shellParent = OS.XtParent(toolTipWindowHandle);
- if (handle == shellParent) toolTipWindowHandle = 0;
- */
- }
+void releaseDisplay () {
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs anywhere in SWT.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addFilter
- * @see #addListener
- *
- * @since 2.1
- */
public void removeFilter (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1315,25 +458,6 @@ public void removeFilter (int eventType, Listener listener) {
if (filterTable.size () == 0) filterTable = null;
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- *
- * @since 2.0
- */
public void removeListener (int eventType, Listener listener) {
checkDevice ();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1341,13 +465,10 @@ public void removeListener (int eventType, Listener listener) {
eventTable.unhook (eventType, listener);
}
-void removeMouseHoverTimeOut () {
- if (mouseHoverID != 0) OS.RemoveEventLoopTimer(mouseHoverID);
- mouseHoverID = mouseHoverHandle = 0;
-}
boolean runAsyncMessages () {
return synchronizer.runAsyncMessages ();
}
+
boolean runDeferredEvents () {
/*
* Run deferred events. This code is always
@@ -1390,7 +511,7 @@ void sendEvent (int eventType, Event event) {
if (event == null) event = new Event ();
event.display = this;
event.type = eventType;
- if (event.time == 0) event.time = getLastEventTime ();
+ //if (event.time == 0) event.time = getLastEventTime ();
if (!filterEvent (event)) {
if (eventTable != null) eventTable.sendEvent (event);
}
@@ -1403,7 +524,6 @@ void sendEvent (int eventType, Event event) {
* @param name the new app name
*/
public static void setAppName (String name) {
- APP_NAME = name;
}
/**
@@ -1430,41 +550,6 @@ public void setCursorLocation (Point point) {
System.out.println("Display.setCursorLocation: nyi");
}
-void setCurrentCaret (Caret caret) {
- if (caretID != 0) OS.RemoveEventLoopTimer(caretID);
- caretID = 0;
- currentCaret = caret;
- if (currentCaret != null) {
- int blinkRate = currentCaret.blinkRate;
- int[] timer= new int[1];
- OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), blinkRate / 1000.0, 0.0, caretProc, 0, timer);
- caretID = timer[0];
- }
-}
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given argument.
- * <p>
- * Applications may have associated arbitrary objects with the
- * receiver in this fashion. If the objects stored in the
- * properties need to be notified when the display is disposed
- * of, it is the application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setData
- * @see #disposeExec
- */
public void setData (String key, Object value) {
checkDevice ();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1512,45 +597,12 @@ public void setData (String key, Object value) {
keys = newKeys;
values = newValues;
}
-/**
- * Sets the application defined, display specific data
- * associated with the receiver, to the argument.
- * The <em>display specific data</em> is a single,
- * unnamed field that is stored with every display.
- * <p>
- * Applications may put arbitrary objects in this field. If
- * the object stored in the display specific data needs to
- * be notified when the display is disposed of, it is the
- * application's responsibility provide a
- * <code>disposeExec()</code> handler which does so.
- * </p>
- *
- * @param data the new display specific data
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #getData
- * @see #disposeExec
- */
+
public void setData (Object data) {
checkDevice ();
this.data = data;
}
-/**
- * Sets the synchronizer used by the display to be
- * the argument, which can not be null.
- *
- * @param synchronizer the new synchronizer for the display (must not be null)
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the synchronizer is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setSynchronizer (Synchronizer synchronizer) {
checkDevice ();
if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1559,146 +611,17 @@ public void setSynchronizer (Synchronizer synchronizer) {
}
this.synchronizer = synchronizer;
}
-void setToolTipText (int handle, String toolTipText) {
-/* AW
- if (toolTipHandle == 0) return;
- int shellHandle = OS.XtParent (toolTipHandle);
- int shellParent = OS.XtParent (shellHandle);
- if (handle != shellParent) return;
-*/
- showToolTip (handle, toolTipText);
-}
-void showToolTip (int handle, String toolTipText) {
-
- if (toolTipText == null || toolTipText.length () == 0) {
- if (toolTipWindowHandle != 0)
- OS.HideWindow(toolTipWindowHandle);
- return;
- }
- if (toolTipWindowHandle != 0)
- return;
-
- if (handle != fCurrentControl) {
- //System.out.println("Display.showToolTip: handle is not current");
- //beep();
- return;
- }
- if (fMenuIsVisible) {
- //System.out.println("Display.showToolTip: menu is visible");
- //beep();
- return;
- }
- if (OS.StillDown()) {
- //System.out.println("Display.showToolTip: button is down");
- //beep();
- return;
- }
-
- toolTipText= MacUtil.removeMnemonics(toolTipText);
-
- // remember text
- fToolTipText= toolTipText;
-
- // calculate text bounding box
- short[] bounds= new short[2];
- short[] baseLine= new short[1];
- int sHandle= OS.CFStringCreateWithCharacters(toolTipText);
- OS.GetThemeTextDimensions(sHandle, fHoverThemeFont, OS.kThemeStateActive, false, bounds, baseLine);
- if (bounds[1] > 200) { // too wide -> wrap text
- bounds[1]= (short) 200;
- OS.GetThemeTextDimensions(sHandle, fHoverThemeFont, OS.kThemeStateActive, true, bounds, baseLine);
- }
- OS.CFRelease(sHandle);
- int width= bounds[1] + 2*TOOLTIP_MARGIN;
- int height= bounds[0] + 2*TOOLTIP_MARGIN;
-
- // position just below mouse cursor
- org.eclipse.swt.internal.carbon.Point loc= new org.eclipse.swt.internal.carbon.Point();
- OS.GetGlobalMouse(loc);
- int x= loc.h + 16;
- int y= loc.v + 16;
-
- // Ensure that the tool tip is on the screen.
- Rect screenBounds= new Rect();
- OS.GetAvailableWindowPositioningBounds(OS.GetMainDevice(), screenBounds);
- x = Math.max (0, Math.min (x, screenBounds.right - screenBounds.left - width ));
- y = Math.max (0, Math.min (y, screenBounds.bottom - screenBounds.top - height ));
-
- // create window
- int[] wHandle= new int[1];
- Rect rect = new Rect();
- rect.left = (short)x;
- rect.top = (short)y;
- rect.right = (short)(x + width);
- rect.bottom = (short)(y + height);
- if (OS.CreateNewWindow(OS.kHelpWindowClass, 0, rect, wHandle) == OS.noErr) {
- toolTipWindowHandle= wHandle[0];
- int[] mask= new int[] {
- OS.kEventClassWindow, OS.kEventWindowDrawContent
- };
- OS.InstallEventHandler(OS.GetWindowEventTarget(toolTipWindowHandle), fTooltipWindowProc,
- mask.length / 2, mask, toolTipWindowHandle, null);
- OS.ShowWindow(toolTipWindowHandle);
- fLastHoverHandle= handle;
- }
-}
-/**
- * Causes the user-interface thread to <em>sleep</em> (that is,
- * to be put in a state where it does not consume CPU cycles)
- * until an event is received or it is otherwise awakened.
- *
- * @return <code>true</code> if an event requiring dispatching was placed on the queue.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #wake
- */
public boolean sleep () {
checkDevice ();
- int rc= OS.ReceiveNextEvent(0, null, OS.kEventDurationForever, false, null);
- if (rc != OS.noErr)
- System.out.println("oha: " + rc);
- return rc == OS.noErr;
+ return false;
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread at the next
- * reasonable opportunity. The thread which calls this method
- * is suspended until the runnable completes.
- *
- * @param runnable code to run on the user-interface thread.
- *
- * @exception SWTException <ul>
- * <li>ERROR_FAILED_EXEC - if an exception occured when executing the runnable</li>
- * </ul>
- *
- * @see #asyncExec
- */
+
public void syncExec (Runnable runnable) {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
synchronizer.syncExec (runnable);
}
-/**
- * Causes the <code>run()</code> method of the runnable to
- * be invoked by the user-interface thread after the specified
- * number of milliseconds have elapsed. If milliseconds is less
- * than zero, the runnable is not executed.
- *
- * @param milliseconds the delay before running the runnable
- * @param runnable code to run on the user-interface thread
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the runnable is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #asyncExec
- */
+
public void timerExec (int milliseconds, Runnable runnable) {
checkDevice ();
if (timerList == null) timerList = new Runnable [4];
@@ -1717,7 +640,7 @@ public void timerExec (int milliseconds, Runnable runnable) {
timerIDs = newTimerIDs;
}
int[] timer= new int[1];
- OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), milliseconds / 1000.0, 0.0, timerProc, index, timer);
+ //OS.InstallEventLoopTimer(OS.GetCurrentEventLoop(), milliseconds / 1000.0, 0.0, timerProc, index, timer);
int timerID = timer[0];
if (timerID != 0) {
@@ -1725,733 +648,13 @@ public void timerExec (int milliseconds, Runnable runnable) {
timerList [index] = runnable;
}
}
-int timerProc (int id, int index) {
- if (id != 0)
- OS.RemoveEventLoopTimer(id);
- if (timerList == null) return 0;
- if (0 <= index && index < timerList.length) {
- Runnable runnable = timerList [index];
- timerList [index] = null;
- timerIDs [index] = 0;
- if (runnable != null) runnable.run ();
- }
- return 0;
-}
-static int translateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [0] == key) return KeyTable [i] [1];
- }
- return 0;
-}
-static int untranslateKey (int key) {
- for (int i=0; i<KeyTable.length; i++) {
- if (KeyTable [i] [1] == key) return KeyTable [i] [0];
- }
- return 0;
-}
-/**
- * Forces all outstanding paint requests for the display
- * to be processed before this method returns.
- *
- * @see Control#update
- */
+
public void update () {
checkDevice ();
- /* AW
- XAnyEvent event = new XAnyEvent ();
- int mask = OS.ExposureMask | OS.ResizeRedirectMask |
- OS.StructureNotifyMask | OS.SubstructureNotifyMask |
- OS.SubstructureRedirectMask;
- OS.XSync (xDisplay, false); OS.XSync (xDisplay, false);
- while (OS.XCheckMaskEvent (xDisplay, mask, event)) OS.XtDispatchEvent (event);
- */
- int[] mask= new int[] {
- OS.kEventClassWindow, OS.kEventWindowDrawContent
- };
- int[] evt= new int[1];
- while (OS.ReceiveNextEvent(mask.length/2, mask, 0.01, true, evt) == OS.noErr) {
- int rc= OS.SendEventToEventTarget(evt[0], OS.GetEventDispatcherTarget());
- if (rc != OS.noErr)
- System.out.println("Display.update: SendEventToEventTarget: " + rc);
- OS.ReleaseEvent(evt[0]);
- }
- /*
- if (wHandle != 0) {
- int port= OS.GetWindowPort(wHandle);
- if (port != 0)
- OS.QDFlushPortBuffer(port, 0);
- }
- */
}
-/**
- * If the receiver's user-interface thread was <code>sleep</code>'ing,
- * causes it to be awakened and start running again. Note that this
- * method may be called from any thread.
- *
- * @see #sleep
- */
+
public void wake () {
if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
if (thread == Thread.currentThread ()) return;
- /* Send a user event to wake up in ReceiveNextEvent */
- sendUserEvent(54322);
-}
-public int windowProc (int handle, int clientData) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.processEvent (clientData);
-}
-public int windowProc (int handle, boolean callData) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.processSetFocus (new Boolean(callData));
-}
-public int windowProc (int handle, int clientData, int callData) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.processResize (new Integer(callData));
-}
-public int windowProc (int handle, int clientData, MacEvent callData) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.processEvent (clientData, callData);
-}
-public int windowProc (int handle, int clientData, MacMouseEvent mme) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.processEvent (clientData, mme);
-}
-public int windowProc (int handle, int clientData, MacControlEvent mce) {
- Widget widget = WidgetTable.get (handle);
- if (widget == null) return 0;
- return widget.processEvent (clientData, mce);
-}
-static String convertToLf(String text) {
- char Cr = '\r';
- char Lf = '\n';
- int length = text.length ();
- if (length == 0) return text;
-
- /* Check for an LF or CR/LF. Assume the rest of the string
- * is formatted that way. This will not work if the string
- * contains mixed delimiters. */
- int i = text.indexOf (Lf, 0);
- if (i == -1 || i == 0) return text;
- if (text.charAt (i - 1) != Cr) return text;
-
- /* The string is formatted with CR/LF.
- * Create a new string with the LF line delimiter. */
- i = 0;
- StringBuffer result = new StringBuffer ();
- while (i < length) {
- int j = text.indexOf (Cr, i);
- if (j == -1) j = length;
- String s = text.substring (i, j);
- result.append (s);
- i = j + 2;
- result.append (Lf);
- }
- return result.toString ();
}
-
-////////////////////////////////////////////////////////////////////////////
-// Some Mac helper functions
-////////////////////////////////////////////////////////////////////////////
-
- short nextMenuId() {
- //FIXME - menu id's are 16-bit and wrap at 0xFFFF
- return fMenuId++;
- }
-
- void flush (int cHandle) {
- int wHandle= OS.GetControlOwner(cHandle);
- if (wHandle != 0) {
- int port= OS.GetWindowPort(wHandle);
- if (port != 0)
- OS.QDFlushPortBuffer(port, 0);
- }
- }
-
- //---- callbacks
-
- private int handleControlAction(int cHandle, int partCode) {
- return windowProc(cHandle, SWT.Selection, new MacControlEvent(cHandle, partCode, true));
- }
-
- private int handleControlProc(int inCallRef, int inEvent, int cHandle) {
- int clazz= OS.GetEventClass(inEvent);
-
- if (OS.GetEventClass(inEvent) == OS.kEventClassControl) {
- int kind= OS.GetEventKind(inEvent);
- switch (kind) {
-
- case OS.kEventControlDraw:
- int[] gccontext= new int[1];
- OS.GetEventParameter(inEvent, OS.kEventParamCGContextRef, OS.typeCGContextRef, null, 4, null, gccontext);
- int[] region= new int[1];
- if (OS.GetEventParameter(inEvent, OS.kEventParamRgnHandle, OS.typeQDRgnHandle, null, 4, null, region) != OS.noErr)
- System.err.println("kEventControlDraw: couldn't retrieve region");
- windowProc(cHandle, SWT.Paint, new MacControlEvent(inEvent, region[0], gccontext[0]));
- return OS.noErr;
-
- case OS.kEventControlHit:
- short[] part= new short[1];
- OS.GetEventParameter(inEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part);
- return windowProc(cHandle, SWT.Selection, new MacControlEvent(cHandle, part[0], true));
-
- default:
- System.out.println("Display.handleControlProc: wrong event kind: " + kind);
- break;
- }
- } else {
- System.out.println("Display.handleControlProc: wrong event class: " + clazz);
- }
- return OS.eventNotHandledErr;
- }
-
- private int handleUserPaneHitTest(int cHandle, int where) {
- return 111;
- }
-
- private int handleDataBrowserDataCallback(int cHandle, int item, int property, int itemData, int setValue) {
- Widget widget= WidgetTable.get(cHandle);
- if (widget instanceof List) {
- List list= (List) widget;
- return list.handleItemCallback(item, property, itemData);
- }
- if (widget instanceof Tree2) {
- Tree2 tree= (Tree2) widget;
- return tree.handleItemCallback(item, property, itemData, setValue);
- }
- return OS.noErr;
- }
-
- private int handleDataBrowserCompareCallback(int cHandle, int item1ID, int item2ID, int sortID) {
- Widget widget= WidgetTable.get(cHandle);
- if (widget instanceof List) {
- List list= (List) widget;
- return list.handleCompareCallback(item1ID, item2ID, sortID);
- }
- if (widget instanceof Tree2) {
- Tree2 tree= (Tree2) widget;
- return tree.handleCompareCallback(item1ID, item2ID, sortID);
- }
- return OS.noErr;
- }
-
- private int handleDataBrowserItemNotificationCallback(int cHandle, int item, int message) {
- Widget widget= WidgetTable.get(cHandle);
- if (widget instanceof List) {
- List list= (List) widget;
- return list.handleItemNotificationCallback(item, message);
- }
- if (widget instanceof Tree2) {
- Tree2 tree= (Tree2) widget;
- return tree.handleItemNotificationCallback(item, message);
- }
- return OS.noErr;
- }
-
- private int handleMenuCallback(int nextHandler, int eHandle, int mHandle) {
- switch (OS.GetEventKind(eHandle)) {
-
- case OS.kEventMenuPopulate:
- case OS.kEventMenuOpening:
- if (fInContextMenu)
- OS.SetMenuFont(mHandle, (short)1024, (short)11); // AW todo: FIXME menu id
- /*
- // copy the menu's font
- short[] fontID= new short[1];
- short[] size= new short[1];
- OS.GetMenuFont(hMenu, fontID, size);
- OS.SetMenuFont(menu.handle, fontID[0], size[0]);
- */
- windowProc(mHandle, SWT.Show, new MacEvent(eHandle, nextHandler));
- break;
-
- case OS.kEventMenuClosed:
- windowProc(mHandle, SWT.Hide, new MacEvent(eHandle, nextHandler));
- break;
- }
- return OS.noErr;
- }
-
- private int handleTextCallback(int nextHandler, int eRefHandle, int userData) {
-
- int eventClass= OS.GetEventClass(eRefHandle);
- int eventKind= OS.GetEventKind(eRefHandle);
-
- switch (eventClass) {
-
- case OS.kEventClassTextInput:
- switch (eventKind) {
- case OS.kEventTextInputUnicodeForKeyEvent:
- return OS.eventNotHandledErr;
- default:
- System.out.println("Display.handleTextCallback: kEventClassTextInput: unexpected event kind");
- break;
- }
- break;
-
- case OS.kEventClassKeyboard:
-
- // decide whether a SWT control has the focus
- Control focus= getFocusControl();
- if (focus == null || focus.handle == 0)
- return OS.eventNotHandledErr;
-
- int frontWindow= OS.FrontWindow();
- if (findWidget(frontWindow) == null) {
- int w= OS.GetControlOwner(focus.handle);
- if (w != OS.FrontWindow()) // its probably a standard dialog
- return OS.eventNotHandledErr;
- }
-
- switch (eventKind) {
- case OS.kEventRawKeyDown:
- if (MacEvent.getKeyCode(eRefHandle) == 114) { // help key
- windowProc(focus.handle, SWT.Help);
- return OS.noErr;
- }
- // fall through!
- case OS.kEventRawKeyRepeat:
- return focus.processEvent(SWT.KeyDown, new MacEvent(eRefHandle, nextHandler));
-
- case OS.kEventRawKeyUp:
- return focus.processEvent(SWT.KeyUp, new MacEvent(eRefHandle, nextHandler));
-
- case OS.kEventRawKeyModifiersChanged:
- MacEvent macEvent = new MacEvent(eRefHandle, nextHandler);
- int modifiers = macEvent.getModifiers();
- int eventType = SWT.KeyUp;
- if ((modifiers & OS.shiftKey) != 0 && (fLastModifiers & OS.shiftKey) == 0) eventType = SWT.KeyDown;
- if ((modifiers & OS.controlKey) != 0 && (fLastModifiers & OS.controlKey) == 0) eventType = SWT.KeyDown;
- if ((modifiers & OS.cmdKey) != 0 && (fLastModifiers & OS.cmdKey) == 0) eventType = SWT.KeyDown;
- if ((modifiers & OS.optionKey) != 0 && (fLastModifiers & OS.optionKey) == 0) eventType = SWT.KeyDown;
- int result = focus.processEvent(eventType, macEvent);
- fLastModifiers = modifiers;
- return result;
- default:
- System.out.println("Display.handleTextCallback: kEventClassKeyboard: unexpected event kind");
- break;
- }
- break;
-
- default:
- System.out.println("Display.handleTextCallback: unexpected event class");
- break;
- }
- return OS.eventNotHandledErr;
- }
-
- private int handleWindowCallback(int nextHandler, int eRefHandle, int whichWindow) {
-
- int eventClass= OS.GetEventClass(eRefHandle);
- int eventKind= OS.GetEventKind(eRefHandle);
-
- switch (eventClass) {
-
- case OS.kEventClassMouse:
- return handleMouseCallback(nextHandler, eRefHandle, whichWindow);
-
- case OS.kEventClassWindow:
- switch (eventKind) {
- case OS.kEventWindowActivated:
- Widget widget = WidgetTable.get(whichWindow);
- if (widget instanceof Shell)
- fMenuRootShell= (Shell) widget;
- windowProc(whichWindow, true);
- break; //return OS.noErr;
-
- case OS.kEventWindowDeactivated:
- fMenuRootShell= null;
- windowProc(whichWindow, false);
- break; // return OS.noErr;
-
- case OS.kEventWindowBoundsChanged:
- int[] attr= new int[1];
- OS.GetEventParameter(eRefHandle, OS.kEventParamAttributes, OS.typeUInt32, null, attr.length*4, null, attr);
- windowProc(whichWindow, SWT.Resize, attr[0]);
- return OS.noErr;
-
- case OS.kEventWindowClose:
- windowProc(whichWindow, SWT.Dispose);
- return OS.noErr;
-
- default:
- System.out.println("handleWindowCallback: kEventClassWindow kind:" + eventKind);
- break;
- }
- break;
-
- default:
- System.out.println("handleWindowCallback: unexpected event class: " + MacUtil.toString(eventClass));
- break;
- }
- return OS.eventNotHandledErr;
- }
-
- private int handleTooltipWindowCallback(int nextHandler, int eRefHandle, int whichWindow) {
-
- int eventClass= OS.GetEventClass(eRefHandle);
- int eventKind= OS.GetEventKind(eRefHandle);
-
- if (eventClass == OS.kEventClassWindow && eventKind == OS.kEventWindowDrawContent) {
- Rect bounds= new Rect();
- OS.GetWindowBounds(whichWindow, (short)OS.kWindowContentRgn, bounds);
- int width= bounds.right - bounds.left;
- int height= bounds.bottom - bounds.top;
- OS.SetRect(bounds, (short)0, (short)0, (short)width, (short)height);
- MacUtil.RGBBackColor(COLOR_INFO_BACKGROUND.handle);
- MacUtil.RGBForeColor(COLOR_INFO_FOREGROUND.handle);
- OS.EraseRect(bounds);
- if (fToolTipText != null) {
- OS.SetRect(bounds, (short)TOOLTIP_MARGIN, (short)TOOLTIP_MARGIN, (short)(width-TOOLTIP_MARGIN), (short)(height-TOOLTIP_MARGIN));
- int sHandle= OS.CFStringCreateWithCharacters(fToolTipText);
- OS.DrawThemeTextBox(sHandle, fHoverThemeFont, OS.kThemeStateActive, true, bounds, (short)0, 0);
- OS.CFRelease(sHandle);
- }
- return OS.noErr;
- }
- return OS.eventNotHandledErr;
- }
-
- private int handleApplicationCallback(int nextHandler, int eRefHandle, int userData) {
-
- int eventClass= OS.GetEventClass(eRefHandle);
- int eventKind= OS.GetEventKind(eRefHandle);
-
- switch (eventClass) {
-
- case OS.kEventClassAppleEvent:
- // check for 'quit' events
- int[] aeclass= new int[1];
- if (OS.GetEventParameter(eRefHandle, OS.kEventParamAEEventClass, OS.typeType, null, aeclass.length*4, null, aeclass) == OS.noErr) {
- // System.out.println("kEventClassAppleEvent: " + MacUtil.toString(aeclass[0]));
- int[] aetype= new int[1];
- if (OS.GetEventParameter(eRefHandle, OS.kEventParamAEEventID, OS.typeType, null, aetype.length*4, null, aetype) == OS.noErr) {
- //System.out.println("kEventParamAEEventID: " + MacUtil.toString(aetype[0]));
- if (aetype[0] == OS.kAEQuitApplication)
- close();
- }
- }
-
- EventRecord eventRecord= new EventRecord();
- OS.ConvertEventRefToEventRecord(eRefHandle, eventRecord);
- OS.AEProcessAppleEvent(eventRecord);
- break;
-
- case OS.kEventClassCommand:
- if (eventKind == OS.kEventProcessCommand) {
- HICommand command= new HICommand();
- OS.GetEventParameter(eRefHandle, OS.kEventParamDirectObject, OS.typeHICommand, null, HICommand.sizeof, null, command);
- if (command.commandID == OS.kAEQuitApplication) {
- close();
- OS.HiliteMenu((short)0); // unhighlight what MenuSelect (or MenuKey) hilited
- return OS.noErr;
- }
- // try to map the MenuRef to a SWT Menu
- Widget w= findWidget (command.menu_menuRef);
- if (w instanceof Menu) {
- Menu menu= (Menu) w;
- menu.handleMenu(command.menu_menuItemIndex);
- OS.HiliteMenu((short)0); // unhighlight what MenuSelect (or MenuKey) hilited
- return OS.noErr;
- }
- OS.HiliteMenu((short)0); // unhighlight what MenuSelect (or MenuKey) hilited
- // we do not return noErr here so that the default handler
- // takes care of special menus like the Combo menu.
- }
- break;
-
- case OS.kEventClassMouse:
- switch (eventKind) {
-
- case OS.kEventMouseDown: // clicks in menu bar
-
- fTrackedControl= 0;
-
- hideToolTip();
-
- MacEvent mEvent= new MacEvent(eRefHandle);
- org.eclipse.swt.internal.carbon.Point where= mEvent.getWhere();
- int[] w= new int[1];
- short part= OS.FindWindow(where, w);
- if (part == OS.inMenuBar) {
- org.eclipse.swt.internal.carbon.Point loc= mEvent.getWhere();
- OS.QDGlobalToLocalPoint(OS.GetWindowPort(w[0]), loc);
- OS.MenuSelect(loc);
- return OS.noErr;
- }
- break;
-
- case OS.kEventMouseDragged:
- case OS.kEventMouseUp:
- case OS.kEventMouseMoved:
- return handleMouseCallback(nextHandler, eRefHandle, 0);
- }
- break;
-
- case SWT_USER_EVENT: // SWT1 user event
- //System.out.println("handleApplicationCallback: user event " + eventKind);
- return OS.noErr;
-
- default:
- System.out.println("handleApplicationCallback: unknown event class" + MacUtil.toString(eventClass));
- break;
- }
- return OS.eventNotHandledErr;
- }
-
- private int handleMouseCallback(int nextHandler, int eRefHandle, int whichWindow) {
-
- int eventClass= OS.GetEventClass(eRefHandle);
- if (eventClass != OS.kEventClassMouse) {
- System.out.println("handleMouseCallback: unexpected event class: " + MacUtil.toString(eventClass));
- return OS.eventNotHandledErr;
- }
-
- int eventKind= OS.GetEventKind(eRefHandle);
-
- if (eventKind == OS.kEventMouseDown) {
- fTrackedControl= 0;
- }
-
- MacEvent me= new MacEvent(eRefHandle);
- org.eclipse.swt.internal.carbon.Point where= me.getWhere();
- lastGlobalMouseXPos= where.h;
- lastGlobalMouseYPos= where.v;
-
- // retrieve window and window part from event
- if (whichWindow == 0) {
- if (fTrackedControl != 0) {
- // in tracking mode: get window from control
- whichWindow= OS.GetControlOwner(fTrackedControl);
- } else {
- int[] w= new int[1];
- OS.FindWindow(where, w);
- whichWindow= w[0];
- if (whichWindow == 0) {
- // try to retrieve window from event
- int rc= OS.GetEventParameter(eRefHandle, OS.kEventParamWindowRef, OS.typeWindowRef, null, 4, null, w);
- if (rc == OS.noErr)
- whichWindow= w[0];
- else {
- // the event is a MouseMoved event:
- }
- }
- }
- }
-
- if (whichWindow == 0) {
- // give up
- return OS.eventNotHandledErr;
- }
-
- MacEvent.trackStateMask(eRefHandle, eventKind);
-
- // determine control under mouse
- short[] cpart= new short[1];
- int whichControl= MacUtil.findControlUnderMouse(whichWindow, me, cpart);
- Widget widget= WidgetTable.get(whichControl);
-
- MacMouseEvent mme= fLastMouseEvent = new MacMouseEvent(me);
-
- switch (eventKind) {
-
- case OS.kEventMouseDown:
-
- Shell shell= null;
- Widget w= findWidget(whichWindow);
- if (w instanceof Shell)
- shell= (Shell) w;
-
- // first click in window -> activation
- if (!OS.IsWindowActive(whichWindow)) {
- if (shell != null && (shell.getStyle() & SWT.ON_TOP) == 0) {
- // let the default handler activate the window
- break;
- }
- }
-
- // whatever we do, we hide the tooltip
- hideToolTip();
-
- // focus handling
- if (shell != null && (shell.getStyle() & SWT.ON_TOP) == 0)
- setMacFocusHandle(whichWindow, whichControl);
-
- if (whichControl != 0) {
-
- // deal with the context menu
- if (widget instanceof Control) {
- Menu cm= ((Control)widget).getMenu(); // is a context menu installed?
- if (cm != null && me.isShowContextualMenuClick()) {
- try {
- fInContextMenu= true;
- // AW: not ready for primetime
- // OS.ContextualMenuSelect(cm.handle, globalPos.getData(), new short[1], new short[1]);
- org.eclipse.swt.internal.carbon.Point pos= me.getWhere();
- OS.PopUpMenuSelect(cm.handle, pos.v, pos.h, (short)1);
- } finally {
- fInContextMenu= false;
- }
- return OS.noErr;
- }
- }
-
- if (cpart[0] == 111) { // a user pane
- if (!(widget instanceof Text))
- fTrackedControl= whichControl; // starts mouse tracking
- windowProc(whichControl, SWT.MouseDown, mme);
- return OS.noErr;
- } else {
- windowProc(whichControl, SWT.MouseDown, mme);
- }
- }
- break;
-
- case OS.kEventMouseDragged:
- if (fTrackedControl != 0) { // continue mouse tracking
- windowProc(fTrackedControl, SWT.MouseMove, mme);
- return OS.noErr;
- }
- break;
-
- case OS.kEventMouseUp:
- if (fTrackedControl != 0) {
- windowProc(fTrackedControl, SWT.MouseUp, mme);
- fTrackedControl= 0; // continue mouse tracking
- return OS.noErr;
- }
- break;
-
- case OS.kEventMouseMoved:
-
- fTrackedControl= 0;
-
- if (fCurrentControl != whichControl) {
-
- if (fCurrentControl != 0) {
- fLastHoverHandle= 0;
- windowProc(fCurrentControl, SWT.MouseExit, mme);
- }
-
- fCurrentControl= whichControl;
-
- if (widget instanceof Control) {
- Control c= (Control) widget;
- if (c.cursor != null)
- c.cursor.install(this);
- else
- setCursor(0);
- } else
- setCursor(0);
-
- windowProc(fCurrentControl, SWT.MouseMove, mme);
-
- if (fCurrentControl != 0) {
- windowProc(fCurrentControl, SWT.MouseEnter, mme);
- }
- return OS.noErr;
-
- } else {
- if (fCurrentControl != 0) {
- windowProc(fCurrentControl, SWT.MouseMove, mme);
- return OS.noErr;
- }
- }
- break;
-
- case OS.kEventMouseWheelMoved:
- if (widget instanceof Composite) {
- ScrollBar sb= ((Composite) widget).getVerticalBar();
- if (sb != null)
- return sb.processWheel(eRefHandle);
- }
- break;
- }
-
- return OS.eventNotHandledErr;
- }
-
- void setMacFocusHandle(int wHandle, int focusHandle) {
-
- Widget w= findWidget(focusHandle);
- if (w == null) {
- int[] parent= new int[1];
- OS.GetSuperControl(focusHandle, parent);
- focusHandle= parent[0];
- w= findWidget(focusHandle);
- if (w == null)
- return;
- }
-
- if (fFocusControl != focusHandle) {
- int oldFocus= fFocusControl;
- fFocusControl= focusHandle;
-
- if (oldFocus != 0)
- windowProc(oldFocus, false);
-
- //fFocusControl= focusHandle;
-
- int[] focusControl= new int[1];
- OS.GetKeyboardFocus(wHandle, focusControl);
- if (focusControl[0] != fFocusControl) {
- OS.SetKeyboardFocus(wHandle, focusHandle, (short)-1);
- //if (rc != OS.noErr)
- // System.out.println("Display.setMacFocusHandle: SetKeyboardFocus " + rc);
- }
-
- if (fFocusControl != 0)
- windowProc(fFocusControl, true);
- }
- }
-
- private void sendUserEvent(int kind) {
- int[] event= new int[1];
- OS.CreateEvent(0, SWT_USER_EVENT, kind, 0.0, OS.kEventAttributeUserEvent, event);
- if (event[0] != 0)
- OS.PostEventToQueue(OS.GetMainEventQueue(), event[0], (short)2);
- }
-
- static MacFont getThemeFont(int themeFontId) {
- byte[] fontName= new byte[256];
- short[] fontSize= new short[1];
- byte[] style= new byte[1];
- OS.GetThemeFont((short)themeFontId, (short)OS.smSystemScript, fontName, fontSize, style);
- return new MacFont(MacUtil.toString(fontName), fontSize[0], style[0]);
- }
-
- void menuIsVisible(boolean menuIsVisible) {
- fMenuIsVisible= menuIsVisible;
- }
-
- public void setCursor(int cursor) {
- if (fCurrentCursor != cursor) {
- fCurrentCursor= cursor;
- if (cursor == 0)
- OS.InitCursor();
- else
- OS.SetCursor(cursor);
- }
- }
-
- private int createCallback(String method, int argCount) {
- Callback cb= new Callback(this, method, argCount);
- if (fCallbacks == null)
- fCallbacks= new ArrayList();
- fCallbacks.add(cb);
- int proc= cb.getAddress();
- if (proc == 0)
- error (SWT.ERROR_NO_MORE_CALLBACKS);
- return proc;
- }
-
- private int testProc (int id, int clientData) {
- System.out.println("testProc");
- return 0;
- }
-
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java
index c4116cdec5..05c41b22dc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ScrollBar.java
@@ -10,77 +10,10 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
-
-/**
- * Instances of this class are selectable user interface
- * objects that represent a range of positive, numeric values.
- * <p>
- * At any given moment, a given scroll bar will have a
- * single <em>selection</em> that is considered to be its
- * value, which is constrained to be within the range of
- * values the scroll bar represents (that is, between its
- * <em>minimum</em> and <em>maximum</em> values).
- * </p><p>
- * Typically, scroll bars will be made up of five areas:
- * <ol>
- * <li>an arrow button for decrementing the value</li>
- * <li>a page decrement area for decrementing the value by a larger amount</li>
- * <li>a <em>thumb</em> for modifying the value by mouse dragging</li>
- * <li>a page increment area for incrementing the value by a larger amount</li>
- * <li>an arrow button for incrementing the value</li>
- * </ol>
- * Based on their style, scroll bars are either <code>HORIZONTAL</code>
- * (which have a left facing button for decrementing the value and a
- * right facing button for incrementing it) or <code>VERTICAL</code>
- * (which have an upward facing button for decrementing the value
- * and a downward facing buttons for incrementing it).
- * </p><p>
- * On some platforms, the size of the scroll bar's thumb can be
- * varied relative to the magnitude of the range of values it
- * represents (that is, relative to the difference between its
- * maximum and minimum values). Typically, this is used to
- * indicate some proportional value such as the ratio of the
- * visible area of a document to the total amount of space that
- * it would take to display it. SWT supports setting the thumb
- * size even if the underlying platform does not, but in this
- * case the appearance of the scroll bar will not change.
- * </p><p>
- * Scroll bars are created by specifying either <code>H_SCROLL</code>,
- * <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>.
- * They are accessed from the <code>Scrollable</code> using
- * <code>getHorizontalBar</code> and <code>getVerticalBar</code>.
- * </p><p>
- * Note: Scroll bars are not Controls. On some platforms, scroll bars
- * that appear as part of some standard controls such as a text or list
- * have no operating system resources and are not children of the control.
- * For this reason, scroll bars are treated specially. To create a control
- * that looks like a scroll bar but has operating system resources, use
- * <code>Slider</code>.
- * </p>
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Selection</dd>
- * </dl>
- * <p>
- * Note: Only one of the styles HORIZONTAL and VERTICAL may be specified.
- * </p><p>
- * IMPORTANT: This class is <em>not</em> intended to be subclassed.
- * </p>
- *
- * @see Slider
- * @see Scrollable
- * @see Scrollable#getHorizontalBar
- * @see Scrollable#getVerticalBar
- */
+
public /*final*/ class ScrollBar extends Widget {
Scrollable parent;
- private int increment= 1;
- private int pageIncrement= 10;
- boolean visible= true;
+ private int increment, pageIncrement;
ScrollBar () {
/* Do Nothing */
@@ -90,38 +23,7 @@ ScrollBar (Scrollable parent, int style) {
this.parent = parent;
createWidget (0);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when the receiver's value changes, by sending
- * it one of the messages defined in the <code>SelectionListener</code>
- * interface.
- * <p>
- * When <code>widgetSelected</code> is called, the event object detail field contains one of the following values:
- * <code>0</code> - for the end of a drag.
- * <code>SWT.DRAG</code>.
- * <code>SWT.HOME</code>.
- * <code>SWT.END</code>.
- * <code>SWT.ARROW_DOWN</code>.
- * <code>SWT.ARROW_UP</code>.
- * <code>SWT.PAGE_DOWN</code>.
- * <code>SWT.PAGE_UP</code>.
- * <code>widgetDefaultSelected</code> is not called.
- * </p>
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #removeSelectionListener
- * @see SelectionEvent
- */
+
public void addSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -129,324 +31,91 @@ public void addSelectionListener(SelectionListener listener) {
addListener(SWT.Selection,typedListener);
addListener(SWT.DefaultSelection,typedListener);
}
+
static int checkStyle (int style) {
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
}
+
void createHandle (int index) {
- state |= HANDLE;
- handle= 0;
- if ((style & SWT.H_SCROLL) != 0) {
- handle= parent.hScrollBar;
- } else if ((style & SWT.V_SCROLL) != 0) {
- handle= parent.vScrollBar;
- }
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
}
-/**
-* Gets the Display.
-*/
+
public Display getDisplay () {
Scrollable parent = this.parent;
if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
return parent.getDisplay ();
}
-/**
- * Returns <code>true</code> if the receiver is enabled, and
- * <code>false</code> otherwise. A disabled control is typically
- * not selectable from the user interface and draws with an
- * inactive or "grayed" look.
- *
- * @return the enabled state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean getEnabled () {
checkWidget();
- return OS.IsControlEnabled(handle);
+ return false;
}
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the up/down (or right/left) arrows
- * are pressed.
- *
- * @return the increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getIncrement () {
checkWidget();
return increment;
}
-/**
- * Returns the maximum value which the receiver will allow.
- *
- * @return the maximum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getMaximum () {
checkWidget();
- return OS.GetControl32BitMaximum(handle) + OS.GetControlViewSize(handle);
+ return 0;
}
-/**
- * Returns the minimum value which the receiver will allow.
- *
- * @return the minimum
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getMinimum () {
checkWidget();
- return OS.GetControl32BitMinimum(handle);
+ return 0;
}
-/**
- * Returns the amount that the receiver's value will be
- * modified by when the page increment/decrement areas
- * are selected.
- *
- * @return the page increment
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getPageIncrement () {
checkWidget();
return pageIncrement;
}
-/**
- * Returns the receiver's parent, which must be scrollable.
- *
- * @return the receiver's parent
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Scrollable getParent () {
checkWidget();
return parent;
}
-/**
- * Returns the single <em>selection</em> that is the receiver's value.
- *
- * @return the selection
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getSelection () {
checkWidget();
- return OS.GetControl32BitValue(handle);
+ return 0;
}
-/**
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Point getSize () {
checkWidget();
- Rect bounds= new Rect();
- OS.GetControlBounds(handle, bounds);
- return new Point(bounds.right-bounds.left, bounds.bottom-bounds.top);
+ return new Point(0, 0);
}
-/**
- * Answers the size of the receiver's thumb relative to the
- * difference between its maximum and minimum values.
- *
- * @return the thumb value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ScrollBar
- */
+
public int getThumb () {
checkWidget();
- return OS.GetControlViewSize(handle);
+ return 0;
}
-/**
- * Returns <code>true</code> if the receiver is visible, and
- * <code>false</code> otherwise.
- * <p>
- * 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.
- * </p>
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public boolean getVisible () {
checkWidget();
- return OS.IsControlVisible(handle);
-}
-/* AW
-void hookEvents () {
- int windowProc = parent.getDisplay ().windowProc;
- OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, SWT.Selection);
- OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, SWT.Selection);
+ return false;
}
-*/
-/**
- * Returns <code>true</code> if the receiver is enabled and all
- * of the receiver's ancestors are enabled, and <code>false</code>
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getEnabled
- */
+
public boolean isEnabled () {
checkWidget();
- return getEnabled () && parent.isEnabled ();
+ return false;
}
-/**
- * Returns <code>true</code> if the receiver is visible and all
- * of the receiver's ancestors are visible and <code>false</code>
- * otherwise.
- *
- * @return the receiver's visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getVisible
- */
+
public boolean isVisible () {
checkWidget();
- return getVisible () && parent.isVisible ();
-}
-/* AW
-void manageChildren () {
- OS.XtManageChild (handle);
+ return false;
}
-*/
-int processSelection (Object callData) {
- MacControlEvent macEvent= (MacControlEvent) callData;
- int partCode= macEvent.getPartCode();
- boolean mouseDown= macEvent.isMouseDown();
-
- if ((partCode != OS.kControlIndicatorPart) && !mouseDown)
- return 0;
-
- Event event= new Event ();
-
- switch (partCode) {
- case OS.kControlUpButtonPart:
- OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - increment);
- event.detail = SWT.ARROW_UP;
- break;
- case OS.kControlPageUpPart:
- OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - pageIncrement);
- event.detail = SWT.PAGE_UP;
- break;
- case OS.kControlPageDownPart:
- OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) + pageIncrement);
- event.detail = SWT.PAGE_DOWN;
- break;
- case OS.kControlDownButtonPart:
- OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) + increment);
- event.detail = SWT.ARROW_DOWN;
- break;
- case OS.kControlIndicatorPart: // end of drag or continuos drag
- if (mouseDown) {
- event.detail = SWT.DRAG; // continuos drag
- } else {
- /*
- * Do not set the detail field to SWT.DRAG
- * to indicate that the dragging has ended.
- */
- }
- break;
- }
-
- sendEvent (SWT.Selection, event);
-
- return OS.noErr;
-}
-int processWheel(int eRefHandle) {
- int[] t= new int[1];
- OS.GetEventParameter(eRefHandle, OS.kEventParamMouseWheelDelta, OS.typeSInt32, null, t.length*4, null, t);
- OS.SetControl32BitValue(handle, OS.GetControl32BitValue(handle) - (increment * t[0]));
- Event event= new Event ();
- event.detail= t[0] > 0 ? SWT.ARROW_UP : SWT.ARROW_DOWN;
- sendEvent (SWT.Selection, event);
- getDisplay().update();
- return OS.noErr;
-}
void releaseChild () {
super.releaseChild ();
if (parent.horizontalBar == this) parent.horizontalBar = null;
if (parent.verticalBar == this) parent.verticalBar = null;
}
+
void releaseWidget () {
super.releaseWidget ();
parent = null;
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when the receiver's value changes.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SelectionListener
- * @see #addSelectionListener
- */
+
public void removeSelectionListener(SelectionListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -454,194 +123,42 @@ public void removeSelectionListener(SelectionListener listener) {
eventTable.unhook(SWT.Selection, listener);
eventTable.unhook(SWT.DefaultSelection,listener);
}
-/**
- * Enables the receiver if the argument is <code>true</code>,
- * 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 <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setEnabled (boolean enabled) {
checkWidget();
- if (enabled)
- OS.EnableControl(handle);
- else
- OS.DisableControl(handle);
}
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the up/down (or right/left) arrows
- * are pressed to the argument, which must be at least
- * one.
- *
- * @param value the new increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setIncrement (int value) {
checkWidget();
if (value < 1) return;
- increment= value;
+
}
-/**
- * Sets the maximum value which the receiver will allow
- * to be the argument which must be greater than or
- * equal to zero.
- *
- * @param value the new maximum (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setMaximum (int value) {
checkWidget();
- if (value < 0) return;
- OS.SetControl32BitMaximum(handle, value-OS.GetControlViewSize(handle));
}
-/**
- * Sets the minimum value which the receiver will allow
- * to be the argument which must be greater than or
- * equal to zero.
- *
- * @param value the new minimum (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setMinimum (int value) {
checkWidget();
- if (value < 0) return;
- OS.SetControl32BitMinimum(handle, value);
}
-/**
- * Sets the amount that the receiver's value will be
- * modified by when the page increment/decrement areas
- * are selected to the argument, which must be at least
- * one.
- *
- * @return the page increment (must be greater than zero)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setPageIncrement (int value) {
checkWidget();
- if (value < 1) return;
- pageIncrement= value;
}
-/**
- * Sets the single <em>selection</em> that is the receiver's
- * value to the argument which must be greater than or equal
- * to zero.
- *
- * @param value the new selection (must be zero or greater)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setSelection (int selection) {
checkWidget();
- if (selection < 0) return;
- OS.SetControl32BitValue(handle, selection);
}
-/**
- * Sets the size of the receiver's thumb relative to the
- * difference between its maximum and minimum values to the
- * argument which must be at least one.
- *
- * @param value the new thumb value (must be at least one)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ScrollBar
- */
+
public void setThumb (int value) {
checkWidget();
- if (value < 1) return;
- int oldMaximum= OS.GetControl32BitMaximum(handle) + OS.GetControlViewSize(handle);
- OS.SetControlViewSize(handle, value);
- OS.SetControl32BitMaximum(handle, oldMaximum-value);
}
-/**
- * Sets the receiver's selection, minimum value, maximum
- * value, thumb, increment and page increment all at once.
- * <p>
- * Note: This is equivalent to setting the values individually
- * using the appropriate methods, but may be implemented in a
- * more efficient fashion on some platforms.
- * </p>
- *
- * @param selection the new selection value
- * @param minimum the new minimum value
- * @param maximum the new maximum value
- * @param thumb the new thumb value
- * @param increment the new increment value
- * @param pageIncrement the new pageIncrement value
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
checkWidget();
- if (selection < 0) return;
- if (minimum < 0) return;
- if (maximum < 0) return;
- if (thumb < 1) return;
- if (maximum - minimum - thumb < 0) return;
- if (increment < 1) return;
- if (pageIncrement < 1) return;
- OS.SetControl32BitMinimum(handle, minimum);
- OS.SetControl32BitMaximum(handle, maximum-thumb);
- OS.SetControlViewSize(handle, thumb);
- OS.SetControl32BitValue(handle, selection);
- this.increment= increment;
- this.pageIncrement= pageIncrement;
}
-/**
- * Marks the receiver as visible if the argument is <code>true</code>,
- * and marks it invisible otherwise.
- * <p>
- * 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.
- * </p>
- *
- * @param visible the new visibility state
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public void setVisible (boolean visible) {
checkWidget();
- if (this.visible != visible) {
- this.visible= visible;
- OS.HIViewSetVisible(handle, visible);
- parent._relayout();
- sendEvent(visible ? SWT.Show : SWT.Hide);
- }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java
index ff0bd6c3f5..e733f40c66 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scrollable.java
@@ -9,22 +9,7 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.carbon.*;
-/**
- * This class is the abstract superclass of all classes which
- * represent controls that have standard scroll bars.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>H_SCROLL, V_SCROLL</dd>
- * <dt><b>Events:</b>
- * <dd>(none)</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * within the SWT implementation.
- * </p>
- */
public abstract class Scrollable extends Control {
int scrolledHandle /* formHandle */;
int hScrollBar, vScrollBar;
@@ -32,250 +17,55 @@ public abstract class Scrollable extends Control {
Scrollable () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#H_SCROLL
- * @see SWT#V_SCROLL
- * @see Widget#checkSubclass
- * @see Widget#getStyle
- */
+
public Scrollable (Composite parent, int style) {
super (parent, style);
}
-/**
- * Given a desired <em>client area</em> for the receiver
- * (as described by the arguments), returns the bounding
- * rectangle which would be required to produce that client
- * area.
- * <p>
- * In other words, it returns a rectangle such that, if the
- * receiver's bounds were set to that rectangle, the area
- * of the receiver which is capable of displaying data
- * (that is, not covered by the "trimmings") would be the
- * rectangle described by the arguments (relative to the
- * receiver's parent).
- * </p>
- *
- * @return the required bounds to produce the given client area
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getClientArea
- */
+
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
- int border = getBorderWidth ();
- int trimX = x - border, trimY = y - border;
- int trimWidth = width + (border * 2), trimHeight = height + (border * 2);
- if (horizontalBar != null) {
- Display display = getDisplay ();
- trimY -= display.scrolledInsetY;
- trimHeight += display.scrolledInsetY + display.scrolledMarginY;
- if (verticalBar == null) {
- trimX -= display.scrolledInsetX;
- trimWidth += display.scrolledInsetX * 2;
- trimHeight -= display.scrolledInsetY * 2;
- }
- }
- if (verticalBar != null) {
- Display display = getDisplay ();
- trimX -= display.scrolledInsetX;
- trimWidth += display.scrolledInsetX + display.scrolledMarginX;
- if (horizontalBar == null) {
- trimY -= display.scrolledInsetY;
- trimHeight += display.scrolledInsetY * 2;
- trimWidth -= display.scrolledInsetX * 2;
- }
- }
- return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+ return new Rectangle (0, 0, 0, 0);
}
+
ScrollBar createScrollBar (int type) {
return new ScrollBar (this, type);
}
-ScrollBar createStandardBar (int style) {
- if (scrolledHandle == 0) return null;
- ScrollBar bar = new ScrollBar ();
- bar.parent = this;
- bar.style = style;
- bar.state |= HANDLE;
- System.out.println("Scrollable.createStandardBar: nyi");
- /* AW
- int [] argList = {OS.XmNhorizontalScrollBar, 0, OS.XmNverticalScrollBar, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- if (style == SWT.H_SCROLL) bar.handle = argList [1];
- if (style == SWT.V_SCROLL) bar.handle = argList [3];
- */
- bar.hookEvents ();
- bar.register ();
- return bar;
-}
+
void createWidget (int index) {
super.createWidget (index);
if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL);
if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
}
+
void deregister () {
super.deregister ();
- /* AW
- if (formHandle != 0) WidgetTable.remove (formHandle);
- */
if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
}
-/* AW
-void enableWidget (boolean enabled) {
- super.enableWidget (enabled);
- if (formHandle != 0) enableHandle (enabled, formHandle);
- if (scrolledHandle != 0) {
- enableHandle (enabled, scrolledHandle);
- int [] argList = {
- OS.XmNhorizontalScrollBar, 0,
- OS.XmNverticalScrollBar, 0,
- };
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- if (argList [1] != 0) enableHandle (enabled, argList [1]);
- if (argList [3] != 0) enableHandle (enabled, argList [3]);
- }
-}
-*/
-/**
- * Returns a rectangle which describes the area of the
- * receiver which is capable of displaying data (that is,
- * not covered by the "trimmings").
- *
- * @return the client area
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #computeTrim
- */
+
public Rectangle getClientArea () {
checkWidget();
- Rect bounds= new Rect();
- OS.GetControlBounds(handle, bounds);
- Rectangle r= new Rectangle (0, 0, bounds.right-bounds.left, bounds.bottom-bounds.top);
- // never return negative values
- if (r.x < 0) r.x= 0;
- if (r.y < 0) r.y= 0;
- if (r.width < 0) r.width= 0;
- if (r.height < 0) r.height= 0;
- return r;
+ return new Rectangle (0, 0, 0, 0);
}
-/**
- * Returns the receiver's horizontal scroll bar if it has
- * one, and null if it does not.
- *
- * @return the horizontal scroll bar (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public ScrollBar getHorizontalBar () {
checkWidget();
return horizontalBar;
}
-/**
- * Returns the receiver's vertical scroll bar if it has
- * one, and null if it does not.
- *
- * @return the vertical scroll bar (or null)
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public ScrollBar getVerticalBar () {
checkWidget();
return verticalBar;
}
-boolean isTabGroup () {
- if ((state & CANVAS) != 0) return true;
- return super.isTabGroup ();
-}
-void manageChildren () {
- /* AW
- if (scrolledHandle != 0) {
- OS.XtSetMappedWhenManaged (scrolledHandle, false);
- OS.XtManageChild (scrolledHandle);
- }
- if (formHandle != 0) {
- OS.XtSetMappedWhenManaged (formHandle, false);
- OS.XtManageChild (formHandle);
- }
- */
- super.manageChildren ();
- /* AW
- if (formHandle != 0) {
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (formHandle, argList, argList.length / 2);
- OS.XtResizeWidget (formHandle, 1, 1, argList [1]);
- OS.XtSetMappedWhenManaged (formHandle, true);
- }
- if (scrolledHandle != 0) {
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- OS.XtResizeWidget (scrolledHandle, 1, 1, argList [1]);
- OS.XtSetMappedWhenManaged (scrolledHandle, true);
- }
- */
-}
-/* AW
-void propagateWidget (boolean enabled) {
- super.propagateWidget (enabled);
- if (formHandle != 0) propagateHandle (enabled, formHandle);
- if (scrolledHandle != 0) {
- propagateHandle (enabled, scrolledHandle);
- int [] argList = {
- OS.XmNhorizontalScrollBar, 0,
- OS.XmNverticalScrollBar, 0,
- };
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- if (argList [1] != 0) propagateHandle (enabled, argList [1]);
- if (argList [3] != 0) propagateHandle (enabled, argList [3]);
- }
-}
-*/
+
void register () {
super.register ();
- /* AW
- if (formHandle != 0) WidgetTable.put (formHandle, this);
- */
if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
}
void releaseHandle () {
super.releaseHandle ();
- scrolledHandle = /* AW formHandle = */ 0;
+ scrolledHandle = 0;
}
+
void releaseWidget () {
if (horizontalBar != null) {
horizontalBar.releaseWidget ();
@@ -288,125 +78,4 @@ void releaseWidget () {
horizontalBar = verticalBar = null;
super.releaseWidget ();
}
-/* AW
-void setBackgroundPixel (int pixel) {
- super.setBackgroundPixel (pixel);
- if (scrolledHandle != 0) {
- int [] argList1 = {
- OS.XmNhorizontalScrollBar, 0,
- OS.XmNverticalScrollBar, 0,
- };
- OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2);
- if (argList1 [1] != 0) OS.XmChangeColor (argList1 [1], pixel);
- if (argList1 [3] != 0) OS.XmChangeColor (argList1 [3], pixel);
- }
-}
-*/
-int topHandle () {
- if (scrolledHandle != 0) return scrolledHandle;
- /* AW
- if (formHandle != 0) return formHandle;
- */
- return handle;
-}
-
-////////////////////////////
-// Mac Stuff
-////////////////////////////
-
- int createScrollView(int parentHandle, int style) {
-
- int features= OS.kControlSupportsEmbedding;
- //features |= OS.kControlSupportsFocus | OS.kControlGetsFocusOnClick
- int controlHandle = OS.NewControl(0, new Rect(), null, false, (short)features, (short)0, (short)0, (short)OS.kControlUserPaneProc, 0);
- MacUtil.insertControl(controlHandle, parentHandle, -1);
- OS.HIViewSetVisible(controlHandle, true);
-
- if ((style & SWT.H_SCROLL) != 0) {
- hScrollBar= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)100, (short)OS.kControlScrollBarLiveProc, 0);
- MacUtil.insertControl(hScrollBar, controlHandle, -1);
- OS.HIViewSetVisible(hScrollBar, true);
- OS.SetControlAction(hScrollBar, getDisplay().fControlActionProc);
- }
-
- if ((style & SWT.V_SCROLL) != 0) {
- vScrollBar= OS.NewControl(0, new Rect(), null, false, (short)0, (short)0, (short)100, (short)OS.kControlScrollBarLiveProc, 0);
- MacUtil.insertControl(vScrollBar, controlHandle, -1);
- OS.HIViewSetVisible(vScrollBar, true);
- OS.SetControlAction(vScrollBar, getDisplay().fControlActionProc);
- }
-
- return controlHandle;
- }
-
- void handleResize(int handle, Rect bounds) {
- super.handleResize(handle, bounds);
- _relayout();
- }
-
- void _relayout() {
-
- if (scrolledHandle == 0)
- return;
-
- Rect bounds= new Rect();
- OS.GetControlBounds(scrolledHandle, bounds);
-
- boolean visible= OS.IsControlVisible(scrolledHandle);
-
- int x= 0;
- int y= 0;
- int w= bounds.right-bounds.left;
- int h= bounds.bottom-bounds.top;
-
- int s= 15;
- int ww= w;
- int hh= h;
- int style= getStyle();
-
- ScrollBar hsb= null;
- if ((style & SWT.H_SCROLL) != 0) {
- hsb= getHorizontalBar();
- if (hsb != null) {
- if (visible && !OS.IsControlVisible(hsb.handle))
- ;
- else
- hh-= s;
- }
- }
-
- ScrollBar vsb= null;
- if ((style & SWT.V_SCROLL) != 0) {
- vsb= getVerticalBar();
- if (vsb != null) {
- if (visible && !OS.IsControlVisible(vsb.handle))
- ;
- else
- ww-= s;
- }
- }
-
- CGRect rect = new CGRect();
- rect.x = x;
- rect.y = y;
- rect.width = ww;
- rect.height = hh;
- OS.HIViewSetFrame(handle, rect);
-
- if (hsb != null) {
- rect.x = x;
- rect.y = y+h-s;
- rect.width = ww;
- rect.height = s;
- OS.HIViewSetFrame(hsb.handle, rect);
- }
-
- if (vsb != null) {
- rect.x = x+w-s;
- rect.y = y;
- rect.width = s;
- rect.height = hh;
- OS.HIViewSetFrame(vsb.handle, rect);
- }
- }
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java
index 2cb7fa520c..16a2e4422f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java
@@ -11,223 +11,27 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.internal.carbon.OS;
-import org.eclipse.swt.internal.carbon.Rect;
-/**
- * Instances of this class represent the "windows"
- * which the desktop or "window manager" is managing.
- * Instances that do not have a parent (that is, they
- * are built using the constructor, which takes a
- * <code>Display</code> as the argument) are described
- * as <em>top level</em> shells. Instances that do have
- * a parent are described as <em>secondary</em> or
- * <em>dialog</em> shells.
- * <p>
- * Instances are always displayed in one of the maximized,
- * minimized or normal states:
- * <ul>
- * <li>
- * When an instance is marked as <em>maximized</em>, the
- * window manager will typically resize it to fill the
- * entire visible area of the display, and the instance
- * is usually put in a state where it can not be resized
- * (even if it has style <code>RESIZE</code>) until it is
- * no longer maximized.
- * </li><li>
- * When an instance is in the <em>normal</em> state (neither
- * maximized or minimized), its appearance is controlled by
- * the style constants which were specified when it was created
- * and the restrictions of the window manager (see below).
- * </li><li>
- * When an instance has been marked as <em>minimized</em>,
- * its contents (client area) will usually not be visible,
- * and depending on the window manager, it may be
- * "iconified" (that is, replaced on the desktop by a small
- * simplified representation of itself), relocated to a
- * distinguished area of the screen, or hidden. Combinations
- * of these changes are also possible.
- * </li>
- * </ul>
- * </p>
- * <p>
- * Note: The styles supported by this class must be treated
- * as <em>HINT</em>s, since the window manager for the
- * desktop on which the instance is visible has ultimate
- * control over the appearance and behavior of decorations
- * and modality. For example, some window managers only
- * support resizable windows and will always assume the
- * RESIZE style, even if it is not set. In addition, if a
- * modality style is not supported, it is "upgraded" to a
- * more restrictive modality style that is supported. For
- * example, if <code>PRIMARY_MODAL</code> is not supported,
- * it would be upgraded to <code>APPLICATION_MODAL</code>.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>BORDER, CLOSE, MIN, MAX, NO_TRIM, RESIZE, TITLE</dd>
- * <dd>APPLICATION_MODAL, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Activate, Close, Deactivate, Deiconify, Iconify</dd>
- * </dl>
- * Class <code>SWT</code> provides two "convenience constants"
- * for the most commonly required style combinations:
- * <dl>
- * <dt><code>SHELL_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application top level shell: (that
- * is, <code>CLOSE | TITLE | MIN | MAX | RESIZE</code>)
- * </dd>
- * <dt><code>DIALOG_TRIM</code></dt>
- * <dd>
- * the result of combining the constants which are required
- * to produce a typical application dialog shell: (that
- * is, <code>TITLE | CLOSE | BORDER</code>)
- * </dd>
- * </dl>
- * </p>
- * <p>
- * Note: Only one of the styles APPLICATION_MODAL, MODELESS,
- * PRIMARY_MODAL and SYSTEM_MODAL may be specified.
- * </p><p>
- * IMPORTANT: This class is not intended to be subclassed.
- * </p>
- *
- * @see Decorations
- * @see SWT
- */
public /*final*/ class Shell extends Decorations {
Display display;
int shellHandle;
- /* AW
- boolean reparented, realized;
- */
- boolean realized;
-
- int oldX, oldY, oldWidth, oldHeight;
- Control lastActive;
- // AW
- private boolean fIsEnabled= true;
- // AW
-/**
- * Constructs a new instance of this class. This is equivalent
- * to calling <code>Shell((Display) null)</code>.
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
public Shell () {
this ((Display) null);
}
-/**
- * Constructs a new instance of this class given only the style
- * value describing its behavior and appearance. This is equivalent
- * to calling <code>Shell((Display) null, style)</code>.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- */
+
public Shell (int style) {
this ((Display) null, style);
}
-/**
- * Constructs a new instance of this class given only the display
- * to create it on. It is created with style <code>SWT.SHELL_TRIM</code>.
- * <p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
+
public Shell (Display display) {
this (display, SWT.SHELL_TRIM);
}
-/**
- * Constructs a new instance of this class given the display
- * to create it on and a style value describing its behavior
- * and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the display argument.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the display argument is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param display the display to create the shell on
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- */
+
public Shell (Display display, int style) {
this (display, null, style, 0);
}
+
Shell (Display display, Shell parent, int style, int handle) {
super ();
@@ -242,73 +46,11 @@ Shell (Display display, Shell parent, int style, int handle) {
this.handle = handle;
createWidget (0);
}
-/**
- * Constructs a new instance of this class given only its
- * parent. It is created with style <code>SWT.DIALOG_TRIM</code>.
- * <p>
- * Note: Currently, null can be passed in for the parent.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the parent is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
+
public Shell (Shell parent) {
this (parent, SWT.DIALOG_TRIM);
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p><p>
- * Note: Currently, null can be passed in for the parent.
- * This has the effect of creating the shell on the currently active
- * display if there is one. If there is no current display, the
- * shell is created on a "default" display. <b>Passing in null as
- * the parent is not considered to be good coding style,
- * and may not be supported in a future release of SWT.</b>
- * </p>
- *
- * @param parent a shell which will be the parent of the new instance
- * @param style the style of control to construct
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT#BORDER
- * @see SWT#CLOSE
- * @see SWT#MIN
- * @see SWT#MAX
- * @see SWT#RESIZE
- * @see SWT#TITLE
- * @see SWT#NO_TRIM
- * @see SWT#SHELL_TRIM
- * @see SWT#DIALOG_TRIM
- * @see SWT#MODELESS
- * @see SWT#PRIMARY_MODAL
- * @see SWT#APPLICATION_MODAL
- * @see SWT#SYSTEM_MODAL
- */
+
public Shell (Shell parent, int style) {
this (parent != null ? parent.getDisplay () : null, parent, style, 0);
}
@@ -322,30 +64,7 @@ static int checkStyle (int style) {
if ((style & SWT.PRIMARY_MODAL) != 0) return bits | SWT.PRIMARY_MODAL;
return bits;
}
-/* AW
-public static Shell carbon_new (Display display, int handle) {
- return new Shell (display, null, SWT.NO_TRIM, handle);
-}
-*/
-/**
- * Adds the listener to the collection of listeners who will
- * be notified when operations are performed on the receiver,
- * by sending the listener one of the messages defined in the
- * <code>ShellListener</code> interface.
- *
- * @param listener the listener which should be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ShellListener
- * @see #removeShellListener
- */
+
public void addShellListener(ShellListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -356,466 +75,56 @@ public void addShellListener(ShellListener listener) {
addListener(SWT.Iconify,typedListener);
addListener(SWT.Deiconify,typedListener);
}
-void adjustTrim () {
- /* AW
- if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) {
- return;
- }
- */
-
- /* Query the trim insets */
- /* AW
- int shellWindow = OS.XtWindow (shellHandle);
- if (shellWindow == 0) return;
- int xDisplay = OS.XtDisplay (shellHandle);
- if (xDisplay == 0) return;
- */
-
- /* Find the direct child of the root window */
- /* AW
- int [] unused = new int [1];
- int [] rootWindow = new int [1];
- int [] parent = new int [1];
- int [] ptr = new int [1];
- int trimWindow = shellWindow;
- OS.XQueryTree (xDisplay, trimWindow, rootWindow, parent, ptr, unused);
- if (ptr [0] != 0) OS.XFree (ptr [0]);
- if (parent [0] == 0) return;
- while (parent [0] != rootWindow [0]) {
- trimWindow = parent [0];
- OS.XQueryTree (xDisplay, trimWindow, unused, parent, ptr, unused);
- if (ptr [0] != 0) OS.XFree (ptr [0]);
- if (parent [0] == 0) return;
- }
- */
-
- /*
- * Translate the coordinates of the shell window to the
- * coordinates of the direct child of the root window
- */
- /* AW
- if (shellWindow == trimWindow) return;
- */
-
- /* Query the border width of the direct child of the root window */
- /*
- int [] trimBorder = new int [1];
- int [] trimWidth = new int [1];
- int [] trimHeight = new int [1];
- OS.XGetGeometry (xDisplay, trimWindow, unused, unused, unused, trimWidth, trimHeight, trimBorder, unused);
- */
- /* Query the border width of the direct child of the shell window */
- /*
- int [] shellBorder = new int [1];
- int [] shellWidth = new int [1];
- int [] shellHeight = new int [1];
- OS.XGetGeometry (xDisplay, shellWindow, unused, unused, unused, shellWidth, shellHeight, shellBorder, unused);
- */
-
- /* Calculate the trim */
- /*
- int width = (trimWidth [0] + (trimBorder [0] * 2)) - (shellWidth [0] + (shellBorder [0] * 2));
- int height = (trimHeight [0] + (trimBorder [0] * 2)) - (shellHeight [0] + (shellBorder [0] * 2));
- */
-
- /* Update the trim guesses to match the query */
- /*
- boolean hasTitle = false, hasResize = false, hasBorder = false;
- if ((style & SWT.NO_TRIM) == 0) {
- hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
- hasResize = (style & SWT.RESIZE) != 0;
- hasBorder = (style & SWT.BORDER) != 0;
- }
- if (hasTitle) {
- if (hasResize) {
- display.titleResizeTrimWidth = width;
- display.titleResizeTrimHeight = height;
- return;
- }
- if (hasBorder) {
- display.titleBorderTrimWidth = width;
- display.titleBorderTrimHeight = height;
- return;
- }
- display.titleTrimWidth = width;
- display.titleTrimHeight = height;
- return;
- }
- if (hasResize) {
- display.resizeTrimWidth = width;
- display.resizeTrimHeight = height;
- return;
- }
- if (hasBorder) {
- display.borderTrimWidth = width;
- display.borderTrimHeight = height;
- return;
- }
- */
-}
-/**
- * Requests that the window manager close the receiver in
- * the same way it would be closed when the user clicks on
- * the "close box" or performs some other platform specific
- * key or mouse combination that indicates the window
- * should be removed.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #dispose
- */
public void close () {
checkWidget();
- closeWidget ();
-}
-void closeWidget () {
- //System.out.println("Shell.closeWidget: nyi");
- if (!isEnabled ()) return;
- Control widget = parent;
- while (widget != null && !(widget.getShell ().isModal ())) {
- widget = widget.parent;
- }
- if (widget == null) {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (shell != this && shell.isModal () && shell.isVisible ()) {
- shell.bringToTop ();
- return;
- }
- }
- }
- Event event = new Event ();
- sendEvent (SWT.Close, event);
- if (event.doit && !isDisposed ()) dispose ();
-}
-public Rectangle computeTrim (int x, int y, int width, int height) {
- checkWidget();
- Rectangle trim = super.computeTrim (x, y, width, height);
- int trimWidth = trimWidth (), trimHeight = trimHeight ();
- trim.x -= trimWidth / 2; trim.y -= trimHeight - (trimWidth / 2);
- trim.width += trimWidth; trim.height += trimHeight + imeHeight ();
- return trim;
}
+
void createHandle (int index) {
state |= HANDLE | CANVAS;
-
- int windowActivationScope= -1;
-
- int decorations = OS.kWindowCompositingAttribute | OS.kWindowStandardHandlerAttribute;
-
- /* AW
- if ((style & SWT.NO_TRIM) == 0) {
- if ((style & SWT.MIN) != 0) decorations |= NSWindow.MiniaturizableWindowMask;
- if ((style & SWT.MAX) != 0) decorations |= OS.MWM_DECOR_MAXIMIZE;
- if ((style & SWT.RESIZE) != 0) decorations |= NSWindow.ResizableWindowMask;
- if ((style & SWT.BORDER) != 0) decorations |= NSWindow.BorderlessWindowMask;
- if ((style & SWT.MENU) != 0) decorations |= OS.MWM_DECOR_MENU;
- if ((style & SWT.TITLE) != 0) decorations |= NSWindow.TitledWindowMask;
- }
- */
-
- if (style == SWT.NONE) {
- } else if ((style & SWT.NO_TRIM) == 0) {
- if ((style & SWT.CLOSE) != 0) decorations |= OS.kWindowCloseBoxAttribute;
- if ((style & SWT.MIN) != 0) decorations |= OS.kWindowCollapseBoxAttribute;
- if ((style & SWT.MAX) != 0) decorations |= OS.kWindowFullZoomAttribute;
- if ((style & SWT.RESIZE) != 0) decorations |= OS.kWindowResizableAttribute;
- }
-
- // if resizable enable 'live resize'
- if ((decorations & OS.kWindowResizableAttribute) != 0)
- decorations |= OS.kWindowLiveResizeAttribute;
-
- // determine modality
- int inputMode = OS.kWindowModalityNone;
- if ((style & SWT.PRIMARY_MODAL) != 0) inputMode = OS.kWindowModalityWindowModal;
- if ((style & SWT.APPLICATION_MODAL) != 0) inputMode = OS.kWindowModalityAppModal;
- if ((style & SWT.SYSTEM_MODAL) != 0) inputMode = OS.kWindowModalitySystemModal;
-
- /* AW
- int [] argList1 = {
- OS.XmNmwmInputMode, inputMode,
- OS.XmNmwmDecorations, decorations,
- OS.XmNoverrideRedirect, (style & SWT.ON_TOP) != 0 ? 1 : 0,
- OS.XmNtitle, ptr,
- };
- */
-
- int windowClass= 0;
- int themeBrush= OS.kThemeBrushDialogBackgroundActive;
- if (parent == null && (style & SWT.ON_TOP) == 0) {
- if ((style & SWT.NO_TRIM) != 0) {
- windowClass= OS.kSheetWindowClass;
- windowActivationScope= OS.kWindowActivationScopeNone;
- } else {
- windowClass= OS.kDocumentWindowClass;
- //themeBrush= OS.kThemeBrushDocumentWindowBackground;
- }
- } else {
- /* AW
- int parentHandle = display.shellHandle;
- if (parent != null) parentHandle = parent.handle;
- shellHandle = OS.XtCreatePopupShell (appClass, widgetClass, parentHandle, argList1, argList1.length / 2);
- */
- if (style == SWT.NONE) {
- windowClass= OS.kSheetWindowClass;
- windowActivationScope= OS.kWindowActivationScopeNone;
- } else if ((style & SWT.NO_TRIM) != 0 && (style & SWT.ON_TOP) != 0) {
- windowClass= OS.kSheetWindowClass;
- windowActivationScope= OS.kWindowActivationScopeNone;
- } else if ((style & SWT.NO_TRIM) != 0) {
- windowClass= OS.kSheetWindowClass;
- windowActivationScope= OS.kWindowActivationScopeNone;
- } else if (inputMode == OS.kWindowModalityAppModal) {
- windowClass= OS.kMovableModalWindowClass;
- } else if (inputMode == OS.kWindowModalitySystemModal) {
- windowClass= OS.kModalWindowClass;
- } else if ((style & SWT.ON_TOP) != 0) {
- windowClass= OS.kSheetWindowClass;
- windowActivationScope= OS.kWindowActivationScopeNone;
- decorations= 0;
- } else {
- windowClass= OS.kDocumentWindowClass;
- }
- }
-
- // check whether window class supports a given decoration
- int allowedAttr= OS.GetAvailableWindowAttributes(windowClass);
- if (decorations != (decorations & allowedAttr)) {
- System.out.println("Shell.createHandle: some attributes are not supported");
- decorations&= allowedAttr;
- }
-
- int[] wHandle= new int[1];
- Rect bounds= new Rect();
- OS.SetRect(bounds, (short)100, (short)100, (short)200, (short)200);
- int rc= OS.CreateNewWindow(windowClass, decorations, bounds, wHandle);
- if (rc != OS.noErr)
- System.out.println("Shell.createHandle: can't create window: " + rc);
- shellHandle= wHandle[0];
- if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
-
- if (windowActivationScope != -1)
- if (OS.SetWindowActivationScope(shellHandle, windowActivationScope) != OS.noErr)
- System.out.println("Shell.createHandle: can't set activation scope");
-
- if (themeBrush != 0)
- OS.SetThemeWindowBackground(shellHandle, (short)themeBrush, false);
-
- // set modality
- if (inputMode != OS.kWindowModalityNone) {
- int parentShellHandle= 0;
- if (parent != null) parentShellHandle = parent.handle;
- //System.out.println("Shell.createHandle: OS.SetWindowModality: " + inputMode);
- OS.SetWindowModality(shellHandle, inputMode, parentShellHandle);
- }
-
- /* Create scrolled handle */
- createScrolledHandle (shellHandle);
}
void deregister () {
super.deregister ();
WidgetTable.remove (shellHandle);
}
-void destroyWidget () {
- /*
- * Hide the shell before calling XtDestroyWidget ()
- * so that the shell will disappear without having
- * to dispatch events. Otherwise, the user will be
- * able to interact with the trimmings between the
- * time that the shell is destroyed and the next
- * event is dispatched.
- */
- /* AW
- if (OS.XtIsRealized (shellHandle)) {
- if (OS.XtIsTopLevelShell (shellHandle)) {
- OS.XtUnmapWidget (shellHandle);
- } else {
- OS.XtPopdown (shellHandle);
- }
- }
- */
- OS.HideWindow(shellHandle);
- super.destroyWidget ();
-}
public void dispose () {
- /*
- * Note: It is valid to attempt to dispose a widget
- * more than once. If this happens, fail silently.
- */
if (isDisposed()) return;
-
- /*
- * This code is intentionally commented. On some
- * platforms, the owner window is repainted right
- * away when the dialog window exits. This behavior
- * is currently unspecified.
- */
-// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
-// Display oldDisplay = display;
-
- /*
- * Feature in Motif. When an override-redirected shell
- * is disposed, Motif does not assign a new active top
- * level shell. The parent shell appears to be active,
- * but XGetInputFocus returns the root window, not the
- * parent. The fix is to make the parent be the active
- * top level shell when the child shell is disposed.
- */
- /* AW
- Composite parent = this.parent;
- int [] argList = {OS.XmNoverrideRedirect, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- */
super.dispose ();
- /* AW
- if (parent != null && argList [1] != 0) {
- Shell shell = parent.getShell ();
- shell.bringToTop ();
- }
- */
-
- /*
- * This code intentionally commented.
- */
-// if (oldDisplay != null) oldDisplay.update ();
-}
-void enableWidget (boolean enabled) {
- super.enableWidget (enabled);
- enableHandle (enabled, shellHandle);
}
-/**
- * Moves the receiver to the top of the drawing order for
- * the display on which it was created (so that all other
- * shells on that display, which are not the receiver's
- * children will be drawn behind it) and forces the window
- * manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @since 2.0
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#open
- * @see Shell#setActive
- */
+
public void forceActive () {
checkWidget ();
- OS.SelectWindow(shellHandle);
}
+
public int getBorderWidth () {
checkWidget();
- /* AW
- int [] argList = {OS.XmNborderWidth, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- return argList [1];
- */
return 0;
}
public Rectangle getBounds () {
checkWidget();
- /* AW
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- int border = argList [5];
- */
-
- Rect contentBounds= new Rect();
- OS.GetWindowBounds(shellHandle, (short)OS.kWindowContentRgn, contentBounds);
-
- Rect bounds= new Rect();
- OS.GetControlBounds(scrolledHandle, bounds);
- int trimWidth = trimWidth (), trimHeight = trimHeight ();
- int border= 0;
- /* AW
- int width = argList [1] + trimWidth + (border * 2);
- int height = argList [3] + trimHeight + (border * 2);
- return new Rectangle (root_x [0], root_y [0], width, height);
- */
- int width = bounds.right - bounds.left + trimWidth + (border * 2);
- int height = bounds.bottom - bounds.top + trimHeight + (border * 2);
- Rectangle r= new Rectangle (contentBounds.left, contentBounds.top, width, height);
- return r;
-
- /*
- OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, bounds.getData());
- Rectangle r= bounds.toRectangle();
- System.out.println("Shell.getBounds: fixme " + r); // should be the contentView
- return r;
- */
+ return new Rectangle (0, 0, 0, 0);
}
public Display getDisplay () {
if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
return display;
}
-// AW
+
public boolean getEnabled () {
checkWidget();
- return fIsEnabled;
-}
-// AW
-/**
- * Returns the receiver's input method editor mode. This
- * will be the result of bitwise OR'ing together one or
- * more of the following constants defined in class
- * <code>SWT</code>:
- * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
- * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
- *
- * @return the IME mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
-public int getImeInputMode () {
- checkWidget();
- return SWT.NONE;
+ return false;
}
+
public Point getLocation () {
checkWidget();
- /* AW
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
- return new Point (root_x [0], root_y [0]);
- */
- // returns the location of the contentArea
- Rect bounds= new Rect();
- OS.GetWindowBounds(shellHandle, (short)OS.kWindowContentRgn, bounds);
- return new Point(bounds.left, bounds.top);
+ return new Point(0, 0);
}
+
public Shell getShell () {
checkWidget();
return this;
}
-/**
- * Returns an array containing all shells which are
- * descendents of the receiver.
- * <p>
- * @return the dialog shells
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public Shell [] getShells () {
checkWidget();
int count = 0;
@@ -842,347 +151,28 @@ public Shell [] getShells () {
}
public Point getSize () {
checkWidget();
- //System.out.println("Shell.getSize: " + shellHandle);
- /* AW
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- int border = argList [5];
- */
- Rect bounds= new Rect();
- OS.GetControlBounds(scrolledHandle, bounds);
- int trimWidth = trimWidth (), trimHeight = trimHeight ();
- int border = 0;
- /* AW
- int width = argList [1] + trimWidth + (border * 2);
- int height = argList [3] + trimHeight + (border * 2);
- return new Point (width, height);
- */
- int width = bounds.right - bounds.left + trimWidth + (border * 2);
- int height = bounds.bottom - bounds.top + trimHeight + (border * 2);
- Point p= new Point (width, height);
- //System.out.println(" Shell.getSize: " + p);
- return p;
+ return new Point (0, 0);
}
+
public boolean getVisible () {
checkWidget();
- /* AW
- if (!OS.XtIsRealized (handle)) return false;
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay == 0) return false;
- int xWindow = OS.XtWindow (handle);
- if (xWindow == 0) return false;
- XWindowAttributes attributes = new XWindowAttributes ();
- OS.XGetWindowAttributes (xDisplay, xWindow, attributes);
- if (attributes.map_state == OS.IsViewable) return true;
- int [] argList = {OS.XmNmappedWhenManaged, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- return minimized && attributes.map_state == OS.IsUnviewable && argList [1] != 0;
- */
- return OS.IsWindowVisible(shellHandle);
-}
-void hookEvents () {
- super.hookEvents ();
- /* AW
- int windowProc = display.windowProc;
- OS.XtAddEventHandler (shellHandle, OS.StructureNotifyMask, false, windowProc, SWT.Resize);
- if (OS.XtIsSubclass (shellHandle, OS.OverrideShellWidgetClass ())) return;
- OS.XtAddEventHandler (shellHandle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn);
- int [] argList = {OS.XmNdeleteResponse, OS.XmDO_NOTHING};
- OS.XtSetValues (shellHandle, argList, argList.length / 2);
- int xDisplay = OS.XtDisplay (shellHandle);
- if (xDisplay != 0) {
- int atom = OS.XmInternAtom (xDisplay, WM_DELETE_WINDOW, false);
- OS.XmAddWMProtocolCallback (shellHandle, atom, windowProc, SWT.Dispose);
- }
- */
- Display display= getDisplay();
- int ref= OS.GetWindowEventTarget(shellHandle);
- int[] mask= new int[] {
- OS.kEventClassWindow, OS.kEventWindowActivated,
- OS.kEventClassWindow, OS.kEventWindowDeactivated,
- OS.kEventClassWindow, OS.kEventWindowBoundsChanged,
- OS.kEventClassWindow, OS.kEventWindowClose,
- // the window only tracks the down and mouse wheel events;
- // up, dragged, and move events are handled by the application because
- // we need to get these events even if the mouse is outside of the window.
- OS.kEventClassMouse, OS.kEventMouseDown,
- OS.kEventClassMouse, OS.kEventMouseWheelMoved,
- };
- OS.InstallEventHandler(ref, display.fWindowProc, mask.length / 2, mask, shellHandle, null);
-}
-int imeHeight () {
- /* AW
- if (!IsDBLocale) return 0;
-// realizeWidget ();
- int [] argList1 = {OS.XmNheight, 0};
- OS.XtGetValues (shellHandle, argList1, argList1.length / 2);
- int [] argList2 = {OS.XmNheight, 0};
- OS.XtGetValues (scrolledHandle, argList2, argList2.length / 2);
- return argList1 [1] - argList2 [];
- */
- return 0;
+ return false;
}
+
public boolean isEnabled () {
checkWidget();
return getEnabled ();
}
-boolean isModal () {
- checkWidget();
- /* AW
- int [] argList = {OS.XmNmwmInputMode, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- return (argList [1] != -1 && argList [1] != OS.MWM_INPUT_MODELESS);
- */
- int[] modalityKind= new int[1];
- if (OS.GetWindowModality(shellHandle, modalityKind, null) == OS.noErr)
- return modalityKind[0] != OS.kWindowModalityNone;
- return false;
-}
+
public boolean isVisible () {
checkWidget();
return getVisible ();
}
-void manageChildren () {
- /* AW
- OS.XtSetMappedWhenManaged (shellHandle, false);
- */
- super.manageChildren ();
- Rect bounds= new Rect();
- OS.GetAvailableWindowPositioningBounds(OS.GetMainDevice(), bounds);
- int width = (bounds.right - bounds.left) * 5 / 8;
- int height = (bounds.bottom - bounds.top) * 5 / 8;
- OS.SizeWindow(shellHandle, (short)width, (short)height, true);
-}
-/**
- * Moves the receiver to the top of the drawing order for
- * the display on which it was created (so that all other
- * shells on that display, which are not the receiver's
- * children will be drawn behind it), marks it visible,
- * and sets focus to its default button (if it has one)
- * and asks the window manager to make the shell active.
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Control#moveAbove
- * @see Control#setFocus
- * @see Control#setVisible
- * @see Display#getActiveShell
- * @see Decorations#setDefaultButton
- * @see Shell#setActive
- * @see Shell#forceActive
- */
+
public void open () {
checkWidget();
- setVisible (true);
}
-int processDispose (Object callData) {
- closeWidget ();
- return 0;
-}
-
-int processResize (Object callData) {
-
- Rect bounds= new Rect();
- // outside bounds and location
- OS.GetWindowBounds(shellHandle, (short)OS.kWindowStructureRgn, bounds);
- int x= bounds.left;
- int y= bounds.top;
-
- // inside bounds and location
- OS.GetWindowBounds(shellHandle, (short)OS.kWindowContentRgn, bounds);
- int w= bounds.right - bounds.left;
- int h= bounds.bottom - bounds.top;
-
- boolean positionChanged= (oldX != x || oldY != y);
- boolean sizeChanged= (oldWidth != w || oldHeight != h);
-
- if (scrolledHandle != 0 && sizeChanged) {
- OS.SetRect(bounds, (short)0, (short)0, (short)w, (short)h);
- handleResize(scrolledHandle, bounds);
- }
-
- if (positionChanged) {
- //System.out.println("Shell.send: SWT.Move");
- sendEvent(SWT.Move);
- }
-
- if (sizeChanged) {
- //System.out.println("Shell.send: SWT.Resize");
- sendEvent (SWT.Resize);
- if (layout != null)
- layout (false);
- }
-
- if (!OS.IsWindowVisible(shellHandle))
- return 0;
-
-
- if (x != 0) oldX = x;
- if (y != 0) oldY = y;
- oldWidth = w;
- oldHeight = h;
-
- /* AW
- XConfigureEvent xEvent = new XConfigureEvent ();
- OS.memmove (xEvent, callData, XConfigureEvent.sizeof);
- switch (xEvent.type) {
- case OS.ReparentNotify: {
- if (reparented) return 0;
- reparented = true;
- short [] root_x = new short [1], root_y = new short [1];
- OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
- int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
- OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
- xEvent.x = root_x [0]; xEvent.y = root_y [0];
- xEvent.width = argList [1]; xEvent.height = argList [3];
- // fall through
- }
- case OS.ConfigureNotify:
- if (!reparented) return 0;
- if (oldX != xEvent.x || oldY != xEvent.y) sendEvent (SWT.Move);
- if (oldWidth != xEvent.width || oldHeight != xEvent.height) {
- sendEvent (SWT.Resize);
- if (layout != null) layout (false);
- }
- if (xEvent.x != 0) oldX = xEvent.x;
- if (xEvent.y != 0) oldY = xEvent.y;
- oldWidth = xEvent.width;
- oldHeight = xEvent.height;
- return 0;
- case OS.UnmapNotify:
- int [] argList = {OS.XmNmappedWhenManaged, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- if (argList [1] != 0) {
- minimized = true;
- sendEvent (SWT.Iconify);
- }
- return 0;
- case OS.MapNotify:
- if (minimized) {
- minimized = false;
- sendEvent (SWT.Deiconify);
- }
- return 0;
- }
- */
- return 0;
-}
-
-int processSetFocus (Object callData) {
- /* AW
- XFocusChangeEvent xEvent = new XFocusChangeEvent ();
- OS.memmove (xEvent, callData, XFocusChangeEvent.sizeof);
- int handle = OS.XtWindowToWidget (xEvent.display, xEvent.window);
- */
- int handle = shellHandle; // AW FIXME fake
- if (handle != shellHandle) return super.processSetFocus (callData);
-
- /* AW
- if (xEvent.mode != OS.NotifyNormal) return 0;
- if (xEvent.detail != OS.NotifyNonlinear) return 0;
- switch (xEvent.type) {
- case OS.FocusIn:
- postEvent (SWT.Activate);
- break;
- case OS.FocusOut:
- postEvent (SWT.Deactivate);
- break;
- }
- */
-
- Menu menuBar= getMenuBar();
- Boolean b= (Boolean) callData;
-
- /*
- if (OS.IsWindowActive(shellHandle) != b.booleanValue()) {
- System.out.println("Shell.processSetFocus: " + b);
- return 0;
- }
- */
-
- if (b.booleanValue()) {
- if (menuBar != null) {
- OS.SetRootMenu(menuBar.handle);
- }
- postEvent (SWT.Activate);
- /*
- if (!isDisposed())
- restoreFocus ();
- */
- } else {
- //if (menuBar != null)
- // OS.ReleaseMenu(menuBar.handle);
-
- /*
- setActiveControl (null);
-
- if (isDisposed()) return 0;
- */
- postEvent (SWT.Deactivate);
- /*
- if (!isDisposed())
- saveFocus ();
- */
- }
- return 0;
-}
-void propagateWidget (boolean enabled) {
- super.propagateWidget (enabled);
- propagateHandle (enabled, shellHandle);
-}
-void realizeWidget () {
- if (realized) return;
- /* AW
- OS.XtRealizeWidget (shellHandle);
- */
- realizeChildren ();
- realized = true;
-}
-void register () {
- super.register ();
- WidgetTable.put (shellHandle, this);
-}
-void releaseHandle () {
- super.releaseHandle ();
- shellHandle = 0;
-}
-void releaseShells () {
- Shell [] shells = getShells ();
- for (int i=0; i<shells.length; i++) {
- Shell shell = shells [i];
- if (!shell.isDisposed ()) {
- shell.releaseWidget ();
- shell.releaseHandle ();
- }
- }
-}
-void releaseWidget () {
- releaseShells ();
- super.releaseWidget ();
- display = null;
- lastActive = null;
-}
-/**
- * Removes the listener from the collection of listeners who will
- * be notified when operations are performed on the receiver.
- *
- * @param listener the listener which should no longer be notified
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see ShellListener
- * @see #addShellListener
- */
public void removeShellListener(ShellListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -1193,283 +183,26 @@ public void removeShellListener(ShellListener listener) {
eventTable.unhook(SWT.Iconify,listener);
eventTable.unhook(SWT.Deiconify,listener);
}
-void saveBounds () {
-/*
- MacRect bounds= new MacRect();
-
- // outside bounds and location
- OS.GetWindowBounds(shellHandle, OS.kWindowStructureRgn, bounds.getData());
- oldX = bounds.getX();
- oldY = bounds.getY();
-
- // inside bounds and location
- OS.GetWindowBounds(shellHandle, OS.kWindowContentRgn, bounds.getData());
- oldWidth = bounds.getWidth();
- oldHeight = bounds.getHeight();
-*/
-}
-
-void setActiveControl (Control control) {
- if (control != null && control.isDisposed ()) control = null;
- if (lastActive != null && lastActive.isDisposed ()) lastActive = null;
- if (lastActive == control) return;
-
- /*
- * Compute the list of controls to be activated and
- * deactivated by finding the first common parent
- * control.
- */
- Control [] activate = (control == null) ? new Control[0] : control.getPath ();
- Control [] deactivate = (lastActive == null) ? new Control[0] : lastActive.getPath ();
- lastActive = control;
- int index = 0, length = Math.min (activate.length, deactivate.length);
- while (index < length) {
- if (activate [index] != deactivate [index]) break;
- index++;
- }
-
- /*
- * It is possible (but unlikely), that application
- * code could have destroyed some of the widgets. If
- * this happens, keep processing those widgets that
- * are not disposed.
- */
- for (int i=deactivate.length-1; i>=index; --i) {
- if (!deactivate [i].isDisposed ()) {
- deactivate [i].sendEvent (SWT.Deactivate);
- }
- }
- for (int i=activate.length-1; i>=index; --i) {
- if (!activate [i].isDisposed ()) {
- activate [i].sendEvent (SWT.Activate);
- }
- }
-}
public void setBounds (int x, int y, int width, int height) {
checkWidget();
- /*
- * Feature in Motif. Motif will not allow a window
- * to have a zero width or zero height. The fix is
- * to ensure these values are never zero.
- */
- saveBounds ();
- int newWidth = Math.max (width - trimWidth (), 1);
- int newHeight = Math.max (height - trimHeight (), 1);
-
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
-
- OS.MoveWindow(shellHandle, (short)x, (short)y, false);
- OS.SizeWindow(shellHandle, (short)newWidth, (short)newHeight, true);
- //processResize (null);
-
- if (isFocus) caret.setFocus ();
-}
-// AW
-public void setEnabled (boolean enabled) {
- fIsEnabled= enabled;
- super.setEnabled(enabled);
-}
-// AW
-/**
- * Sets the input method editor mode to the argument which
- * should be the result of bitwise OR'ing together one or more
- * of the following constants defined in class <code>SWT</code>:
- * <code>NONE</code>, <code>ROMAN</code>, <code>DBCS</code>,
- * <code>PHONETIC</code>, <code>NATIVE</code>, <code>ALPHA</code>.
- *
- * @param mode the new IME mode
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see SWT
- */
-public void setImeInputMode (int mode) {
- checkWidget();
}
+
public void setLocation (int x, int y) {
checkWidget();
- saveBounds ();
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- OS.MoveWindow(shellHandle, (short)x, (short)y, true);
- //processResize(null);
- if (isFocus) caret.setFocus ();
}
+
public void setMinimized (boolean minimized) {
checkWidget();
-
- /*
- * Bug in MOTIF. For some reason, the receiver does not keep the
- * value of the XmNiconic resource up to date when the user minimizes
- * and restores the window. As a result, a window that is minimized
- * by the user and then restored by the programmer is not restored.
- * This happens because the XmNiconic resource is unchanged when the
- * window is minimized by the user and subsequent attempts to set the
- * resource fail because the new value of the resource is the same as
- * the old value. The fix is to force XmNiconic to be up to date
- * before setting the desired value.
- */
- /* AW
- int [] argList = {OS.XmNiconic, 0};
- OS.XtGetValues (shellHandle, argList, argList.length / 2);
- if ((argList [1] != 0) != this.minimized) {
- argList [1] = this.minimized ? 1 : 0;
- OS.XtSetValues (shellHandle, argList, argList.length / 2);
- }
- */
-
- /* Minimize or restore the shell */
- /* AW
- argList [1] = (this.minimized = minimized) ? 1 : 0;
- OS.XtSetValues (shellHandle, argList, argList.length / 2);
- */
-
- /* Force the XWindowAttributes to be up to date */
- /*
- int xDisplay = OS.XtDisplay (handle);
- if (xDisplay != 0) OS.XSync (xDisplay, false);
- */
-
- OS.CollapseWindow(shellHandle, true);
}
public void setSize (int width, int height) {
checkWidget();
- saveBounds ();
- int newWidth = Math.max (width - trimWidth (), 1);
- int newHeight = Math.max (height - trimHeight (), 1);
- boolean isFocus = caret != null && caret.isFocusCaret ();
- if (isFocus) caret.killFocus ();
- OS.SizeWindow(shellHandle, (short)newWidth, (short)newHeight, true);
- //processResize (null);
- if (isFocus) caret.setFocus ();
}
public void setText (String string) {
checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- super.setText (string);
- int sHandle= 0;
- try {
- sHandle= OS.CFStringCreateWithCharacters(string);
- OS.SetWindowTitleWithCFString(shellHandle, sHandle);
- } finally {
- if (sHandle != 0)
- OS.CFRelease(sHandle);
- }
}
public void setVisible (boolean visible) {
checkWidget();
- realizeWidget ();
-
- /* Show the shell */
- if (visible) {
-
- sendEvent (SWT.Show);
- if (isDisposed ()) return;
-
- /* Map the widget */
- /* AW
- OS.XtSetMappedWhenManaged (shellHandle, true);
- if (OS.XtIsTopLevelShell (shellHandle)) {
- OS.XtMapWidget (shellHandle);
- } else {
- OS.XtPopup (shellHandle, OS.XtGrabNone);
- }
- */
- OS.ShowWindow(shellHandle);
- //OS.SelectWindow(shellHandle);
- OS.BringToFront(shellHandle);
-
- processResize (null);
-
- // find focus
- //if (savedFocus == null)
- // setFocus();
-
- /*
- * Force the shell to be fully exposed before returning.
- * This ensures that the shell coordinates are correct
- * when queried directly after showing the shell.
- */
- do {
- display.update ();
- } while (!isVisible ());
-
- //adjustTrim ();
-
- /* Set the saved focus widget */
- /*
- if (savedFocus != null && !savedFocus.isDisposed ()) {
- savedFocus.setFocus ();
- }
- savedFocus = null;
- */
-
- //sendEvent (SWT.Show);
-
- return;
- }
-
- Shell[] shells= getShells();
- for (int i= 0; i < shells.length; i++) {
- Shell shell= shells[i];
- if (shell.isVisible())
- shell.setVisible(false);
- }
-
- /* Hide the shell */
- /* AW
- OS.XtSetMappedWhenManaged (shellHandle, false);
- if (OS.XtIsTopLevelShell (shellHandle)) {
- OS.XtUnmapWidget (shellHandle);
- } else {
- OS.XtPopdown (shellHandle);
- }
- */
- OS.HideWindow(shellHandle);
-
- sendEvent (SWT.Hide);
-}
-int topHandle () {
- return shellHandle;
-}
-int trimHeight () {
- if ((style & SWT.NO_TRIM) != 0) return 0;
- /* AW
- boolean hasTitle = false, hasResize = false, hasBorder = false;
- hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
- hasResize = (style & SWT.RESIZE) != 0;
- hasBorder = (style & SWT.BORDER) != 0;
- if (hasTitle) {
- if (hasResize) return display.titleResizeTrimHeight;
- if (hasBorder) return display.titleBorderTrimHeight;
- return display.titleTrimHeight;
- }
- if (hasResize) return display.resizeTrimHeight;
- if (hasBorder) return display.borderTrimHeight;
- */
- return 0;
-}
-int trimWidth () {
- if ((style & SWT.NO_TRIM) != 0) return 0;
- /* AW
- boolean hasTitle = false, hasResize = false, hasBorder = false;
- hasTitle = (style & (SWT.MIN | SWT.MAX | SWT.TITLE | SWT.MENU)) != 0;
- hasResize = (style & SWT.RESIZE) != 0;
- hasBorder = (style & SWT.BORDER) != 0;
- if (hasTitle) {
- if (hasResize) return display.titleResizeTrimWidth;
- if (hasBorder) return display.titleBorderTrimWidth;
- return display.titleTrimWidth;
- }
- if (hasResize) return display.resizeTrimWidth;
- if (hasBorder) return display.borderTrimWidth;
- */
- return 0;
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
index ca56088eec..ece049a301 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
@@ -8,36 +8,9 @@ package org.eclipse.swt.widgets;
*/
import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.carbon.*;
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
-/**
- * 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.
- * <dl>
- * <dt><b>Styles:</b></dt>
- * <dd>(none)</dd>
- * <dt><b>Events:</b></dt>
- * <dd>Dispose</dd>
- * </dl>
- * <p>
- * IMPORTANT: This class is intended to be subclassed <em>only</em>
- * 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.
- * </p>
- *
- * @see #checkSubclass
- */
public abstract class Widget {
public int handle;
@@ -48,113 +21,48 @@ public abstract class Widget {
Object [] values;
/* Global state flags */
-// static final int AUTOMATIC = 0x00000001;
-// static final int ACTIVE = 0x00000002;
-// static final int AUTOGRAB = 0x00000004;
-// static final int MULTIEXPOSE = 0x00000008;
-// static final int RESIZEREDRAW = 0x00000010;
-// static final int WRAP = 0x00000020;
-// static final int DISABLED = 0x00000040;
- static final int HIDDEN = 0x00000080;
-// static final int FOREGROUND = 0x00000100;
-// static final int BACKGROUND = 0x00000200;
- static final int DISPOSED = 0x00000400;
- static final int HANDLE = 0x00000800;
- static final int CANVAS = 0x00001000;
+// static final int AUTOMATIC = 1 << 0;
+// static final int ACTIVE = 1 << 1;
+// static final int AUTOGRAB = 1 << 2;
+// static final int MULTIEXPOSE = 1 << 3;
+// static final int RESIZEREDRAW = 1 << 4;
+// static final int WRAP = 1 << 5;
+// static final int DISABLED = 1 << 6;
+ static final int HIDDEN = 1 << 7;
+// static final int FOREGROUND = 1 << 8;
+// static final int BACKGROUND = 1 << 9;
+ static final int DISPOSED = 1 << 10;
+ static final int HANDLE = 1 << 11;
+ static final int CANVAS = 1 << 12;
static final int DEFAULT_WIDTH = 64;
static final int DEFAULT_HEIGHT = 64;
-
- /* Global widget variables */
static final char Mnemonic = '&';
Widget () {
/* Do nothing */
}
-/**
- * Constructs a new instance of this class given its parent
- * and a style value describing its behavior and appearance.
- * <p>
- * The style value is either one of the style constants defined in
- * class <code>SWT</code> which is applicable to instances of this
- * class, or must be built by <em>bitwise OR</em>'ing together
- * (that is, using the <code>int</code> "|" operator) two or more
- * of those <code>SWT</code> style constants. The class description
- * lists the style constants that are applicable to the class.
- * Style bits are also inherited from superclasses.
- * </p>
- *
- * @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 IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- *
- * @see SWT
- * @see #checkSubclass
- * @see #getStyle
- */
+
public Widget (Widget parent, int style) {
- if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ checkSubclass ();
+ checkParent (parent);
this.style = style;
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when an event of the given type occurs. When the
- * event does occur in the widget, the listener is notified by
- * sending it the <code>handleEvent()</code> message.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #removeListener
- */
+
public void addListener (int eventType, Listener handler) {
checkWidget();
if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) eventTable = new EventTable ();
eventTable.hook (eventType, handler);
}
-/**
- * Adds the listener to the collection of listeners who will
- * be notifed when the widget is disposed. When the widget is
- * disposed, the listener is notified by sending it the
- * <code>widgetDisposed()</code> message.
- *
- * @param listener the listener which should be notified when the receiver is disposed
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @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);
}
+
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;
@@ -166,118 +74,36 @@ static int checkBits (int style, int int0, int int1, int int2, int int3, int int
if ((style & int5) != 0) style = (style & ~mask) | int5;
return style;
}
+
void checkParent (Widget parent) {
if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (parent.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
}
-/**
- * Checks that this class can be subclassed.
- * <p>
- * The SWT class library is intended to be subclassed
- * only at specific, controlled points (most notably,
- * <code>Composite</code> and <code>Canvas</code> when
- * implementing new widgets). This method enforces this
- * rule unless it is overridden.
- * </p><p>
- * <em>IMPORTANT:</em> 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.
- * </p><p>
- * 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.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
- * </ul>
- */
+
protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
-/**
- * Throws an <code>SWTException</code> 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 <em>should</em> be called by
- * widget implementors to enforce the standard SWT invariants.
- * <p>
- * Currently, it is an error to invoke any method (other than
- * <code>isDisposed()</code>) on a widget that has had its
- * <code>dispose()</code> method called. It is also an error
- * to call widget methods from any thread that is different
- * from the thread that created the widget.
- * </p><p>
- * In future releases of SWT, there may be more or fewer error
- * checks and exceptions may be thrown for different reasons.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
protected void checkWidget () {
if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED);
}
+
void createHandle (int index) {
/* Do nothing */
}
void createWidget (int index) {
createHandle (index);
- hookEvents ();
register ();
- manageChildren ();
}
void deregister () {
if (handle == 0) return;
WidgetTable.remove (handle);
}
void destroyWidget () {
- int topHandle = topHandle ();
- releaseHandle ();
- if (topHandle != 0) {
- if (OS.IsValidControlHandle(topHandle)) {
- OS.DisposeControl(topHandle);
- } else if (OS.IsValidWindowPtr(topHandle)) {
- OS.DisposeWindow(topHandle);
- } else {
- System.out.println("Widget.destroyWidget: wrong handle");
- }
- }
}
-/**
- * Disposes of the operating system resources associated with
- * the receiver and all its descendents. After this method has
- * been invoked, the receiver and all descendents will answer
- * <code>true</code> when sent the message <code>isDisposed()</code>.
- * Any internal connections between the widgets in the tree will
- * have been removed to facilitate garbage collection.
- * <p>
- * NOTE: This method is not called recursively on the descendents
- * 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 <code>Dispose</code>
- * event.
- * </p>
- *
- * @exception SWTException <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #addDisposeListener
- * @see #removeDisposeListener
- * @see #checkWidget
- */
+
public void dispose () {
/*
* Note: It is valid to attempt to dispose a widget
@@ -289,70 +115,24 @@ public void dispose () {
releaseWidget ();
destroyWidget ();
}
+
void enableHandle (boolean enabled, int widgetHandle) {
- if (enabled)
- OS.EnableControl(widgetHandle);
- else
- OS.DisableControl(widgetHandle);
-}
+}
+
void error (int code) {
SWT.error(code);
}
+
boolean filters (int eventType) {
Display display = getDisplay ();
return display.filters (eventType);
}
-/**
- * Returns the application defined widget data associated
- * with the receiver, or null if it has not been set. The
- * <em>widget data</em> is a single, unnamed field that is
- * stored with every widget.
- * <p>
- * 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.
- * </p>
- *
- * @return the widget data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- *
- * @see #setData
- */
+
public Object getData () {
checkWidget();
return data;
}
-/**
- * Returns the application defined property of the receiver
- * with the specified name, or null if it has not been set.
- * <p>
- * 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.
- * </p>
- *
- * @param key the name of the property
- * @return the value of the property or null if it has not been set
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #setData
- */
public Object getData (String key) {
checkWidget();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -363,123 +143,49 @@ public Object getData (String key) {
return null;
}
-/**
- * Returns the <code>Display</code> that is associated with
- * the receiver.
- * <p>
- * A widget's display is either provided when it is created
- * (for example, top level <code>Shell</code>s) or is the
- * same as its parent's display.
- * </p>
- *
- * @return the receiver's display
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
public abstract Display getDisplay ();
+
String getName () {
String string = getClass ().getName ();
- int index = string.lastIndexOf ('.');
+ int index = string.lastIndexOf(".");
if (index == -1) return string;
- return string.substring (index + 1, string.length ());
+ return string.substring(index + 1, string.length ());
}
+
String getNameText () {
return "";
}
-/**
- * Returns the receiver's style information.
- * <p>
- * Note that the value which is returned by this method <em>may
- * not match</em> 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
- * <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set.
- * </p>
- *
- * @return the style bits
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
public int getStyle () {
checkWidget();
return style;
}
-void hookEvents () {
- /* Do nothing */
-}
+
boolean hooks (int eventType) {
if (eventTable == null) return false;
return eventTable.hooks (eventType);
}
-/**
- * Returns <code>true</code> if the widget has been disposed,
- * and <code>false</code> otherwise.
- * <p>
- * This method gets the dispose state for the widget.
- * When a widget has been disposed, it is an error to
- * invoke any other method using the widget.
- * </p>
- *
- * @return <code>true</code> when the widget is disposed and <code>false</code> otherwise
- */
+
public boolean isDisposed () {
if (handle != 0) return false;
if ((state & HANDLE) != 0) return true;
return (state & DISPOSED) != 0;
}
-/**
- * Return the listening state.
- * <p>
- * Returns true if there is a listener, listening for the eventType.
- * Otherwise, returns false.
- *
- * @param eventType the type of event
- * @return true if the event is hooked
- *
- * @exception SWTError <ul>
- * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
- * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
- * <li>ERROR_NULL_ARGUMENT when the name is null</li>
- * </ul>
- */
+
protected boolean isListening (int eventType) {
checkWidget();
return hooks (eventType);
}
+
boolean isValidSubclass () {
return Display.isValidClass (getClass ());
}
+
boolean isValidThread () {
return getDisplay ().isValidThread ();
}
-void manageChildren () {
- /* Do nothing */
-}
-/**
- * Notifies all of the receiver's listeners for events
- * of the given type that one such event has occurred by
- * invoking their <code>handleEvent()</code> method.
- *
- * @param eventType the type of event which has occurred
- * @param event the event data
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the event is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- */
+
+
public void notifyListeners (int eventType, Event event) {
checkWidget();
if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -488,191 +194,7 @@ public void notifyListeners (int eventType, Event event) {
event.widget = this;
eventTable.sendEvent (event);
}
-void postEvent (int eventType) {
- sendEvent (eventType, null, false);
-}
-void postEvent (int eventType, Event event) {
- sendEvent (eventType, event, false);
-}
-int processArm (Object callData) {
- return OS.noErr;
-}
-int processDispose (Object callData) {
- return OS.noErr;
-}
-int processDefaultSelection (Object callData) {
- return OS.noErr;
-}
-final int processEvent (int eventNumber) {
- switch (eventNumber) {
- case SWT.Dispose: return processDispose (null);
- case SWT.Help: return processHelp (null);
- default:
- System.out.println("Widget.processEvent(): unexpected event");
- break;
- }
- return OS.eventNotHandledErr;
-}
-final int processEvent (int eventNumber, MacControlEvent mcEvent) {
- switch (eventNumber) {
- case SWT.Selection: return processSelection (mcEvent);
- case SWT.Paint: return processPaint (mcEvent);
- default:
- System.out.println("Widget.processEvent(MacMouseEvent): unexpected event");
- break;
- }
- return OS.eventNotHandledErr;
-}
-final int processEvent (int eventNumber, MacMouseEvent mmEvent) {
- switch (eventNumber) {
- case SWT.MouseDown: return processMouseDown (mmEvent);
- case SWT.MouseEnter: return processMouseEnter (mmEvent);
- case SWT.MouseExit: return processMouseExit (mmEvent);
- case SWT.MouseHover: return processMouseHover (mmEvent);
- case SWT.MouseMove: return processMouseMove (mmEvent);
- case SWT.MouseUp: return processMouseUp (mmEvent);
- default:
- System.out.println("Widget.processEvent(MacMouseEvent): unexpected event");
- break;
- }
- return OS.eventNotHandledErr;
-}
-final int processEvent (int eventNumber, MacEvent me) {
- switch (eventNumber) {
- case SWT.Arm: return processArm (me);
- case SWT.DefaultSelection: return processDefaultSelection (me);
- case SWT.Hide: return processHide (me);
- case SWT.KeyDown: return processKeyDown (me);
- case SWT.KeyUp: return processKeyUp (me);
- case SWT.Modify: return processModify (me);
- case SWT.Show: return processShow (me);
- case SWT.Verify: return processVerify (me);
- case -1: return processNonMaskable (me);
- default:
- System.out.println("Widget.processEvent(Object): unexpected event");
- break;
- }
- return OS.eventNotHandledErr;
-}
-int processHelp (Object callData) {
- return OS.noErr;
-}
-int processHide (Object callData) {
- return OS.noErr;
-}
-int processKeyDown (Object callData) {
- return OS.noErr;
-}
-int processKeyUp (Object callData) {
- return OS.noErr;
-}
-int processModify (Object callData) {
- return OS.noErr;
-}
-int processMouseDown (MacMouseEvent mme) {
- return OS.noErr;
-}
-int processMouseEnter (MacMouseEvent mme) {
- return OS.noErr;
-}
-int processMouseExit (MacMouseEvent mme) {
- return OS.noErr;
-}
-int processMouseHover (MacMouseEvent mme) {
- return OS.noErr;
-}
-int processMouseMove (MacMouseEvent mme) {
- return OS.noErr;
-}
-int processMouseUp (MacMouseEvent mme) {
- return OS.noErr;
-}
-int processNonMaskable (Object callData) {
- return OS.noErr;
-}
-int processPaint (Object callData) {
- return OS.noErr;
-}
-int processResize (Object callData) {
- return OS.noErr;
-}
-int processSelection (Object callData) {
- return OS.noErr;
-}
-int processSetFocus (Object callData) {
- return OS.noErr;
-}
-int processShow (Object callData) {
- return OS.noErr;
-}
-int processVerify (Object callData) {
- return OS.noErr;
-}
-void propagateHandle (boolean enabled, int widgetHandle) {
- /* AW
- int xDisplay = OS.XtDisplay (widgetHandle);
- if (xDisplay == 0) return;
- int xWindow = OS.XtWindow (widgetHandle);
- if (xWindow == 0) return;
- */
- /*
- * Get the event mask from the widget. The event mask
- * returned by XtBuildEventMask () includes the masks
- * associated with all callbacks and event handlers
- * that have been hooked on the widget.
- */
- /* AW
- int event_mask = OS.XtBuildEventMask (widgetHandle);
- int do_not_propagate_mask =
- OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask |
- OS.ButtonReleaseMask | OS.PointerMotionMask;
- if (!enabled) {
- */
- /*
- * Attempting to propogate EnterWindowMask and LeaveWindowMask
- * causes an X error so these must be specially cleared out from
- * the event mask, not included in the propogate mask.
- */
- /* AW
- event_mask &= ~(do_not_propagate_mask | OS.EnterWindowMask | OS.LeaveWindowMask);
- do_not_propagate_mask = 0;
- }
- XSetWindowAttributes attributes = new XSetWindowAttributes ();
- attributes.event_mask = event_mask;
- attributes.do_not_propagate_mask = do_not_propagate_mask;
- OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWDontPropagate | OS.CWEventMask, attributes);
- int [] argList = {OS.XmNtraversalOn, enabled ? 1 : 0};
- OS.XtSetValues (widgetHandle, argList, argList.length / 2);
- */
-}
-final void redrawHandle (int x, int y, int width, int height, int widgetHandle, boolean all) {
- /* AW
- int display = OS.XtDisplay (widgetHandle);
- if (display == 0) return;
- int window = OS.XtWindow (widgetHandle);
- if (window == 0) return;
- int [] argList = {OS.XmNborderWidth, 0, OS.XmNborderColor, 0};
- OS.XtGetValues (widgetHandle, argList, argList.length / 2);
- if (argList [1] != 0) {
- */
- /* Force the border to repaint by setting the color */
- /*
- OS.XtSetValues (widgetHandle, argList, argList.length / 2);
- }
- OS.XClearArea (display, window, x, y, width, height, true);
- */
- Rect r= new Rect();
- OS.SetRect(r, (short)x, (short)y, (short)(x + width), (short)(y + height));
- if (width <= 0 || height <= 0) {
- OS.HIViewSetNeedsDisplay(widgetHandle, true);
- return;
- //OS.GetControlBounds(widgetHandle, r.getData());
- }
- int rgn= OS.NewRgn();
- OS.RectRgn(rgn, r);
- OS.HIViewSetNeedsDisplayInRegion(widgetHandle, rgn, true);
- OS.DisposeRgn(rgn);
-}
+
void register () {
if (handle == 0) return;
WidgetTable.put (handle, this);
@@ -692,77 +214,21 @@ void releaseWidget () {
keys = null;
values = null;
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs.
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- */
+
public void removeListener (int eventType, Listener handler) {
checkWidget();
if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (eventType, handler);
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when an event of the given type occurs.
- * <p>
- * <b>IMPORTANT:</b> This method is <em>not</em> 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.
- * </p>
- *
- * @param eventType the type of event to listen for
- * @param listener the listener which should no longer be notified when the event occurs
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see Listener
- * @see #addListener
- */
+
protected void removeListener (int eventType, SWTEventListener handler) {
checkWidget();
if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
if (eventTable == null) return;
eventTable.unhook (eventType, handler);
}
-/**
- * Removes the listener from the collection of listeners who will
- * be notifed when the widget is disposed.
- *
- * @param listener the listener which should no longer be notified when the receiver is disposed
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see DisposeListener
- * @see #addDisposeListener
- */
+
public void removeDisposeListener (DisposeListener listener) {
checkWidget();
if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -770,103 +236,6 @@ public void removeDisposeListener (DisposeListener listener) {
eventTable.unhook (SWT.Dispose, listener);
}
-void setInputState (Event event, MacMouseEvent mEvent) {
- event.stateMask= mEvent.getState();
- switch (event.type) {
- case SWT.MouseDown:
- case SWT.MouseDoubleClick:
- if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
- if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
- if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
- break;
- case SWT.MouseUp:
- if (event.button == 1) event.stateMask |= SWT.BUTTON1;
- if (event.button == 2) event.stateMask |= SWT.BUTTON2;
- if (event.button == 3) {
- event.stateMask |= SWT.BUTTON3;
- if (MacEvent.EMULATE_RIGHT_BUTTON) event.stateMask &= ~SWT.CONTROL;
- }
- break;
- }
-}
-
-void setInputState (Event event, MacEvent mEvent) {
- event.stateMask= mEvent.getStateMask();
- switch (event.type) {
- case SWT.KeyDown:
- case SWT.Traverse: {
- if (event.keyCode != 0 || event.character != 0) return;
- int modifiers = mEvent.getModifiers();
- int fLastModifiers = getDisplay().fLastModifiers;
- if ((modifiers & OS.shiftKey) != 0 && (fLastModifiers & OS.shiftKey) == 0) {
- event.stateMask &= ~SWT.SHIFT;
- event.keyCode = SWT.SHIFT;
- return;
- }
- if ((modifiers & OS.controlKey) != 0 && (fLastModifiers & OS.controlKey) == 0) {
- event.stateMask &= ~SWT.CONTROL;
- event.keyCode = SWT.CONTROL;
- return;
- }
- if ((modifiers & OS.cmdKey) != 0 && (fLastModifiers & OS.cmdKey) == 0) {
- event.stateMask &= ~SWT.COMMAND;
- event.keyCode = SWT.COMMAND;
- return;
- }
- if ((modifiers & OS.optionKey) != 0 && (fLastModifiers & OS.optionKey) == 0) {
- event.stateMask &= ~SWT.ALT;
- event.keyCode = SWT.ALT;
- return;
- }
- break;
- }
- case SWT.KeyUp: {
- if (event.keyCode != 0 || event.character != 0) return;
- int modifiers = mEvent.getModifiers();
- int fLastModifiers = getDisplay().fLastModifiers;
- if ((modifiers & OS.shiftKey) == 0 && (fLastModifiers & OS.shiftKey) != 0) {
- event.stateMask |= SWT.SHIFT;
- event.keyCode = SWT.SHIFT;
- return;
- }
- if ((modifiers & OS.controlKey) == 0 && (fLastModifiers & OS.controlKey) != 0) {
- event.stateMask |= SWT.CONTROL;
- event.keyCode = SWT.CONTROL;
- return;
- }
- if ((modifiers & OS.cmdKey) == 0 && (fLastModifiers & OS.cmdKey) != 0) {
- event.stateMask |= SWT.COMMAND;
- event.keyCode = SWT.COMMAND;
- return;
- }
- if ((modifiers & OS.optionKey) != 0 && (fLastModifiers & OS.optionKey) == 0) {
- event.stateMask |= SWT.ALT;
- event.keyCode = SWT.ALT;
- return;
- }
- break;
- }
- }
-}
-
-void setKeyState (Event event, MacEvent mEvent) {
- event.keyCode = Display.translateKey (mEvent.getKeyCode ());
- switch (event.keyCode) {
- case 0:
- case SWT.BS:
- case SWT.CR:
- case SWT.DEL:
- case SWT.ESC:
- case SWT.TAB:
- event.character = (char) mEvent.getMacCharCodes ();
- break;
- case SWT.LF:
- event.character = '\n';
- break;
- }
- setInputState (event, mEvent);
-}
-
void sendEvent (Event event) {
Display display = event.display;
if (!display.filterEvent (event)) {
@@ -892,7 +261,7 @@ void sendEvent (int eventType, Event event, boolean send) {
event.display = display;
event.widget = this;
if (event.time == 0) {
- event.time = display.getLastEventTime ();
+ //event.time = display.getLastEventTime ();
}
if (send) {
sendEvent (event);
@@ -900,55 +269,12 @@ void sendEvent (int eventType, Event event, boolean send) {
display.postEvent (event);
}
}
-/**
- * Sets the application defined widget data associated
- * with the receiver to be the argument. The <em>widget
- * data</em> is a single, unnamed field that is stored
- * with every widget.
- * <p>
- * 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.
- * </p>
- *
- * @param data the widget data
- *
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - when the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
- * </ul>
- */
+
public void setData (Object data) {
checkWidget();
this.data = data;
}
-/**
- * Sets the application defined property of the receiver
- * with the specified name to the given value.
- * <p>
- * 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.
- * </p>
- *
- * @param key the name of the property
- * @param value the new value for the property
- *
- * @exception IllegalArgumentException <ul>
- * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
- * </ul>
- * @exception SWTException <ul>
- * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
- * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
- * </ul>
- *
- * @see #getData
- */
public void setData (String key, Object value) {
checkWidget();
if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
@@ -997,12 +323,6 @@ public void setData (String key, Object value) {
values = newValues;
}
-/**
- * Returns a string containing a concise, human-readable
- * description of the receiver.
- *
- * @return a string representation of the receiver
- */
public String toString () {
String string = "*Disposed*";
if (!isDisposed ()) {
@@ -1011,7 +331,4 @@ public String toString () {
}
return getName () + " {" + string + "}";
}
-int topHandle () {
- return handle;
-}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java
index 20f514e91b..8e59598c95 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/WidgetTable.java
@@ -7,8 +7,6 @@ package org.eclipse.swt.widgets;
* http://www.eclipse.org/legal/cpl-v10.html
*/
-import org.eclipse.swt.internal.carbon.OS;
-
public class WidgetTable {
static int FreeSlot = 0;
static int GrowSize = 1024;
@@ -18,12 +16,13 @@ public class WidgetTable {
for (int i=0; i<GrowSize-1; i++) IndexTable [i] = i + 1;
IndexTable [GrowSize - 1] = -1;
}
+
public static synchronized Widget get (int handle) {
if (handle == 0) return null;
- int index = getUserData(handle) - 1;
- if (0 <= index && index < WidgetTable.length) return WidgetTable [index];
+
return null;
}
+
public synchronized static void put (int handle, Widget widget) {
if (handle == 0) return;
if (FreeSlot == -1) {
@@ -39,7 +38,7 @@ public synchronized static void put (int handle, Widget widget) {
IndexTable = newIndexTable;
WidgetTable = newWidgetTable;
}
- setUserData(handle, FreeSlot + 1);
+
int oldSlot = FreeSlot;
FreeSlot = IndexTable [oldSlot];
IndexTable [oldSlot] = -2;
@@ -48,14 +47,7 @@ public synchronized static void put (int handle, Widget widget) {
public static synchronized Widget remove (int handle) {
if (handle == 0) return null;
Widget widget = null;
- int index= getUserData(handle) - 1;
- if (0 <= index && index < WidgetTable.length) {
- widget = WidgetTable [index];
- WidgetTable [index] = null;
- IndexTable [index] = FreeSlot;
- FreeSlot = index;
- setUserData(handle, 0);
- }
+
return widget;
}
public static synchronized Shell [] shells () {
@@ -80,38 +72,4 @@ public static synchronized int size () {
}
return length;
}
-/////////////////////////////////////////////////
-// Mac stuff
-/////////////////////////////////////////////////
-
- private static int getUserData(int handle) {
- if (OS.IsValidControlHandle(handle))
- return OS.GetControlReference(handle);
- if (OS.IsValidMenu(handle)) {
- int[] refCon= new int[1];
- OS.GetMenuItemRefCon(handle, (short)0, refCon);
- //System.out.println("refCon: " + refCon[0]);
- return refCon[0];
- }
- if (OS.IsValidWindowPtr(handle))
- return OS.GetWRefCon(handle);
- //System.out.println("WidgetTable.getUserData: unknown handle type");
- return -1;
- }
-
- private static void setUserData(int handle, int data) {
- if (OS.IsValidControlHandle(handle)) {
- OS.SetControlReference(handle, data);
- return;
- }
- if (OS.IsValidMenu(handle)) {
- OS.SetMenuItemRefCon(handle, (short)0, data);
- return;
- }
- if (OS.IsValidWindowPtr(handle)) {
- OS.SetWRefCon(handle, data);
- return;
- }
- System.out.println("WidgetTable.setUserData: unknown handle type: " + handle);
- }
}