]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/htparser.tex
fixed bug in PS clipping (non-virtual SetClippingRegion was overloaded)
[wxWidgets.git] / docs / latex / wx / htparser.tex
CommitLineData
704a4b75
VS
1%
2% automatically generated by HelpGen from
3% htmlparser.tex at 14/Mar/99 20:13:37
4%
5
704a4b75
VS
6\section{\class{wxHtmlParser}}\label{wxhtmlparser}
7
22d6efa8 8This class handles the {\bf generic} parsing of HTML document: it scans
704a4b75
VS
9the document and divide it into blocks of tags (where one block
10consists of begining and ending tag and of text between these
22d6efa8 11two tags).
704a4b75
VS
12
13It is independent from wxHtmlWindow and can be used as stand-alone parser
14(Julian Smart's idea of speech-only HTML viewer or wget-like utility -
3660fc40 15see InetGet sample for example).
704a4b75
VS
16
17It uses system of tag handlers to parse the HTML document. Tag handlers
3660fc40 18are not staticaly shared by all instances but are created for each
704a4b75
VS
19wxHtmlParser instance. The reason is that the handler may contain
20document-specific temporary data used during parsing (e.g. complicated
22d6efa8 21structures like tables).
704a4b75 22
22d6efa8 23Typically the user calls only the \helpref{Parse}{wxhtmlparserparse} method.
704a4b75
VS
24
25\wxheading{Derived from}
26
27wxObject
28
29\wxheading{See also}
30
31\helpref{Cells Overview}{cells},
32\helpref{Tag Handlers Overview}{handlers},
33\helpref{wxHtmlTag}{wxhtmltag}
34
35\latexignore{\rtfignore{\wxheading{Members}}}
36
704a4b75
VS
37\membersection{wxHtmlParser::wxHtmlParser}\label{wxhtmlparserwxhtmlparser}
38
39\func{}{wxHtmlParser}{\void}
40
3660fc40 41Constructor.
704a4b75 42
704a4b75
VS
43\membersection{wxHtmlParser::SetFS}\label{wxhtmlparsersetfs}
44
45\func{void}{SetFS}{\param{wxFileSystem }{*fs}}
46
47Sets the virtual file system that will be used to request additional
48files. (For example {\tt <IMG>} tag handler requests wxFSFile with the
49image data.)
50
51\membersection{wxHtmlParser::GetFS}\label{wxhtmlparsergetfs}
52
53\constfunc{wxFileSystem*}{GetFS}{\void}
54
55Returns pointer to the file system. Because each tag handler has
56reference to it's parent parser it can easily request the file by
57calling
58
59\begin{verbatim}
60wxFSFile *f = m_Parser -> GetFS() -> OpenFile("image.jpg");
61\end{verbatim}
62
704a4b75
VS
63\membersection{wxHtmlParser::Parse}\label{wxhtmlparserparse}
64
65\func{wxObject*}{Parse}{\param{const wxString\& }{source}}
66
67Proceeds parsing of the document. This is end-user method. You can simply
68call it when you need to obtain parsed output (which is parser-specific)
69
70The method does these things:
71
72\begin{enumerate}
73\item calls \helpref{InitParser(source)}{wxhtmlparserinitparser}
74\item calls \helpref{DoParsing}{wxhtmlparserdoparsing}
75\item calls \helpref{GetProduct}{wxhtmlparsergetproduct}
76\item calls \helpref{DoneParser}{wxhtmlparserdoneparser}
77\item returns value returned by GetProduct
78\end{enumerate}
79
80You shouldn't use InitParser, DoParsing, GetProduct or DoneParser directly.
81
82\membersection{wxHtmlParser::InitParser}\label{wxhtmlparserinitparser}
83
84\func{virtual void}{InitParser}{\param{const wxString\& }{source}}
85
86Setups the parser for parsing the {\it source} string. (Should be overriden
87in derived class)
88
704a4b75
VS
89\membersection{wxHtmlParser::DoneParser}\label{wxhtmlparserdoneparser}
90
91\func{virtual void}{DoneParser}{\void}
92
93This must be called after DoParsing().
94
704a4b75
VS
95\membersection{wxHtmlParser::DoParsing}\label{wxhtmlparserdoparsing}
96
97\func{void}{DoParsing}{\param{int }{begin\_pos}, \param{int }{end\_pos}}
98
99\func{void}{DoParsing}{\void}
100
101Parses the m\_Source from begin\_pos to end\_pos-1.
102(in noparams version it parses whole m\_Source)
103
104\membersection{wxHtmlParser::GetProduct}\label{wxhtmlparsergetproduct}
105
106\func{virtual wxObject*}{GetProduct}{\void}
107
3660fc40
RD
108Returns product of parsing. Returned value is result of parsing
109of the document. The type of this result depends on internal
704a4b75
VS
110representation in derived parser (but it must be derived from wxObject!).
111
112See wxHtmlWinParser for details.
113
704a4b75
VS
114\membersection{wxHtmlParser::AddTagHandler}\label{wxhtmlparseraddtaghandler}
115
116\func{virtual void}{AddTagHandler}{\param{wxHtmlTagHandler }{*handler}}
117
118Adds handler to the internal list (\& hash table) of handlers. This
119method should not be called directly by user but rather by derived class'
120constructor.
121
22d6efa8
JS
122This adds the handler to this {\bf instance} of wxHtmlParser, not to
123all objects of this class! (Static front-end to AddTagHandler is provided
124by wxHtmlWinParser).
704a4b75
VS
125
126All handlers are deleted on object deletion.
127
128\membersection{wxHtmlParser::GetSource}\label{wxhtmlparsergetsource}
129
130\func{wxString*}{GetSource}{\void}
131
132Returns pointer to the source being parsed.
133
704a4b75
VS
134\membersection{wxHtmlParser::GetTempData}\label{wxhtmlparsergettempdata}
135
136\func{virtual wxList*}{GetTempData}{\void}
137
138This method returns list of wxObjects that represents
22d6efa8
JS
139all data allocated by the parser. These can't be freed
140by the destructor because they must be valid as long as
704a4b75
VS
141GetProduct's return value is valid - the caller must
142explicitly call
143
144\begin{verbatim}
145delete (MyParser -> GetTempData());
146\end{verbatim}
147
22d6efa8 148to free the memory (this method always sets the list to delete its contents).
704a4b75
VS
149
150\wxheading{Example}
151
22d6efa8
JS
152Why is this neccessary? Imagine wxHtmlWinParser: when handling
153a FONT tag it creates some fonts. These fonts are then used by wxHtmlWindow
154to display the text. But the wxHtmWinParser object is needed only when parsing
704a4b75 155the document - it may be deleted then. But fonts CAN'T be deleted - they
3660fc40 156must exist as long as the window is displaying text.
704a4b75
VS
157
158GetTempData() solves the problem.
159
160\membersection{wxHtmlParser::AddText}\label{wxhtmlparseraddword}
161
162\func{virtual void}{AddWord}{\param{const char* }{txt}}
163
164Must be overwriten in derived class.
165
166This method is called by \helpref{DoParsing}{wxhtmlparserdoparsing}
3660fc40 167each time a part of text is parsed. {\it txt} is NOT only one word, it is
704a4b75 168substring of input. It is not formatted or preprocessed (so white spaces are
22d6efa8 169unmodified).
704a4b75
VS
170
171\membersection{wxHtmlParser::AddTag}\label{wxhtmlparseraddtag}
172
3660fc40 173\func{void}{AddTag}{\param{const wxHtmlTag\& }{tag}}
704a4b75
VS
174
175This may (and may not) be overwriten in derived class.
176
22d6efa8 177This method is called each time new tag is about to be added.
704a4b75
VS
178{\it tag} contains information about the tag. (See \helpref{wxHtmlTag}{wxhtmltag}
179for details.)
180
22d6efa8 181Default (wxHtmlParser) behaviour is this:
704a4b75
VS
182First it finds a handler capable of handling this tag and then it calls
183handler's HandleTag method.
22d6efa8 184