gwenhywfar 5.10.1
htmlobject.c
Go to the documentation of this file.
1/***************************************************************************
2 begin : Sat Feb 20 2010
3 copyright : (C) 2010 by Martin Preuss
4 email : martin@libchipcard.de
5
6 ***************************************************************************
7 * Please see toplevel file COPYING for license details *
8 ***************************************************************************/
9
10#ifdef HAVE_CONFIG_H
11# include <config.h>
12#endif
13
14#define DISABLE_DEBUGLOG
15
16
17#include "htmlobject_p.h"
18
19#include <gwenhywfar/misc.h>
20#include <gwenhywfar/debug.h>
21
22#include <assert.h>
23#include <string.h>
24
25
28
29
30
32{
33 HTML_OBJECT *o;
34
36 o->refCount=1;
37 o->objectType=t;
38 o->xmlCtx=ctx;
41
42 return o;
43}
44
45
46
48{
49 if (o) {
50 assert(o->refCount);
51 if (o->refCount>1)
52 o->refCount--;
53 else {
56
57 free(o->text);
58 HtmlProps_free(o->properties);
59
60 o->refCount=0;
62 }
63 }
64}
65
66
67
69{
70 assert(o);
71 assert(o->refCount);
72 o->refCount++;
73}
74
75
76
78{
79 assert(o);
80 assert(o->refCount);
81 return o->xmlCtx;
82}
83
84
85
87{
88 assert(o);
89 assert(o->refCount);
90 return o->objectType;
91}
92
93
94
96{
97 assert(o);
98 assert(o->refCount);
99 o->objectType=t;
100}
101
102
103
105{
106 assert(o);
107 assert(o->refCount);
108 return o->properties;
109}
110
111
112
114{
115 assert(o);
116 assert(o->refCount);
117
119 HtmlProps_free(o->properties);
120 o->properties=pr;
121}
122
123
124
126{
127 assert(o);
128 assert(o->refCount);
129 return o->x;
130}
131
132
133
135{
136 assert(o);
137 assert(o->refCount);
138 o->x=i;
139}
140
141
142
144{
145 assert(o);
146 assert(o->refCount);
147 return o->y;
148}
149
150
151
153{
154 assert(o);
155 assert(o->refCount);
156 o->y=i;
157}
158
159
160
162{
163 assert(o);
164 assert(o->refCount);
165 return o->width;
166}
167
168
169
171{
172 assert(o);
173 assert(o->refCount);
174 o->width=i;
175}
176
177
178
180{
181 assert(o);
182 assert(o->refCount);
183 return o->height;
184}
185
186
187
189{
190 assert(o);
191 assert(o->refCount);
192 o->height=i;
193}
194
195
196
198{
199 assert(o);
200 assert(o->refCount);
201 return o->configuredWidth;
202}
203
204
205
207{
208 assert(o);
209 assert(o->refCount);
210 o->configuredWidth=i;
211}
212
213
214
216{
217 assert(o);
218 assert(o->refCount);
219 return o->configuredHeight;
220}
221
222
223
225{
226 assert(o);
227 assert(o->refCount);
228 o->configuredHeight=i;
229}
230
231
232
233const char *HtmlObject_GetText(const HTML_OBJECT *o)
234{
235 assert(o);
236 assert(o->refCount);
237 return o->text;
238}
239
240
241
242void HtmlObject_SetText(HTML_OBJECT *o, const char *s)
243{
244 assert(o);
245 assert(o->refCount);
246 free(o->text);
247 if (s)
248 o->text=strdup(s);
249 else
250 o->text=NULL;
251}
252
253
254
256{
257 assert(o);
258 assert(o->refCount);
259
260 return o->flags;
261}
262
263
264
265void HtmlObject_SetFlags(HTML_OBJECT *o, uint32_t fl)
266{
267 assert(o);
268 assert(o->refCount);
269
270 o->flags=fl;
271}
272
273
274
275void HtmlObject_AddFlags(HTML_OBJECT *o, uint32_t fl)
276{
277 assert(o);
278 assert(o->refCount);
279
280 o->flags|=fl;
281}
282
283
284
285void HtmlObject_SubFlags(HTML_OBJECT *o, uint32_t fl)
286{
287 assert(o);
288 assert(o->refCount);
289
290 o->flags&=~fl;
291}
292
293
294
296{
297 assert(o);
298 assert(o->refCount);
299 if (o->layoutFn)
300 return o->layoutFn(o);
301 else {
302 o->width=0;
303 o->height=0;
304 return 0;
305 }
306}
307
308
309
312{
314
315 of=o->layoutFn;
316 o->layoutFn=fn;
317 return of;
318}
319
320
321
#define NULL
Definition: binreloc.c:300
HTML_OBJECT_LAYOUT_FN HtmlObject_SetLayoutFn(HTML_OBJECT *o, HTML_OBJECT_LAYOUT_FN fn)
Definition: htmlobject.c:310
HTML_OBJECT_TYPE HtmlObject_GetObjectType(const HTML_OBJECT *o)
Definition: htmlobject.c:86
HTML_OBJECT * HtmlObject_new(GWEN_XML_CONTEXT *ctx, HTML_OBJECT_TYPE t)
Definition: htmlobject.c:31
void HtmlObject_SetProperties(HTML_OBJECT *o, HTML_PROPS *pr)
Definition: htmlobject.c:113
void HtmlObject_SetWidth(HTML_OBJECT *o, int i)
Definition: htmlobject.c:170
int HtmlObject_GetWidth(const HTML_OBJECT *o)
Definition: htmlobject.c:161
void HtmlObject_SetObjectType(HTML_OBJECT *o, HTML_OBJECT_TYPE t)
Definition: htmlobject.c:95
void HtmlObject_Attach(HTML_OBJECT *o)
Definition: htmlobject.c:68
uint32_t HtmlObject_GetFlags(const HTML_OBJECT *o)
Definition: htmlobject.c:255
void HtmlObject_SetText(HTML_OBJECT *o, const char *s)
Definition: htmlobject.c:242
void HtmlObject_SetFlags(HTML_OBJECT *o, uint32_t fl)
Definition: htmlobject.c:265
GWEN_XML_CONTEXT * HtmlObject_GetXmlCtx(const HTML_OBJECT *o)
Definition: htmlobject.c:77
void HtmlObject_SetConfiguredHeight(HTML_OBJECT *o, int i)
Definition: htmlobject.c:224
void HtmlObject_AddFlags(HTML_OBJECT *o, uint32_t fl)
Definition: htmlobject.c:275
const char * HtmlObject_GetText(const HTML_OBJECT *o)
Definition: htmlobject.c:233
int HtmlObject_GetX(const HTML_OBJECT *o)
Definition: htmlobject.c:125
void HtmlObject_free(HTML_OBJECT *o)
Definition: htmlobject.c:47
void HtmlObject_SetY(HTML_OBJECT *o, int i)
Definition: htmlobject.c:152
void HtmlObject_SetHeight(HTML_OBJECT *o, int i)
Definition: htmlobject.c:188
int HtmlObject_GetY(const HTML_OBJECT *o)
Definition: htmlobject.c:143
void HtmlObject_SetConfiguredWidth(HTML_OBJECT *o, int i)
Definition: htmlobject.c:206
void HtmlObject_SubFlags(HTML_OBJECT *o, uint32_t fl)
Definition: htmlobject.c:285
HTML_PROPS * HtmlObject_GetProperties(const HTML_OBJECT *o)
Definition: htmlobject.c:104
void HtmlObject_SetX(HTML_OBJECT *o, int i)
Definition: htmlobject.c:134
int HtmlObject_GetHeight(const HTML_OBJECT *o)
Definition: htmlobject.c:179
int HtmlObject_GetConfiguredWidth(const HTML_OBJECT *o)
Definition: htmlobject.c:197
int HtmlObject_Layout(HTML_OBJECT *o)
Definition: htmlobject.c:295
int HtmlObject_GetConfiguredHeight(const HTML_OBJECT *o)
Definition: htmlobject.c:215
HTML_OBJECT_TYPE
Definition: htmlobject_be.h:43
int(* HTML_OBJECT_LAYOUT_FN)(HTML_OBJECT *o)
Definition: htmlobject_be.h:41
struct HTML_OBJECT HTML_OBJECT
Definition: htmlobject_be.h:25
void HtmlProps_free(HTML_PROPS *pr)
Definition: htmlprops.c:40
void HtmlProps_Attach(HTML_PROPS *pr)
Definition: htmlprops.c:73
struct HTML_PROPS HTML_PROPS
Definition: htmlprops_be.h:15
#define GWEN_INHERIT_FUNCTIONS(t)
Definition: inherit.h:163
#define GWEN_INHERIT_INIT(t, element)
Definition: inherit.h:223
#define GWEN_INHERIT_FINI(t, element)
Definition: inherit.h:238
#define GWEN_FREE_OBJECT(varname)
Definition: memory.h:61
#define GWEN_NEW_OBJECT(typ, varname)
Definition: memory.h:55
#define GWEN_TREE_FINI(t, element)
Definition: tree.h:571
#define GWEN_TREE_FUNCTIONS(t, pr)
Definition: tree.h:402
#define GWEN_TREE_INIT(t, element)
Definition: tree.h:562
struct GWEN_XML_CONTEXT GWEN_XML_CONTEXT
Definition: xmlctx.h:39