diff options
author | Steve Northover <steve> | 2003-12-17 22:46:13 +0000 |
---|---|---|
committer | Steve Northover <steve> | 2003-12-17 22:46:13 +0000 |
commit | f0509f96c75e0bc7b0a6d6af406e7a9a2d4f8abe (patch) | |
tree | 9842fef9c9792dac0636e592530c3d8eef9478ee /bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse | |
parent | 5258b5d41cf68402bb882b86e09e5b93debe0f1d (diff) | |
download | eclipse.platform.swt-f0509f96c75e0bc7b0a6d6af406e7a9a2d4f8abe.tar.gz eclipse.platform.swt-f0509f96c75e0bc7b0a6d6af406e7a9a2d4f8abe.tar.xz eclipse.platform.swt-f0509f96c75e0bc7b0a6d6af406e7a9a2d4f8abe.zip |
*** empty log message ***
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse')
8 files changed, 48 insertions, 86 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java index 348225a9b1..afe8edb982 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java @@ -134,6 +134,7 @@ static int checkStyle (int style) { return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0); } if ((style & SWT.ARROW) != 0) { + style |= SWT.NO_FOCUS; return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0); } return style; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java index 05ca0eccd9..ca08e25089 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java @@ -704,7 +704,6 @@ public boolean setFocus () { Control child = children [i]; if (child.setFocus ()) return true; } - if ((style & SWT.NO_FOCUS) != 0) return false; return super.setFocus (); } /** @@ -744,16 +743,6 @@ public void setTabList (Control [] tabList) { Control control = tabList [i]; if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - /* - * This code is intentionally commented. - * Tab lists are currently only supported - * for the direct children of a composite. - */ -// Shell shell = control.getShell (); -// while (control != shell && control != this) { -// control = control.parent; -// } -// if (control != this) error (SWT.ERROR_INVALID_PARENT); if (control.parent != this) error (SWT.ERROR_INVALID_PARENT); } Control [] newList = new Control [tabList.length]; @@ -764,13 +753,12 @@ public void setTabList (Control [] tabList) { } boolean setTabGroupFocus () { if (isTabItem ()) return setTabItemFocus (); - if ((style & SWT.NO_FOCUS) == 0) { - boolean takeFocus = true; - if ((state & CANVAS) != 0) takeFocus = hooksKeys (); - if ((takeFocus || ((state & CANVAS) != 0 && (style & SWT.EMBEDDED) != 0)) && setTabItemFocus ()) { - return true; - } + boolean takeFocus = (style & SWT.NO_FOCUS) == 0; + if ((state & CANVAS) != 0) { + takeFocus = hooksKeys (); + if ((style & SWT.EMBEDDED) != 0) takeFocus = true; } + if (takeFocus && setTabItemFocus ()) return true; Control [] children = _getChildren (); for (int i=0; i<children.length; i++) { Control child = children [i]; @@ -778,17 +766,6 @@ boolean setTabGroupFocus () { } return false; } -boolean setTabItemFocus () { - if ((style & SWT.NO_FOCUS) == 0) { - boolean takeFocus = true; - if ((state & CANVAS) != 0) takeFocus = hooksKeys (); - if (takeFocus || (style & SWT.EMBEDDED) != 0) { - if (!isShowing ()) return false; - if (forceFocus ()) return true; - } - } - return super.setTabItemFocus (); -} int traversalCode (int key, XKeyEvent xEvent) { if ((state & CANVAS) != 0) { if ((style & SWT.NO_FOCUS) != 0) return 0; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java index da5910f5e0..47b2ea2e57 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java @@ -556,7 +556,22 @@ public boolean forceFocus () { focusHandle = handle; } } - return XmProcessTraversal (focusHandle, OS.XmTRAVERSE_CURRENT); + int [] argList = new int [] {OS.XmNtraversalOn, 0}; + OS.XtGetValues (focusHandle, argList, argList.length / 2); + boolean force = argList [1] == 0; + if (force) { + state |= FOCUS_FORCED; + argList [1] = 1; + OS.XtSetValues (focusHandle, argList, argList.length / 2); + overrideTranslations (); + } + if (XmProcessTraversal (focusHandle, OS.XmTRAVERSE_CURRENT)) return true; + if (force) { + state &= ~FOCUS_FORCED; + argList [1] = 0; + OS.XtSetValues (focusHandle, argList, argList.length / 2); + } + return false; } /** @@ -2033,6 +2048,7 @@ public void setEnabled (boolean enabled) { */ public boolean setFocus () { checkWidget(); + if ((style & SWT.NO_FOCUS) != 0) return false; return forceFocus (); } /** @@ -2261,7 +2277,7 @@ boolean setTabGroupFocus () { } boolean setTabItemFocus () { if (!isShowing ()) return false; - return setFocus (); + return forceFocus (); } /** * Sets the receiver's size to the point specified by the arguments. @@ -2958,10 +2974,8 @@ int xFocusIn (XFocusChangeEvent xEvent) { return 0; } int xFocusOut (XFocusChangeEvent xEvent) { - int focusHandle = OS.XtWindowToWidget (xEvent.display, xEvent.window); - if (!hasIMSupport ()) { - OS.XmImUnsetFocus (focusHandle); - } + int focusHandle = OS.XtWindowToWidget (xEvent.display, xEvent.window); + if (!hasIMSupport ()) OS.XmImUnsetFocus (focusHandle); /* * Bug in Motif. For some reason, when the widget font is @@ -2978,13 +2992,25 @@ int xFocusOut (XFocusChangeEvent xEvent) { int [] argList2 = {OS.XmNfontList, fontList}; OS.XmImSetValues (focusHandle, argList2, argList2.length / 2); } - + + /* Set the focus out event */ if (display.postFocusOut) { postEvent (SWT.FocusOut); } else { sendEvent (SWT.FocusOut); // widget could be disposed at this point } + + /* Restore XmNtraversalOn if it was focus was forced */ + if (handle == 0) return 0; + if ((style & SWT.NO_FOCUS) != 0) { + int [] argList = new int [] {OS.XmNtraversalOn, 0}; + OS.XtGetValues (focusHandle, argList, argList.length / 2); + if (argList [1] != 0 && (state & FOCUS_FORCED) != 0) { + argList [1] = 0; + OS.XtSetValues (focusHandle, argList, argList.length / 2); + } + } return 0; } int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java index 12d564c731..7e343895cd 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java @@ -85,6 +85,7 @@ public Label (Composite parent, int style) { super (parent, checkStyle (style)); } static int checkStyle (int style) { + style |= SWT.NO_FOCUS; if ((style & SWT.SEPARATOR) != 0) { style = checkBits (style, SWT.VERTICAL, SWT.HORIZONTAL, 0, 0, 0, 0); return checkBits (style, SWT.SHADOW_OUT, SWT.SHADOW_IN, SWT.SHADOW_NONE, 0, 0, 0); @@ -201,16 +202,6 @@ void enableWidget (boolean enabled) { super.enableWidget (enabled); if (formHandle != 0) enableHandle (enabled, formHandle); } -public boolean forceFocus () { - checkWidget(); - int [] argList = new int [] {OS.XmNtraversalOn, 1}; - OS.XtSetValues (handle, argList, argList.length / 2); - overrideTranslations (); - if (super.forceFocus ()) return true; - argList [1] = 0; - OS.XtSetValues (handle, argList, argList.length / 2); - return false; -} /** * Returns a value which describes the position of the * text or image in the receiver. The value will be one of @@ -541,15 +532,4 @@ int topHandle () { if (formHandle != 0) return formHandle; return handle; } -int xFocusOut (XFocusChangeEvent xEvent) { - int result = super.xFocusOut (xEvent); - if (handle == 0) return result; - int [] argList = new int [] {OS.XmNtraversalOn, 0}; - OS.XtGetValues (handle, argList, argList.length / 2); - if (argList [1] != 0) { - argList [1] = 0; - OS.XtSetValues (handle, argList, argList.length / 2); - } - return result; -} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java index f921581aa3..e0e00effac 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java @@ -80,6 +80,7 @@ public ProgressBar (Composite parent, int style) { super (parent, checkStyle (style | SWT.BORDER)); } static int checkStyle (int style) { + style |= SWT.NO_FOCUS; return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0); } public Point computeSize (int wHint, int hHint, boolean changed) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java index 7b5ced7c21..5409b20f3f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java @@ -220,13 +220,7 @@ public void setCursor (Cursor cursor) { } public boolean setFocus () { checkWidget(); - int [] argList = new int [] {OS.XmNtraversalOn, 1}; - OS.XtSetValues (handle, argList, argList.length / 2); - overrideTranslations (); - if (super.setFocus ()) return true; - argList [1] = 0; - OS.XtSetValues (handle, argList, argList.length / 2); - return false; + return forceFocus (); } int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatch) { int result = super.XButtonPress (w, client_data, call_data, continue_to_dispatch); @@ -297,13 +291,6 @@ int xFocusIn (XFocusChangeEvent xEvent) { lastY = argList [3]; return result; } -int xFocusOut (XFocusChangeEvent xEvent) { - int result = super.xFocusOut (xEvent); - if (handle == 0) return result; - int [] argList = new int [] {OS.XmNtraversalOn, 0}; - OS.XtSetValues (handle, argList, argList.length / 2); - return result; -} int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch) { int result = super.XKeyPress (w, client_data, call_data, continue_to_dispatch); if (result != 0) return result; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java index 6b8426c1f6..fc7a3e5c81 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java @@ -163,6 +163,7 @@ void createHandle (int index) { OS.XmNhighlightThickness, display.textHighlightThickness, OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0, OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL, + OS.XmNtraversalOn, 1, }; int parentHandle = parent.handle; handle = OS.XmCreateScrollBar (parentHandle, null, argList, argList.length / 2); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java index 94cc3dea04..f2b5103f88 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java @@ -54,22 +54,11 @@ public abstract class Widget { Object data; /* Global state flags */ -// static final int AUTOMATIC = 1<<0; -// static final int ACTIVE = 1<<1; -// static final int GRAB = 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 MOVED = 1<<13; -// static final int RESIZED = 1<<14; - static final int KEYED_DATA = 1<<15; + static final int DISPOSED = 1<<0; + static final int CANVAS = 1<<1; + static final int KEYED_DATA = 1<<2; + static final int HANDLE = 1<<3; + static final int FOCUS_FORCED = 1<<4; static final int DEFAULT_WIDTH = 64; static final int DEFAULT_HEIGHT = 64; |