Inkscape
Vector Graphics Editor
combo-tool-item.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
6/*
7 * Authors:
8 * Tavmjong Bah <tavmjong@free.fr>
9 *
10 * Copyright (C) 2017 Tavmjong Bah
11 *
12 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
13 */
14
15#ifndef SEEN_COMBO_TOOL_ITEM
16#define SEEN_COMBO_TOOL_ITEM
17
18#include <memory>
19#include <glibmm/refptr.h>
20#include <glibmm/ustring.h>
21#include <gtkmm/box.h>
22#include <gtkmm/enums.h>
23#include <gtkmm/treemodel.h>
24#include <sigc++/signal.h>
25
26namespace Gdk {
27class Pixbuf;
28} // namespace Gdk
29
30namespace Gtk {
31class ComboBox;
32class Label;
33class ListStore;
34} // namespace Gtk
35
36namespace Inkscape::UI::Widget {
37
38class ComboToolItemColumns final : public Gtk::TreeModel::ColumnRecord {
39public:
41 add (col_label);
42 add (col_value);
43 add (col_icon);
45 add (col_data); // Used to store a pointer
48 }
49 Gtk::TreeModelColumn<Glib::ustring> col_label;
50 Gtk::TreeModelColumn<Glib::ustring> col_value;
51 Gtk::TreeModelColumn<Glib::ustring> col_icon;
52 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > col_pixbuf;
53 Gtk::TreeModelColumn<void *> col_data;
54 Gtk::TreeModelColumn<Glib::ustring> col_tooltip;
55 Gtk::TreeModelColumn<bool> col_sensitive;
56};
57
58class ComboToolItem final : public Gtk::Box {
59public:
60 static ComboToolItem* create(const Glib::ustring &label,
61 const Glib::ustring &tooltip,
62 const Glib::ustring &stock_id,
63 Glib::RefPtr<Gtk::ListStore> store,
64 bool has_entry = false);
65
66 /* Style of combobox */
67 void use_label( bool use_label );
68 void use_icon( bool use_icon );
69 void focus_on_click( bool focus_on_click );
70 void use_pixbuf( bool use_pixbuf );
71 void use_group_label( bool use_group_label ); // Applies to tool item only
72
73 int get_active() const { return _active; }
74 Glib::ustring get_active_text();
75 void set_active(int active);
76 void set_icon_size( Gtk::IconSize size ) { _icon_size = size; }
77
78 Glib::RefPtr<Gtk::ListStore> const &get_store() { return _store; }
79
80 sigc::signal<void (int)> signal_changed() { return _changed; }
81 sigc::signal<void (int)> signal_changed_after() { return _changed_after; }
82
83protected:
84 void populate_combobox();
85
86 /* Signals */
87 sigc::signal<void (int)> _changed;
88 sigc::signal<void (int)> _changed_after; // Needed for unit tracker which eats _changed.
89
90private:
91 Glib::ustring _group_label;
92 Glib::ustring _tooltip;
93 Glib::ustring _stock_id;
94 Glib::RefPtr<Gtk::ListStore> _store;
95
96 int _active; // Active menu item/button
97
98 /* Style */
100 bool _use_icon; // Applies to menu item only
102 Gtk::IconSize _icon_size;
103
104 /* Combobox in tool */
105 Gtk::ComboBox* _combobox;
106 std::unique_ptr<Gtk::Label> _group_label_widget;
107 Gtk::Box* _container;
108
109 /* Internal Callbacks */
110 void on_changed_combobox();
111
112 ComboToolItem(Glib::ustring group_label,
113 Glib::ustring tooltip,
114 Glib::ustring stock_id,
115 Glib::RefPtr<Gtk::ListStore> store,
116 bool has_entry = false);
118};
119
120} // namespace Inkscape::UI::Widget
121
122#endif /* SEEN_COMBO_TOOL_ITEM */
123
124/*
125 Local Variables:
126 mode:c++
127 c-file-style:"stroustrup"
128 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
129 indent-tabs-mode:nil
130 fill-column:99
131 End:
132*/
133// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
Fragment store
Definition: canvas.cpp:155
Gtk::TreeModelColumn< Glib::RefPtr< Gdk::Pixbuf > > col_pixbuf
Gtk::TreeModelColumn< void * > col_data
Gtk::TreeModelColumn< Glib::ustring > col_icon
Gtk::TreeModelColumn< Glib::ustring > col_value
Gtk::TreeModelColumn< Glib::ustring > col_tooltip
Gtk::TreeModelColumn< bool > col_sensitive
Gtk::TreeModelColumn< Glib::ustring > col_label
void use_group_label(bool use_group_label)
std::unique_ptr< Gtk::Label > _group_label_widget
sigc::signal< void(int)> signal_changed_after()
Glib::RefPtr< Gtk::ListStore > const & get_store()
sigc::signal< void(int)> _changed
static ComboToolItem * create(const Glib::ustring &label, const Glib::ustring &tooltip, const Glib::ustring &stock_id, Glib::RefPtr< Gtk::ListStore > store, bool has_entry=false)
void set_icon_size(Gtk::IconSize size)
sigc::signal< void(int)> signal_changed()
void focus_on_click(bool focus_on_click)
sigc::signal< void(int)> _changed_after
Glib::RefPtr< Gtk::ListStore > _store
ComboToolItem(Glib::ustring group_label, Glib::ustring tooltip, Glib::ustring stock_id, Glib::RefPtr< Gtk::ListStore > store, bool has_entry=false)
Definition: desktop.h:51
Custom widgets.
Definition: desktop.h:127
static void add(Gtk::Box &box, PackType const pack_type, Gtk::Widget &child)
Definition: pack.cpp:94
int size