\subsection{Cells and Containers}\label{cells} This article describes mechanism used by \helpref{wxHtmlWinParser}{wxhtmlwinparser} and \helpref{wxHtmlWindow}{wxhtmlwindow} to parse and display HTML documents. \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 "magic" cells with zero dimensions - e.g. colour changers or font changers). 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}. This image shows the cells and containers: \helponly{\image{}{contbox.bmp}} \wxheading{Using Containers in Tag Handler} \helpref{wxHtmlWinParser}{wxhtmlwinparser} provides a user-friendly way of managing containers. It is based on the idea of opening and closing containers. Use \helpref{OpenContainer}{wxhtmlwinparseropencontainer} to open new 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();}.) Use \helpref{CloseContainer}{wxhtmlwinparserclosecontainer} to close the container. This doesn't create a new container with same depth level but it returns "control" to the parent container. See explanation: \helponly{\image{}{cont.bmp}} There clearly must be same number of calls to OpenContainer as to CloseContainer. \wxheading{Example} This code creates a new paragraph (container at same depth level) with "Hello, world!": \begin{verbatim} m_WParser -> CloseContainer(); c = m_WParser -> OpenContainer(); m_WParser -> AddText("Hello, "); m_WParser -> AddText("world!"); m_WParser -> CloseContainer(); m_WParser -> OpenContainer(); \end{verbatim} and here is image of the situation: \helponly{\image{}{hello.bmp}} You can see that there was an opened container before the code was executed. 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 executing. This is general rule that should be followed by tag handlers: leave depth level of containers unmodified (in other words, number of OpenContainer and CloseContainer calls should be same within \helpref{HandleTag}{wxhtmltaghandlerhandletag}'s body). Notice that it would be usually better to use \helpref{wxHtmlContainerCell::InsertCell}{wxhtmlcontainercellinsertcell} instead of adding text to the parser directly.