]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/html/htmltag.h
compilation fixes for !USE_PCH
[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#if defined(__GNUG__) && !defined(__APPLE__)
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 DECLARE_NO_COPY_CLASS(wxHtmlTagsCache)
52};
53
54
55//--------------------------------------------------------------------------------
56// wxHtmlTag
57// This represents single tag. It is used as internal structure
58// by wxHtmlParser.
59//--------------------------------------------------------------------------------
60
61class WXDLLEXPORT wxHtmlTag : public wxObject
62{
63 DECLARE_CLASS(wxHtmlTag)
64
65protected:
66 // constructs wxHtmlTag object based on HTML tag.
67 // The tag begins (with '<' character) at position pos in source
68 // end_pos is position where parsing ends (usually end of document)
69 wxHtmlTag(wxHtmlTag *parent,
70 const wxString& source, int pos, int end_pos,
71 wxHtmlTagsCache *cache,
72 wxHtmlEntitiesParser *entParser);
73 friend class wxHtmlParser;
74public:
75 ~wxHtmlTag();
76
77 wxHtmlTag *GetParent() const {return m_Parent;}
78 wxHtmlTag *GetFirstSibling() const;
79 wxHtmlTag *GetLastSibling() const;
80 wxHtmlTag *GetChildren() const { return m_FirstChild; }
81 wxHtmlTag *GetPreviousSibling() const { return m_Prev; }
82 wxHtmlTag *GetNextSibling() const {return m_Next; }
83 // Return next tag, as if tree had been flattened
84 wxHtmlTag *GetNextTag() const;
85
86 // Returns tag's name in uppercase.
87 inline wxString GetName() const {return m_Name;}
88
89 // Returns TRUE if the tag has given parameter. Parameter
90 // should always be in uppercase.
91 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
92 bool HasParam(const wxString& par) const;
93
94 // Returns value of the param. Value is in uppercase unless it is
95 // enclosed with "
96 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
97 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
98 // (or ("WhaT.jpg") if with_commas == TRUE)
99 wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
100
101 // Convenience functions:
102 bool GetParamAsColour(const wxString& par, wxColour *clr) const;
103 bool GetParamAsInt(const wxString& par, int *clr) const;
104
105 // Scans param like scanf() functions family does.
106 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
107 // This is always with with_commas=FALSE
108 // Returns number of scanned values
109 // (like sscanf() does)
110 // NOTE: unlike scanf family, this function only accepts
111 // *one* parameter !
112 int ScanParam(const wxString& par, const wxChar *format, void *param) const;
113
114 // Returns string containing all params.
115 wxString GetAllParams() const;
116
117#if WXWIN_COMPATIBILITY_2_2
118 // return TRUE if this is ending tag (</something>) or FALSE
119 // if it isn't (<something>)
120 inline bool IsEnding() const {return FALSE;}
121#endif
122
123 // return TRUE if this there is matching ending tag
124 inline bool HasEnding() const {return m_End1 >= 0;}
125
126 // returns beginning position of _internal_ block of text
127 // See explanation (returned value is marked with *):
128 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
129 inline int GetBeginPos() const {return m_Begin;}
130 // returns ending position of _internal_ block of text.
131 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
132 inline int GetEndPos1() const {return m_End1;}
133 // returns end position 2 :
134 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
135 inline int GetEndPos2() const {return m_End2;}
136
137private:
138 wxString m_Name;
139 int m_Begin, m_End1, m_End2;
140 wxArrayString m_ParamNames, m_ParamValues;
141
142 // DOM tree relations:
143 wxHtmlTag *m_Next;
144 wxHtmlTag *m_Prev;
145 wxHtmlTag *m_FirstChild, *m_LastChild;
146 wxHtmlTag *m_Parent;
147
148 DECLARE_NO_COPY_CLASS(wxHtmlTag)
149};
150
151
152
153
154
155#endif
156
157#endif // _WX_HTMLTAG_H_
158