1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHtmlTag class (represents single tag)
4 // Author: Vaclav Slavik
6 // Copyright: (c) 1999 Vaclav Slavik
7 // Licence: wxWindows Licence
8 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_HTMLTAG_H_
12 #define _WX_HTMLTAG_H_
15 #pragma interface "htmltag.h"
22 #include "wx/object.h"
24 class WXDLLEXPORT wxColour
;
25 class WXDLLEXPORT wxHtmlEntitiesParser
;
27 //-----------------------------------------------------------------------------
29 // - internal wxHTML class, do not use!
30 //-----------------------------------------------------------------------------
32 struct wxHtmlCacheItem
;
34 class WXDLLEXPORT wxHtmlTagsCache
: public wxObject
36 DECLARE_DYNAMIC_CLASS(wxHtmlTagsCache
)
39 wxHtmlCacheItem
*m_Cache
;
44 wxHtmlTagsCache() : wxObject() {m_CacheSize
= 0; m_Cache
= NULL
;}
45 wxHtmlTagsCache(const wxString
& source
);
46 ~wxHtmlTagsCache() {free(m_Cache
);}
48 // Finds parameters for tag starting at at and fills the variables
49 void QueryTag(int at
, int* end1
, int* end2
);
53 //--------------------------------------------------------------------------------
55 // This represents single tag. It is used as internal structure
57 //--------------------------------------------------------------------------------
59 class WXDLLEXPORT wxHtmlTag
: public wxObject
61 DECLARE_CLASS(wxHtmlTag
)
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(const wxString
& source
, int pos
, int end_pos
,
68 wxHtmlTagsCache
*cache
,
69 wxHtmlEntitiesParser
*entParser
= NULL
);
71 // Returns tag's name in uppercase.
72 inline wxString
GetName() const {return m_Name
;}
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;
79 // Returns value of the param. Value is in uppercase unless it is
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;
86 // Convenience functions:
87 bool GetParamAsColour(const wxString
& par
, wxColour
*clr
) const;
88 bool GetParamAsInt(const wxString
& par
, int *clr
) const;
90 // Scans param like scanf() functions family does.
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
97 int ScanParam(const wxString
& par
, wxChar
*format
, void *param
) const;
99 // Returns string containing all params.
100 wxString
GetAllParams() const;
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
;}
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;}
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
;}
123 int m_Begin
, m_End1
, m_End2
;
125 wxArrayString m_ParamNames
, m_ParamValues
;
134 #endif // _WX_HTMLTAG_H_