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