Code

Group dock related prefs, add hidden prefs for dock bar and switcher appearance.
[inkscape.git] / src / ui / widget / dock-item.h
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, FLOATING_STATE, DOCKED_STATE };
36     enum Placement { 
37         NONE     = GDL_DOCK_NONE,
38         TOP      = GDL_DOCK_TOP,
39         BOTTOM   = GDL_DOCK_BOTTOM,
40         RIGHT    = GDL_DOCK_RIGHT,
41         LEFT     = GDL_DOCK_LEFT,
42         CENTER   = GDL_DOCK_CENTER,
43         FLOATING = GDL_DOCK_FLOATING
44     };
46     DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name, 
47              const Glib::ustring& icon_name, State state);
49     ~DockItem();
51     Gtk::Widget& getWidget();
52     GtkWidget *gobj();
54     Gtk::VBox *get_vbox();
56     void get_position(int& x, int& y);
57     void get_size(int& width, int& height);
59     void resize(int width, int height);
60     void move(int x, int y);
61     void set_position(Gtk::WindowPosition);
62     void set_size_request(int width, int height);
63     void size_request(Gtk::Requisition& requisition);
64     void set_title(Glib::ustring title);
66     bool isAttached() const;
67     bool isFloating() const;
68     bool isIconified() const;
69     State getState() const;
70     State getPrevState() const;
71     Placement getPlacement() const;
73     Gtk::Window *getWindow();   //< gives the parent window, if the dock item has one (i.e. it's floating)
75     void addButton(Gtk::Button *button, int response_id);
77     void hide();
78     void show();
79     void show_all();
81     void present();
83     Glib::SignalProxy0<void> signal_show();
84     Glib::SignalProxy0<void> signal_hide();
85     Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
86     Glib::SignalProxy1<void, int> signal_response();
87     Glib::SignalProxy0<void> signal_drag_begin();
88     Glib::SignalProxy1<void, bool> signal_drag_end();
90     sigc::signal<void, State, State> signal_state_changed();
92 private:
93     Dock &_dock;              //< parent dock
95     State _prev_state;        //< last known state
97     int _prev_position;
99     Gtk::Window *_window;     //< reference to floating window, if any 
100     int _x, _y;               //< last known position of window, if floating
102     GtkWidget *_gdl_dock_item;
103     Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf;
105     /** Interface widgets, will be packed like 
106      * gdl_dock_item -> _frame -> _dock_item_box -> (_dock_item_action_area) 
107      */
108     Gtk::Frame _frame;
109     Gtk::VBox _dock_item_box;
110     Gtk::HButtonBox *_dock_item_action_area;
112     /** Internal signal handlers */
113     void _onHide();
114     void _onHideWindow();
115     void _onShow();
116     void _onResponse(int response_id);
117     void _onDragBegin();
118     void _onDragEnd(bool cancelled);
119     bool _onKeyPress(GdkEventKey *event);
120     void _onStateChanged(State prev_state, State new_state);
121     bool _onDeleteEvent(GdkEventAny *event);
123     sigc::connection _signal_key_press_event_connection;
125     /** GdlDockItem signal proxy structures */
126     static const Glib::SignalProxyInfo _signal_show_proxy;
127     static const Glib::SignalProxyInfo _signal_hide_proxy;
128     static const Glib::SignalProxyInfo _signal_delete_event_proxy;
129     static const Glib::SignalProxyInfo _signal_response_proxy;
130     static const Glib::SignalProxyInfo _signal_drag_begin_proxy;
131     static const Glib::SignalProxyInfo _signal_drag_end_proxy;
133     static gboolean _signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, void *data);
134     static void _signal_drag_end_callback(GtkWidget* self, gboolean p0, void* data);
136     /** In order to emulate a signal_response signal like the one for Gtk::Dialog we inject a new
137      * signal into GdlDockItem. This signal will be emitted when a button in the dock item added
138      * through the addButton(..., response_id) method, is clicked. 
139      */
140     static void _signal_response_callback(GtkWidget* self, gint p0, void* data);
142     sigc::signal<void, State, State> _signal_state_changed;
144     DockItem();
145 };
147 } // namespace Widget
148 } // namespace UI
149 } // namespace Inkscape
151 #endif // INKSCAPE_UI_WIGET_DOCK_ITEM_H
153 /*
154   Local Variables:
155   mode:c++
156   c-file-style:"stroustrup"
157   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
158   indent-tabs-mode:nil
159   fill-column:99
160   End:
161 */
162 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :