1 #ifndef INKSCAPE_UI_VIEW_VIEW_H
2 #define INKSCAPE_UI_VIEW_VIEW_H
4 /** \file
5 * Abstract base class for all SVG document views
6 *
7 * Authors:
8 * Lauris Kaplinski <lauris@kaplinski.com>
9 * Ralf Stephan <ralf@ark.in-berlin.de>
10 *
11 * Copyright (C) 2001-2002 Lauris Kaplinski
12 * Copyright (C) 2001 Ximian, Inc.
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include <gdk/gdktypes.h>
18 #include <sigc++/connection.h>
19 #include "message.h"
20 #include "gc-managed.h"
21 #include "gc-finalized.h"
22 #include "gc-anchored.h"
23 #include <libnr/nr-forward.h>
24 #include <2geom/forward.h>
26 /**
27 * Iterates until true or returns false.
28 * When used as signal accumulator, stops emission if one slot returns true.
29 */
30 struct StopOnTrue {
31 typedef bool result_type;
33 template<typename T_iterator>
34 result_type operator()(T_iterator first, T_iterator last) const{
35 for (; first != last; ++first)
36 if (*first) return true;
37 return false;
38 }
39 };
41 /**
42 * Iterates until nonzero or returns 0.
43 * When used as signal accumulator, stops emission if one slot returns nonzero.
44 */
45 struct StopOnNonZero {
46 typedef int result_type;
48 template<typename T_iterator>
49 result_type operator()(T_iterator first, T_iterator last) const{
50 for (; first != last; ++first)
51 if (*first) return *first;
52 return 0;
53 }
54 };
56 class SPDocument;
58 namespace Inkscape {
59 class MessageContext;
60 class MessageStack;
61 namespace UI {
62 namespace View {
64 /**
65 * View is an abstract base class of all UI document views. This
66 * includes both the editing window and the SVG preview, but does not
67 * include the non-UI RGBA buffer-based NRArena nor the XML editor or
68 * similar views. The View base class has very little functionality of
69 * its own.
70 */
71 class View : public GC::Managed<>,
72 public GC::Finalized,
73 public GC::Anchored
74 {
75 public:
77 View();
78 virtual ~View();
80 void close() { _close(); }
82 /// Returns a pointer to the view's document.
83 SPDocument *doc() const
84 { return _doc; }
85 /// Returns a pointer to the view's message stack.
86 Inkscape::MessageStack *messageStack() const
87 { return _message_stack; }
88 /// Returns a pointer to the view's tipsMessageContext.
89 Inkscape::MessageContext *tipsMessageContext() const
90 { return _tips_message_context; }
92 void setPosition(gdouble x, gdouble y);
93 void setPosition(Geom::Point const &p);
94 void emitResized(gdouble width, gdouble height);
95 void requestRedraw();
97 // view subclasses must give implementations of these methods
99 virtual bool shutdown() = 0;
100 virtual void mouseover() = 0;
101 virtual void mouseout() = 0;
103 virtual void onPositionSet (double, double) = 0;
104 virtual void onResized (double, double) = 0;
105 virtual void onRedrawRequested() = 0;
106 virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message) = 0;
107 virtual void onDocumentURISet (gchar const* uri) = 0;
108 virtual void onDocumentResized (double, double) = 0;
110 protected:
111 SPDocument *_doc;
112 Inkscape::MessageStack *_message_stack;
113 Inkscape::MessageContext *_tips_message_context;
115 virtual void _close();
116 virtual void setDocument(SPDocument *doc);
118 sigc::signal<void,double,double> _position_set_signal;
119 sigc::signal<void,double,double> _resized_signal;
120 sigc::signal<void,gchar const*> _document_uri_set_signal;
121 sigc::signal<void> _redraw_requested_signal;
123 private:
124 sigc::connection _position_set_connection;
125 sigc::connection _resized_connection;
126 sigc::connection _redraw_requested_connection;
127 sigc::connection _message_changed_connection; // foreign
128 sigc::connection _document_uri_set_connection; // foreign
129 sigc::connection _document_resized_connection; // foreign
130 };
132 }}}
134 #endif // INKSCAPE_UI_VIEW_VIEW_H
136 /*
137 Local Variables:
138 mode:c++
139 c-file-style:"stroustrup"
140 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
141 indent-tabs-mode:nil
142 fill-column:99
143 End:
144 */
145 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :