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