]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: richtext/richtexthtml.h | |
21b447dc | 3 | // Purpose: interface of wxRichTextHTMLHandler |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
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 FM |
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 | |
20 | temporary images | |
21 | later. 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. | |
7c913512 | 24 | |
23324ae1 FM |
25 | However, if you want wxHTML compatibility, you will need to use |
26 | wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY | |
27 | or wxRICHTEXT_HANDLER_SAVE_IMAGES_TO_FILES. In this case, you must either call | |
28 | wxRichTextHTMLHandler::DeleteTemporaryImages before | |
29 | the next load operation, or you must store the image | |
30 | locations and delete them yourself when appropriate. You can call | |
31 | wxRichTextHTMLHandler::GetTemporaryImageLocations to | |
32 | get the array of temporary image names. | |
7c913512 | 33 | |
23324ae1 | 34 | @library{wxrichtext} |
21b447dc | 35 | @category{richtext} |
23324ae1 FM |
36 | */ |
37 | class wxRichTextHTMLHandler : public wxRichTextFileHandler | |
38 | { | |
39 | public: | |
40 | /** | |
328f5751 | 41 | , wxString&@e ext = wxT("html"), @b int@e type = wxRICHTEXT_TYPE_HTML) |
23324ae1 FM |
42 | Constructor. |
43 | */ | |
328f5751 | 44 | wxRichTextHTMLHandler() const; |
23324ae1 FM |
45 | |
46 | /** | |
47 | Clears the image locations generated by the last operation. | |
48 | */ | |
49 | void ClearTemporaryImageLocations(); | |
50 | ||
51 | //@{ | |
52 | /** | |
53 | Delete the in-memory or temporary files generated by the last operation. This | |
54 | is a static | |
55 | function that can be used to delete the saved locations from an earlier | |
56 | operation, | |
57 | for example after the user has viewed the HTML file. | |
58 | */ | |
59 | bool DeleteTemporaryImages(); | |
7c913512 FM |
60 | bool DeleteTemporaryImages(int flags, |
61 | const wxArrayString& imageLocations); | |
23324ae1 FM |
62 | //@} |
63 | ||
64 | /** | |
65 | Saves the buffer content to the HTML stream. | |
66 | */ | |
67 | bool DoSaveFile(wxRichTextBuffer* buffer, wxOutputStream& stream); | |
68 | ||
69 | /** | |
70 | Returns the mapping for converting point sizes to HTML font sizes. | |
71 | */ | |
72 | wxArrayInt GetFontSizeMapping(); | |
73 | ||
74 | /** | |
75 | Returns the directory used to store temporary image files. | |
76 | */ | |
328f5751 | 77 | const wxString GetTempDir() const; |
23324ae1 FM |
78 | |
79 | /** | |
80 | Returns the image locations for the last operation. | |
81 | */ | |
328f5751 | 82 | const wxArrayString GetTemporaryImageLocations() const; |
23324ae1 FM |
83 | |
84 | /** | |
85 | Reset the file counter, in case, for example, the same names are required each | |
86 | time | |
87 | */ | |
88 | void SetFileCounter(int counter); | |
89 | ||
90 | /** | |
91 | Sets the mapping for converting point sizes to HTML font sizes. | |
92 | There should be 7 elements, one for each HTML font size, each element | |
93 | specifying the maximum point size for that | |
94 | HTML font size. | |
23324ae1 FM |
95 | For example: |
96 | */ | |
97 | void SetFontSizeMapping(const wxArrayInt& fontSizeMapping); | |
98 | ||
99 | /** | |
100 | Sets the directory for storing temporary files. If empty, the system | |
101 | temporary directory will be used. | |
102 | */ | |
103 | void SetTempDir(const wxString& tempDir); | |
104 | ||
105 | /** | |
106 | Sets the list of image locations generated by the last operation. | |
107 | */ | |
108 | void SetTemporaryImageLocations(const wxArrayString& locations); | |
109 | }; | |
e54c96f1 | 110 |