]> git.saurik.com Git - wxWidgets.git/blob - include/wx/html/htmltag.h
Some wxUniv compile fixes
[wxWidgets.git] / include / wx / html / htmltag.h
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 #if wxUSE_HTML
20
21 //-----------------------------------------------------------------------------
22 // wxHtmlTagsCache
23 // - internal wxHTML class, do not use!
24 //-----------------------------------------------------------------------------
25
26 struct wxHtmlCacheItem;
27
28 class WXDLLEXPORT wxHtmlTagsCache : public wxObject
29 {
30 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache)
31
32 private:
33 wxHtmlCacheItem *m_Cache;
34 int m_CacheSize;
35 int m_CachePos;
36
37 public:
38 wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;}
39 wxHtmlTagsCache(const wxString& source);
40 ~wxHtmlTagsCache() {free(m_Cache);}
41
42 // Finds parameters for tag starting at at and fills the variables
43 void QueryTag(int at, int* end1, int* end2);
44 };
45
46
47 //--------------------------------------------------------------------------------
48 // wxHtmlTag
49 // This represents single tag. It is used as internal structure
50 // by wxHtmlParser.
51 //--------------------------------------------------------------------------------
52
53 class WXDLLEXPORT wxHtmlTag : public wxObject
54 {
55 DECLARE_CLASS(wxHtmlTag)
56
57 public:
58 // constructs wxHtmlTag object based on HTML tag.
59 // The tag begins (with '<' character) at position pos in source
60 // end_pos is position where parsing ends (usually end of document)
61 wxHtmlTag(const wxString& source, int pos, int end_pos, wxHtmlTagsCache* cache);
62
63 // Returns tag's name in uppercase.
64 inline wxString GetName() const {return m_Name;}
65
66 // Returns TRUE if the tag has given parameter. Parameter
67 // should always be in uppercase.
68 // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE
69 bool HasParam(const wxString& par) const;
70
71 // Returns value of the param. Value is in uppercase unless it is
72 // enclosed with "
73 // Example : <P align=right> GetParam("ALIGN") returns (RIGHT)
74 // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg)
75 // (or ("WhaT.jpg") if with_commas == TRUE)
76 wxString GetParam(const wxString& par, bool with_commas = FALSE) const;
77
78 // Scans param like scanf() functions family do.
79 // Example : ScanParam("COLOR", "\"#%X\"", &clr);
80 // This is always with with_commas=FALSE
81 // Returns number of scanned values
82 // (like sscanf() does)
83 // NOTE: unlike scanf family, this function only accepts
84 // *one* parameter !
85 int ScanParam(const wxString& par, wxChar *format, void *param) const;
86
87 // Returns string containing all params.
88 inline const wxString& GetAllParams() const {return m_Params;}
89
90 // return TRUE if this is ending tag (</something>) or FALSE
91 // if it isn't (<something>)
92 inline bool IsEnding() const {return m_Ending;}
93
94 // return TRUE if this is ending tag (</something>) or FALSE
95 // if it isn't (<something>)
96 inline bool HasEnding() const {return m_End1 >= 0;}
97
98 // returns beginning position of _internal_ block of text
99 // See explanation (returned value is marked with *):
100 // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla
101 inline int GetBeginPos() const {return m_Begin;}
102 // returns ending position of _internal_ block of text.
103 // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla
104 inline int GetEndPos1() const {return m_End1;}
105 // returns end position 2 :
106 // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla
107 inline int GetEndPos2() const {return m_End2;}
108
109 private:
110 wxString m_Name, m_Params;
111 int m_Begin, m_End1, m_End2;
112 bool m_Ending;
113 };
114
115
116
117
118
119 #endif
120
121 #endif // _WX_HTMLTAG_H_
122