1 /**
2 * \brief Base class for dialogs in Inkscape. This class provides certain common behaviors and
3 * styles wanted of all dialogs in the application. Fundamental parts of the dialog's
4 * behavior is controlled by a Dialog::Behavior subclass instance connected to the dialog.
5 *
6 * Author:
7 * Bryce W. Harrington <bryce@bryceharrington.org>
8 * Gustav Broberg <broberg@kth.se>
9 *
10 * Copyright (C) 2004--2007 Authors
11 *
12 * Released under GNU GPL. Read the file 'COPYING' for more information.
13 */
15 #ifndef INKSCAPE_DIALOG_H
16 #define INKSCAPE_DIALOG_H
18 #include <gtkmm/dialog.h>
19 #include <gtkmm/tooltips.h>
21 #include "dock-behavior.h"
22 #include "floating-behavior.h"
24 class SPDesktop;
26 namespace Inkscape {
27 class Selection;
28 class Application;
29 }
31 namespace Inkscape {
32 namespace UI {
33 namespace Dialog {
35 enum BehaviorType { FLOATING, DOCK };
37 void sp_retransientize(Inkscape::Application *inkscape, SPDesktop *desktop, gpointer dlgPtr);
38 gboolean sp_retransientize_again(gpointer dlgPtr);
39 void sp_dialog_shutdown(GtkObject *object, gpointer dlgPtr);
41 class Dialog {
43 public:
45 Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL,
46 int verb_num = 0, Glib::ustring const &apply_label = "");
48 virtual ~Dialog();
50 virtual void onDesktopActivated(SPDesktop*);
51 virtual void onShutdown();
53 /** Hide and show dialogs */
54 virtual void onHideF12();
55 virtual void onShowF12();
57 virtual operator Gtk::Widget &();
58 virtual GtkWidget *gobj();
59 virtual void present();
60 virtual Gtk::VBox *get_vbox();
61 virtual void show();
62 virtual void hide();
63 virtual void show_all_children();
64 virtual void set_size_request(int, int);
65 virtual void size_request(Gtk::Requisition &);
66 virtual void get_position(int &x, int &y);
67 virtual void get_size(int &width, int &height);
68 virtual void resize(int width, int height);
69 virtual void move(int x, int y);
70 virtual void set_position(Gtk::WindowPosition position);
71 virtual void set_title(Glib::ustring title);
72 virtual void set_sensitive(bool sensitive=true);
74 virtual Glib::SignalProxy0<void> signal_show();
75 virtual Glib::SignalProxy0<void> signal_hide();
77 bool _user_hidden; // when it is closed by the user, to prevent repopping on f12
78 bool _hiddenF12;
80 void read_geometry();
81 void save_geometry();
83 bool retransientize_suppress; // when true, do not retransientize (prevents races when switching new windows too fast)
85 protected:
86 const char *_prefs_path;
87 int _verb_num;
88 Glib::ustring _title;
89 Glib::ustring _apply_label;
91 /**
92 * Tooltips object for all descendants to use
93 */
94 Gtk::Tooltips tooltips;
96 virtual void _handleResponse(int response_id);
98 virtual bool _onDeleteEvent (GdkEventAny*);
99 virtual bool _onEvent(GdkEvent *event);
100 virtual bool _onKeyPress(GdkEventKey *event);
102 virtual void _apply();
103 virtual void _close();
104 virtual void _defocus();
106 Inkscape::Selection* _getSelection();
108 sigc::connection _desktop_activated_connection;
109 sigc::connection _dialogs_hidden_connection;
110 sigc::connection _dialogs_unhidden_connection;
111 sigc::connection _shutdown_connection;
113 private:
114 Behavior::Behavior* _behavior;
116 Dialog(); // no constructor without params
118 Dialog(Dialog const &d); // no copy
119 Dialog& operator=(Dialog const &d); // no assign
121 friend class Behavior::FloatingBehavior;
122 friend class Behavior::DockBehavior;
123 };
125 } // namespace Dialog
126 } // namespace UI
127 } // namespace Inkscape
129 #endif //INKSCAPE_DIALOG_H
131 /*
132 Local Variables:
133 mode:c++
134 c-file-style:"stroustrup"
135 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
136 indent-tabs-mode:nil
137 fill-column:99
138 End:
139 */
140 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :