gwenhywfar  4.3.3
g_tablerow.c
Go to the documentation of this file.
1 /***************************************************************************
2  begin : Mon Feb 22 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 "g_tablerow_p.h"
18 #include "g_box_l.h"
19 #include "g_generic_l.h"
20 #include "htmlctx_l.h"
21 #include "o_grid_l.h"
22 #include "o_gridentry_l.h"
23 
24 #include <gwenhywfar/debug.h>
25 
26 
27 GWEN_INHERIT(HTML_GROUP, GROUP_TABLEROW)
28 
29 
30 
31 
32 HTML_GROUP *HtmlGroup_TableRow_new(const char *groupName,
33  HTML_GROUP *parent,
34  GWEN_XML_CONTEXT *ctx) {
35  HTML_GROUP *g;
36  GROUP_TABLEROW *xg;
37 
38  /* create base group */
39  g=HtmlGroup_Generic_new(groupName, parent, ctx);
40  assert(g);
41  GWEN_NEW_OBJECT(GROUP_TABLEROW, xg);
43 
44  /* set virtual functions */
46 
47  return g;
48 }
49 
50 
51 
52 void GWENHYWFAR_CB HtmlGroup_TableRow_FreeData(void *bp, void *p) {
53  GROUP_TABLEROW *xg;
54 
55  xg=(GROUP_TABLEROW*) p;
56 
57  GWEN_FREE_OBJECT(xg);
58 }
59 
60 
61 
63  GROUP_TABLEROW *xg;
64 
65  assert(g);
66  xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_TABLEROW, g);
67  assert(xg);
68 
69  return xg->columns;
70 }
71 
72 
73 
74 int HtmlGroup_TableRow_StartTag(HTML_GROUP *g, const char *tagName) {
75  GROUP_TABLEROW *xg;
76  HTML_GROUP *gNew=NULL;
77  GWEN_XML_CONTEXT *ctx;
78  GWEN_DB_NODE *dbAttribs;
79 
80  assert(g);
81  xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_TABLEROW, g);
82  assert(xg);
83 
85  dbAttribs=HtmlCtx_GetCurrentAttributes(ctx);
86 
87  if (strcasecmp(tagName, "th")==0) {
88  HTML_OBJECT *o;
89  HTML_PROPS *pr;
90  HTML_FONT *fnt;
91 
92  /* create new parser group */
93  gNew=HtmlGroup_Box_new(tagName, g, ctx);
95  fnt=HtmlProps_GetFont(pr);
96  fnt=HtmlCtx_GetFont(ctx,
100  if (fnt) {
101  HtmlProps_SetFont(pr, fnt);
102  //HtmlFont_free(fnt);
103  }
104  HtmlGroup_SetProperties(gNew, pr);
105  HtmlProps_free(pr);
106 
109  HtmlObject_GridEntry_SetColumn(o, xg->columns++);
110  HtmlObject_GridEntry_SetRow(o, xg->row);
112 
113  if (dbAttribs) {
114  const char *s;
115 
116  s=GWEN_DB_GetCharValue(dbAttribs, "align", 0, "left");
117  if (s) {
118  if (strcasecmp(s, "right")==0)
120  else if (strcasecmp(s, "center")==0)
122  }
123  }
124 
125  HtmlObject_Tree_AddChild(HtmlGroup_GetObject(g), o);
126  HtmlGroup_SetObject(gNew, o);
127  }
128  else if (strcasecmp(tagName, "td")==0) {
129  HTML_OBJECT *o;
130 
131  /* create new parser group */
132  gNew=HtmlGroup_Box_new(tagName, g, ctx);
136  HtmlObject_GridEntry_SetColumn(o, xg->columns++);
137  HtmlObject_GridEntry_SetRow(o, xg->row);
139 
140  if (dbAttribs) {
141  const char *s;
142 
143  s=GWEN_DB_GetCharValue(dbAttribs, "align", 0, "left");
144  if (s) {
145  if (strcasecmp(s, "right")==0)
147  else if (strcasecmp(s, "center")==0)
149  }
150  }
151 
152  HtmlObject_Tree_AddChild(HtmlGroup_GetObject(g), o);
153  HtmlGroup_SetObject(gNew, o);
154  }
155  else {
157  "Unexpected group [%s]", tagName);
158  return GWEN_ERROR_BAD_DATA;
159  }
160 
161  if (gNew) {
162  HtmlCtx_SetCurrentGroup(ctx, gNew);
164  }
165 
166  return 0;
167 }
168 
169 
170 
172  GROUP_TABLEROW *xg;
173 
174  assert(g);
175  xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_TABLEROW, g);
176  assert(xg);
177 
178  xg->row=row;
179 }
180 
181 
182 
183 
184 
185