diff options
author | Steve Northover <steve> | 2003-04-25 21:51:26 +0000 |
---|---|---|
committer | Steve Northover <steve> | 2003-04-25 21:51:26 +0000 |
commit | b4f322e3385e851e5b10bf1691d16547f6c2be88 (patch) | |
tree | 4c52d4afc95a13b9b16fcf610b65807aa05d3aa6 /bundles/org.eclipse.swt/Eclipse SWT | |
parent | 7a3cf5a9c985ebcd2b191d6860fdf1864c5947c4 (diff) | |
download | eclipse.platform.swt-b4f322e3385e851e5b10bf1691d16547f6c2be88.tar.gz eclipse.platform.swt-b4f322e3385e851e5b10bf1691d16547f6c2be88.tar.xz eclipse.platform.swt-b4f322e3385e851e5b10bf1691d16547f6c2be88.zip |
Display!
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT')
27 files changed, 29 insertions, 162 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 492b96bfa1..b5d4792330 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 @@ -410,7 +410,6 @@ public String getText () { Rect getInset () { if ((style & SWT.PUSH) == 0) return super.getInset(); - Display display = getDisplay (); return display.buttonInset; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java index cfe5a27a8b..0789d1cf44 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Caret.java @@ -83,7 +83,6 @@ boolean blinkCaret () { void createWidget () { super.createWidget (); - Display display = parent.getDisplay (); blinkRate = display.getCaretBlinkTime (); isVisible = true; if (parent.getCaret () == null) { @@ -150,12 +149,6 @@ public Rectangle getBounds () { return new Rectangle (x, y, width, height); } -public Display getDisplay () { - Composite parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} - /** * Returns the font that the receiver will use to paint textual information. * @@ -285,12 +278,10 @@ public boolean isVisible () { } boolean isFocusCaret () { - Display display = getDisplay (); return this == display.currentCaret; } void killFocus () { - Display display = getDisplay (); if (display.currentCaret != this) return; display.setCurrentCaret (null); if (isVisible) hideCaret (); @@ -303,7 +294,6 @@ void releaseChild () { void releaseWidget () { super.releaseWidget (); - Display display = getDisplay (); if (display.currentCaret == this) { hideCaret (); display.setCurrentCaret (null); @@ -359,7 +349,6 @@ public void setBounds (Rectangle rect) { } void setFocus () { - Display display = getDisplay (); if (display.currentCaret == this) return; display.setCurrentCaret (this); if (isVisible) showCaret (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java index d9558b3d84..d633ecbb0f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Combo.java @@ -775,7 +775,6 @@ public int getTextLimit () { void hookEvents () { super.hookEvents (); if ((style & SWT.READ_ONLY) != 0) { - Display display = getDisplay (); int commandProc = display.commandProc; int [] mask = new int [] { OS.kEventClassCommand, OS.kEventProcessCommand, @@ -837,7 +836,6 @@ public int indexOf (String string, int start) { } Rect getInset () { - Display display = getDisplay (); return display.comboInset; } 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 7b634074fb..945a5c509d 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 @@ -471,7 +471,6 @@ void createWidget () { } Color defaultBackground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_WHITE); } @@ -483,11 +482,10 @@ Font defaultFont () { short id = OS.FMGetFontFamilyFromName (family); int [] font = new int [1]; OS.FMGetFontFromFontFamilyInstance (id, style [0], font, null); - return Font.carbon_new (getDisplay (), font [0], id, style [0], size [0]); + return Font.carbon_new (display, font [0], id, style [0], size [0]); } Color defaultForeground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_BLACK); } @@ -628,7 +626,7 @@ public Color getBackground () { checkWidget(); //NOT DONE - get default colors if (background == null) return defaultBackground (); - return Color.carbon_new (getDisplay (), background); + return Color.carbon_new (display, background); } /** @@ -663,22 +661,6 @@ public Rectangle getBounds () { return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.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 (); -} - int getDrawCount (int control) { if (!isTrimHandle (control) && drawCount > 0) return drawCount; return parent.getDrawCount (control); @@ -733,7 +715,7 @@ public Color getForeground () { checkWidget(); //NOT DONE - get default colors if (foreground == null) return defaultForeground (); - return Color.carbon_new (getDisplay (), foreground); + return Color.carbon_new (display, foreground); } /** @@ -904,11 +886,10 @@ public boolean getVisible () { } boolean hasFocus () { - return this == getDisplay ().getFocusControl (); + return this == display.getFocusControl (); } int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) { - Display display = getDisplay (); switch (inRequest) { case OS.kHMSupplyContent: { int [] contentProvided = new int [] {OS.kHMContentNotProvidedDontPropagate}; @@ -982,7 +963,6 @@ int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentPro void hookEvents () { super.hookEvents (); - Display display = getDisplay (); int controlProc = display.controlProc; int [] mask = new int [] { OS.kEventClassControl, OS.kEventControlActivate, @@ -1050,7 +1030,6 @@ public int internal_new_GC (GCData data) { } if (context == 0) SWT.error (SWT.ERROR_NO_HANDLES); if (data != null) { - Display display = getDisplay (); data.device = display; data.foreground = foreground != null ? foreground : new float [] {0, 0, 0, 1}; data.background = background != null ? background : new float [] {1, 1, 1, 1}; @@ -1115,7 +1094,6 @@ public boolean isEnabled () { boolean isEnabledModal () { //NOT DONE - fails for multiple APP MODAL shells - Display display = getDisplay (); Shell [] shells = display.getShells (); for (int i = 0; i < shells.length; i++) { Shell modal = shells [i]; @@ -1141,7 +1119,6 @@ boolean isEnabledModal () { } boolean isFocusAncestor () { - Display display = getDisplay (); Control control = display.getFocusControl (); while (control != null && control != this) { control = control.parent; @@ -1278,7 +1255,6 @@ int kEventControlSetCursor (int nextHandler, int theEvent, int userData) { } int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { - Display display = getDisplay (); if (!display.ignoreFocus) { short [] part = new short [1]; OS.GetEventParameter (theEvent, OS.kEventParamControlPart, OS.typeControlPartCode, null, 2, null, part); @@ -1298,10 +1274,7 @@ int kEventMouseDown (int nextHandler, int theEvent, int userData) { OS.GetEventParameter (theEvent, OS.kEventParamClickCount, OS.typeUInt32, null, 4, null, clickCount); sendMouseEvent (SWT.MouseDown, theEvent); if (clickCount [0] == 2) sendMouseEvent (SWT.MouseDoubleClick, theEvent); - if ((state & GRAB) != 0) { - Display display = getDisplay (); - display.grabControl = this; - } + if ((state & GRAB) != 0) display.grabControl = this; /* * It is possible that the shell may be * disposed at this point. If this happens @@ -1354,7 +1327,6 @@ int kEventRawKeyDown (int nextHandler, int theEvent, int userData) { int kEventRawKeyModifiersChanged (int nextHandler, int theEvent, int userData) { int [] modifiers = new int [1]; OS.GetEventParameter (theEvent, OS.kEventParamKeyModifiers, OS.typeUInt32, null, modifiers.length * 4, null, modifiers); - Display display = getDisplay (); int lastModifiers = display.lastModifiers; int type = SWT.KeyUp; if ((modifiers [0] & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) type = SWT.KeyDown; @@ -1778,7 +1750,6 @@ void sendFocusEvent (boolean focusIn, boolean post) { if (focusIn) { shell.setActiveControl (this); } else { - Display display = shell.getDisplay (); Control control = display.getFocusControl (); if (control == null || shell != control.getShell () ) { shell.setActiveControl (null); 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 c4516e2797..fa06262889 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 @@ -300,7 +300,6 @@ Decorations menuShell () { void releaseWidget () { if (menuBar != null) menuBar.dispose (); menuBar = null; - Display display = getDisplay (); Menu [] menus = display.getMenus (this); if (menus != null) { do { @@ -332,7 +331,7 @@ boolean restoreFocus () { void saveFocus () { int window = OS.GetControlOwner (handle); - Control control = getDisplay ().getFocusControl (window); + Control control = display.getFocusControl (window); if (control != null) savedFocus = control; } 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 b16bf95995..50d528a89a 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 @@ -1219,7 +1219,7 @@ public Shell [] getShells () { Shell [] shells = WidgetTable.shells (); for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; - if (!shell.isDisposed () && this == shell.getDisplay ()) { + if (!shell.isDisposed () && this == shell.display) { count++; } } @@ -1228,7 +1228,7 @@ public Shell [] getShells () { Shell [] result = new Shell [count]; for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; - if (!shell.isDisposed () && this == shell.getDisplay ()) { + if (!shell.isDisposed () && this == shell.display) { result [index++] = shell; } } @@ -1769,7 +1769,7 @@ protected void release () { for (int i=0; i<shells.length; i++) { Shell shell = shells [i]; if (!shell.isDisposed ()) { - if (this == shell.getDisplay ()) shell.dispose (); + if (this == shell.display) shell.dispose (); } } while (readAndDispatch ()) {}; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java index 6923ce136f..a1b68680e6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/FontDialog.java @@ -231,7 +231,7 @@ public FontData open () { rgb = null; open = true; OS.FPShowHideFontPanel (); - Display display = parent.getDisplay (); + Display display = parent.display; while (!parent.isDisposed() && open) { if (!display.readAndDispatch ()) display.sleep (); }; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java index 8aacc0ce6d..55450363ce 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/List.java @@ -288,12 +288,10 @@ ScrollBar createScrollBar (int style) { } Color defaultBackground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_LIST_BACKGROUND); } Color defaultForeground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND); } @@ -664,7 +662,6 @@ public int getTopIndex () { void hookEvents () { super.hookEvents (); - Display display= getDisplay(); DataBrowserCallbacks callbacks = new DataBrowserCallbacks (); callbacks.version = OS.kDataBrowserLatestCallbacks; OS.InitDataBrowserCallbacks (callbacks); @@ -716,7 +713,6 @@ int kEventMouseDown (int nextHandler, int theEvent, int userData) { * The fix is to ignore kEvenControlSetFocusPart when the user * clicks and send the focus events from kEventMouseDown. */ - Display display = getDisplay (); Control oldFocus = display.getFocusControl (); display.ignoreFocus = true; result = OS.CallNextEventHandler (nextHandler, theEvent); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java index 764d10bd39..da88f35422 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Menu.java @@ -241,7 +241,6 @@ public void addMenuListener (MenuListener listener) { } void createHandle () { - Display display = getDisplay (); display.addMenu (this); int outMenuRef [] = new int [1]; OS.CreateNewMenu (id, 0, outMenuRef); @@ -336,12 +335,6 @@ public MenuItem getDefaultItem () { return defaultItem; } -public Display getDisplay () { - Decorations 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 @@ -529,7 +522,6 @@ public boolean getVisible () { return this == parent.menuShell ().menuBar; } if ((style & SWT.POP_UP) != 0) { - Display display = getDisplay (); Menu [] popups = display.popups; if (popups == null) return false; for (int i=0; i<popups.length; i++) { @@ -542,7 +534,6 @@ public boolean getVisible () { void hookEvents () { super.hookEvents (); - Display display = getDisplay (); int menuProc = display.menuProc; int [] mask = new int [] { OS.kEventClassMenu, OS.kEventMenuClosed, @@ -671,7 +662,6 @@ void releaseWidget () { } items = null; super.releaseWidget (); - Display display = getDisplay (); display.removeMenu (this); parent = null; cascade = defaultItem = lastTarget = null; @@ -838,7 +828,6 @@ public void setLocation (Point location) { public void setVisible (boolean visible) { checkWidget (); if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return; - Display display = getDisplay (); if (visible) { display.addPopup (this); } else { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java index 0feb3f3b07..d17647118f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/MenuItem.java @@ -242,12 +242,6 @@ public int getAccelerator () { return accelerator; } -public Display getDisplay () { - Menu 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 @@ -417,7 +411,6 @@ void releaseChild () { } void releaseWidget () { - Display display = getDisplay (); if (menu != null) { menu.releaseWidget (); menu.destroyWidget (display); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java index 28d780166c..6fe719cf75 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java @@ -70,7 +70,7 @@ public class Sash extends Control { public Sash (Composite parent, int style) { super (parent, checkStyle (style)); int cursorStyle = (style & SWT.VERTICAL) != 0 ? SWT.CURSOR_SIZEWE : SWT.CURSOR_SIZENS; - sizeCursor = new Cursor (getDisplay (), cursorStyle); + sizeCursor = new Cursor (display, cursorStyle); } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java index cf0cd00d91..4a2cfb5f63 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Scale.java @@ -130,7 +130,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) { } void createHandle () { - Display display = getDisplay (); int actionProc = display.actionProc; int [] outControl = new int [1]; int window = OS.GetControlOwner (parent.handle); 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 632a2ec20e..43bbdcab72 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 @@ -192,7 +192,6 @@ void enableWidget (boolean enabled) { } void createHandle () { - Display display = getDisplay (); int actionProc = display.actionProc; int [] outControl = new int [1]; int window = OS.GetControlOwner (parent.scrolledHandle); @@ -211,12 +210,6 @@ void deregister () { WidgetTable.remove (handle); } -public Display getDisplay () { - Scrollable parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} - int getDrawCount (int control) { return parent.getDrawCount (control); } @@ -398,7 +391,6 @@ public boolean getVisible () { void hookEvents () { super.hookEvents (); - Display display = getDisplay (); int controlProc = display.controlProc; int [] mask = new int [] { OS.kEventClassControl, OS.kEventControlDraw, 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 a5a40af484..517641d8e0 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 @@ -125,6 +125,7 @@ ScrollBar createStandardBar (int style) { ScrollBar bar = new ScrollBar (); bar.parent = this; bar.style = style; + bar.display = display; bar.handle = outControl [0]; bar.register (); bar.hookEvents (); @@ -202,7 +203,6 @@ boolean hasBorder () { void hookEvents () { super.hookEvents (); if ((state & CANVAS) != 0 && scrolledHandle != 0) { - Display display = getDisplay (); int controlProc = display.controlProc; int [] mask = new int [] { OS.kEventClassControl, OS.kEventControlDraw, 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 a4d1baa858..e5860f623e 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 @@ -101,7 +101,6 @@ import org.eclipse.swt.graphics.*; * @see SWT */ public class Shell extends Decorations { - Display display; int shellHandle, windowGroup; boolean resized; Control lastActive; @@ -312,7 +311,7 @@ public Shell (Shell parent) { * @see SWT#SYSTEM_MODAL */ public Shell (Shell parent, int style) { - this (parent != null ? parent.getDisplay () : null, parent, style, 0); + this (parent != null ? parent.display : null, parent, style, 0); } static int checkStyle (int style) { @@ -524,11 +523,6 @@ public Rectangle getBounds () { return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } -public Display getDisplay () { - if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); - return display; -} - int getDrawCount (int control) { if (!isTrimHandle (control)) return drawCount; return 0; @@ -685,7 +679,6 @@ int kEventWindowActivated (int nextHandler, int theEvent, int userData) { int [] outScope = new int [1]; OS.GetWindowActivationScope (shellHandle, outScope); if (outScope [0] == OS.kWindowActivationScopeNone) return result; - Display display = getDisplay (); display.setMenuBar (menuBar); sendEvent (SWT.Activate); if (isDisposed ()) return result; @@ -743,7 +736,6 @@ int kEventWindowDeactivated (int nextHandler, int theEvent, int userData) { //TEMPORARY CODE - should be send, but causes a GP if (!savedFocus.isDisposed ()) savedFocus.sendFocusEvent (false, true); } - Display display = getDisplay (); display.setMenuBar (null); return result; } @@ -946,7 +938,6 @@ public void setBounds (int x, int y, int width, int height) { public void setMenuBar (Menu menu) { checkWidget(); super.setMenuBar (menu); - Display display = getDisplay (); if (display.getActiveShell () == this) { display.setMenuBar (menuBar); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java index 7825875753..78f4177296 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Slider.java @@ -199,7 +199,6 @@ public Point computeSize (int wHint, int hHint, boolean changed) { } void createHandle () { - Display display = getDisplay (); int actionProc = display.actionProc; int [] outControl = new int [1]; int window = OS.GetControlOwner (parent.handle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java index 2eb1affb4e..6b744620d0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabFolder.java @@ -398,7 +398,6 @@ Point minimumSize (int wHint, int hHint, boolean flushCache) { } Rect getInset () { - Display display = getDisplay (); return display.tabFolderInset; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java index bd928f323e..efea4608de 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TabItem.java @@ -130,11 +130,6 @@ public Control getControl () { return control; } -public Display getDisplay () { - TabFolder parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} /** * Returns the receiver's parent, which must be a <code>TabFolder</code>. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java index aa7e0f8bbd..56ce2e8ebf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Table.java @@ -353,12 +353,10 @@ void createWidget () { } Color defaultBackground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_LIST_BACKGROUND); } Color defaultForeground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND); } @@ -540,7 +538,6 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, Rect itemRect = new Rect(); OS.GetDataBrowserItemPartBounds (handle, id, property, OS.kDataBrowserPropertyEnclosingPart, itemRect); OS.OffsetRect (itemRect, (short) -controlRect.left, (short) -controlRect.top); - Display display = getDisplay (); if (selected && (style & SWT.FULL_SELECTION) != 0) { gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.fillRectangle(itemRect.left, itemRect.top, itemRect.right - itemRect.left, itemRect.bottom - itemRect.top); @@ -1011,7 +1008,6 @@ int hitTestProc (int browser, int id, int property, int theRect, int mouseRect) void hookEvents () { super.hookEvents (); - Display display= getDisplay(); DataBrowserCallbacks callbacks = new DataBrowserCallbacks (); callbacks.version = OS.kDataBrowserLatestCallbacks; OS.InitDataBrowserCallbacks (callbacks); @@ -1209,7 +1205,6 @@ int kEventMouseDown (int nextHandler, int theEvent, int userData) { * The fix is to ignore kEvenControlSetFocusPart when the user * clicks and send the focus events from kEventMouseDown. */ - Display display = getDisplay (); Control oldFocus = display.getFocusControl (); display.ignoreFocus = true; result = OS.CallNextEventHandler (nextHandler, theEvent); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java index c25f3d471d..952bdb3f1f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableColumn.java @@ -203,12 +203,6 @@ public int getAlignment () { return SWT.LEFT; } -public Display getDisplay () { - Table parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} - String getNameText () { return getText (); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java index a89555f234..479094f2e6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TableItem.java @@ -194,12 +194,6 @@ public boolean getChecked () { return checked; } -public Display getDisplay () { - Table parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} - /** * Returns the foreground color that the receiver will use to draw. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java index c38674cbda..02f22f053d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/ToolItem.java @@ -371,12 +371,6 @@ public boolean getEnabled () { return (state & DISABLED) == 0; } -public Display getDisplay () { - Composite parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} - int getDrawCount (int control) { return parent.getDrawCount (control); } @@ -473,7 +467,6 @@ public int getWidth () { } int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentProvided, int ioHelpContent) { - Display display = getDisplay (); switch (inRequest) { case OS.kHMSupplyContent: { int [] contentProvided = new int [] {OS.kHMContentNotProvided}; @@ -520,7 +513,6 @@ int helpProc (int inControl, int inGlobalMouse, int inRequest, int outContentPro void hookEvents () { super.hookEvents (); - Display display = getDisplay (); int controlProc = display.controlProc; int [] mask1 = new int [] { OS.kEventClassControl, OS.kEventControlDraw, @@ -617,7 +609,6 @@ int kEventMouseDown (int nextHandler, int theEvent, int userData) { * NOTE: No mouse move events are sent while tracking. There is no * fix for this at this time. */ - Display display = getDisplay (); display.grabControl = null; display.runDeferredEvents (); tracking = false; @@ -1050,7 +1041,6 @@ void updateImage () { void updateArrow () { if (arrowCIcon != 0) destroyCIcon (arrowCIcon); arrowCIcon = 0; - Display display = getDisplay (); Image image = new Image (display, 7, 4); GC gc = new GC (image); int startX = 0, startY = 0; @@ -1062,7 +1052,7 @@ void updateArrow () { ImageData data = image.getImageData (); data.transparentPixel = 0xFFFFFFFF; image.dispose (); - image = new Image (getDisplay (), data, data.getTransparencyMask()); + image = new Image (display, data, data.getTransparencyMask()); arrowCIcon = createCIcon (image); image.dispose (); ControlButtonContentInfo inContent = new ControlButtonContentInfo (); @@ -1090,7 +1080,6 @@ void updateText () { GC gc = new GC (parent); Point size = gc.stringExtent (text); gc.dispose (); - Display display = getDisplay (); Image image = new Image (display, size.x, size.y); gc = new GC (image); gc.setFont (font); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java index 5d6e46c440..5b2f72898f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tracker.java @@ -36,7 +36,6 @@ import org.eclipse.swt.events.*; */ public class Tracker extends Widget { Control parent; - Display display; boolean tracking, stippled; Rectangle [] rectangles, proportions; int cursorOrientation = SWT.NONE; @@ -76,7 +75,6 @@ public class Tracker extends Widget { public Tracker (Composite parent, int style) { super (parent, checkStyle (style)); this.parent = parent; - display = parent.getDisplay (); } /** @@ -223,10 +221,6 @@ void drawRectangles () { } } -public Display getDisplay () { - return display; -} - /** * Returns the bounds that are being drawn, expressed relative to the parent * widget. If the parent is a <code>Display</code> then these are screen diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java index a0e3aa278e..cda0cc976e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Tree.java @@ -329,12 +329,10 @@ void createWidget () { } Color defaultBackground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_LIST_BACKGROUND); } Color defaultForeground () { - Display display = getDisplay (); return display.getSystemColor (SWT.COLOR_LIST_FOREGROUND); } @@ -411,7 +409,6 @@ int drawItemProc (int browser, int id, int property, int itemState, int theRect, } Point extent = gc.stringExtent (item.text); if ((itemState & OS.kDataBrowserItemIsSelected) != 0) { - Display display = getDisplay (); gc.setForeground (display.getSystemColor (SWT.COLOR_LIST_SELECTION_TEXT)); gc.setBackground (display.getSystemColor (SWT.COLOR_LIST_SELECTION)); gc.fillRectangle (x - 1, y, extent.x + 2, height); @@ -690,7 +687,6 @@ int hitTestProc (int browser, int id, int property, int theRect, int mouseRect) void hookEvents () { super.hookEvents (); - Display display= getDisplay(); DataBrowserCallbacks callbacks = new DataBrowserCallbacks (); callbacks.version = OS.kDataBrowserLatestCallbacks; OS.InitDataBrowserCallbacks (callbacks); @@ -903,7 +899,6 @@ int kEventMouseDown (int nextHandler, int theEvent, int userData) { * The fix is to ignore kEvenControlSetFocusPart when the user * clicks and send the focus events from kEventMouseDown. */ - Display display = getDisplay (); Control oldFocus = display.getFocusControl (); display.ignoreFocus = true; result = OS.CallNextEventHandler (nextHandler, theEvent); @@ -941,6 +936,7 @@ void releaseWidget () { item.releaseResources (); } } + items = null; super.releaseWidget (); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java index fb4bcfefb8..0e8dea3ad8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/TreeItem.java @@ -277,12 +277,6 @@ public boolean getChecked () { return checked; } -public Display getDisplay () { - Tree parent = this.parent; - if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED); - return parent.getDisplay (); -} - /** * Returns <code>true</code> if the receiver is expanded, * and false otherwise. 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 ee0503985c..69282fae73 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 @@ -50,6 +50,7 @@ import org.eclipse.swt.events.*; */ public abstract class Widget { int style, state; + Display display; EventTable eventTable; Object data; @@ -113,6 +114,7 @@ public Widget (Widget parent, int style) { checkSubclass (); checkParent (parent); this.style = style; + display = parent.display; } int actionProc (int theControl, int partCode) { @@ -197,8 +199,7 @@ void checkOrientation (Widget parent) { 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); + parent.checkWidget (); } /** @@ -257,8 +258,10 @@ protected void checkSubclass () { * </ul> */ protected void checkWidget () { - if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); - if (isDisposed ()) error (SWT.ERROR_WIDGET_DISPOSED); + Display display = this.display; + if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); + if (display.thread != Thread.currentThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); + if ((state & DISPOSED) != 0) error (SWT.ERROR_WIDGET_DISPOSED); } int colorProc (int inControl, int inMessage, int inDrawDepth, int inDrawInColor) { @@ -440,7 +443,6 @@ public void dispose () { */ if (isDisposed()) return; if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS); - Display display = getDisplay (); releaseChild (); releaseWidget (); destroyWidget (display); @@ -506,7 +508,6 @@ void error (int code) { } boolean filters (int eventType) { - Display display = getDisplay (); return display.filters (eventType); } @@ -621,7 +622,11 @@ public Object getData (String key) { * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ -public abstract Display getDisplay (); +public Display getDisplay () { + Display display = this.display; + if (display == null) error (SWT.ERROR_WIDGET_DISPOSED); + return display; +} String getName () { String string = getClass ().getName (); @@ -1036,6 +1041,7 @@ void releaseChild () { void releaseHandle () { state |= DISPOSED; + display = null; } void releaseResources () { @@ -1146,7 +1152,6 @@ void sendEvent (int eventType, Event event) { } void sendEvent (int eventType, Event event, boolean send) { - Display display = getDisplay (); if (eventTable == null && !display.filters (eventType)) { return; } @@ -1358,7 +1363,6 @@ void setInputState (Event event, short button, int chord, int modifiers) { case SWT.KeyDown: case SWT.Traverse: { if (event.keyCode != 0 || event.character != 0) return; - Display display = getDisplay (); int lastModifiers = display.lastModifiers; if ((modifiers & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) { event.stateMask &= ~SWT.SHIFT; @@ -1384,7 +1388,6 @@ void setInputState (Event event, short button, int chord, int modifiers) { } case SWT.KeyUp: { if (event.keyCode != 0 || event.character != 0) return; - Display display = getDisplay (); int lastModifiers = display.lastModifiers; if ((modifiers & OS.shiftKey) == 0 && (lastModifiers & OS.shiftKey) != 0) { event.stateMask |= SWT.SHIFT; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java index 8c0898acf9..c63a5682d9 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java @@ -167,8 +167,7 @@ protected void checkSubclass () { */ void checkParent (Shell 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); + parent.checkWidget (); } /** |