~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/display/sp-canvas.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SEEN_SP_CANVAS_H
 
2
#define SEEN_SP_CANVAS_H
 
3
 
 
4
/** \file
 
5
 * SPCanvas, SPCanvasBuf, and SPCanvasItem.
 
6
 *
 
7
 * Authors:
 
8
 *   Federico Mena <federico@nuclecu.unam.mx>
 
9
 *   Raph Levien <raph@gimp.org>
 
10
 *   Lauris Kaplinski <lauris@kaplinski.com>
 
11
 *
 
12
 * Copyright (C) 1998 The Free Software Foundation
 
13
 * Copyright (C) 2002 Lauris Kaplinski
 
14
 *
 
15
 * Released under GNU GPL, read the file 'COPYING' for more information
 
16
 */
 
17
 
 
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>
 
35
 
 
36
#include <glibmm/ustring.h>
 
37
 
 
38
#include <2geom/matrix.h>
 
39
#include <libnr/nr-rect-l.h>
 
40
 
 
41
#include <2geom/rect.h>
 
42
 
 
43
G_BEGIN_DECLS
 
44
 
 
45
struct SPCanvas;
 
46
struct SPCanvasGroup;
 
47
typedef struct _SPCanvasItemClass SPCanvasItemClass;
 
48
 
 
49
enum {
 
50
    SP_CANVAS_UPDATE_REQUESTED  = 1 << 0,
 
51
    SP_CANVAS_UPDATE_AFFINE     = 1 << 1
 
52
};
 
53
 
 
54
/**
 
55
 * The canvas buf contains the actual pixels.
 
56
 */
 
57
struct SPCanvasBuf{
 
58
    guchar *buf;
 
59
    int buf_rowstride;
 
60
    NRRectL rect;
 
61
    NRRectL visible_rect;
 
62
    /// Background color, given as 0xrrggbb
 
63
    guint32 bg_color;
 
64
    // If empty, ignore contents of buffer and use a solid area of bg_color
 
65
    bool is_empty;
 
66
    cairo_t *ct;
 
67
};
 
68
 
 
69
/**
 
70
 * An SPCanvasItem refers to a SPCanvas and to its parent item; it has
 
71
 * four coordinates, a bounding rectangle, and a transformation matrix.
 
72
 */
 
73
struct SPCanvasItem : public GtkObject {
 
74
    SPCanvas *canvas;
 
75
    SPCanvasItem *parent;
 
76
 
 
77
    double x1, y1, x2, y2;
 
78
    Geom::Rect bounds;
 
79
    Geom::Matrix xform;
 
80
};
 
81
 
 
82
/**
 
83
 * The vtable of an SPCanvasItem.
 
84
 */
 
85
struct _SPCanvasItemClass : public GtkObjectClass {
 
86
    void (* update) (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
 
87
 
 
88
    void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
 
89
    double (* point) (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
 
90
 
 
91
    int (* event) (SPCanvasItem *item, GdkEvent *event);
 
92
};
 
93
 
 
94
SPCanvasItem *sp_canvas_item_new(SPCanvasGroup *parent, GtkType type, const gchar *first_arg_name, ...);
 
95
 
 
96
G_END_DECLS
 
97
 
 
98
#define sp_canvas_item_set gtk_object_set
 
99
 
 
100
void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Matrix const &aff);
 
101
 
 
102
void sp_canvas_item_raise(SPCanvasItem *item, int positions);
 
103
void sp_canvas_item_lower(SPCanvasItem *item, int positions);
 
104
void sp_canvas_item_show(SPCanvasItem *item);
 
105
void sp_canvas_item_hide(SPCanvasItem *item);
 
106
int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime);
 
107
void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime);
 
108
 
 
109
Geom::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item);
 
110
 
 
111
void sp_canvas_item_grab_focus(SPCanvasItem *item);
 
112
 
 
113
void sp_canvas_item_request_update(SPCanvasItem *item);
 
114
 
 
115
/* get item z-order in parent group */
 
116
 
 
117
gint sp_canvas_item_order(SPCanvasItem * item);
 
118
 
 
119
 
 
120
// SPCanvas -------------------------------------------------
 
121
/**
 
122
 * Port of GnomeCanvas for inkscape needs.
 
123
 */
 
124
struct SPCanvas {
 
125
    GtkWidget widget;
 
126
 
 
127
    guint idle_id;
 
128
 
 
129
    SPCanvasItem *root;
 
130
 
 
131
    double dx0, dy0;
 
132
    int x0, y0;
 
133
 
 
134
    /* Area that needs redrawing, stored as a microtile array */
 
135
    int    tLeft,tTop,tRight,tBottom;
 
136
    int    tileH,tileV;
 
137
    uint8_t *tiles;
 
138
 
 
139
    /* Last known modifier state, for deferred repick when a button is down */
 
140
    int state;
 
141
 
 
142
    /* The item containing the mouse pointer, or NULL if none */
 
143
    SPCanvasItem *current_item;
 
144
 
 
145
    /* Item that is about to become current (used to track deletions and such) */
 
146
    SPCanvasItem *new_current_item;
 
147
 
 
148
    /* Item that holds a pointer grab, or NULL if none */
 
149
    SPCanvasItem *grabbed_item;
 
150
 
 
151
    /* Event mask specified when grabbing an item */
 
152
    guint grabbed_event_mask;
 
153
 
 
154
    /* If non-NULL, the currently focused item */
 
155
    SPCanvasItem *focused_item;
 
156
 
 
157
    /* Event on which selection of current item is based */
 
158
    GdkEvent pick_event;
 
159
 
 
160
    int close_enough;
 
161
 
 
162
    /* GC for temporary draw pixmap */
 
163
    GdkGC *pixmap_gc;
 
164
 
 
165
    unsigned int need_update : 1;
 
166
    unsigned int need_redraw : 1;
 
167
    unsigned int need_repick : 1;
 
168
 
 
169
    int forced_redraw_count;
 
170
    int forced_redraw_limit;
 
171
 
 
172
    /* For use by internal pick_current_item() function */
 
173
    unsigned int left_grabbed_item : 1;
 
174
    /* For use by internal pick_current_item() function */
 
175
    unsigned int in_repick : 1;
 
176
 
 
177
    // In most tools Inkscape only generates enter and leave events
 
178
    // on the current item, but no other enter events if a mouse button
 
179
    // is depressed -- see function pick_current_item().  Some tools
 
180
    // may wish the canvas to generate to all enter events, (e.g., the
 
181
    // connector tool).  If so, they may temporarily set this flag to
 
182
    // 'true'.
 
183
    bool gen_all_enter_events;
 
184
 
 
185
    int rendermode;
 
186
 
 
187
#if ENABLE_LCMS
 
188
    bool enable_cms_display_adj;
 
189
    Glib::ustring* cms_key;
 
190
#endif // ENABLE_LCMS
 
191
 
 
192
    bool is_scrolling;
 
193
 
 
194
    Geom::Rect getViewbox() const;
 
195
    NR::IRect getViewboxIntegers() const;
 
196
};
 
197
 
 
198
GtkWidget *sp_canvas_new_aa();
 
199
 
 
200
SPCanvasGroup *sp_canvas_root(SPCanvas *canvas);
 
201
 
 
202
void sp_canvas_scroll_to(SPCanvas *canvas, double cx, double cy, unsigned int clear, bool is_scrolling = false);
 
203
void sp_canvas_update_now(SPCanvas *canvas);
 
204
 
 
205
void sp_canvas_request_redraw(SPCanvas *canvas, int x1, int y1, int x2, int y2);
 
206
void sp_canvas_force_full_redraw_after_interruptions(SPCanvas *canvas, unsigned int count);
 
207
void sp_canvas_end_forced_full_redraws(SPCanvas *canvas);
 
208
 
 
209
bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const &world);
 
210
 
 
211
void sp_canvas_window_to_world(SPCanvas const *canvas, double winx, double winy, double *worldx, double *worldy);
 
212
void sp_canvas_world_to_window(SPCanvas const *canvas, double worldx, double worldy, double *winx, double *winy);
 
213
 
 
214
Geom::Point sp_canvas_window_to_world(SPCanvas const *canvas, Geom::Point const win);
 
215
Geom::Point sp_canvas_world_to_window(SPCanvas const *canvas, Geom::Point const world);
 
216
 
 
217
#endif // SEEN_SP_CANVAS_H
 
218
 
 
219
/*
 
220
  Local Variables:
 
221
  mode:c++
 
222
  c-file-style:"stroustrup"
 
223
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
224
  indent-tabs-mode:nil
 
225
  fill-column:99
 
226
  End:
 
227
*/
 
228
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :