Code

Line-end fix
[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 namespace NR{ struct translate; }
29 struct SPGroup : public SPItem {
30         enum LayerMode { GROUP, LAYER };
32         LayerMode _layer_mode;
33         std::map<unsigned int, LayerMode> _display_modes;
35         LayerMode layerMode() const { return _layer_mode; }
36         void setLayerMode(LayerMode mode);
38         LayerMode effectiveLayerMode(unsigned int display_key) const {
39                 if ( _layer_mode == LAYER ) {
40                         return LAYER;
41                 } else {
42                         return layerDisplayMode(display_key);
43                 }
44         }
46         LayerMode layerDisplayMode(unsigned int display_key) const;
47         void setLayerDisplayMode(unsigned int display_key, LayerMode mode);
48         void translateChildItems(NR::translate const &tr);
50     CGroup *group;
52 private:
53         void _updateLayerMode(unsigned int display_key=0);
54 };
56 struct SPGroupClass {
57         SPItemClass parent_class;
58 };
60 /*
61  * Virtual methods of SPGroup
62  */
63 class CGroup {
64 public:
65     CGroup(SPGroup *group);
66     virtual ~CGroup();
67     
68     virtual void onChildAdded(Inkscape::XML::Node *child);
69     virtual void onChildRemoved(Inkscape::XML::Node *child);
70     virtual void onUpdate(SPCtx *ctx, unsigned int flags);
71     virtual void onModified(guint flags);
72     virtual void calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
73     virtual void onPrint(SPPrintContext *ctx);
74     virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
75     virtual gchar *getDescription();
76     virtual NRArenaItem *show (NRArena *arena, unsigned int key, unsigned int flags);
77     virtual void hide (unsigned int key);
79     gint getItemCount();
81 protected:
82     virtual void _showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, unsigned int flags);
84     SPGroup *_group;
85 };
87 GType sp_group_get_type (void);
89 void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true);
92 GSList *sp_item_group_item_list (SPGroup *group);
93 SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name);
95 #endif