1 \subsection{Cells and Containers
}\label{cells
} 
   3 This article describes mechanism used by 
 
   4 \helpref{wxHtmlWinParser
}{wxhtmlwinparser
} and 
 
   5 \helpref{wxHtmlWindow
}{wxhtmlwindow
} to parse and display HTML documents.
 
   9 You can divide any text (or HTML) into small fragments. Let's call these
 
  10 fragments 
{\bf cells
}. Cell is for example one word, horizontal line, image
 
  11 or any other part of 
document. Each cell has width and height (except special
 
  12 "magic" cells with zero dimensions - e.g. colour changers or font changers).
 
  14 See 
\helpref{wxHtmlCell
}{wxhtmlcell
}.
 
  16 \wxheading{Containers
} 
  18 Container is kind of cell that may contain sub-cells. Its size depends
 
  19 on number and sizes of its sub-cells (and also depends on width of window). 
 
  21 See 
\helpref{wxHtmlContainerCell
}{wxhtmlcontainercell
}, 
 
  22 \helpref{wxHtmlCell::Layout
}{wxhtmlcelllayout
}.
 
  26 This image shows you cells and containers:
 
  28 \helponly{\image{}{contbox.bmp
}} 
  30 \wxheading{Using Containers in Tag Handler
} 
  32 \helpref{wxHtmlWinParser
}{wxhtmlwinparser
} provides a user-friendly way
 
  33 of managing containers. It is based on the idea of opening and closing containers.
 
  35 Use 
\helpref{OpenContainer
}{wxhtmlwinparseropencontainer
} to open new
 
  36 a container 
{\it within an already opened container
}. This new container is a 
 
  37 {\it sub-container
} of the old one. (If you want to create a new container with
 
  38 the same depth level you can call 
{\tt CloseContainer(); OpenContainer();
}.)
 
  40 Use 
\helpref{CloseContainer
}{wxhtmlwinparserclosecontainer
} to close the 
 
  41 container. This doesn't create a new container with same depth level but
 
  42 it returns "control" to the parent container.
 
  48 \helponly{\image{}{cont.bmp
}} 
  50 It is clear there must be same number of calls to 
 
  51 OpenContainer as to CloseContainer...
 
  55 This code creates a new paragraph (container at same depth level)
 
  59 m_WParser -> CloseContainer();
 
  60 c = m_WParser -> OpenContainer();
 
  62 m_WParser -> AddWord("Hello, ");
 
  63 m_WParser -> AddWord("world!");
 
  65 m_WParser -> CloseContainer();
 
  66 m_WParser -> OpenContainer();
 
  71 and here is image of the situation:
 
  73 \helponly{\image{}{hello.bmp
}} 
  76 You can see that there was opened container before running the code. We closed
 
  77 it, created our own container, then closed our container and opened
 
  78 new container. The result was that we had 
{\it same depth level
} after
 
  79 executing. This is general rule that should be followed by tag handlers:
 
  80 leave depth level of containers unmodified (in other words, number of
 
  81 OpenContainer and CloseContainer calls should be same within 
\helpref{HandleTag
}{wxhtmltaghandlerhandletag
}'s body).