1 #ifndef SEEN_SP_DESKTOP_WIDGET_H
2 #define SEEN_SP_DESKTOP_WIDGET_H
4 /** \file
5 * SPDesktopWidget: handling Gtk events on a desktop.
6 *
7 * Authors:
8 * John Bintz <jcoswell@coswellproductions.org> (c) 2006
9 * Ralf Stephan <ralf@ark.in-berlin.de> (c) 2005, distrib. under GPL2
10 * ? -2004
11 */
13 #include <gtk/gtktooltips.h>
14 #include <gtk/gtkwindow.h>
16 #include "display/display-forward.h"
17 #include "libnr/nr-point.h"
18 #include "forward.h"
19 #include "message.h"
20 #include "ui/view/view-widget.h"
21 #include "ui/view/edit-widget-interface.h"
23 #include <sigc++/connection.h>
25 // forward declaration
26 typedef struct _EgeColorProfTracker EgeColorProfTracker;
29 #define SP_TYPE_DESKTOP_WIDGET (sp_desktop_widget_get_type ())
30 #define SP_DESKTOP_WIDGET(o) (GTK_CHECK_CAST ((o), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidget))
31 #define SP_DESKTOP_WIDGET_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), SP_TYPE_DESKTOP_WIDGET, SPDesktopWidgetClass))
32 #define SP_IS_DESKTOP_WIDGET(o) (GTK_CHECK_TYPE ((o), SP_TYPE_DESKTOP_WIDGET))
33 #define SP_IS_DESKTOP_WIDGET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_DESKTOP_WIDGET))
35 GtkType sp_desktop_widget_get_type();
37 void sp_desktop_widget_destroy (SPDesktopWidget* dtw);
39 void sp_desktop_widget_show_decorations(SPDesktopWidget *dtw, gboolean show);
40 void sp_desktop_widget_iconify(SPDesktopWidget *dtw);
41 void sp_desktop_widget_maximize(SPDesktopWidget *dtw);
42 void sp_desktop_widget_fullscreen(SPDesktopWidget *dtw);
43 void sp_desktop_widget_layout(SPDesktopWidget *dtw);
44 void sp_desktop_widget_update_zoom(SPDesktopWidget *dtw);
45 void sp_desktop_widget_update_rulers (SPDesktopWidget *dtw);
47 /* Show/hide rulers & scrollbars */
48 void sp_desktop_widget_toggle_rulers (SPDesktopWidget *dtw);
49 void sp_desktop_widget_toggle_scrollbars (SPDesktopWidget *dtw);
50 void sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale);
51 void sp_desktop_widget_toggle_color_prof_adj( SPDesktopWidget *dtw );
53 void sp_dtw_desktop_activate (SPDesktopWidget *dtw);
54 void sp_dtw_desktop_deactivate (SPDesktopWidget *dtw);
56 namespace Inkscape { namespace Widgets { class LayerSelector; } }
58 namespace Inkscape { namespace UI { namespace Widget { class SelectedStyle; } } }
60 /// A GtkEventBox on an SPDesktop.
61 struct SPDesktopWidget {
62 SPViewWidget viewwidget;
64 unsigned int update : 1;
66 sigc::connection modified_connection;
68 GtkTooltips *tt;
70 SPDesktop *desktop;
72 Gtk::Window *window;
74 // The root vbox of the window layout.
75 GtkWidget *vbox;
77 GtkWidget *menubar, *statusbar;
79 GtkWidget *panels;
81 GtkWidget *hscrollbar, *vscrollbar, *vscrollbar_box;
83 GtkWidget *tool_toolbox, *aux_toolbox, *commands_toolbox;
85 /* Rulers */
86 GtkWidget *hruler, *vruler;
87 GtkWidget *hruler_box, *vruler_box; // eventboxes for setting tooltips
89 GtkWidget *sticky_zoom;
90 GtkWidget *cms_adjust;
91 GtkWidget *coord_status;
92 GtkWidget *coord_status_x;
93 GtkWidget *coord_status_y;
94 GtkWidget *select_status;
95 GtkWidget *select_status_eventbox;
96 GtkWidget *zoom_status;
97 gulong zoom_update;
99 Inkscape::UI::Widget::Dock *dock;
101 Inkscape::UI::Widget::SelectedStyle *selected_style;
103 gint coord_status_id, select_status_id;
105 unsigned int _interaction_disabled_counter;
107 SPCanvas *canvas;
108 NR::Point ruler_origin;
109 double dt2r;
111 GtkAdjustment *hadj, *vadj;
113 Inkscape::Widgets::LayerSelector *layer_selector;
115 EgeColorProfTracker* _tracker;
117 struct WidgetStub : public Inkscape::UI::View::EditWidgetInterface {
118 SPDesktopWidget *_dtw;
119 SPDesktop *_dt;
120 WidgetStub (SPDesktopWidget* dtw) : _dtw(dtw) {}
122 virtual void setTitle (gchar const *uri)
123 { _dtw->updateTitle (uri); }
124 virtual Gtk::Window* getWindow()
125 { return _dtw->window; }
126 virtual void layout()
127 { sp_desktop_widget_layout (_dtw); }
128 virtual void present()
129 { _dtw->presentWindow(); }
130 virtual void getGeometry (gint &x, gint &y, gint &w, gint &h)
131 { _dtw->getWindowGeometry (x, y, w, h); }
132 virtual void setSize (gint w, gint h)
133 { _dtw->setWindowSize (w, h); }
134 virtual void setPosition (NR::Point p)
135 { _dtw->setWindowPosition (p); }
136 virtual void setTransient (void* p, int transient_policy)
137 { _dtw->setWindowTransient (p, transient_policy); }
138 virtual NR::Point getPointer()
139 { return _dtw->window_get_pointer(); }
140 virtual void setIconified()
141 { sp_desktop_widget_iconify (_dtw); }
142 virtual void setMaximized()
143 { sp_desktop_widget_maximize (_dtw); }
144 virtual void setFullscreen()
145 { sp_desktop_widget_fullscreen (_dtw); }
146 virtual bool shutdown()
147 { return _dtw->shutdown(); }
148 virtual void destroy()
149 {
150 if(_dtw->window != NULL)
151 delete _dtw->window;
152 _dtw->window = NULL;
153 }
155 virtual void requestCanvasUpdate()
156 { _dtw->requestCanvasUpdate(); }
157 virtual void requestCanvasUpdateAndWait()
158 { _dtw->requestCanvasUpdateAndWait(); }
159 virtual void enableInteraction()
160 { _dtw->enableInteraction(); }
161 virtual void disableInteraction()
162 { _dtw->disableInteraction(); }
163 virtual void activateDesktop()
164 { sp_dtw_desktop_activate (_dtw); }
165 virtual void deactivateDesktop()
166 { sp_dtw_desktop_deactivate (_dtw); }
167 virtual void viewSetPosition (NR::Point p)
168 { _dtw->viewSetPosition (p); }
169 virtual void updateRulers()
170 { sp_desktop_widget_update_rulers (_dtw); }
171 virtual void updateScrollbars (double scale)
172 { sp_desktop_widget_update_scrollbars (_dtw, scale); }
173 virtual void toggleRulers()
174 { sp_desktop_widget_toggle_rulers (_dtw); }
175 virtual void toggleScrollbars()
176 { sp_desktop_widget_toggle_scrollbars (_dtw); }
177 virtual void toggleColorProfAdjust()
178 { sp_desktop_widget_toggle_color_prof_adj(_dtw); }
179 virtual void updateZoom()
180 { sp_desktop_widget_update_zoom (_dtw); }
181 virtual void letZoomGrabFocus()
182 { _dtw->letZoomGrabFocus(); }
183 virtual void setToolboxFocusTo (const gchar * id)
184 { _dtw->setToolboxFocusTo (id); }
185 virtual void setToolboxAdjustmentValue (const gchar *id, double val)
186 { _dtw->setToolboxAdjustmentValue (id, val); }
187 virtual void setToolboxSelectOneValue (gchar const *id, int val)
188 { _dtw->setToolboxSelectOneValue (id, val); }
189 virtual bool isToolboxButtonActive (gchar const* id)
190 { return _dtw->isToolboxButtonActive (id); }
191 virtual void setCoordinateStatus (NR::Point p)
192 { _dtw->setCoordinateStatus (p); }
193 virtual void setMessage (Inkscape::MessageType type, gchar const* msg)
194 { _dtw->setMessage (type, msg); }
195 virtual bool warnDialog (gchar* text)
196 { return _dtw->warnDialog (text); }
197 virtual Inkscape::UI::Widget::Dock* getDock ()
198 { return _dtw->getDock(); }
199 };
201 WidgetStub *stub;
203 void setMessage(Inkscape::MessageType type, gchar const *message);
204 NR::Point window_get_pointer();
205 bool shutdown();
206 void viewSetPosition (NR::Point p);
207 void letZoomGrabFocus();
208 void getWindowGeometry (gint &x, gint &y, gint &w, gint &h);
209 void setWindowPosition (NR::Point p);
210 void setWindowSize (gint w, gint h);
211 void setWindowTransient (void *p, int transient_policy);
212 void presentWindow();
213 bool warnDialog (gchar *text);
214 void setToolboxFocusTo (gchar const *);
215 void setToolboxAdjustmentValue (gchar const * id, double value);
216 void setToolboxSelectOneValue (gchar const * id, gint value);
217 bool isToolboxButtonActive (gchar const *id);
218 void setCoordinateStatus(NR::Point p);
219 void requestCanvasUpdate();
220 void requestCanvasUpdateAndWait();
221 void enableInteraction();
222 void disableInteraction();
223 void updateTitle(gchar const *uri);
224 bool onFocusInEvent(GdkEventFocus*);
226 Inkscape::UI::Widget::Dock* getDock();
228 };
230 /// The SPDesktopWidget vtable
231 struct SPDesktopWidgetClass {
232 SPViewWidgetClass parent_class;
233 };
235 #endif /* !SEEN_SP_DESKTOP_WIDGET_H */
237 /*
238 Local Variables:
239 mode:c++
240 c-file-style:"stroustrup"
241 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
242 indent-tabs-mode:nil
243 fill-column:99
244 End:
245 */
246 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :