Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
unit-tracker.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Inkscape::UI::Widget::UnitTracker
4 * Simple mediator to synchronize changes to unit menus
5 *
6 * Authors:
7 * Jon A. Cruz <jon@joncruz.org>
8 * Matthew Petroff <matthew@mpetroff.net>
9 *
10 * Copyright (C) 2007 Jon A. Cruz
11 * Copyright (C) 2013 Matthew Petroff
12 *
13 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
14 */
15
16#ifndef INKSCAPE_UI_WIDGET_UNIT_TRACKER_H
17#define INKSCAPE_UI_WIDGET_UNIT_TRACKER_H
18
19#include <map>
20#include <vector>
21#include <glibmm/refptr.h>
22
23#include "util/units.h"
24
27
28typedef struct _GObject GObject;
29typedef struct _GtkAdjustment GtkAdjustment;
30typedef struct _GtkListStore GtkListStore;
31
32namespace Gtk {
33class ListStore;
34} // namespace Gtk
35
36namespace Inkscape::UI::Widget {
37
38class ComboToolItem;
39
41public:
42 UnitTracker(UnitType unit_type);
43 virtual ~UnitTracker();
44
45 bool isUpdating() const;
46
47 void setActiveUnit(Inkscape::Util::Unit const *unit);
48 void setActiveUnitByAbbr(gchar const *abbr);
49 void setActiveUnitByLabel(Glib::ustring label);
50 Inkscape::Util::Unit const * getActiveUnit() const;
51
52 void addUnit(Inkscape::Util::Unit const *u);
54 void prependUnit(Inkscape::Util::Unit const *u);
55 void setFullVal(GtkAdjustment *adj, double val);
56 Glib::ustring getCurrentLabel();
57 void changeLabel(Glib::ustring new_label, gint pos, bool onlylabel = false);
58
59 ComboToolItem *create_tool_item(Glib::ustring const &label,
60 Glib::ustring const &tooltip);
61
62protected:
63 UnitType _type;
64
65private:
66 // Callbacks
67 void _unitChangedCB(int active);
68 static void _adjustmentFinalizedCB(gpointer data, GObject *where_the_object_was);
69
70 void _setActive(gint index);
71 void _fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit);
72
73 // Cleanup
74 void _adjustmentFinalized(GObject *where_the_object_was);
75
76 gint _active;
80
81 Glib::RefPtr<Gtk::ListStore> _store;
82 std::vector<ComboToolItem *> _combo_list;
83 std::vector<GtkAdjustment*> _adjList;
84 std::map <GtkAdjustment *, double> _priorValues;
85};
86
87} // namespace Inkscape::UI::Widget
88
89#endif // INKSCAPE_UI_WIDGET_UNIT_TRACKER_H
90
91/*
92 Local Variables:
93 mode:c++
94 c-file-style:"stroustrup"
95 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
96 indent-tabs-mode:nil
97 fill-column:99
98 End:
99*/
100// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
std::vector< GtkAdjustment * > _adjList
void prependUnit(Inkscape::Util::Unit const *u)
void setFullVal(GtkAdjustment *adj, double val)
std::vector< ComboToolItem * > _combo_list
Glib::RefPtr< Gtk::ListStore > _store
void _adjustmentFinalized(GObject *where_the_object_was)
void addAdjustment(GtkAdjustment *adj)
void setActiveUnit(Inkscape::Util::Unit const *unit)
void _fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit)
static void _adjustmentFinalizedCB(gpointer data, GObject *where_the_object_was)
void setActiveUnitByLabel(Glib::ustring label)
void changeLabel(Glib::ustring new_label, gint pos, bool onlylabel=false)
ComboToolItem * create_tool_item(Glib::ustring const &label, Glib::ustring const &tooltip)
Inkscape::Util::Unit const * getActiveUnit() const
void addUnit(Inkscape::Util::Unit const *u)
Inkscape::Util::Unit const * _activeUnit
std::map< GtkAdjustment *, double > _priorValues
void setActiveUnitByAbbr(gchar const *abbr)
Glib::ustring label
Definition desktop.h:50
Custom widgets.
Definition desktop.h:126
static const Point data[]
int index
struct _GObject GObject
struct _GtkAdjustment GtkAdjustment
struct _GtkListStore GtkListStore