Code

copyedit
[inkscape.git] / src / ui / dialog / dialog.h
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 {
42 public:
44     Dialog(const char *prefs_path = NULL, int verb_num = 0, const char *apply_label = NULL);
46     Dialog(Behavior::BehaviorFactory behavior_factory, const char *prefs_path = NULL, 
47            int verb_num = 0, const char *apply_label = NULL);
49     virtual ~Dialog();
51     virtual void onDesktopActivated (SPDesktop*);
52     virtual void onShutdown();
54     virtual void present();
56     /** Hide and show dialogs */
57     virtual void onHideF12();
58     virtual void onShowF12();
60     virtual operator Gtk::Widget&();
61     virtual GtkWidget *gobj();
62     virtual Gtk::VBox *get_vbox();
63     virtual void show();
64     virtual void hide();
65     virtual void show_all_children();
66     virtual void set_resizable(bool);
67     virtual void set_sensitive(bool sensitive=true);
68     virtual void set_default(Gtk::Widget&);
69     virtual void set_size_request(int, int);
70     virtual void size_request(Gtk::Requisition&);
71     virtual void get_position(int& x, int& y);
72     virtual void get_size(int& width, int& height);
73     virtual void resize(int width, int height);
74     virtual void move(int x, int y);
75     virtual void set_position(Gtk::WindowPosition position);
76     virtual void set_title(Glib::ustring title);
78     virtual void set_response_sensitive(int response_id, bool setting);
79     virtual Glib::SignalProxy0<void> signal_show();
80     virtual Glib::SignalProxy0<void> signal_hide();
81     virtual Glib::SignalProxy1<void, int> signal_response();
83     virtual Gtk::Button* add_button (const Glib::ustring& button_text, int response_id);
84     virtual Gtk::Button* add_button (const Gtk::StockID& stock_id, int response_id);
85     
86     virtual void set_default_response(int response_id);
88     bool           _user_hidden; // when it is closed by the user, to prevent repopping on f12
89     bool           _hiddenF12;
91     void           read_geometry();
92     void           save_geometry();
94     bool retransientize_suppress; // when true, do not retransientize (prevents races when switching new windows too fast)
96 protected:
97     const char    *_prefs_path;
98     int            _verb_num;
99     Glib::ustring  _title;
100     const char    *_apply_label;
102     /**
103      * Tooltips object for all descendants to use
104      */
105     Gtk::Tooltips tooltips;
107     virtual void   on_response(int response_id);
108     virtual bool   on_delete_event (GdkEventAny*);
109     virtual void   _apply();
110     virtual void   _close();
112     static bool windowKeyPress(GdkEventKey *event);
114     Inkscape::Selection*   _getSelection();
116     sigc::connection _desktop_activated_connection;
117     sigc::connection _dialogs_hidden_connection;
118     sigc::connection _dialogs_unhidden_connection;
119     sigc::connection _shutdown_connection;
121 private:
122     Behavior::Behavior* _behavior;
124     Dialog(); // no constructor without params
126     Dialog(Dialog const &d);            // no copy
127     Dialog& operator=(Dialog const &d); // no assign
129     friend class Behavior::FloatingBehavior;
130     friend class Behavior::DockBehavior;
131 };
133 } // namespace Dialog
134 } // namespace UI
135 } // namespace Inkscape
137 #endif //INKSCAPE_DIALOG_H
139 /*
140   Local Variables:
141   mode:c++
142   c-file-style:"stroustrup"
143   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
144   indent-tabs-mode:nil
145   fill-column:99
146   End:
147 */
148 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :