Code

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