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