Code

SVG 1.1 Conditional Processing Module rendering support (<switch> element, requiredRe...
[inkscape.git] / src / sp-item-group.h
1 #ifndef __SP_ITEM_GROUP_H__
2 #define __SP_ITEM_GROUP_H__
4 /*
5  * SVG <g> implementation
6  *
7  * Authors:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *
10  * Copyright (C) 1999-2002 authors
11  * Copyright (C) 2000-2001 Ximian, Inc.
12  *
13  * Released under GNU GPL, read the file 'COPYING' for more information
14  */
16 #include <map>
17 #include "sp-item.h"
19 #define SP_TYPE_GROUP            (sp_group_get_type ())
20 #define SP_GROUP(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_GROUP, SPGroup))
21 #define SP_GROUP_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), SP_TYPE_GROUP, SPGroupClass))
22 #define SP_IS_GROUP(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_GROUP))
23 #define SP_IS_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SP_TYPE_GROUP))
25 class CGroup;
27 struct SPGroup : public SPItem {
28         enum LayerMode { GROUP, LAYER };
30         LayerMode _layer_mode;
31         std::map<unsigned int, LayerMode> _display_modes;
33         LayerMode layerMode() const { return _layer_mode; }
34         void setLayerMode(LayerMode mode);
36         LayerMode effectiveLayerMode(unsigned int display_key) const {
37                 if ( _layer_mode == LAYER ) {
38                         return LAYER;
39                 } else {
40                         return layerDisplayMode(display_key);
41                 }
42         }
44         LayerMode layerDisplayMode(unsigned int display_key) const;
45         void setLayerDisplayMode(unsigned int display_key, LayerMode mode);
47     CGroup *group;
49 private:
50         void _updateLayerMode(unsigned int display_key=0);
51 };
53 struct SPGroupClass {
54         SPItemClass parent_class;
55 };
57 /*
58  * Virtual methods of SPGroup
59  */
60 class CGroup {
61 public:
62     CGroup(SPGroup *group);
63     virtual ~CGroup();
64     
65     virtual void onChildAdded(Inkscape::XML::Node *child);
66     virtual void onChildRemoved(Inkscape::XML::Node *child);
67     virtual void onUpdate(SPCtx *ctx, unsigned int flags);
68     virtual void onModified(guint flags);
69     virtual void calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
70     virtual void onPrint(SPPrintContext *ctx);
71     virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
72     virtual gchar *getDescription();
73     virtual NRArenaItem *show (NRArena *arena, unsigned int key, unsigned int flags);
74     virtual void hide (unsigned int key);
76     gint getItemCount();
78 protected:
79     enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow };
80     virtual GSList *_childList(bool add_ref, Action action = ActionGeneral);
81     virtual void _showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags);
83     SPGroup *_group;
84 };
86 GType sp_group_get_type (void);
88 void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true);
91 GSList *sp_item_group_item_list (SPGroup *group);
92 SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name);
94 #endif