]> git.saurik.com Git - wxWidgets.git/blame - include/wx/html/htmltag.h
more wxVector<T> tests
[wxWidgets.git] / include / wx / html / htmltag.h
CommitLineData
5526e819
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: htmltag.h
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
97494971 28struct wxHtmlCacheItem;
5526e819 29
6acba9a7 30class WXDLLIMPEXP_HTML wxHtmlTagsCache : public wxObject
5526e819
VS
31{
32 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
33
97494971
VS
34private:
35 wxHtmlCacheItem *m_Cache;
36 int m_CacheSize;
37 int m_CachePos;
5526e819 38
97494971
VS
39public:
40 wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
41 wxHtmlTagsCache(const wxString& source);
d3c7fc99 42 virtual ~wxHtmlTagsCache() {free(m_Cache);}
5526e819 43
97494971
VS
44 // Finds parameters for tag starting at at and fills the variables
45 void QueryTag(int at, int* end1, int* end2);
22f3361e
VZ
46
47 DECLARE_NO_COPY_CLASS(wxHtmlTagsCache)
5526e819
VS
48};
49
50
5526e819
VS
51//--------------------------------------------------------------------------------
52// wxHtmlTag
53// This represents single tag. It is used as internal structure
54// by wxHtmlParser.
55//--------------------------------------------------------------------------------
56
6acba9a7 57class WXDLLIMPEXP_HTML wxHtmlTag : public wxObject
5526e819
VS
58{
59 DECLARE_CLASS(wxHtmlTag)
60
6c62a62b 61protected:
97494971
VS
62 // constructs wxHtmlTag object based on HTML tag.
63 // The tag begins (with '<' character) at position pos in source
64 // end_pos is position where parsing ends (usually end of document)
6c62a62b
VS
65 wxHtmlTag(wxHtmlTag *parent,
66 const wxString& source, int pos, int end_pos,
8bd72d90 67 wxHtmlTagsCache *cache,
6c62a62b
VS
68 wxHtmlEntitiesParser *entParser);
69 friend class wxHtmlParser;
70public:
d3c7fc99 71 virtual ~wxHtmlTag();
6c62a62b
VS
72
73 wxHtmlTag *GetParent() const {return m_Parent;}
74 wxHtmlTag *GetFirstSibling() const;
75 wxHtmlTag *GetLastSibling() const;
76 wxHtmlTag *GetChildren() const { return m_FirstChild; }
77 wxHtmlTag *GetPreviousSibling() const { return m_Prev; }
78 wxHtmlTag *GetNextSibling() const {return m_Next; }
79 // Return next tag, as if tree had been flattened
80 wxHtmlTag *GetNextTag() const;
97494971
VS
81
82 // Returns tag's name in uppercase.
83 inline wxString GetName() const {return m_Name;}
84
6953da00 85 // Returns true if the tag has given parameter. Parameter
97494971 86 // should always be in uppercase.
6953da00 87 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns true
97494971
VS
88 bool HasParam(const wxString& par) const;
89
90 // Returns value of the param. Value is in uppercase unless it is
91 // enclosed with "
92 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
93 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
6953da00
WS
94 // (or ("WhaT.jpg") if with_commas == true)
95 wxString GetParam(const wxString& par, bool with_commas = false) const;
97494971 96
04dbb646 97 // Convenience functions:
8bd72d90
VS
98 bool GetParamAsColour(const wxString& par, wxColour *clr) const;
99 bool GetParamAsInt(const wxString& par, int *clr) const;
100
101 // Scans param like scanf() functions family does.
97494971 102 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
6953da00 103 // This is always with with_commas=false
97494971
VS
104 // Returns number of scanned values
105 // (like sscanf() does)
106 // NOTE: unlike scanf family, this function only accepts
107 // *one* parameter !
d7640339
VS
108 int ScanParam(const wxString& par, const char *format, void *param) const;
109 int ScanParam(const wxString& par, const wchar_t *format, void *param) const;
97494971
VS
110
111 // Returns string containing all params.
8bd72d90 112 wxString GetAllParams() const;
97494971 113
6953da00 114 // return true if this there is matching ending tag
97494971
VS
115 inline bool HasEnding() const {return m_End1 >= 0;}
116
117 // returns beginning position of _internal_ block of text
118 // See explanation (returned value is marked with *):
119 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
120 inline int GetBeginPos() const {return m_Begin;}
121 // returns ending position of _internal_ block of text.
122 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
123 inline int GetEndPos1() const {return m_End1;}
124 // returns end position 2 :
125 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
126 inline int GetEndPos2() const {return m_End2;}
127
128private:
8bd72d90 129 wxString m_Name;
97494971 130 int m_Begin, m_End1, m_End2;
8bd72d90 131 wxArrayString m_ParamNames, m_ParamValues;
6c62a62b
VS
132
133 // DOM tree relations:
134 wxHtmlTag *m_Next;
135 wxHtmlTag *m_Prev;
136 wxHtmlTag *m_FirstChild, *m_LastChild;
137 wxHtmlTag *m_Parent;
22f3361e
VZ
138
139 DECLARE_NO_COPY_CLASS(wxHtmlTag)
69941f05 140};
5526e819
VS
141
142
143
144
5526e819
VS
145
146#endif
69941f05
VS
147
148#endif // _WX_HTMLTAG_H_
149