summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/cocoa
diff options
context:
space:
mode:
authorLakshmi Shanmugam <lshanmug@in.ibm.com>2012-03-27 15:53:44 +0530
committerLakshmi Shanmugam <lshanmug@in.ibm.com>2012-03-27 15:53:44 +0530
commit33615efba6b3b14d1b8ee0928c8a1f12f629315a (patch)
tree11cf6885471377dbdfb40236cdcf2618bf7d3a25 /bundles/org.eclipse.swt/Eclipse SWT/cocoa
parent6d671179e56122bf4c75081a96a44e45b06a5b27 (diff)
downloadeclipse.platform.swt-33615efba6b3b14d1b8ee0928c8a1f12f629315a.tar.gz
eclipse.platform.swt-33615efba6b3b14d1b8ee0928c8a1f12f629315a.tar.xz
eclipse.platform.swt-33615efba6b3b14d1b8ee0928c8a1f12f629315a.zip
Bug 353084-Layout problem with Shell toolbar
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/cocoa')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java57
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java6
2 files changed, 30 insertions, 33 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
index 760cd911e0..57098f5328 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
@@ -417,17 +417,6 @@ public static Shell cocoa_new (Display display, int /*long*/ handle) {
return new Shell (display, null, SWT.NO_TRIM, handle, true);
}
-Control [] _getChildren () {
- Control [] children = super._getChildren();
- if (toolBar != null) {
- Control [] newChildren = new Control [children.length + 1];
- System.arraycopy (children, 0, newChildren, 1, children.length);
- newChildren[0] = toolBar;
- children = newChildren;
- }
- return children;
-}
-
static int checkStyle (Shell parent, int style) {
style = Decorations.checkStyle (style);
style &= ~SWT.TRANSPARENT;
@@ -611,6 +600,17 @@ void closeWidget (boolean force) {
if ((force || event.doit) && !isDisposed ()) dispose ();
}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ Point size = super.computeSize (wHint, hHint, changed);
+ if (toolBar != null) {
+ if (wHint == SWT.DEFAULT && toolBar.itemCount > 0) {
+ Point tbSize = toolBar.computeSize (SWT.DEFAULT, SWT.DEFAULT);
+ size.x = Math.max (tbSize.x, size.x);
+ }
+ }
+ return size;
+}
+
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
Rectangle trim = super.computeTrim(x, y, width, height);
@@ -1179,7 +1179,9 @@ float getThemeAlpha () {
*/
public ToolBar getToolBar() {
checkWidget();
- if (toolBar == null) toolBar = new ToolBar(this, SWT.HORIZONTAL | SWT.SMOOTH, true);
+ if ((style & SWT.NO_TRIM) == 0) {
+ if (toolBar == null) toolBar = new ToolBar(this, SWT.HORIZONTAL | SWT.SMOOTH, true);
+ }
return toolBar;
}
@@ -1204,6 +1206,7 @@ void helpRequested(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
void invalidateVisibleRegion () {
resetVisibleRegion ();
+ if (toolBar != null) toolBar.resetVisibleRegion();
invalidateChildrenVisibleRegion ();
}
@@ -1253,26 +1256,6 @@ void makeKeyAndOrderFront() {
window.makeKeyAndOrderFront (null);
}
-Point minimumSize (int wHint, int Hint, boolean changed) {
- // minimumSize is used by computeSize() to figure out how big the view
- // (or, in this case, the content view of the Shell) should be.
- // An NSToolbar does not contribute to the content area, but must be
- // accounted for. If the shell has a toolbar but no other children
- // this will return the width of the toolbar and a height of 1
- 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);
- if (children[i] != toolBar) {
- height = Math.max (height, rect.y + rect.height);
- } else {
- height = Math.max (height, 1);
- }
- }
- return new Point (width, height);
-}
-
void mouseMoved(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) {
super.mouseMoved(id, sel, theEvent);
@@ -1389,6 +1372,10 @@ void releaseParent () {
void releaseWidget () {
super.releaseWidget ();
+ if (toolBar != null) {
+ toolBar.dispose();
+ toolBar = null;
+ }
if (tooltipTag != 0) {
view.window().contentView().removeToolTip(tooltipTag);
tooltipTag = 0;
@@ -1451,6 +1438,7 @@ public void removeShellListener(ShellListener listener) {
}
void reskinChildren (int flags) {
+ if (toolBar != null) toolBar.reskin(flags);
Shell [] shells = getShells ();
for (int i=0; i<shells.length; i++) {
Shell shell = shells [i];
@@ -2021,6 +2009,11 @@ boolean traverseEscape () {
return true;
}
+void updateCursorRects(boolean enabled) {
+ super.updateCursorRects(enabled);
+ if (toolBar != null) toolBar.updateCursorRects(enabled);
+};
+
void updateModal () {
// do nothing
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
index e3be309c92..a6cab7ff3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/ToolBar.java
@@ -208,7 +208,11 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget();
- if (scrollView != null) {
+ if (nsToolbar != null) {
+ NSRect outer = view.frame();
+ NSRect inner = new NSView(view.subviews().objectAtIndex(0)).frame();
+ width += (int)outer.width - (int)inner.width;
+ } else if (scrollView != null) {
NSSize size = new NSSize();
size.width = width;
size.height = height;