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
|
enum {
Pbackground,
Pmax,
};
enum {
Gnone,
Gcontainer,
Gmax,
};
typedef struct Colour Colour;
typedef union PropVal PropVal;
typedef struct PropSpec PropSpec;
typedef struct Prop Prop;
typedef struct GuiSpec GuiSpec;
typedef struct GuiElement GuiElement;
struct Colour {
Image *image;
ulong code;
};
union PropVal {
Colour *colour;
};
struct PropSpec {
char *name;
PropVal (*def)(void);
char *(*print)(PropVal);
char *(*parse)(char *, PropVal *);
};
struct Prop {
int tag;
PropVal val;
Qid qid;
};
struct GuiSpec {
char *name;
void (*draw)(GuiElement *);
void (*layout)(GuiElement *, Rectangle);
int nprops;
int proptags[];
};
struct GuiElement {
int type;
int id;
Qid qid;
Qid qclone;
Qid qevent;
Qid qtype;
Qid qprops;
int nchildren;
GuiElement **children;
GuiElement *parent;
int nprops;
Prop *props;
Rectangle rect;
};
extern GuiElement *root;
extern PropSpec propspecs[Pmax];
extern GuiSpec guispecs[Gmax];
void *emalloc(ulong);
Colour *mkcolour(ulong);
void initgraphics(void);
void layout(GuiElement *, Rectangle);
void updategui(int);
void drawnone(GuiElement *);
void drawcontainer(GuiElement *);
void layoutnone(GuiElement *, Rectangle);
void layoutcontainer(GuiElement *, Rectangle);
PropVal getprop(GuiElement *, int);
void setprop(GuiElement *, int, PropVal);
|