]>
Commit | Line | Data |
---|---|---|
5526e819 VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmltag.h | |
3 | // Purpose: wxHtmlTag class (represents single tag) | |
4 | // Author: Vaclav Slavik | |
69941f05 | 5 | // RCS-ID: $Id$ |
5526e819 VS |
6 | // Copyright: (c) 1999 Vaclav Slavik |
7 | // Licence: wxWindows Licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | ||
69941f05 VS |
11 | #ifndef _WX_HTMLTAG_H_ |
12 | #define _WX_HTMLTAG_H_ | |
5526e819 VS |
13 | |
14 | #ifdef __GNUG__ | |
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 VZ |
22 | #include "wx/object.h" |
23 | ||
24 | class WXDLLEXPORT wxColour; | |
8bd72d90 VS |
25 | class WXDLLEXPORT wxHtmlEntitiesParser; |
26 | ||
97494971 | 27 | //----------------------------------------------------------------------------- |
5526e819 | 28 | // wxHtmlTagsCache |
97494971 VS |
29 | // - internal wxHTML class, do not use! |
30 | //----------------------------------------------------------------------------- | |
5526e819 | 31 | |
97494971 | 32 | struct wxHtmlCacheItem; |
5526e819 | 33 | |
c3952f65 | 34 | class WXDLLEXPORT wxHtmlTagsCache : public wxObject |
5526e819 VS |
35 | { |
36 | DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache) | |
37 | ||
97494971 VS |
38 | private: |
39 | wxHtmlCacheItem *m_Cache; | |
40 | int m_CacheSize; | |
41 | int m_CachePos; | |
5526e819 | 42 | |
97494971 VS |
43 | public: |
44 | wxHtmlTagsCache() : wxObject() {m_CacheSize = 0; m_Cache = NULL;} | |
45 | wxHtmlTagsCache(const wxString& source); | |
46 | ~wxHtmlTagsCache() {free(m_Cache);} | |
5526e819 | 47 | |
97494971 VS |
48 | // Finds parameters for tag starting at at and fills the variables |
49 | void QueryTag(int at, int* end1, int* end2); | |
5526e819 VS |
50 | }; |
51 | ||
52 | ||
5526e819 VS |
53 | //-------------------------------------------------------------------------------- |
54 | // wxHtmlTag | |
55 | // This represents single tag. It is used as internal structure | |
56 | // by wxHtmlParser. | |
57 | //-------------------------------------------------------------------------------- | |
58 | ||
59 | class WXDLLEXPORT wxHtmlTag : public wxObject | |
60 | { | |
61 | DECLARE_CLASS(wxHtmlTag) | |
62 | ||
97494971 VS |
63 | public: |
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) | |
04dbb646 | 67 | wxHtmlTag(const wxString& source, int pos, int end_pos, |
8bd72d90 VS |
68 | wxHtmlTagsCache *cache, |
69 | wxHtmlEntitiesParser *entParser = NULL); | |
97494971 VS |
70 | |
71 | // Returns tag's name in uppercase. | |
72 | inline wxString GetName() const {return m_Name;} | |
73 | ||
74 | // Returns TRUE if the tag has given parameter. Parameter | |
75 | // should always be in uppercase. | |
76 | // Example : <IMG SRC="test.jpg"> HasParam("SRC") returns TRUE | |
77 | bool HasParam(const wxString& par) const; | |
78 | ||
79 | // Returns value of the param. Value is in uppercase unless it is | |
80 | // enclosed with " | |
81 | // Example : <P align=right> GetParam("ALIGN") returns (RIGHT) | |
82 | // <P IMG SRC="WhaT.jpg"> GetParam("SRC") returns (WhaT.jpg) | |
83 | // (or ("WhaT.jpg") if with_commas == TRUE) | |
84 | wxString GetParam(const wxString& par, bool with_commas = FALSE) const; | |
85 | ||
04dbb646 | 86 | // Convenience functions: |
8bd72d90 VS |
87 | bool GetParamAsColour(const wxString& par, wxColour *clr) const; |
88 | bool GetParamAsInt(const wxString& par, int *clr) const; | |
89 | ||
90 | // Scans param like scanf() functions family does. | |
97494971 VS |
91 | // Example : ScanParam("COLOR", "\"#%X\"", &clr); |
92 | // This is always with with_commas=FALSE | |
93 | // Returns number of scanned values | |
94 | // (like sscanf() does) | |
95 | // NOTE: unlike scanf family, this function only accepts | |
96 | // *one* parameter ! | |
97 | int ScanParam(const wxString& par, wxChar *format, void *param) const; | |
98 | ||
99 | // Returns string containing all params. | |
8bd72d90 | 100 | wxString GetAllParams() const; |
97494971 VS |
101 | |
102 | // return TRUE if this is ending tag (</something>) or FALSE | |
103 | // if it isn't (<something>) | |
104 | inline bool IsEnding() const {return m_Ending;} | |
105 | ||
106 | // return TRUE if this is ending tag (</something>) or FALSE | |
107 | // if it isn't (<something>) | |
108 | inline bool HasEnding() const {return m_End1 >= 0;} | |
109 | ||
110 | // returns beginning position of _internal_ block of text | |
111 | // See explanation (returned value is marked with *): | |
112 | // bla bla bla <MYTAG>* bla bla intenal text</MYTAG> bla bla | |
113 | inline int GetBeginPos() const {return m_Begin;} | |
114 | // returns ending position of _internal_ block of text. | |
115 | // bla bla bla <MYTAG> bla bla intenal text*</MYTAG> bla bla | |
116 | inline int GetEndPos1() const {return m_End1;} | |
117 | // returns end position 2 : | |
118 | // bla bla bla <MYTAG> bla bla internal text</MYTAG>* bla bla | |
119 | inline int GetEndPos2() const {return m_End2;} | |
120 | ||
121 | private: | |
8bd72d90 | 122 | wxString m_Name; |
97494971 VS |
123 | int m_Begin, m_End1, m_End2; |
124 | bool m_Ending; | |
8bd72d90 | 125 | wxArrayString m_ParamNames, m_ParamValues; |
69941f05 | 126 | }; |
5526e819 VS |
127 | |
128 | ||
129 | ||
130 | ||
5526e819 VS |
131 | |
132 | #endif | |
69941f05 VS |
133 | |
134 | #endif // _WX_HTMLTAG_H_ | |
135 |