1 /**
2 * \brief A custom wrapper around gdl-dock-item
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_WIGET_DOCK_ITEM_H
14 #define INKSCAPE_UI_WIGET_DOCK_ITEM_H
16 #include <gtkmm/button.h>
17 #include <gtkmm/buttonbox.h>
18 #include <gtkmm/frame.h>
19 #include <gtkmm/paned.h>
20 #include <gtkmm/window.h>
22 #include "libgdl/libgdl.h"
24 namespace Inkscape {
25 namespace UI {
26 namespace Widget {
28 class Dock;
30 class DockItem {
32 public:
34 enum State { UNATTACHED, // item not bound to the dock (a temporary state)
35 FLOATING_STATE, // item not in its dock (but can be docked in other,
36 // e.g. floating, docks)
37 DOCKED_STATE }; // item in its assigned dock
39 enum Placement {
40 NONE = GDL_DOCK_NONE,
41 TOP = GDL_DOCK_TOP,
42 BOTTOM = GDL_DOCK_BOTTOM,
43 RIGHT = GDL_DOCK_RIGHT,
44 LEFT = GDL_DOCK_LEFT,
45 CENTER = GDL_DOCK_CENTER,
46 FLOATING = GDL_DOCK_FLOATING
47 };
49 DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name,
50 const Glib::ustring& icon_name, State state);
52 ~DockItem();
54 Gtk::Widget& getWidget();
55 GtkWidget *gobj();
57 Gtk::VBox *get_vbox();
59 void get_position(int& x, int& y);
60 void get_size(int& width, int& height);
62 void resize(int width, int height);
63 void move(int x, int y);
64 void set_position(Gtk::WindowPosition);
65 void set_size_request(int width, int height);
66 void size_request(Gtk::Requisition& requisition);
67 void set_title(Glib::ustring title);
69 bool isAttached() const;
70 bool isFloating() const;
71 bool isIconified() const;
72 State getState() const;
73 State getPrevState() const;
74 Placement getPlacement() const;
76 Gtk::Window *getWindow(); //< gives the parent window, if the dock item has one (i.e. it's floating)
78 void hide();
79 void show();
80 void show_all();
82 void present();
84 void grab_focus();
86 Glib::SignalProxy0<void> signal_show();
87 Glib::SignalProxy0<void> signal_hide();
88 Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
89 Glib::SignalProxy0<void> signal_drag_begin();
90 Glib::SignalProxy1<void, bool> signal_drag_end();
91 Glib::SignalProxy0<void> signal_realize();
93 sigc::signal<void, State, State> signal_state_changed();
95 private:
96 Dock &_dock; //< parent dock
98 State _prev_state; //< last known state
100 int _prev_position;
102 Gtk::Window *_window; //< reference to floating window, if any
103 int _x, _y; //< last known position of window, if floating
105 bool _grab_focus_on_realize; //< if the dock item should grab focus on the next realize
107 GtkWidget *_gdl_dock_item;
108 Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf;
110 /** Interface widgets, will be packed like
111 * gdl_dock_item -> _frame -> _dock_item_box -> (_dock_item_action_area)
112 */
113 Gtk::Frame _frame;
114 Gtk::VBox _dock_item_box;
115 Gtk::HButtonBox *_dock_item_action_area;
117 /** Internal signal handlers */
118 void _onHide();
119 void _onHideWindow();
120 void _onShow();
121 void _onDragBegin();
122 void _onDragEnd(bool cancelled);
123 void _onRealize();
125 bool _onKeyPress(GdkEventKey *event);
126 void _onStateChanged(State prev_state, State new_state);
127 bool _onDeleteEvent(GdkEventAny *event);
129 sigc::connection _signal_key_press_event_connection;
131 /** GdlDockItem signal proxy structures */
132 static const Glib::SignalProxyInfo _signal_show_proxy;
133 static const Glib::SignalProxyInfo _signal_hide_proxy;
134 static const Glib::SignalProxyInfo _signal_delete_event_proxy;
136 static const Glib::SignalProxyInfo _signal_drag_begin_proxy;
137 static const Glib::SignalProxyInfo _signal_drag_end_proxy;
138 static const Glib::SignalProxyInfo _signal_realize_proxy;
140 static gboolean _signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, void *data);
141 static void _signal_drag_end_callback(GtkWidget* self, gboolean p0, void* data);
143 sigc::signal<void, State, State> _signal_state_changed;
145 DockItem();
146 };
148 } // namespace Widget
149 } // namespace UI
150 } // namespace Inkscape
152 #endif // INKSCAPE_UI_WIGET_DOCK_ITEM_H
154 /*
155 Local Variables:
156 mode:c++
157 c-file-style:"stroustrup"
158 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
159 indent-tabs-mode:nil
160 fill-column:99
161 End:
162 */
163 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :