-
Notifications
You must be signed in to change notification settings - Fork 8
/
lispe_gui.h
309 lines (234 loc) · 7.83 KB
/
lispe_gui.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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
/*
* LispE
*
* Copyright 2020-present NAVER Corp.
* The 3-Clause BSD License
*/
//
// lispe_gui.cxx
//
#ifndef lispe_gui_h
#define lispe_gui_h
class Doublewindow;
class Fltk_widget : public Element {
public:
LispE* lisp;
Fl_Widget* widget;
Element* function;
Element* object;
Fltk_widget(LispE* lsp, short t, Element* f, Element* o) : Element(t) {
lisp = lsp;
widget = NULL;
object = null_;
function = NULL;
if (o != NULL) {
object = o;
object->increment();
}
if (f != null_ && f != NULL) {
function = f;
function->increment();
}
//In case an error occurs, we use this mechanism to ensure a clean
//deletion of FLTK objects
}
~Fltk_widget() {
if (function != NULL)
function->decrement();
object->decrement();
if (widget != NULL)
delete widget;
}
Element* labeltype(LispE*);
Element* labelcolor(LispE*);
Element* labelfont(LispE*);
Element* labelsize(LispE*);
Element* backgroundcolor(LispE*);
Element* labelwindow(LispE*);
Element* selectionColor(LispE* lisp);
void align(LispE*);
void hide(LispE*);
void focus(LispE*);
void show(LispE*);
void circle(LispE* lisp);
void point(LispE* lisp);
void pie(LispE* lisp);
void rectangleFill(LispE* lisp);
void rectangle(LispE* lisp);
void drawText(LispE* lisp);
void arc(LispE* lisp);
void line(LispE* lisp);
void lineShape(LispE* lisp);
Element* coordinates(LispE* lisp);
Element* linerotation(LispE* lisp);
Element* transform_x(LispE* lisp);
Element* transform_y(LispE* lisp);
Element* transform_dx(LispE* lisp);
Element* transform_dy(LispE* lisp);
Element* plot(LispE* lisp);
Element* plotcoords(LispE* lisp);
Element* textsize(LispE* lisp);
Element* rgbcolor(LispE* lisp);;
void drawcolor(LispE* lisp);
void textfont(LispE* lisp);
void polygon(LispE* lisp);
void loop(LispE* lisp);
void scale(LispE* lisp);
void translate(LispE* lisp);
void rotate(LispE* lisp);
void multmatrix(LispE* lisp);
void transform_vertex(LispE* lisp);
void pushclip(LispE*);
void popclip(LispE*);
virtual void run() {}
virtual void finalize(LispE*) {}
virtual void close() {}
virtual Element* ask(LispE* lisp) {return null_;}
virtual void alert(LispE*) {}
virtual void bitmap(LispE* lisp) {}
virtual void gif_image(LispE* lisp) {}
virtual void onclose(Element* f) {}
Element* widget_label(LispE*);
virtual void resize() {}
virtual Element* value(LispE*) {
return emptystring_;
}
virtual void insert(LispE*) {}
virtual Element* selection(LispE* lisp) {
return emptystring_;
}
virtual void wrap() {}
virtual void boundaries() {}
virtual void step() {}
void redraw() {
if (widget != NULL)
widget->redraw();
}
bool check();
virtual void clean() {
if (widget != NULL) {
delete widget;
widget = NULL;
}
}
virtual void push(Fltk_widget* w) {}
};
class Fltk_window : public Fltk_widget {
public:
Element* on_close_function;
string label;
double time_value;
bool main_window;
bool update;
bool finalized;
vector<Fltk_widget*> items;
Fltk_window(LispE* lsp, short t, int x, int y, int w, int h, string& label, Element* f, Element* o);
Fltk_window(LispE* lsp, short t, int x, int y, string& label, Element* f, Element* o);
~Fltk_window();
void push(Fltk_widget* w) {
items.push_back(w);
w->increment();
}
void run();
void finalize(LispE*);
void close();
Element* ask(LispE*);
void alert(LispE*);
void onclose(Element* f);
void resize();
void bitmap(LispE*);
void gif_image(LispE*);
Doublewindow* window() {
return (Doublewindow*)widget;
}
void clean() {
close();
}
};
//------------------------------------------------------------------------------------
class Fltk_input : public Fltk_widget {
public:
string text;
string buf;
Fltk_input(LispE* lsp, short t, int x, int y, int w, int h, bool mltline, string& label, Element* f, Element* o);
Element* value(LispE*);
void insert(LispE*);
Element* selection(LispE*);
};
//------------------------------------------------------------------------------------
class Fltk_output : public Fltk_widget {
public:
string text;
string buf;
Fltk_output(LispE* lsp, short t, int x, int y, int w, int h, bool mltline, string& label);
Element* value(LispE*);
void wrap();
};
//------------------------------------------------------------------------------------
class Fltk_button : public Fltk_widget {
public:
string text;
bool image;
Fltk_button(LispE* lsp, short t, int x, int y, int w, int h, int thetype, int shape, string& label, Element* f, Element* o);
Element* value(LispE*);
void bitmap(LispE*);
void gif_image(LispE*);
};
//------------------------------------------------------------------------------------
class Fltk_slider : public Fltk_widget {
public:
string text;
Fltk_slider(LispE* lsp, short t, int x, int y, int w, int h, int align, bool value_slider, string& label, Element* f, Element* o);
Element* value(LispE*);
void boundaries();
void step();
};
//------------------------------------------------------------------------------------
class Fltk_bitmap : public Element {
public:
Fl_Bitmap* bitmap;
uchar* bm;
int szw, szh;
Fltk_bitmap(LispE* lisp, short ty, List* kbitmaps, int w, int h, int sz);
};
//------------------------------------------------------------------------------------
class Fltk_gif : public Element {
public:
Fl_Image* image;
string filename;
Fltk_gif(LispE* lisp, short ty, string& name);
};
//------------------------------------------------------------------------------------
class Doublewindow : public Fl_Double_Window {
public:
LispE* lisp;
Fltk_window* fltk_window;
long i_fltk_window;
Doublewindow(LispE* lsp, int x, int y, int w, int h, const char* l, Fltk_window* wn);
Doublewindow(LispE* lsp, int x, int y, const char* l, Fltk_window* wn);
~Doublewindow();
void draw();
};
typedef enum {
fltk_create_bitmap, fltk_create_gif, fltk_create, fltk_create_resizable,
fltk_input, fltk_output, fltk_button, fltk_slider, fltk_bitmap, fltk_gif_image,
fltk_run, fltk_end, fltk_close, fltk_on_close, fltk_value, fltk_insert, fltk_selection, fltk_resize,
fltk_redraw, fltk_circle, fltk_drawtext, fltk_rectangle, fltk_wrap, fltk_step, fltk_label,
fltk_rectanglefill, fltk_arc, fltk_pie, fltk_point, fltk_line, fltk_boundaries,
fltk_textfont, fltk_rgbcolor, fltk_show, fltk_focus, fltk_align, fltk_coordinates,
fltk_selectioncolor, fltk_labelwindow, fltk_labeltype, fltk_labelcolor, fltk_labelfont, fltk_labelsize, fltk_drawcolor, fltk_polygon,
fltk_loop, fltk_linerotation, fltk_scale, fltk_translate, fltk_rotate, fltk_multmatrix, fltk_transform_x, fltk_transform_y,
fltk_transform_dx, fltk_transform_dy, fltk_transform_vertex, fltk_pushclip, fltk_popclip, fltk_textsize, fltk_hide,
fltk_backgroundcolor, fltk_plot, fltk_plotcoords, fltk_ask, fltk_alert, fltk_lineshape
} fltk_action;
class Lispe_gui : public Element {
public:
fltk_action action;
short fltk_widget;
Lispe_gui(LispE*, short idgui, short idwn, fltk_action a);
Element* eval(LispE* lisp);
//We use this instruction to return a description of the instruction
//Indeed, just do: (print getenv) to get this information
wstring asString(LispE* lisp);
};
#endif