]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/richtext/richtexthtml.h
Make AsyncExecLoopExitEnum enum in the wxExecute() test public.
[wxWidgets.git] / interface / wx / richtext / richtexthtml.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: richtext/richtexthtml.h
21b447dc 3// Purpose: interface of wxRichTextHTMLHandler
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxRichTextHTMLHandler
7c913512 11
23324ae1 12 Handles HTML output (only) for wxRichTextCtrl content.
7c913512 13
23324ae1
FM
14 The most flexible way to use this class is to create a temporary object and call
15 its functions directly, rather than use wxRichTextBuffer::SaveFile or
16 wxRichTextCtrl::SaveFile.
7c913512 17
23324ae1 18 Image handling requires a little extra work from the application, to choose an
9e7ad1ca
FM
19 appropriate image format for the target HTML viewer and to clean up the temporary
20 images later.
21 If you are planning to load the HTML into a standard web browser, you can
23324ae1
FM
22 specify the handler flag wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64 (the default)
23 and no extra work is required: the images will be written with the HTML.
7c913512 24
23324ae1 25 However, if you want wxHTML compatibility, you will need to use
9e7ad1ca
FM
26 @c wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY or
27 @c wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES.
28
29 In this case, you must either call wxRichTextHTMLHandler::DeleteTemporaryImages
30 before the next load operation, or you must store the image locations and
31 delete them yourself when appropriate.
32
33 You can call wxRichTextHTMLHandler::GetTemporaryImageLocations to
23324ae1 34 get the array of temporary image names.
7c913512 35
9e7ad1ca
FM
36
37 @section richtexthtmlhandler_flags Handler flags
38
39 The following flags can be used with this handler, via the handler's SetFlags()
40 function or the buffer or control's SetHandlerFlags() function:
41
42 - wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY
43 Images are saved to the memory filesystem: suitable for showing wxHTML windows.
44 - wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES
45 Images are saved to temporary files: suitable for showing in wxHTML windows.
46 - wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_BASE64
47 Images are written with the HTML files in Base 64 format: suitable for showing
48 in web browsers.
49 - wxRICHTEXT_HANDLER_NO_HEADER_FOOTER
50 Don't include header and footer tags (HTML, HEAD, BODY), so that the HTML
51 can be used as part of a larger document.
4fdc2c5f
JS
52 - wxRICHTEXT_HANDLER_USE_CSS
53 Use CSS where possible, otherwise use workarounds that will show in wxHtmlWindow.
9e7ad1ca 54
23324ae1 55 @library{wxrichtext}
21b447dc 56 @category{richtext}
23324ae1
FM
57*/
58class wxRichTextHTMLHandler : public wxRichTextFileHandler
59{
60public:
61 /**
23324ae1
FM
62 Constructor.
63 */
f8ebb70d
FM
64 wxRichTextHTMLHandler(const wxString& name = "HTML",
65 const wxString& ext = "html",
9e7ad1ca 66 int type = wxRICHTEXT_TYPE_HTML);
23324ae1
FM
67
68 /**
69 Clears the image locations generated by the last operation.
70 */
71 void ClearTemporaryImageLocations();
72
23324ae1 73 /**
9e7ad1ca 74 Deletes the in-memory or temporary files generated by the last operation.
23324ae1
FM
75 */
76 bool DeleteTemporaryImages();
9e7ad1ca
FM
77
78 /**
79 Delete the in-memory or temporary files generated by the last operation.
80 This is a static function that can be used to delete the saved locations
81 from an earlier operation, for example after the user has viewed the HTML file.
82 */
fadc2df6
FM
83 static bool DeleteTemporaryImages(int flags,
84 const wxArrayString& imageLocations);
23324ae1 85
23324ae1
FM
86 /**
87 Returns the mapping for converting point sizes to HTML font sizes.
88 */
adaaa686 89 wxArrayInt GetFontSizeMapping() const;
23324ae1
FM
90
91 /**
92 Returns the directory used to store temporary image files.
93 */
5267aefd 94 const wxString& GetTempDir() const;
23324ae1
FM
95
96 /**
97 Returns the image locations for the last operation.
98 */
5267aefd 99 const wxArrayString& GetTemporaryImageLocations() const;
23324ae1
FM
100
101 /**
102 Reset the file counter, in case, for example, the same names are required each
9e7ad1ca 103 time.
23324ae1 104 */
adaaa686 105 static void SetFileCounter(int counter);
23324ae1
FM
106
107 /**
108 Sets the mapping for converting point sizes to HTML font sizes.
9e7ad1ca 109
23324ae1 110 There should be 7 elements, one for each HTML font size, each element
9e7ad1ca 111 specifying the maximum point size for that HTML font size.
23324ae1 112 For example:
9e7ad1ca
FM
113 @code
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 @endcode
23324ae1
FM
125 */
126 void SetFontSizeMapping(const wxArrayInt& fontSizeMapping);
127
128 /**
9e7ad1ca
FM
129 Sets the directory for storing temporary files.
130 If empty, the system temporary directory will be used.
23324ae1
FM
131 */
132 void SetTempDir(const wxString& tempDir);
133
134 /**
135 Sets the list of image locations generated by the last operation.
136 */
137 void SetTemporaryImageLocations(const wxArrayString& locations);
5e6e278d
FM
138
139protected:
140 /**
141 Saves the buffer content to the HTML stream.
142 */
143 virtual bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream);
23324ae1 144};
e54c96f1 145