]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/htmltag.h
Generate the interface file for STC from gen_iface too.
[wxWidgets.git] / include / wx / html / htmltag.h
CommitLineData
5526e819 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/html/htmltag.h
5526e819
VS
3// Purpose: wxHtmlTag class (represents single tag)
4// Author: Vaclav Slavik
69941f05 5// RCS-ID: $Id$
5526e819 6// Copyright: (c) 1999 Vaclav Slavik
65571936 7// Licence: wxWindows licence
5526e819
VS
8/////////////////////////////////////////////////////////////////////////////
9
69941f05
VS
10#ifndef _WX_HTMLTAG_H_
11#define _WX_HTMLTAG_H_
5526e819 12
5526e819 13#include "wx/defs.h"
04dbb646 14
5526e819
VS
15#if wxUSE_HTML
16
04dbb646 17#include "wx/object.h"
360b63dd 18#include "wx/arrstr.h"
04dbb646 19
b5dbe15d
VS
20class WXDLLIMPEXP_FWD_CORE wxColour;
21class WXDLLIMPEXP_FWD_HTML wxHtmlEntitiesParser;
8bd72d90 22
97494971 23//-----------------------------------------------------------------------------
5526e819 24// wxHtmlTagsCache
97494971
VS
25// - internal wxHTML class, do not use!
26//-----------------------------------------------------------------------------
5526e819 27
4fe7567d 28class wxHtmlTagsCacheData;
5526e819 29
7da48d49 30class WXDLLIMPEXP_HTML wxHtmlTagsCache
5526e819 31{
97494971 32private:
4fe7567d 33 wxHtmlTagsCacheData *m_Cache;
b1a3a964 34 int m_CachePos;
4fe7567d
VS
35
36 wxHtmlTagsCacheData& Cache() { return *m_Cache; }
5526e819 37
97494971 38public:
4fe7567d 39 wxHtmlTagsCache() {m_Cache = NULL;}
97494971 40 wxHtmlTagsCache(const wxString& source);
4fe7567d 41 virtual ~wxHtmlTagsCache();
5526e819 42
97494971 43 // Finds parameters for tag starting at at and fills the variables
b1a3a964
VS
44 void QueryTag(const wxString::const_iterator& at,
45 const wxString::const_iterator& inputEnd,
46 wxString::const_iterator *end1,
47 wxString::const_iterator *end2,
48 bool *hasEnding);
22f3361e 49
c0c133e1 50 wxDECLARE_NO_COPY_CLASS(wxHtmlTagsCache);
5526e819
VS
51};
52
53
5526e819
VS
54//--------------------------------------------------------------------------------
55// wxHtmlTag
56// This represents single tag. It is used as internal structure
57// by wxHtmlParser.
58//--------------------------------------------------------------------------------
59
7da48d49 60class WXDLLIMPEXP_HTML wxHtmlTag
5526e819 61{
6c62a62b 62protected:
97494971
VS
63 // constructs wxHtmlTag object based on HTML tag.
64 // The tag begins (with '<' character) at position pos in source
65 // end_pos is position where parsing ends (usually end of document)
6c62a62b 66 wxHtmlTag(wxHtmlTag *parent,
b1a3a964
VS
67 const wxString *source,
68 const wxString::const_iterator& pos,
69 const wxString::const_iterator& end_pos,
8bd72d90 70 wxHtmlTagsCache *cache,
6c62a62b
VS
71 wxHtmlEntitiesParser *entParser);
72 friend class wxHtmlParser;
73public:
7da48d49 74 ~wxHtmlTag();
6c62a62b
VS
75
76 wxHtmlTag *GetParent() const {return m_Parent;}
77 wxHtmlTag *GetFirstSibling() const;
78 wxHtmlTag *GetLastSibling() const;
79 wxHtmlTag *GetChildren() const { return m_FirstChild; }
80 wxHtmlTag *GetPreviousSibling() const { return m_Prev; }
81 wxHtmlTag *GetNextSibling() const {return m_Next; }
82 // Return next tag, as if tree had been flattened
83 wxHtmlTag *GetNextTag() const;
97494971
VS
84
85 // Returns tag's name in uppercase.
86 inline wxString GetName() const {return m_Name;}
87
6953da00 88 // Returns true if the tag has given parameter. Parameter
97494971 89 // should always be in uppercase.
6953da00 90 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns true
97494971
VS
91 bool HasParam(const wxString& par) const;
92
93 // Returns value of the param. Value is in uppercase unless it is
94 // enclosed with "
95 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
96 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
614f9713
VS
97 // (or ("WhaT.jpg") if with_quotes == true)
98 wxString GetParam(const wxString& par, bool with_quotes = false) const;
97494971 99
f68e16c5
VZ
100 // Return true if the string could be parsed as an HTML colour and false
101 // otherwise.
102 static bool ParseAsColour(const wxString& str, wxColour *clr);
103
04dbb646 104 // Convenience functions:
8bd72d90
VS
105 bool GetParamAsColour(const wxString& par, wxColour *clr) const;
106 bool GetParamAsInt(const wxString& par, int *clr) const;
107
108 // Scans param like scanf() functions family does.
97494971 109 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
614f9713 110 // This is always with with_quotes=false
97494971
VS
111 // Returns number of scanned values
112 // (like sscanf() does)
113 // NOTE: unlike scanf family, this function only accepts
114 // *one* parameter !
d7640339
VS
115 int ScanParam(const wxString& par, const char *format, void *param) const;
116 int ScanParam(const wxString& par, const wchar_t *format, void *param) const;
97494971
VS
117
118 // Returns string containing all params.
8bd72d90 119 wxString GetAllParams() const;
97494971 120
b1a3a964
VS
121 // return true if there is matching ending tag
122 inline bool HasEnding() const {return m_hasEnding;}
97494971 123
0e89a51a
VS
124 // returns beginning position of _internal_ block of text as iterator
125 // into parser's source string (see wxHtmlParser::GetSource())
97494971
VS
126 // See explanation (returned value is marked with *):
127 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
b1a3a964
VS
128 wxString::const_iterator GetBeginIter() const
129 { return m_Begin; }
0e89a51a
VS
130 // returns ending position of _internal_ block of text as iterator
131 // into parser's source string (see wxHtmlParser::GetSource()):
97494971 132 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
61679695 133 wxString::const_iterator GetEndIter1() const { return m_End1; }
0e89a51a
VS
134 // returns end position 2 as iterator
135 // into parser's source string (see wxHtmlParser::GetSource()):
97494971 136 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
61679695 137 wxString::const_iterator GetEndIter2() const { return m_End2; }
b1a3a964
VS
138
139#if WXWIN_COMPATIBILITY_2_8
0e89a51a 140 // use GetBeginIter(), GetEndIter1() and GetEndIter2() instead
b1a3a964
VS
141 wxDEPRECATED( inline int GetBeginPos() const );
142 wxDEPRECATED( inline int GetEndPos1() const );
143 wxDEPRECATED( inline int GetEndPos2() const );
144#endif // WXWIN_COMPATIBILITY_2_8
97494971
VS
145
146private:
8bd72d90 147 wxString m_Name;
b1a3a964
VS
148 bool m_hasEnding;
149 wxString::const_iterator m_Begin, m_End1, m_End2;
8bd72d90 150 wxArrayString m_ParamNames, m_ParamValues;
b1a3a964
VS
151#if WXWIN_COMPATIBILITY_2_8
152 wxString::const_iterator m_sourceStart;
153#endif
6c62a62b
VS
154
155 // DOM tree relations:
156 wxHtmlTag *m_Next;
157 wxHtmlTag *m_Prev;
158 wxHtmlTag *m_FirstChild, *m_LastChild;
159 wxHtmlTag *m_Parent;
22f3361e 160
c0c133e1 161 wxDECLARE_NO_COPY_CLASS(wxHtmlTag);
69941f05 162};
5526e819
VS
163
164
b1a3a964
VS
165#if WXWIN_COMPATIBILITY_2_8
166inline int wxHtmlTag::GetBeginPos() const { return m_Begin - m_sourceStart; }
167inline int wxHtmlTag::GetEndPos1() const { return m_End1 - m_sourceStart; }
168inline int wxHtmlTag::GetEndPos2() const { return m_End2 - m_sourceStart; }
169#endif // WXWIN_COMPATIBILITY_2_8
5526e819
VS
170
171
5526e819 172
b1a3a964
VS
173
174#endif // wxUSE_HTML
69941f05
VS
175
176#endif // _WX_HTMLTAG_H_
177