]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/html/htmltag.h
implemented (untested) work around for wxScrolledWindow painting bug
[wxWidgets.git] / include / wx / html / htmltag.h
... / ...
CommitLineData
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
24class WXDLLEXPORT wxColour;
25class WXDLLEXPORT wxHtmlEntitiesParser;
26
27//-----------------------------------------------------------------------------
28// wxHtmlTagsCache
29// - internal wxHTML class, do not use!
30//-----------------------------------------------------------------------------
31
32struct wxHtmlCacheItem;
33
34class WXDLLEXPORT wxHtmlTagsCache : public wxObject
35{
36 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
37
38private:
39 wxHtmlCacheItem *m_Cache;
40 int m_CacheSize;
41 int m_CachePos;
42
43public:
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
59class WXDLLEXPORT wxHtmlTag : public wxObject
60{
61 DECLARE_CLASS(wxHtmlTag)
62
63protected:
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(wxHtmlTag *parent,
68 const wxString& source, int pos, int end_pos,
69 wxHtmlTagsCache *cache,
70 wxHtmlEntitiesParser *entParser);
71 friend class wxHtmlParser;
72public:
73 ~wxHtmlTag();
74
75 wxHtmlTag *GetParent() const {return m_Parent;}
76 wxHtmlTag *GetFirstSibling() const;
77 wxHtmlTag *GetLastSibling() const;
78 wxHtmlTag *GetChildren() const { return m_FirstChild; }
79 wxHtmlTag *GetPreviousSibling() const { return m_Prev; }
80 wxHtmlTag *GetNextSibling() const {return m_Next; }
81 // Return next tag, as if tree had been flattened
82 wxHtmlTag *GetNextTag() const;
83
84 // Returns tag's name in uppercase.
85 inline wxString GetName() const {return m_Name;}
86
87 // Returns TRUE if the tag has given parameter. Parameter
88 // should always be in uppercase.
89 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
90 bool HasParam(const wxString& par) const;
91
92 // Returns value of the param. Value is in uppercase unless it is
93 // enclosed with "
94 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
95 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
96 // (or ("WhaT.jpg") if with_commas == TRUE)
97 wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
98
99 // Convenience functions:
100 bool GetParamAsColour(const wxString& par, wxColour *clr) const;
101 bool GetParamAsInt(const wxString& par, int *clr) const;
102
103 // Scans param like scanf() functions family does.
104 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
105 // This is always with with_commas=FALSE
106 // Returns number of scanned values
107 // (like sscanf() does)
108 // NOTE: unlike scanf family, this function only accepts
109 // *one* parameter !
110 int ScanParam(const wxString& par, wxChar *format, void *param) const;
111
112 // Returns string containing all params.
113 wxString GetAllParams() const;
114
115#if WXWIN_COMPATIBILITY_2_2
116 // return TRUE if this is ending tag (</something>) or FALSE
117 // if it isn't (<something>)
118 inline bool IsEnding() const {return FALSE;}
119#endif
120
121 // return TRUE if this there is matching ending tag
122 inline bool HasEnding() const {return m_End1 >= 0;}
123
124 // returns beginning position of _internal_ block of text
125 // See explanation (returned value is marked with *):
126 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
127 inline int GetBeginPos() const {return m_Begin;}
128 // returns ending position of _internal_ block of text.
129 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
130 inline int GetEndPos1() const {return m_End1;}
131 // returns end position 2 :
132 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
133 inline int GetEndPos2() const {return m_End2;}
134
135private:
136 wxString m_Name;
137 int m_Begin, m_End1, m_End2;
138 wxArrayString m_ParamNames, m_ParamValues;
139
140 // DOM tree relations:
141 wxHtmlTag *m_Next;
142 wxHtmlTag *m_Prev;
143 wxHtmlTag *m_FirstChild, *m_LastChild;
144 wxHtmlTag *m_Parent;
145};
146
147
148
149
150
151#endif
152
153#endif // _WX_HTMLTAG_H_
154