]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/richtext/richtexthtml.h
document the protected functions of wxTextValidator; it helps user to eventually...
[wxWidgets.git] / interface / wx / richtext / richtexthtml.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtexthtml.h
3 // Purpose: interface of wxRichTextHTMLHandler
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxRichTextHTMLHandler
11
12 Handles HTML output (only) for wxRichTextCtrl content.
13
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.
17
18 Image handling requires a little extra work from the application, to choose an
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
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.
24
25 However, if you want wxHTML compatibility, you will need to use
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
34 get the array of temporary image names.
35
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.
52
53
54 @library{wxrichtext}
55 @category{richtext}
56 */
57 class wxRichTextHTMLHandler : public wxRichTextFileHandler
58 {
59 public:
60 /**
61 Constructor.
62 */
63 wxRichTextHTMLHandler(const wxString& name = "HTML",
64 const wxString& ext = "html",
65 int type = wxRICHTEXT_TYPE_HTML);
66
67 /**
68 Clears the image locations generated by the last operation.
69 */
70 void ClearTemporaryImageLocations();
71
72 /**
73 Deletes the in-memory or temporary files generated by the last operation.
74 */
75 bool DeleteTemporaryImages();
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 */
82 static bool DeleteTemporaryImages(int flags,
83 const wxArrayString& imageLocations);
84
85 /**
86 Returns the mapping for converting point sizes to HTML font sizes.
87 */
88 wxArrayInt GetFontSizeMapping() const;
89
90 /**
91 Returns the directory used to store temporary image files.
92 */
93 const wxString& GetTempDir() const;
94
95 /**
96 Returns the image locations for the last operation.
97 */
98 const wxArrayString& GetTemporaryImageLocations() const;
99
100 /**
101 Reset the file counter, in case, for example, the same names are required each
102 time.
103 */
104 static void SetFileCounter(int counter);
105
106 /**
107 Sets the mapping for converting point sizes to HTML font sizes.
108
109 There should be 7 elements, one for each HTML font size, each element
110 specifying the maximum point size for that HTML font size.
111 For example:
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
124 */
125 void SetFontSizeMapping(const wxArrayInt& fontSizeMapping);
126
127 /**
128 Sets the directory for storing temporary files.
129 If empty, the system temporary directory will be used.
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);
137
138 protected:
139 /**
140 Saves the buffer content to the HTML stream.
141 */
142 virtual bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream);
143 };
144