]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/htmltag.h
added default values for SetSizeHints() arguments, as in wxMSW
[wxWidgets.git] / include / wx / html / htmltag.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: htmltag.h
3 // Purpose: wxHtmlTag class (represents single tag)
4 // Author: Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef _WX_HTMLTAG_H_
12 #define _WX_HTMLTAG_H_
13
14 #ifdef __GNUG__
15 #pragma interface "htmltag.h"
16 #endif
17
18 #include "wx/defs.h"
19 #if wxUSE_HTML
20
21 class WXDLLEXPORT wxHtmlEntitiesParser;
22
23 //-----------------------------------------------------------------------------
24 // wxHtmlTagsCache
25 // - internal wxHTML class, do not use!
26 //-----------------------------------------------------------------------------
27
28 struct wxHtmlCacheItem;
29
30 class WXDLLEXPORT wxHtmlTagsCache : public wxObject
31 {
32 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
33
34 private:
35 wxHtmlCacheItem *m_Cache;
36 int m_CacheSize;
37 int m_CachePos;
38
39 public:
40 wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
41 wxHtmlTagsCache(const wxString& source);
42 ~wxHtmlTagsCache() {free(m_Cache);}
43
44 // Finds parameters for tag starting at at and fills the variables
45 void QueryTag(int at, int* end1, int* end2);
46 };
47
48
49 //--------------------------------------------------------------------------------
50 // wxHtmlTag
51 // This represents single tag. It is used as internal structure
52 // by wxHtmlParser.
53 //--------------------------------------------------------------------------------
54
55 class WXDLLEXPORT wxHtmlTag : public wxObject
56 {
57 DECLARE_CLASS(wxHtmlTag)
58
59 public:
60 // constructs wxHtmlTag object based on HTML tag.
61 // The tag begins (with '<' character) at position pos in source
62 // end_pos is position where parsing ends (usually end of document)
63 wxHtmlTag(const wxString& source, int pos, int end_pos,
64 wxHtmlTagsCache *cache,
65 wxHtmlEntitiesParser *entParser = NULL);
66
67 // Returns tag's name in uppercase.
68 inline wxString GetName() const {return m_Name;}
69
70 // Returns TRUE if the tag has given parameter. Parameter
71 // should always be in uppercase.
72 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
73 bool HasParam(const wxString& par) const;
74
75 // Returns value of the param. Value is in uppercase unless it is
76 // enclosed with "
77 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
78 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
79 // (or ("WhaT.jpg") if with_commas == TRUE)
80 wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
81
82 // Convenience functions:
83 bool GetParamAsColour(const wxString& par, wxColour *clr) const;
84 bool GetParamAsInt(const wxString& par, int *clr) const;
85
86 // Scans param like scanf() functions family does.
87 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
88 // This is always with with_commas=FALSE
89 // Returns number of scanned values
90 // (like sscanf() does)
91 // NOTE: unlike scanf family, this function only accepts
92 // *one* parameter !
93 int ScanParam(const wxString& par, wxChar *format, void *param) const;
94
95 // Returns string containing all params.
96 wxString GetAllParams() const;
97
98 // return TRUE if this is ending tag (</something>) or FALSE
99 // if it isn't (<something>)
100 inline bool IsEnding() const {return m_Ending;}
101
102 // return TRUE if this is ending tag (</something>) or FALSE
103 // if it isn't (<something>)
104 inline bool HasEnding() const {return m_End1 >= 0;}
105
106 // returns beginning position of _internal_ block of text
107 // See explanation (returned value is marked with *):
108 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
109 inline int GetBeginPos() const {return m_Begin;}
110 // returns ending position of _internal_ block of text.
111 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
112 inline int GetEndPos1() const {return m_End1;}
113 // returns end position 2 :
114 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
115 inline int GetEndPos2() const {return m_End2;}
116
117 private:
118 wxString m_Name;
119 int m_Begin, m_End1, m_End2;
120 bool m_Ending;
121 wxArrayString m_ParamNames, m_ParamValues;
122 };
123
124
125
126
127
128 #endif
129
130 #endif // _WX_HTMLTAG_H_
131