1 /* 2 * Copyright 2006-2007, Haiku, Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _SHAPE_H 6 #define _SHAPE_H 7 8 9 #include <Archivable.h> 10 11 class BPoint; 12 class BRect; 13 class BShape; 14 15 namespace BPrivate { 16 class ServerLink; 17 class PicturePlayer; 18 }; 19 20 21 class BShapeIterator { 22 public: 23 BShapeIterator(); 24 virtual ~BShapeIterator(); 25 26 virtual status_t IterateMoveTo(BPoint* point); 27 virtual status_t IterateLineTo(int32 lineCount, 28 BPoint* linePts); 29 virtual status_t IterateBezierTo(int32 bezierCount, 30 BPoint* bezierPts); 31 virtual status_t IterateClose(); 32 33 virtual status_t IterateArcTo(float& rx, float& ry, 34 float& angle, bool largeArc, 35 bool counterClockWise, BPoint& point); 36 37 status_t Iterate(BShape* shape); 38 39 private: 40 virtual void _ReservedShapeIterator2(); 41 virtual void _ReservedShapeIterator3(); 42 virtual void _ReservedShapeIterator4(); 43 44 uint32 reserved[4]; 45 }; 46 47 48 class BShape : public BArchivable { 49 public: 50 BShape(); 51 BShape(const BShape& other); 52 BShape(BMessage* archive); 53 virtual ~BShape(); 54 55 static BArchivable* Instantiate(BMessage* archive); 56 virtual status_t Archive(BMessage* archive, 57 bool deep = true) const; 58 59 BShape& operator=(const BShape& other); 60 61 bool operator==(const BShape& other) const; 62 bool operator!=(const BShape& other) const; 63 64 void Clear(); 65 BRect Bounds() const; 66 BPoint CurrentPosition() const; 67 68 status_t AddShape(const BShape* other); 69 70 status_t MoveTo(BPoint point); 71 status_t LineTo(BPoint linePoint); 72 status_t BezierTo(BPoint controlPoints[3]); 73 status_t BezierTo(const BPoint& control1, 74 const BPoint& control2, 75 const BPoint& endPoint); 76 status_t ArcTo(float rx, float ry, 77 float angle, bool largeArc, 78 bool counterClockWise, 79 const BPoint& point); 80 status_t Close(); 81 82 private: 83 // FBC padding 84 virtual status_t Perform(perform_code code, void* data); 85 86 virtual void _ReservedShape1(); 87 virtual void _ReservedShape2(); 88 virtual void _ReservedShape3(); 89 virtual void _ReservedShape4(); 90 91 private: 92 friend class BShapeIterator; 93 friend class BView; 94 friend class BFont; 95 friend class BPrivate::PicturePlayer; 96 friend class BPrivate::ServerLink; 97 98 void GetData(int32* opCount, int32* ptCount, 99 uint32** opList, BPoint** ptList); 100 void SetData(int32 opCount, int32 ptCount, 101 const uint32* opList, 102 const BPoint* ptList); 103 void InitData(); 104 bool AllocatePts(int32 count); 105 bool AllocateOps(int32 count); 106 107 private: 108 uint32 fState; 109 uint32 fBuildingOp; 110 void* fPrivateData; 111 112 uint32 reserved[4]; 113 }; 114 115 #endif // _SHAPE_H 116