2d1ef7af3b4bd10565a62d3ae21cb2d3308b4ff1
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, const char *apply_label = NULL);
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_resizable(bool);
65 virtual void set_sensitive(bool sensitive=true);
66 virtual void set_default(Gtk::Widget&);
67 virtual void set_size_request(int, int);
68 virtual void size_request(Gtk::Requisition&);
69 virtual void get_position(int& x, int& y);
70 virtual void get_size(int& width, int& height);
71 virtual void resize(int width, int height);
72 virtual void move(int x, int y);
73 virtual void set_position(Gtk::WindowPosition position);
74 virtual void set_title(Glib::ustring title);
76 virtual void set_response_sensitive(int response_id, bool setting);
77 virtual Glib::SignalProxy0<void> signal_show();
78 virtual Glib::SignalProxy0<void> signal_hide();
79 virtual Glib::SignalProxy1<void, int> signal_response();
81 virtual Gtk::Button* add_button (const Glib::ustring& button_text, int response_id);
82 virtual Gtk::Button* add_button (const Gtk::StockID& stock_id, int response_id);
84 virtual void set_default_response(int response_id);
86 bool _user_hidden; // when it is closed by the user, to prevent repopping on f12
87 bool _hiddenF12;
89 void read_geometry();
90 void save_geometry();
92 bool retransientize_suppress; // when true, do not retransientize (prevents races when switching new windows too fast)
94 protected:
95 const char *_prefs_path;
96 int _verb_num;
97 Glib::ustring _title;
98 const char *_apply_label;
100 /**
101 * Tooltips object for all descendants to use
102 */
103 Gtk::Tooltips tooltips;
105 virtual void _onResponse(int response_id);
106 virtual bool _onDeleteEvent (GdkEventAny*);
108 virtual void _apply();
109 virtual void _close();
111 static bool windowKeyPress(GdkEventKey *event);
113 Inkscape::Selection* _getSelection();
115 sigc::connection _desktop_activated_connection;
116 sigc::connection _dialogs_hidden_connection;
117 sigc::connection _dialogs_unhidden_connection;
118 sigc::connection _shutdown_connection;
120 private:
121 Behavior::Behavior* _behavior;
123 Dialog(); // no constructor without params
125 Dialog(Dialog const &d); // no copy
126 Dialog& operator=(Dialog const &d); // no assign
128 friend class Behavior::FloatingBehavior;
129 friend class Behavior::DockBehavior;
130 };
132 } // namespace Dialog
133 } // namespace UI
134 } // namespace Inkscape
136 #endif //INKSCAPE_DIALOG_H
138 /*
139 Local Variables:
140 mode:c++
141 c-file-style:"stroustrup"
142 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
143 indent-tabs-mode:nil
144 fill-column:99
145 End:
146 */
147 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :