15
15
* Released under GNU GPL, read the file 'COPYING' for more information
22
#ifdef HAVE_INTTYPES_H
23
# include <inttypes.h>
30
#include <glib/gtypes.h>
31
#include <gdk/gdkevents.h>
32
#include <gdk/gdkgc.h>
33
#include <gtk/gtkobject.h>
34
#include <gtk/gtkwidget.h>
20
36
#include <libnr/nr-matrix.h>
21
37
#include <libnr/nr-rect.h>
22
38
#include <libnr/nr-rect-l.h>
24
#include <gtk/gtklayout.h>
26
#include <display/display-forward.h>
31
SP_CANVAS_UPDATE_REQUESTED = 1 << 0,
32
SP_CANVAS_UPDATE_AFFINE = 1 << 1
44
SP_CANVAS_UPDATE_REQUESTED = 1 << 0,
45
SP_CANVAS_UPDATE_AFFINE = 1 << 1
36
49
* The canvas buf contains the actual pixels.
38
51
struct SPCanvasBuf{
42
/// Background color, given as 0xrrggbb
44
/// Invariant: at least one of the following flags is true.
45
/// Set when the render rectangle area is the solid color bg_color.
46
unsigned int is_bg : 1;
47
/// Set when the render rectangle area is represented by the buf.
48
unsigned int is_buf : 1;
56
/// Background color, given as 0xrrggbb
58
// If empty, ignore contents of buffer and use a solid area of bg_color
52
63
* An SPCanvasItem refers to a SPCanvas and to its parent item; it has
53
64
* four coordinates, a bounding rectangle, and a transformation matrix.
55
struct SPCanvasItem : public GtkObject{
59
double x1, y1, x2, y2;
66
struct SPCanvasItem : public GtkObject {
70
double x1, y1, x2, y2;
65
76
* The vtable of an SPCanvasItem.
67
struct SPCanvasItemClass : public GtkObjectClass{
68
void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
70
void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
71
double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
73
int (* event) (SPCanvasItem *item, GdkEvent *event);
78
struct SPCanvasItemClass : public GtkObjectClass {
79
void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
81
void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
82
double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
84
int (* event) (SPCanvasItem *item, GdkEvent *event);
76
SPCanvasItem *sp_canvas_item_new (SPCanvasGroup *parent, GtkType type, const gchar *first_arg_name, ...);
87
SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GtkType type, const gchar *first_arg_name, ...);
78
89
#define sp_canvas_item_set gtk_object_set
80
void sp_canvas_item_affine_absolute (SPCanvasItem *item, NR::Matrix const &aff);
91
void sp_canvas_item_affine_absolute(SPCanvasItem *item, NR::Matrix const &aff);
82
void sp_canvas_item_raise (SPCanvasItem *item, int positions);
83
void sp_canvas_item_lower (SPCanvasItem *item, int positions);
84
void sp_canvas_item_show (SPCanvasItem *item);
85
void sp_canvas_item_hide (SPCanvasItem *item);
86
int sp_canvas_item_grab (SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime);
87
void sp_canvas_item_ungrab (SPCanvasItem *item, guint32 etime);
93
void sp_canvas_item_raise(SPCanvasItem *item, int positions);
94
void sp_canvas_item_lower(SPCanvasItem *item, int positions);
95
void sp_canvas_item_show(SPCanvasItem *item);
96
void sp_canvas_item_hide(SPCanvasItem *item);
97
int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime);
98
void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime);
89
100
NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item);
91
void sp_canvas_item_grab_focus (SPCanvasItem *item);
102
void sp_canvas_item_grab_focus(SPCanvasItem *item);
93
void sp_canvas_item_request_update (SPCanvasItem *item);
104
void sp_canvas_item_request_update(SPCanvasItem *item);
95
106
/* get item z-order in parent group */
97
gint sp_canvas_item_order (SPCanvasItem * item);
108
gint sp_canvas_item_order(SPCanvasItem * item);
100
111
// SPCanvas -------------------------------------------------
102
113
* Port of GnomeCanvas for inkscape needs.
104
115
struct SPCanvas {
114
/* Area that needs redrawing, stored as a microtile array */
115
int tLeft,tTop,tRight,tBottom;
119
/* Last known modifier state, for deferred repick when a button is down */
122
/* The item containing the mouse pointer, or NULL if none */
123
SPCanvasItem *current_item;
125
/* Item that is about to become current (used to track deletions and such) */
126
SPCanvasItem *new_current_item;
128
/* Item that holds a pointer grab, or NULL if none */
129
SPCanvasItem *grabbed_item;
131
/* Event mask specified when grabbing an item */
132
guint grabbed_event_mask;
134
/* If non-NULL, the currently focused item */
135
SPCanvasItem *focused_item;
137
/* Event on which selection of current item is based */
142
/* GC for temporary draw pixmap */
145
unsigned int need_update : 1;
146
unsigned int need_redraw : 1;
147
unsigned int need_repick : 1;
149
/* For use by internal pick_current_item() function */
150
unsigned int left_grabbed_item : 1;
151
/* For use by internal pick_current_item() function */
152
unsigned int in_repick : 1;
125
/* Area that needs redrawing, stored as a microtile array */
126
int tLeft,tTop,tRight,tBottom;
130
/* Last known modifier state, for deferred repick when a button is down */
133
/* The item containing the mouse pointer, or NULL if none */
134
SPCanvasItem *current_item;
136
/* Item that is about to become current (used to track deletions and such) */
137
SPCanvasItem *new_current_item;
139
/* Item that holds a pointer grab, or NULL if none */
140
SPCanvasItem *grabbed_item;
142
/* Event mask specified when grabbing an item */
143
guint grabbed_event_mask;
145
/* If non-NULL, the currently focused item */
146
SPCanvasItem *focused_item;
148
/* Event on which selection of current item is based */
153
/* GC for temporary draw pixmap */
156
unsigned int need_update : 1;
157
unsigned int need_redraw : 1;
158
unsigned int need_repick : 1;
160
/* For use by internal pick_current_item() function */
161
unsigned int left_grabbed_item : 1;
162
/* For use by internal pick_current_item() function */
163
unsigned int in_repick : 1;
165
// In most tools Inkscape only generates enter and leave events
166
// on the current item, but no other enter events if a mouse button
167
// is depressed -- see function pick_current_item(). Some tools
168
// may wish the canvas to generate to all enter events, (e.g., the
169
// connector tool). If so, they may temporarily set this flag to
171
bool gen_all_enter_events;
175
NR::Rect getViewbox() const;
155
GtkWidget *sp_canvas_new_aa (void);
157
SPCanvasGroup *sp_canvas_root (SPCanvas *canvas);
159
void sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear);
160
void sp_canvas_update_now (SPCanvas *canvas);
162
void sp_canvas_request_redraw (SPCanvas *canvas, int x1, int y1, int x2, int y2);
178
GtkWidget *sp_canvas_new_aa();
180
SPCanvasGroup *sp_canvas_root(SPCanvas *canvas);
182
void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear);
183
void sp_canvas_update_now(SPCanvas *canvas);
185
void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2);
164
187
void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy);
165
188
void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double worldy, double *winx, double *winy);