Code

trivial: ui/widget/*, ui/dialog/*: svn propset svn:eol-style native *.h *.cpp.
[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,     // 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 addButton(Gtk::Button *button, int response_id);
80     void hide();
81     void show();
82     void show_all();
84     void present();
86     void grab_focus();
88     Glib::SignalProxy0<void> signal_show();
89     Glib::SignalProxy0<void> signal_hide();
90     Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
91     Glib::SignalProxy1<void, int> signal_response();
92     Glib::SignalProxy0<void> signal_drag_begin();
93     Glib::SignalProxy1<void, bool> signal_drag_end();
94     Glib::SignalProxy0<void> signal_realize();
96     sigc::signal<void, State, State> signal_state_changed();
98 private:
99     Dock &_dock;              //< parent dock
101     State _prev_state;        //< last known state
103     int _prev_position;
105     Gtk::Window *_window;     //< reference to floating window, if any 
106     int _x, _y;               //< last known position of window, if floating
108     bool _grab_focus_on_realize;   //< if the dock item should grab focus on the next realize
110     GtkWidget *_gdl_dock_item;
111     Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf;
113     /** Interface widgets, will be packed like 
114      * gdl_dock_item -> _frame -> _dock_item_box -> (_dock_item_action_area) 
115      */
116     Gtk::Frame _frame;
117     Gtk::VBox _dock_item_box;
118     Gtk::HButtonBox *_dock_item_action_area;
120     /** Internal signal handlers */
121     void _onHide();
122     void _onHideWindow();
123     void _onShow();
124     void _onResponse(int response_id);
125     void _onDragBegin();
126     void _onDragEnd(bool cancelled);
127     void _onRealize();
129     bool _onKeyPress(GdkEventKey *event);
130     void _onStateChanged(State prev_state, State new_state);
131     bool _onDeleteEvent(GdkEventAny *event);
133     sigc::connection _signal_key_press_event_connection;
135     /** GdlDockItem signal proxy structures */
136     static const Glib::SignalProxyInfo _signal_show_proxy;
137     static const Glib::SignalProxyInfo _signal_hide_proxy;
138     static const Glib::SignalProxyInfo _signal_delete_event_proxy;
139     static const Glib::SignalProxyInfo _signal_response_proxy;
140     static const Glib::SignalProxyInfo _signal_drag_begin_proxy;
141     static const Glib::SignalProxyInfo _signal_drag_end_proxy;
142     static const Glib::SignalProxyInfo _signal_realize_proxy;
144     static gboolean _signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, void *data);
145     static void _signal_drag_end_callback(GtkWidget* self, gboolean p0, void* data);
147     /** In order to emulate a signal_response signal like the one for Gtk::Dialog we inject a new
148      * signal into GdlDockItem. This signal will be emitted when a button in the dock item added
149      * through the addButton(..., response_id) method, is clicked. 
150      */
151     static void _signal_response_callback(GtkWidget* self, gint p0, void* data);
153     sigc::signal<void, State, State> _signal_state_changed;
155     DockItem();
156 };
158 } // namespace Widget
159 } // namespace UI
160 } // namespace Inkscape
162 #endif // INKSCAPE_UI_WIGET_DOCK_ITEM_H
164 /*
165   Local Variables:
166   mode:c++
167   c-file-style:"stroustrup"
168   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
169   indent-tabs-mode:nil
170   fill-column:99
171   End:
172 */
173 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :