annotate src/tools.h @ 58:1ca417f741f1

-
author Thinker K.F. Li <thinker@branda.to>
date Sun, 10 Aug 2008 21:32:42 +0800
parents 01ed2bc37eed
children 9ab15ebc9061
rev   line source
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
1 #ifndef __TOOLS_H_
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
2 #define __TOOLS_H_
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
3
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
4
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
5 typedef struct _elmpool elmpool_t;
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
6
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
7 extern elmpool_t *elmpool_new(int elm_sz, int inc_num);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
8 extern void *elmpool_elm_alloc(elmpool_t *pool);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
9 extern void elmpool_elm_free(elmpool_t *pool, void *elm);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
10 extern void elmpool_free(elmpool_t *pool);
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
11
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
13 #define STAILQ(type) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
14 struct { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
15 type *head; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
16 type *tail; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
17 }
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
18 #define STAILQ_INIT(q) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
19 do { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
20 (q).head = (q).tail = NULL; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
21 } while(0)
13
ed55009d96d3 refactory for redrawing
Thinker K.F. Li <thinker@branda.to>
parents: 12
diff changeset
22 #define STAILQ_CLEAN(q) STAILQ_INIT(q)
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
23 #define STAILQ_HEAD(q) ((q).head)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
24 #define STAILQ_TAIL(q) ((q).tail)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
25 #define STAILQ_NEXT(type, field, elm) ((elm)->field)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
26 #define STAILQ_INS(q, type, field, elm) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
27 do { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
28 (elm)->field = (q).head; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
29 (q).head = elm; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
30 if((q).tail == NULL) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
31 (q).tail = elm; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
32 } while(0)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
33 #define STAILQ_INS_TAIL(q, type, field, elm) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
34 do { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
35 (elm)->field = NULL; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
36 if((q).tail != NULL) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
37 (q).tail->field = elm; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
38 (q).tail = elm; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
39 if((q).head == NULL) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
40 (q).head = elm; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
41 } while(0)
39
db2aa914e14b timer for animation
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
42 #define STAILQ_INS_AFTER(type, field, follow, elm) \
db2aa914e14b timer for animation
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
43 do { \
db2aa914e14b timer for animation
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
44 (follow)->field = (elm)->field; \
db2aa914e14b timer for animation
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
45 (elm)->field = follow; \
db2aa914e14b timer for animation
Thinker K.F. Li <thinker@branda.to>
parents: 13
diff changeset
46 } while(0)
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
47 #define STAILQ_REMOVE(q, type, field, elm) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
48 do { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
49 if((elm) == (q).head) { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
50 (q).head = (elm)->field; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
51 if((q).head == NULL) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
52 (q).tail = NULL; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
53 } else { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
54 type *_stailq_cur = (q).head; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
55 while(_stailq_cur != NULL && \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
56 _stailq_cur->field != (elm)) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
57 _stailq_cur = _stailq_cur->field; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
58 if(_stailq_cur != NULL) { \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
59 _stailq_cur->field = elm; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
60 if((q).tail == (elm)) \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
61 (q).tail = _stailq_cur; \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
62 } \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
63 } \
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
64 } while(0)
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
65
55
01ed2bc37eed Radial gradient paint
Thinker K.F. Li <thinker@branda.to>
parents: 39
diff changeset
66
01ed2bc37eed Radial gradient paint
Thinker K.F. Li <thinker@branda.to>
parents: 39
diff changeset
67 #define O_ALLOC(type) ((type *)malloc(sizeof(type)))
01ed2bc37eed Radial gradient paint
Thinker K.F. Li <thinker@branda.to>
parents: 39
diff changeset
68
12
79e9edf4c00a Add redraw manager
Thinker K.F. Li <thinker@branda.to>
parents:
diff changeset
69 #endif /* __TOOLS_H_ */