1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/richtext/richedithtml.h
3 // Purpose: HTML I/O for wxRichTextCtrl
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_RICHTEXTHTML_H_
13 #define _WX_RICHTEXTHTML_H_
19 #include "wx/richtext/richtextbuffer.h"
22 * wxRichTextHTMLHandler
25 class WXDLLIMPEXP_RICHTEXT wxRichTextHTMLHandler
: public wxRichTextFileHandler
27 DECLARE_CLASS(wxRichTextHTMLHandler
)
29 wxRichTextHTMLHandler(const wxString
& name
= wxT("HTML"), const wxString
& ext
= wxT("html"), int type
= wxRICHTEXT_TYPE_HTML
)
30 : wxRichTextFileHandler(name
, ext
, type
)
33 /// Can we save using this handler?
34 virtual bool CanSave() const { return true; }
36 /// Can we load using this handler?
37 virtual bool CanLoad() const { return false; }
39 /// Can we handle this filename (if using files)? By default, checks the extension.
40 virtual bool CanHandle(const wxString
& filename
) const;
45 virtual bool DoLoadFile(wxRichTextBuffer
*buffer
, wxInputStream
& stream
);
46 virtual bool DoSaveFile(wxRichTextBuffer
*buffer
, wxOutputStream
& stream
);
49 /// Output character formatting
50 virtual void BeginCharacterFormatting(const wxTextAttrEx
& currentStyle
, const wxTextAttrEx
& thisStyle
, const wxTextAttrEx
& paraStyle
, wxOutputStream
& stream
);
51 virtual void EndCharacterFormatting(const wxTextAttrEx
& WXUNUSED(currentStyle
), const wxTextAttrEx
& thisStyle
, const wxTextAttrEx
& paraStyle
, wxOutputStream
& stream
);
53 /// Output paragraph formatting
54 virtual void OutputParagraphFormatting(const wxTextAttrEx
& WXUNUSED(currentStyle
), const wxTextAttrEx
& thisStyle
, wxOutputStream
& stream
/*, bool start*/);
56 /// Converts an image to its base64 equivalent
57 void Image_to_Base64(wxRichTextImage
* image
, wxOutputStream
& stream
);
59 /// Builds required indentation
60 void Indent( const wxTextAttrEx
& thisStyle
, wxTextOutputStream
& str
);
63 void LIndent( const wxTextAttrEx
& thisStyle
, wxTextOutputStream
& str
);
65 /// Converts from pt to size property compatible height
66 long Pt_To_Size(long size
);
68 /// Typical base64 encoder
69 wxChar
* b64enc( unsigned char* input
, size_t in_len
);
71 /// Gets the mime type of the given wxBITMAP_TYPE
72 const wxChar
* GetMimeType(int imageType
);
74 /// Gets the html equivalent of the specified value
75 wxString
GetAlignment( const wxTextAttrEx
& thisStyle
);
77 /// Generates array for indentations
78 wxString
SymbolicIndent(long indent
);
80 /// Finds the html equivalent of the specified bullet
81 void TypeOfList( const wxTextAttrEx
& thisStyle
, wxString
& tag
);
83 /// Closes existings or Opens new tables for navigation to an item's horizontal position.
84 void NavigateToListPosition( const wxTextAttrEx
& thisStyle
, wxTextOutputStream
& str
);
86 /// Indentation values of the table tags
89 /// Horizontal position of the current table
92 /// Is there any opened font tag
95 /// Is there any opened ul/ol tag
98 /// type of list, ul or ol?
104 // _WX_RICHTEXTXML_H_