~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/desktop.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_DESKTOP_H
 
2
#define SEEN_SP_DESKTOP_H
 
3
 
 
4
/** \file
 
5
 * SPDesktop: an editable view.
 
6
 *
 
7
 * Author:
 
8
 *   Lauris Kaplinski <lauris@kaplinski.com>
 
9
 *   Frank Felfe <innerspace@iname.com>
 
10
 *   bulia byak <buliabyak@users.sf.net>
 
11
 *   Ralf Stephan <ralf@ark.in-berlin.de>
 
12
 *   John Bintz <jcoswell@coswellproductions.org>
 
13
 *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
 
14
 *
 
15
 * Copyright (C) 2007 Johan Engelen
 
16
 * Copyright (C) 2006 John Bintz
 
17
 * Copyright (C) 1999-2005 authors
 
18
 * Copyright (C) 2000-2001 Ximian, Inc.
 
19
 *
 
20
 * Released under GNU GPL, read the file 'COPYING' for more information
 
21
 *
 
22
 */
 
23
 
 
24
#ifdef HAVE_CONFIG_H
 
25
#include "config.h"
 
26
#endif
 
27
 
 
28
#include <gdk/gdkevents.h>
 
29
#include <gtk/gtktypeutils.h>
 
30
#include <sigc++/sigc++.h>
 
31
 
 
32
#include <2geom/matrix.h>
 
33
#include <2geom/rect.h>
 
34
 
 
35
#include "ui/view/view.h"
 
36
#include "ui/view/edit-widget-interface.h"
 
37
 
 
38
#include "display/rendermode.h"
 
39
#include "display/snap-indicator.h"
 
40
 
 
41
class NRRect;
 
42
class SPCSSAttr;
 
43
struct _GtkWidget;
 
44
typedef struct _GtkWidget GtkWidget;
 
45
struct SPCanvas;
 
46
struct SPCanvasItem;
 
47
struct SPCanvasGroup;
 
48
struct SPEventContext;
 
49
struct SPItem;
 
50
struct SPNamedView;
 
51
struct SPObject;
 
52
struct SPStyle;
 
53
 
 
54
namespace Gtk
 
55
{
 
56
  class Window;
 
57
}
 
58
 
 
59
typedef int sp_verb_t;
 
60
 
 
61
 
 
62
 
 
63
namespace Inkscape {
 
64
  class Application;
 
65
  class MessageContext;
 
66
  class Selection;
 
67
  class ObjectHierarchy;
 
68
  class LayerManager;
 
69
  class EventLog;
 
70
  namespace UI {
 
71
      namespace Dialog {
 
72
          class DialogManager;
 
73
      }
 
74
  }
 
75
  namespace Whiteboard {
 
76
      class SessionManager;
 
77
  }
 
78
  namespace Display {
 
79
      class TemporaryItemList;
 
80
      class TemporaryItem;
 
81
      //class SnapIndicator;
 
82
  }
 
83
}
 
84
 
 
85
/**
 
86
 * Editable view.
 
87
 *
 
88
 * @see \ref desktop-handles.h for desktop macros.
 
89
 */
 
90
struct SPDesktop : public Inkscape::UI::View::View
 
91
{
 
92
    Inkscape::UI::Dialog::DialogManager *_dlg_mgr;
 
93
    SPNamedView               *namedview;
 
94
    SPCanvas                  *canvas;
 
95
    /// current selection; will never generally be NULL
 
96
    Inkscape::Selection       *selection;
 
97
    SPEventContext            *event_context;
 
98
    Inkscape::LayerManager    *layer_manager;
 
99
    Inkscape::EventLog        *event_log;
 
100
 
 
101
    Inkscape::Display::TemporaryItemList *temporary_item_list;
 
102
    Inkscape::Display::SnapIndicator *snapindicator;
 
103
 
 
104
    SPCanvasItem  *acetate;
 
105
    SPCanvasGroup *main;
 
106
    SPCanvasGroup *gridgroup;
 
107
    SPCanvasGroup *guides;
 
108
    SPCanvasItem  *drawing;
 
109
    SPCanvasGroup *sketch;
 
110
    SPCanvasGroup *controls;
 
111
    SPCanvasGroup *tempgroup;   ///< contains temporary canvas items
 
112
    SPCanvasItem  *table;       ///< outside-of-page background
 
113
    SPCanvasItem  *page;        ///< page background
 
114
    SPCanvasItem  *page_border; ///< page border
 
115
    SPCSSAttr     *current;     ///< current style
 
116
    bool           _focusMode;  ///< Whether we're focused working or general working
 
117
 
 
118
    GList *zooms_past;
 
119
    GList *zooms_future;
 
120
    bool _quick_zoom_enabled; ///< Signifies that currently we're in quick zoom mode
 
121
    Geom::Rect _quick_zoom_stored_area;  ///< The area of the screen before quick zoom
 
122
    unsigned int dkey;
 
123
    unsigned int number;
 
124
    guint window_state;
 
125
    unsigned int interaction_disabled_counter;
 
126
    bool waiting_cursor;
 
127
 
 
128
    /// \todo fixme: This has to be implemented in different way */
 
129
    guint guides_active : 1;
 
130
 
 
131
    // storage for selected dragger used by GrDrag as it's
 
132
    // created and deleted by tools
 
133
    SPItem *gr_item;
 
134
    guint  gr_point_type;
 
135
    guint  gr_point_i;
 
136
    bool   gr_fill_or_stroke;
 
137
 
 
138
 
 
139
    Inkscape::ObjectHierarchy *_layer_hierarchy;
 
140
    gchar * _reconstruction_old_layer_id;
 
141
 
 
142
    sigc::signal<void, sp_verb_t>      _tool_changed;
 
143
    sigc::signal<void, SPObject *>     _layer_changed_signal;
 
144
    sigc::signal<bool, const SPCSSAttr *>::accumulated<StopOnTrue> _set_style_signal;
 
145
    sigc::signal<int, SPStyle *, int>::accumulated<StopOnNonZero> _query_style_signal;
 
146
    sigc::connection connectDocumentReplaced (const sigc::slot<void,SPDesktop*,SPDocument*> & slot)
 
147
    {
 
148
        return _document_replaced_signal.connect (slot);
 
149
    }
 
150
 
 
151
    sigc::connection connectEventContextChanged (const sigc::slot<void,SPDesktop*,SPEventContext*> & slot)
 
152
    {
 
153
        return _event_context_changed_signal.connect (slot);
 
154
    }
 
155
    sigc::connection connectSetStyle (const sigc::slot<bool, const SPCSSAttr *> & slot)
 
156
    {
 
157
        return _set_style_signal.connect (slot);
 
158
    }
 
159
    sigc::connection connectQueryStyle (const sigc::slot<int, SPStyle *, int> & slot)
 
160
    {
 
161
        return _query_style_signal.connect (slot);
 
162
    }
 
163
     // subselection is some sort of selection which is specific to the tool, such as a handle in gradient tool, or a text selection
 
164
    sigc::connection connectToolSubselectionChanged(const sigc::slot<void, gpointer> & slot) {
 
165
        return _tool_subselection_changed.connect(slot);
 
166
    }
 
167
    void emitToolSubselectionChanged(gpointer data);
 
168
    sigc::connection connectCurrentLayerChanged(const sigc::slot<void, SPObject *> & slot) {
 
169
        return _layer_changed_signal.connect(slot);
 
170
    }
 
171
 
 
172
    // Whiteboard changes
 
173
 
 
174
#ifdef WITH_INKBOARD
 
175
    Inkscape::Whiteboard::SessionManager* whiteboard_session_manager() {
 
176
        return _whiteboard_session_manager;
 
177
    }
 
178
 
 
179
    Inkscape::Whiteboard::SessionManager* _whiteboard_session_manager;
 
180
#endif
 
181
 
 
182
    SPDesktop();
 
183
    void init (SPNamedView* nv, SPCanvas* canvas);
 
184
    virtual ~SPDesktop();
 
185
    void destroy();
 
186
 
 
187
    Inkscape::MessageContext *guidesMessageContext() const {
 
188
        return _guides_message_context;
 
189
    }
 
190
 
 
191
    Inkscape::Display::TemporaryItem * add_temporary_canvasitem (SPCanvasItem *item, guint lifetime, bool move_to_bottom = true);
 
192
    void remove_temporary_canvasitem (Inkscape::Display::TemporaryItem * tempitem);
 
193
 
 
194
    void _setDisplayMode(Inkscape::RenderMode mode);
 
195
    void setDisplayModeNormal() {
 
196
        _setDisplayMode(Inkscape::RENDERMODE_NORMAL);
 
197
    }
 
198
    void setDisplayModeNoFilters() {
 
199
        _setDisplayMode(Inkscape::RENDERMODE_NO_FILTERS);
 
200
    }
 
201
    void setDisplayModeOutline() {
 
202
        _setDisplayMode(Inkscape::RENDERMODE_OUTLINE);
 
203
    }
 
204
    void displayModeToggle();
 
205
    Inkscape::RenderMode _display_mode;
 
206
    Inkscape::RenderMode _saved_display_mode;
 
207
    Inkscape::RenderMode getMode() const { return _display_mode; }
 
208
 
 
209
    Inkscape::UI::Widget::Dock* getDock() { return _widget->getDock(); }
 
210
 
 
211
    void set_active (bool new_active);
 
212
    SPObject *currentRoot() const;
 
213
    SPObject *currentLayer() const;
 
214
    void setCurrentLayer(SPObject *object);
 
215
    void toggleLayerSolo(SPObject *object);
 
216
    SPObject *layerForObject(SPObject *object);
 
217
    bool isLayer(SPObject *object) const;
 
218
    bool isWithinViewport(SPItem *item) const;
 
219
    bool itemIsHidden(SPItem const *item) const;
 
220
 
 
221
    void activate_guides (bool activate);
 
222
    void change_document (SPDocument *document);
 
223
 
 
224
    void set_event_context (GtkType type, const gchar *config);
 
225
    void push_event_context (GtkType type, const gchar *config, unsigned int key);
 
226
 
 
227
    void set_coordinate_status (Geom::Point p);
 
228
    SPItem *item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const;
 
229
    SPItem *item_at_point (Geom::Point const p, bool into_groups, SPItem *upto = NULL) const;
 
230
    SPItem *group_at_point (Geom::Point const p) const;
 
231
    Geom::Point point() const;
 
232
 
 
233
    Geom::Rect get_display_area() const;
 
234
    void set_display_area (double x0, double y0, double x1, double y1, double border, bool log = true);
 
235
    void set_display_area(Geom::Rect const &a, Geom::Coord border, bool log = true);
 
236
    void zoom_absolute (double cx, double cy, double zoom);
 
237
    void zoom_relative (double cx, double cy, double zoom);
 
238
    void zoom_absolute_keep_point (double cx, double cy, double px, double py, double zoom);
 
239
    void zoom_relative_keep_point (double cx, double cy, double zoom);
 
240
    void zoom_relative_keep_point (Geom::Point const &c, double const zoom)
 
241
    {
 
242
            zoom_relative_keep_point (c[Geom::X], c[Geom::Y], zoom);
 
243
    }
 
244
 
 
245
    void zoom_page();
 
246
    void zoom_page_width();
 
247
    void zoom_drawing();
 
248
    void zoom_selection();
 
249
    void zoom_grab_focus();
 
250
    double current_zoom() const  { return _d2w.descrim(); }
 
251
    void prev_zoom();
 
252
    void next_zoom();
 
253
    void zoom_quick(bool enable = true);
 
254
        /** \brief  Returns whether the desktop is in quick zoom mode or not */
 
255
        bool quick_zoomed(void) { return _quick_zoom_enabled; }
 
256
 
 
257
    bool scroll_to_point (Geom::Point const &s_dt, gdouble autoscrollspeed = 0);
 
258
    void scroll_world (double dx, double dy, bool is_scrolling = false);
 
259
    void scroll_world (Geom::Point const scroll, bool is_scrolling = false)
 
260
    {
 
261
        scroll_world(scroll[Geom::X], scroll[Geom::Y], is_scrolling);
 
262
    }
 
263
    void scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling = false);
 
264
 
 
265
    void getWindowGeometry (gint &x, gint &y, gint &w, gint &h);
 
266
    void setWindowPosition (Geom::Point p);
 
267
    void setWindowSize (gint w, gint h);
 
268
    void setWindowTransient (void* p, int transient_policy=1);
 
269
    Gtk::Window* getToplevel();
 
270
    void presentWindow();
 
271
    bool warnDialog (gchar *text);
 
272
    void toggleRulers();
 
273
    void toggleScrollbars();
 
274
    void layoutWidget();
 
275
    void destroyWidget();
 
276
    void setToolboxFocusTo (gchar const* label);
 
277
    void setToolboxAdjustmentValue (gchar const* id, double val);
 
278
    void setToolboxSelectOneValue (gchar const* id, gint val);
 
279
    bool isToolboxButtonActive (gchar const *id);
 
280
    void updateNow();
 
281
    void updateCanvasNow();
 
282
 
 
283
    void enableInteraction();
 
284
    void disableInteraction();
 
285
 
 
286
    void setWaitingCursor();
 
287
    void clearWaitingCursor();
 
288
    bool isWaitingCursor() const { return waiting_cursor; };
 
289
 
 
290
    void toggleColorProfAdjust();
 
291
 
 
292
    void toggleGrids();
 
293
    void toggleSnapGlobal();
 
294
    bool gridsEnabled() const { return grids_visible; };
 
295
    void showGrids(bool show, bool dirty_document = true);
 
296
 
 
297
    bool is_iconified();
 
298
    bool is_maximized();
 
299
    bool is_fullscreen();
 
300
    bool is_focusMode();
 
301
 
 
302
    void iconify();
 
303
    void maximize();
 
304
    void fullscreen();
 
305
    void focusMode(bool mode = true);
 
306
 
 
307
    void registerEditWidget (Inkscape::UI::View::EditWidgetInterface *widget)
 
308
    { _widget = widget; }
 
309
 
 
310
    Geom::Matrix w2d() const; //transformation from window to desktop coordinates (used for zooming)
 
311
    Geom::Point w2d(Geom::Point const &p) const;
 
312
    Geom::Point d2w(Geom::Point const &p) const;
 
313
    Geom::Matrix doc2dt() const;
 
314
    Geom::Matrix dt2doc() const;
 
315
    Geom::Point doc2dt(Geom::Point const &p) const;
 
316
    Geom::Point dt2doc(Geom::Point const &p) const;
 
317
 
 
318
    virtual void setDocument (SPDocument* doc);
 
319
    virtual bool shutdown();
 
320
    virtual void mouseover() {}
 
321
    virtual void mouseout() {}
 
322
 
 
323
    virtual bool onDeleteUI (GdkEventAny*);
 
324
    virtual bool onWindowStateEvent (GdkEventWindowState* event);
 
325
 
 
326
private:
 
327
    Inkscape::UI::View::EditWidgetInterface       *_widget;
 
328
    Inkscape::Application     *_inkscape;
 
329
    Inkscape::MessageContext  *_guides_message_context;
 
330
    bool _active;
 
331
    Geom::Matrix _w2d;
 
332
    Geom::Matrix _d2w;
 
333
    Geom::Matrix _doc2dt;
 
334
 
 
335
    bool grids_visible; /* don't set this variable directly, use the method below */
 
336
    void set_grids_visible(bool visible);
 
337
 
 
338
    void push_current_zoom (GList**);
 
339
 
 
340
    sigc::signal<void,SPDesktop*,SPDocument*>     _document_replaced_signal;
 
341
    sigc::signal<void>                 _activate_signal;
 
342
    sigc::signal<void>                 _deactivate_signal;
 
343
    sigc::signal<void,SPDesktop*,SPEventContext*> _event_context_changed_signal;
 
344
    sigc::signal<void, gpointer>       _tool_subselection_changed;
 
345
 
 
346
    sigc::connection _activate_connection;
 
347
    sigc::connection _deactivate_connection;
 
348
    sigc::connection _sel_modified_connection;
 
349
    sigc::connection _sel_changed_connection;
 
350
    sigc::connection _reconstruction_start_connection;
 
351
    sigc::connection _reconstruction_finish_connection;
 
352
    sigc::connection _commit_connection;
 
353
    sigc::connection _modified_connection;
 
354
 
 
355
    virtual void onPositionSet (double, double);
 
356
    virtual void onResized (double, double);
 
357
    virtual void onRedrawRequested();
 
358
    virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message);
 
359
    virtual void onDocumentURISet (gchar const* uri);
 
360
    virtual void onDocumentResized (double, double);
 
361
 
 
362
    static void _onActivate (SPDesktop* dt);
 
363
    static void _onDeactivate (SPDesktop* dt);
 
364
    static void _onSelectionModified (Inkscape::Selection *selection, guint flags, SPDesktop *dt);
 
365
};
 
366
 
 
367
#endif // SEEN_SP_DESKTOP_H
 
368
 
 
369
/*
 
370
  Local Variables:
 
371
  mode:c++
 
372
  c-file-style:"stroustrup"
 
373
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
374
  indent-tabs-mode:nil
 
375
  fill-column:99
 
376
  End:
 
377
*/
 
378
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :