1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
#ifndef __SHAPE_H__
#define __SHAPE_H__
#include <vector>
#include <Exceptions.h>
#include <BString.h>
#include <mcolor.h>
#include <texture.h>
namespace mogltk {
typedef enum {
LEFT,
CENTER,
RIGHT
} align_t;
class fillwalker : public Base {
public:
fillwalker();
virtual ~fillwalker();
virtual void step(int x, int y);
};
class segwalker : public Base {
public:
segwalker();
virtual ~segwalker();
virtual void step(int x1, int y1, int x2, int y2);
};
class fill : public Base {
public:
fill();
virtual ~fill();
void walk(fillwalker *);
void swalk(segwalker *);
void insert(int, int, int, int);
void insertfix(int, int);
int GetMinX() const;
int GetMinY() const;
int GetMaxX() const;
int GetMaxY() const;
texture * GetTexture();
texture * Talloc();
texture * GetSTexture();
texture * STalloc();
Color last;
private:
void insert(int, int);
struct segment {
int x1, y1, x2, y2;
};
class sline : public Base {
public:
sline(int, fill *);
virtual ~sline();
int GetY() const;
void insert(int, int);
void insertfix(int, int);
void walk(fillwalker *);
private:
class point : public Base {
public:
point(int, sline *);
virtual ~point();
int GetX() const;
int GetY() const;
void walk(fillwalker *);
point * look(int);
private:
int x;
point * next;
sline * header;
};
int y;
sline * next;
fill * header;
sline * look(int);
protected:
point * pheader;
friend class point;
private:
int count() const;
};
int minX, minY, maxX, maxY;
texture * cached;
texture * scached;
std::vector<segment> segments;
protected:
sline * header;
friend class sline;
};
class shape : public Base {
public:
shape(SDL_Surface * = 0);
virtual void pixel(int x, int y, ColorP = WHITE);
virtual void circle(int x, int y, int r, ColorP = WHITE);
virtual void pcircle(int x, int y, int r, ColorP = WHITE);
virtual fill * fcircle(int x, int y, int r);
virtual void fdraw(fill *, ColorP = WHITE, int sx = 0, int sy = 0);
virtual void sdraw(fill *, ColorP = WHITE, int sx = 0, int sy = 0);
virtual void box(int x1, int y1, int x2, int y2, ColorP = DOS_WHITE);
virtual void box3d(int x1, int y1, int x2, int y2, ColorP = DOS_WHITE, ColorP = DOS_HIGH_WHITE, ColorP = DOS_GRAY, int = 2, bool = false);
virtual void box(int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP);
virtual void obox(int x1, int y1, int x2, int y2, ColorP = DOS_WHITE);
virtual void obox3d(int x1, int y1, int x2, int y2, ColorP = DOS_HIGH_WHITE, ColorP = DOS_GRAY, bool = false);
virtual void obox(int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP);
virtual void hline(int x1, int x2, int y, ColorP = DOS_WHITE);
virtual void hline3d(int x1, int x2, int y, ColorP = DOS_HIGH_WHITE, ColorP = DOS_GRAY, bool = false);
virtual void hline(int x1, int x2, int y, ColorP, ColorP);
virtual void vline(int x, int y1, int y2, ColorP = DOS_WHITE);
virtual void vline3d(int x, int y1, int y2, ColorP = DOS_HIGH_WHITE, ColorP = DOS_GRAY, bool = false);
virtual void vline(int x, int y1, int y2, ColorP, ColorP);
virtual void line(int x1, int y1, int x2, int y2, ColorP = WHITE);
virtual void tbox(texture *, int x1, int y1, int x2, int y2, int tx = 0, int ty = 0, double = 1.0, ColorP = WHITE);
virtual void tbox(texture *, int x1, int y1, int x2, int y2, int tx1, int ty1, int tx2, int ty2, ColorP = WHITE);
virtual void tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx = 0, int ty = 0, double = 1.0);
virtual void tbox(texture *, int x1, int y1, int x2, int y2, ColorP, ColorP, ColorP, ColorP, int tx1, int ty1, int tx2, int ty2);
virtual void window(int x1, int y1, int x2, int y2,
const String & title = "",
ColorP titlecolor = DOS_HIGH_WHITE,
ColorP titlebackcolor = DOS_MAGENTA,
ColorP front = DOS_WHITE,
ColorP shade1 = DOS_HIGH_WHITE,
ColorP shade2 = DOS_GRAY);
virtual void text(int x, int y, const String &,
ColorP textcolor = DOS_HIGH_WHITE,
align_t align = LEFT);
virtual void text3d(int x, int y, const String &,
ColorP textcolor = DOS_BLACK,
ColorP shade1 = DOS_HIGH_WHITE,
ColorP shade2 = DOS_GRAY,
align_t align = LEFT,
bool bevel = false);
virtual void button(int x1, int y1, int x2, int y2, const String &,
bool bevel = false,
ColorP front = DOS_WHITE,
ColorP shade1 = DOS_HIGH_WHITE,
ColorP shade2 = DOS_GRAY,
ColorP round = DOS_BLACK,
ColorP textcolor = DOS_BLACK,
ColorP tshade1 = DOS_HIGH_WHITE,
ColorP tshade2 = DOS_GRAY);
SDL_Surface * GetSurf();
private:
void bsubline_1(int x1, int y1, int x2, int y2, ColorP = WHITE);
void bsubline_2(int x1, int y1, int x2, int y2, ColorP = WHITE);
void bsubline_3(int x1, int y1, int x2, int y2, ColorP = WHITE);
void bsubline_4(int x1, int y1, int x2, int y2, ColorP = WHITE);
virtual bool Enter();
virtual void Leave(bool);
SDL_Surface * surf;
};
class filldrawer : public fillwalker {
public:
filldrawer(fill *, texture *, ColorP = DOS_WHITE);
virtual ~filldrawer();
virtual void step(int x, int y);
private:
fill * f;
texture * t;
ColorP c;
int oldx, oldy;
};
class segdrawer : public segwalker {
public:
segdrawer(fill *, texture *, ColorP = DOS_WHITE);
virtual ~segdrawer();
virtual void step(int x1, int y1, int x2, int y2);
private:
fill * f;
texture * t;
ColorP c;
shape * sh;
};
};
#endif
|