1 /*
2 * Inkscape::UnitTracker - Simple mediator to synchronize changes to a set
3 * of possible units
4 *
5 * Authors:
6 * Jon A. Cruz <jon@joncruz.org>
7 *
8 * Copyright (C) 2007 Jon A. Cruz
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
13 #ifndef SEEN_INKSCAPE_UNIT_TRACKER_H
14 #define SEEN_INKSCAPE_UNIT_TRACKER_H
16 #include <map>
18 #include <gtk/gtkaction.h>
19 #include <gtk/gtkliststore.h>
21 #include "helper/units.h"
23 namespace Inkscape {
25 class UnitTracker
26 {
27 public:
28 UnitTracker( guint bases = (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE) );
29 virtual ~UnitTracker();
31 void setBase( guint bases ); // SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE
32 void addUnit( SPUnitId id, gint index );
34 bool isUpdating() const;
36 void setActiveUnit( SPUnit const *unit );
37 SPUnit const* getActiveUnit() const;
39 void addAdjustment( GtkAdjustment* adj );
40 void setFullVal( GtkAdjustment* adj, gdouble val );
42 GtkAction* createAction( gchar const* name, gchar const* label, gchar const* tooltip );
44 private:
45 static void _unitChangedCB( GtkAction* action, gpointer data );
46 static void _actionFinalizedCB( gpointer data, GObject *where_the_object_was );
47 static void _adjustmentFinalizedCB( gpointer data, GObject *where_the_object_was );
48 void _setActive( gint index );
49 void _fixupAdjustments( SPUnit const* oldUnit, SPUnit const *newUnit );
50 void _actionFinalized( GObject *where_the_object_was );
51 void _adjustmentFinalized( GObject *where_the_object_was );
53 gint _active;
54 bool _isUpdating;
55 SPUnit* _activeUnit;
56 GtkListStore* _store;
57 GSList* _unitList;
58 GSList* _actionList;
59 GSList* _adjList;
60 std::map <GtkAdjustment*, gdouble> _priorValues;
61 };
63 }
65 #endif // SEEN_INKSCAPE_UNIT_TRACKER_H
67 /*
68 Local Variables:
69 mode:c++
70 c-file-style:"stroustrup"
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
72 indent-tabs-mode:nil
73 fill-column:99
74 End:
75 */
76 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :