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
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
/* -*- C -*- */ 
class GDK2.GC; 
inherit G.Object; 
 
//! A GC, or Graphics Context, is used for most low-level drawing operations. 
//! <p> 
//! As an example, the foreground color, background color, and drawing 
//! function is stored in the GC.</p> 
//! 
//! NOIMG 
 
void create(GTK2.Widget|GDK2.Drawable context, mapping|void attributes) 
//! The argument is either a W(Widget) or a GDK2(Drawable) in 
//! which the gc will be valid. 
{ 
  struct object *o; 
  GdkGC *gc; 
  GdkGCValues values; 
  int have_values=0; 
  struct mapping *m=NULL; 
  struct svalue *sv; 
 
  pgtk2_verify_setup(); 
  pgtk2_verify_not_inited(); 
  get_all_args(NULL,args,"%o.%m",&o,&m); 
  memset(&values,0,sizeof(values));  
 
  if (m!=NULL) { 
    have_values=1; 
 
#define VALUE(X,Y)                                      \ 
    if ( (sv=simple_mapping_string_lookup(m,#X)) ) {    \ 
      values.X=sv->u.integer;                           \ 
      have_values|=Y;                                   \ 
    } 
 
    VALUE(graphics_exposures,GDK_GC_EXPOSURES); 
    VALUE(subwindow_mode,GDK_GC_SUBWINDOW); 
    VALUE(join_style,GDK_GC_JOIN_STYLE); 
    VALUE(cap_style,GDK_GC_CAP_STYLE); 
    VALUE(line_style,GDK_GC_LINE_STYLE); 
    VALUE(line_width,GDK_GC_LINE_WIDTH); 
    VALUE(clip_x_origin,GDK_GC_CLIP_X_ORIGIN); 
    VALUE(clip_y_origin,GDK_GC_CLIP_Y_ORIGIN); 
    VALUE(ts_x_origin,GDK_GC_TS_X_ORIGIN); 
    VALUE(ts_y_origin,GDK_GC_TS_Y_ORIGIN); 
    VALUE(fill,GDK_GC_FILL); 
    VALUE(function,GDK_GC_FUNCTION); 
    if (g_type_is_a(G_TYPE_FROM_INSTANCE(get_gobject(o)), GDK_TYPE_DRAWABLE)) 
      gc=gdk_gc_new_with_values(GDK_WINDOW(get_gobject(o)), 
                                &values,have_values); 
    else 
      gc=gdk_gc_new_with_values(GTK_WIDGET(get_gobject(o))->window, 
                                &values,have_values); 
  } else { 
    if (g_type_is_a(G_TYPE_FROM_INSTANCE(get_gobject(o)), GDK_TYPE_DRAWABLE)) 
      gc=gdk_gc_new(GDK_WINDOW(get_gobject(o))); 
    else 
      gc=gdk_gc_new(GTK_WIDGET(get_gobject(o))->window); 
  } 
  THIS->obj=G_OBJECT(gc); 
  pgtk2_pop_n_elems(args); 
  pgtk2__init_this_object(); 
} 
 
GDK2.Screen get_screen(); 
//! Gets the screen. 
 
mapping(string:mixed) get_values() 
//! Get all (or rather most) values from the GC. 
//! Even though GdkGCValues contains a GdkFont object, we won't return 
//! this value because GdkFont is deprecated.  The Pango methods should 
//! be used instead. 
{ 
  GdkGCValues v; 
  struct svalue *osp; 
  if (args) 
    pgtk2_pop_n_elems(args); 
 
  gdk_gc_get_values(GDK_GC(THIS->obj),&v); 
 
  osp=Pike_sp; 
  ref_push_string(_STR("join_style"));  push_int(v.join_style); 
  ref_push_string(_STR("cap_style"));   push_int(v.cap_style); 
  ref_push_string(_STR("line_style"));  push_int(v.line_style); 
  ref_push_string(_STR("line_width"));  push_int(v.line_width); 
  ref_push_string(_STR("clip_x_origin"));  push_int(v.clip_x_origin); 
  ref_push_string(_STR("clip_y_origin"));  push_int(v.clip_y_origin); 
  ref_push_string(_STR("ts_x_origin"));  push_int(v.ts_x_origin); 
  ref_push_string(_STR("ts_y_origin"));  push_int(v.ts_y_origin); 
  ref_push_string(_STR("subwindow_mode"));  push_int(v.subwindow_mode); 
  ref_push_string(_STR("clip_mask"));  push_gobject(v.clip_mask); 
  ref_push_string(_STR("stipple"));    push_gobject(v.stipple); 
  ref_push_string(_STR("tile"));       push_gobject(v.tile); 
/*push_text("font");       push_gdkobject(v.font,font,0); */ 
 
/*if (v.font)  g_object_ref(v.font); */ 
  if (v.tile) 
    g_object_ref(v.tile); 
  if (v.stipple) 
    g_object_ref(v.stipple); 
  if (v.clip_mask) 
    g_object_ref(v.clip_mask); 
 
  ref_push_string(_STR("fill"));  push_int(v.fill); 
  ref_push_string(literal_function_string);  push_int(v.function); 
  { 
    GdkColor *f,*b; 
    f=g_malloc(sizeof(GdkColor)); 
    if (f==NULL) 
      SIMPLE_OUT_OF_MEMORY_ERROR("get_values",sizeof(GdkColor)); 
    b=g_malloc(sizeof(GdkColor)); 
    if (b==NULL) 
    { 
      g_free(f); 
      SIMPLE_OUT_OF_MEMORY_ERROR("get_values",sizeof(GdkColor)); 
    } 
    *f=v.foreground; 
    *b=v.background; 
    ref_push_string(_STR("foreground"));  push_gdkobject(f,color,1); 
    ref_push_string(_STR("background"));  push_gdkobject(b,color,1); 
  } 
  f_aggregate_mapping(Pike_sp-osp); 
} 
 
void set_foreground(GDK2.Color color) 
//! Set the foreground to the specified GDK2.Color. 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    gdk_gc_set_foreground(GDK_GC(THIS->obj),get_gdkobject(o,color)); 
  } 
  RETURN_THIS(); 
} 
 
void set_background(GDK2.Color color) 
//! Set the background to the specified GDK2.Color. 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    gdk_gc_set_background(GDK_GC(THIS->obj),get_gdkobject(o,color)); 
  } 
  RETURN_THIS(); 
} 
 
/* 
void set_font(GDK22.Font font) 
//! Set the font to the specified GDK2.Font. 
//! Deprecated: Use Pango.Layout instead. 
{ 
  struct object *o; 
  get_all_args(NULL,args,"%o",&o); 
  gdk_gc_set_font(GDK_GC(THIS->obj),get_gdkobject(o,font)); 
  RETURN_THIS(); 
} 
*/ 
 
void set_clip_origin(int x, int y) 
//! Set the clip mask origin to the specified point. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE x,y; 
 
    get_all_args(NULL,args,"%i%i",&x,&y); 
    gdk_gc_set_clip_origin(GDK_GC(THIS->obj),x,y); 
  } 
  RETURN_THIS(); 
} 
 
void set_clip_mask(GDK2.Bitmap mask) 
//! Set the clip mask to the specified GDK2.Bitmap 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    gdk_gc_set_clip_mask(GDK_GC(THIS->obj),GDK_DRAWABLE(get_gobject(o))); 
  } 
  RETURN_THIS(); 
} 
 
void set_function(int fun) 
//! Set the function to the specified one.  One of GDK2.Xor, 
//! GDK2.Invert and GDK2.Copy. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE a; 
 
    get_all_args(NULL,args,"%i",&a); 
    gdk_gc_set_function(GDK_GC(THIS->obj),a); 
  } 
  RETURN_THIS(); 
} 
 
void set_subwindow(int draw_on_subwindows) 
//! If set, anything drawn with this GC will draw on subwindows as well 
//! as the window in which the drawing is done. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE a; 
  
    get_all_args(NULL,args,"%i",&a); 
    gdk_gc_set_subwindow(GDK_GC(THIS->obj),a); 
  } 
  RETURN_THIS(); 
} 
 
void set_fill(int fill) 
//! Set the fill method to fill. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE i; 
 
    get_all_args(NULL,args,"%d",&i); 
    gdk_gc_set_fill(GDK_GC(THIS->obj),i); 
  } 
  RETURN_THIS(); 
} 
 
void set_tile(GDK2.Pixmap tile) 
//! Set the background type.  Fill must be GDK_TILED 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    if (GDK_IS_PIXMAP(get_gobject(o))) 
      gdk_gc_set_tile(GDK_GC(THIS->obj),GDK_PIXMAP(get_gobject(o))); 
  } 
  RETURN_THIS(); 
} 
 
void set_stipple(GDK2.Bitmap stipple) 
//! Set the background type.  Fill must be GDK_STIPPLED or GDK_OPAQUE_STIPPLED. 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    if (GDK_IS_DRAWABLE(get_gobject(o))) 
      gdk_gc_set_stipple(GDK_GC(THIS->obj),GDK_DRAWABLE(get_gobject(o))); 
  } 
  RETURN_THIS(); 
} 
 
void set_ts_origin(int x, int y) 
//! Set the origin when using tiles or stipples with the GC.  The tile 
//! or stipple will be aligned such that the upper left corner of the 
//! tile or stipple will coincide with this point. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE x,y; 
 
    get_all_args(NULL,args,"%i%i",&x,&y); 
    gdk_gc_set_ts_origin(GDK_GC(THIS->obj),x,y); 
  } 
  RETURN_THIS(); 
} 
 
void set_clip_rectangle(?GDK2.Rectangle rect) 
//! Sets the clip mask for a graphics context from a rectangle.  The 
//! clip mask is interpreted relative to the clip origin. 
{ 
  pgtk2_verify_inited(); 
  if (args==1) { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    gdk_gc_set_clip_rectangle(GDK_GC(THIS->obj),get_gdkobject(o,rectangle)); 
  } else 
    gdk_gc_set_clip_rectangle(GDK_GC(THIS->obj),NULL); 
  RETURN_THIS(); 
} 
 
void set_clip_region(GDK2.Region rect) 
//! Sets the clip mask for a graphs context from a region.  The 
//! clip mask is interpreted relative to the clip origin. 
{ 
  pgtk2_verify_inited(); 
  if (args==1) { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    gdk_gc_set_clip_region(GDK_GC(THIS->obj),get_gdkobject(o,region)); 
  } else 
    gdk_gc_set_clip_region(GDK_GC(THIS->obj),NULL); 
  RETURN_THIS(); 
} 
 
void set_dashes(int offset, array dashes) 
//! Sets the way dashed-lines are drawn.  Lines will be drawn with 
//! alternating on and off segments of the lengths specified in 
//! dashes.  The manner in which the on and off segments are drawn is 
//! determined by the line_style value of the GC. 
{ 
  pgtk2_verify_inited(); 
  { 
    int i; 
    INT_TYPE o; 
    struct array *a; 
    gint8 *list; 
 
    get_all_args(NULL,args,"%d%a",&o,&a); 
    list=xalloc(a->size); 
    for (i=0; i<a->size; i++) 
      list[i]=a->item[i].u.integer; 
 
    gdk_gc_set_dashes(GDK_GC(THIS->obj),o,list,a->size); 
    free(list); 
  } 
  RETURN_THIS(); 
} 
 
void set_line_attributes(int line_width, int line_style, int cap_style, 
                         int join_style) 
//! Control how lines are drawn. 
//! line_style is one of GDK2.LineSolid, GDK2,LineOnOffDash and GDK2.LineDoubleDash. 
//! cap_style is one of GDK2.CapNotLast, GDK2.CapButt, GDK2.CapRound and GDK2.CapProjecting. 
//! join_style is one of GDK2.JoinMiter, GDK2.JoinRound and GDK2.JoinBevel. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE a,b,c,d; 
 
    get_all_args(NULL,args,"%d%d%d%d",&a,&b,&c,&d); 
    gdk_gc_set_line_attributes(GDK_GC(THIS->obj),a,b,c,d); 
  } 
  RETURN_THIS(); 
} 
 
void copy(GDK2.GC source) 
//! Copy all attributes from the source GC 
{ 
  pgtk2_verify_inited(); 
  { 
    struct object *o; 
 
    get_all_args(NULL,args,"%o",&o); 
    gdk_gc_copy(GDK_GC(THIS->obj),GDK_GC(get_gobject(o))); 
  } 
  RETURN_THIS(); 
} 
 
void set_exposures(int exp) 
//! Sets whether copying non-visible portions of a drawable using this gc 
//! generates exposure events for the corresponding regions of the dest 
//! drawable. 
{ 
  pgtk2_verify_inited(); 
  { 
    INT_TYPE a; 
 
    get_all_args(NULL,args,"%i",&a); 
    gdk_gc_set_exposures(GDK_GC(THIS->obj),a); 
  } 
  RETURN_THIS(); 
}