Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover2001-10-29 20:58:09 +0000
committerSteve Northover2001-10-29 20:58:09 +0000
commit3bb1d0d5b18ad64f312195905956ceba8e91d9dc (patch)
treed92c4ab75f62e3883c5376d6ea5ce153ae58219b
parentd34c95efdcf10af2458e871da91456b39b9b2bcc (diff)
downloadeclipse.platform.swt-3bb1d0d5b18ad64f312195905956ceba8e91d9dc.tar.gz
eclipse.platform.swt-3bb1d0d5b18ad64f312195905956ceba8e91d9dc.tar.xz
eclipse.platform.swt-3bb1d0d5b18ad64f312195905956ceba8e91d9dc.zip
*** empty log message ***
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java121
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java98
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java2
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java51
8 files changed, 213 insertions, 82 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
index 4bc08b2693..c9f18d30bf 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -321,7 +321,7 @@ public String getText () {
return buffer.toString (0, length);
}
-boolean mnemonicHit () {
+boolean mnemonicHit (char ch) {
if (!setFocus ()) return false;
/*
* Feature in Windows. When a radio button gets focus,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
index da1fae02d8..d201108102 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -29,9 +29,9 @@ import org.eclipse.swt.graphics.*;
*/
public class Composite extends Scrollable {
-
Layout layout;
int font, hdwp;
+ Control [] tabList;
/**
* Prevents uninitialized instances from being created outside the package.
@@ -94,10 +94,46 @@ Control [] _getChildren () {
return newChildren;
}
+Control [] _getTabList () {
+ if (tabList == null) return tabList;
+ int index = 0, count = 0;
+ while (index < tabList.length) {
+ if (!tabList [index].isDisposed ()) count++;
+ index++;
+ }
+ if (index == count) return tabList;
+ Control [] newList = new Control [count];
+ index = 0;
+ for (int i=0; i<tabList.length; i++) {
+ if (!tabList [index].isDisposed ()) {
+ newList [index++] = tabList [i];
+ }
+ }
+ tabList = newList;
+ return tabList;
+}
+
protected void checkSubclass () {
/* Do nothing - Subclassing is allowed */
}
+Control [] computeTabList () {
+ Control result [] = super.computeTabList ();
+ if (result.length == 0) return result;
+ Control [] list = tabList != null ? tabList : _getChildren ();
+ for (int i=0; i<list.length; i++) {
+ Control child = list [i];
+ Control [] childList = child.computeTabList ();
+ if (childList.length != 0) {
+ Control [] newResult = new Control [result.length + childList.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (childList, 0, newResult, result.length, childList.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
Point size;
@@ -181,20 +217,9 @@ public Layout getLayout () {
return layout;
}
-Control [] getTabList () {
- Control result [] = super.getTabList ();
- Control [] children = _getChildren ();
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- Control [] list = child.getTabList ();
- if (list.length != 0) {
- Control [] newResult = new Control [result.length + list.length];
- System.arraycopy (result, 0, newResult, 0, result.length);
- System.arraycopy (list, 0, newResult, result.length, list.length);
- result = newResult;
- }
- }
- return result;
+public Control [] getTabList () {
+ checkWidget ();
+ return _getTabList ();
}
/**
@@ -272,6 +297,7 @@ void releaseWidget () {
releaseChildren ();
super.releaseWidget ();
layout = null;
+ tabList = null;
int oldHdwp = hdwp;
hdwp = 0;
if (oldHdwp != 0) OS.EndDeferWindowPos (oldHdwp);
@@ -310,13 +336,46 @@ public void setLayout (Layout layout) {
this.layout = layout;
}
+public void setTabList (Control [] tabList) {
+ checkWidget ();
+ if (tabList == null) error (SWT.ERROR_NULL_ARGUMENT);
+ /*
+ * This code is intentionally commented. It is
+ * not yet clear whether setting the tab list
+ * should force the widget to be a tab group
+ * instead of a tab item or non-traversable.
+ */
+// Control [] children = _getChildren ();
+// for (int i=0; i<children.length; i++) {
+// Control control = children [i];
+// if (control != null) {
+// if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
+// int index = 0;
+// while (index < tabList.length) {
+// if (tabList [index] == control) break;
+// index++;
+// }
+// int hwnd = control.handle;
+// int bits = OS.GetWindowLong (hwnd, OS.GWL_STYLE);
+// if (index == tabList.length) {
+// bits &= ~OS.WS_TABSTOP;
+// } else {
+// bits |= OS.WS_TABSTOP;
+// }
+// OS.SetWindowLong (hwnd, OS.GWL_STYLE, bits);
+// }
+// }
+ this.tabList = tabList;
+}
+
boolean setTabGroupFocus () {
- if (!isVisible ()) return false;
if (isTabItem ()) return setTabItemFocus ();
- Control [] children = _getChildren ();
- if (children.length == 0) {
- return (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) && setTabItemFocus ();
+ if ((state & CANVAS) != 0) {
+ if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+ if (setTabItemFocus ()) return true;
+ }
}
+ Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
if (child.isVisible () && child.setRadioFocus ()) return true;
@@ -325,13 +384,23 @@ boolean setTabGroupFocus () {
Control child = children [i];
if (child.isTabItem () && child.setTabItemFocus ()) return true;
}
- for (int i=0; i<children.length; i++) {
- Control child = children [i];
- if (child.isTabGroup () && child.setTabGroupFocus ()) return true;
- }
return false;
}
+boolean setTabItemFocus () {
+ Control [] path = getPath ();
+ for (int i=0; i<path.length; i++) {
+ Point size = path [i].getSize ();
+ if (size.x == 0 || size.y == 0) return false;
+ }
+ if ((state & CANVAS) != 0) {
+ if (hooks (SWT.KeyDown) || hooks (SWT.KeyUp)) {
+ return forceFocus ();
+ }
+ }
+ return setFocus ();
+}
+
String toolTipText (NMTTDISPINFO hdr) {
if ((hdr.uFlags & OS.TTF_IDISHWND) == 0) {
return null;
@@ -343,12 +412,12 @@ String toolTipText (NMTTDISPINFO hdr) {
return control.toolTipText;
}
-boolean traverseMnemonic (char key) {
- if (super.traverseMnemonic (key)) return true;
+boolean translateMnemonic (char key) {
+ if (super.translateMnemonic (key)) return true;
Control [] children = _getChildren ();
for (int i=0; i<children.length; i++) {
Control child = children [i];
- if (child.traverseMnemonic (key)) return true;
+ if (child.translateMnemonic (key)) return true;
}
return false;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index aa35b736bf..b99018f1b6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -391,6 +391,35 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
return new Point (width, height);
}
+Control computeTabGroup () {
+ if (isTabGroup ()) return this;
+ return parent.computeTabGroup ();
+}
+
+Control computeTabRoot () {
+ Control [] tabList = parent._getTabList ();
+ if (tabList != null) {
+ int index = 0;
+ while (index < tabList.length) {
+ if (tabList [index] == this) break;
+ index++;
+ }
+ if (index == tabList.length) {
+ if (isTabGroup ()) return this;
+ }
+ }
+ return parent.computeTabRoot ();
+}
+
+Control [] computeTabList () {
+ if (isTabGroup ()) {
+ if (getVisible () && getEnabled ()) {
+ return new Control [] {this};
+ }
+ }
+ return new Control [0];
+}
+
void createHandle () {
int hwndParent = 0;
if (handle != 0) {
@@ -424,11 +453,6 @@ void createWidget () {
setDefaultFont ();
}
-Control currentTabGroup () {
- if (isTabGroup ()) return this;
- return parent.currentTabGroup ();
-}
-
int defaultBackground () {
return OS.GetSysColor (OS.COLOR_BTNFACE);
}
@@ -802,15 +826,6 @@ public Point getSize () {
return new Point (width, height);
}
-Control [] getTabList () {
- if (isTabGroup ()) {
- if (getVisible () && getEnabled ()) {
- return new Control [] {this};
- }
- }
- return new Control [0];
-}
-
/**
* Returns the receiver's tool tip text, or null if it has
* not been set.
@@ -1051,7 +1066,7 @@ Decorations menuShell () {
return parent.menuShell ();
}
-boolean mnemonicHit () {
+boolean mnemonicHit (char key) {
return false;
}
@@ -2180,6 +2195,33 @@ boolean translateAccelerator (MSG msg) {
return menuShell ().translateAccelerator (msg);
}
+boolean translateMnemonic (char key) {
+ 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;
+ Display display = getDisplay ();
+ display.lastKey = display.lastAscii = key;
+ display.lastVirtual = false;
+ if (!setKeyState (event, SWT.Traverse)) {
+ return false;
+ }
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the traverse
+ * event. If this happens, return true to stop further
+ * event processing.
+ */
+ sendEvent (SWT.Traverse, event);
+ if (isDisposed ()) return true;
+ doit = event.doit;
+ }
+ if (doit) return mnemonicHit (key);
+ return false;
+}
+
boolean translateMnemonic (MSG msg) {
int hwnd = msg.hwnd;
if (OS.GetKeyState (OS.VK_MENU) >= 0) {
@@ -2188,9 +2230,11 @@ boolean translateMnemonic (MSG msg) {
if ((code & OS.DLGC_BUTTON) == 0) return false;
}
Decorations shell = menuShell ();
- if (!shell.isVisible () || !shell.isEnabled ()) return false;
- char ch = mbcsToWcs ((char) msg.wParam);
- return ch != 0 && shell.traverseMnemonic (ch);
+ if (shell.isVisible () && shell.isEnabled ()) {
+ char ch = mbcsToWcs ((char) msg.wParam);
+ return ch != 0 && shell.translateMnemonic (ch);
+ }
+ return false;
}
boolean translateTraversal (MSG msg) {
@@ -2291,12 +2335,13 @@ public boolean traverse (int traversal) {
checkWidget ();
if (!isFocusControl () && !setFocus ()) return false;
switch (traversal) {
- case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
- case SWT.TRAVERSE_RETURN: return traverseReturn ();
- case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
- case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
+ case SWT.TRAVERSE_ESCAPE: return traverseEscape ();
+ case SWT.TRAVERSE_RETURN: return traverseReturn ();
+ case SWT.TRAVERSE_TAB_NEXT: return traverseGroup (true);
+ case SWT.TRAVERSE_TAB_PREVIOUS: return traverseGroup (false);
case SWT.TRAVERSE_ARROW_NEXT: return traverseItem (true);
- case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+ case SWT.TRAVERSE_ARROW_PREVIOUS: return traverseItem (false);
+// case SWT.TRAVERSE_MNEMONIC: return traverseMnemonic (??);
}
return false;
}
@@ -2310,8 +2355,9 @@ boolean traverseEscape () {
}
boolean traverseGroup (boolean next) {
- Control group = currentTabGroup ();
- Control [] list = menuShell ().getTabList ();
+ Control root = computeTabRoot ();
+ Control group = computeTabGroup ();
+ Control [] list = root.computeTabList ();
int length = list.length;
int index = 0;
while (index < length) {
@@ -2362,7 +2408,7 @@ boolean traverseItem (boolean next) {
boolean traverseMnemonic (char key) {
if (!isVisible () || !isEnabled ()) return false;
- return mnemonicMatch (key) && mnemonicHit ();
+ return mnemonicHit (key);
}
boolean traverseReturn () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
index 463d96b3ee..256dd4149f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -84,7 +84,6 @@ import org.eclipse.swt.graphics.*;
*/
public class Decorations extends Canvas {
-
Image image;
Menu menuBar;
Menu [] menus;
@@ -196,6 +195,14 @@ protected void checkSubclass () {
if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
}
+Control computeTabGroup () {
+ return this;
+}
+
+Control computeTabRoot () {
+ return this;
+}
+
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
@@ -262,10 +269,6 @@ void createWidget () {
hAccel = -1;
}
-Control currentTabGroup () {
- return this;
-}
-
void destroyAcceleratorTable () {
if (hAccel != 0 && hAccel != -1) OS.DestroyAcceleratorTable (hAccel);
hAccel = -1;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
index c38025257d..323e483a58 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -192,7 +192,7 @@ public String getText () {
return buffer.toString (0, length);
}
-boolean mnemonicHit () {
+boolean mnemonicHit (char key) {
return setFocus ();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
index 69ed0f3e50..82ec1d45b2 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -233,7 +233,7 @@ boolean getWrap () {
return true;
}
-boolean mnemonicHit () {
+boolean mnemonicHit (char key) {
Composite control = this.parent;
while (control != null) {
Control [] children = control._getChildren ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index f2721d4948..b1821739eb 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -539,10 +539,8 @@ public void open () {
checkWidget ();
bringToTop ();
setVisible (true);
- if (savedFocus == null) {
- setTabGroupFocus ();
- } else {
- restoreFocus ();
+ if (!restoreFocus ()) {
+ traverseGroup (true);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
index 1c2ccdda35..467d7e9870 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -457,29 +457,28 @@ public int indexOf (TabItem item) {
}
boolean mnemonicHit (char key) {
- if (!setFocus ()) return false;
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- char mnemonic = findMnemonic (items[i].getText ());
- if (mnemonic != '\0') {
- if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
- setSelection(i);
- sendEvent(SWT.Selection, new Event());
+ for (int i=0; i<items.length; i++) {
+ TabItem item = items [i];
+ if (item != null) {
+ char ch = findMnemonic (item.getText ());
+ if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
+ if (setFocus ()) {
+ setSelection (i, true);
+ return true;
}
}
}
}
- return true;
+ return false;
}
boolean mnemonicMatch (char key) {
- for (int i = 0; i < items.length; i++) {
- if (items[i] != null) {
- char mnemonic = findMnemonic (items[i].getText ());
- if (mnemonic != '\0') {
- if (Character.toUpperCase (key) == Character.toUpperCase (mnemonic)) {
- return true;
- }
+ for (int i=0; i<items.length; i++) {
+ TabItem item = items [i];
+ if (item != null) {
+ char ch = findMnemonic (item.getText ());
+ if (Character.toUpperCase (key) == Character.toUpperCase (ch)) {
+ return true;
}
}
}
@@ -557,6 +556,7 @@ boolean setTabGroupFocus () {
}
boolean setTabItemFocus () {
+ //????
Control [] path = getPath ();
for (int i=0; i<path.length; i++) {
Point size = path [i].getSize ();
@@ -580,6 +580,10 @@ boolean setTabItemFocus () {
*/
public void setSelection (int index) {
checkWidget ();
+ setSelection (index, false);
+}
+
+public void setSelection (int index, boolean notify) {
int oldIndex = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
if (oldIndex != -1) {
TabItem item = items [oldIndex];
@@ -597,6 +601,12 @@ public void setSelection (int index) {
control.setBounds (getClientArea ());
control.setVisible (true);
}
+ if (notify) {
+ Event event = new Event ();
+ event.item = item;
+ ///??? post or send
+ postEvent (SWT.Selection, event);
+ }
}
}
@@ -628,7 +638,8 @@ int widgetStyle () {
* this cannot happen by setting WS_CLIPCHILDREN.
*/
int bits = super.widgetStyle () | OS.WS_CLIPCHILDREN;
- return bits | OS.TCS_TABS /*| OS.TCS_FOCUSNEVER*/ | OS.TCS_TOOLTIPS;
+ if ((style & SWT.NO_FOCUS) != 0) bits |= OS.TCS_FOCUSNEVER;
+ return bits | OS.TCS_TABS | OS.TCS_TOOLTIPS;
}
TCHAR windowClass () {
@@ -641,7 +652,11 @@ int windowProc () {
LRESULT WM_GETDLGCODE (int wParam, int lParam) {
LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
- // ALT Key
+ /*
+ * Return DLGC_BUTTON so that mnemonics will be
+ * processed without needing to press the ALT when
+ * the tab folder has focus.
+ */
if (result != null) return result;
return new LRESULT (OS.DLGC_BUTTON);
}

Back to the top