blob: de7574b9eb493e2b3302a9ceb666be48c7db9e1a [file] [log] [blame]
reed@android.comf76bacf2009-05-13 14:00:33 +00001#ifndef SkGroupShape_DEFINED
2#define SkGroupShape_DEFINED
3
4#include "SkShape.h"
5#include "SkTDArray.h"
6
7class SkGroupShape : public SkShape {
8public:
9 SkGroupShape();
10 virtual ~SkGroupShape();
11
12 /** Return the number of child shapes in this group
13 */
14 int countShapes() const;
15
16 /** Return the shape at the specified index. Note this does not affect the
17 owner count of the index'd shape. If index is out of range, returns NULL
18 */
19 SkShape* getShape(int index) const;
20
21 /** Ref the specified shape, and insert it into the child list at the
22 specified index. If index == countShapes(), then the shape will be
23 appended to the child list, otherwise if index is out of range, the
24 shape is not added. Either way, the shape parameter is returned.
25
26 Child shapes are drawn in order, after the parent, so the shape at index
27 0 will be drawn first, and the shape at index countShapes() - 1 will be
28 drawn last.
29 */
30 SkShape* addShape(int index, SkShape*);
31
32 /** Helper method to append a shape, passing countShapes() for the index
33 */
34 SkShape* appendShape(SkShape* shape) {
35 return this->addShape(this->countShapes(), shape);
36 }
37
38 /** Unref the specified index, and remove it from the child list. If index
39 is out of range, does nothing.
40 */
41 void removeShape(int index);
42
43 /** Unrefs and removes all of the child shapes
44 */
45 void removeAllShapes();
46
47 // overrides
48 virtual Factory getFactory();
49 virtual void flatten(SkFlattenableWriteBuffer&);
50
51protected:
52 // overrides
53 virtual void onDraw(SkCanvas*);
54
55 SkGroupShape(SkFlattenableReadBuffer&);
56
57private:
58 SkTDArray<SkShape*> fList;
59
60 static SkFlattenable* CreateProc(SkFlattenableReadBuffer&);
61
62 typedef SkShape INHERITED;
63};
64
65#endif