Code

Add default grid settings to Inkscape preferences.
[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     virtual ~Panel();
42     Panel(Glib::ustring const &label = "", gchar const *prefs_path = 0, 
43           int verb_num = 0, Glib::ustring const &apply_label = "",
44           bool menu_desired = false);
46     gchar const *getPrefsPath() const;
47     void setLabel(Glib::ustring const &label);
48     Glib::ustring const &getLabel() const;
49     int const &getVerb() const;
50     Glib::ustring const &getApplyLabel() const;
52     virtual void setOrientation(Gtk::AnchorType how);
54     virtual void present();  //< request to be present
56     void restorePanelPrefs();
58     virtual void setDesktop(SPDesktop *desktop);
59     SPDesktop *getDesktop() { return _desktop; }
60     
61     /** Signal accessors */
62     virtual sigc::signal<void, int> &signalResponse();
63     virtual sigc::signal<void> &signalPresent();
65     /** Methods providing a Gtk::Dialog like interface for adding buttons that emit Gtk::RESPONSE
66      *  signals on click. */
67     Gtk::Button* addResponseButton (const Glib::ustring &button_text, int response_id);
68     Gtk::Button* addResponseButton (const Gtk::StockID &stock_id, int response_id);
69     void setDefaultResponse(int response_id);
70     void setResponseSensitive(int response_id, bool setting);
72     virtual sigc::signal<void, SPDesktop *, SPDocument *> &signalDocumentReplaced();
73     virtual sigc::signal<void, Inkscape::Application *, SPDesktop *> &signalActivateDesktop();
74     virtual sigc::signal<void, Inkscape::Application *, SPDesktop *> &signalDeactiveDesktop();
76 protected:
77     Gtk::Box *_getContents() { return &_contents; }
78     void _setTargetFillable(PreviewFillable *target);
79     void _regItem(Gtk::MenuItem* item, int group, int id);
81     virtual void _handleAction(int set_id, int item_id);
82     virtual void _apply();
84     virtual void _handleResponse(int response_id);
86     /** Helper methods */
87     void _addResponseButton(Gtk::Button *button, int response_id);
88     Inkscape::Selection *_getSelection();
90     /** Tooltips object for all descendants to use */
91     Gtk::Tooltips _tooltips;
93     const gchar *_prefs_path;
95     bool _menu_desired;
96     Gtk::AnchorType _anchor;
98     /** Signals */
99     sigc::signal<void, int> _signal_response;
100     sigc::signal<void>      _signal_present;
101     sigc::signal<void, SPDesktop *, SPDocument *> _signal_document_replaced;
102     sigc::signal<void, Inkscape::Application *, SPDesktop *> _signal_activate_desktop;
103     sigc::signal<void, Inkscape::Application *, SPDesktop *> _signal_deactive_desktop;
105 private:
106     void _init();
107     void _bounceCall(int i, int j);
109     void _popper(GdkEventButton *btn);
110     void _wrapToggled(Gtk::CheckMenuItem *toggler);
112     SPDesktop       *_desktop;
114     Glib::ustring    _label;
115     Glib::ustring    _apply_label;
116     int              _verb_num;
118     Gtk::HBox        _top_bar;
119     Gtk::VBox        _right_bar;
120     Gtk::VBox        _contents;
121     Gtk::Label       _tab_title;
122     Gtk::Arrow       _temp_arrow;
123     Gtk::EventBox    _menu_popper;
124     Gtk::Button      _close_button;
125     Gtk::Menu       *_menu;
126     Gtk::HButtonBox *_action_area;  //< stores response buttons
127     std::vector<Gtk::Widget *> _non_horizontal;
128     std::vector<Gtk::Widget *> _non_vertical;
129     PreviewFillable *_fillable;
131     /** A map to store which widget that emits a certain response signal */
132     typedef std::map<int, Gtk::Widget *> ResponseMap;
133     ResponseMap _response_map;
134 };
136 } // namespace Widget
137 } // namespace UI
138 } // namespace Inkscape
140 #endif // SEEN_INKSCAPE_UI_WIDGET_PANEL_H
142 /*
143   Local Variables:
144   mode:c++
145   c-file-style:"stroustrup"
146   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
147   indent-tabs-mode:nil
148   fill-column:99
149   End:
150 */
151 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :