Added URL support to attribute objects and to wxRichTextCtrl,

generating a wxTextUrlEvent as appropriate.
Added outline list support and updated previews.
Added alignment support for bullets.
Added single right parenthesis support.
Added XML stylesheet reading/writing.
Changed SetBulletSymbol to SetBulletText so it can support
bullet text more generally (e.g. for cached outline list numbering)
Added wxRichTextRenderer to isolate e.g. bullet drawing and make
it customisable.
Added event handler support to wxRichTextBuffer.
Updated documentation.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42431 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-10-26 06:32:47 +00:00
parent a60a549995
commit d2d0adc776
25 changed files with 2460 additions and 780 deletions

View File

@@ -27,7 +27,7 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextHTMLHandler: public wxRichTextFileHandler
DECLARE_CLASS(wxRichTextHTMLHandler)
public:
wxRichTextHTMLHandler(const wxString& name = wxT("HTML"), const wxString& ext = wxT("html"), int type = wxRICHTEXT_TYPE_HTML)
: wxRichTextFileHandler(name, ext, type)
: wxRichTextFileHandler(name, ext, type), m_indent(0), m_font(false), m_list(false), m_is_ul(false)
{ }
/// Can we save using this handler?
@@ -39,12 +39,38 @@ public:
/// Can we handle this filename (if using files)? By default, checks the extension.
virtual bool CanHandle(const wxString& filename) const;
// Accessors and operations unique to this handler
/// Set and get the list of image locations generated by the last operation
void SetTemporaryImageLocations(const wxArrayString& locations) { m_imageLocations = locations; }
const wxArrayString& GetTemporaryImageLocations() const { return m_imageLocations; }
/// Clear the image locations generated by the last operation
void ClearTemporaryImageLocations() { m_imageLocations.Clear(); }
/// Delete the in-memory or temporary files generated by the last operation
bool DeleteTemporaryImages();
/// Delete the in-memory or temporary files generated by the last operation. This is a static
/// function that can be used to delete the saved locations from an earlier operation,
/// for example after the user has viewed the HTML file.
static bool DeleteTemporaryImages(int flags, const wxArrayString& imageLocations);
/// Reset the file counter, in case, for example, the same names are required each time
static void SetFileCounter(int counter) { sm_fileCounter = counter; }
/// Set and get the directory for storing temporary files. If empty, the system
/// temporary directory will be used.
void SetTempDir(const wxString& tempDir) { m_tempDir = tempDir; }
const wxString& GetTempDir() const { return m_tempDir; }
protected:
// Implementation
#if wxUSE_STREAMS
virtual bool DoLoadFile(wxRichTextBuffer *buffer, wxInputStream& stream);
virtual bool DoSaveFile(wxRichTextBuffer *buffer, wxOutputStream& stream);
#endif
/// Output character formatting
virtual void BeginCharacterFormatting(const wxTextAttrEx& currentStyle, const wxTextAttrEx& thisStyle, const wxTextAttrEx& paraStyle, wxOutputStream& stream );
@@ -53,51 +79,62 @@ protected:
/// Output paragraph formatting
virtual void OutputParagraphFormatting(const wxTextAttrEx& WXUNUSED(currentStyle), const wxTextAttrEx& thisStyle, wxOutputStream& stream/*, bool start*/);
/// Converts an image to its base64 equivalent
void Image_to_Base64(wxRichTextImage* image, wxOutputStream& stream);
/// Writes an image to its base64 equivalent, or to the memory filesystem, or to a file
void WriteImage(wxRichTextImage* image, wxOutputStream& stream);
/// Builds required indentation
void Indent( const wxTextAttrEx& thisStyle, wxTextOutputStream& str );
void Indent(const wxTextAttrEx& thisStyle, wxTextOutputStream& str);
/// Left indent
void LIndent( const wxTextAttrEx& thisStyle, wxTextOutputStream& str );
void LIndent(const wxTextAttrEx& thisStyle, wxTextOutputStream& str);
/// Converts from pt to size property compatible height
long Pt_To_Size(long size);
long PtToSize(long size);
/// Typical base64 encoder
wxChar* b64enc( unsigned char* input, size_t in_len );
wxChar* b64enc(unsigned char* input, size_t in_len);
/// Gets the mime type of the given wxBITMAP_TYPE
const wxChar* GetMimeType(int imageType);
/// Gets the html equivalent of the specified value
wxString GetAlignment( const wxTextAttrEx& thisStyle );
wxString GetAlignment(const wxTextAttrEx& thisStyle);
/// Generates   array for indentations
wxString SymbolicIndent(long indent);
/// Finds the html equivalent of the specified bullet
void TypeOfList( const wxTextAttrEx& thisStyle, wxString& tag );
void TypeOfList(const wxTextAttrEx& thisStyle, wxString& tag);
/// Closes existings or Opens new tables for navigation to an item's horizontal position.
void NavigateToListPosition( const wxTextAttrEx& thisStyle, wxTextOutputStream& str );
void NavigateToListPosition(const wxTextAttrEx& thisStyle, wxTextOutputStream& str);
#endif
// Data members
/// Indentation values of the table tags
wxArrayInt m_indents;
wxArrayInt m_indents;
/// Horizontal position of the current table
long m_indent;
long m_indent;
/// Is there any opened font tag
bool m_font;
bool m_font;
/// Is there any opened ul/ol tag
bool m_list;
bool m_list;
/// type of list, ul or ol?
bool m_is_ul;
bool m_is_ul;
/// A list of the image files or in-memory images created by the last operation.
wxArrayString m_imageLocations;
/// A location for the temporary files
wxString m_tempDir;
/// A counter for generating filenames
static int sm_fileCounter;
};
#endif