Code

From trunk
[inkscape.git] / src / ui / widget / panel.h
1 /**
2  * \brief Generic Panel widget - A generic dockable container.
3  *
4  * Authors:
5  *   Bryce Harrington <bryce@bryceharrington.org>
6  *   Jon A. Cruz <jon@joncruz.org>
7  *
8  * Copyright (C) 2004 Bryce Harrington
9  * Copyright (C) 2005 Jon A. Cruz
10  *
11  * Released under GNU GPL.  Read the file 'COPYING' for more information.
12  */
14 #ifndef SEEN_INKSCAPE_UI_WIDGET_PANEL_H
15 #define SEEN_INKSCAPE_UI_WIDGET_PANEL_H
17 #include <vector>
18 #include <gtkmm/arrow.h>
19 #include <gtkmm/box.h>
20 #include <gtkmm/button.h>
21 #include <gtkmm/buttonbox.h>
22 #include <gtkmm/eventbox.h>
23 #include <gtkmm/frame.h>
24 #include <gtkmm/label.h>
25 #include <gtkmm/menu.h>
26 #include <gtkmm/optionmenu.h>
27 #include <gtkmm/table.h>
28 #include <gtkmm/tooltips.h>
30 #include "inkscape.h"
31 #include "ui/previewfillable.h"
32 #include "selection.h"
34 namespace Inkscape {
35 namespace UI {
36 namespace Widget {
38 class Panel : public Gtk::VBox {
40 public:
41     static void prep();
43     virtual ~Panel();
44     Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0,
45           int verb_num = 0, Glib::ustring const &apply_label = "",
46           bool menu_desired = false);
48     gchar const *getPrefsPath() const;
49     void setLabel(Glib::ustring const &label);
50     Glib::ustring const &getLabel() const;
51     int const &getVerb() const;
52     Glib::ustring const &getApplyLabel() const;
54     virtual void setOrientation(Gtk::AnchorType how);
56     virtual void present();  //< request to be present
58     void restorePanelPrefs();
60     virtual void setDesktop(SPDesktop *desktop);
61     SPDesktop *getDesktop() { return _desktop; }
63     /** Signal accessors */
64     virtual sigc::signal<void, int> &signalResponse();
65     virtual sigc::signal<void> &signalPresent();
67     /** Methods providing a Gtk::Dialog like interface for adding buttons that emit Gtk::RESPONSE
68      *  signals on click. */
69     Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id);
70     Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id);
71     void setDefaultResponse(int response_id);
72     void setResponseSensitive(int response_id, bool setting);
74     virtual sigc::signal<void, SPDesktop *, SPDocument *> &signalDocumentReplaced();
75     virtual sigc::signal<void, Inkscape::Application *, SPDesktop *> &signalActivateDesktop();
76     virtual sigc::signal<void, Inkscape::Application *, SPDesktop *> &signalDeactiveDesktop();
78 protected:
79     Gtk::Box *_getContents() { return &_contents; }
80     void _setTargetFillable(PreviewFillable *target);
81     void _regItem(Gtk::MenuItem* item, int group, int id);
83     virtual void _handleAction(int set_id, int item_id);
84     virtual void _apply();
86     virtual void _handleResponse(int response_id);
88     /** Helper methods */
89     void _addResponseButton(Gtk::Button *button, int response_id);
90     Inkscape::Selection *_getSelection();
92     /** Tooltips object for all descendants to use */
93     Gtk::Tooltips _tooltips;
95     Glib::ustring const _prefs_path;
97     bool _menu_desired;
98     Gtk::AnchorType _anchor;
100     /** Signals */
101     sigc::signal<void, int> _signal_response;
102     sigc::signal<void>      _signal_present;
103     sigc::signal<void, SPDesktop *, SPDocument *> _signal_document_replaced;
104     sigc::signal<void, Inkscape::Application *, SPDesktop *> _signal_activate_desktop;
105     sigc::signal<void, Inkscape::Application *, SPDesktop *> _signal_deactive_desktop;
107 private:
108     void _init();
109     void _bounceCall(int i, int j);
111     void _popper(GdkEventButton *btn);
112     void _wrapToggled(Gtk::CheckMenuItem *toggler);
114     SPDesktop       *_desktop;
116     Glib::ustring    _label;
117     Glib::ustring    _apply_label;
118     int              _verb_num;
120     Gtk::HBox        _top_bar;
121     Gtk::VBox        _right_bar;
122     Gtk::VBox        _contents;
123     Gtk::Label       _tab_title;
124     Gtk::Arrow       _temp_arrow;
125     Gtk::EventBox    _menu_popper;
126     Gtk::Button      _close_button;
127     Gtk::Menu       *_menu;
128     Gtk::HButtonBox *_action_area;  //< stores response buttons
129     std::vector<Gtk::Widget *> _non_horizontal;
130     std::vector<Gtk::Widget *> _non_vertical;
131     PreviewFillable *_fillable;
133     /** A map to store which widget that emits a certain response signal */
134     typedef std::map<int, Gtk::Widget *> ResponseMap;
135     ResponseMap _response_map;
136 };
138 } // namespace Widget
139 } // namespace UI
140 } // namespace Inkscape
142 #endif // SEEN_INKSCAPE_UI_WIDGET_PANEL_H
144 /*
145   Local Variables:
146   mode:c++
147   c-file-style:"stroustrup"
148   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
149   indent-tabs-mode:nil
150   fill-column:99
151   End:
152 */
153 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :