diff options
author | Silenio Quarti <silenio> | 2002-12-05 21:59:06 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2002-12-05 21:59:06 +0000 |
commit | 74c55d1ab903acf012def12d921c186e052fd81a (patch) | |
tree | 47a85e076ad4a42c9072ff6a7e8e3d07942cc914 | |
parent | f2fc2cab7787c0d8273bf8693276ad42143a775d (diff) | |
download | eclipse.platform.swt-74c55d1ab903acf012def12d921c186e052fd81a.tar.gz eclipse.platform.swt-74c55d1ab903acf012def12d921c186e052fd81a.tar.xz eclipse.platform.swt-74c55d1ab903acf012def12d921c186e052fd81a.zip |
*** empty log message ***
5 files changed, 92 insertions, 43 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java index 047e3e14de..3c82b96619 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Composite.java @@ -112,7 +112,7 @@ Control [] computeTabList () { void createHandle () { state |= CANVAS | GRAB; - if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) { + if ((style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL)) != 0) { createScrolledHandle (parent.handle); } else { createHandle (parent.handle); @@ -146,6 +146,23 @@ void draw (int control) { if ((state & CANVAS) == 0) return; if (control == scrolledHandle) { drawBackground (control, background); + Rect rect = new Rect (); + OS.GetControlBounds (scrolledHandle, rect); + Rect inset = inset (); + rect.left += inset.left; + rect.top += inset.top; + rect.right -= inset.right; + rect.bottom -= inset.bottom; + boolean drawFocus = (style & SWT.NO_FOCUS) == 0 && hooksKeys (); + boolean drawBorder = hasBorder (); + int state = OS.IsControlActive (handle) ? OS.kThemeStateActive : OS.kThemeStateInactive; + if (hasFocus ()) { + if (drawBorder) OS.DrawThemeEditTextFrame (rect, state); + if (drawFocus) OS.DrawThemeFocusRect (rect, true); + } else { + if (drawFocus) OS.DrawThemeFocusRect (rect, false); + if (drawBorder) OS.DrawThemeEditTextFrame (rect, state); + } } else { if ((style & SWT.NO_BACKGROUND) != 0) return; drawBackground (control, background); @@ -215,7 +232,16 @@ int kEventControlClick (int nextHandler, int theEvent, int userData) { int kEventControlSetFocusPart (int nextHandler, int theEvent, int userData) { int result = super.kEventControlSetFocusPart (nextHandler, theEvent, userData); if (result == OS.noErr) return result; - return ((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0 && hooksKeys ()) ? OS.noErr : result; + if (((state & CANVAS) != 0 && (style & SWT.NO_FOCUS) == 0 && hooksKeys ())) { + if (scrolledHandle != 0) { + Rect rect = new Rect (); + OS.GetControlBounds (scrolledHandle, rect); + int window = OS.GetControlOwner (scrolledHandle); + OS.InvalWindowRect (window, rect); + } + return OS.noErr; + } + return result; } boolean hooksKeys () { 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 ec95562ad0..fc9cb76844 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 @@ -87,23 +87,6 @@ void destroyWidget () { } } -Point computeSize (int wHint, int hHint, boolean changed) { - checkWidget(); - int [] outMetric = new int [1]; - OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric); - int width = 0, height = 0; - if ((style & SWT.HORIZONTAL) != 0) { - height = outMetric [0]; - width = height * 10; - } else { - width = outMetric [0]; - height = width * 10; - } - if (wHint != SWT.DEFAULT) width = wHint; - if (hHint != SWT.DEFAULT) height = hHint; - return new Point (width, height); -} - void createHandle () { Display display = getDisplay (); int actionProc = display.actionProc; 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 baa1a6581d..67254e631b 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 @@ -28,6 +28,15 @@ public Scrollable (Composite parent, int style) { public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget(); + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric); + if (horizontalBar != null) height += outMetric [0]; + if (verticalBar != null) width += outMetric [0]; + Rect inset = inset (); + x -= inset.left; + y -= inset.top; + width += inset.left + inset.right; + height += inset.top + inset.bottom; return new Rectangle (x, y, width, height); } @@ -80,6 +89,10 @@ public ScrollBar getVerticalBar () { return verticalBar; } +boolean hasBorder () { + return (style & SWT.BORDER) != 0; +} + void hookEvents () { super.hookEvents (); if ((state & CANVAS) != 0 && scrolledHandle != 0) { @@ -93,28 +106,54 @@ void hookEvents () { } } -void layoutControl () { - if ((state & CANVAS) != 0 && (horizontalBar != null || verticalBar != null)) { - int vWidth = 0, hHeight = 0; - if (horizontalBar != null && horizontalBar.getVisible ()) { - Point size = horizontalBar.computeSize (SWT.DEFAULT, SWT.DEFAULT, false); - hHeight = size.y; +boolean hooksKeys () { + return hooks (SWT.KeyDown) || hooks (SWT.KeyUp) || hooks (SWT.Traverse); +} + +Rect inset () { + if ((state & CANVAS) != 0) { + Rect rect = new Rect (); + int [] outMetric = new int [1]; + if ((style & SWT.NO_FOCUS) == 0 && hooksKeys ()) { + OS.GetThemeMetric (OS.kThemeMetricFocusRectOutset, outMetric); + rect.left += outMetric [0]; + rect.top += outMetric [0]; + rect.right += outMetric [0]; + rect.bottom += outMetric [0]; } - if (verticalBar != null && verticalBar.getVisible ()) { - Point size = verticalBar.computeSize (SWT.DEFAULT, SWT.DEFAULT, false); - vWidth = size.x; + if (hasBorder ()) { + OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric); + rect.left += outMetric [0]; + rect.top += outMetric [0]; + rect.right += outMetric [0]; + rect.bottom += outMetric [0]; } + return rect; + } + return EMPTY_RECT; +} + +void layoutControl () { + if (scrolledHandle != 0) { + int vWidth = 0, hHeight = 0; + int [] outMetric = new int [1]; + OS.GetThemeMetric (OS.kThemeMetricScrollBarWidth, outMetric); + boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible (); + boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible (); + if (isVisibleHBar) hHeight = outMetric [0]; + if (isVisibleVBar) vWidth = outMetric [0]; Rect rect = new Rect (); OS.GetControlBounds (scrolledHandle, rect); - int width = Math.max (0, rect.right - rect.left - vWidth); - int height = Math.max (0, rect.bottom - rect.top - hHeight); - if (horizontalBar != null) { - setBounds (horizontalBar.handle, 0, height, width, hHeight, true, true); + Rect inset = inset (); + int width = Math.max (0, rect.right - rect.left - vWidth - inset.left - inset.right); + int height = Math.max (0, rect.bottom - rect.top - hHeight - inset.top - inset.bottom); + if (isVisibleHBar) { + setBounds (horizontalBar.handle, inset.left, inset.top + height, width, hHeight, true, true); } - if (verticalBar != null) { - setBounds (verticalBar.handle, width, 0, vWidth, height, true, true); + if (isVisibleVBar) { + setBounds (verticalBar.handle, inset.left + width, inset.top, vWidth, height, true, true); } - setBounds (handle, 0, 0, width, height, true, true); + setBounds (handle, inset.left, inset.top, width, height, true, true); } } 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 0886318e3c..adc2cc49ea 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 @@ -277,6 +277,10 @@ public boolean getVisible () { return OS.IsWindowVisible (shellHandle); } +boolean hasBorder () { + return false; +} + void hookEvents () { super.hookEvents (); int mouseProc = display.mouseProc; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java index 708ba00105..9d50a3a5ec 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Text.java @@ -115,10 +115,8 @@ public Rectangle computeTrim (int x, int y, int width, int height) { height += rect.top + rect.bottom; int [] size = new int [1]; OS.GetThemeMetric(OS.kThemeMetricScrollBarWidth, size); - //if (horizontalBar != null) height += size [0]; - if ((style & SWT.H_SCROLL) != 0) height += size [0]; - //if (verticalBar != null) width += size [0]; - if ((style & SWT.V_SCROLL) != 0) width += size [0]; + if (horizontalBar != null) height += size [0]; + if (verticalBar != null) width += size [0]; Rect inset = inset (); x -= inset.left; y -= inset.top; @@ -185,8 +183,7 @@ void createHandle () { } ScrollBar createScrollBar (int type) { - //NOT DONE - return null; + return createStandardBar (style); } public void cut () { @@ -216,7 +213,7 @@ void draw (int control) { rect.top += inset.top; rect.right -= inset.right; rect.bottom -= inset.bottom; - if ((style & SWT.BORDER) != 0) { + if (hasBorder ()) { int state = OS.IsControlActive (handle) ? OS.kThemeStateActive : OS.kThemeStateInactive; if (hasFocus ()) { OS.DrawThemeEditTextFrame (rect, state); @@ -375,7 +372,7 @@ Rect inset () { rect.top += outMetric [0]; rect.right += outMetric [0]; rect.bottom += outMetric [0]; - if ((style & SWT.BORDER) != 0) { + if (hasBorder ()) { OS.GetThemeMetric (OS.kThemeMetricEditTextFrameOutset, outMetric); rect.left += outMetric [0]; rect.top += outMetric [0]; |