ubit
uhtml.hpp
1 /************************************************************************
2  *
3  * uhtml.hpp: HTML parser and renderer
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uhtml_hpp_
18 #define _uhtml_hpp_
19 #include <ubit/udefs.hpp>
20 #include <ubit/uxmlgrammar.hpp>
21 #include <ubit/uxmlparser.hpp>
22 
23 namespace ubit {
24 
27  class UHtmlGrammar : public UXmlGrammar {
28  public:
29  UHtmlGrammar();
30  };
31 
32  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
40  class UHtmlParser : public UXmlParser {
41  public:
42  UHtmlParser();
43  };
44 
45  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
48  struct UHtmlAttribute : public UAttr {
49  UCLASSDEF("uhtmlattribute", UHtmlAttribute, null)
50 
51  virtual void setValue(const UStr& val) {setValueImpl(pvalue, val);}
52  virtual bool getValue(UStr& val) const {return getValueImpl(pvalue, val);}
53 
54  static void setValueImpl(uptr<UStr>& pvalue, const UStr& value);
55  static bool getValueImpl(const uptr<UStr>& pvalue, UStr& value);
56 
57  uptr<UStr> pvalue;
58  };
59 
60  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61 
62  struct UHtmlStyle : public UAttrList {
63  UCLASSDEF("style", UHtmlStyle, new UHtmlStyle)
64  void initNode(UDoc* doc, UElem* parent);
65  void setValue(const UStr& val) {UHtmlAttribute::setValueImpl(pvalue, val);}
66  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
67  private:
68  uptr<UStr> pvalue;
69  };
70 
71  struct UHtmlClass : public UHtmlAttribute {
72  UCLASSDEF("class", UHtmlClass, new UHtmlClass)
73  void initNode(UDoc* doc, UElem* parent);
74  };
75 
76  struct UHtmlId : public UHtmlAttribute {
77  UCLASSDEF("id", UHtmlId, new UHtmlId)
78  void initNode(UDoc* doc, UElem* parent);
79  };
80 
81  struct UHtmlRel : public UHtmlAttribute {
82  UCLASSDEF("rel", UHtmlRel, new UHtmlRel)
83  };
84 
85  struct UHtmlType : public UHtmlAttribute {
86  UCLASSDEF("type", UHtmlType, new UHtmlType)
87  };
88 
89  struct UHtmlAlt : public UHtmlAttribute {
90  UCLASSDEF("alt", UHtmlAlt, new UHtmlAlt)
91  };
92 
93  struct UHtmlName : public UHtmlAttribute {
94  UCLASSDEF("name", UHtmlName, new UHtmlName)
95  };
96 
97  struct UHtmlSrc : public UHtmlAttribute {
98  UCLASSDEF("src", UHtmlSrc, new UHtmlSrc)
99  };
100 
101  struct UHtmlHref : public UHtmlAttribute {
102  UCLASSDEF("href", UHtmlHref, new UHtmlHref)
103  };
104 
105  struct UHtmlColor : public UColor {
106  UCLASSDEF("color", UHtmlColor, new UHtmlColor)
107  void setValue(const UStr& value);
108  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
109  private:
110  uptr<UStr> pvalue;
111  };
112 
113  struct UHtmlBgcolor : public UBackground {
114  UCLASSDEF("bgcolor", UHtmlBgcolor, new UHtmlBgcolor)
115  void setValue(const UStr&);
116  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
117  private:
118  uptr<UStr> pvalue;
119  };
120 
121  struct UHtmlBorder : public UBorder {
122  UCLASSDEF("border", UHtmlBorder, new UHtmlBorder)
123  void setValue(const UStr& v);
124  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
125  private:
126  uptr<UStr> pvalue;
127  };
128 
129  struct UHtmlFontFace : public UFont {
130  UCLASSDEF("face", UHtmlFontFace, new UHtmlFontFace)
131  void setValue(const UStr&);
132  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
133  private:
134  uptr<UStr> pvalue;
135  };
136 
137  struct UHtmlFontSize : public UFont {
138  UCLASSDEF("size", UHtmlFontSize, new UHtmlFontSize)
139  void setValue(const UStr&);
140  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
141  private:
142  uptr<UStr> pvalue;
143  };
144 
145 
146  struct UHtmlUWidth : public UHtmlAttribute {
147  UCLASSDEF("width", UHtmlUWidth, new UHtmlUWidth)
148  //void setValue(const UStr&);
149  //bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue,val);}
150  private:
151  void initNode(UDoc*, UElem* parent);
152  };
153 
154  struct UHtmlHeight : public UHtmlAttribute {
155  UCLASSDEF("height", UHtmlHeight, new UHtmlHeight)
156  //void setValue(const UStr&);
157  //bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue,val);}
158  private:
159  void initNode(UDoc*, UElem* parent);
160  };
161 
162  struct UHtmlAlign : public UHalign {
163  UCLASSDEF("align", UHtmlAlign, new UHtmlAlign)
164  void setValue(const UStr&);
165  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
166  private:
167  uptr<UStr> pvalue;
168  };
169 
170  struct UHtmlValign : public UValign {
171  UCLASSDEF("valign", UHtmlValign, new UHtmlValign)
172  void setValue(const UStr&);
173  bool getValue(UStr& val) const {return UHtmlAttribute::getValueImpl(pvalue, val);}
174  private:
175  uptr<UStr> pvalue;
176  };
177 
178  struct UHtmlColspan : public UHtmlAttribute {
179  UCLASSDEF("colspan", UHtmlColspan, new UHtmlColspan)
180  void initNode(UDoc* doc, UElem* parent);
181  void setValue(const UStr&);
182  };
183 
184  struct UHtmlRowspan : public UHtmlAttribute {
185  UCLASSDEF("rowspan", UHtmlRowspan, new UHtmlRowspan)
186  void initNode(UDoc* doc, UElem* parent);
187  void setValue(const UStr&);
188  };
189 
191  UCLASSDEF("cellspacing", UHtmlCellspacing, new UHtmlCellspacing)
192  void setValue(const UStr&);
193  };
194 
196  UCLASSDEF("cellpadding", UHtmlCellpadding, new UHtmlCellpadding)
197  void setValue(const UStr&);
198  };
199 
200  struct UHtmlNowrap : public UHtmlAttribute {
201  UCLASSDEF("nowrap", UHtmlNowrap, new UHtmlNowrap)
202  void setValue(const UStr&);
203  };
204 
205 }
206 #endif
207 
208 
209 
210 
Base class for attributes.
Definition: uattr.hpp:97
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:124
Definition: uhtml.hpp:162
Definition: uhtml.hpp:178
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:116
HTML Parser.
Definition: uhtml.hpp:40
Definition: uhtml.hpp:129
Box vertical layout.
Definition: uboxgeom.hpp:480
XML parser.
Definition: uxmlparser.hpp:30
Definition: uhtml.hpp:200
Definition: uhtml.hpp:113
Widget background.
Definition: ubackground.hpp:30
Definition: uhtml.hpp:85
Definition: uhtml.hpp:71
virtual bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:52
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:165
HTML Grammar.
Definition: uhtml.hpp:27
Definition: uhtml.hpp:97
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
Definition: uhtml.hpp:89
Definition: uhtml.hpp:170
Definition: uhtml.hpp:137
Definition: uhtml.hpp:105
Definition: uhtml.hpp:190
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:140
Attribute list.
Definition: uattr.hpp:167
Definition: uhtml.hpp:146
Definition: uhtml.hpp:121
Definition: uhtml.hpp:184
Definition: uhtml.hpp:62
Generic Document.
Definition: udoc.hpp:122
lightweight general purpose container.
Definition: uelem.hpp:44
Definition: uhtml.hpp:93
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:132
Definition: uhtml.hpp:81
XML Grammar.
Definition: uxmlgrammar.hpp:27
Definition: uhtml.hpp:101
UBox Border.
Definition: uborder.hpp:27
Box horizontal layout.
Definition: uboxgeom.hpp:412
Font of a UElem or UBox container.
Definition: ufont.hpp:30
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:108
Definition: uhardfont.hpp:31
void setValue(const UStr &val)
changes the value of this attribute does nothing if not applicable for a given subclass.
Definition: uhtml.hpp:65
Definition: uhtml.hpp:154
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:66
Definition: uhtml.hpp:76
bool getValue(UStr &val) const
gets the value of this attribute.
Definition: uhtml.hpp:173
HTML Attribute.
Definition: uhtml.hpp:48
Definition: uhtml.hpp:195
Ubit String.
Definition: ustr.hpp:72