/src/wrappers/gdk/library/gdk_region.e

http://github.com/tybor/Liberty · Specman e · 265 lines · 103 code · 62 blank · 100 comment · 2 complexity · b12fc381982fde7c85577e780facb96f MD5 · raw file

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