diff options
author | Veronika Irvine | 2003-10-09 11:58:06 +0000 |
---|---|---|
committer | Veronika Irvine | 2003-10-09 11:58:06 +0000 |
commit | 6ed06d4c1619dd61479299f848e5b573eab4a4a7 (patch) | |
tree | 8b318778031ac6caeb9c870622606b37cf1b038f | |
parent | 49e73f5b7d0a2b3e9e6335b7001ff82f5b999b0a (diff) | |
download | eclipse.platform.swt-6ed06d4c1619dd61479299f848e5b573eab4a4a7.tar.gz eclipse.platform.swt-6ed06d4c1619dd61479299f848e5b573eab4a4a7.tar.xz eclipse.platform.swt-6ed06d4c1619dd61479299f848e5b573eab4a4a7.zip |
*** empty log message ***
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Shell.java | 140 |
1 files changed, 63 insertions, 77 deletions
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 e44007a5f7..b269d1b658 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 @@ -104,8 +104,8 @@ public class Shell extends Decorations { int shellHandle, windowGroup; boolean resized; Control lastActive; - int clipRgn; - Rect clipRect; + Region region; + Rect rgnRect; /** * Constructs a new instance of this class. This is equivalent @@ -392,7 +392,7 @@ void closeWidget () { public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget(); Rectangle trim = super.computeTrim (x, y, width, height); - if (clipRgn == 0) { + if (region == null) { Rect rect = new Rect (); OS.GetWindowStructureWidths (shellHandle, rect); trim.x -= rect.left; @@ -532,36 +532,6 @@ public Rectangle getBounds () { return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); } -/** - * Sets the region managed by the argument to the current - * shape of the shell. - * - * @param region the region to fill with the clipping region - * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the region is null</li> - * </ul> - * @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> - * - * @since 3.0 - * - */ -public void getClipping (Region region) { - checkWidget (); - if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); - int hRegion = region.handle; - if (clipRgn != 0) { - OS.CopyRgn(clipRgn, hRegion); - } else { - Rect rect = new Rect (); - OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); - OS.SetRectRgn(hRegion, (short) 0, (short) 0, (short) (rect.right - rect.left), (short) (rect.bottom - rect.top)); - } -} - int getDrawCount (int control) { if (!isTrimHandle (control)) return drawCount; return 0; @@ -612,6 +582,24 @@ float [] getParentBackground () { return null; } +/** + * Returns the region that defines the shape of the shell. + * + * @return the region that defines the shape of the shell + * + * @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> + * + * @since 3.0 + * + */ +public Region getRegion () { + checkWidget (); + return region; +} + public Shell getShell () { checkWidget(); return this; @@ -746,9 +734,9 @@ int kEventWindowBoundsChanged (int nextHandler, int theEvent, int userData) { layoutControl (false); sendEvent (SWT.Resize); if (layout != null) layout.layout (this, false); - if (clipRgn != 0) { - OS.GetEventParameter (theEvent, OS.kEventParamCurrentBounds, OS.typeQDRectangle, null, Rect.sizeof, null, clipRect); - OS.SetRect (clipRect, (short) 0, (short) 0, (short) (clipRect.right - clipRect.left), (short) (clipRect.bottom - clipRect.top)); + if (region != null) { + OS.GetEventParameter (theEvent, OS.kEventParamCurrentBounds, OS.typeQDRectangle, null, Rect.sizeof, null, rgnRect); + OS.SetRect (rgnRect, (short) 0, (short) 0, (short) (rgnRect.right - rgnRect.left), (short) (rgnRect.bottom - rgnRect.top)); OS.ReshapeCustomWindow (shellHandle); } } @@ -804,17 +792,17 @@ int kEventWindowExpanded (int nextHandler, int theEvent, int userData) { int kEventWindowGetRegion (int nextHandler, int theEvent, int userData) { int result = super.kEventWindowGetRegion (nextHandler, theEvent, userData); if (result == OS.noErr) return result; - if (clipRgn == 0) return OS.eventNotHandledErr; + if (region == null) return OS.eventNotHandledErr; short [] regionCode = new short [1]; OS.GetEventParameter (theEvent, OS.kEventParamWindowRegionCode , OS.typeWindowRegionCode , null, 2, null, regionCode); - int [] region = new int [1]; - OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle , OS.typeQDRgnHandle , null, 4, null, region); - int hRegion = region [0]; + int [] temp = new int [1]; + OS.GetEventParameter (theEvent, OS.kEventParamRgnHandle , OS.typeQDRgnHandle , null, 4, null, temp); + int hRegion = temp [0]; switch (regionCode [0]) { case OS.kWindowContentRgn: case OS.kWindowStructureRgn: - OS.RectRgn (hRegion, clipRect); - OS.SectRgn (hRegion, clipRgn, hRegion); + OS.RectRgn (hRegion, rgnRect); + OS.SectRgn (hRegion, region.handle, hRegion); /* * Bug in the Macintosh. In kEventWindowGetRegion, * Carbon assumes the origin of the Region is (0, 0) @@ -852,7 +840,7 @@ int kEventWindowHidden (int nextHandler, int theEvent, int userData) { int kEventWindowHitTest (int nextHandler, int theEvent, int userData) { int result = super.kEventWindowHitTest (nextHandler, theEvent, userData); if (result == OS.noErr) return result; - if (clipRgn == 0) return OS.eventNotHandledErr; + if (region == null) return OS.eventNotHandledErr; org.eclipse.swt.internal.carbon.Point pt = new org.eclipse.swt.internal.carbon.Point (); int sizeof = org.eclipse.swt.internal.carbon.Point.sizeof; OS.GetEventParameter (theEvent, OS.kEventParamMouseLocation, OS.typeQDPoint, null, sizeof, null, pt); @@ -860,8 +848,8 @@ int kEventWindowHitTest (int nextHandler, int theEvent, int userData) { OS.GetWindowBounds (shellHandle, (short) OS.kWindowContentRgn, rect); OS.SetPt (pt, (short) (pt.h - rect.left), (short) (pt.v - rect.top)); int rgn = OS.NewRgn (); - OS.RectRgn (rgn, clipRect); - OS.SectRgn (rgn, clipRgn, rgn); + OS.RectRgn (rgn, rgnRect); + OS.SectRgn (rgn, region.handle, rgn); short inData = OS.PtInRgn (pt, rgn) ? OS.wInContent: OS.wNoHit; OS.DisposeRgn (rgn); OS.SetEventParameter (theEvent, OS.kEventParamWindowDefPart, OS.typeWindowDefPartCode, 2, new short [] {inData}); @@ -944,6 +932,7 @@ void releaseWidget () { display.updateQuitMenu (); windowGroup = 0; lastActive = null; + region = null; } /** @@ -1046,38 +1035,6 @@ public void setBounds (int x, int y, int width, int height) { OS.SetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rect); } -/** - * Sets the shape of the shell to the region specified - * by the argument. A null region will restore the default shape. - * Shell must be created with the style SWT.NO_TRIM. - * - * @param rect the clipping region. - * - * @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> - * - * @since 3.0 - * - */ -public void setClipping(Region region) { - checkWidget (); - if ((style & SWT.NO_TRIM) == 0) return; - if (clipRgn != 0) OS.DisposeRgn (clipRgn); - if (region == null) { - clipRgn = 0; - clipRect = null; - } else { - if (clipRect == null) clipRect = new Rect (); - OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, clipRect); - OS.SetRect (clipRect, (short) 0, (short) 0, (short) (clipRect.right - clipRect.left), (short) (clipRect.bottom - clipRect.top)); - clipRgn = OS.NewRgn (); - OS.CopyRgn (region.handle, clipRgn); - } - OS.ReshapeCustomWindow (shellHandle); -} - public void setMenuBar (Menu menu) { checkWidget(); super.setMenuBar (menu); @@ -1135,6 +1092,35 @@ public void setMinimized (boolean minimized) { OS.CollapseWindow (shellHandle, minimized); } +/** + * Sets the shape of the shell to the region specified + * by the argument. A null region will restore the default shape. + * Shell must be created with the style SWT.NO_TRIM. + * + * @param rgn the region that defines the shape of the shell + * + * @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> + * + * @since 3.0 + * + */ +public void setRegion (Region region) { + checkWidget (); + if ((style & SWT.NO_TRIM) == 0) return; + if (region == null) { + rgnRect = null; + } else { + if (rgnRect == null) rgnRect = new Rect (); + OS.GetWindowBounds (shellHandle, (short) OS.kWindowStructureRgn, rgnRect); + OS.SetRect (rgnRect, (short) 0, (short) 0, (short) (rgnRect.right - rgnRect.left), (short) (rgnRect.bottom - rgnRect.top)); + } + this.region = region; + OS.ReshapeCustomWindow (shellHandle); +} + public void setSize (int width, int height) { checkWidget(); width = Math.max (0, width); |