~valavanisalex/ubuntu/oneiric/inkscape/inkscape_0.48.1-2ubuntu4

« back to all changes in this revision

Viewing changes to src/display/sp-canvas.h

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2006-07-06 22:03:02 UTC
  • mto: (2.4.1 sid) (1.4.1 upstream) (45.1.3 maverick)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060706220302-itgso3qgxdaxjmcy
Tags: upstream-0.44
ImportĀ upstreamĀ versionĀ 0.44

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 * Released under GNU GPL, read the file 'COPYING' for more information
16
16
 */
17
17
 
18
 
#include <glib.h>
 
18
#ifdef HAVE_CONFIG_H
 
19
# include "config.h"
 
20
#endif
 
21
 
 
22
#ifdef HAVE_INTTYPES_H
 
23
# include <inttypes.h>
 
24
#else
 
25
# ifdef HAVE_STDINT_H
 
26
#  include <stdint.h>
 
27
# endif
 
28
#endif
 
29
 
 
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>
19
35
 
20
36
#include <libnr/nr-matrix.h>
21
37
#include <libnr/nr-rect.h>
22
38
#include <libnr/nr-rect-l.h>
23
 
#include <gdk/gdk.h>
24
 
#include <gtk/gtklayout.h>
25
 
 
26
 
#include <display/display-forward.h>
27
 
 
28
 
#include <inttypes.h>
 
39
 
 
40
struct SPCanvas;
 
41
struct SPCanvasGroup;
29
42
 
30
43
enum {
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
33
46
};
34
47
 
35
48
/**
36
49
 * The canvas buf contains the actual pixels.
37
50
 */
38
51
struct SPCanvasBuf{
39
 
        guchar *buf;
40
 
        int buf_rowstride;
41
 
        NRRectL rect;
42
 
        /// Background color, given as 0xrrggbb
43
 
        guint32 bg_color;
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;
 
52
    guchar *buf;
 
53
    int buf_rowstride;
 
54
    NRRectL rect;
 
55
    NRRectL visible_rect;
 
56
    /// Background color, given as 0xrrggbb
 
57
    guint32 bg_color;
 
58
    // If empty, ignore contents of buffer and use a solid area of bg_color
 
59
    bool is_empty;
49
60
};
50
61
 
51
62
/**
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.
54
65
 */
55
 
struct SPCanvasItem : public GtkObject{
56
 
        SPCanvas *canvas;
57
 
        SPCanvasItem *parent;
58
 
 
59
 
        double x1, y1, x2, y2;
60
 
        NR::Rect bounds;
61
 
        NR::Matrix xform;
 
66
struct SPCanvasItem : public GtkObject {
 
67
    SPCanvas *canvas;
 
68
    SPCanvasItem *parent;
 
69
    
 
70
    double x1, y1, x2, y2;
 
71
    NR::Rect bounds;
 
72
    NR::Matrix xform;
62
73
};
63
74
 
64
75
/**
65
76
 * The vtable of an SPCanvasItem.
66
77
 */
67
 
struct SPCanvasItemClass : public GtkObjectClass{
68
 
        void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
69
 
 
70
 
        void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
71
 
        double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
72
 
 
73
 
        int (* event) (SPCanvasItem *item, GdkEvent *event);
 
78
struct SPCanvasItemClass : public GtkObjectClass {
 
79
    void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
 
80
    
 
81
    void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
 
82
    double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
 
83
    
 
84
    int (* event) (SPCanvasItem *item, GdkEvent *event);
74
85
};
75
86
 
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, ...);
77
88
 
78
89
#define sp_canvas_item_set gtk_object_set
79
90
 
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);
81
92
 
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);
88
99
 
89
100
NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item);
90
101
 
91
 
void sp_canvas_item_grab_focus (SPCanvasItem *item);
 
102
void sp_canvas_item_grab_focus(SPCanvasItem *item);
92
103
 
93
 
void sp_canvas_item_request_update (SPCanvasItem *item);
 
104
void sp_canvas_item_request_update(SPCanvasItem *item);
94
105
 
95
106
/* get item z-order in parent group */
96
107
 
97
 
gint sp_canvas_item_order (SPCanvasItem * item);
 
108
gint sp_canvas_item_order(SPCanvasItem * item);
98
109
 
99
110
 
100
111
// SPCanvas -------------------------------------------------
102
113
 * Port of GnomeCanvas for inkscape needs.
103
114
 */
104
115
struct SPCanvas {
105
 
        GtkWidget widget;
106
 
 
107
 
        guint idle_id;
108
 
 
109
 
        SPCanvasItem *root;
110
 
 
111
 
        double dx0, dy0;
112
 
        int x0, y0;
113
 
 
114
 
        /* Area that needs redrawing, stored as a microtile array */
115
 
        int    tLeft,tTop,tRight,tBottom;
116
 
        int    tileH,tileV;
117
 
        uint8_t *tiles;
118
 
  
119
 
        /* Last known modifier state, for deferred repick when a button is down */
120
 
        int state;
121
 
 
122
 
        /* The item containing the mouse pointer, or NULL if none */
123
 
        SPCanvasItem *current_item;
124
 
 
125
 
        /* Item that is about to become current (used to track deletions and such) */
126
 
        SPCanvasItem *new_current_item;
127
 
 
128
 
        /* Item that holds a pointer grab, or NULL if none */
129
 
        SPCanvasItem *grabbed_item;
130
 
 
131
 
        /* Event mask specified when grabbing an item */
132
 
        guint grabbed_event_mask;
133
 
 
134
 
        /* If non-NULL, the currently focused item */
135
 
        SPCanvasItem *focused_item;
136
 
 
137
 
        /* Event on which selection of current item is based */
138
 
        GdkEvent pick_event;
139
 
 
140
 
        int close_enough;
141
 
 
142
 
        /* GC for temporary draw pixmap */
143
 
        GdkGC *pixmap_gc;
144
 
 
145
 
        unsigned int need_update : 1;
146
 
        unsigned int need_redraw : 1;
147
 
        unsigned int need_repick : 1;
148
 
 
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;
 
116
    GtkWidget widget;
 
117
    
 
118
    guint idle_id;
 
119
    
 
120
    SPCanvasItem *root;
 
121
    
 
122
    double dx0, dy0;
 
123
    int x0, y0;
 
124
    
 
125
    /* Area that needs redrawing, stored as a microtile array */
 
126
    int    tLeft,tTop,tRight,tBottom;
 
127
    int    tileH,tileV;
 
128
    uint8_t *tiles;
 
129
    
 
130
    /* Last known modifier state, for deferred repick when a button is down */
 
131
    int state;
 
132
    
 
133
    /* The item containing the mouse pointer, or NULL if none */
 
134
    SPCanvasItem *current_item;
 
135
    
 
136
    /* Item that is about to become current (used to track deletions and such) */
 
137
    SPCanvasItem *new_current_item;
 
138
    
 
139
    /* Item that holds a pointer grab, or NULL if none */
 
140
    SPCanvasItem *grabbed_item;
 
141
    
 
142
    /* Event mask specified when grabbing an item */
 
143
    guint grabbed_event_mask;
 
144
    
 
145
    /* If non-NULL, the currently focused item */
 
146
    SPCanvasItem *focused_item;
 
147
    
 
148
    /* Event on which selection of current item is based */
 
149
    GdkEvent pick_event;
 
150
    
 
151
    int close_enough;
 
152
    
 
153
    /* GC for temporary draw pixmap */
 
154
    GdkGC *pixmap_gc;
 
155
    
 
156
    unsigned int need_update : 1;
 
157
    unsigned int need_redraw : 1;
 
158
    unsigned int need_repick : 1;
 
159
    
 
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;
 
164
 
 
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
 
170
    // 'true'.
 
171
    bool gen_all_enter_events;
 
172
    
 
173
    int rendermode;
 
174
    
 
175
    NR::Rect getViewbox() const;
153
176
};
154
177
 
155
 
GtkWidget *sp_canvas_new_aa (void);
156
 
 
157
 
SPCanvasGroup *sp_canvas_root (SPCanvas *canvas);
158
 
 
159
 
void sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear);
160
 
void sp_canvas_update_now (SPCanvas *canvas);
161
 
 
162
 
void sp_canvas_request_redraw (SPCanvas *canvas, int x1, int y1, int x2, int y2);
 
178
GtkWidget *sp_canvas_new_aa();
 
179
 
 
180
SPCanvasGroup *sp_canvas_root(SPCanvas *canvas);
 
181
 
 
182
void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear);
 
183
void sp_canvas_update_now(SPCanvas *canvas);
 
184
 
 
185
void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2);
163
186
 
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);
169
192
 
170
193
bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, NR::Point const &world);
171
194
 
172
 
NRRect *sp_canvas_get_viewbox(SPCanvas const *canvas, NRRect *viewbox);
173
 
 
174
 
 
175
195
#endif
 
196
 
 
197
/*
 
198
  Local Variables:
 
199
  mode:c++
 
200
  c-file-style:"stroustrup"
 
201
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
202
  indent-tabs-mode:nil
 
203
  fill-column:99
 
204
  End:
 
205
*/
 
206
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :