1 #ifndef __SP_SWITCH_H__
2 #define __SP_SWITCH_H__
4 /*
5 * SVG <switch> implementation
6 *
7 * Authors:
8 * Andrius R. <knutux@gmail.com>
9 *
10 * Copyright (C) 2006 authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
15 #include "sp-item-group.h"
17 #define SP_TYPE_SWITCH (CSwitch::getType())
18 #define SP_SWITCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_SWITCH, SPSwitch))
19 #define SP_SWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_SWITCH, SPSwitchClass))
20 #define SP_IS_SWITCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_SWITCH))
21 #define SP_IS_SWITCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_SWITCH))
23 /*
24 * Virtual methods of SPSwitch
25 */
26 class CSwitch : public CGroup {
27 public:
28 CSwitch(SPGroup *group);
29 virtual ~CSwitch();
31 friend class SPSwitch;
33 static GType getType();
35 virtual void onChildAdded(Inkscape::XML::Node *child);
36 virtual void onChildRemoved(Inkscape::XML::Node *child);
37 virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
38 virtual gchar *getDescription();
40 protected:
41 virtual GSList *_childList(bool add_ref, Action action);
42 virtual void _showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags);
44 SPObject *_evaluateFirst();
45 void _reevaluate(bool add_to_arena = false);
46 static void _releaseItem(SPObject *obj, CSwitch *selection);
47 void _releaseLastItem(SPObject *obj);
49 private:
50 SPObject *_cached_item;
51 gulong _release_handler_id;
52 };
54 struct SPSwitch : public SPGroup {
55 void resetChildEvaluated() { ((CSwitch *)group)->_reevaluate(); }
56 };
58 struct SPSwitchClass : public SPGroupClass {
59 };
61 #endif