Inkscape
Vector Graphics Editor
view.cpp
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Authors:
4  * Lauris Kaplinski <lauris@kaplinski.com>
5  * Ralf Stephan <ralf@ark.in-berlin.de>
6  * Jon A. Cruz <jon@joncruz.org>
7  *
8  * Copyright (C) 2001-2002 Lauris Kaplinski
9  * Copyright (C) 2001 Ximian, Inc.
10  *
11  * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12  */
13 
14 #include <2geom/point.h>
15 #include <memory>
16 #include "document.h"
17 #include "view.h"
18 #include "message-stack.h"
19 #include "message-context.h"
20 #include "inkscape.h"
21 
22 namespace Inkscape {
23 namespace UI {
24 namespace View {
25 
27 : _doc(nullptr)
28 {
29  _message_stack = std::make_shared<Inkscape::MessageStack>();
30  _tips_message_context = std::make_unique<Inkscape::MessageContext>(_message_stack);
31 
32  _resized_connection = _resized_signal.connect([this] (double x, double y) {
33  onResized(x, y);
34  });
35 
36  _message_changed_connection = _message_stack->connectChanged([this] (Inkscape::MessageType type, const gchar *message) {
37  onStatusMessage(type, message);
38  });
39 }
40 
41 View::~View()
42 {
43  _close();
44 }
45 
46 void View::_close() {
47  _message_changed_connection.disconnect();
48 
49  _tips_message_context = nullptr;
50 
51  _message_stack = nullptr;
52 
53  if (_doc) {
54  _document_uri_set_connection.disconnect();
55  INKSCAPE.remove_document(_doc);
56  _doc = nullptr;
57  }
58 }
59 
60 void View::emitResized (double width, double height)
61 {
63 }
64 
65 void View::setDocument(SPDocument *doc) {
66  if (!doc) return;
67 
68  if (_doc) {
69  _document_uri_set_connection.disconnect();
70  INKSCAPE.remove_document(_doc);
71  }
72 
73  INKSCAPE.add_document(doc);
74 
75  _doc = doc;
76  _document_uri_set_connection = _doc->connectFilenameSet([this] (const gchar *filename) {
77  onDocumentFilenameSet(filename);
78  });
80 }
81 
82 } // namespace View
83 } // namespace UI
84 } // namespace Inkscape
85 
86 /*
87  Local Variables:
88  mode:c++
89  c-file-style:"stroustrup"
90  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
91  indent-tabs-mode:nil
92  fill-column:99
93  End:
94 */
95 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Inkscape::UI::View::View::_document_uri_set_connection
sigc::connection _document_uri_set_connection
Definition: view.h:125
SPDocument
Typed SVG document implementation.
Definition: document.h:105
SPDocument::getDocumentFilename
const char * getDocumentFilename() const
Definition: document.h:224
point.h
Cartesian point / 2D vector and related operations.
width
double width
Definition: convex_hull.cpp:106
Inkscape::UI::View::View::onStatusMessage
virtual void onStatusMessage(Inkscape::MessageType type, gchar const *message)
Definition: view.h:98
message-stack.h
Inkscape::MessageType
MessageType
A hint about the meaning of a message; is it an ordinary message, a message advising the user of some...
Definition: message.h:23
Inkscape
A class to represent a Bezier path.
Definition: actions-canvas-snapping.h:17
Inkscape::UI::View::View::_close
virtual void _close()
Definition: view.cpp:46
Inkscape::UI::View::View::doc
SPDocument * doc() const
Returns a pointer to the view's document.
Definition: view.h:86
Inkscape::UI::View::View
View is an abstract base class of all UI document views.
Definition: view.h:70
inkscape.h
Inkscape::UI::View::View::onDocumentFilenameSet
virtual void onDocumentFilenameSet(gchar const *filename)
Definition: view.h:99
Inkscape::UI::View::View::onResized
virtual void onResized(double, double)
Definition: view.h:97
Inkscape::UI::View::View::_resized_connection
sigc::connection _resized_connection
Definition: view.h:123
message-context.h
Inkscape::UI::View::View::_tips_message_context
std::unique_ptr< Inkscape::MessageContext > _tips_message_context
Definition: view.h:104
Inkscape::UI::View::View::_message_changed_connection
sigc::connection _message_changed_connection
Definition: view.h:124
view.h
SPDocument::connectFilenameSet
sigc::connection connectFilenameSet(FilenameSetSignal::slot_type slot)
Definition: document.cpp:2116
Inkscape::UI::View::View::_message_stack
std::shared_ptr< Inkscape::MessageStack > _message_stack
Definition: view.h:103
Inkscape::UI::View::View::_resized_signal
sigc::signal< void, double, double > _resized_signal
Definition: view.h:119
Inkscape::UI::View::View::_doc
SPDocument * _doc
Definition: view.h:99
height
double height
Definition: convex_hull.cpp:107
Inkscape::UI::View::View::_document_filename_set_signal
sigc::signal< void, gchar const * > _document_filename_set_signal
Definition: view.h:120