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>
20 #include "helper/units.h"
22 namespace Inkscape {
24 class UnitTracker
25 {
26 public:
27 UnitTracker( guint bases = (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE) );
28 virtual ~UnitTracker();
30 void setBase( guint bases ); // SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE
31 void addUnit( SPUnitId id, gint index );
33 bool isUpdating() const;
35 void setActiveUnit( SPUnit const *unit );
36 SPUnit const* getActiveUnit() const;
38 void addAdjustment( GtkAdjustment* adj );
39 void setFullVal( GtkAdjustment* adj, gdouble val );
41 GtkAction* createAction( gchar const* name, gchar const* label, gchar const* tooltip );
43 private:
44 static void _unitChangedCB( GtkAction* action, gpointer data );
45 static void _actionFinalizedCB( gpointer data, GObject *where_the_object_was );
46 static void _adjustmentFinalizedCB( gpointer data, GObject *where_the_object_was );
47 void _setActive( gint index );
48 void _fixupAdjustments( SPUnit const* oldUnit, SPUnit const *newUnit );
49 void _actionFinalized( GObject *where_the_object_was );
50 void _adjustmentFinalized( GObject *where_the_object_was );
52 gint _active;
53 bool _isUpdating;
54 SPUnit* _activeUnit;
55 GtkListStore* _store;
56 GSList* _unitList;
57 GSList* _actionList;
58 GSList* _adjList;
59 std::map <GtkAdjustment*, gdouble> _priorValues;
60 };
62 }
64 #endif // SEEN_INKSCAPE_UNIT_TRACKER_H
66 /*
67 Local Variables:
68 mode:c++
69 c-file-style:"stroustrup"
70 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
71 indent-tabs-mode:nil
72 fill-column:99
73 End:
74 */
75 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :