-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathContainr.h
287 lines (241 loc) · 10.9 KB
/
Containr.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
/*
* Containr.h -- Tree hierarchy to hold frames.
*
* A container is a polymorph struct which can either hold one or more children
* containers or exactly one frame (or is empty). This way a tree structure of
* containers represents the hierarchy as given by <FRAMESET> and <FRAME> tags
* and allowes every node (= container) in the tree to have it's content be
* replaced at any time.
*
* AltF4 - Feb. 17, 2002
*
*/
#ifndef __CONTAINR_H__
#define __CONTAINR_H__
#ifdef __PUREC__
# ifdef CONTAINR
# undef CONTAINR
# undef HISTORY
# endif
typedef struct s_containr * CONTAINR;
typedef struct s_history * HISTORY;
#endif
/*--- Events propagated by the library to registered handlers ---*/
typedef enum {
HW_ActivityBeg, /* Some unspecified background job started/stopped its */
HW_ActivityEnd, /* activity (generic event). If 'gen_ptr' isn't NULL it *
* is to be seen as a long value describing the amount of *
* started/stopped activities. */
HW_PageCleared, /* A part of or the pane itsels lost it contents. Any *
* pointer into the tree structure should be invalidated *
* immediately. */
HW_PageStarted, /* A part of or the pane itsels starts loading new *
* content. 'gen_ptr' contains the LOCATION of the *
* new contents. */
HW_PageFinished, /* A part of or the pane itself is finished after loading *
* and parsing. 'gen_ptr' points to the screen extents *
* or is NULL if no content exists. */
HW_PageUpdated, /* A page changed it's content. 'gen_ptr' points to the *
* changed screen area or may be NULL. */
HW_ImgBegLoad, /* An image starts to be loaded. 'gen_ptr' points to a *
* char* of the image location. */
HW_ImgEndLoad, /* An image ended loading. On success 'gen_ptr' points *
* to a rectangle of changed contents else it is NULL. */
HW_SetTitle,
HW_SetInfo
} HW_EVENT;
typedef void (*CNTR_HDLR)(HW_EVENT, long arg, CONTAINR, const void * gen_ptr);
/* Declaration of handlers for recieving events from the library
* which can be registered with a container. The parameter 'arg' is
* the value that was given along with the handler function by the
* caller. The container is this one where the event appeared and
* needn't to be the same that was initially created. The gen_ptr
* argument holds some additional information depending of the type
* of event.
*/
/*--- Declaration ---*/
struct s_containr {
char * Name; /* named location as given from the <FRAME NAME=".."> tag */
GRECT Area; /* position and size in absolute screen coordinates */
CONTAINR Base, /* the anchestor of all containers in this tree or *
* itself if this is the base itself */
Parent, /* structure pointer, back reference to it's linking *
* parent or NULL for a base container */
Sibling; /* next container of the same parent or NULL */
short ColSize, RowSize; /* extent of the container, both values are either *
* positive absolute values or negative fractions *
* of -1024 */
void * HighLight;
BOOL Resize; /* as given from the <.. RESIZE tag */
WORD BorderSize; /* BAD HTML frame border attribute */
WORD BorderColor; /* BAD HTML frame border colour */
SCROLL_CODE Scroll; /* as given from the <.. SCROLLING=".."tag */
CNTR_HDLR Handler;
long HdlrArg;
enum { CNT_EMPTY = 0, /* initial state */
CNT_FRAME = 1, /* u.Frame may point to a frame */
CNT_CLD_H = 2, /* u.Child may point to a list of children,
* horizontal ordered */
CNT_CLD_V = 3 /* same as above but vertical ordered */
} Mode;
union { CONTAINR Child;
FRAME Frame;
} u;
};
/*--- Constructor/Destructor ---*/
CONTAINR new_containr (CONTAINR parent);
/* Create a new container structure with an initial mode of
* CNT_EMPTY.
*/
void delete_containr (CONTAINR *);
/* Delete a container and all of it's children and substructures.
*/
/*--- Modification of the tree structure ---*/
void containr_fillup (CONTAINR, const char * text, BOOL colsNrows);
/* Fill an empty container with a number of children according
* to the comma separated list of 'text'. If 'colsNrows' is TRUE
* the container's mode will be set to CNT_CLD_H and the children
* ColSizes will be set from the parameters in the list.
* Else the mode will be set to CNT_CLD_V and RowSizes are
* calculated.
*/
CONTAINR containr_resume (CONTAINR);
/* Calculates percentage and fractional sizes of children and
* removes undefined childrens. The container argument is the
* last defined or the first undefined of the list of siblings.
* The return value is the parent of the sibling list.
*/
void containr_setup (CONTAINR, FRAME, const char * anchor);
/* Attache a frame to an empty container and change the
* container's mode to CNT_FRAME. If anchor is not NULL the
* content will be shifted to this location.
*/
void containr_clear (CONTAINR);
/* Destroy all children and substructures of the container and
* reset it to the state CNT_EMPTY. Only the structure pointers
* and the attributes Area and Name are preserved.
*/
void containr_register (CONTAINR, CNTR_HDLR, long arg);
/* Registers a handler function with a container. Parents aren't
* affected but every later created children will inherit this
* values.
*/
void * containr_highlight (CONTAINR, void * highlight);
ULONG containr_escape (CONTAINR);
/*--- History stuff ---*/
struct s_history {
UWORD Length;
char Text[80]; /* maxium length of a GEM string */
};
#undef HISTORY
#define HISTORY HISTORY
HISTORY history_create (CONTAINR, const char * name, HISTORY prev);
/* Creates a history item that is a snapshot of the complete
* container tree and all of it contents. If prev is NULL a
* title string will be created from the name argument, else it
* will be taken from prev.
*/
void history_update (CONTAINR, HISTORY);
/* Stores a snapshot of the content states in the history item
* (scroll bar positions).
*/
void history_destroy (HISTORY*);
/* Deletes a history item and frees all shared resources.
*/
typedef struct {
CONTAINR Target;
LOCATION Location;
ENCODING Encoding;
WORD ScrollV, ScrollH;
} HISTENTR;
UWORD containr_process (CONTAINR, HISTORY hist, HISTORY prev,
HISTENTR entr[], UWORD max_num);
/* Re-creates a container tree from a history item. If prev is
* not NULL only changed contents will be processed. The entr
* array will be filled with frames which needs to get reloaded,
* but not more than given by max_num.
* The return value is the number of entries to be post-processed
* in the array.
*/
/*--- Queries of attributes/characteristics (const methods) ---*/
#define containr_Frame(cont) ((cont)->Mode == CNT_FRAME ?(cont)->u.Frame :NULL)
/* Returns the frame of a container or NULL if no frame was
* attached.
*/
#define containr_Base(frame) (((CONTAINR)(frame)->Container)->Base)
/* Returns the base of the frame's container hierarchy. That is
* the parent of all other members and has no parent itself.
*/
CONTAINR containr_byName (CONTAINR, const char * name);
/* Returns the first member of the given container's hierarchy
* which name matches the given string case insensitive or NULL
* if no match was found.
*/
CONTAINR containr_byCoord (CONTAINR, short x, short y);
/* Returns the member of the given container's hierarchy which
* includes the absolute coordinate [x/y] or NULL if the
* coordinate is outside of all.
*/
BOOL containr_Anchor (CONTAINR, const char * anchor, long * dx, long * dy);
/* Calculates the distances between the current container
* content's origin and and the location of an anchor and stores
* the results in dx and dy. If one or both results are nonzero
* a TRUE will be returned.
*/
/*--- Finding an element at a screen coordinate ---*/
#define PE_NONE 0x0000
#define PE_BORDER 0x0010
#define PE_BORDER_UP 0x0011
#define PE_BORDER_DN 0x0012
#define PE_BORDER_LF 0x0014
#define PE_BORDER_RT 0x0018
#define PE_EMPTY 0x0020
#define PE_FRAME 0x0030
#define PE_VBAR 0x0040
#define PE_HBAR 0x0050
#define PE_PARAGRPH 0x0080
#define PE_TEXT 0x0100
#define PE_IMAGE 0x0101
#define PE_TLINK 0x1100
#define PE_ILINK 0x1101
#define PE_INPUT 0x1200
#define PE_EDITABLE 0x1201
#define PE_Type(t) (t & 0xFFF0)
#define PE_SubType(t) (t & 0x000F)
#define PE_isActive(t) (t & 0x1000)
#define PE_isLink(t) ((t & PE_ILINK) >= PE_TLINK)
UWORD containr_Element (CONTAINR *, short x, short y,
GRECT * watch, GRECT * clip, void **);
/*--- Modification of screen representation ---*/
BOOL containr_relocate (CONTAINR, short x, short y);
/* Set the absolute screen coordinate of a base container and
* adjust all children and substructures positions.
*/
BOOL containr_calculate (CONTAINR, const GRECT *);
/* Set the absolute screen coordinate and size of a base
* container and recalculate all children and substructure
* geometries.
*/
BOOL containr_shift (CONTAINR, long * dx, long * dy);
/* Shifts the contents of the container with the distances dx
* horizontal and dy vertical. The differences are aligned to
* the real extent of the contents and the results are stored
* into dx and dy. If any of these both are nonzero the related
* slider value(s) will be updated and a TRUE returned.
*/
/*--- Graphical output (const methods) ---*/
void containr_redraw (CONTAINR, const GRECT *);
/* Redraw a container and all of it's children and substructures.
* If the GRECT argument isn't NULL it will be used as a clipping
* rectangle.
*/
void containr_scroll (CONTAINR, const GRECT *, long dx, long dy);
/* Scrolls the screen at the content's location by the distances
* aligned by the given rectangle.
*/
/*--- Library internal ---*/
BOOL containr_notify (CONTAINR, HW_EVENT, const void * gen_ptr);
/* default values for frame borders */
#define BORDER_SIZE 5
#define BORDER_COLOR G_LWHITE
#endif /*__CONTAINR_H__*/