File: renderer.gob

package info (click to toggle)
ggobi 2.1.9~20091212-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 19,340 kB
  • ctags: 5,083
  • sloc: ansic: 57,242; xml: 30,604; cpp: 833; makefile: 355; java: 225; perl: 201; sh: 122; python: 23
file content (260 lines) | stat: -rw-r--r-- 9,564 bytes parent folder | download | duplicates (5)
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
%h{
  #include <gdk/gdk.h>
%}

%{
  #include <gtk/gtk.h>
  #if GTK_CHECK_VERSION(2,8,0)
  static cairo_surface_t *ref_cairo_surface(GdkDrawable *self);
  #endif
%}

/* Transfers logical drawing commands to a physical (screen) device */
/* The default renderer just passes everything through to GDK */
/* Since GGobi is an interactive graphics platform, the renderer design
   is biased towards screen devices. This doesn't preclude, however, 
   off-screen devices that take "snapshots" of GGobi plots */
class GGobi:Renderer from Gdk:Drawable
{
  /* everything passes through to this drawable by default */
  private GdkDrawable *buffer unrefwith g_object_unref;
  
  /* buffer should be flushed to this drawable */
  private GdkDrawable *parent unrefwith g_object_unref;
  property OBJECT parent
  (nick = "out", blurb = "The drawable to which this renderer is flushed",
   object_type = Gdk:Drawable, flags = CONSTRUCT_ONLY)
   set {
     GObject *obj = g_value_dup_object(VAL);
     if (selfp->parent)
       g_object_unref(G_OBJECT(selfp->parent));
     selfp->parent = GDK_DRAWABLE(obj);
     if (selfp->buffer)
       g_object_unref(G_OBJECT(selfp->buffer));
     selfp->buffer = self_create_target(self, selfp->parent);
   } get {
     g_value_set_object(VAL, selfp->parent);
   };
  
  /* if you already have a special GdkDrawable, and want to make it into a 
     GGobiRenderer, just override this to provide it */
  private virtual GdkDrawable *
  create_target(self, GdkDrawable *parent)
  {
    gint width, height;
    gdk_drawable_get_size(parent, &width, &height);
    return gdk_pixmap_new(parent, width, height, -1);
  }
  
  /* buffers are created by cloning (prototype approach) */
  public virtual GGobiRenderer *
  buffer(self)
  {
    GObject *obj = g_object_new(G_OBJECT_TYPE(self), "parent", self, NULL);
    return GGOBI_RENDERER(obj);
  }
  
  public virtual void
  flush(self, GdkGC *gc, gint xsrc, gint ysrc, gint xdest, gint ydest, 
    gint width, gint height)
  {
    gdk_draw_drawable(selfp->parent, gc, selfp->buffer, xsrc, ysrc, xdest, ydest, 
      width, height);
  }

  /* pass everything through to underlying drawable */
  
  override (Gdk:Drawable) void 
  draw_rectangle (GdkDrawable  *self, GdkGC *gc, gboolean filled,
    gint x, gint y, gint width, gint height)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_rectangle(
      SELF(self)->_priv->buffer, gc, filled, x, y, width, height);
  }
  override (Gdk:Drawable) void 
  draw_arc(GdkDrawable  *self, GdkGC *gc, gboolean filled, gint x, gint y, 
    gint width, gint height, gint angle1, gint angle2)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_arc(
      SELF(self)->_priv->buffer, gc, filled, x, y, width, height, angle1, angle2);
  }
  override (Gdk:Drawable) void 
  draw_polygon(GdkDrawable  *self, GdkGC *gc, gboolean filled, 
    GdkPoint *points, gint npoints)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_polygon(
      SELF(self)->_priv->buffer, gc, filled, points, npoints);
  }
  override (Gdk:Drawable) void 
  draw_points(GdkDrawable  *self, GdkGC *gc, GdkPoint *points, gint npoints)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_points(
      SELF(self)->_priv->buffer, gc, points, npoints);
  }
  override (Gdk:Drawable) void 
  draw_segments(GdkDrawable  *self, GdkGC *gc, GdkSegment *segs, gint nsegs)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_segments(
      SELF(self)->_priv->buffer, gc, segs, nsegs);
  }
  override (Gdk:Drawable) void 
  draw_lines(GdkDrawable  *self, GdkGC *gc, GdkPoint *points, gint npoints)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_lines(
      SELF(self)->_priv->buffer, gc, points, npoints);
  }
  override (Gdk:Drawable) void 
  draw_trapezoids(GdkDrawable *self, GdkGC *gc, GdkTrapezoid *trapezoids, 
    gint n_trapezoids)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_trapezoids(
      SELF(self)->_priv->buffer, gc, trapezoids, n_trapezoids);
  }
  
  override (Gdk:Drawable) void 
  draw_text(GdkDrawable  *self, GdkFont *font, GdkGC *gc, gint x, gint y, 
    const gchar  *text, gint text_length)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_text(
      SELF(self)->_priv->buffer, font, gc, x, y, text, text_length);
  }
  override (Gdk:Drawable) void 
  draw_text_wc(GdkDrawable *self, GdkFont *font, GdkGC *gc, gint x, gint y, 
    const GdkWChar *text, gint text_length)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_text_wc(
      SELF(self)->_priv->buffer, font, gc, x, y, text, text_length);
  }
  override (Gdk:Drawable) void 
  draw_glyphs(GdkDrawable *self, GdkGC *gc, PangoFont *font, gint x, gint y, 
    PangoGlyphString *glyphs)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_glyphs(
      SELF(self)->_priv->buffer, gc, font, x, y, glyphs);
  }
  override (Gdk:Drawable) void 
  draw_glyphs_transformed(GdkDrawable *self, GdkGC *gc, PangoMatrix *matrix, 
    PangoFont *font, gint x, gint y, PangoGlyphString *glyphs)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_glyphs_transformed(
      SELF(self)->_priv->buffer, gc, matrix, font, x, y, glyphs);
  }
  
  override (Gdk:Drawable) GdkGC *
  create_gc(GdkDrawable *self, GdkGCValues *values, GdkGCValuesMask mask)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->create_gc(
      SELF(self)->_priv->buffer, values, mask);
  }
  override (Gdk:Drawable) void 
  draw_drawable(GdkDrawable  *self, GdkGC *gc, GdkDrawable  *src, gint xsrc, 
    gint ysrc, gint xdest, gint ydest, gint width, gint height)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_drawable(
      SELF(self)->_priv->buffer, gc, src, xsrc, ysrc, xdest, ydest, width, height);
  }
  override (Gdk:Drawable) void 
  draw_image(GdkDrawable *self, GdkGC *gc, GdkImage *image, gint xsrc, gint ysrc, 
    gint xdest, gint ydest, gint width, gint height)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_image(
      SELF(self)->_priv->buffer, gc, image, xsrc, ysrc, xdest, ydest, width, height);
  }

  override (Gdk:Drawable) gint 
  get_depth(GdkDrawable  *self)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_depth(
      SELF(self)->_priv->buffer);
  }
  override (Gdk:Drawable) void 
  get_size(GdkDrawable  *self, gint *width, gint *height)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_size(
      SELF(self)->_priv->buffer, width, height);
  }
  
  override (Gdk:Drawable) void 
  set_colormap(GdkDrawable  *self, GdkColormap  *cmap)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->set_colormap(
      SELF(self)->_priv->buffer, cmap);
  }
  override (Gdk:Drawable) GdkColormap* 
  get_colormap(GdkDrawable  *self)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_colormap(
      SELF(self)->_priv->buffer);
  }
  override (Gdk:Drawable) GdkVisual* 
  get_visual(GdkDrawable  *self)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_visual(
      SELF(self)->_priv->buffer);
  }
  override (Gdk:Drawable) GdkScreen* 
  get_screen(GdkDrawable  *self)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_screen(
      SELF(self)->_priv->buffer);
  }
  override (Gdk:Drawable) GdkImage* 
  get_image(GdkDrawable  *self, gint x, gint y, gint width, gint height)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_image(
      SELF(self)->_priv->buffer, x, y, width, height);
  }
  override (Gdk:Drawable) GdkRegion* 
  get_clip_region(GdkDrawable  *self)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_clip_region(
      SELF(self)->_priv->buffer);
  }
  override (Gdk:Drawable) GdkRegion* 
  get_visible_region(GdkDrawable  *self)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_visible_region(
      SELF(self)->_priv->buffer);
  }
  override (Gdk:Drawable) GdkDrawable* 
  get_composite_drawable(GdkDrawable *self, gint x, gint y, gint width, 
    gint height, gint *composite_x_offset, gint *composite_y_offset)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->get_composite_drawable(
      SELF(self)->_priv->buffer, x, y, width, height, composite_x_offset, composite_y_offset);
  }
  
  override (Gdk:Drawable) void 
  draw_pixbuf(GdkDrawable *self, GdkGC *gc, GdkPixbuf *pixbuf, gint src_x, 
    gint src_y, gint dest_x, gint dest_y, gint width, gint height, 
    GdkRgbDither dither, gint x_dither, gint y_dither)
  {
    GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->draw_pixbuf(
      SELF(self)->_priv->buffer, gc, pixbuf, src_x, src_y, dest_x, dest_y, 
      width, height, dither, x_dither, y_dither);
  }
  override (Gdk:Drawable) GdkImage* 
  _copy_to_image(GdkDrawable *self, GdkImage *image, gint src_x, gint src_y,
    gint dest_x, gint dest_y, gint width, gint height)
  {
    return GDK_DRAWABLE_GET_CLASS(SELF(self)->_priv->buffer)->_copy_to_image(
      SELF(self)->_priv->buffer, image, src_x, src_y, dest_x, dest_y, width, height);
  }
  
  class_init(self_class) { /* need to do this one manually, to avoid GTK+ 2.8.x dep */
    #if GTK_CHECK_VERSION(2,8,0)
    GDK_DRAWABLE_CLASS(self_class)->ref_cairo_surface = ref_cairo_surface;
    #endif
  }
}

%{
  #if GTK_CHECK_VERSION(2,8,0)
  static cairo_surface_t *
  ref_cairo_surface(GdkDrawable *self)
  {
    return GDK_DRAWABLE_GET_CLASS(GGOBI_RENDERER(self)->_priv->buffer)->ref_cairo_surface(
      GGOBI_RENDERER(self)->_priv->buffer);
  }
  #endif
%}