~ubuntu-branches/ubuntu/maverick/gcompris/maverick

« back to all changes in this revision

Viewing changes to src/goocanvas/src/goocanvas.h

  • Committer: Bazaar Package Importer
  • Author(s): Marc Gariepy, Marc Gariepy, Stephane Graber
  • Date: 2010-01-04 17:42:49 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174249-7bupatd9dtxyhvs4
Tags: 9.0-0ubuntu1
[Marc Gariepy]
* New upstream release (9.0).
* Remove cache.c from POTFILES to avoid FTBFS
* Remove unneeded rm in debian/rules (file no longer exists upstream)

[Stephane Graber]
* Bump Debian standards to 3.8.3
* Add patch system (dpatch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * GooCanvas. Copyright (C) 2005 Damon Chaplin.
 
3
 * Released under the GNU LGPL license. See COPYING for details.
 
4
 *
 
5
 * goocanvas.h - the main canvas widget.
 
6
 */
 
7
#ifndef __GOO_CANVAS_H__
 
8
#define __GOO_CANVAS_H__
 
9
 
 
10
#include <gtk/gtk.h>
 
11
#include <goocanvasenumtypes.h>
 
12
#include <goocanvasellipse.h>
 
13
#include <goocanvasgrid.h>
 
14
#include <goocanvasgroup.h>
 
15
#include <goocanvasimage.h>
 
16
#include <goocanvaspath.h>
 
17
#include <goocanvaspolyline.h>
 
18
#include <goocanvasrect.h>
 
19
#include <goocanvastable.h>
 
20
#include <goocanvastext.h>
 
21
#include <goocanvaswidget.h>
 
22
#include <goocanvassvg.h>
 
23
 
 
24
G_BEGIN_DECLS
 
25
 
 
26
 
 
27
#define GOO_TYPE_CANVAS            (goo_canvas_get_type ())
 
28
#define GOO_CANVAS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_CANVAS, GooCanvas))
 
29
#define GOO_CANVAS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_CANVAS, GooCanvasClass))
 
30
#define GOO_IS_CANVAS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOO_TYPE_CANVAS))
 
31
#define GOO_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOO_TYPE_CANVAS))
 
32
#define GOO_CANVAS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GOO_TYPE_CANVAS, GooCanvasClass))
 
33
 
 
34
 
 
35
typedef struct _GooCanvasClass  GooCanvasClass;
 
36
 
 
37
/**
 
38
 * GooCanvas
 
39
 *
 
40
 * The #GooCanvas-struct struct contains private data only.
 
41
 */
 
42
struct _GooCanvas
 
43
{
 
44
  GtkContainer container;
 
45
 
 
46
  /* The model for the root item, in model/view mode. */
 
47
  GooCanvasItemModel *root_item_model;
 
48
 
 
49
  /* The root canvas item. */
 
50
  GooCanvasItem *root_item;
 
51
 
 
52
  /* The bounds of the canvas, in canvas units (not pixels). */
 
53
  GooCanvasBounds bounds;
 
54
 
 
55
  /* The scale/zoom factors of the canvas. */
 
56
  gdouble scale_x, scale_y;
 
57
 
 
58
  /* The minimum of scale_x and scale_y, to compare with items' visibility
 
59
     thresholds. */
 
60
  gdouble scale;
 
61
 
 
62
  /* Where the canvas is anchored (where it is displayed when it is smaller
 
63
     than the entire window). */
 
64
  GtkAnchorType anchor;
 
65
 
 
66
  /* Idle handler ID, for processing updates. */
 
67
  guint idle_id;
 
68
 
 
69
  /* This is TRUE if some item in the canvas needs an update. */
 
70
  guint need_update : 1;
 
71
 
 
72
  /* This is TRUE if all items in the canvas need to be updated. */
 
73
  guint need_entire_subtree_update : 1;
 
74
 
 
75
  /* This is TRUE if all layout should be done to the nearest integer. */
 
76
  guint integer_layout : 1;
 
77
 
 
78
  /* This is TRUE if the bounds are calculated automatically, using the bounds
 
79
     of all the items in the canvas. */
 
80
  guint automatic_bounds : 1;
 
81
 
 
82
  /* This is TRUE if the automatic bounds are calculated from the origin. */
 
83
  guint bounds_from_origin : 1;
 
84
 
 
85
  /* This is TRUE if the background is cleared before painting the canvas. */
 
86
  guint clear_background : 1;
 
87
 
 
88
  /* This is TRUE if the canvas is completely redrawn when scrolled. It is
 
89
     useful when there are sticky items to reduce flicker, but is slower. */
 
90
  guint redraw_when_scrolled : 1;
 
91
 
 
92
  /* This is the padding around the automatic bounds. */
 
93
  gdouble bounds_padding;
 
94
 
 
95
  /* The item that the mouse is over. */
 
96
  GooCanvasItem *pointer_item;
 
97
 
 
98
  /* The item that has the pointer grab, or NULL. */
 
99
  GooCanvasItem *pointer_grab_item;
 
100
 
 
101
  /* This is the item that the grab was started from. When the grab ends
 
102
     we synthesize enter/leave notify events from this item. */
 
103
  GooCanvasItem *pointer_grab_initial_item;
 
104
 
 
105
  /* This is the mouse button that started an implicit pointer grab.
 
106
     When the same button is released the implicit grab ends. */
 
107
  guint pointer_grab_button;
 
108
 
 
109
  /* The item that has the keyboard focus, or NULL. */
 
110
  GooCanvasItem *focused_item;
 
111
 
 
112
  /* The item that has the keyboard grab, or NULL. */
 
113
  GooCanvasItem *keyboard_grab_item;
 
114
 
 
115
  /* The synthesized event used for sending enter-notify and leave-notify
 
116
     events to items. */
 
117
  GdkEventCrossing crossing_event;
 
118
 
 
119
  /* The main canvas window, which gets scrolled around. */
 
120
  GdkWindow *canvas_window;
 
121
 
 
122
  /* The offsets of the canvas within the canvas window, in pixels. These are
 
123
     used when the canvas is smaller than the window size and the anchor is not
 
124
     NORTH_WEST. */
 
125
  gint canvas_x_offset;
 
126
  gint canvas_y_offset;
 
127
 
 
128
  /* The adjustments used for scrolling. */
 
129
  GtkAdjustment *hadjustment;
 
130
  GtkAdjustment *vadjustment;
 
131
 
 
132
  /* Freezes any movement of the canvas window, until thawed. This is used
 
133
     when we need to set both adjustments and don't want it to scroll twice. */
 
134
  gint freeze_count;
 
135
 
 
136
  /* A window temporarily mapped above the canvas to stop X from scrolling
 
137
     the contents unnecessarily (i.e. when we zoom in/out). */
 
138
  GdkWindow *tmp_window;
 
139
 
 
140
  /* A hash table mapping canvas item models to canvas items. */
 
141
  GHashTable *model_to_item;
 
142
 
 
143
  /* The units of the canvas, which applies to all item coords. */
 
144
  GtkUnit units;
 
145
 
 
146
  /* The horizontal and vertical resolution of the display, in dots per inch.
 
147
     This is only needed when units other than pixels are used. */
 
148
  gdouble resolution_x, resolution_y;
 
149
 
 
150
  /* The multiplers to convert from device units to pixels, taking into account
 
151
     the canvas scale, the units setting and the display resolution. */
 
152
  gdouble device_to_pixels_x, device_to_pixels_y;
 
153
 
 
154
  /* The list of child widgets (using GooCanvasWidget items). */
 
155
  GList *widget_items;
 
156
};
 
157
 
 
158
/**
 
159
 * GooCanvasClass
 
160
 * @create_item: a virtual method that subclasses may override to create custom
 
161
 *  canvas items for item models.
 
162
 * @item_created: signal emitted when a new canvas item has been created.
 
163
 *  Applications can connect to this to setup signal handlers for the new item.
 
164
 *
 
165
 * The #GooCanvasClass-struct struct contains one virtual method that
 
166
 * subclasses may override.
 
167
 */
 
168
struct _GooCanvasClass
 
169
{
 
170
  /*< private >*/
 
171
  GtkContainerClass parent_class;
 
172
 
 
173
  void           (* set_scroll_adjustments) (GooCanvas          *canvas,
 
174
                                             GtkAdjustment      *hadjustment,
 
175
                                             GtkAdjustment      *vadjustment);
 
176
 
 
177
  /* Virtual methods. */
 
178
  /*< public >*/
 
179
  GooCanvasItem* (* create_item)            (GooCanvas          *canvas,
 
180
                                             GooCanvasItemModel *model);
 
181
 
 
182
  /* Signals. */
 
183
  void           (* item_created)           (GooCanvas          *canvas,
 
184
                                             GooCanvasItem      *item,
 
185
                                             GooCanvasItemModel *model);
 
186
 
 
187
  /*< private >*/
 
188
 
 
189
  /* Padding for future expansion */
 
190
  void (*_goo_canvas_reserved1) (void);
 
191
  void (*_goo_canvas_reserved2) (void);
 
192
  void (*_goo_canvas_reserved3) (void);
 
193
  void (*_goo_canvas_reserved4) (void);
 
194
  void (*_goo_canvas_reserved5) (void);
 
195
  void (*_goo_canvas_reserved6) (void);
 
196
  void (*_goo_canvas_reserved7) (void);
 
197
  void (*_goo_canvas_reserved8) (void);
 
198
};
 
199
 
 
200
 
 
201
GType           goo_canvas_get_type         (void) G_GNUC_CONST;
 
202
GtkWidget*      goo_canvas_new              (void);
 
203
 
 
204
GooCanvasItem*  goo_canvas_get_root_item    (GooCanvas          *canvas);
 
205
void            goo_canvas_set_root_item    (GooCanvas          *canvas,
 
206
                                             GooCanvasItem      *item);
 
207
 
 
208
GooCanvasItemModel* goo_canvas_get_root_item_model (GooCanvas          *canvas);
 
209
void                goo_canvas_set_root_item_model (GooCanvas          *canvas,
 
210
                                                    GooCanvasItemModel *model);
 
211
 
 
212
GooCanvasItem*  goo_canvas_get_static_root_item    (GooCanvas           *canvas);
 
213
void            goo_canvas_set_static_root_item    (GooCanvas           *canvas,
 
214
                                                    GooCanvasItem      *item);
 
215
 
 
216
GooCanvasItemModel* goo_canvas_get_static_root_item_model (GooCanvas           *canvas);
 
217
void                goo_canvas_set_static_root_item_model (GooCanvas           *canvas,
 
218
                                                           GooCanvasItemModel *model);
 
219
 
 
220
GooCanvasItem*  goo_canvas_get_item         (GooCanvas          *canvas,
 
221
                                             GooCanvasItemModel *model);
 
222
GooCanvasItem*  goo_canvas_get_item_at      (GooCanvas          *canvas,
 
223
                                             gdouble             x,
 
224
                                             gdouble             y,
 
225
                                             gboolean            is_pointer_event);
 
226
GList*          goo_canvas_get_items_at     (GooCanvas          *canvas,
 
227
                                             gdouble             x,
 
228
                                             gdouble             y,
 
229
                                             gboolean            is_pointer_event);
 
230
GList*          goo_canvas_get_items_in_area(GooCanvas          *canvas,
 
231
                                             const GooCanvasBounds *area,
 
232
                                             gboolean            inside_area,
 
233
                                             gboolean            allow_overlaps,
 
234
                                             gboolean            include_containers);
 
235
 
 
236
gdouble         goo_canvas_get_scale        (GooCanvas          *canvas);
 
237
void            goo_canvas_set_scale        (GooCanvas          *canvas,
 
238
                                             gdouble             scale);
 
239
 
 
240
void            goo_canvas_get_bounds       (GooCanvas          *canvas,
 
241
                                             gdouble            *left,
 
242
                                             gdouble            *top,
 
243
                                             gdouble            *right,
 
244
                                             gdouble            *bottom);
 
245
void            goo_canvas_set_bounds       (GooCanvas          *canvas,
 
246
                                             gdouble             left,
 
247
                                             gdouble             top,
 
248
                                             gdouble             right,
 
249
                                             gdouble             bottom);
 
250
 
 
251
void            goo_canvas_scroll_to        (GooCanvas          *canvas,
 
252
                                             gdouble             left,
 
253
                                             gdouble             top);
 
254
 
 
255
void            goo_canvas_grab_focus       (GooCanvas          *canvas,
 
256
                                             GooCanvasItem      *item);
 
257
 
 
258
void            goo_canvas_render           (GooCanvas             *canvas,
 
259
                                             cairo_t               *cr,
 
260
                                             const GooCanvasBounds *bounds,
 
261
                                             gdouble                scale);
 
262
 
 
263
/*
 
264
 * Coordinate conversion.
 
265
 */
 
266
void            goo_canvas_convert_to_pixels       (GooCanvas       *canvas,
 
267
                                                    gdouble         *x,
 
268
                                                    gdouble         *y);
 
269
void            goo_canvas_convert_from_pixels     (GooCanvas       *canvas,
 
270
                                                    gdouble         *x,
 
271
                                                    gdouble         *y);
 
272
 
 
273
void            goo_canvas_convert_to_item_space   (GooCanvas       *canvas,
 
274
                                                    GooCanvasItem   *item,
 
275
                                                    gdouble         *x,
 
276
                                                    gdouble         *y);
 
277
void            goo_canvas_convert_from_item_space (GooCanvas       *canvas,
 
278
                                                    GooCanvasItem   *item,
 
279
                                                    gdouble         *x,
 
280
                                                    gdouble         *y);
 
281
void            goo_canvas_convert_bounds_to_item_space (GooCanvas           *canvas,
 
282
                                                         GooCanvasItem       *item,
 
283
                                                         GooCanvasBounds     *bounds);
 
284
 
 
285
 
 
286
/*
 
287
 * Pointer/keyboard grabbing & ungrabbing.
 
288
 */
 
289
GdkGrabStatus   goo_canvas_pointer_grab     (GooCanvas          *canvas,
 
290
                                             GooCanvasItem      *item,
 
291
                                             GdkEventMask        event_mask,
 
292
                                             GdkCursor          *cursor,
 
293
                                             guint32             time);
 
294
void            goo_canvas_pointer_ungrab   (GooCanvas          *canvas,
 
295
                                             GooCanvasItem      *item,
 
296
                                             guint32             time);
 
297
GdkGrabStatus   goo_canvas_keyboard_grab    (GooCanvas          *canvas,
 
298
                                             GooCanvasItem      *item,
 
299
                                             gboolean            owner_events,
 
300
                                             guint32             time);
 
301
void            goo_canvas_keyboard_ungrab  (GooCanvas          *canvas,
 
302
                                             GooCanvasItem      *item,
 
303
                                             guint32             time);
 
304
 
 
305
 
 
306
/*
 
307
 * Internal functions, mainly for canvas subclasses and item implementations.
 
308
 */
 
309
cairo_t*        goo_canvas_create_cairo_context (GooCanvas *canvas);
 
310
GooCanvasItem*  goo_canvas_create_item      (GooCanvas          *canvas,
 
311
                                             GooCanvasItemModel *model);
 
312
void            goo_canvas_unregister_item  (GooCanvas          *canvas,
 
313
                                             GooCanvasItemModel *model);
 
314
void            goo_canvas_update           (GooCanvas          *canvas);
 
315
void            goo_canvas_request_update   (GooCanvas          *canvas);
 
316
void            goo_canvas_request_redraw   (GooCanvas          *canvas,
 
317
                                             const GooCanvasBounds *bounds);
 
318
void            goo_canvas_request_item_redraw   (GooCanvas             *canvas,
 
319
                                                  const GooCanvasBounds *bounds,
 
320
                                                  gboolean               is_static);
 
321
gdouble         goo_canvas_get_default_line_width (GooCanvas    *canvas);
 
322
 
 
323
 
 
324
void            goo_canvas_register_widget_item   (GooCanvas          *canvas,
 
325
                                                   GooCanvasWidget    *witem);
 
326
void            goo_canvas_unregister_widget_item (GooCanvas          *canvas,
 
327
                                                   GooCanvasWidget    *witem);
 
328
 
 
329
 
 
330
G_END_DECLS
 
331
 
 
332
#endif /* __GOO_CANVAS_H__ */