/src/wrappers/gdk/library/gdk_region.e
Specman e | 265 lines | 103 code | 62 blank | 100 comment | 2 complexity | b12fc381982fde7c85577e780facb96f MD5 | raw file
1indexing 2 description: "GdkRegion." 3 copyright: "[ 4 Copyright (C) 2006 eiffel-libraries team, GTK+ team 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public License 8 as published by the Free Software Foundation; either version 2.1 of 9 the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301 USA 20 ]" 21class GDK_REGION 22 23inherit 24 G_STRUCT 25 redefine copy, dispose end 26 27insert 28 GDK_FILL_RULE -- redefine copy end 29 GDK_OVERLAP_TYPE -- redefine copy end 30 31creation 32 make, from_polygon, from_external_pointer, from_rectangle, copy, from_external_copy 33 34feature -- Creation 35 make is 36 -- Creates a new empty GdkRegion. 37 do 38 handle := gdk_region_new 39 end 40 41 from_polygon (some_points: ARRAY[GDK_POINT]; a_fill_rule: INTEGER) is 42 -- Creates a new GdkRegion using the polygon defined by a 43 -- number of points. `some_points': an array of GdkPoint 44 -- structs. `a_fill_rule' specifies which pixels are 45 -- included in the region when the polygon overlaps itself. 46 47 -- TODO: current implementation has to copy `some_points' 48 -- into a NATIVE_ARRAY. Implement G_ARRAY or something 49 -- similar to achieve better performance. Paolo 2006-07-02 50 require valid_fill_rule: is_valid_fill_rule (a_fill_rule) 51 local array: NATIVE_ARRAY [POINTER]; i: INTEGER; iter: ITERATOR[GDK_POINT] 52 do 53 array := array.calloc (some_points.count) 54 iter := some_points.get_new_iterator; 55 from i:=0; iter.start 56 until iter.is_off 57 loop 58 array.put(iter.item.handle, i) 59 i := i + 1 60 iter.next 61 end 62 handle := gdk_region_polygon (array.to_external,some_points.count,a_fill_rule) 63 end 64 65 from_rectangle (a_rectangle: GDK_RECTANGLE) is 66 -- Creates a new region containing the area `a_rectangle'. 67 require rectangle_not_void: a_rectangle /= Void 68 do 69 handle := gdk_region_rectangle (handle) 70 end 71 72 73 dispose is 74 -- Destroys a GdkRegion. 75 do 76 gdk_region_destroy (handle) 77 handle := default_pointer 78 end 79 80feature -- Duplication 81 82 copy (another: GDK_REGION) is 83 -- Copies region, creating an identical new region. 84 do 85 handle := gdk_region_copy (another.handle) 86 end 87 88feature {} -- Unwrapped code 89 90-- gdk_region_get_clipbox () 91 92-- void gdk_region_get_clipbox (GdkRegion *region, 93-- GdkRectangle *rectangle); 94 95-- Returns the smallest rectangle which includes the entire GdkRegion. 96-- region : a GdkRegion. 97-- rectangle : returns the smallest rectangle which includes all of region. 98-- gdk_region_get_rectangles () 99 100-- void gdk_region_get_rectangles (GdkRegion *region, 101-- GdkRectangle **rectangles, 102-- gint *n_rectangles); 103 104-- Obtains the area covered by the region as a list of rectangles. The array returned in rectangles must be freed with g_free(). 105 106-- region : a GdkRegion 107-- rectangles : return location for an array of rectangles 108-- n_rectangles : length of returned array 109-- gdk_region_empty () 110 111-- gboolean gdk_region_empty (GdkRegion *region); 112 113-- Returns TRUE if the GdkRegion is empty. 114-- region : a GdkRegion. 115-- Returns : TRUE if region is empty. 116-- gdk_region_equal () 117 118-- gboolean gdk_region_equal (GdkRegion *region1, 119-- GdkRegion *region2); 120 121-- Returns TRUE if the two regions are the same. 122-- region1 : a GdkRegion. 123-- region2 : a GdkRegion. 124-- Returns : TRUE if region1 and region2 are equal. 125-- gdk_region_point_in () 126 127-- gboolean gdk_region_point_in (GdkRegion *region, 128-- int x, 129-- int y); 130 131-- Returns TRUE if a point is in a region. 132-- region : a GdkRegion. 133-- x : the x coordinate of a point. 134-- y : the y coordinate of a point. 135-- Returns : TRUE if the point is in region. 136-- gdk_region_rect_in () 137 138-- GdkOverlapType gdk_region_rect_in (GdkRegion *region, 139-- GdkRectangle *rect); 140 141-- Tests whether a rectangle is within a region. 142-- region : a GdkRegion. 143-- rect : a GdkRectangle. 144-- Returns : GDK_OVERLAP_RECTANGLE_IN, GDK_OVERLAP_RECTANGLE_OUT, or GDK_OVERLAP_RECTANGLE_PART, depending on whether the rectangle is inside, outside, or partly inside the GdkRegion, respectively. 145 146-- gdk_region_offset () 147 148-- void gdk_region_offset (GdkRegion *region, 149-- gint dx, 150-- gint dy); 151 152-- Moves a region the specified distance. 153-- region : a GdkRegion. 154-- dx : the distance to move the region horizontally. 155-- dy : the distance to move the region vertically. 156-- gdk_region_shrink () 157 158-- void gdk_region_shrink (GdkRegion *region, 159-- gint dx, 160-- gint dy); 161 162-- Resizes a region by the specified amount. Positive values shrink the region. Negative values expand it. 163-- region : a GdkRegion. 164-- dx : the number of pixels to shrink the region horizontally. 165-- dy : the number of pixels to shrink the region vertically. 166-- gdk_region_union_with_rect () 167 168-- void gdk_region_union_with_rect (GdkRegion *region, 169-- GdkRectangle *rect); 170 171-- Sets the area of region to the union of the areas of region and rect. The resulting area is the set of pixels contained in either region or rect. 172 173-- region : a GdkRegion. 174-- rect : a GdkRectangle. 175-- gdk_region_intersect () 176 177-- void gdk_region_intersect (GdkRegion *source1, 178-- GdkRegion *source2); 179 180-- Sets the area of source1 to the intersection of the areas of source1 and source2. The resulting area is the set of pixels contained in both source1 and source2. 181 182-- source1 : a GdkRegion 183-- source2 : another GdkRegion 184-- gdk_region_union () 185 186-- void gdk_region_union (GdkRegion *source1, 187-- GdkRegion *source2); 188 189-- Sets the area of source1 to the union of the areas of source1 and source2. The resulting area is the set of pixels contained in either source1 or source2. 190 191-- source1 : a GdkRegion 192-- source2 : a GdkRegion 193-- gdk_region_subtract () 194 195-- void gdk_region_subtract (GdkRegion *source1, 196-- GdkRegion *source2); 197 198-- Subtracts the area of source2 from the area source1. The resulting area is the set of pixels contained in source1 but not in source2. 199 200-- source1 : a GdkRegion 201-- source2 : another GdkRegion 202-- gdk_region_xor () 203 204-- void gdk_region_xor (GdkRegion *source1, 205-- GdkRegion *source2); 206 207-- Sets the area of source1 to the exclusive-OR of the areas of source1 and source2. The resulting area is the set of pixels contained in one or the other of the two sources but not in both. 208 209-- source1 : a GdkRegion 210-- source2 : another GdkRegion 211 212feature -- size 213 struct_size: INTEGER is 214 external "C inline use <gtk/gtk.h>" 215 alias "sizeof(GdkRegion)" 216 end 217 218feature {} -- extnernal features 219 220 gdk_region_new: POINTER is -- GdkRegion* 221 external "C use <gdk/gdk.h>" 222 end 223 224 gdk_region_polygon (some_gdk_points: POINTER; n_points: INTEGER; a_gdkfillrule: INTEGER): POINTER is -- GdkRegion* 225 external "C use <gdk/gdk.h>" 226 end 227 228 gdk_region_copy (a_region: POINTER): POINTER is -- GdkRegion* 229 external "C use <gdk/gdk.h>" 230 end 231 232 gdk_region_rectangle (a_gdk_rectangle: POINTER): POINTER is -- GdkRegion* 233 external "C use <gdk/gdk.h>" 234 end 235 236 gdk_region_destroy (a_region: POINTER) is 237 external "C use <gdk/gdk.h>" 238 end 239 240 gdk_region_get_clipbox (a_region, a_gdk_rectangle: POINTER) is 241 external "C use <gdk/gdk.h>" 242 end 243 244 gdk_region_get_rectangles (a_region, rectangles, n_rectangles: POINTER) is 245 -- Note GdkRectangle **rectangles; gint *n_rectangles 246 external "C use <gdk/gdk.h>" 247 end 248 249 gdk_region_empty (a_region: POINTER): INTEGER is -- gboolean 250 external "C use <gdk/gdk.h>" 251 end 252 253 gdk_region_equal (a_region, another_region: POINTER): INTEGER is -- gboolean 254 external "C use <gdk/gdk.h>" 255 end 256 257 gdk_region_point_in (a_region: POINTER; an_x, an_y: INTEGER): INTEGER is -- gboolean 258 external "C use <gdk/gdk.h>" 259 end 260 261 gdk_region_rect_in (a_region, a_gdk_rectangle: POINTER): INTEGER is -- GdkOverlapType 262 external "C use <gdk/gdk.h>" 263 ensure valid_result: is_valid_overlap_type (Result) 264 end 265end