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