gwenhywfar  4.8.0beta
g_unorderedlist.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_unorderedlist_p.h"
18 #include "g_box_l.h"
19 #include "g_generic_l.h"
20 #include "htmlctx_l.h"
21 #include "o_box_l.h"
22 #include "o_grid_l.h"
23 #include "o_gridentry_l.h"
24 #include "o_word_l.h"
25 
26 #include <gwenhywfar/debug.h>
27 
28 
29 GWEN_INHERIT(HTML_GROUP, GROUP_UNORDEREDLIST)
30 
31 
32 
33 HTML_GROUP *HtmlGroup_UnorderedList_new(const char *groupName,
34  HTML_GROUP *parent,
35  GWEN_XML_CONTEXT *ctx) {
36  HTML_GROUP *g;
37  GROUP_UNORDEREDLIST *xg;
38 
39  /* create base group */
40  g=HtmlGroup_Generic_new(groupName, parent, ctx);
41  assert(g);
42 
43  /* inherit */
44  GWEN_NEW_OBJECT(GROUP_UNORDEREDLIST, xg);
45  GWEN_INHERIT_SETDATA(HTML_GROUP, GROUP_UNORDEREDLIST, g, xg,
47 
48  /* set virtual functions */
50 
51  return g;
52 }
53 
54 
55 
57  GROUP_UNORDEREDLIST *xg;
58 
59  xg=(GROUP_UNORDEREDLIST*) p;
60  GWEN_FREE_OBJECT(xg);
61 }
62 
63 
64 
65 int HtmlGroup_UnorderedList_StartTag(HTML_GROUP *g, const char *tagName) {
66  GROUP_UNORDEREDLIST *xg;
67  HTML_GROUP *gNew=NULL;
68  GWEN_XML_CONTEXT *ctx;
69 
70  assert(g);
71  xg=GWEN_INHERIT_GETDATA(HTML_GROUP, GROUP_UNORDEREDLIST, g);
72  assert(xg);
73 
75 
76  if (strcasecmp(tagName, "li")==0) {
77  HTML_OBJECT *o;
78  HTML_OBJECT *oGrid;
79 
80  /* first column in the grid is "-" */
81  oGrid=HtmlObject_GridEntry_new(ctx);
83  HtmlObject_GridEntry_SetRow(oGrid, xg->row);
85  HtmlObject_Tree_AddChild(HtmlGroup_GetObject(g), oGrid);
86 
87  o=HtmlObject_Word_new(ctx, "-");
89  HtmlObject_Tree_AddChild(oGrid, o);
90 
91  /* Create new parser group with new properties but use the same object */
92  gNew=HtmlGroup_Box_new(tagName, g, ctx);
95  assert(o);
97  int i;
98 
100  HtmlObject_Grid_SetRows(o, ++i);
101  }
102 
103  /* second column is the content of li */
106  HtmlObject_GridEntry_SetRow(oGrid, xg->row);
108  HtmlObject_Tree_AddChild(oGrid, o);
109 
110  HtmlGroup_SetObject(gNew, o);
111  xg->row++;
112  }
113  else {
115  "Unexpected group [%s]", tagName);
116  return GWEN_ERROR_BAD_DATA;
117  }
118 
119  if (gNew) {
120  HtmlCtx_SetCurrentGroup(ctx, gNew);
122  }
123 
124  return 0;
125 }
126 
127 
128