1\section{\class{wxRichTextHTMLHandler}}\label{wxrichtexthtmlhandler} 2 3Handles HTML output (only) for \helpref{wxRichTextCtrl}{wxrichtextctrl} content. 4 5The most flexible way to use this class is to create a temporary object and call 6its functions directly, rather than use \helpref{wxRichTextBuffer::SaveFile}{wxrichtextbuffersavefile} or\rtfsp 7\helpref{wxRichTextCtrl::SaveFile}{wxrichtextctrlsavefile}. 8 9Image handling requires a little extra work from the application, to choose an 10appropriate image format for the target HTML viewer and to clean up the temporary images 11later. If you are planning to load the HTML into a standard web browser, you can 12specify the handler flag wxRICHTEXT\_HANDLER\_SAVE\_IMAGES\_TO\_BASE64 (the default) 13and no extra work is required: the images will be written with the HTML. 14 15However, if you want wxHTML compatibility, you will need to use wxRICHTEXT\_HANDLER\_SAVE\_IMAGES\_TO\_MEMORY 16or wxRICHTEXT\_HANDLER\_SAVE\_IMAGES\_TO\_FILES. In this case, you must either call \helpref{DeleteTemporaryImages}{wxrichtexthtmlhandlerdeletetemporaryimages} before 17the next load operation, or you must store the image 18locations and delete them yourself when appropriate. You can call \helpref{GetTemporaryImageLocations}{wxrichtexthtmlhandlergettemporaryimagelocations} to 19get the array of temporary image names. 20 21\wxheading{Handler flags} 22 23The following flags can be used with this handler, via 24the handler's SetFlags function or the buffer or control's 25SetHandlerFlags function: 26 27\twocolwidtha{7cm} 28\begin{twocollist}\itemsep=0pt 29\twocolitem{\windowstyle{wxRICHTEXT\_HANDLER\_SAVE\_IMAGES\_TO\_MEMORY}}{Images are saved to the memory filesystem: suitable for showing wxHTML windows.} 30\twocolitem{\windowstyle{wxRICHTEXT\_HANDLER\_SAVE\_IMAGES\_TO\_FILES}}{Images are saved to temporary files: suitable for showing in wxHTML windows.} 31\twocolitem{\windowstyle{wxRICHTEXT\_HANDLER\_SAVE\_IMAGES\_TO\_BASE64}}{Images are written with the HTML files in Base 64 format: suitable for showing in web browsers.} 32\twocolitem{\windowstyle{wxRICHTEXT\_HANDLER\_NO\_HEADER\_FOOTER}}{Don't include header and footer tags (HTML, HEAD, BODY), so that the HTML can be used as part of a larger document.} 33\twocolitem{\windowstyle{wxRICHTEXT\_HANDLER\_USE\_CSS}}{Use CSS where possible, otherwise use workarounds that will show in wxHtmlWindow.} 34 35\end{twocollist} 36 37\wxheading{Derived from} 38 39\helpref{wxRichTextFileHandler}{wxrichtextfilehandler} 40 41\wxheading{Include files} 42 43<wx/richtext/richtexthtml.h> 44 45\wxheading{Data structures} 46 47\latexignore{\rtfignore{\wxheading{Members}}} 48 49\membersection{wxRichTextHTMLHandler::wxRichTextHTMLHandler}\label{wxrichtexthtmlhandlerwxrichtexthtmlhandler} 50 51\func{}{wxRichTextHTMLHandler}{\param{const wxString\& }{name = wxT("HTML")}, \param{const wxString\& }{ext = wxT("html")}, \param{int }{type = wxRICHTEXT\_TYPE\_HTML}} 52 53Constructor. 54 55\membersection{wxRichTextHTMLHandler::ClearTemporaryImageLocations}\label{wxrichtexthtmlhandlercleartemporaryimagelocations} 56 57\func{void}{ClearTemporaryImageLocations}{\void} 58 59Clears the image locations generated by the last operation. 60 61\membersection{wxRichTextHTMLHandler::DeleteTemporaryImages}\label{wxrichtexthtmlhandlerdeletetemporaryimages} 62 63\func{bool}{DeleteTemporaryImages}{\void} 64 65Deletes the in-memory or temporary files generated by the last operation. 66 67\func{bool}{DeleteTemporaryImages}{\param{int }{flags}, \param{const wxArrayString\& }{imageLocations}} 68 69Delete the in-memory or temporary files generated by the last operation. This is a static 70function that can be used to delete the saved locations from an earlier operation, 71for example after the user has viewed the HTML file. 72 73\membersection{wxRichTextHTMLHandler::DoSaveFile}\label{wxrichtexthtmlhandlerdosavefile} 74 75\func{bool}{DoSaveFile}{\param{wxRichTextBuffer* }{buffer}, \param{wxOutputStream\& }{stream}} 76 77Saves the buffer content to the HTML stream. 78 79\membersection{wxRichTextHTMLHandler::GetFontSizeMapping}\label{wxrichtexthtmlhandlergetfontsizemapping} 80 81\func{wxArrayInt}{GetFontSizeMapping}{\void} 82 83Returns the mapping for converting point sizes to HTML font sizes. 84 85\membersection{wxRichTextHTMLHandler::GetTempDir}\label{wxrichtexthtmlhandlergettempdir} 86 87\constfunc{const wxString\&}{GetTempDir}{\void} 88 89Returns the directory used to store temporary image files. 90 91\membersection{wxRichTextHTMLHandler::GetTemporaryImageLocations}\label{wxrichtexthtmlhandlergettemporaryimagelocations} 92 93\constfunc{const wxArrayString\&}{GetTemporaryImageLocations}{\void} 94 95Returns the image locations for the last operation. 96 97\membersection{wxRichTextHTMLHandler::SetFileCounter}\label{wxrichtexthtmlhandlersetfilecounter} 98 99\func{void}{SetFileCounter}{\param{int }{counter}} 100 101Reset the file counter, in case, for example, the same names are required each time 102 103\membersection{wxRichTextHTMLHandler::SetFontSizeMapping}\label{wxrichtexthtmlhandlersetfontsizemapping} 104 105\func{void}{SetFontSizeMapping}{\param{const wxArrayInt\& }{fontSizeMapping}} 106 107Sets the mapping for converting point sizes to HTML font sizes. 108There should be 7 elements, one for each HTML font size, each element specifying the maximum point size for that 109HTML font size. 110 111For example: 112 113\begin{verbatim} 114 wxArrayInt fontSizeMapping; 115 fontSizeMapping.Add(7); 116 fontSizeMapping.Add(9); 117 fontSizeMapping.Add(11); 118 fontSizeMapping.Add(12); 119 fontSizeMapping.Add(14); 120 fontSizeMapping.Add(22); 121 fontSizeMapping.Add(100); 122 123 htmlHandler.SetFontSizeMapping(fontSizeMapping); 124\end{verbatim} 125 126\membersection{wxRichTextHTMLHandler::SetTempDir}\label{wxrichtexthtmlhandlersettempdir} 127 128\func{void}{SetTempDir}{\param{const wxString\& }{tempDir}} 129 130Sets the directory for storing temporary files. If empty, the system 131temporary directory will be used. 132 133\membersection{wxRichTextHTMLHandler::SetTemporaryImageLocations}\label{wxrichtexthtmlhandlersettemporaryimagelocations} 134 135\func{void}{SetTemporaryImageLocations}{\param{const wxArrayString\& }{locations}} 136 137Sets the list of image locations generated by the last operation. 138 139