~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/ui/widget/dock-item.h

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
11
 
 
12
 
 
13
#ifndef INKSCAPE_UI_WIGET_DOCK_ITEM_H
 
14
#define INKSCAPE_UI_WIGET_DOCK_ITEM_H
 
15
 
 
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>
 
21
 
 
22
#include "libgdl/libgdl.h"
 
23
 
 
24
namespace Inkscape {
 
25
namespace UI {
 
26
namespace Widget {
 
27
 
 
28
class Dock;
 
29
 
 
30
class DockItem {
 
31
 
 
32
public:
 
33
 
 
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
 
38
 
 
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
    };
 
48
 
 
49
    DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& long_name, 
 
50
             const Glib::ustring& icon_name, State state);
 
51
 
 
52
    ~DockItem();
 
53
 
 
54
    Gtk::Widget& getWidget();
 
55
    GtkWidget *gobj();
 
56
 
 
57
    Gtk::VBox *get_vbox();
 
58
 
 
59
    void get_position(int& x, int& y);
 
60
    void get_size(int& width, int& height);
 
61
 
 
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);
 
68
 
 
69
    bool isAttached() const;
 
70
    bool isFloating() const;
 
71
    bool isIconified() const;
 
72
    State getState() const;
 
73
    State getPrevState() const;
 
74
    Placement getPlacement() const;
 
75
 
 
76
    Gtk::Window *getWindow();   //< gives the parent window, if the dock item has one (i.e. it's floating)
 
77
 
 
78
    void hide();
 
79
    void show();
 
80
    void show_all();
 
81
 
 
82
    void present();
 
83
 
 
84
    void grab_focus();
 
85
 
 
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();
 
92
 
 
93
    sigc::signal<void, State, State> signal_state_changed();
 
94
 
 
95
private:
 
96
    Dock &_dock;              //< parent dock
 
97
 
 
98
    State _prev_state;        //< last known state
 
99
 
 
100
    int _prev_position;
 
101
 
 
102
    Gtk::Window *_window;     //< reference to floating window, if any 
 
103
    int _x, _y;               //< last known position of window, if floating
 
104
 
 
105
    bool _grab_focus_on_realize;   //< if the dock item should grab focus on the next realize
 
106
 
 
107
    GtkWidget *_gdl_dock_item;
 
108
    Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf;
 
109
 
 
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;
 
116
 
 
117
    /** Internal signal handlers */
 
118
    void _onHide();
 
119
    void _onHideWindow();
 
120
    void _onShow();
 
121
    void _onDragBegin();
 
122
    void _onDragEnd(bool cancelled);
 
123
    void _onRealize();
 
124
 
 
125
    bool _onKeyPress(GdkEventKey *event);
 
126
    void _onStateChanged(State prev_state, State new_state);
 
127
    bool _onDeleteEvent(GdkEventAny *event);
 
128
 
 
129
    sigc::connection _signal_key_press_event_connection;
 
130
 
 
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;
 
135
 
 
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;
 
139
 
 
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);
 
142
 
 
143
    sigc::signal<void, State, State> _signal_state_changed;
 
144
 
 
145
    DockItem();
 
146
};
 
147
 
 
148
} // namespace Widget
 
149
} // namespace UI
 
150
} // namespace Inkscape
 
151
 
 
152
#endif // INKSCAPE_UI_WIGET_DOCK_ITEM_H
 
153
 
 
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 :