Code

added SPDesktop::updateNow() and forced redraw of canvas upon completion of selection...
[inkscape.git] / src / desktop.h
1 #ifndef __SP_DESKTOP_H__
2 #define __SP_DESKTOP_H__
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  *
13  * Copyright (C) 1999-2005 authors
14  * Copyright (C) 2000-2001 Ximian, Inc.
15  *
16  * Released under GNU GPL, read the file 'COPYING' for more information
17  *
18  */
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include <gtk/gtktypeutils.h>
25 #include <sigc++/sigc++.h>
26 #include "libnr/nr-matrix.h"
27 #include "libnr/nr-matrix-fns.h"
28 #include "libnr/nr-rect.h"
29 #include "ui/view/view.h"
30 #include "ui/view/edit-widget-interface.h"
32 class NRRect;
33 class SPCSSAttr;
34 struct SPCanvas;
35 struct SPCanvasItem;
36 struct SPCanvasGroup;
37 struct SPDesktopWidget;
38 struct SPEventContext;
39 struct SPItem;
40 struct SPNamedView;
41 struct SPObject;
42 struct SPStyle;
43 struct SPViewWidget;
45 typedef int sp_verb_t;
47 namespace Inkscape { 
48   class Application;
49   class MessageContext;
50   class Selection; 
51   class ObjectHierarchy;
52   class LayerManager;
53   namespace UI { 
54       namespace Dialog { 
55           class DialogManager; 
56       }
57   }
58   namespace Whiteboard {
59       class SessionManager;
60   }
61 }
63 /**
64  * Editable view.
65  *
66  * @see \ref desktop-handles.h for desktop macros.
67  */
68 struct SPDesktop : public Inkscape::UI::View::View
69 {
70     Inkscape::UI::Dialog::DialogManager *_dlg_mgr;
71     SPNamedView               *namedview;
72     SPCanvas                  *canvas;
73     /// current selection; will never generally be NULL
74     Inkscape::Selection       *selection;
75     SPEventContext            *event_context;
76     Inkscape::LayerManager    *layer_manager;
78     SPCanvasItem  *acetate;
79     SPCanvasGroup *main;
80     SPCanvasGroup *grid;
81     SPCanvasGroup *guides;
82     SPCanvasItem  *drawing;
83     SPCanvasGroup *sketch;
84     SPCanvasGroup *controls;
85     SPCanvasItem  *table;       ///< outside-of-page background
86     SPCanvasItem  *page;        ///< page background
87     SPCanvasItem  *page_border; ///< page border
88     SPCSSAttr     *current;     ///< current style
90     GList *zooms_past;
91     GList *zooms_future;
92     unsigned int dkey;
93     unsigned int number;
94     bool is_fullscreen;
96     /// \todo fixme: This has to be implemented in different way */
97     guint guides_active : 1;
99     // storage for selected dragger used by GrDrag as it's 
100     // created and deleted by tools
101     SPItem *gr_item;
102     guint  gr_point_num;
103     bool   gr_fill_or_stroke;   
105     Inkscape::ObjectHierarchy *_layer_hierarchy;
106     gchar * _reconstruction_old_layer_id;
108     sigc::signal<void, sp_verb_t>      _tool_changed;
109     sigc::signal<void, SPObject *>     _layer_changed_signal;
110     sigc::signal<bool, const SPCSSAttr *>::accumulated<StopOnTrue> _set_style_signal;
111     sigc::signal<int, SPStyle *, int>::accumulated<StopOnNonZero> _query_style_signal;
112     sigc::connection connectDocumentReplaced (const sigc::slot<void,SPDesktop*,SPDocument*> & slot)
113     {
114         return _document_replaced_signal.connect (slot);
115     }
116     
117     sigc::connection connectEventContextChanged (const sigc::slot<void,SPDesktop*,SPEventContext*> & slot) 
118     {
119         return _event_context_changed_signal.connect (slot);
120     }
121     sigc::connection connectSetStyle (const sigc::slot<bool, const SPCSSAttr *> & slot) 
122     {
123         return _set_style_signal.connect (slot);
124     }
125     sigc::connection connectQueryStyle (const sigc::slot<int, SPStyle *, int> & slot) 
126     {
127         return _query_style_signal.connect (slot);
128     }
129      // subselection is some sort of selection which is specific to the tool, such as a handle in gradient tool, or a text selection
130     sigc::connection connectToolSubselectionChanged(const sigc::slot<void, gpointer> & slot) {
131         return _tool_subselection_changed.connect(slot);
132     }
133     void emitToolSubselectionChanged(gpointer data); 
134     sigc::connection connectCurrentLayerChanged(const sigc::slot<void, SPObject *> & slot) {
135         return _layer_changed_signal.connect(slot);
136     }
137     
138         // Whiteboard changes
140 #ifdef WITH_INKBOARD
141         Inkscape::Whiteboard::SessionManager* whiteboard_session_manager() {
142         return _whiteboard_session_manager;
143         }
145         Inkscape::Whiteboard::SessionManager* _whiteboard_session_manager;
146 #endif
147    
148     SPDesktop();
149     void init (SPNamedView* nv, SPCanvas* canvas);
150     ~SPDesktop();
151     void destroy();
153     Inkscape::MessageContext *guidesMessageContext() const {
154         return _guides_message_context;
155     }
157     void setDisplayModeNormal();
158     void setDisplayModeOutline();
160     void set_active (bool new_active);
161     SPObject *currentRoot() const;
162     SPObject *currentLayer() const;
163     void setCurrentLayer(SPObject *object);
164     SPObject *layerForObject(SPObject *object);
165     bool isLayer(SPObject *object) const;
166     bool isWithinViewport(SPItem *item) const;
167     bool itemIsHidden(SPItem const *item) const;
168     
169     void activate_guides (bool activate);
170     void change_document (SPDocument *document);
172     void set_event_context (GtkType type, const gchar *config);
173     void push_event_context (GtkType type, const gchar *config, unsigned int key);
175     void set_coordinate_status (NR::Point p);
176     SPItem *item_from_list_at_point_bottom (const GSList *list, NR::Point const p) const;
177     SPItem *item_at_point (NR::Point const p, bool into_groups, SPItem *upto = NULL) const;
178     SPItem *group_at_point (NR::Point const p) const;
179     NR::Point point() const;
181     NR::Rect get_display_area() const;
182     void set_display_area (double x0, double y0, double x1, double y1, double border, bool log = true);
183     void set_display_area(NR::Rect const &a, NR::Coord border, bool log = true);
184     void zoom_absolute (double cx, double cy, double zoom);
185     void zoom_relative (double cx, double cy, double zoom);
186     void zoom_absolute_keep_point (double cx, double cy, double px, double py, double zoom);
187     void zoom_relative_keep_point (double cx, double cy, double zoom);
188     void zoom_relative_keep_point (NR::Point const &c, double const zoom)
189     {
190             using NR::X;
191             using NR::Y;
192             zoom_relative_keep_point (c[X], c[Y], zoom);
193     }
195     void zoom_page();
196     void zoom_page_width();
197     void zoom_drawing();
198     void zoom_selection();
199     void zoom_grab_focus();
200     double current_zoom() const  { return _d2w.expansion(); }
201     void prev_zoom();
202     void next_zoom();
204     bool scroll_to_point (NR::Point const *s_dt, gdouble autoscrollspeed = 0);
205     void scroll_world (double dx, double dy);
206     void scroll_world (NR::Point const scroll)
207     {
208         using NR::X;
209         using NR::Y;
210         scroll_world(scroll[X], scroll[Y]);
211     }
213     void getWindowGeometry (gint &x, gint &y, gint &w, gint &h);
214     void setWindowPosition (NR::Point p);
215     void setWindowSize (gint w, gint h);
216     void setWindowTransient (void* p, int transient_policy=1);
217     void presentWindow();
218     bool warnDialog (gchar *text);
219     void toggleRulers();
220     void toggleScrollbars();
221     void layoutWidget();
222     void destroyWidget();
223     void setToolboxFocusTo (gchar const* label);
224     void setToolboxAdjustmentValue (gchar const* id, double val);
225     bool isToolboxButtonActive (gchar const *id);
226     void updateNow();
227     
228     void fullscreen();
230     void registerEditWidget (Inkscape::UI::View::EditWidgetInterface *widget)
231     { _widget = widget; }
233     NR::Matrix w2d() const;
234     NR::Point w2d(NR::Point const &p) const;
235     NR::Point d2w(NR::Point const &p) const;
236     NR::Matrix doc2dt() const;
237     NR::Point doc2dt(NR::Point const &p) const;
238     NR::Point dt2doc(NR::Point const &p) const;
240     virtual void setDocument (SPDocument* doc);
241     virtual bool shutdown();
242     virtual void mouseover() {}
243     virtual void mouseout() {}
245 private:
246     Inkscape::UI::View::EditWidgetInterface       *_widget;
247     Inkscape::Application     *_inkscape;
248     Inkscape::MessageContext  *_guides_message_context;
249     bool _active;
250     NR::Matrix _w2d;
251     NR::Matrix _d2w;
252     NR::Matrix _doc2dt;
253     
254     void push_current_zoom (GList**);
256     sigc::signal<void,SPDesktop*,SPDocument*>     _document_replaced_signal;
257     sigc::signal<void>                 _activate_signal;
258     sigc::signal<void>                 _deactivate_signal;
259     sigc::signal<void,SPDesktop*,SPEventContext*> _event_context_changed_signal;
260     sigc::signal<void, gpointer>       _tool_subselection_changed;
261   
262     sigc::connection _activate_connection;
263     sigc::connection _deactivate_connection;
264     sigc::connection _sel_modified_connection;
265     sigc::connection _sel_changed_connection;
266     sigc::connection _reconstruction_start_connection;
267     sigc::connection _reconstruction_finish_connection;
268     sigc::connection _commit_connection;
269     
270     virtual void onPositionSet (double, double);
271     virtual void onResized (double, double);
272     virtual void onRedrawRequested();
273     virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message);
274     virtual void onDocumentURISet (gchar const* uri);
275     virtual void onDocumentResized (double, double);
277     static void _onActivate (SPDesktop* dt);
278     static void _onDeactivate (SPDesktop* dt);
279     static void _onSelectionModified (Inkscape::Selection *selection, guint flags, SPDesktop *dt);
280 };
282 #endif
284 /*
285   Local Variables:
286   mode:c++
287   c-file-style:"stroustrup"
288   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
289   indent-tabs-mode:nil
290   fill-column:99
291   End:
292 */
293 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :