xref: /inferno-os/include/prefab.h (revision 37da2899f40661e3e9631e497da8dc59b971cbd0)
1 #pragma src "/usr/inferno/libprefab"
2 
3 typedef struct PElement PElement;
4 typedef struct PCompound PCompound;
5 typedef struct Memimage Memimage;
6 
7 enum
8 {
9 	Dirty,
10 	Clean
11 };
12 
13 enum Elementtype	/* same as in prefab.m */
14 {
15 	EIcon,
16 	EText,
17 	ETitle,
18 	EHorizontal,
19 	EVertical,
20 	ESeparator,
21 	NEtypes
22 };
23 
24 enum Adjust	/* same as in prefab.m */
25 {
26 	/* first arg: size of elements */
27 	Adjpack = 10,	/* leave alone, pack tightly */
28 	Adjequal = 11,	/* make equal */
29 	Adjfill = 12,	/* make equal, filling available space */
30 
31 	/* second arg: position of element within space */
32 	Adjleft = 20,
33 	Adjup = 20,
34 	Adjcenter = 21,
35 	Adjright = 22,
36 	Adjdown = 22
37 };
38 
39 enum
40 {
41 	Maxchars = 128	/* maximum # chars in a word */
42 };
43 
44 struct PElement
45 {
46 	Prefab_Element	e;
47 	Point		drawpt;
48 	Prefab_Compound*highlight;
49 	List*		first;
50 	List*		last;
51 	List*		vfirst;
52 	List*		vlast;
53 	int		nkids;
54 	int		newline;
55 	int		pkind;	/* for error check against e.kind */
56 };
57 
58 struct PCompound
59 {
60 	Prefab_Compound	c;
61 	Display*	display;
62 };
63 
64 extern Type*	TLayout;
65 extern Type*	TElement;
66 extern Type*	TCompound;
67 
68 PCompound*	iconbox(Prefab_Environ*, Draw_Point, String*, Draw_Image*, Draw_Image*);
69 PCompound*	textbox(Prefab_Environ*, Draw_Rect, String*, String*);
70 PCompound*	layoutbox(Prefab_Environ*, Draw_Rect, String*, List*);
71 PCompound*	box(Prefab_Environ*, Draw_Point, Prefab_Element*, Prefab_Element*);
72 
73 PElement*	separatorelement(Prefab_Environ*, Draw_Rect, Draw_Image*, Draw_Image*);
74 PElement*	iconelement(Prefab_Environ*, Draw_Rect, Draw_Image*, Draw_Image*);
75 PElement*	textelement(Prefab_Environ*, String*, Draw_Rect, enum Elementtype);
76 PElement*	layoutelement(Prefab_Environ*, List*, Draw_Rect, enum Elementtype);
77 PElement*	elistelement(Prefab_Environ*, Prefab_Element*, enum Elementtype);
78 PElement*	appendelist(Prefab_Element*, Prefab_Element*);
79 
80 void		drawcompound(Prefab_Compound*);
81 void		redrawcompound(Image*, Rectangle, Prefab_Compound*);
82 void		refreshcompound(Image*, Rectangle, void*);
83 void		drawelement(Prefab_Element*, Image*, Rectangle, int, int);
84 void		translateelement(Prefab_Element*, Point);
85 void		adjustelement(Prefab_Element*, int, int);
86 void		highlightelement(Prefab_Element*, Image*, Prefab_Compound*, int);
87 void		clipelement(Prefab_Element*, Rectangle);
88 void		scrollelement(Prefab_Element*, Point, int*);
89 int		showelement(Prefab_Element*, Prefab_Element*);
90 void		edge(Prefab_Environ*, Image*, Draw_Rect, Draw_Rect);
91 int		fitrect(Rectangle*, Rectangle);
92 Draw_Rect	edgerect(Prefab_Environ*, Draw_Point, Draw_Rect*);
93 List*		prefabwrap(void*);
94 List*		listoflayout(Prefab_Style*, String*, int);
95 
96 extern PElement*	lookupelement(Prefab_Element*);
97 extern PCompound*	lookupcompound(Prefab_Compound*);
98 extern PElement*	checkelement(Prefab_Element*);
99 extern PCompound*	checkcompound(Prefab_Compound*);
100 extern int		badenviron(Prefab_Environ*, int);
101 extern PElement*	mkelement(Prefab_Environ*, enum Elementtype);
102 extern Point		iconsize(Image*);
103 extern void		localrefreshcompound(Memimage*, Rectangle, void*);
104