-
Notifications
You must be signed in to change notification settings - Fork 34
/
wxTurtleGraphics.h
262 lines (217 loc) · 6.12 KB
/
wxTurtleGraphics.h
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#include <wx/wx.h>
#include <wx/colordlg.h>
#include <wx/image.h>
#include <wx/artprov.h>
#include <vector>
#include "LogoFrame.h"
#include "logo.h"
#include "wxTerminal.h"
#include <wx/colordlg.h>
#include <wx/image.h>
#include <wx/artprov.h>
#include "wxGlobals.h"
// ----------------------------------------------------------------------------
// structs
// ----------------------------------------------------------------------------
struct line {
short int x1;
short int y1;
short int x2;
short int y2;
short int pw;
short int color;
unsigned char pm;
int vis;
};
typedef struct {
int color;
int xpos;
int ypos;
int vis;
int pw;
int ph;
int pen_mode;
} pen_info;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// what do we show on screen (there are too many shapes to put them all on
// screen simultaneously)
enum ScreenToShow
{
Show_Default,
Show_Text,
Show_Lines,
Show_Brushes,
Show_Polygons,
Show_Mask,
Show_Ops,
Show_Regions,
Show_Circles
};
enum messageEnum {
PREPARE = 0,
SPLITSCREEN,
FULLSCREEN,
TEXTSCREEN,
DRAWLINE,
EDITCALL,
CLEARSCREEN,
SAVEPEN,
RESTOREPEN,
KILLAPPLICATION,
SETPENCOLOR,
ADDLINE,
SETPENWIDTH,
GETPALETTE,
FLOODFILL,
TOPRINTER,
GETMOUSECOORDS,
GETMOUSEDOWN,
SETINFO,
GETINFO,
DRAWLABEL,
CATCHUP,
PRINTPICT,
PRINTPREVIEWPICT,
PRINTTEXT,
PRINTPREVIEWTEXT
};
#define PEN_REVERSE 0
#define PEN_ERASE 1
#define PEN_DOWN 2
#define NUMCOLORS 512
#define NUMINITCOLORS 16
// ----------------------------------------------------------------------------
// Classes
// ----------------------------------------------------------------------------
class TurtleCanvas;
// This frame will contain the TurtleCanvas
class TurtleFrame : public wxFrame
{
public:
TurtleFrame( wxFrame * parent, const wxString& title, const wxPoint& pos, const wxSize& size);
// event handlers (these functions should _not_ be virtual)
void OnQuit(wxCommandEvent& event);
void OnShow(wxCommandEvent &event);
static int
back_ground,
screen_height,
screen_width,
in_graphics_mode,
in_splitscreen;
static pen_info xgr_pen;
int m_backgroundMode;
int m_textureBackground;
int m_mapMode;
double m_xUserScale;
double m_yUserScale;
int m_xLogicalOrigin;
int m_yLogicalOrigin;
bool m_xAxisReversed,
m_yAxisReversed;
wxColour m_colourForeground, // these are _text_ colours
m_colourBackground;
wxBrush m_backgroundBrush;
TurtleCanvas *m_canvas;
TurtleCanvas * GetCanvas ();
private:
// any class wishing to process wxWindows events must use this macro
DECLARE_EVENT_TABLE()
};
struct mypoint {
int x,y;
};
// define a scrollable canvas for drawing onto
class TurtleCanvas: public wxWindow
{
public:
TurtleCanvas( wxFrame *parent );
virtual ~TurtleCanvas();
wxFrame *m_owner;
wxPaintDC * dc;
static void FinishedEvent();
static void WaitForEvent();
void OnPaint(wxPaintEvent &event);
void OnSize(wxSizeEvent &event);
void OnDraw(wxDC &dc);
bool SetFont(const wxFont &f);
void Show(ScreenToShow show) { m_show = show; Refresh(); }
void internalPrepare();
void TurtlePrintPreview(wxCommandEvent& event);
void PrintTurtleWindow(wxCommandEvent& event);
void SetOwner (wxFrame * frame);
void SetDC (wxPaintDC * dc);
void drawLine(wxCommandEvent & e);
void editCall();
void logoHandle ( wxCommandEvent & e);
void exitApplication();
void OnFocus (wxFocusEvent & event);
void LoseFocus (wxFocusEvent & event);
void OnLeftDown(wxMouseEvent& event) ;
void OnLeftUp(wxMouseEvent& event);
void OnMiddleDown(wxMouseEvent& event) ;
void OnMiddleUp(wxMouseEvent& event);
void OnRightDown(wxMouseEvent& event) ;
void OnRightUp(wxMouseEvent& event);
void OnMouseMove(wxMouseEvent& event) ;
void OnChar(wxKeyEvent& event);
static void setInfo(int type, int val);
static int getInfo(int type);
void OnTimer (wxTimerEvent& event);
void OnEraseBackGround(wxEraseEvent& event) ;
void OnPageSetup(wxCommandEvent& event);
static void drawOneLine(struct line *, wxDC *);
static void realFloodFill(int, wxDC *);
static void realdoFilled(int fillcolor, int count,
struct mypoint *points, wxDC *dc);
static void realDrawLabel(char *, wxDC *);
static void realClearScreen(wxDC *);
void PaintBackground(wxDC& dc) ;
wxFrame * GetOwner();
wxDC * GetDC();
static int mousePosition_x;
static int mousePosition_y;
static int clickPosition_x;
static int clickPosition_y;
static int mouse_down_left;
static int mouse_down_middle;
static int mouse_down_right;
static int mouse_down_last;
static wxColour colors[NUMCOLORS+SPECIAL_COLORS];
private:
void DrawTurtle(wxDC &dc);
wxBitmap
*m_bitmap;
int resized;
ScreenToShow m_show;
wxBitmap m_smile_bmp;
wxIcon m_std_icon;
bool m_clip;
wxTimer * m_timer;
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// Accessed by interpreter
// ----------------------------------------------------------------------------
extern "C" void nop();
extern "C" void set_palette(int, unsigned int, unsigned int, unsigned int);
extern "C" void get_palette(int, unsigned int*, unsigned int*, unsigned int*);
extern "C" void save_pen(pen_info *p);
extern "C" void restore_pen(pen_info *p);
extern "C" void set_pen_patter();
extern "C" void logofill();
extern "C" void wx_clear();
extern "C" NODE lclearscreen(NODE *);
extern "C" void wxDrawLine(int x1, int y1, int x2, int y2, int vis);
extern "C" void wxSplitScreen();
extern "C" void wxFullScreen();
extern "C" void wxTextScreen();
extern "C" void wxPrepare();
extern "C" int wxEditFile(char * f);
extern "C" int wxGetMouseX();
extern "C" int wxGetMouseY();
extern "C" int wxGetButton();
extern "C" void redraw_graphics();
extern "C" void wxSetInfo(int type, int val);
extern "C" int wxGetInfo(int type);