2
* GooCanvas. Copyright (C) 2005 Damon Chaplin.
3
* Released under the GNU LGPL license. See COPYING for details.
5
* goocanvas.h - the main canvas widget.
7
#ifndef __GOO_CANVAS_H__
8
#define __GOO_CANVAS_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>
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))
35
typedef struct _GooCanvasClass GooCanvasClass;
40
* The #GooCanvas-struct struct contains private data only.
44
GtkContainer container;
46
/* The model for the root item, in model/view mode. */
47
GooCanvasItemModel *root_item_model;
49
/* The root canvas item. */
50
GooCanvasItem *root_item;
52
/* The bounds of the canvas, in canvas units (not pixels). */
53
GooCanvasBounds bounds;
55
/* The scale/zoom factors of the canvas. */
56
gdouble scale_x, scale_y;
58
/* The minimum of scale_x and scale_y, to compare with items' visibility
62
/* Where the canvas is anchored (where it is displayed when it is smaller
63
than the entire window). */
66
/* Idle handler ID, for processing updates. */
69
/* This is TRUE if some item in the canvas needs an update. */
70
guint need_update : 1;
72
/* This is TRUE if all items in the canvas need to be updated. */
73
guint need_entire_subtree_update : 1;
75
/* This is TRUE if all layout should be done to the nearest integer. */
76
guint integer_layout : 1;
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;
82
/* This is TRUE if the automatic bounds are calculated from the origin. */
83
guint bounds_from_origin : 1;
85
/* This is TRUE if the background is cleared before painting the canvas. */
86
guint clear_background : 1;
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;
92
/* This is the padding around the automatic bounds. */
93
gdouble bounds_padding;
95
/* The item that the mouse is over. */
96
GooCanvasItem *pointer_item;
98
/* The item that has the pointer grab, or NULL. */
99
GooCanvasItem *pointer_grab_item;
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;
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;
109
/* The item that has the keyboard focus, or NULL. */
110
GooCanvasItem *focused_item;
112
/* The item that has the keyboard grab, or NULL. */
113
GooCanvasItem *keyboard_grab_item;
115
/* The synthesized event used for sending enter-notify and leave-notify
117
GdkEventCrossing crossing_event;
119
/* The main canvas window, which gets scrolled around. */
120
GdkWindow *canvas_window;
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
125
gint canvas_x_offset;
126
gint canvas_y_offset;
128
/* The adjustments used for scrolling. */
129
GtkAdjustment *hadjustment;
130
GtkAdjustment *vadjustment;
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. */
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;
140
/* A hash table mapping canvas item models to canvas items. */
141
GHashTable *model_to_item;
143
/* The units of the canvas, which applies to all item coords. */
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;
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;
154
/* The list of child widgets (using GooCanvasWidget items). */
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.
165
* The #GooCanvasClass-struct struct contains one virtual method that
166
* subclasses may override.
168
struct _GooCanvasClass
171
GtkContainerClass parent_class;
173
void (* set_scroll_adjustments) (GooCanvas *canvas,
174
GtkAdjustment *hadjustment,
175
GtkAdjustment *vadjustment);
177
/* Virtual methods. */
179
GooCanvasItem* (* create_item) (GooCanvas *canvas,
180
GooCanvasItemModel *model);
183
void (* item_created) (GooCanvas *canvas,
185
GooCanvasItemModel *model);
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);
201
GType goo_canvas_get_type (void) G_GNUC_CONST;
202
GtkWidget* goo_canvas_new (void);
204
GooCanvasItem* goo_canvas_get_root_item (GooCanvas *canvas);
205
void goo_canvas_set_root_item (GooCanvas *canvas,
206
GooCanvasItem *item);
208
GooCanvasItemModel* goo_canvas_get_root_item_model (GooCanvas *canvas);
209
void goo_canvas_set_root_item_model (GooCanvas *canvas,
210
GooCanvasItemModel *model);
212
GooCanvasItem* goo_canvas_get_static_root_item (GooCanvas *canvas);
213
void goo_canvas_set_static_root_item (GooCanvas *canvas,
214
GooCanvasItem *item);
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);
220
GooCanvasItem* goo_canvas_get_item (GooCanvas *canvas,
221
GooCanvasItemModel *model);
222
GooCanvasItem* goo_canvas_get_item_at (GooCanvas *canvas,
225
gboolean is_pointer_event);
226
GList* goo_canvas_get_items_at (GooCanvas *canvas,
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);
236
gdouble goo_canvas_get_scale (GooCanvas *canvas);
237
void goo_canvas_set_scale (GooCanvas *canvas,
240
void goo_canvas_get_bounds (GooCanvas *canvas,
245
void goo_canvas_set_bounds (GooCanvas *canvas,
251
void goo_canvas_scroll_to (GooCanvas *canvas,
255
void goo_canvas_grab_focus (GooCanvas *canvas,
256
GooCanvasItem *item);
258
void goo_canvas_render (GooCanvas *canvas,
260
const GooCanvasBounds *bounds,
264
* Coordinate conversion.
266
void goo_canvas_convert_to_pixels (GooCanvas *canvas,
269
void goo_canvas_convert_from_pixels (GooCanvas *canvas,
273
void goo_canvas_convert_to_item_space (GooCanvas *canvas,
277
void goo_canvas_convert_from_item_space (GooCanvas *canvas,
281
void goo_canvas_convert_bounds_to_item_space (GooCanvas *canvas,
283
GooCanvasBounds *bounds);
287
* Pointer/keyboard grabbing & ungrabbing.
289
GdkGrabStatus goo_canvas_pointer_grab (GooCanvas *canvas,
291
GdkEventMask event_mask,
294
void goo_canvas_pointer_ungrab (GooCanvas *canvas,
297
GdkGrabStatus goo_canvas_keyboard_grab (GooCanvas *canvas,
299
gboolean owner_events,
301
void goo_canvas_keyboard_ungrab (GooCanvas *canvas,
307
* Internal functions, mainly for canvas subclasses and item implementations.
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,
321
gdouble goo_canvas_get_default_line_width (GooCanvas *canvas);
324
void goo_canvas_register_widget_item (GooCanvas *canvas,
325
GooCanvasWidget *witem);
326
void goo_canvas_unregister_widget_item (GooCanvas *canvas,
327
GooCanvasWidget *witem);
332
#endif /* __GOO_CANVAS_H__ */