1999-11-06 15:39:25 +00:00
|
|
|
\section{Cells and Containers}\label{cells}
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
This article describes mechanism used by
|
1999-08-05 22:05:15 +00:00
|
|
|
\helpref{wxHtmlWinParser}{wxhtmlwinparser} and
|
|
|
|
\helpref{wxHtmlWindow}{wxhtmlwindow} to parse and display HTML documents.
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
\wxheading{Cells}
|
|
|
|
|
|
|
|
You can divide any text (or HTML) into small fragments. Let's call these
|
|
|
|
fragments {\bf cells}. Cell is for example one word, horizontal line, image
|
|
|
|
or any other part of document. Each cell has width and height (except special
|
1999-08-05 22:05:15 +00:00
|
|
|
"magic" cells with zero dimensions - e.g. colour changers or font changers).
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
See \helpref{wxHtmlCell}{wxhtmlcell}.
|
|
|
|
|
|
|
|
\wxheading{Containers}
|
|
|
|
|
|
|
|
Container is kind of cell that may contain sub-cells. Its size depends
|
|
|
|
on number and sizes of its sub-cells (and also depends on width of window).
|
|
|
|
|
|
|
|
See \helpref{wxHtmlContainerCell}{wxhtmlcontainercell},
|
|
|
|
\helpref{wxHtmlCell::Layout}{wxhtmlcelllayout}.
|
|
|
|
|
1999-08-05 15:51:32 +00:00
|
|
|
\begin{comment}
|
|
|
|
% Bitmap is corrupt!
|
1999-08-05 22:05:15 +00:00
|
|
|
This image shows you cells and containers:
|
1999-07-10 21:17:24 +00:00
|
|
|
|
1999-12-24 23:40:13 +00:00
|
|
|
\helponly{\image{}{contbox.bmp}}
|
1999-08-05 15:51:32 +00:00
|
|
|
\end{comment}
|
1999-07-10 21:17:24 +00:00
|
|
|
\wxheading{Using Containers in Tag Handler}
|
|
|
|
|
1999-08-05 22:05:15 +00:00
|
|
|
\helpref{wxHtmlWinParser}{wxhtmlwinparser} provides a user-friendly way
|
|
|
|
of managing containers. It's based on the idea of opening and closing containers.
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
Use \helpref{OpenContainer}{wxhtmlwinparseropencontainer} to open new
|
1999-08-05 22:05:15 +00:00
|
|
|
a container {\it within an already opened container}. This new container is a
|
|
|
|
{\it sub-container} of the old one. (If you want to create a new container with
|
|
|
|
the same depth level you can call {\tt CloseContainer(); OpenContainer();}.)
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
Use \helpref{CloseContaier}{wxhtmlwinparserclosecontainer} to close the
|
1999-08-05 22:05:15 +00:00
|
|
|
container. This doesn't create a new container with same depth level but
|
1999-07-10 21:17:24 +00:00
|
|
|
it returns "control" to the parent container.
|
|
|
|
|
1999-08-05 15:51:32 +00:00
|
|
|
\begin{comment}
|
|
|
|
% Bitmap corrupt!
|
1999-07-10 21:17:24 +00:00
|
|
|
See explanation:
|
|
|
|
|
1999-12-24 23:40:13 +00:00
|
|
|
\helponly{\image{}{cont.bmp}}
|
1999-08-05 15:51:32 +00:00
|
|
|
\end{comment}
|
1999-07-10 21:17:24 +00:00
|
|
|
It's clear there must be same number of calls to
|
|
|
|
OpenContainer as to CloseContainer...
|
|
|
|
|
|
|
|
\wxheading{Example}
|
|
|
|
|
1999-08-05 22:05:15 +00:00
|
|
|
This code creates a new paragraph (container at same depth level)
|
|
|
|
with "Hello, world!":
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
m_WParser -> CloseContainer();
|
|
|
|
c = m_WParser -> OpenContainer();
|
|
|
|
|
|
|
|
m_WParser -> AddWord("Hello, ");
|
|
|
|
m_WParser -> AddWord("world!");
|
|
|
|
|
|
|
|
m_WParser -> CloseContainer();
|
|
|
|
m_WParser -> OpenContainer();
|
|
|
|
\end{verbatim}
|
|
|
|
|
1999-08-05 15:51:32 +00:00
|
|
|
\begin{comment}
|
|
|
|
% Bitmap corrupt!
|
1999-07-10 21:17:24 +00:00
|
|
|
and here is image of the situation:
|
|
|
|
|
1999-12-24 23:40:13 +00:00
|
|
|
\helponly{\image{}{hello.bmp}}
|
1999-08-05 15:51:32 +00:00
|
|
|
\end{comment}
|
1999-07-10 21:17:24 +00:00
|
|
|
|
|
|
|
You can see that there was opened container before running the code. We closed
|
|
|
|
it, created our own container, then closed our container and opened
|
|
|
|
new container. The result was that we had {\it same depth level} after
|
1999-08-05 22:05:15 +00:00
|
|
|
executing. This is general rule that should be followed by tag handlers:
|
1999-07-10 21:17:24 +00:00
|
|
|
leave depth level of containers unmodified (in other words, number of
|
|
|
|
OpenContainer and CloseContainer calls should be same within \helpref{HandleTag}{wxhtmltaghandlerhandletag}'s body).
|
|
|
|
|