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-lpe-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 SPLPEItem {
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);
46 void translateChildItems(Geom::Translate const &tr);
48 CGroup *group;
50 private:
51 void _updateLayerMode(unsigned int display_key=0);
52 };
54 struct SPGroupClass {
55 SPLPEItemClass parent_class;
56 };
58 /*
59 * Virtual methods of SPGroup
60 */
61 class CGroup {
62 public:
63 CGroup(SPGroup *group);
64 virtual ~CGroup();
66 virtual void onChildAdded(Inkscape::XML::Node *child);
67 virtual void onChildRemoved(Inkscape::XML::Node *child);
68 virtual void onUpdate(SPCtx *ctx, unsigned int flags);
69 virtual void onModified(guint flags);
70 virtual void calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
71 virtual void onPrint(SPPrintContext *ctx);
72 virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
73 virtual gchar *getDescription();
74 virtual NRArenaItem *show (NRArena *arena, unsigned int key, unsigned int flags);
75 virtual void hide (unsigned int key);
77 gint getItemCount();
79 protected:
80 virtual void _showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags);
82 SPGroup *_group;
83 };
85 GType sp_group_get_type (void);
87 void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true);
90 GSList *sp_item_group_item_list (SPGroup *group);
91 SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name);
93 #endif
95 /*
96 Local Variables:
97 mode:c++
98 c-file-style:"stroustrup"
99 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
100 indent-tabs-mode:nil
101 fill-column:99
102 End:
103 */
104 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :