]> git.saurik.com Git - wxWidgets.git/blame - include/wx/richtext/richtexthtml.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / richtext / richtexthtml.h
CommitLineData
b71e9aa4 1/////////////////////////////////////////////////////////////////////////////
1b88201f 2// Name: wx/richtext/richtexthtml.h
b71e9aa4
JS
3// Purpose: HTML I/O for wxRichTextCtrl
4// Author: Julian Smart
5// Modified by:
6// Created: 2005-09-30
b71e9aa4
JS
7// Copyright: (c) Julian Smart
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_RICHTEXTHTML_H_
12#define _WX_RICHTEXTHTML_H_
13
14/*!
15 * Includes
16 */
17
18#include "wx/richtext/richtextbuffer.h"
19
4fdc2c5f
JS
20// Use CSS styles where applicable, otherwise use non-CSS workarounds
21#define wxRICHTEXT_HANDLER_USE_CSS 0x1000
22
b71e9aa4
JS
23/*!
24 * wxRichTextHTMLHandler
25 */
26
3b2cb431 27class WXDLLIMPEXP_RICHTEXT wxRichTextHTMLHandler: public wxRichTextFileHandler
b71e9aa4 28{
48dd0055 29 DECLARE_DYNAMIC_CLASS(wxRichTextHTMLHandler)
b71e9aa4 30public:
50f65288 31 wxRichTextHTMLHandler(const wxString& name = wxT("HTML"), const wxString& ext = wxT("html"), int type = wxRICHTEXT_TYPE_HTML);
b71e9aa4 32
b71e9aa4
JS
33 /// Can we save using this handler?
34 virtual bool CanSave() const { return true; }
35
36 /// Can we load using this handler?
37 virtual bool CanLoad() const { return false; }
38
39 /// Can we handle this filename (if using files)? By default, checks the extension.
40 virtual bool CanHandle(const wxString& filename) const;
41
d2d0adc7
JS
42// Accessors and operations unique to this handler
43
44 /// Set and get the list of image locations generated by the last operation
45 void SetTemporaryImageLocations(const wxArrayString& locations) { m_imageLocations = locations; }
46 const wxArrayString& GetTemporaryImageLocations() const { return m_imageLocations; }
47
48 /// Clear the image locations generated by the last operation
49 void ClearTemporaryImageLocations() { m_imageLocations.Clear(); }
50
51 /// Delete the in-memory or temporary files generated by the last operation
52 bool DeleteTemporaryImages();
53
54 /// Delete the in-memory or temporary files generated by the last operation. This is a static
55 /// function that can be used to delete the saved locations from an earlier operation,
56 /// for example after the user has viewed the HTML file.
57 static bool DeleteTemporaryImages(int flags, const wxArrayString& imageLocations);
58
59 /// Reset the file counter, in case, for example, the same names are required each time
60 static void SetFileCounter(int counter) { sm_fileCounter = counter; }
61
62 /// Set and get the directory for storing temporary files. If empty, the system
63 /// temporary directory will be used.
64 void SetTempDir(const wxString& tempDir) { m_tempDir = tempDir; }
65 const wxString& GetTempDir() const { return m_tempDir; }
66
50f65288
WS
67 /// Set and get mapping from point size to HTML font size. There should be 7 elements,
68 /// one for each HTML font size, each element specifying the maximum point size for that
69 /// HTML font size. E.g. 8, 10, 13, 17, 22, 29, 100
70 void SetFontSizeMapping(const wxArrayInt& fontSizeMapping) { m_fontSizeMapping = fontSizeMapping; }
71 wxArrayInt GetFontSizeMapping() const { return m_fontSizeMapping; }
72
b71e9aa4 73protected:
2dec6761 74
d2d0adc7
JS
75// Implementation
76
6f02a879
VZ
77#if wxUSE_STREAMS
78 virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
79 virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
2dec6761
JS
80
81 /// Output character formatting
24777478
JS
82 void BeginCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& paraStyle, wxTextOutputStream& stream );
83 void EndCharacterFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, const wxRichTextAttr& paraStyle, wxTextOutputStream& stream );
1b88201f
WS
84
85 /// Output paragraph formatting
24777478
JS
86 void BeginParagraphFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, wxTextOutputStream& stream);
87 void EndParagraphFormatting(const wxRichTextAttr& currentStyle, const wxRichTextAttr& thisStyle, wxTextOutputStream& stream);
1b88201f 88
50f65288 89 /// Output font tag
24777478 90 void OutputFont(const wxRichTextAttr& style, wxTextOutputStream& stream);
1b88201f 91
50f65288
WS
92 /// Closes lists to level (-1 means close all)
93 void CloseLists(int level, wxTextOutputStream& str);
1b88201f 94
50f65288
WS
95 /// Writes an image to its base64 equivalent, or to the memory filesystem, or to a file
96 void WriteImage(wxRichTextImage* image, wxOutputStream& stream);
1b88201f
WS
97
98 /// Converts from pt to size property compatible height
d2d0adc7 99 long PtToSize(long size);
1b88201f
WS
100
101 /// Typical base64 encoder
d2d0adc7 102 wxChar* b64enc(unsigned char* input, size_t in_len);
1b88201f
WS
103
104 /// Gets the mime type of the given wxBITMAP_TYPE
21e354f1 105 const wxChar* GetMimeType(int imageType);
1b88201f
WS
106
107 /// Gets the html equivalent of the specified value
24777478 108 wxString GetAlignment(const wxRichTextAttr& thisStyle);
1b88201f
WS
109
110 /// Generates   array for indentations
111 wxString SymbolicIndent(long indent);
112
113 /// Finds the html equivalent of the specified bullet
24777478 114 int TypeOfList(const wxRichTextAttr& thisStyle, wxString& tag);
d2d0adc7
JS
115#endif
116
117// Data members
1b88201f 118
50f65288
WS
119 wxRichTextBuffer* m_buffer;
120
1b88201f 121 /// Indentation values of the table tags
d2d0adc7 122 wxArrayInt m_indents;
1b88201f 123
50f65288
WS
124 /// Stack of list types: 0 = ol, 1 = ul
125 wxArrayInt m_listTypes;
1b88201f 126
50f65288 127 /// Is there any opened font tag?
d2d0adc7 128 bool m_font;
1b88201f 129
50f65288
WS
130 /// Are we in a table?
131 bool m_inTable;
d2d0adc7
JS
132
133 /// A list of the image files or in-memory images created by the last operation.
134 wxArrayString m_imageLocations;
135
136 /// A location for the temporary files
137 wxString m_tempDir;
2dec6761 138
50f65288
WS
139 /// A mapping from point size to HTML font size
140 wxArrayInt m_fontSizeMapping;
141
d2d0adc7
JS
142 /// A counter for generating filenames
143 static int sm_fileCounter;
b71e9aa4
JS
144};
145
146#endif
147 // _WX_RICHTEXTXML_H_