summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes <krbarnes>2009-10-01 18:05:43 +0000
committerKevin Barnes <krbarnes>2009-10-01 18:05:43 +0000
commit670729bfb4582fa29fa221faed226712a0baf256 (patch)
treedea96690710e79690ae753d50f20b2c4a0212aac
parent11c2e30ca1a299f6ffb69daaed9de9feb2653341 (diff)
downloadeclipse.platform.swt-670729bfb4582fa29fa221faed226712a0baf256.tar.gz
eclipse.platform.swt-670729bfb4582fa29fa221faed226712a0baf256.tar.xz
eclipse.platform.swt-670729bfb4582fa29fa221faed226712a0baf256.zip
revert
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java61
1 files changed, 23 insertions, 38 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
index c06b1b2ae0..f07a52ab39 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
@@ -50,6 +50,7 @@ public class CCombo extends Composite {
Text text;
List list;
int visibleItemCount = 5;
+ Shell popup;
Button arrow;
boolean hasFocus;
Listener listener, filter;
@@ -102,7 +103,7 @@ public CCombo (Composite parent, int style) {
listener = new Listener () {
public void handleEvent (Event event) {
if (isDisposed ()) return;
- if (getPopup() == event.widget) {
+ if (popup == event.widget) {
popupEvent (event);
return;
}
@@ -360,10 +361,9 @@ void comboEvent (Event event) {
notifyListeners(SWT.Dispose, event);
event.type = SWT.None;
- Shell popup = getPopup();
if (popup != null && !popup.isDisposed ()) {
list.removeListener (SWT.Dispose, listener);
- list.dispose ();
+ popup.dispose ();
}
Shell shell = getShell ();
shell.removeListener (SWT.Deactivate, listener);
@@ -432,30 +432,24 @@ public void copy () {
checkWidget ();
text.copy ();
}
+void createPopup(String[] items, int selectionIndex) {
+ // create shell and list
+ popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP);
+ int style = getStyle ();
+ int listStyle = SWT.SINGLE | SWT.V_SCROLL;
+ if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
+ if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
+ if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
+ list = new List (popup, listStyle);
+ if (font != null) list.setFont (font);
+ if (foreground != null) list.setForeground (foreground);
+ if (background != null) list.setBackground (background);
+
+ int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
+ for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
+ int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose};
+ for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
-void createPopup(String[] items, int selectionIndex) {
- Shell popup = getPopup();
- if (popup == null) {
- // create shell and list
- popup = new Shell (getShell (), SWT.NO_TRIM | SWT.ON_TOP);
- getShell().setData("ccombolist", popup);
- }
- if (list == null) {
- int style = getStyle ();
- int listStyle = SWT.SINGLE | SWT.V_SCROLL;
- if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
- if ((style & SWT.RIGHT_TO_LEFT) != 0) listStyle |= SWT.RIGHT_TO_LEFT;
- if ((style & SWT.LEFT_TO_RIGHT) != 0) listStyle |= SWT.LEFT_TO_RIGHT;
- list = new List (popup, listStyle);
- if (font != null) list.setFont (font);
- if (foreground != null) list.setForeground (foreground);
- if (background != null) list.setBackground (background);
-
- int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
- for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
- int [] listEvents = {SWT.MouseUp, SWT.Selection, SWT.Traverse, SWT.KeyDown, SWT.KeyUp, SWT.FocusIn, SWT.Dispose};
- for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
- }
if (items != null) list.setItems (items);
if (selectionIndex != -1) list.setSelection (selectionIndex);
}
@@ -519,7 +513,6 @@ public void deselectAll () {
}
void dropDown (boolean drop) {
if (drop == isDropped ()) return;
- Shell popup = getPopup();
if (!drop) {
popup.setVisible (false);
if (!isDisposed () && isFocusControl()) {
@@ -544,7 +537,6 @@ void dropDown (boolean drop) {
int itemHeight = list.getItemHeight () * itemCount;
Point listSize = list.computeSize (SWT.DEFAULT, itemHeight, false);
list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
- list.moveAbove(null);
int index = list.getSelectionIndex ();
if (index != -1) list.setTopIndex (index);
@@ -710,10 +702,6 @@ public boolean getListVisible () {
public Menu getMenu() {
return text.getMenu();
}
-Shell getPopup() {
- Shell shell = getShell();
- return (Shell)shell.getData("ccombolist");
-}
/**
* Returns a <code>Point</code> whose x coordinate is the start
* of the selection in the receiver's text field, and whose y
@@ -1007,11 +995,11 @@ void initAccessible() {
});
}
boolean isDropped () {
- return getPopup().getVisible ();
+ return popup.getVisible ();
}
public boolean isFocusControl () {
checkWidget();
- if (text.isFocusControl () || arrow.isFocusControl () || list.isFocusControl () || getPopup().isFocusControl ()) {
+ if (text.isFocusControl () || arrow.isFocusControl () || list.isFocusControl () || popup.isFocusControl ()) {
return true;
}
return super.isFocusControl ();
@@ -1028,7 +1016,6 @@ void internalLayout (boolean changed) {
void listEvent (Event event) {
switch (event.type) {
case SWT.Dispose:
- Shell popup = getPopup();
if (getShell () != popup.getParent ()) {
String[] items = list.getItems ();
int selectionIndex = list.getSelectionIndex ();
@@ -1181,7 +1168,7 @@ public void redraw () {
super.redraw();
text.redraw();
arrow.redraw();
- if (getPopup().isVisible()) list.redraw();
+ if (popup.isVisible()) list.redraw();
}
public void redraw (int x, int y, int width, int height, boolean all) {
super.redraw(x, y, width, height, true);
@@ -1382,7 +1369,6 @@ public void setEditable (boolean editable) {
}
public void setEnabled (boolean enabled) {
super.setEnabled(enabled);
- Shell popup = getPopup();
if (popup != null) popup.setVisible (false);
if (text != null) text.setEnabled(enabled);
if (arrow != null) arrow.setEnabled(enabled);
@@ -1583,7 +1569,6 @@ public void setVisible (boolean visible) {
*/
if (isDisposed ()) return;
// TEMPORARY CODE
- Shell popup = getPopup();
if (popup == null || popup.isDisposed ()) return;
if (!visible) popup.setVisible (false);
}