gwenhywfar
4.3.1
|
00001 /*************************************************************************** 00002 begin : Sat Feb 20 2010 00003 copyright : (C) 2010 by Martin Preuss 00004 email : martin@libchipcard.de 00005 00006 *************************************************************************** 00007 * Please see toplevel file COPYING for license details * 00008 ***************************************************************************/ 00009 00010 #ifdef HAVE_CONFIG_H 00011 # include <config.h> 00012 #endif 00013 00014 #define DISABLE_DEBUGLOG 00015 00016 00017 #include "htmlobject_p.h" 00018 00019 #include <gwenhywfar/misc.h> 00020 #include <gwenhywfar/debug.h> 00021 00022 #include <assert.h> 00023 #include <string.h> 00024 00025 00026 GWEN_TREE_FUNCTIONS(HTML_OBJECT, HtmlObject) 00027 GWEN_INHERIT_FUNCTIONS(HTML_OBJECT) 00028 00029 00030 00031 HTML_OBJECT *HtmlObject_new(GWEN_XML_CONTEXT *ctx, HTML_OBJECT_TYPE t) { 00032 HTML_OBJECT *o; 00033 00034 GWEN_NEW_OBJECT(HTML_OBJECT, o); 00035 o->refCount=1; 00036 o->objectType=t; 00037 o->xmlCtx=ctx; 00038 GWEN_TREE_INIT(HTML_OBJECT, o); 00039 GWEN_INHERIT_INIT(HTML_OBJECT, o); 00040 00041 return o; 00042 } 00043 00044 00045 00046 void HtmlObject_free(HTML_OBJECT *o) { 00047 if (o) { 00048 assert(o->refCount); 00049 if (o->refCount>1) 00050 o->refCount--; 00051 else { 00052 GWEN_TREE_FINI(HTML_OBJECT, o); 00053 GWEN_INHERIT_FINI(HTML_OBJECT, o); 00054 00055 free(o->text); 00056 HtmlProps_free(o->properties); 00057 00058 o->refCount=0; 00059 GWEN_FREE_OBJECT(o); 00060 } 00061 } 00062 } 00063 00064 00065 00066 void HtmlObject_Attach(HTML_OBJECT *o) { 00067 assert(o); 00068 assert(o->refCount); 00069 o->refCount++; 00070 } 00071 00072 00073 00074 GWEN_XML_CONTEXT *HtmlObject_GetXmlCtx(const HTML_OBJECT *o) { 00075 assert(o); 00076 assert(o->refCount); 00077 return o->xmlCtx; 00078 } 00079 00080 00081 00082 HTML_OBJECT_TYPE HtmlObject_GetObjectType(const HTML_OBJECT *o) { 00083 assert(o); 00084 assert(o->refCount); 00085 return o->objectType; 00086 } 00087 00088 00089 00090 void HtmlObject_SetObjectType(HTML_OBJECT *o, HTML_OBJECT_TYPE t) { 00091 assert(o); 00092 assert(o->refCount); 00093 o->objectType=t; 00094 } 00095 00096 00097 00098 HTML_PROPS *HtmlObject_GetProperties(const HTML_OBJECT *o) { 00099 assert(o); 00100 assert(o->refCount); 00101 return o->properties; 00102 } 00103 00104 00105 00106 void HtmlObject_SetProperties(HTML_OBJECT *o, HTML_PROPS *pr) { 00107 assert(o); 00108 assert(o->refCount); 00109 00110 HtmlProps_Attach(pr); 00111 HtmlProps_free(o->properties); 00112 o->properties=pr; 00113 } 00114 00115 00116 00117 int HtmlObject_GetX(const HTML_OBJECT *o) { 00118 assert(o); 00119 assert(o->refCount); 00120 return o->x; 00121 } 00122 00123 00124 00125 void HtmlObject_SetX(HTML_OBJECT *o, int i) { 00126 assert(o); 00127 assert(o->refCount); 00128 o->x=i; 00129 } 00130 00131 00132 00133 int HtmlObject_GetY(const HTML_OBJECT *o) { 00134 assert(o); 00135 assert(o->refCount); 00136 return o->y; 00137 } 00138 00139 00140 00141 void HtmlObject_SetY(HTML_OBJECT *o, int i) { 00142 assert(o); 00143 assert(o->refCount); 00144 o->y=i; 00145 } 00146 00147 00148 00149 int HtmlObject_GetWidth(const HTML_OBJECT *o) { 00150 assert(o); 00151 assert(o->refCount); 00152 return o->width; 00153 } 00154 00155 00156 00157 void HtmlObject_SetWidth(HTML_OBJECT *o, int i) { 00158 assert(o); 00159 assert(o->refCount); 00160 o->width=i; 00161 } 00162 00163 00164 00165 int HtmlObject_GetHeight(const HTML_OBJECT *o) { 00166 assert(o); 00167 assert(o->refCount); 00168 return o->height; 00169 } 00170 00171 00172 00173 void HtmlObject_SetHeight(HTML_OBJECT *o, int i) { 00174 assert(o); 00175 assert(o->refCount); 00176 o->height=i; 00177 } 00178 00179 00180 00181 int HtmlObject_GetConfiguredWidth(const HTML_OBJECT *o) { 00182 assert(o); 00183 assert(o->refCount); 00184 return o->configuredWidth; 00185 } 00186 00187 00188 00189 void HtmlObject_SetConfiguredWidth(HTML_OBJECT *o, int i) { 00190 assert(o); 00191 assert(o->refCount); 00192 o->configuredWidth=i; 00193 } 00194 00195 00196 00197 int HtmlObject_GetConfiguredHeight(const HTML_OBJECT *o) { 00198 assert(o); 00199 assert(o->refCount); 00200 return o->configuredHeight; 00201 } 00202 00203 00204 00205 void HtmlObject_SetConfiguredHeight(HTML_OBJECT *o, int i) { 00206 assert(o); 00207 assert(o->refCount); 00208 o->configuredHeight=i; 00209 } 00210 00211 00212 00213 const char *HtmlObject_GetText(const HTML_OBJECT *o) { 00214 assert(o); 00215 assert(o->refCount); 00216 return o->text; 00217 } 00218 00219 00220 00221 void HtmlObject_SetText(HTML_OBJECT *o, const char *s) { 00222 assert(o); 00223 assert(o->refCount); 00224 free(o->text); 00225 if (s) o->text=strdup(s); 00226 else o->text=NULL; 00227 } 00228 00229 00230 00231 uint32_t HtmlObject_GetFlags(const HTML_OBJECT *o) { 00232 assert(o); 00233 assert(o->refCount); 00234 00235 return o->flags; 00236 } 00237 00238 00239 00240 void HtmlObject_SetFlags(HTML_OBJECT *o, uint32_t fl) { 00241 assert(o); 00242 assert(o->refCount); 00243 00244 o->flags=fl; 00245 } 00246 00247 00248 00249 void HtmlObject_AddFlags(HTML_OBJECT *o, uint32_t fl) { 00250 assert(o); 00251 assert(o->refCount); 00252 00253 o->flags|=fl; 00254 } 00255 00256 00257 00258 void HtmlObject_SubFlags(HTML_OBJECT *o, uint32_t fl) { 00259 assert(o); 00260 assert(o->refCount); 00261 00262 o->flags&=~fl; 00263 } 00264 00265 00266 00267 int HtmlObject_Layout(HTML_OBJECT *o) { 00268 assert(o); 00269 assert(o->refCount); 00270 if (o->layoutFn) 00271 return o->layoutFn(o); 00272 else { 00273 o->width=0; 00274 o->height=0; 00275 return 0; 00276 } 00277 } 00278 00279 00280 00281 HTML_OBJECT_LAYOUT_FN HtmlObject_SetLayoutFn(HTML_OBJECT *o, 00282 HTML_OBJECT_LAYOUT_FN fn) { 00283 HTML_OBJECT_LAYOUT_FN of; 00284 00285 of=o->layoutFn; 00286 o->layoutFn=fn; 00287 return of; 00288 } 00289 00290 00291