1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
/* -*- C -*- */ 
class GDK2.Region; 
 
//! Region information. 
 
%{ 
static void return_gdkregion( int n, void *r ) 
{ 
  struct object *o; 
  if( n ) 
    pgtk2_pop_n_elems( n ); 
  o = fast_clone_object( pgdk2_region_program ); 
  ((struct object_wrapper *)o->storage)->obj = r; 
  push_object( o ); 
} 
%} 
 
void create() 
//! Create a new (empty) region 
//! 
//! NOIMG 
{ 
  pgtk2_verify_setup(); 
  pgtk2_verify_not_inited(); 
  THIS->obj = (void *)gdk_region_new(); 
  pgtk2_pop_n_elems(args); 
} 
 
void destroy() 
{ 
  if( THIS->obj && THIS->owned ) 
    gdk_region_destroy((GdkRegion *)THIS->obj); 
  pgtk2_pop_n_elems(args); 
  push_int(0); 
} 
 
int equal(GDK2.Region victim) 
//! Return true if the region used as an argument is equal to the 
//! current region. Also available as a==b when a is a region. 
{ 
  struct object *o; 
  GdkRegion *r; 
  get_all_args("equal",args,"%o",&o); 
  r=get_gdkobject(o,region); 
  if (!r) { 
    pgtk2_pop_n_elems(args); 
    push_int(0); 
    return; 
  } else { 
    int eq=gdk_region_equal((GdkRegion *)THIS->obj,r); 
    pgtk2_pop_n_elems(args); 
    push_int(eq); 
  } 
} 
 
int point_in(int x, int y) 
//! Returns true if the given point resides in the given region 
{ 
  INT_TYPE x, y; 
  get_all_args( "point_in", args, "%i%i", &x, &y ); 
  pgtk2_pop_n_elems(args); 
  push_int( gdk_region_point_in( (GdkRegion *)THIS->obj, x, y ) ); 
} 
 
int rect_in(GDK2.Rectangle r) 
//! Returns true if the given rectangle resides inside the given region 
{ 
  struct object *o; 
  GdkRectangle *r; 
  get_all_args("rect_in",args,"%o",&o); 
  if (!(r=get_gdkobject(o,rectangle))) { 
    Pike_error("Bad argument 1 to GDK2.rect_in( GDK2.Rectangle r )\n"); 
  } else { 
    int b=gdk_region_rect_in((GdkRegion *)THIS->obj,r); 
    pgtk2_pop_n_elems(args); 
    push_int(b); 
  } 
} 
 
void offset(int dx, int dy) 
//! Offset(move) the region by dx,dy pixels. 
{ 
  INT_TYPE dx, dy; 
  get_all_args( "offset", args, "%i%i", &dx, &dy ); 
  gdk_region_offset( (GdkRegion *)THIS->obj, dx, dy ); 
  RETURN_THIS(); 
} 
 
 
void shrink(int dx, int dy) 
//! reduces the size of a region by a 
//! specified amount.  Positive values shrink the size of the 
//! region, and negative values expand the region. 
{ 
  INT_TYPE dx, dy; 
  get_all_args( "shrink", args, "%i%i", &dx, &dy ); 
  gdk_region_shrink( (GdkRegion *)THIS->obj, dx, dy ); 
  RETURN_THIS(); 
} 
 
GDK2.Region union(GDK2.Region victim) 
//! Computes the union of the given rectangle or region and the region.  
//! Also available as region | rectangle, region | region, region + 
//! region and region + rectangle. 
{ 
  struct object *o; 
  void *v; 
  get_all_args( "union", args, "%o", &o ); 
  if( (v = get_gdkobject(o, rectangle )) ) 
    gdk_region_union_with_rect( (GdkRegion *)THIS->obj, v); 
  else if( (v=get_gdkobject(o, region )) ) 
    gdk_region_union( (GdkRegion *)THIS->obj, v); 
  else 
    Pike_error("Bad argument to union: Not Region or Rectangle\n"); 
  RETURN_THIS(); 
} 
 
GDK2.Region intersect(GDK2.Region victim) 
//! Computes the intersection of the given region and the region. Also 
//! available as region & region 
{ 
  struct object *o; 
  void *v; 
  get_all_args( "intersect", args, "%o", &o ); 
  if( (v=get_gdkobject(o, region )) ) { 
    gdk_region_union( (GdkRegion *)THIS->obj, v); 
  } else { 
    Pike_error("Bad argument to intersect: Not a GDK2.Region object\n"); 
  } 
  RETURN_THIS(); 
} 
 
GDK2.Region subtract(GDK2.Region victim) 
//! Computes the difference of the given region and the region. 
//! Also available as region - region 
{ 
  struct object *o; 
  void *v; 
  get_all_args( "subtract", args, "%o", &o ); 
  if( (v=get_gdkobject(o, region )) ) { 
    gdk_region_subtract( (GdkRegion *)THIS->obj, v); 
  } else { 
    Pike_error("Bad argument to subtract: Not a GDK2.Region object\n"); 
  } 
  RETURN_THIS(); 
} 
 
GDK2.Region xor(GDK2.Region victim) 
//! Computes the exlusive or of the given region and the region. 
//! Also available as region ^ region 
{ 
  struct object *o; 
  void *v; 
  get_all_args( "xor", args, "%o", &o ); 
  if( (v=get_gdkobject(o, region )) ) { 
    gdk_region_xor( (GdkRegion *)THIS->obj, v); 
  } else { 
    Pike_error("Bad argument to xor: Not a GDK2.Region object\n"); 
  } 
  RETURN_THIS(); 
}