diff options
author | Silenio Quarti <silenio> | 2004-10-13 19:03:17 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2004-10-13 19:03:17 +0000 |
commit | 4e4985016371569b02f638ebd602eb39483feabc (patch) | |
tree | 69e495ee357ad02a14810cc4a400140d2e774f9f /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java | |
parent | 5260c59e8c29a1f3e9622ba11d34d5eb775d9540 (diff) | |
download | eclipse.platform.swt-4e4985016371569b02f638ebd602eb39483feabc.tar.gz eclipse.platform.swt-4e4985016371569b02f638ebd602eb39483feabc.tar.xz eclipse.platform.swt-4e4985016371569b02f638ebd602eb39483feabc.zip |
4735
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java | 161 |
1 files changed, 130 insertions, 31 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java index 6c8dd00648..08d27915c5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java @@ -17,7 +17,7 @@ import org.eclipse.swt.*; /** * Instances of this class represent areas of an x-y coordinate * system that are aggregates of the areas covered by a number - * of rectangles. + * of polygons. * <p> * Application code must explicitly invoke the <code>Region.dispose()</code> * method to release the operating system resources managed by each instance @@ -81,7 +81,7 @@ Region(Device device, int /*long*/ handle) { } /** - * Adds the given polygon to the collection of rectangles + * Adds the given polygon to the collection of polygons * the receiver maintains to describe its area. * * @param pointArray points that describe the polygon to merge with the receiver @@ -105,7 +105,7 @@ public void add (int[] pointArray) { } /** - * Adds the given rectangle to the collection of rectangles + * Adds the given rectangle to the collection of polygons * the receiver maintains to describe its area. * * @param rect the rectangle to merge with the receiver @@ -121,18 +121,38 @@ public void add (int[] pointArray) { public void add(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + add (rect.x, rect.y, rect.width, rect.height); +} + +/** + * Adds the given rectangle to the collection of polygons + * the receiver maintains to describe its area. + * + * @param rect the rectangle to merge with the receiver + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 3.1 + */ +public void add(int x, int y, int width, int height) { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = rect.x; - gdkRect.y = rect.y; - gdkRect.width = rect.width; - gdkRect.height = rect.height; + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; OS.gdk_region_union_with_rect(handle, gdkRect); } /** - * Adds all of the rectangles which make up the area covered - * by the argument to the collection of rectangles the receiver + * Adds all of the polygons which make up the area covered + * by the argument to the collection of polygons the receiver * maintains to describe its area. * * @param region the region to merge @@ -223,7 +243,7 @@ public boolean equals(Object object) { /** * Returns a rectangle which represents the rectangular - * union of the collection of rectangles the receiver + * union of the collection of polygons the receiver * maintains to describe its area. * * @return a bounding rectangle for the region @@ -260,7 +280,7 @@ public int hashCode() { } /** - * Intersects the given rectangle to the collection of rectangles + * Intersects the given rectangle to the collection of polygons * the receiver maintains to describe its area. * * @param rect the rectangle to intersect with the receiver @@ -278,20 +298,40 @@ public int hashCode() { public void intersect(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + intersect (rect.x, rect.y, rect.width, rect.height); +} + +/** + * Intersects the given rectangle to the collection of polygons + * the receiver maintains to describe its area. + * + * @param rect the rectangle to intersect with the receiver + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 3.1 + */ +public void intersect(int x, int y, int width, int height) { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = rect.x; - gdkRect.y = rect.y; - gdkRect.width = rect.width; - gdkRect.height = rect.height; + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; int /*long*/ rectRgn = OS.gdk_region_rectangle(gdkRect); OS.gdk_region_intersect(handle, rectRgn); OS.gdk_region_destroy(rectRgn); } /** - * Intersects all of the rectangles which make up the area covered - * by the argument to the collection of rectangles the receiver + * Intersects all of the polygons which make up the area covered + * by the argument to the collection of polygons the receiver * maintains to describe its area. * * @param region the region to intersect @@ -315,8 +355,8 @@ public void intersect(Region region) { /** * Returns <code>true</code> if the rectangle described by the - * arguments intersects with any of the rectangles the receiver - * mainains to describe its area, and <code>false</code> otherwise. + * arguments intersects with any of the polygons the receiver + * maintains to describe its area, and <code>false</code> otherwise. * * @param x the x coordinate of the origin of the rectangle * @param y the y coordinate of the origin of the rectangle @@ -341,7 +381,7 @@ public boolean intersects (int x, int y, int width, int height) { } /** * Returns <code>true</code> if the given rectangle intersects - * with any of the rectangles the receiver mainains to describe + * with any of the polygons the receiver maintains to describe * its area and <code>false</code> otherwise. * * @param rect the rectangle to test for intersection @@ -392,7 +432,7 @@ public boolean isEmpty() { } /** - * Subtracts the given polygon from the collection of rectangles + * Subtracts the given polygon from the collection of polygons * the receiver maintains to describe its area. * * @param pointArray points that describe the polygon to merge with the receiver @@ -415,7 +455,7 @@ public void subtract (int[] pointArray) { } /** - * Subtracts the given rectangle from the collection of rectangles + * Subtracts the given rectangle from the collection of polygons * the receiver maintains to describe its area. * * @param rect the rectangle to subtract from the receiver @@ -433,20 +473,40 @@ public void subtract (int[] pointArray) { public void subtract(Rectangle rect) { if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - if (rect.width < 0 || rect.height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); + subtract (rect.x, rect.y, rect.width, rect.height); +} + +/** + * Subtracts the given rectangle from the collection of polygons + * the receiver maintains to describe its area. + * + * @param rect the rectangle to subtract from the receiver + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the rectangle's width or height is negative</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 3.1 + */ +public void subtract(int x, int y, int width, int height) { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (width < 0 || height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT); GdkRectangle gdkRect = new GdkRectangle(); - gdkRect.x = rect.x; - gdkRect.y = rect.y; - gdkRect.width = rect.width; - gdkRect.height = rect.height; + gdkRect.x = x; + gdkRect.y = y; + gdkRect.width = width; + gdkRect.height = height; int /*long*/ rectRgn = OS.gdk_region_rectangle(gdkRect); OS.gdk_region_subtract(handle, rectRgn); OS.gdk_region_destroy(rectRgn); } /** - * Subtracts all of the rectangles which make up the area covered - * by the argument from the collection of rectangles the receiver + * Subtracts all of the polygons which make up the area covered + * by the argument from the collection of polygons the receiver * maintains to describe its area. * * @param region the region to subtract @@ -469,6 +529,45 @@ public void subtract(Region region) { } /** + * Translate all of the polygons the receiver maintains to describe + * its area by the specified point. + * + * @param x the x coordinate of the point to translate + * @param y the y coordinate of the point to translate + * + * @exception SWTException <ul> + * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 3.1 + */ +public void translate (int x, int y) { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + OS.gdk_region_offset (handle, x, y); +} + +/** + * Translate all of the polygons the receiver maintains to describe + * its area by the specified point. + * + * @param point the point to translate + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_NULL_ARGUMENT - if the argument is null</li> + * </ul> + * @exception SWTException <ul> + * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> + * </ul> + * + * @since 3.1 + */ +public void translate (Point pt) { + if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED); + if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); + translate (pt.x, pt.y); +} + +/** * Returns a string containing a concise, human-readable * description of the receiver. * |