Inkscape
Vector Graphics Editor
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Concepts
dialog-base.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
13#ifndef INK_DIALOG_BASE_H
14#define INK_DIALOG_BASE_H
15
16#include <glibmm/ustring.h>
17#include <gtk/gtk.h> // GtkEventControllerKey
18#include <gtkmm/box.h>
19
21
22namespace Gtk {
23class EventControllerKey;
24}
25
26class SPDesktop;
27
28namespace Inkscape::UI::Dialog {
29
40class DialogBase : public Gtk::Box
41{
42 using parent_type = Gtk::Box;
43
44public:
45 DialogBase(char const *prefs_path = nullptr, Glib::ustring dialog_type = {});
46 DialogBase(DialogBase const &) = delete;
47 DialogBase &operator=(DialogBase const &) = delete;
48 ~DialogBase() override;
49
56 virtual void update() {}
57
58 // Public for future use, say if the desktop is smartly set when docking dialogs.
59 void setDesktop(SPDesktop *new_desktop);
60
61 void on_map() override;
62
63 Glib::ustring const &get_name () const { return _name ; }
64 Glib::ustring const &getPrefsPath() const { return _prefs_path ; }
65 Glib::ustring const &get_type () const { return _dialog_type; }
66 const Glib::ustring& get_icon() const { return _icon_name; }
67
68 void blink();
69 // find focusable widget to grab focus
70 void focus_dialog();
71 // return focus back to canvas
72 void defocus_dialog();
73 bool getShowing() { return _showing; }
74 // fix children scrolled windows to send outer scroll when his own reach limits
75 void fix_inner_scroll(Gtk::Widget *child);
76 // Too many dialogs have unprotected calls to ask for this data
77 SPDesktop *getDesktop() const { return desktop; }
78
79protected:
80 InkscapeApplication *getApp() const { return _app; }
81 SPDocument *getDocument() const { return document; }
82 Selection *getSelection() const { return selection; }
83 friend class DialogNotebook;
84 void setShowing(bool showing);
85 Glib::ustring _name; // Gtk widget name (must be set!)
86 Glib::ustring const _prefs_path; // Stores characteristic path for loading/saving the dialog position.
87 Glib::ustring const _dialog_type; // Type of dialog (we could just use _pref_path?).
88
89private:
90 bool blink_off(); // timer callback
91 bool on_key_pressed(Gtk::EventControllerKey const &controller,
92 unsigned keyval, unsigned keycode, Gdk::ModifierType state);
93 // return if dialog is on visible tab
94 bool _showing = true;
95 void unsetDesktop();
96 void desktopDestroyed(SPDesktop* old_desktop);
97 void setDocument(SPDocument *new_document);
102 virtual void desktopReplaced() {}
103 virtual void documentReplaced() {}
105 virtual void selectionModified(Inkscape::Selection *selection, guint flags) {};
106
107 sigc::connection _desktop_destroyed;
108 sigc::connection _doc_replaced;
109 sigc::connection _select_changed;
110 sigc::connection _select_modified;
111
115
116 InkscapeApplication *_app; // Used for state management
117 SPDesktop *desktop = nullptr;
120 Glib::ustring _icon_name;
121};
122
123} // namespace Inkscape::UI::Dialog
124
125#endif // INK_DIALOG_BASE_H
126
127/*
128 Local Variables:
129 mode:c++
130 c-file-style:"stroustrup"
131 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
132 indent-tabs-mode:nil
133 fill-column:99
134 End:
135*/
136// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
The set of selected SPObjects for a given document and layer model.
Definition selection.h:80
DialogBase is the base class for the dialog system.
Definition dialog-base.h:41
void setShowing(bool showing)
function called from notebook dialog that performs an update of the dialog and sets the dialog showin...
void fix_inner_scroll(Gtk::Widget *child)
DialogBase & operator=(DialogBase const &)=delete
Selection * getSelection() const
Definition dialog-base.h:82
void setDesktop(SPDesktop *new_desktop)
Called when the desktop might have changed for this dialog.
void blink()
Highlight notebook where dialog already exists.
virtual void selectionChanged(Inkscape::Selection *selection)
bool blink_off()
Callback to reset the dialog highlight.
void unsetDesktop()
Called to destruct desktops, must not call virtuals.
InkscapeApplication * _app
virtual void update()
The update() method is essential to Gtk state management.
Definition dialog-base.h:56
void setDocument(SPDocument *new_document)
Called when the document might have changed, called from setDesktop too.
bool on_key_pressed(Gtk::EventControllerKey const &controller, unsigned keyval, unsigned keycode, Gdk::ModifierType state)
Glib::ustring const & get_type() const
Definition dialog-base.h:65
DialogBase(DialogBase const &)=delete
void desktopDestroyed(SPDesktop *old_desktop)
virtual void selectionModified(Inkscape::Selection *selection, guint flags)
SPDocument * getDocument() const
Definition dialog-base.h:81
virtual void desktopReplaced()
Called when the desktop has certainly changed.
Glib::ustring const _prefs_path
Definition dialog-base.h:86
sigc::connection _desktop_destroyed
const Glib::ustring & get_icon() const
Definition dialog-base.h:66
Glib::ustring const & get_name() const
Definition dialog-base.h:63
InkscapeApplication * getApp() const
Definition dialog-base.h:80
Glib::ustring const & getPrefsPath() const
Definition dialog-base.h:64
SPDesktop * getDesktop() const
Definition dialog-base.h:77
Glib::ustring const _dialog_type
Definition dialog-base.h:87
A widget that wraps a Gtk::Notebook with dialogs as pages.
To do: update description of desktop.
Definition desktop.h:149
Typed SVG document implementation.
Definition document.h:102
Definition desktop.h:50
Dialog code.
Definition desktop.h:117
static Glib::ustring const prefs_path
Ocnode * child[8]
Definition quantize.cpp:33