-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.h
115 lines (103 loc) · 1.95 KB
/
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
typedef struct gcolor GColor;
typedef struct gfont GFont;
typedef struct grect GRect;
typedef struct gevent GEvent;
typedef enum gpointer GPointer;
enum gpointer {
GPNormal,
GPResize,
};
struct gcolor {
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char x;
};
#define GBlack (GColor){ 0, 0, 0, 0 }
#define GGray (GColor){ 150, 150, 150, 0 }
#define GPaleBlue (GColor){ 208, 235, 255, 0 }
#define GPaleGreen (GColor){ 231, 255, 221, 0 }
#define GPalePink (GColor){ 255, 248, 221, 0 }
#define GPaleYellow (GColor){ 255, 255, 234, 0 }
#define GPinkLace (GColor){ 255, 221, 244, 0 }
#define GXBlack (GColor){ 0, 0, 0, 1 }
struct gfont {
int ascent;
int descent;
int height;
};
struct grect {
int x, y;
int w, h;
};
struct gevent {
enum {
GResize,
GKey,
GMouseDown,
GMouseUp,
GMouseSelect,
} type;
union {
struct {
int width;
int height;
} resize;
Rune key;
struct {
enum {
GBLeft,
GBMiddle,
GBRight,
GBWheelUp,
GBWheelDown,
} button;
int x;
int y;
} mouse;
};
};
enum {
GKEsc = 0x1b,
GKF1 = 0xe001, /* unicode private use area */
GKF2,
GKF3,
GKF4,
GKF5,
GKF6,
GKF7,
GKF8,
GKF9,
GKF10,
GKF11,
GKF12,
GKLeft,
GKRight,
GKUp,
GKDown,
GKPageUp,
GKPageDown,
GKBackspace,
};
#define CTRL(x) ((x) ^ 64)
struct gui {
int (*init)(void);
void (*fini)(void);
void (*getfont)(GFont *fret);
void (*decorate)(GRect *clip, int dirty, GColor color);
void (*drawtext)(GRect *clip, Rune *str, int len,
int x, int y, GColor color);
void (*drawrect)(GRect *clip, int x, int y, int w, int h, GColor c);
void (*drawcursor)(GRect *clip, int insert, int x, int y, int w);
void (*setpointer)(GPointer pt);
int (*sync)(void);
int (*textwidth)(Rune *str, int len);
int (*nextevent)(GEvent *eret);
int hmargin;
int vmargin;
int border;
GRect actionr;
};
/* Available gui modules */
extern struct gui gui_x11;
extern struct gui gui_sdl;