| 4394 |
ripley |
1 |
/*
|
|
|
2 |
* GraphApp
|
|
|
3 |
* --------
|
|
|
4 |
* Common cross-platform graphics application routines.
|
|
|
5 |
* Version 2.4 (c) Lachlan Patrick 1996-1998.
|
|
|
6 |
* This header file is designed to be platform-independent.
|
|
|
7 |
*
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
/*
|
|
|
11 |
* Common cross-platform graphics routines library.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
#ifndef _GRAPHAPP_H
|
|
|
15 |
#define _GRAPHAPP_H 240
|
|
|
16 |
|
|
|
17 |
/*
|
|
|
18 |
* Assume C declarations for C++
|
|
|
19 |
*/
|
|
|
20 |
|
|
|
21 |
#ifdef __cplusplus
|
|
|
22 |
extern "C" {
|
|
|
23 |
#endif /* begin normal C declarations */
|
|
|
24 |
|
|
|
25 |
/*
|
|
|
26 |
* Definition of some constants.
|
|
|
27 |
*/
|
|
|
28 |
|
|
|
29 |
#include <stdio.h>
|
|
|
30 |
#include <stdlib.h>
|
|
|
31 |
|
|
|
32 |
#ifndef Pi
|
|
|
33 |
#define Pi 3.14159265359
|
|
|
34 |
#endif
|
|
|
35 |
|
|
|
36 |
/*
|
|
|
37 |
* Types.
|
|
|
38 |
*/
|
|
|
39 |
|
| 21104 |
ripley |
40 |
typedef unsigned char GAbyte;
|
| 4394 |
ripley |
41 |
|
| 21104 |
ripley |
42 |
#define byte GAbyte
|
|
|
43 |
|
| 4394 |
ripley |
44 |
#ifndef objptr
|
|
|
45 |
typedef struct { int kind; } gui_obj;
|
|
|
46 |
typedef gui_obj * objptr;
|
|
|
47 |
#endif
|
|
|
48 |
|
|
|
49 |
typedef unsigned long rgb; /* red-green-blue colour value */
|
|
|
50 |
|
|
|
51 |
typedef objptr font; /* font of certain size and style */
|
|
|
52 |
typedef objptr cursor; /* mouse cursor shape */
|
|
|
53 |
|
|
|
54 |
typedef objptr drawing; /* bitmap, window or control */
|
|
|
55 |
|
|
|
56 |
typedef drawing bitmap; /* platform-specific bitmap */
|
|
|
57 |
typedef drawing window; /* on-screen window */
|
|
|
58 |
typedef drawing control; /* buttons, text-fields, scrollbars */
|
|
|
59 |
|
|
|
60 |
typedef control label; /* text label */
|
|
|
61 |
typedef control button; /* push button */
|
|
|
62 |
typedef control checkbox; /* check-box */
|
|
|
63 |
typedef control radiobutton; /* radio button */
|
|
|
64 |
typedef control radiogroup; /* group of radio buttons */
|
|
|
65 |
typedef control field; /* one-line text field */
|
|
|
66 |
typedef control textbox; /* multi-line text box */
|
|
|
67 |
typedef control scrollbar; /* scroll-bar */
|
|
|
68 |
typedef control listbox; /* list of text */
|
| 13710 |
ripley |
69 |
typedef control progressbar; /* progress bar */
|
| 4394 |
ripley |
70 |
|
|
|
71 |
typedef control menubar; /* contains menus */
|
|
|
72 |
typedef control menu; /* pull-down menu contains menuitems */
|
|
|
73 |
typedef control menuitem; /* a single item in a pull-down menu */
|
|
|
74 |
|
|
|
75 |
/*
|
|
|
76 |
* Structures.
|
|
|
77 |
*/
|
|
|
78 |
|
|
|
79 |
typedef struct point point;
|
|
|
80 |
typedef struct rect rect;
|
|
|
81 |
typedef struct drawstruct drawstruct;
|
|
|
82 |
typedef struct drawstruct *drawstate;
|
|
|
83 |
typedef struct imagedata imagedata;
|
|
|
84 |
typedef struct imagedata *image;
|
|
|
85 |
|
|
|
86 |
struct point
|
|
|
87 |
{
|
|
|
88 |
int x, y;
|
|
|
89 |
};
|
|
|
90 |
|
|
|
91 |
struct rect
|
|
|
92 |
{
|
|
|
93 |
int x, y; /* top-left point inside rect */
|
|
|
94 |
int width, height; /* width and height of rect */
|
|
|
95 |
};
|
|
|
96 |
|
|
|
97 |
struct drawstruct
|
|
|
98 |
{
|
|
|
99 |
drawing dest;
|
|
|
100 |
rgb hue;
|
|
|
101 |
int mode;
|
|
|
102 |
point p;
|
|
|
103 |
int linewidth;
|
|
|
104 |
font fnt;
|
|
|
105 |
cursor crsr;
|
|
|
106 |
};
|
|
|
107 |
|
|
|
108 |
struct imagedata {
|
|
|
109 |
int depth;
|
|
|
110 |
int width;
|
|
|
111 |
int height;
|
|
|
112 |
int cmapsize;
|
|
|
113 |
rgb * cmap;
|
|
|
114 |
byte * pixels;
|
|
|
115 |
};
|
|
|
116 |
|
|
|
117 |
/*
|
|
|
118 |
* Call-backs.
|
|
|
119 |
*/
|
|
|
120 |
|
|
|
121 |
typedef void (*voidfn)(void);
|
|
|
122 |
typedef void (*timerfn)(void *data);
|
|
|
123 |
typedef void (*actionfn)(control c);
|
|
|
124 |
typedef void (*drawfn)(control c, rect r);
|
|
|
125 |
typedef void (*mousefn)(control c, int buttons, point xy);
|
|
|
126 |
typedef void (*intfn)(control c, int argument);
|
|
|
127 |
typedef void (*keyfn)(control c, int key);
|
|
|
128 |
typedef void (*menufn)(menuitem m);
|
|
|
129 |
typedef void (*scrollfn)(scrollbar s, int position);
|
| 14086 |
ripley |
130 |
typedef void (*dropfn)(control c, char *data);
|
| 4394 |
ripley |
131 |
|
|
|
132 |
/*
|
|
|
133 |
* Mouse buttons state (bit-fields).
|
|
|
134 |
*/
|
|
|
135 |
|
|
|
136 |
#define NoButton 0x0000
|
|
|
137 |
#define LeftButton 0x0001
|
|
|
138 |
#define MiddleButton 0x0002
|
|
|
139 |
#define RightButton 0x0004
|
|
|
140 |
|
|
|
141 |
/*
|
|
|
142 |
* ANSI character codes.
|
|
|
143 |
*/
|
|
|
144 |
|
|
|
145 |
#define BELL 0x07
|
|
|
146 |
#define BKSP 0x08
|
|
|
147 |
#define VTAB 0x0B
|
|
|
148 |
#define FF 0x0C
|
|
|
149 |
#define ESC 0x1B
|
|
|
150 |
|
|
|
151 |
/*
|
|
|
152 |
* Edit-key codes.
|
|
|
153 |
*/
|
|
|
154 |
|
|
|
155 |
#define INS 0x2041
|
|
|
156 |
#define DEL 0x2326
|
|
|
157 |
#define HOME 0x21B8
|
|
|
158 |
#define END 0x2198
|
|
|
159 |
#define PGUP 0x21DE
|
|
|
160 |
#define PGDN 0x21DF
|
|
|
161 |
#define ENTER 0x2324
|
|
|
162 |
|
|
|
163 |
/*
|
|
|
164 |
* Cursor-key codes.
|
|
|
165 |
*/
|
|
|
166 |
|
|
|
167 |
#define LEFT 0x2190
|
|
|
168 |
#define UP 0x2191
|
|
|
169 |
#define RIGHT 0x2192
|
|
|
170 |
#define DOWN 0x2193
|
|
|
171 |
|
|
|
172 |
/*
|
|
|
173 |
* Function-key codes.
|
|
|
174 |
*/
|
|
|
175 |
|
|
|
176 |
#define F1 0x276C
|
|
|
177 |
#define F2 0x276D
|
|
|
178 |
#define F3 0x276E
|
|
|
179 |
#define F4 0x276F
|
|
|
180 |
#define F5 0x2770
|
|
|
181 |
#define F6 0x2771
|
|
|
182 |
#define F7 0x2772
|
|
|
183 |
#define F8 0x2773
|
|
|
184 |
#define F9 0x2774
|
|
|
185 |
#define F10 0x2775
|
|
|
186 |
|
|
|
187 |
/*
|
|
|
188 |
* Redefined functions.
|
|
|
189 |
*/
|
|
|
190 |
#define REDEFINE_FUNC_NAMES
|
|
|
191 |
#define addpt GA_addpt
|
|
|
192 |
#define subpt GA_subpt
|
|
|
193 |
#define equalpt GA_equalpt
|
|
|
194 |
#define newmenu GA_newmenu
|
|
|
195 |
#define newcontrol GA_newcontrol
|
|
|
196 |
#define newwindow GA_newwindow
|
|
|
197 |
#define gettext GA_gettext
|
|
|
198 |
#define settext GA_settext
|
|
|
199 |
|
|
|
200 |
/*
|
|
|
201 |
* General functions.
|
|
|
202 |
*/
|
|
|
203 |
|
|
|
204 |
int initapp(int argc, char *argv[]);
|
|
|
205 |
void exitapp(void);
|
|
|
206 |
|
|
|
207 |
void drawall(void);
|
|
|
208 |
int peekevent(void);
|
|
|
209 |
int doevent(void);
|
|
|
210 |
void mainloop(void);
|
|
|
211 |
|
|
|
212 |
int execapp(char *cmd);
|
|
|
213 |
|
| 9184 |
ripley |
214 |
/*void beep(void);*/
|
| 4394 |
ripley |
215 |
|
|
|
216 |
/*
|
|
|
217 |
* Point and rectangle arithmetic.
|
|
|
218 |
*/
|
|
|
219 |
|
|
|
220 |
point newpoint(int x, int y);
|
|
|
221 |
rect newrect(int left, int top, int width, int height);
|
|
|
222 |
rect rpt(point min, point max);
|
|
|
223 |
|
|
|
224 |
#define pt(x,y) newpoint((x),(y))
|
|
|
225 |
#define rect(x,y,w,h) newrect((x),(y),(w),(h))
|
|
|
226 |
|
|
|
227 |
point topleft(rect r);
|
|
|
228 |
point bottomright(rect r);
|
|
|
229 |
point topright(rect r);
|
|
|
230 |
point bottomleft(rect r);
|
|
|
231 |
|
|
|
232 |
point addpt(point p1, point p2);
|
|
|
233 |
point subpt(point p1, point p2);
|
|
|
234 |
point midpt(point p1, point p2);
|
|
|
235 |
point mulpt(point p1, int i);
|
|
|
236 |
point divpt(point p1, int i);
|
|
|
237 |
rect rmove(rect r, point p);
|
|
|
238 |
rect raddpt(rect r, point p);
|
|
|
239 |
rect rsubpt(rect r, point p);
|
|
|
240 |
rect rmul(rect r, int i);
|
|
|
241 |
rect rdiv(rect r, int i);
|
|
|
242 |
rect growr(rect r, int w, int h);
|
|
|
243 |
rect insetr(rect r, int i);
|
|
|
244 |
rect rcenter(rect r1, rect r2);
|
|
|
245 |
int ptinr(point p, rect r);
|
|
|
246 |
int rinr(rect r1, rect r2);
|
|
|
247 |
int rxr(rect r1, rect r2);
|
|
|
248 |
int equalpt(point p1, point p2);
|
|
|
249 |
int equalr(rect r1, rect r2);
|
|
|
250 |
rect clipr(rect r1, rect r2);
|
|
|
251 |
rect rcanon(rect r);
|
|
|
252 |
|
|
|
253 |
/*
|
|
|
254 |
* Colour functions and constants.
|
|
|
255 |
*/
|
|
|
256 |
|
|
|
257 |
#define rgb(r,g,b) ((((rgb)r)<<16)|(((rgb)g)<<8)|((rgb)b))
|
|
|
258 |
#define getalpha(col) (((col)>>24)&0x00FFUL)
|
|
|
259 |
#define getred(col) (((col)>>16)&0x00FFUL)
|
|
|
260 |
#define getgreen(col) (((col)>>8)&0x00FFUL)
|
|
|
261 |
#define getblue(col) ((col)&0x00FFUL)
|
|
|
262 |
|
|
|
263 |
void setrgb(rgb c);
|
|
|
264 |
#define setcolor(c) setrgb(c)
|
|
|
265 |
#define setcolour(c) setrgb(c)
|
|
|
266 |
|
| 21104 |
ripley |
267 |
/* changed to avoid clashes with w32api 2.0 */
|
|
|
268 |
#define gaRed 0x00FF0000UL
|
|
|
269 |
#define gaGreen 0x0000FF00UL
|
|
|
270 |
#define gaBlue 0x000000FFUL
|
|
|
271 |
|
|
|
272 |
|
| 4394 |
ripley |
273 |
#define Transparent 0xFFFFFFFFUL
|
|
|
274 |
|
|
|
275 |
#define Black 0x00000000UL
|
|
|
276 |
#define White 0x00FFFFFFUL
|
|
|
277 |
#define Yellow 0x00FFFF00UL
|
|
|
278 |
#define Magenta 0x00FF00FFUL
|
|
|
279 |
#define Cyan 0x0000FFFFUL
|
|
|
280 |
|
|
|
281 |
#define Grey 0x00808080UL
|
|
|
282 |
#define Gray 0x00808080UL
|
|
|
283 |
#define LightGrey 0x00C0C0C0UL
|
|
|
284 |
#define LightGray 0x00C0C0C0UL
|
|
|
285 |
#define DarkGrey 0x00404040UL
|
|
|
286 |
#define DarkGray 0x00404040UL
|
|
|
287 |
|
|
|
288 |
#define DarkBlue 0x00000080UL
|
|
|
289 |
#define DarkGreen 0x00008000UL
|
| 9184 |
ripley |
290 |
#define DarkRed 0x008B0000UL/* changed to match rgb */
|
| 4394 |
ripley |
291 |
#define LightBlue 0x0080C0FFUL
|
|
|
292 |
#define LightGreen 0x0080FF80UL
|
|
|
293 |
#define LightRed 0x00FFC0FFUL
|
|
|
294 |
#define Pink 0x00FFAFAFUL
|
|
|
295 |
#define Brown 0x00603000UL
|
|
|
296 |
#define Orange 0x00FF8000UL
|
|
|
297 |
#define Purple 0x00C000FFUL
|
|
|
298 |
#define Lime 0x0080FF00UL
|
|
|
299 |
|
|
|
300 |
/*
|
|
|
301 |
* Context functions for bitmaps, windows, controls.
|
|
|
302 |
*/
|
|
|
303 |
|
|
|
304 |
void addto(control dest);
|
|
|
305 |
void drawto(drawing dest);
|
|
|
306 |
void setlinewidth(int width);
|
|
|
307 |
|
|
|
308 |
/*
|
|
|
309 |
* Transfer modes for drawing operations, S=source, D=destination.
|
|
|
310 |
* The modes are arranged so that, for example, (~D)|S == notDorS.
|
|
|
311 |
*/
|
|
|
312 |
|
|
|
313 |
void setdrawmode(int mode);
|
|
|
314 |
|
|
|
315 |
#define Zeros 0x00
|
|
|
316 |
#define DnorS 0x01
|
|
|
317 |
#define DandnotS 0x02
|
|
|
318 |
#define notS 0x03
|
|
|
319 |
#define notDandS 0x04
|
|
|
320 |
#define notD 0x05
|
|
|
321 |
#define DxorS 0x06
|
|
|
322 |
#define DnandS 0x07
|
|
|
323 |
#define DandS 0x08
|
|
|
324 |
#define DxnorS 0x09
|
|
|
325 |
#define D 0x0A
|
|
|
326 |
#define DornotS 0x0B
|
|
|
327 |
#define S 0x0C
|
|
|
328 |
#define notDorS 0x0D
|
|
|
329 |
#define DorS 0x0E
|
|
|
330 |
#define Ones 0x0F
|
|
|
331 |
|
|
|
332 |
/*
|
|
|
333 |
* Drawing functions.
|
|
|
334 |
*/
|
|
|
335 |
|
|
|
336 |
void bitblt(drawing dest, drawing src, point dp, rect sr, int mode);
|
|
|
337 |
|
|
|
338 |
void scrollrect(point dp, rect sr);
|
|
|
339 |
void copyrect(drawing src, point dp, rect sr);
|
|
|
340 |
void texturerect(drawing src, rect r);
|
|
|
341 |
void invertrect(rect r);
|
|
|
342 |
|
|
|
343 |
rgb getpixel(point p);
|
|
|
344 |
void setpixel(point p, rgb c);
|
|
|
345 |
|
|
|
346 |
/*
|
|
|
347 |
* Drawing using the current colour.
|
|
|
348 |
*/
|
|
|
349 |
|
|
|
350 |
void moveto(point p);
|
|
|
351 |
void lineto(point p);
|
|
|
352 |
|
|
|
353 |
void drawpoint(point p);
|
|
|
354 |
void drawline(point p1, point p2);
|
|
|
355 |
void drawrect(rect r);
|
|
|
356 |
void fillrect(rect r);
|
|
|
357 |
void drawarc(rect r, int start_angle, int end_angle);
|
|
|
358 |
void fillarc(rect r, int start_angle, int end_angle);
|
|
|
359 |
void drawellipse(rect r);
|
|
|
360 |
void fillellipse(rect r);
|
|
|
361 |
void drawroundrect(rect r);
|
|
|
362 |
void fillroundrect(rect r);
|
|
|
363 |
void drawpolygon(point *p, int n);
|
|
|
364 |
void fillpolygon(point *p, int n);
|
|
|
365 |
|
|
|
366 |
/*
|
|
|
367 |
* Drawing text, selecting fonts.
|
|
|
368 |
*/
|
|
|
369 |
|
|
|
370 |
font newfont(char *name, int style, int size);
|
|
|
371 |
void setfont(font f);
|
|
|
372 |
|
|
|
373 |
int fontwidth(font f);
|
|
|
374 |
int fontheight(font f);
|
|
|
375 |
int fontascent(font f);
|
|
|
376 |
int fontdescent(font f);
|
|
|
377 |
|
|
|
378 |
#define getascent(f) fontascent(f)
|
|
|
379 |
#define getdescent(f) fontdescent(f)
|
|
|
380 |
|
|
|
381 |
int strwidth(font f, char *s);
|
|
|
382 |
point strsize(font f, char *s);
|
|
|
383 |
rect strrect(font f, char *s);
|
|
|
384 |
|
|
|
385 |
int drawstr(point p, char *str);
|
|
|
386 |
int textheight(int width, char *text);
|
|
|
387 |
char * drawtext(rect r, int alignment, char *text);
|
|
|
388 |
int gprintf(char *fmt, ...);
|
|
|
389 |
|
|
|
390 |
/*
|
|
|
391 |
* Text styles and alignments.
|
|
|
392 |
*/
|
|
|
393 |
|
|
|
394 |
#define Plain 0x0000
|
|
|
395 |
#define Bold 0x0001
|
|
|
396 |
#define Italic 0x0002
|
|
|
397 |
#define BoldItalic 0x0003
|
|
|
398 |
#define SansSerif 0x0004
|
|
|
399 |
#define FixedWidth 0x0008
|
|
|
400 |
#define Wide 0x0010
|
|
|
401 |
#define Narrow 0x0020
|
|
|
402 |
|
|
|
403 |
#define AlignTop 0x0000
|
|
|
404 |
#define AlignBottom 0x0100
|
|
|
405 |
#define VJustify 0x0200
|
|
|
406 |
#define VCenter 0x0400
|
|
|
407 |
#define VCentre 0x0400
|
|
|
408 |
#define AlignLeft 0x0000
|
|
|
409 |
#define AlignRight 0x1000
|
|
|
410 |
#define Justify 0x2000
|
|
|
411 |
#define Center 0x4000
|
|
|
412 |
#define Centre 0x4000
|
|
|
413 |
#define AlignCenter 0x4000
|
|
|
414 |
#define AlignCentre 0x4000
|
|
|
415 |
#define Underline 0x0800
|
|
|
416 |
|
|
|
417 |
/*
|
|
|
418 |
* Find the current state of drawing.
|
|
|
419 |
*/
|
|
|
420 |
|
|
|
421 |
drawing currentdrawing(void);
|
|
|
422 |
rgb currentrgb(void);
|
|
|
423 |
#define currentcolor() currentrgb()
|
|
|
424 |
#define currentcolour() currentrgb()
|
|
|
425 |
int currentmode(void);
|
|
|
426 |
point currentpoint(void);
|
|
|
427 |
int currentlinewidth(void);
|
|
|
428 |
font currentfont(void);
|
|
|
429 |
cursor currentcursor(void);
|
|
|
430 |
|
|
|
431 |
/*
|
|
|
432 |
* Find current keyboard state.
|
|
|
433 |
*/
|
|
|
434 |
|
|
|
435 |
int getkeystate(void);
|
|
|
436 |
|
|
|
437 |
#define AltKey 0x0001
|
|
|
438 |
#define CmdKey 0x0001
|
|
|
439 |
#define CtrlKey 0x0002
|
|
|
440 |
#define OptionKey 0x0002
|
|
|
441 |
#define ShiftKey 0x0004
|
|
|
442 |
|
|
|
443 |
/*
|
|
|
444 |
* Bitmaps.
|
|
|
445 |
*/
|
|
|
446 |
|
|
|
447 |
bitmap newbitmap(int width, int height, int depth);
|
|
|
448 |
bitmap loadbitmap(char *name);
|
|
|
449 |
bitmap imagetobitmap(image img);
|
|
|
450 |
bitmap createbitmap(int width, int height, int depth, byte *data);
|
|
|
451 |
void setbitmapdata(bitmap b, byte data[]);
|
|
|
452 |
void getbitmapdata(bitmap b, byte data[]);
|
| 26839 |
ripley |
453 |
void getbitmapdata2(bitmap b, byte **data);
|
| 4394 |
ripley |
454 |
|
|
|
455 |
/*
|
|
|
456 |
* Images.
|
|
|
457 |
*/
|
|
|
458 |
|
|
|
459 |
image newimage(int width, int height, int depth);
|
|
|
460 |
image copyimage(image img);
|
|
|
461 |
void delimage(image img);
|
|
|
462 |
|
|
|
463 |
void setpixels(image img, byte pixels[]);
|
|
|
464 |
byte * getpixels(image img);
|
|
|
465 |
|
|
|
466 |
void setpalette(image img, int length, rgb cmap[]);
|
|
|
467 |
rgb * getpalette(image img);
|
|
|
468 |
int getpalettesize(image img);
|
|
|
469 |
|
|
|
470 |
image scaleimage(image src, rect dr, rect sr);
|
|
|
471 |
image convert32to8(image img);
|
|
|
472 |
image convert8to32(image img);
|
|
|
473 |
void sortpalette(image img);
|
|
|
474 |
|
|
|
475 |
image loadimage(char *filename);
|
|
|
476 |
void saveimage(image img, char *filename);
|
|
|
477 |
|
|
|
478 |
void drawimage(image img, rect dr, rect sr);
|
|
|
479 |
void drawmonochrome(image img, rect dr, rect sr);
|
|
|
480 |
void drawgreyscale(image img, rect dr, rect sr);
|
|
|
481 |
#define drawgrayscale drawgreyscale
|
|
|
482 |
void drawdarker(image img, rect dr, rect sr);
|
|
|
483 |
void drawbrighter(image img, rect dr, rect sr);
|
|
|
484 |
|
|
|
485 |
/*
|
|
|
486 |
* Windows.
|
|
|
487 |
*/
|
|
|
488 |
|
|
|
489 |
window newwindow(char *name, rect r, long flags);
|
|
|
490 |
void show(window w);
|
|
|
491 |
void hide(window w);
|
| 24605 |
ripley |
492 |
rect GetCurrentWinPos(window obj);
|
| 4394 |
ripley |
493 |
|
|
|
494 |
/*
|
|
|
495 |
* Window creation flags.
|
|
|
496 |
*/
|
|
|
497 |
|
|
|
498 |
#define SimpleWindow 0x00000000L
|
|
|
499 |
|
|
|
500 |
#define Menubar 0x00000010L
|
|
|
501 |
#define Titlebar 0x00000020L
|
|
|
502 |
#define Closebox 0x00000040L
|
|
|
503 |
#define Resize 0x00000080L
|
|
|
504 |
#define Maximize 0x00000100L
|
|
|
505 |
#define Minimize 0x00000200L
|
|
|
506 |
#define HScrollbar 0x00000400L
|
|
|
507 |
#define VScrollbar 0x00000800L
|
|
|
508 |
|
|
|
509 |
#define Modal 0x00001000L
|
|
|
510 |
#define Floating 0x00002000L
|
|
|
511 |
#define Centered 0x00004000L
|
|
|
512 |
#define Centred 0x00004000L
|
|
|
513 |
|
|
|
514 |
#define Workspace 0x00010000L
|
|
|
515 |
#define Document 0x00020000L
|
|
|
516 |
#define ChildWindow 0x00040000L
|
|
|
517 |
|
|
|
518 |
#define TrackMouse 0x00080000L
|
|
|
519 |
|
|
|
520 |
#define UsePalette 0x00100000L
|
|
|
521 |
|
|
|
522 |
#define StandardWindow (Titlebar|Closebox|Resize|Maximize|Minimize)
|
|
|
523 |
|
|
|
524 |
/*
|
|
|
525 |
* Functions which work for bitmaps, windows and controls.
|
|
|
526 |
*/
|
|
|
527 |
|
|
|
528 |
int objdepth(objptr obj);
|
|
|
529 |
rect objrect(objptr obj);
|
|
|
530 |
int objwidth(objptr obj);
|
|
|
531 |
int objheight(objptr obj);
|
|
|
532 |
void delobj(objptr obj);
|
|
|
533 |
|
|
|
534 |
#define getdepth(obj) objdepth((objptr)(obj))
|
|
|
535 |
#define getrect(obj) objrect((objptr)(obj))
|
|
|
536 |
#define getwidth(obj) objwidth((objptr)(obj))
|
|
|
537 |
#define getheight(obj) objheight((objptr)(obj))
|
|
|
538 |
#define del(obj) delobj((objptr)(obj))
|
|
|
539 |
|
|
|
540 |
/*
|
|
|
541 |
* Setting window and control callback functions.
|
|
|
542 |
*/
|
|
|
543 |
|
|
|
544 |
void setaction(control c, actionfn fn);
|
|
|
545 |
void sethit(control c, intfn fn);
|
|
|
546 |
void setdel(control c, actionfn fn);
|
|
|
547 |
void setclose(control c, actionfn fn);
|
|
|
548 |
|
|
|
549 |
void setredraw(control c, drawfn fn);
|
|
|
550 |
void setresize(control c, drawfn fn);
|
|
|
551 |
|
|
|
552 |
void setkeydown(control c, keyfn fn);
|
|
|
553 |
void setkeyaction(control c, keyfn fn);
|
|
|
554 |
|
|
|
555 |
void setmousedown(control c, mousefn fn);
|
|
|
556 |
void setmousedrag(control c, mousefn fn);
|
|
|
557 |
void setmouseup(control c, mousefn fn);
|
|
|
558 |
void setmousemove(control c, mousefn fn);
|
|
|
559 |
void setmouserepeat(control c, mousefn fn);
|
|
|
560 |
|
| 14086 |
ripley |
561 |
void setdrop(control c, dropfn fn);
|
|
|
562 |
|
| 4394 |
ripley |
563 |
/*
|
|
|
564 |
* Using windows and controls.
|
|
|
565 |
*/
|
|
|
566 |
|
|
|
567 |
void clear(control c);
|
|
|
568 |
void draw(control c);
|
|
|
569 |
void redraw(control c);
|
|
|
570 |
void resize(control c, rect r);
|
|
|
571 |
|
|
|
572 |
void show(control c);
|
|
|
573 |
void hide(control c);
|
|
|
574 |
int isvisible(control c);
|
|
|
575 |
|
|
|
576 |
void enable(control c);
|
|
|
577 |
void disable(control c);
|
|
|
578 |
int isenabled(control c);
|
|
|
579 |
|
|
|
580 |
void check(control c);
|
|
|
581 |
void uncheck(control c);
|
|
|
582 |
int ischecked(control c);
|
|
|
583 |
|
|
|
584 |
void highlight(control c);
|
|
|
585 |
void unhighlight(control c);
|
|
|
586 |
int ishighlighted(control c);
|
|
|
587 |
|
|
|
588 |
void flashcontrol(control c);
|
|
|
589 |
void activatecontrol(control c);
|
|
|
590 |
|
|
|
591 |
/*
|
|
|
592 |
* Changing the state of a control.
|
|
|
593 |
*/
|
|
|
594 |
|
|
|
595 |
void settext(control c, char *newtext);
|
|
|
596 |
char * gettext(control c);
|
|
|
597 |
#define setname(c,newname) settext(c,newname)
|
|
|
598 |
#define getname(c) gettext(c)
|
|
|
599 |
|
|
|
600 |
void settextfont(control c, font f);
|
|
|
601 |
font gettextfont(control c);
|
|
|
602 |
|
|
|
603 |
void setforeground(control c, rgb fg);
|
|
|
604 |
rgb getforeground(control c);
|
|
|
605 |
void setbackground(control c, rgb bg);
|
|
|
606 |
rgb getbackground(control c);
|
|
|
607 |
|
|
|
608 |
void setvalue(control c, int value);
|
|
|
609 |
int getvalue(control c);
|
|
|
610 |
void setdata(control c, void *data);
|
|
|
611 |
void * getdata(control c);
|
|
|
612 |
|
|
|
613 |
window parentwindow(control c);
|
|
|
614 |
|
|
|
615 |
/*
|
|
|
616 |
* Control states.
|
|
|
617 |
*/
|
|
|
618 |
|
|
|
619 |
#define Visible 0x0001L
|
|
|
620 |
#define Enabled 0x0002L
|
|
|
621 |
#define Checked 0x0004L
|
|
|
622 |
#define Highlighted 0x0008L
|
|
|
623 |
#define Armed 0x0010L
|
|
|
624 |
#define Focus 0x0020L
|
|
|
625 |
|
|
|
626 |
/*
|
|
|
627 |
* Create buttons, scrollbars, controls etc on the current window.
|
|
|
628 |
*/
|
|
|
629 |
|
|
|
630 |
control newcontrol(char *text, rect r);
|
|
|
631 |
|
|
|
632 |
drawing newdrawing(rect r, drawfn fn);
|
|
|
633 |
drawing newpicture(image img, rect r);
|
|
|
634 |
|
|
|
635 |
button newbutton(char *text, rect r, actionfn fn);
|
|
|
636 |
button newimagebutton(image img, rect r, actionfn fn);
|
|
|
637 |
void setimage(control c, image img);
|
|
|
638 |
|
|
|
639 |
checkbox newcheckbox(char *text, rect r, actionfn fn);
|
|
|
640 |
checkbox newimagecheckbox(image img, rect r, actionfn fn);
|
|
|
641 |
|
|
|
642 |
radiobutton newradiobutton(char *text, rect r, actionfn fn);
|
|
|
643 |
radiogroup newradiogroup(void);
|
|
|
644 |
|
|
|
645 |
scrollbar newscrollbar(rect r, int max, int pagesize, scrollfn fn);
|
|
|
646 |
void changescrollbar(scrollbar s, int where, int max, int size);
|
|
|
647 |
|
|
|
648 |
label newlabel(char *text, rect r, int alignment);
|
|
|
649 |
field newfield(char *text, rect r);
|
|
|
650 |
field newpassword(char *text, rect r);
|
|
|
651 |
textbox newtextbox(char *text, rect r);
|
|
|
652 |
textbox newtextarea(char *text, rect r);
|
|
|
653 |
|
|
|
654 |
listbox newlistbox(char *list[], rect r, scrollfn fn);
|
|
|
655 |
listbox newdroplist(char *list[], rect r, scrollfn fn);
|
|
|
656 |
listbox newdropfield(char *list[], rect r, scrollfn fn);
|
|
|
657 |
listbox newmultilist(char *list[], rect r, scrollfn fn);
|
|
|
658 |
int isselected(listbox b, int index);
|
|
|
659 |
void setlistitem(listbox b, int index);
|
|
|
660 |
int getlistitem(listbox b);
|
|
|
661 |
void changelistbox(listbox b, char *new_list[]);
|
|
|
662 |
|
| 13710 |
ripley |
663 |
progressbar newprogressbar(rect r, int pmin, int pmax, int incr, int smooth);
|
|
|
664 |
void setprogressbar(progressbar obj, int n);
|
|
|
665 |
void stepprogressbar(progressbar obj, int n);
|
|
|
666 |
void setprogressbarrange(progressbar obj, int pbmin, int pbmax);
|
|
|
667 |
|
|
|
668 |
|
| 4394 |
ripley |
669 |
menubar newmenubar(actionfn adjust_menus);
|
|
|
670 |
menu newsubmenu(menu parent, char *name);
|
|
|
671 |
menu newmenu(char *name);
|
|
|
672 |
menuitem newmenuitem(char *name, int key, menufn fn);
|
|
|
673 |
|
|
|
674 |
/*
|
|
|
675 |
* Text editing functions.
|
|
|
676 |
*/
|
|
|
677 |
|
|
|
678 |
void cuttext(textbox t);
|
|
|
679 |
void copytext(textbox t);
|
|
|
680 |
void cleartext(textbox t);
|
|
|
681 |
void pastetext(textbox t);
|
|
|
682 |
void inserttext(textbox t, char *text);
|
|
|
683 |
void selecttext(textbox t, long start, long end);
|
|
|
684 |
void textselection(textbox t, long *start, long *end);
|
|
|
685 |
|
|
|
686 |
/*
|
|
|
687 |
* Dialogs.
|
|
|
688 |
*/
|
|
|
689 |
|
|
|
690 |
#define YES 1
|
|
|
691 |
#define NO -1
|
|
|
692 |
#define CANCEL 0
|
|
|
693 |
|
|
|
694 |
void apperror(char *errstr);
|
|
|
695 |
void askok(char *info);
|
|
|
696 |
int askokcancel(char *question);
|
|
|
697 |
int askyesno(char *question);
|
|
|
698 |
int askyesnocancel(char *question);
|
|
|
699 |
char * askstring(char *question, char *default_string);
|
|
|
700 |
char * askpassword(char *question, char *default_string);
|
|
|
701 |
char * askfilename(char *title, char *default_name);
|
|
|
702 |
char * askfilesave(char *title, char *default_name);
|
| 22785 |
ripley |
703 |
char * askUserPass(char *title);
|
| 4394 |
ripley |
704 |
|
|
|
705 |
/*
|
|
|
706 |
* Time functions.
|
|
|
707 |
*/
|
|
|
708 |
|
|
|
709 |
int settimer(unsigned millisec);
|
|
|
710 |
void settimerfn(timerfn timeout, void *data);
|
|
|
711 |
int setmousetimer(unsigned millisec);
|
|
|
712 |
void delay(unsigned millisec);
|
|
|
713 |
long currenttime(void);
|
|
|
714 |
|
|
|
715 |
/*
|
|
|
716 |
* Cursors.
|
|
|
717 |
*/
|
|
|
718 |
|
|
|
719 |
cursor newcursor(point hotspot, image img);
|
|
|
720 |
cursor createcursor(point offset, byte *white_mask, byte *black_shape);
|
|
|
721 |
cursor loadcursor(char *name);
|
|
|
722 |
void setcursor(cursor c);
|
|
|
723 |
|
|
|
724 |
/*
|
|
|
725 |
* Change the drawing state.
|
|
|
726 |
*/
|
|
|
727 |
|
|
|
728 |
drawstate copydrawstate(void);
|
|
|
729 |
void setdrawstate(drawstate saved_state);
|
|
|
730 |
void restoredrawstate(drawstate saved_state);
|
|
|
731 |
void resetdrawstate(void);
|
|
|
732 |
|
|
|
733 |
|
|
|
734 |
/*
|
|
|
735 |
* Library supplied variables.
|
|
|
736 |
*/
|
|
|
737 |
|
|
|
738 |
extern font SystemFont; /* system font */
|
|
|
739 |
extern font FixedFont; /* fixed-width font */
|
|
|
740 |
extern font Times; /* times roman font (serif) */
|
|
|
741 |
extern font Helvetica; /* helvetica font (sans serif) */
|
|
|
742 |
extern font Courier; /* courier font (fixed width) */
|
|
|
743 |
|
| 15716 |
ripley |
744 |
#include <R_ext/libextern.h>
|
|
|
745 |
LibExtern cursor ArrowCursor; /* normal arrow cursor */
|
|
|
746 |
LibExtern cursor BlankCursor; /* invisible cursor */
|
|
|
747 |
LibExtern cursor WatchCursor; /* wait for the computer */
|
|
|
748 |
LibExtern cursor CaretCursor; /* insert text */
|
|
|
749 |
LibExtern cursor TextCursor; /* insert text */
|
|
|
750 |
LibExtern cursor HandCursor; /* hand pointer */
|
|
|
751 |
#undef LibExtern
|
| 19907 |
ripley |
752 |
#undef extern
|
| 4394 |
ripley |
753 |
|
|
|
754 |
#ifdef __cplusplus
|
|
|
755 |
}
|
|
|
756 |
#endif /* end normal C declarations */
|
|
|
757 |
|
|
|
758 |
|
|
|
759 |
#ifdef __cplusplus
|
|
|
760 |
|
|
|
761 |
/* begin C++ declarations */
|
|
|
762 |
|
|
|
763 |
/*
|
|
|
764 |
* Point and rectangle arithmetic.
|
|
|
765 |
*/
|
|
|
766 |
|
|
|
767 |
inline point operator + (point p, point p2) {p.x+=p2.x; p.y+=p2.y; return p;}
|
|
|
768 |
inline point operator - (point p, point p2) {p.x-=p2.x; p.y-=p2.y; return p;}
|
|
|
769 |
inline point operator += (point& p, point p2) {p.x+=p2.x; p.y+=p2.y; return p;}
|
|
|
770 |
inline point operator -= (point& p, point p2) {p.x-=p2.x; p.y-=p2.y; return p;}
|
|
|
771 |
|
|
|
772 |
inline rect operator + (rect r, point p) {r.x+=p.x; r.y+=p.y; return r;}
|
|
|
773 |
inline rect operator - (rect r, point p) {r.x-=p.x; r.y-=p.y; return r;}
|
|
|
774 |
inline rect operator += (rect& r, point p) {r.x+=p.x; r.y+=p.y; return r;}
|
|
|
775 |
inline rect operator -= (rect& r, point p) {r.x-=p.x; r.y-=p.y; return r;}
|
|
|
776 |
|
|
|
777 |
inline rect operator + (rect r, int i) {return insetr(r,-i);}
|
|
|
778 |
inline rect operator - (rect r, int i) {return insetr(r,i);}
|
|
|
779 |
inline rect operator ++ (rect& r) {return r=insetr(r,-1);}
|
|
|
780 |
inline rect operator -- (rect& r) {return r=insetr(r,1);}
|
|
|
781 |
inline rect operator += (rect& r, int i) {return r=insetr(r,-i);}
|
|
|
782 |
inline rect operator -= (rect& r, int i) {return r=insetr(r,i);}
|
|
|
783 |
|
|
|
784 |
inline int operator == (point p1, point p2) {return equalpt(p1,p2);}
|
|
|
785 |
inline int operator == (rect r1, rect r2) {return equalr(r1,r2);}
|
|
|
786 |
inline int operator != (point p1, point p2) {return !equalpt(p1,p2);}
|
|
|
787 |
inline int operator != (rect r1, rect r2) {return !equalr(r1,r2);}
|
|
|
788 |
|
|
|
789 |
#endif /* end C++ declarations */
|
|
|
790 |
|
|
|
791 |
#endif /* Common cross-platform graphics library. */
|