summaryrefslogtreecommitdiffstats
path: root/src/sp-switch.cpp
diff options
context:
space:
mode:
authorMarkus Engel <markus.engel@tum.de>2013-04-05 15:51:29 +0000
committerMarkus Engel <markus.engel@tum.de>2013-04-05 15:51:29 +0000
commitdbda80349e95767e390a178cda7c05787fbce1fe (patch)
tree851cb7ea9e876da0ff50665f16e2410604c79da1 /src/sp-switch.cpp
parentMerged Shape and subclasses. Cleaned up a bit. (diff)
downloadinkscape-dbda80349e95767e390a178cda7c05787fbce1fe.tar.gz
inkscape-dbda80349e95767e390a178cda7c05787fbce1fe.zip
Merged Group and subclasses.
(bzr r11608.1.77)
Diffstat (limited to 'src/sp-switch.cpp')
-rw-r--r--src/sp-switch.cpp59
1 files changed, 21 insertions, 38 deletions
diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index 7dd5bf669..d36406cef 100644
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
@@ -35,47 +35,26 @@ namespace {
bool switchRegistered = SPFactory::instance().registerObject("svg:switch", createSwitch);
}
-G_DEFINE_TYPE(SPSwitch, sp_switch, G_TYPE_OBJECT);
-
-static void
-sp_switch_class_init (SPSwitchClass *)
-{
-}
-
-CSwitch::CSwitch(SPSwitch* sw) : CGroup(sw) {
- this->spswitch = sw;
-}
-
-CSwitch::~CSwitch() {
-}
-
SPSwitch::SPSwitch() : SPGroup() {
- SPSwitch* sw = this;
-
- sw->cswitch = new CSwitch(sw);
- sw->typeHierarchy.insert(typeid(SPSwitch));
-
- delete sw->cgroup;
- sw->cgroup = sw->cswitch;
- sw->clpeitem = sw->cswitch;
- sw->citem = sw->cswitch;
- sw->cobject = sw->cswitch;
+ this->clpeitem = this;
+ this->citem = this;
+ this->cobject = this;
- sw->_cached_item = 0;
+ this->_cached_item = 0;
}
-static void sp_switch_init (SPSwitch *sw)
-{
- new (sw) SPSwitch();
+SPSwitch::~SPSwitch() {
}
SPObject *SPSwitch::_evaluateFirst() {
SPObject *first = 0;
+
for (SPObject *child = this->firstChild() ; child && !first ; child = child->getNext() ) {
if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) {
- first = child;
- }
+ first = child;
+ }
}
+
return first;
}
@@ -94,25 +73,25 @@ GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) {
return g_slist_prepend (NULL, child);
}
-gchar *CSwitch::description() {
- gint len = this->spgroup->getItemCount();
+gchar *SPSwitch::description() {
+ gint len = this->getItemCount();
return g_strdup_printf(
ngettext("<b>Conditional group</b> of <b>%d</b> object",
"<b>Conditional group</b> of <b>%d</b> objects",
len), len);
}
-void CSwitch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) {
- this->spswitch->_reevaluate(true);
+void SPSwitch::child_added(Inkscape::XML::Node* child, Inkscape::XML::Node* ref) {
+ this->_reevaluate(true);
}
-void CSwitch::remove_child(Inkscape::XML::Node *) {
- this->spswitch->_reevaluate();
+void SPSwitch::remove_child(Inkscape::XML::Node *) {
+ this->_reevaluate();
}
-void CSwitch::order_changed (Inkscape::XML::Node *, Inkscape::XML::Node *, Inkscape::XML::Node *)
+void SPSwitch::order_changed (Inkscape::XML::Node *, Inkscape::XML::Node *, Inkscape::XML::Node *)
{
- this->spswitch->_reevaluate();
+ this->_reevaluate();
}
void SPSwitch::_reevaluate(bool /*add_to_drawing*/) {
@@ -159,16 +138,20 @@ void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem
SPObject *evaluated_child = this->_evaluateFirst();
GSList *l = this->_childList(false, SPObject::ActionShow);
+
while (l) {
SPObject *o = SP_OBJECT (l->data);
+
if (SP_IS_ITEM (o)) {
SPItem * child = SP_ITEM(o);
child->setEvaluated(o == evaluated_child);
Inkscape::DrawingItem *ac = child->invoke_show (drawing, key, flags);
+
if (ac) {
ai->appendChild(ac);
}
}
+
l = g_slist_remove (l, o);
}
}