Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
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 <gdkmm/pixbuf.h>
22#include <gtkmm/box.h>
23#include <gtkmm/enums.h>
24#include <gtkmm/treemodel.h>
25#include <sigc++/signal.h>
26
27namespace Gtk {
28class ComboBox;
29class Label;
30class ListStore;
31} // namespace Gtk
32
33namespace Inkscape::UI::Widget {
34
35class ComboToolItemColumns final : public Gtk::TreeModel::ColumnRecord {
36public:
38 add (col_label);
39 add (col_value);
40 add (col_icon);
41 // Guard against Gdk::Pixbuf being forward-declared (https://discourse.gnome.org/t/24669).
42 static_assert(sizeof(Gdk::Pixbuf) > 0);
43 add (col_pixbuf);
44 add (col_data); // Used to store a pointer
45 add (col_tooltip);
46 add (col_sensitive);
47 }
48 Gtk::TreeModelColumn<Glib::ustring> col_label;
49 Gtk::TreeModelColumn<Glib::ustring> col_value;
50 Gtk::TreeModelColumn<Glib::ustring> col_icon;
51 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > col_pixbuf;
52 Gtk::TreeModelColumn<void *> col_data;
53 Gtk::TreeModelColumn<Glib::ustring> col_tooltip;
54 Gtk::TreeModelColumn<bool> col_sensitive;
55};
56
57class ComboToolItem final : public Gtk::Box {
58public:
59 static ComboToolItem* create(const Glib::ustring &label,
60 const Glib::ustring &tooltip,
61 const Glib::ustring &stock_id,
62 Glib::RefPtr<Gtk::ListStore> store,
63 bool has_entry = false);
64
65 /* Style of combobox */
66 void use_label( bool use_label );
67 void use_icon( bool use_icon );
68 void focus_on_click( bool focus_on_click );
69 void use_pixbuf( bool use_pixbuf );
70 void use_group_label( bool use_group_label ); // Applies to tool item only
71
72 int get_active() const { return _active; }
73 Glib::ustring get_active_text();
74 void set_active(int active);
75 void set_icon_size( Gtk::IconSize size ) { _icon_size = size; }
76
77 Glib::RefPtr<Gtk::ListStore> const &get_store() { return _store; }
78
79 sigc::signal<void (int)> signal_changed() { return _changed; }
80 sigc::signal<void (int)> signal_changed_after() { return _changed_after; }
81
82protected:
83 void populate_combobox();
84
85 /* Signals */
86 sigc::signal<void (int)> _changed;
87 sigc::signal<void (int)> _changed_after; // Needed for unit tracker which eats _changed.
88
89private:
90 Glib::ustring _group_label;
91 Glib::ustring _tooltip;
92 Glib::ustring _stock_id;
93 Glib::RefPtr<Gtk::ListStore> _store;
94
95 int _active; // Active menu item/button
96
97 /* Style */
99 bool _use_icon; // Applies to menu item only
101 Gtk::IconSize _icon_size;
102
103 /* Combobox in tool */
104 Gtk::ComboBox* _combobox;
105 std::unique_ptr<Gtk::Label> _group_label_widget;
106 Gtk::Box* _container;
107
108 /* Internal Callbacks */
109 void on_changed_combobox();
110
111 ComboToolItem(Glib::ustring group_label,
112 Glib::ustring tooltip,
113 Glib::ustring stock_id,
114 Glib::RefPtr<Gtk::ListStore> store,
115 bool has_entry = false);
117};
118
119} // namespace Inkscape::UI::Widget
120
121#endif /* SEEN_COMBO_TOOL_ITEM */
122
123/*
124 Local Variables:
125 mode:c++
126 c-file-style:"stroustrup"
127 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
128 indent-tabs-mode:nil
129 fill-column:99
130 End:
131*/
132// 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
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
Glib::ustring label
Definition desktop.h:50
Custom widgets.
Definition desktop.h:126
std::unique_ptr< Toolbar >(* create)()
Definition toolbars.cpp:56