]> Shamusworld >> Repos - ttedit/blob - src/glyphpoints.h
Move main repo to trunk.
[ttedit] / src / glyphpoints.h
1 //\r
2 // glyphpoints.h\r
3 //\r
4 // by James L. Hammons\r
5 //\r
6 // This class encapsulates the data associated with a TrueType glyph.\r
7 // Data is dynamically allocated.\r
8 //\r
9 \r
10 #ifndef __GLYPHPOINTS_H__\r
11 #define __GLYPHPOINTS_H__\r
12 \r
13 #include "types.h"\r
14 \r
15 \r
16 struct IPoint\r
17 {\r
18         int32 x, y;\r
19         bool onCurve;\r
20 \r
21         IPoint(int32 xx=0, int32 yy=0, bool oc=true): x(xx), y(yy), onCurve(oc) {}\r
22 };\r
23 \r
24 // Throws the following exceptions:\r
25 #define GP_OUT_OF_RANGE  1\r
26 \r
27 class GlyphPoints\r
28 {\r
29         public:\r
30 //For some reason, gcc barfs here when something tries to use the copy\r
31 //constructor because it gets confused between the optional arguments (which\r
32 //start with an INT for cryin' out loud) and the GlyphPoints & argument. So,\r
33 //Let's try making it a non-optional first param, and go from there...\r
34 //Turns out the compiler barfs regardless...\r
35 //Turns out the problem was that the copy ctor wasn't declared as CONST...\r
36                 GlyphPoints(int nPts = 0, int nPlys = 0, int * xa = NULL, int * ya = NULL,\r
37                         bool * oca = NULL, uint16 * pa = NULL);\r
38 //              GlyphPoints(void);// And now *this* is needed... Bleah!\r
39 //              GlyphPoints(int nPts, int nPlys = 0, int * xa = NULL, int * ya = NULL,\r
40 //                      bool * oca = NULL, uint16 * pa = NULL);\r
41                 GlyphPoints(int xx, int yy, bool oc);\r
42 //              GlyphPoints(GlyphPoints &);                             // Copy constructor\r
43                 GlyphPoints(const GlyphPoints &);                               // Copy constructor\r
44                 ~GlyphPoints();\r
45                 GlyphPoints& operator=(const GlyphPoints &);\r
46                 GlyphPoints operator+(const GlyphPoints &);\r
47                 GlyphPoints operator+(const IPoint &);\r
48                 GlyphPoints& operator+=(const IPoint &);\r
49                 void InsertPoint(uint16, int, int, bool);\r
50                 void InsertPoint(uint16, const IPoint &);\r
51                 void DeletePoint(uint16);\r
52                 uint16 GetNumPoints(void);\r
53                 uint16 GetNumPoints(uint16);\r
54                 uint16 GetNumPolys(void);\r
55                 int GetX(uint16);\r
56                 int GetY(uint16);\r
57                 bool GetOnCurve(uint16);\r
58                 int GetX(uint16, uint16);\r
59                 int GetY(uint16, uint16);\r
60                 bool GetOnCurve(uint16, uint16);\r
61                 uint16 GetPolyEnd(uint16);\r
62                 void OffsetPoints(int, int);\r
63                 void OffsetPoly(uint16, int32, int32);\r
64                 void ScalePoints(float);\r
65                 void SetXY(uint16, int, int);\r
66                 void SetOnCurve(uint16, bool);\r
67                 uint16 GetPrev(uint16);\r
68                 uint16 GetNext(uint16);\r
69                 uint16 GetPrev(uint16, uint16);\r
70                 uint16 GetNext(uint16, uint16);\r
71                 uint16 GetPoly(uint16);\r
72                 void AddNewPolyAtEnd(void);\r
73 \r
74         private:\r
75                 void AllocateAndCopy(int, int, int *, int *, bool *, uint16 *);\r
76 \r
77         private:\r
78                 int numPoints, numPolys;\r
79                 int * x, * y;\r
80                 bool * onCurve;\r
81                 uint16 * polyEnd;\r
82                 uint16 pointsAllocated, polysAllocated;\r
83 };\r
84 \r
85 #endif  // __GLYPHPOINTS_H__\r