Code

fix compositing for premultiplication and non-alpha cases
[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     void addButton(Gtk::Button *button, int response_id);
75     void hide();
76     void show();
77     void show_all();
79     void present();
81     Glib::SignalProxy0<void> signal_show();
82     Glib::SignalProxy0<void> signal_hide();
83     Glib::SignalProxy1<bool, GdkEventAny *> signal_delete_event();
84     Glib::SignalProxy1<void, int> signal_response();
85     Glib::SignalProxy0<void> signal_drag_begin();
86     Glib::SignalProxy1<void, bool> signal_drag_end();
88     sigc::signal<void, State, State> signal_state_changed();
90 private:
91     Dock &_dock;              //< parent dock
93     State _prev_state;        //< last known state
95     int _prev_position;
97     Gtk::Window *_window;     //< reference to floating window, if any 
98     int _x, _y;               //< last known position of window, if floating
100     GtkWidget *_gdl_dock_item;
101     Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf;
103     /** Interface widgets, will be packed like 
104      * gdl_dock_item -> _frame -> _dock_item_box -> (_dock_item_action_area) 
105      */
106     Gtk::Frame _frame;
107     Gtk::VBox _dock_item_box;
108     Gtk::HButtonBox *_dock_item_action_area;
110     /** Internal signal handlers */
111     void _onHide();
112     void _onHideWindow();
113     void _onShow();
114     void _onResponse(int response_id);
115     void _onDragBegin();
116     void _onDragEnd(bool cancelled);
117     bool _onKeyPress(GdkEventKey *event);
118     void _onStateChanged(State prev_state, State new_state);
119     bool _onDeleteEvent(GdkEventAny *event);
121     void _onFoo();
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     /** Internal helpers */
137     Gtk::Window *_getWindow();   //< gives the parent window, if the dock item has one (i.e. it's floating)
139     /** In order to emulate a signal_response signal like the one for Gtk::Dialog we inject a new
140      * signal into GdlDockItem. This signal will be emitted when a button in the dock item added
141      * through the addButton(..., response_id) method, is clicked. 
142      */
143     static void _signal_response_callback(GtkWidget* self, gint p0, void* data);
145     sigc::signal<void, State, State> _signal_state_changed;
147     DockItem();
148 };
150 } // namespace Widget
151 } // namespace UI
152 } // namespace Inkscape
154 #endif // INKSCAPE_UI_WIGET_DOCK_ITEM_H
156 /*
157   Local Variables:
158   mode:c++
159   c-file-style:"stroustrup"
160   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
161   indent-tabs-mode:nil
162   fill-column:99
163   End:
164 */
165 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :