File: drawable.cc

package info (click to toggle)
gtkmm2.4 1%3A2.24.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 74,416 kB
  • ctags: 20,265
  • sloc: xml: 80,438; sh: 11,064; cpp: 8,013; perl: 236; makefile: 224
file content (493 lines) | stat: -rw-r--r-- 15,020 bytes parent folder | download | duplicates (2)
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
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
// Generated by gtkmmproc -- DO NOT MODIFY!


#include <gdkmm/drawable.h>
#include <gdkmm/private/drawable_p.h>

// -*- c++ -*-
/* $Id: drawable.ccg,v 1.2 2004/01/19 19:48:41 murrayc Exp $ */

/* Copyright 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <gdkmm/gc.h>
#include <gdkmm/display.h>
#include <gdkmm/pixbuf.h>
#include <gdk/gdk.h>

namespace Gdk
{

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_points(const Glib::RefPtr<const GC>& gc, const Glib::ArrayHandle<Point>& points)
{
  // Don't assume the reinterpret_cast<> works everywhere.  Gdk::Point is *special*.
  gdk_draw_points(
      gobj(), const_cast<GdkGC*>(Glib::unwrap<Gdk::GC>(gc)),
      reinterpret_cast<GdkPoint*>(const_cast<Point*>(points.data())),
      points.size());
}

void Drawable::draw_lines(const Glib::RefPtr<const GC>& gc, const Glib::ArrayHandle<Point>& points)
{
  // Don't assume the reinterpret_cast<> works everywhere.  Gdk::Point is *special*.
  gdk_draw_lines(
      gobj(), const_cast<GdkGC*>(Glib::unwrap<Gdk::GC>(gc)),
      reinterpret_cast<GdkPoint*>(const_cast<Point*>(points.data())),
      points.size());
}

void Drawable::draw_polygon(const Glib::RefPtr<const GC>& gc, bool filled,
                            const Glib::ArrayHandle<Point>& points)
{
  // Don't assume the reinterpret_cast<> works everywhere.  Gdk::Point is *special*.
  gdk_draw_polygon(
      gobj(), const_cast<GdkGC*>(Glib::unwrap<Gdk::GC>(gc)), filled,
      reinterpret_cast<GdkPoint*>(const_cast<Point*>(points.data())),
      points.size());
}
#endif // GDKMM_DISABLE_DEPRECATED


void Drawable::copy_to_image(const Glib::RefPtr<Image>& image, int src_x, int src_y, int dest_x, int dest_y, int width, int height) const
{
  gdk_drawable_copy_to_image(const_cast<GdkDrawable*>(gobj()), Glib::unwrap(image), src_x, src_y, dest_x, dest_y, width, height);
}

void Drawable::draw_pixbuf(const Glib::RefPtr<Pixbuf>& pixbuf, int src_x, int src_y, int dest_x, int dest_y, int width, int height, RgbDither dither, int x_dither, int y_dither)
{
gdk_draw_pixbuf(gobj(), 0, Glib::unwrap(pixbuf), src_x, src_y, dest_x, dest_y, width, height, ((GdkRgbDither)(dither)), x_dither, y_dither); 
}


} // namespace Gdk


namespace
{
} // anonymous namespace

// static
GType Glib::Value<Gdk::RgbDither>::value_type()
{
  return gdk_rgb_dither_get_type();
}


namespace Glib
{

Glib::RefPtr<Gdk::Drawable> wrap(GdkDrawable* object, bool take_copy)
{
  return Glib::RefPtr<Gdk::Drawable>( dynamic_cast<Gdk::Drawable*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );
  //We use dynamic_cast<> in case of multiple inheritance.
}

} /* namespace Glib */


namespace Gdk
{


/* The *_Class implementation: */

const Glib::Class& Drawable_Class::init()
{
  if(!gtype_) // create the GType if necessary
  {
    // Glib::Class has to know the class init function to clone custom types.
    class_init_func_ = &Drawable_Class::class_init_function;

    // This is actually just optimized away, apparently with no harm.
    // Make sure that the parent type has been created.
    //CppClassParent::CppObjectType::get_type();

    // Create the wrapper type, with the same class/instance size as the base type.
    register_derived_type(gdk_drawable_get_type());

    // Add derived versions of interfaces, if the C type implements any interfaces:

  }

  return *this;
}


void Drawable_Class::class_init_function(void* g_class, void* class_data)
{
  BaseClassType *const klass = static_cast<BaseClassType*>(g_class);
  CppClassParent::class_init_function(klass, class_data);


}


Glib::ObjectBase* Drawable_Class::wrap_new(GObject* object)
{
  return new Drawable((GdkDrawable*)object);
}


/* The implementation: */

GdkDrawable* Drawable::gobj_copy()
{
  reference();
  return gobj();
}

Drawable::Drawable(const Glib::ConstructParams& construct_params)
:
  Glib::Object(construct_params)
{

}

Drawable::Drawable(GdkDrawable* castitem)
:
  Glib::Object((GObject*)(castitem))
{}


Drawable::~Drawable()
{}


Drawable::CppClassType Drawable::drawable_class_; // initialize static member

GType Drawable::get_type()
{
  return drawable_class_.init().get_type();
}


GType Drawable::get_base_type()
{
  return gdk_drawable_get_type();
}


Drawable::Drawable()
:
  // Mark this class as non-derived to allow C++ vfuncs to be skipped.
  Glib::ObjectBase(0),
  Glib::Object(Glib::ConstructParams(drawable_class_.init()))
{
  

}

Glib::RefPtr<Drawable> Drawable::create()
{
  return Glib::RefPtr<Drawable>( new Drawable() );
}

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::get_size(int& width, int& height)
{
gdk_drawable_get_size(gobj(), &(width), &(height)); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::get_size(int& width, int& height) const
{
gdk_drawable_get_size(const_cast<GdkDrawable*>(gobj()), &(width), &(height)); 
}

#endif // GDKMM_DISABLE_DEPRECATED

int Drawable::get_depth() const
{
  return gdk_drawable_get_depth(const_cast<GdkDrawable*>(gobj()));
}

void Drawable::set_colormap(const Glib::RefPtr<Colormap>& colormap)
{
gdk_drawable_set_colormap(gobj(), Glib::unwrap(colormap)); 
}

Glib::RefPtr<Colormap> Drawable::get_colormap()
{

  Glib::RefPtr<Colormap> retvalue = Glib::wrap(gdk_drawable_get_colormap(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

#ifndef GDKMM_DISABLE_DEPRECATED

Glib::RefPtr<Visual> Drawable::get_visual()
{

  Glib::RefPtr<Visual> retvalue = Glib::wrap(gdk_drawable_get_visual(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_point(const Glib::RefPtr<const GC>& gc, int x, int y)
{
gdk_draw_point(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_line(const Glib::RefPtr<const GC>& gc, int x1, int y1, int x2, int y2)
{
gdk_draw_line(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x1, y1, x2, y2); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_rectangle(const Glib::RefPtr<const GC>& gc, bool filled, int x, int y, int width, int height)
{
gdk_draw_rectangle(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), static_cast<int>(filled), x, y, width, height); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_arc(const Glib::RefPtr<const GC>& gc, bool filled, int x, int y, int width, int height, int angle1, int angle2)
{
gdk_draw_arc(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), static_cast<int>(filled), x, y, width, height, angle1, angle2); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_drawable(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Drawable>& src, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
{
gdk_draw_drawable(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), const_cast<GdkDrawable*>(Glib::unwrap<Drawable>(src)), xsrc, ysrc, xdest, ydest, width, height); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_image(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Image>& image, int xsrc, int ysrc, int xdest, int ydest, int width, int height)
{
gdk_draw_image(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), const_cast<GdkImage*>(Glib::unwrap<Image>(image)), xsrc, ysrc, xdest, ydest, width, height); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_segments(const Glib::RefPtr<const GC>& gc, GdkSegment* segs, int nsegs)
{
gdk_draw_segments(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), (segs), nsegs); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_glyphs(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<const Pango::Font>& font, int x, int y, const Pango::GlyphString& glyphs)
{
gdk_draw_glyphs(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), const_cast<PangoFont*>(Glib::unwrap<Pango::Font>(font)), x, y, const_cast<PangoGlyphString*>(glyphs.gobj())); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_layout_line(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::LayoutLine>& line)
{
gdk_draw_layout_line(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, const_cast<PangoLayoutLine*>(Glib::unwrap<Pango::LayoutLine>(line))); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_layout_line(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::LayoutLine>& line, const Color& foreground, const Color& background)
{
gdk_draw_layout_line_with_colors(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, const_cast<PangoLayoutLine*>(Glib::unwrap<Pango::LayoutLine>(line)), (foreground).gobj(), (background).gobj()); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_layout(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::Layout>& layout)
{
gdk_draw_layout(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, const_cast<PangoLayout*>(Glib::unwrap<Pango::Layout>(layout))); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_layout(const Glib::RefPtr<const GC>& gc, int x, int y, const Glib::RefPtr<const Pango::Layout>& layout, const Color& foreground, const Color& background)
{
gdk_draw_layout_with_colors(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, const_cast<PangoLayout*>(Glib::unwrap<Pango::Layout>(layout)), (foreground).gobj(), (background).gobj()); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_pixbuf(const Glib::RefPtr<const GC>& gc, const Glib::RefPtr<Pixbuf>& pixbuf, int src_x, int src_y, int dest_x, int dest_y, int width, int height, RgbDither dither, int x_dither, int y_dither)
{
gdk_draw_pixbuf(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), Glib::unwrap(pixbuf), src_x, src_y, dest_x, dest_y, width, height, ((GdkRgbDither)(dither)), x_dither, y_dither); 
}

#endif // GDKMM_DISABLE_DEPRECATED

Glib::RefPtr<Image> Drawable::get_image(int x, int y, int width, int height) const
{
  return Glib::wrap(gdk_drawable_get_image(const_cast<GdkDrawable*>(gobj()), x, y, width, height));
}

Region Drawable::get_clip_region() const
{
  return Region(gdk_drawable_get_clip_region(const_cast<GdkDrawable*>(gobj())));
}

Region Drawable::get_visible_region() const
{
  return Region(gdk_drawable_get_visible_region(const_cast<GdkDrawable*>(gobj())));
}

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_rgb_image(const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride)
{
gdk_draw_rgb_image(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, width, height, ((GdkRgbDither)(dith)), rgb_buf, rowstride); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_rgb_image_dithalign(const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride, int xdith, int ydith)
{
gdk_draw_rgb_image_dithalign(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, width, height, ((GdkRgbDither)(dith)), rgb_buf, rowstride, xdith, ydith); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_rgb_32_image(const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride)
{
gdk_draw_rgb_32_image(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, width, height, ((GdkRgbDither)(dith)), rgb_buf, rowstride); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_rgb_32_image_dithalign(const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* buf, int rowstride, int xdith, int ydith)
{
gdk_draw_rgb_32_image_dithalign(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, width, height, ((GdkRgbDither)(dith)), buf, rowstride, xdith, ydith); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_gray_image(const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride)
{
gdk_draw_gray_image(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, width, height, ((GdkRgbDither)(dith)), rgb_buf, rowstride); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

void Drawable::draw_indexed_image(const Glib::RefPtr<const GC>& gc, int x, int y, int width, int height, RgbDither dith, const guchar* rgb_buf, int rowstride, const RgbCmap& cmap)
{
gdk_draw_indexed_image(gobj(), const_cast<GdkGC*>(Glib::unwrap<GC>(gc)), x, y, width, height, ((GdkRgbDither)(dith)), rgb_buf, rowstride, const_cast<GdkRgbCmap*>(cmap.gobj())); 
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

Glib::RefPtr<Screen> Drawable::get_screen()
{

  Glib::RefPtr<Screen> retvalue = Glib::wrap(gdk_drawable_get_screen(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

Glib::RefPtr<const Screen> Drawable::get_screen() const
{
  return const_cast<Drawable*>(this)->get_screen();
}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

Glib::RefPtr<Display> Drawable::get_display()
{

  Glib::RefPtr<Display> retvalue = Glib::wrap(gdk_drawable_get_display(gobj()));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;

}

#endif // GDKMM_DISABLE_DEPRECATED

#ifndef GDKMM_DISABLE_DEPRECATED

Glib::RefPtr<const Display> Drawable::get_display() const
{
  return const_cast<Drawable*>(this)->get_display();
}

#endif // GDKMM_DISABLE_DEPRECATED

Cairo::RefPtr<Cairo::Context> Drawable::create_cairo_context()
{
  return Cairo::RefPtr<Cairo::Context>(new Cairo::Context(gdk_cairo_create(gobj()), true /* has_reference */));
}


} // namespace Gdk