1 /**
2 * \brief A dockable dialog implementation.
3 *
4 * Author:
5 * Gustav Broberg <broberg@kth.se>
6 *
7 * Copyright (C) 2007 Authors
8 *
9 * Released under GNU GPL. Read the file 'COPYING' for more information.
10 */
13 #ifndef INKSCAPE_UI_DIALOG_DOCK_BEHAVIOR_H
14 #define INKSCAPE_UI_DIALOG_DOCK_BEHAVIOR_H
16 #include <map>
18 #include <gtkmm/buttonbox.h>
19 #include <gtkmm/frame.h>
20 #include <gtkmm/paned.h>
22 #include "ui/widget/dock-item.h"
24 #include "libgdl/libgdl.h"
26 #include "behavior.h"
28 namespace Inkscape {
29 namespace UI {
30 namespace Dialog {
31 namespace Behavior {
33 class DockBehavior : public Behavior {
35 public:
36 static Behavior *create(Dialog& dialog);
38 ~DockBehavior();
40 /** Gtk::Dialog methods */
41 operator Gtk::Widget&();
42 GtkWidget *gobj();
43 void present();
44 Gtk::VBox *get_vbox();
45 void show();
46 void hide();
47 void show_all_children();
48 void resize(int width, int height);
49 void move(int x, int y);
50 void set_position(Gtk::WindowPosition);
51 void set_size_request(int width, int height);
52 void size_request(Gtk::Requisition& requisition);
53 void get_position(int& x, int& y);
54 void get_size(int& width, int& height);
55 void set_title(Glib::ustring title);
56 void set_response_sensitive(int response_id, bool setting);
57 void set_sensitive(bool sensitive);
58 Gtk::Button *add_button(const Glib::ustring& button_text, int response_id);
59 Gtk::Button *add_button(const Gtk::StockID& stock_id, int response_id);
60 void set_default_response(int response_id);
62 /** Gtk::Dialog signal proxies */
63 Glib::SignalProxy0<void> signal_show();
64 Glib::SignalProxy0<void> signal_hide();
65 Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
66 Glib::SignalProxy0<void> signal_drag_begin();
67 Glib::SignalProxy1<void, bool> signal_drag_end();
68 Glib::SignalProxy1<void, int> signal_response();
70 /** Custom signal handlers */
71 void onHideF12();
72 void onShowF12();
73 void onDesktopActivated(SPDesktop *desktop);
74 void onShutdown();
76 private:
77 Widget::DockItem _dock_item;
79 DockBehavior(Dialog& dialog);
81 /** A map to store which widget that emits a certain response signal */
82 typedef std::map<int, Gtk::Widget *> ResponseMap;
83 ResponseMap _response_map;
85 /** Internal helpers */
86 void _addButton(Gtk::Button *button, int response_id);
87 Gtk::Paned *_getPaned(); //< gives the parent pane, if the dock item has one
88 void _requestHeight(int height); //< tries to resize the dock item to the requested hieght
90 /** Internal signal handlers */
91 void _onHide();
92 bool _onDeleteEvent(GdkEventAny *event);
93 void _onResponse(int response_id);
94 void _onDragBegin();
95 void _onDragEnd(bool cancelled);
96 bool _onKeyPress(GdkEventKey *event);
98 sigc::connection _signal_hide_connection;
99 sigc::connection _signal_key_press_event_connection;
101 };
103 } // namespace Behavior
104 } // namespace Dialog
105 } // namespace UI
106 } // namespace Inkscape
108 #endif // INKSCAPE_UI_DIALOG_DOCK_BEHAVIOR_H
110 /*
111 Local Variables:
112 mode:c++
113 c-file-style:"stroustrup"
114 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
115 indent-tabs-mode:nil
116 fill-column:99
117 End:
118 */
119 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :