]> git.saurik.com Git - wxWidgets.git/commitdiff
Added a customisable formatting dialog for wxRichTextCtrl. Control the
authorJulian Smart <julian@anthemion.co.uk>
Sun, 8 Oct 2006 14:05:17 +0000 (14:05 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 8 Oct 2006 14:05:17 +0000 (14:05 +0000)
visible tabs with flags passed to the constructor.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

12 files changed:
include/wx/richtext/richtextbulletspage.h [new file with mode: 0644]
include/wx/richtext/richtextfontpage.h [new file with mode: 0644]
include/wx/richtext/richtextformatdlg.h [new file with mode: 0644]
include/wx/richtext/richtextindentspage.h [new file with mode: 0644]
include/wx/richtext/richtextstylepage.h [new file with mode: 0644]
include/wx/richtext/richtexttabspage.h [new file with mode: 0644]
src/richtext/richtextbulletspage.cpp [new file with mode: 0644]
src/richtext/richtextfontpage.cpp [new file with mode: 0644]
src/richtext/richtextformatdlg.cpp [new file with mode: 0644]
src/richtext/richtextindentspage.cpp [new file with mode: 0644]
src/richtext/richtextstylepage.cpp [new file with mode: 0644]
src/richtext/richtexttabspage.cpp [new file with mode: 0644]

diff --git a/include/wx/richtext/richtextbulletspage.h b/include/wx/richtext/richtextbulletspage.h
new file mode 100644 (file)
index 0000000..53aa666
--- /dev/null
@@ -0,0 +1,199 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtextbulletspage.h
+// Purpose:
+// Author:      Julian Smart
+// Modified by:
+// Created:     10/4/2006 10:32:31 AM
+// RCS-ID:
+// Copyright:   (c) Julian Smart
+// Licence:
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _RICHTEXTBULLETSPAGE_H_
+#define _RICHTEXTBULLETSPAGE_H_
+
+/*!
+ * Includes
+ */
+
+////@begin includes
+#include "wx/statline.h"
+#include "wx/spinctrl.h"
+////@end includes
+
+/*!
+ * Forward declarations
+ */
+
+////@begin forward declarations
+class wxSpinCtrl;
+class wxRichTextCtrl;
+////@end forward declarations
+
+/*!
+ * Control identifiers
+ */
+
+////@begin control identifiers
+#define SYMBOL_WXRICHTEXTBULLETSPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL
+#define SYMBOL_WXRICHTEXTBULLETSPAGE_TITLE _("wxRichTextBulletsPage")
+#define SYMBOL_WXRICHTEXTBULLETSPAGE_IDNAME ID_RICHTEXTBULLETSPAGE
+#define SYMBOL_WXRICHTEXTBULLETSPAGE_SIZE wxSize(400, 300)
+#define SYMBOL_WXRICHTEXTBULLETSPAGE_POSITION wxDefaultPosition
+////@end control identifiers
+
+/*!
+ * Compatibility
+ */
+
+#ifndef wxCLOSE_BOX
+#define wxCLOSE_BOX 0x1000
+#endif
+
+/*!
+ * wxRichTextBulletsPage class declaration
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextBulletsPage: public wxPanel
+{
+    DECLARE_DYNAMIC_CLASS( wxRichTextBulletsPage )
+    DECLARE_EVENT_TABLE()
+
+public:
+    /// Constructors
+    wxRichTextBulletsPage( );
+    wxRichTextBulletsPage( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTBULLETSPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTBULLETSPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTBULLETSPAGE_SIZE, long style = SYMBOL_WXRICHTEXTBULLETSPAGE_STYLE );
+
+    /// Creation
+    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTBULLETSPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTBULLETSPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTBULLETSPAGE_SIZE, long style = SYMBOL_WXRICHTEXTBULLETSPAGE_STYLE );
+
+    /// Initialise members
+    void Init();
+
+    /// Creates the controls and sizers
+    void CreateControls();
+
+    /// Updates the bullets preview
+    void UpdatePreview();
+
+    /// Transfer data from/to window
+    virtual bool TransferDataFromWindow();
+    virtual bool TransferDataToWindow();
+
+    /// Gets the attributes associated with the main formatting dialog
+    wxTextAttrEx* GetAttributes();
+
+    /// Update for symbol-related controls
+    void OnSymbolUpdate( wxUpdateUIEvent& event );
+
+    /// Update for number-related controls
+    void OnNumberUpdate( wxUpdateUIEvent& event );
+
+////@begin wxRichTextBulletsPage event handler declarations
+
+    /// wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
+    void OnStylelistboxSelected( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
+    void OnSymbolstaticUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
+    void OnSymbolctrlSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
+    void OnSymbolctrlUpdated( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
+    void OnSymbolctrlUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
+    void OnChooseSymbolClick( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
+    void OnChooseSymbolUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
+    void OnSymbolfontctrlSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
+    void OnSymbolfontctrlUpdated( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
+    void OnSymbolfontctrlUIUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
+    void OnNumberstaticUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+    void OnNumberctrlUpdated( wxSpinEvent& event );
+
+    /// wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+    void OnNumberctrlUp( wxSpinEvent& event );
+
+    /// wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+    void OnNumberctrlDown( wxSpinEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+    void OnNumberctrlTextUpdated( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+    void OnNumberctrlUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
+    void OnParenthesesctrlClick( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
+    void OnParenthesesctrlUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
+    void OnPeriodctrlClick( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
+    void OnPeriodctrlUpdate( wxUpdateUIEvent& event );
+
+////@end wxRichTextBulletsPage event handler declarations
+
+////@begin wxRichTextBulletsPage member function declarations
+
+    /// Retrieves bitmap resources
+    wxBitmap GetBitmapResource( const wxString& name );
+
+    /// Retrieves icon resources
+    wxIcon GetIconResource( const wxString& name );
+////@end wxRichTextBulletsPage member function declarations
+
+    /// Should we show tooltips?
+    static bool ShowToolTips();
+
+////@begin wxRichTextBulletsPage member variables
+    wxListBox* m_styleListBox;
+    wxComboBox* m_symbolCtrl;
+    wxComboBox* m_symbolFontCtrl;
+    wxSpinCtrl* m_numberCtrl;
+    wxCheckBox* m_parenthesesCtrl;
+    wxCheckBox* m_periodCtrl;
+    wxRichTextCtrl* m_previewCtrl;
+    /// Control identifiers
+    enum {
+        ID_RICHTEXTBULLETSPAGE = 10300,
+        ID_RICHTEXTBULLETSPAGE_STYLELISTBOX = 10305,
+        ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC = 10301,
+        ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL = 10307,
+        ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL = 10308,
+        ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL = 10309,
+        ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC = 10302,
+        ID_RICHTEXTBULLETSPAGE_NUMBERCTRL = 10310,
+        ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL = 10311,
+        ID_RICHTEXTBULLETSPAGE_PERIODCTRL = 10313,
+        ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL = 10314
+    };
+////@end wxRichTextBulletsPage member variables
+
+    bool m_hasBulletStyle;
+    bool m_hasBulletNumber;
+    bool m_hasBulletSymbol;
+    bool m_dontUpdate;
+};
+
+#endif
+    // _RICHTEXTBULLETSPAGE_H_
diff --git a/include/wx/richtext/richtextfontpage.h b/include/wx/richtext/richtextfontpage.h
new file mode 100644 (file)
index 0000000..ba1c0d7
--- /dev/null
@@ -0,0 +1,144 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/richtext/richeditfontpage.h
+// Purpose:     Font page for wxRichTextFormattingDialog
+// Author:      Julian Smart
+// Modified by:
+// Created:     2006-10-02
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _RICHTEXTFONTPAGE_H_
+#define _RICHTEXTFONTPAGE_H_
+
+/*!
+ * Includes
+ */
+
+////@begin includes
+////@end includes
+
+/*!
+ * Forward declarations
+ */
+
+////@begin forward declarations
+class wxRichTextFontListBox;
+class wxRichTextColourSwatchCtrl;
+class wxRichTextFontPreviewCtrl;
+////@end forward declarations
+
+/*!
+ * Control identifiers
+ */
+
+////@begin control identifiers
+#define SYMBOL_WXRICHTEXTFONTPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL
+#define SYMBOL_WXRICHTEXTFONTPAGE_TITLE _("wxRichTextFontPage")
+#define SYMBOL_WXRICHTEXTFONTPAGE_IDNAME ID_RICHTEXTFONTPAGE
+#define SYMBOL_WXRICHTEXTFONTPAGE_SIZE wxSize(400, 300)
+#define SYMBOL_WXRICHTEXTFONTPAGE_POSITION wxDefaultPosition
+////@end control identifiers
+
+/*!
+ * wxRichTextFontPage class declaration
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFontPage: public wxPanel
+{
+    DECLARE_DYNAMIC_CLASS( wxRichTextFontPage )
+    DECLARE_EVENT_TABLE()
+
+public:
+    /// Constructors
+    wxRichTextFontPage( );
+    wxRichTextFontPage( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTFONTPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTFONTPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTFONTPAGE_SIZE, long style = SYMBOL_WXRICHTEXTFONTPAGE_STYLE );
+
+    /// Initialise members
+    void Init();
+
+    /// Creation
+    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTFONTPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTFONTPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTFONTPAGE_SIZE, long style = SYMBOL_WXRICHTEXTFONTPAGE_STYLE );
+
+    /// Creates the controls and sizers
+    void CreateControls();
+
+    /// Transfer data from/to window
+    virtual bool TransferDataFromWindow();
+    virtual bool TransferDataToWindow();
+
+    /// Updates the font preview
+    void UpdatePreview();
+
+    void OnFaceListBoxSelected( wxCommandEvent& event );
+    void OnColourClicked( wxCommandEvent& event );
+
+    /// Gets the attributes associated with the main formatting dialog
+    wxTextAttrEx* GetAttributes();
+
+////@begin wxRichTextFontPage event handler declarations
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
+    void OnFaceTextCtrlUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
+    void OnSizeTextCtrlUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
+    void OnSizeListBoxSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
+    void OnStyleCtrlSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
+    void OnWeightCtrlSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
+    void OnUnderliningCtrlSelected( wxCommandEvent& event );
+
+////@end wxRichTextFontPage event handler declarations
+
+////@begin wxRichTextFontPage member function declarations
+
+    /// Retrieves bitmap resources
+    wxBitmap GetBitmapResource( const wxString& name );
+
+    /// Retrieves icon resources
+    wxIcon GetIconResource( const wxString& name );
+////@end wxRichTextFontPage member function declarations
+
+    /// Should we show tooltips?
+    static bool ShowToolTips();
+
+////@begin wxRichTextFontPage member variables
+    wxTextCtrl* m_faceTextCtrl;
+    wxRichTextFontListBox* m_faceListBox;
+    wxTextCtrl* m_sizeTextCtrl;
+    wxListBox* m_sizeListBox;
+    wxComboBox* m_styleCtrl;
+    wxComboBox* m_weightCtrl;
+    wxComboBox* m_underliningCtrl;
+    wxRichTextColourSwatchCtrl* m_colourCtrl;
+    wxRichTextFontPreviewCtrl* m_previewCtrl;
+    /// Control identifiers
+    enum {
+        ID_RICHTEXTFONTPAGE = 10000,
+        ID_RICHTEXTFONTPAGE_FACETEXTCTRL = 10001,
+        ID_RICHTEXTFONTPAGE_FACELISTBOX = 10002,
+        ID_RICHTEXTFONTPAGE_SIZETEXTCTRL = 10005,
+        ID_RICHTEXTFONTPAGE_SIZELISTBOX = 10006,
+        ID_RICHTEXTFONTPAGE_STYLECTRL = 10007,
+        ID_RICHTEXTFONTPAGE_WEIGHTCTRL = 10004,
+        ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL = 10008,
+        ID_RICHTEXTFONTPAGE_COLOURCTRL = 10009,
+        ID_RICHTEXTFONTPAGE_PREVIEWCTRL = 10003
+    };
+////@end wxRichTextFontPage member variables
+
+    bool m_dontUpdate;
+    bool m_colourPresent;
+};
+
+#endif
+    // _RICHTEXTFONTPAGE_H_
diff --git a/include/wx/richtext/richtextformatdlg.h b/include/wx/richtext/richtextformatdlg.h
new file mode 100644 (file)
index 0000000..234594d
--- /dev/null
@@ -0,0 +1,280 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        wx/richtext/richtextformatdlg.h
+// Purpose:     Formatting dialog for wxRichTextCtrl
+// Author:      Julian Smart
+// Modified by:
+// Created:     2006-10-01
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_RICHTEXTFORMATDLG_H_
+#define _WX_RICHTEXTFORMATDLG_H_
+
+/*!
+ * Includes
+ */
+
+#include "wx/defs.h"
+
+#if wxUSE_RICHTEXT
+
+#include "wx/propdlg.h"
+#if wxUSE_HTML
+#include "wx/htmllbox.h"
+#endif
+
+#include "wx/richtext/richtextbuffer.h"
+#include "wx/richtext/richtextstyles.h"
+
+class WXDLLEXPORT wxNotebookEvent;
+class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog;
+
+/*!
+ * Flags determining the pages to be created in the dialog
+ */
+
+#define wxRICHTEXT_FORMAT_STYLE_EDITOR      0x0001
+#define wxRICHTEXT_FORMAT_FONT              0x0002
+#define wxRICHTEXT_FORMAT_TABS              0x0004
+#define wxRICHTEXT_FORMAT_BULLETS           0x0008
+#define wxRICHTEXT_FORMAT_INDENTS_SPACING   0x0010
+
+/*!
+ * Shorthand for common combinations of pages
+ */
+
+#define wxRICHTEXT_FORMAT_PARAGRAPH         (wxRICHTEXT_FORMAT_INDENTS_SPACING | wxRICHTEXT_FORMAT_BULLETS | wxRICHTEXT_FORMAT_TABS | wxRICHTEXT_FORMAT_FONT)
+#define wxRICHTEXT_FORMAT_CHARACTER         (wxRICHTEXT_FORMAT_FONT)
+#define wxRICHTEXT_FORMAT_STYLE             (wxRICHTEXT_FORMAT_PARAGRAPH | wxRICHTEXT_FORMAT_STYLE_EDITOR)
+
+/*!
+ * Factory for formatting dialog
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialogFactory: public wxObject
+{
+public:
+    wxRichTextFormattingDialogFactory() {}
+    virtual ~wxRichTextFormattingDialogFactory() {}
+
+// Overrideables
+
+    /// Create all pages, under the dialog's book control, also calling AddPage
+    virtual bool CreatePages(long pages, wxRichTextFormattingDialog* dialog);
+
+    /// Create a page, given a page identifier
+    virtual wxPanel* CreatePage(int page, wxString& title, wxRichTextFormattingDialog* dialog);
+
+    /// Enumerate all available page identifiers
+    virtual int GetPageId(int i) const;
+
+    /// Get the number of available page identifiers
+    virtual int GetPageIdCount() const;
+
+    /// Get the image index for the given page identifier
+    virtual int GetPageImage(int WXUNUSED(id)) const { return -1; }
+
+    /// Invoke help for the dialog
+    virtual bool ShowHelp(int WXUNUSED(page), wxRichTextFormattingDialog* WXUNUSED(dialog)) { return false; }
+
+    /// Set the sheet style, called at the start of wxRichTextFormattingDialog::Create
+    virtual bool SetSheetStyle(wxRichTextFormattingDialog* dialog);
+
+    /// Create the main dialog buttons
+    virtual bool CreateButtons(wxRichTextFormattingDialog* dialog);
+};
+
+/*!
+ * Formatting dialog for a wxRichTextCtrl
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog: public wxPropertySheetDialog
+{
+DECLARE_CLASS(wxRichTextFormattingDialog)
+public:
+    wxRichTextFormattingDialog() { Init(); }
+
+    wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = _("Formatting"), wxWindowID id = wxID_ANY,
+        const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize,
+        long style = wxDEFAULT_DIALOG_STYLE)
+    {
+        Init();
+        Create(flags, parent, title, id, pos, sz, style);
+    }
+
+    ~wxRichTextFormattingDialog();
+
+    void Init();
+
+    bool Create(long flags, wxWindow* parent, const wxString& title, wxWindowID id,
+        const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize,
+        long style = wxDEFAULT_DIALOG_STYLE);
+
+    /// Get attributes from the given range
+    virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range);
+
+    /// Set the attributes and optionally update the display
+    virtual bool SetStyle(const wxTextAttrEx& style, bool update = true);
+
+    /// Set the style definition and optionally update the display
+    virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update = true);
+
+    /// Get the style definition, if any
+    virtual wxRichTextStyleDefinition* GetStyleDefinition() const { return m_styleDefinition; }
+
+    /// Get the style sheet, if any
+    virtual wxRichTextStyleSheet* GetStyleSheet() const { return m_styleSheet; }
+
+    /// Update the display
+    virtual bool UpdateDisplay();
+
+    /// Apply attributes to the given range
+    virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE);
+
+    /// Gets and sets the attributes
+    const wxTextAttrEx& GetAttributes() const { return m_attributes; }
+    wxTextAttrEx& GetAttributes() { return m_attributes; }
+    void SetAttributes(const wxTextAttrEx& attr) { m_attributes = attr; }
+
+    /// Transfers the data and from to the window
+    virtual bool TransferDataToWindow();
+    virtual bool TransferDataFromWindow();
+
+    /// Apply the styles when a different tab is selected, so the previews are
+    /// up to date
+    void OnTabChanged(wxNotebookEvent& event);
+
+    /// Set/get image list
+    void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
+    wxImageList* GetImageList() const { return m_imageList; }
+
+    /// Get/set formatting factory object
+    static void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory);
+    static wxRichTextFormattingDialogFactory* GetFormattingDialogFactory() { return ms_FormattingDialogFactory; }
+
+    /// Helper for pages to get the top-level dialog
+    static wxRichTextFormattingDialog* GetDialog(wxWindow* win);
+
+    /// Helper for pages to get the attributes
+    static wxTextAttrEx* GetDialogAttributes(wxWindow* win);
+
+    /// Helper for pages to get the style
+    static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
+
+protected:
+
+    wxImageList*                                m_imageList;
+    wxTextAttrEx                                m_attributes;
+    wxRichTextStyleDefinition*                  m_styleDefinition;
+    wxRichTextStyleSheet*                       m_styleSheet;
+
+    static wxRichTextFormattingDialogFactory*   ms_FormattingDialogFactory;
+
+DECLARE_EVENT_TABLE()
+};
+
+//-----------------------------------------------------------------------------
+// helper class - wxRichTextFontPreviewCtrl
+//-----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFontPreviewCtrl : public wxWindow
+{
+public:
+    wxRichTextFontPreviewCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = 0) :
+        wxWindow(parent, id, pos, sz, style)
+    {
+        SetBackgroundColour(*wxWHITE);
+    }
+
+private:
+    void OnPaint(wxPaintEvent& event);
+    DECLARE_EVENT_TABLE()
+};
+
+/*
+ * A control for displaying a small preview of a colour or bitmap
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextColourSwatchCtrl: public wxControl
+{
+    DECLARE_CLASS(wxRichTextColourSwatchCtrl)
+public:
+    wxRichTextColourSwatchCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0);
+    ~wxRichTextColourSwatchCtrl();
+
+    void OnPaint(wxPaintEvent& event);
+    void OnMouseEvent(wxMouseEvent& event);
+
+    void SetColour(const wxColour& colour) { m_colour = colour; SetBackgroundColour(m_colour); }
+
+    wxColour& GetColour() { return m_colour; }
+
+    virtual wxSize DoGetBestSize() const { return GetSize(); }
+
+protected:
+    wxColour    m_colour;
+
+DECLARE_EVENT_TABLE()
+};
+
+/*!
+ * wxRichTextFontListBox class declaration
+ * A listbox to display fonts.
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextFontListBox: public wxHtmlListBox
+{
+    DECLARE_CLASS(wxRichTextFontListBox)
+    DECLARE_EVENT_TABLE()
+
+public:
+    wxRichTextFontListBox()
+    {
+        Init();
+    }
+    wxRichTextFontListBox(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
+        const wxSize& size = wxDefaultSize, long style = 0);
+    virtual ~wxRichTextFontListBox();
+
+    void Init()
+    {
+    }
+
+    bool Create(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
+        const wxSize& size = wxDefaultSize, long style = 0);
+
+    /// Creates a suitable HTML fragment for a font
+    wxString CreateHTML(const wxString& facename) const;
+
+    /// Get font name for index
+    wxString GetFaceName(size_t i) const ;
+
+    /// Set selection for string, returning the index.
+    int SetFaceNameSelection(const wxString& name);
+
+    /// Updates the font list
+    void UpdateFonts();
+
+    /// Does this face name exist?
+    bool HasFaceName(const wxString& faceName) const { return m_faceNames.Index(faceName) != wxNOT_FOUND; }
+
+    /// Returns the array of face names
+    const wxArrayString& GetFaceNames() const { return m_faceNames; }
+
+protected:
+    /// Returns the HTML for this item
+    virtual wxString OnGetItem(size_t n) const;
+
+private:
+
+    wxArrayString           m_faceNames;
+};
+
+#endif
+    // wxUSE_RICHTEXT
+
+#endif
+    // _WX_RICHTEXTFORMATDLG_H_
+
diff --git a/include/wx/richtext/richtextindentspage.h b/include/wx/richtext/richtextindentspage.h
new file mode 100644 (file)
index 0000000..eb61c59
--- /dev/null
@@ -0,0 +1,168 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtextindentspage.h
+// Purpose:
+// Author:      Julian Smart
+// Modified by:
+// Created:     10/3/2006 2:28:21 PM
+// RCS-ID:
+// Copyright:   (c) Julian Smart
+// Licence:
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _RICHTEXTINDENTSPAGE_H_
+#define _RICHTEXTINDENTSPAGE_H_
+
+/*!
+ * Includes
+ */
+
+////@begin includes
+#include "wx/statline.h"
+////@end includes
+
+/*!
+ * Forward declarations
+ */
+
+////@begin forward declarations
+class wxRichTextCtrl;
+////@end forward declarations
+
+/*!
+ * Control identifiers
+ */
+
+////@begin control identifiers
+#define SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL
+#define SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_TITLE _("wxRichTextFontPage")
+#define SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_IDNAME ID_RICHTEXTINDENTSSPACINGPAGE
+#define SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_SIZE wxSize(400, 300)
+#define SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_POSITION wxDefaultPosition
+////@end control identifiers
+
+/*!
+ * Compatibility
+ */
+
+#ifndef wxCLOSE_BOX
+#define wxCLOSE_BOX 0x1000
+#endif
+
+/*!
+ * wxRichTextIndentsSpacingPage class declaration
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextIndentsSpacingPage: public wxPanel
+{
+    DECLARE_DYNAMIC_CLASS( wxRichTextIndentsSpacingPage )
+    DECLARE_EVENT_TABLE()
+
+public:
+    /// Constructors
+    wxRichTextIndentsSpacingPage( );
+    wxRichTextIndentsSpacingPage( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_SIZE, long style = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_STYLE );
+
+    /// Creation
+    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_SIZE, long style = SYMBOL_WXRICHTEXTINDENTSSPACINGPAGE_STYLE );
+
+    /// Initialise members
+    void Init();
+
+    /// Creates the controls and sizers
+    void CreateControls();
+
+    /// Transfer data from/to window
+    virtual bool TransferDataFromWindow();
+    virtual bool TransferDataToWindow();
+
+    /// Updates the paragraph preview
+    void UpdatePreview();
+
+    /// Gets the attributes associated with the main formatting dialog
+    wxTextAttrEx* GetAttributes();
+
+////@begin wxRichTextIndentsSpacingPage event handler declarations
+
+    /// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
+    void OnAlignmentLeftSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
+    void OnAlignmentRightSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
+    void OnAlignmentJustifiedSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
+    void OnAlignmentCentredSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
+    void OnAlignmentIndeterminateSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
+    void OnIndentLeftUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
+    void OnIndentLeftFirstUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
+    void OnIndentRightUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
+    void OnSpacingBeforeUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
+    void OnSpacingAfterUpdated( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
+    void OnSpacingLineSelected( wxCommandEvent& event );
+
+////@end wxRichTextIndentsSpacingPage event handler declarations
+
+////@begin wxRichTextIndentsSpacingPage member function declarations
+
+    /// Retrieves bitmap resources
+    wxBitmap GetBitmapResource( const wxString& name );
+
+    /// Retrieves icon resources
+    wxIcon GetIconResource( const wxString& name );
+////@end wxRichTextIndentsSpacingPage member function declarations
+
+    /// Should we show tooltips?
+    static bool ShowToolTips();
+
+////@begin wxRichTextIndentsSpacingPage member variables
+    wxRadioButton* m_alignmentLeft;
+    wxRadioButton* m_alignmentRight;
+    wxRadioButton* m_alignmentJustified;
+    wxRadioButton* m_alignmentCentred;
+    wxRadioButton* m_alignmentIndeterminate;
+    wxTextCtrl* m_indentLeft;
+    wxTextCtrl* m_indentLeftFirst;
+    wxTextCtrl* m_indentRight;
+    wxTextCtrl* m_spacingBefore;
+    wxTextCtrl* m_spacingAfter;
+    wxComboBox* m_spacingLine;
+    wxRichTextCtrl* m_previewCtrl;
+    /// Control identifiers
+    enum {
+        ID_RICHTEXTINDENTSSPACINGPAGE = 10100,
+        ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT = 10102,
+        ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT = 10110,
+        ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED = 10111,
+        ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED = 10112,
+        ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE = 10101,
+        ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT = 10103,
+        ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST = 10104,
+        ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT = 10113,
+        ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE = 10114,
+        ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER = 10116,
+        ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE = 10115,
+        ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL = 10109
+    };
+////@end wxRichTextIndentsSpacingPage member variables
+
+    bool m_dontUpdate;
+};
+
+#endif
+    // _RICHTEXTINDENTSPAGE_H_
diff --git a/include/wx/richtext/richtextstylepage.h b/include/wx/richtext/richtextstylepage.h
new file mode 100644 (file)
index 0000000..76db0aa
--- /dev/null
@@ -0,0 +1,113 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtextstylepage.h
+// Purpose:     
+// Author:      Julian Smart
+// Modified by: 
+// Created:     10/5/2006 11:34:55 AM
+// RCS-ID:      
+// Copyright:   (c) Julian Smart
+// Licence:     
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _RICHTEXTSTYLEPAGE_H_
+#define _RICHTEXTSTYLEPAGE_H_
+
+/*!
+ * Includes
+ */
+
+////@begin includes
+////@end includes
+
+/*!
+ * Forward declarations
+ */
+
+////@begin forward declarations
+////@end forward declarations
+
+/*!
+ * Control identifiers
+ */
+
+////@begin control identifiers
+#define SYMBOL_WXRICHTEXTSTYLEPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL
+#define SYMBOL_WXRICHTEXTSTYLEPAGE_TITLE _("wxRichTextStylePage")
+#define SYMBOL_WXRICHTEXTSTYLEPAGE_IDNAME ID_RICHTEXTSTYLEPAGE
+#define SYMBOL_WXRICHTEXTSTYLEPAGE_SIZE wxSize(400, 300)
+#define SYMBOL_WXRICHTEXTSTYLEPAGE_POSITION wxDefaultPosition
+////@end control identifiers
+
+/*!
+ * Compatibility
+ */
+
+#ifndef wxCLOSE_BOX
+#define wxCLOSE_BOX 0x1000
+#endif
+
+/*!
+ * wxRichTextStylePage class declaration
+ */
+
+class wxRichTextStylePage: public wxPanel
+{    
+    DECLARE_DYNAMIC_CLASS( wxRichTextStylePage )
+    DECLARE_EVENT_TABLE()
+
+public:
+    /// Constructors
+    wxRichTextStylePage( );
+    wxRichTextStylePage( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTSTYLEPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTSTYLEPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTSTYLEPAGE_SIZE, long style = SYMBOL_WXRICHTEXTSTYLEPAGE_STYLE );
+
+    /// Creation
+    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTSTYLEPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTSTYLEPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTSTYLEPAGE_SIZE, long style = SYMBOL_WXRICHTEXTSTYLEPAGE_STYLE );
+    
+    /// Initialise members
+    void Init();
+
+    /// Creates the controls and sizers
+    void CreateControls();
+
+    /// Transfer data from/to window
+    virtual bool TransferDataFromWindow();
+    virtual bool TransferDataToWindow();
+
+    /// Gets the attributes associated with the main formatting dialog
+    wxTextAttrEx* GetAttributes();
+
+////@begin wxRichTextStylePage event handler declarations
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
+    void OnNextStyleUpdate( wxUpdateUIEvent& event );
+
+////@end wxRichTextStylePage event handler declarations
+
+////@begin wxRichTextStylePage member function declarations
+
+    /// Retrieves bitmap resources
+    wxBitmap GetBitmapResource( const wxString& name );
+
+    /// Retrieves icon resources
+    wxIcon GetIconResource( const wxString& name );
+////@end wxRichTextStylePage member function declarations
+
+    /// Should we show tooltips?
+    static bool ShowToolTips();
+
+////@begin wxRichTextStylePage member variables
+    wxTextCtrl* m_styleName;
+    wxComboBox* m_basedOn;
+    wxComboBox* m_nextStyle;
+    /// Control identifiers
+    enum {
+        ID_RICHTEXTSTYLEPAGE = 10403,
+        ID_RICHTEXTSTYLEPAGE_STYLE_NAME = 10404,
+        ID_RICHTEXTSTYLEPAGE_BASED_ON = 10405,
+        ID_RICHTEXTSTYLEPAGE_NEXT_STYLE = 10406
+    };
+////@end wxRichTextStylePage member variables
+};
+
+#endif
+    // _RICHTEXTSTYLEPAGE_H_
diff --git a/include/wx/richtext/richtexttabspage.h b/include/wx/richtext/richtexttabspage.h
new file mode 100644 (file)
index 0000000..b3fa7c4
--- /dev/null
@@ -0,0 +1,137 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtexttabspage.h
+// Purpose:
+// Author:      Julian Smart
+// Modified by:
+// Created:     10/4/2006 8:03:20 AM
+// RCS-ID:
+// Copyright:   (c) Julian Smart
+// Licence:
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _RICHTEXTTABSPAGE_H_
+#define _RICHTEXTTABSPAGE_H_
+
+/*!
+ * Includes
+ */
+
+////@begin includes
+////@end includes
+
+/*!
+ * Forward declarations
+ */
+
+////@begin forward declarations
+////@end forward declarations
+
+/*!
+ * Control identifiers
+ */
+
+////@begin control identifiers
+#define SYMBOL_WXRICHTEXTTABSPAGE_STYLE wxRESIZE_BORDER|wxTAB_TRAVERSAL
+#define SYMBOL_WXRICHTEXTTABSPAGE_TITLE _("wxRichTextFontPage")
+#define SYMBOL_WXRICHTEXTTABSPAGE_IDNAME ID_RICHTEXTTABSPAGE
+#define SYMBOL_WXRICHTEXTTABSPAGE_SIZE wxSize(400, 300)
+#define SYMBOL_WXRICHTEXTTABSPAGE_POSITION wxDefaultPosition
+////@end control identifiers
+
+/*!
+ * Compatibility
+ */
+
+#ifndef wxCLOSE_BOX
+#define wxCLOSE_BOX 0x1000
+#endif
+
+/*!
+ * wxRichTextTabsPage class declaration
+ */
+
+class WXDLLIMPEXP_RICHTEXT wxRichTextTabsPage: public wxPanel
+{
+    DECLARE_DYNAMIC_CLASS( wxRichTextTabsPage )
+    DECLARE_EVENT_TABLE()
+
+public:
+    /// Constructors
+    wxRichTextTabsPage( );
+    wxRichTextTabsPage( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTTABSPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTTABSPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTTABSPAGE_SIZE, long style = SYMBOL_WXRICHTEXTTABSPAGE_STYLE );
+
+    /// Creation
+    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_WXRICHTEXTTABSPAGE_IDNAME, const wxPoint& pos = SYMBOL_WXRICHTEXTTABSPAGE_POSITION, const wxSize& size = SYMBOL_WXRICHTEXTTABSPAGE_SIZE, long style = SYMBOL_WXRICHTEXTTABSPAGE_STYLE );
+
+    /// Creates the controls and sizers
+    void CreateControls();
+
+    /// Initialise members
+    void Init();
+
+    /// Transfer data from/to window
+    virtual bool TransferDataFromWindow();
+    virtual bool TransferDataToWindow();
+
+    /// Sorts the tab array
+    virtual void SortTabs();
+
+    /// Gets the attributes associated with the main formatting dialog
+    wxTextAttrEx* GetAttributes();
+
+////@begin wxRichTextTabsPage event handler declarations
+
+    /// wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTTABSPAGE_TABLIST
+    void OnTablistSelected( wxCommandEvent& event );
+
+    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTTABSPAGE_NEW_TAB
+    void OnNewTabClick( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTTABSPAGE_NEW_TAB
+    void OnNewTabUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTTABSPAGE_DELETE_TAB
+    void OnDeleteTabClick( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTTABSPAGE_DELETE_TAB
+    void OnDeleteTabUpdate( wxUpdateUIEvent& event );
+
+    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS
+    void OnDeleteAllTabsClick( wxCommandEvent& event );
+
+    /// wxEVT_UPDATE_UI event handler for ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS
+    void OnDeleteAllTabsUpdate( wxUpdateUIEvent& event );
+
+////@end wxRichTextTabsPage event handler declarations
+
+////@begin wxRichTextTabsPage member function declarations
+
+    /// Retrieves bitmap resources
+    wxBitmap GetBitmapResource( const wxString& name );
+
+    /// Retrieves icon resources
+    wxIcon GetIconResource( const wxString& name );
+////@end wxRichTextTabsPage member function declarations
+
+    /// Should we show tooltips?
+    static bool ShowToolTips();
+
+////@begin wxRichTextTabsPage member variables
+    wxTextCtrl* m_tabEditCtrl;
+    wxListBox* m_tabListCtrl;
+    /// Control identifiers
+    enum {
+        ID_RICHTEXTTABSPAGE = 10200,
+        ID_RICHTEXTTABSPAGE_TABEDIT = 10213,
+        ID_RICHTEXTTABSPAGE_TABLIST = 10214,
+        ID_RICHTEXTTABSPAGE_NEW_TAB = 10201,
+        ID_RICHTEXTTABSPAGE_DELETE_TAB = 10202,
+        ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS = 10203
+    };
+////@end wxRichTextTabsPage member variables
+
+    bool m_tabsPresent;
+};
+
+#endif
+    // _RICHTEXTTABSPAGE_H_
diff --git a/src/richtext/richtextbulletspage.cpp b/src/richtext/richtextbulletspage.cpp
new file mode 100644 (file)
index 0000000..740ad08
--- /dev/null
@@ -0,0 +1,691 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtextbulletspage.cpp
+// Purpose:
+// Author:      Julian Smart
+// Modified by:
+// Created:     10/4/2006 10:32:31 AM
+// RCS-ID:
+// Copyright:   (c) Julian Smart
+// Licence:
+/////////////////////////////////////////////////////////////////////////////
+
+////@begin includes
+////@end includes
+
+#include "../../include/wx/richtext/richtextbulletspage.h"
+#include "wx/richtext/richtextsymboldlg.h"
+#include "wx/fontenum.h"
+
+////@begin XPM images
+////@end XPM images
+
+/*!
+ * wxRichTextBulletsPage type definition
+ */
+
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextBulletsPage, wxPanel )
+
+/*!
+ * wxRichTextBulletsPage event table definition
+ */
+
+BEGIN_EVENT_TABLE( wxRichTextBulletsPage, wxPanel )
+
+////@begin wxRichTextBulletsPage event table entries
+    EVT_LISTBOX( ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxRichTextBulletsPage::OnStylelistboxSelected )
+
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, wxRichTextBulletsPage::OnSymbolstaticUpdate )
+
+    EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlSelected )
+    EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlUpdated )
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, wxRichTextBulletsPage::OnSymbolctrlUpdate )
+
+    EVT_BUTTON( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, wxRichTextBulletsPage::OnChooseSymbolClick )
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, wxRichTextBulletsPage::OnChooseSymbolUpdate )
+
+    EVT_COMBOBOX( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlSelected )
+    EVT_TEXT( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlUpdated )
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate )
+
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, wxRichTextBulletsPage::OnNumberstaticUpdate )
+
+    EVT_SPINCTRL( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUpdated )
+    EVT_SPIN_UP( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUp )
+    EVT_SPIN_DOWN( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlDown )
+    EVT_TEXT( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlTextUpdated )
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, wxRichTextBulletsPage::OnNumberctrlUpdate )
+
+    EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlClick )
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, wxRichTextBulletsPage::OnParenthesesctrlUpdate )
+
+    EVT_CHECKBOX( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlClick )
+    EVT_UPDATE_UI( ID_RICHTEXTBULLETSPAGE_PERIODCTRL, wxRichTextBulletsPage::OnPeriodctrlUpdate )
+
+////@end wxRichTextBulletsPage event table entries
+
+END_EVENT_TABLE()
+
+/*!
+ * wxRichTextBulletsPage constructors
+ */
+
+wxRichTextBulletsPage::wxRichTextBulletsPage( )
+{
+    Init();
+}
+
+wxRichTextBulletsPage::wxRichTextBulletsPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+    Init();
+    Create(parent, id, pos, size, style);
+}
+
+/*!
+ * Initialise members
+ */
+void wxRichTextBulletsPage::Init()
+{
+    m_hasBulletStyle = false;
+    m_hasBulletNumber = false;
+    m_hasBulletSymbol = false;
+    m_dontUpdate = false;
+
+////@begin wxRichTextBulletsPage member initialisation
+    m_styleListBox = NULL;
+    m_symbolCtrl = NULL;
+    m_symbolFontCtrl = NULL;
+    m_numberCtrl = NULL;
+    m_parenthesesCtrl = NULL;
+    m_periodCtrl = NULL;
+    m_previewCtrl = NULL;
+////@end wxRichTextBulletsPage member initialisation
+}
+
+/*!
+ * wxRichTextBulletsPage creator
+ */
+
+bool wxRichTextBulletsPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+////@begin wxRichTextBulletsPage creation
+    wxPanel::Create( parent, id, pos, size, style );
+
+    CreateControls();
+    if (GetSizer())
+    {
+        GetSizer()->SetSizeHints(this);
+    }
+    Centre();
+////@end wxRichTextBulletsPage creation
+    return true;
+}
+
+/*!
+ * Control creation for wxRichTextBulletsPage
+ */
+
+void wxRichTextBulletsPage::CreateControls()
+{
+////@begin wxRichTextBulletsPage content construction
+    wxRichTextBulletsPage* itemPanel1 = this;
+
+    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
+    itemPanel1->SetSizer(itemBoxSizer2);
+
+    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5);
+
+    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Bullet style:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_styleListBoxStrings = NULL;
+    m_styleListBox = new wxListBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_STYLELISTBOX, wxDefaultPosition, wxDefaultSize, 0, m_styleListBoxStrings, wxLB_SINGLE );
+    itemBoxSizer5->Add(m_styleListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxStaticLine* itemStaticLine9 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
+    itemBoxSizer4->Add(itemStaticLine9, 0, wxGROW|wxALL, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxBoxSizer* itemBoxSizer11 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer11, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText12 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("&Symbol:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer11->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer11->Add(itemBoxSizer13, 0, wxGROW, 5);
+
+    wxString* m_symbolCtrlStrings = NULL;
+    m_symbolCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL, _T(""), wxDefaultPosition, wxSize(60, -1), 0, m_symbolCtrlStrings, wxCB_DROPDOWN );
+    itemBoxSizer13->Add(m_symbolCtrl, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxFIXED_MINSIZE, 5);
+
+    wxButton* itemButton15 = new wxButton( itemPanel1, ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL, _("Ch&oose..."), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer13->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    itemBoxSizer11->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    wxStaticText* itemStaticText17 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC, _("Symbol &font:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer11->Add(itemStaticText17, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_symbolFontCtrlStrings = NULL;
+    m_symbolFontCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_symbolFontCtrlStrings, wxCB_DROPDOWN );
+    itemBoxSizer11->Add(m_symbolFontCtrl, 0, wxGROW|wxALL, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxStaticLine* itemStaticLine20 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
+    itemBoxSizer4->Add(itemStaticLine20, 0, wxGROW|wxALL, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer22, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText23 = new wxStaticText( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC, _("&Number:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer22->Add(itemStaticText23, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    m_numberCtrl = new wxSpinCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_NUMBERCTRL, _T("0"), wxDefaultPosition, wxSize(50, -1), wxSP_ARROW_KEYS, 0, 100000, 0 );
+    itemBoxSizer22->Add(m_numberCtrl, 0, wxGROW|wxALL, 5);
+
+    itemBoxSizer22->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    m_parenthesesCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL, _("&Parentheses"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_parenthesesCtrl->SetValue(false);
+    itemBoxSizer22->Add(m_parenthesesCtrl, 0, wxALIGN_LEFT|wxALL, 5);
+
+    m_periodCtrl = new wxCheckBox( itemPanel1, ID_RICHTEXTBULLETSPAGE_PERIODCTRL, _("Peri&od"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_periodCtrl->SetValue(false);
+    itemBoxSizer22->Add(m_periodCtrl, 0, wxALIGN_LEFT|wxALL, 5);
+
+    itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTBULLETSPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER );
+    m_previewCtrl->SetHelpText(_("Shows a preview of the bullet settings."));
+    if (ShowToolTips())
+        m_previewCtrl->SetToolTip(_("Shows a preview of the bullet settings."));
+    itemBoxSizer3->Add(m_previewCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+////@end wxRichTextBulletsPage content construction
+
+    m_styleListBox->Append(_("(None)"));
+    m_styleListBox->Append(_("Arabic"));
+    m_styleListBox->Append(_("Upper case letters"));
+    m_styleListBox->Append(_("Lower case letters"));
+    m_styleListBox->Append(_("Upper case roman numerals"));
+    m_styleListBox->Append(_("Lower case roman numerals"));
+    m_styleListBox->Append(_("Symbol"));
+    m_styleListBox->Append(_("Bitmap"));
+
+    m_symbolCtrl->Append(_("*"));
+    m_symbolCtrl->Append(_("-"));
+    m_symbolCtrl->Append(_(">"));
+    m_symbolCtrl->Append(_("+"));
+    m_symbolCtrl->Append(_("~"));
+    
+    wxFontEnumerator enumerator;
+    enumerator.EnumerateFacenames();
+    wxArrayString facenames = enumerator.GetFacenames();
+    facenames.Sort();
+    
+    m_symbolFontCtrl->Append(facenames);
+}
+
+/// Transfer data from/to window
+bool wxRichTextBulletsPage::TransferDataFromWindow()
+{
+    wxPanel::TransferDataFromWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (m_hasBulletStyle)
+    {
+        long bulletStyle = 0;
+
+        int index = m_styleListBox->GetSelection();
+        if (index == 1)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ARABIC;
+        else if (index == 2)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER;
+        else if (index == 3)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER;
+        else if (index == 4)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER;
+        else if (index == 5)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER;
+        else if (index == 6)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_SYMBOL;
+        else if (index == 7)
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_BITMAP;
+
+        if (m_parenthesesCtrl->GetValue())
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_PARENTHESES;
+        if (m_periodCtrl->GetValue())
+            bulletStyle |= wxTEXT_ATTR_BULLET_STYLE_PERIOD;
+
+        attr->SetBulletStyle(bulletStyle);
+    }
+
+    if (m_hasBulletNumber)
+    {
+        attr->SetBulletNumber(m_numberCtrl->GetValue());
+    }
+
+    if (m_hasBulletSymbol)
+    {
+        wxChar c(wxT('*'));
+        if (m_symbolCtrl->GetValue().Length() > 0)
+            c = m_symbolCtrl->GetValue()[0];
+        attr->SetBulletSymbol(c);
+        attr->SetBulletFont(m_symbolFontCtrl->GetValue());
+    }
+    return true;
+}
+
+bool wxRichTextBulletsPage::TransferDataToWindow()
+{
+    m_dontUpdate = true;
+
+    wxPanel::TransferDataToWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (attr->HasBulletStyle())
+    {
+        int index = -1;
+        if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ARABIC)
+            index = 1;
+        else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_UPPER)
+            index = 2;
+        else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_LETTERS_LOWER)
+            index = 3;
+        else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_UPPER)
+            index = 4;
+        else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_ROMAN_LOWER)
+            index = 5;
+        else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_SYMBOL)
+            index = 6;
+        else if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_BITMAP)
+            index = 7;
+        m_styleListBox->SetSelection(index);
+
+        if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PARENTHESES)
+            m_parenthesesCtrl->SetValue(true);
+        else
+            m_parenthesesCtrl->SetValue(false);
+
+        if (attr->GetBulletStyle() & wxTEXT_ATTR_BULLET_STYLE_PERIOD)
+            m_periodCtrl->SetValue(true);
+        else
+            m_periodCtrl->SetValue(false);        
+    }
+    else
+        m_styleListBox->SetSelection(-1);
+
+    if (attr->HasBulletSymbol())
+    {
+        wxChar c = attr->GetBulletSymbol();
+        wxString s;
+        s << c;
+        m_symbolCtrl->SetValue(s);
+        m_symbolFontCtrl->SetValue(attr->GetBulletFont());
+    }
+    else
+        m_symbolCtrl->SetValue(wxEmptyString);
+
+    if (attr->HasBulletNumber())
+        m_numberCtrl->SetValue(attr->GetBulletNumber());
+    else
+        m_numberCtrl->SetValue(0);
+
+    UpdatePreview();
+
+    m_dontUpdate = false;
+
+    return true;
+}
+
+/// Updates the bullet preview
+void wxRichTextBulletsPage::UpdatePreview()
+{
+    static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
+Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
+
+    static const wxChar* s_para2 = wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
+et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
+
+    static const wxChar* s_para3 = wxT("\nInteger convallis dolor at augue \
+iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
+
+    TransferDataFromWindow();
+    wxTextAttrEx attr(*GetAttributes());
+    attr.SetFlags(attr.GetFlags() &
+      (wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL|
+       wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
+       wxTEXT_ATTR_LINE_SPACING));
+
+    wxFont font(m_previewCtrl->GetFont());
+    font.SetPointSize(9);
+    m_previewCtrl->SetFont(font);
+
+    font.SetWeight(wxBOLD);
+    attr.SetFont(font);
+
+    m_previewCtrl->Clear();
+
+    m_previewCtrl->WriteText(s_para1);
+    m_previewCtrl->BeginStyle(attr);
+    m_previewCtrl->WriteText(s_para2);
+    m_previewCtrl->EndStyle();
+    m_previewCtrl->WriteText(s_para3);
+}
+
+wxTextAttrEx* wxRichTextBulletsPage::GetAttributes()
+{
+    return wxRichTextFormattingDialog::GetDialogAttributes(this);
+}
+
+/*!
+ * Should we show tooltips?
+ */
+
+bool wxRichTextBulletsPage::ShowToolTips()
+{
+    return true;
+}
+
+/*!
+ * Get bitmap resources
+ */
+
+wxBitmap wxRichTextBulletsPage::GetBitmapResource( const wxString& name )
+{
+    // Bitmap retrieval
+////@begin wxRichTextBulletsPage bitmap retrieval
+    wxUnusedVar(name);
+    return wxNullBitmap;
+////@end wxRichTextBulletsPage bitmap retrieval
+}
+
+/*!
+ * Get icon resources
+ */
+
+wxIcon wxRichTextBulletsPage::GetIconResource( const wxString& name )
+{
+    // Icon retrieval
+////@begin wxRichTextBulletsPage icon retrieval
+    wxUnusedVar(name);
+    return wxNullIcon;
+////@end wxRichTextBulletsPage icon retrieval
+}
+
+/*!
+ * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_STYLELISTBOX
+ */
+
+void wxRichTextBulletsPage::OnStylelistboxSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletStyle = true;
+
+        if (m_styleListBox->GetSelection() == 6)
+            m_hasBulletSymbol = true;
+
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
+ */
+
+void wxRichTextBulletsPage::OnSymbolctrlSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletSymbol = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
+ */
+
+void wxRichTextBulletsPage::OnSymbolctrlUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletSymbol = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLCTRL
+ */
+
+void wxRichTextBulletsPage::OnSymbolctrlUpdate( wxUpdateUIEvent& event )
+{
+    OnSymbolUpdate(event);
+}
+
+/*!
+ * wxEVT_COMMAND_SPINCTRL_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+ */
+
+void wxRichTextBulletsPage::OnNumberctrlUpdated( wxSpinEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletNumber = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_SCROLL_LINEUP event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+ */
+
+void wxRichTextBulletsPage::OnNumberctrlUp( wxSpinEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletNumber = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_SCROLL_LINEDOWN event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+ */
+
+void wxRichTextBulletsPage::OnNumberctrlDown( wxSpinEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletNumber = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+ */
+
+void wxRichTextBulletsPage::OnNumberctrlTextUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletNumber = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERCTRL
+ */
+
+void wxRichTextBulletsPage::OnNumberctrlUpdate( wxUpdateUIEvent& event )
+{
+    OnNumberUpdate(event);
+}
+
+/*!
+ * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
+ */
+
+void wxRichTextBulletsPage::OnParenthesesctrlClick( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletStyle = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PARENTHESESCTRL
+ */
+
+void wxRichTextBulletsPage::OnParenthesesctrlUpdate( wxUpdateUIEvent& event )
+{
+    int sel = m_styleListBox->GetSelection();
+    event.Enable(m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0));
+}
+
+/*!
+ * wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
+ */
+
+void wxRichTextBulletsPage::OnPeriodctrlClick( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+    {
+        m_hasBulletStyle = true;
+        UpdatePreview();
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_PERIODCTRL
+ */
+
+void wxRichTextBulletsPage::OnPeriodctrlUpdate( wxUpdateUIEvent& event )
+{
+    int sel = m_styleListBox->GetSelection();
+    event.Enable(m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0));
+}
+
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
+ */
+
+void wxRichTextBulletsPage::OnChooseSymbolClick( wxCommandEvent& WXUNUSED(event) )
+{
+    int sel = m_styleListBox->GetSelection();
+    if (m_hasBulletStyle && sel == 6)
+    {
+        wxString symbol = m_symbolCtrl->GetValue();
+        wxString fontName = m_symbolFontCtrl->GetValue();
+        wxSymbolPickerDialog dlg(symbol, fontName, fontName, this);
+
+        if (dlg.ShowModal() == wxID_OK)
+        {
+            m_dontUpdate = true;
+            
+            m_symbolCtrl->SetValue(dlg.GetSymbol());
+            m_symbolFontCtrl->SetValue(dlg.GetFontName());
+            
+            UpdatePreview();
+
+            m_dontUpdate = false;
+        }
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_CHOOSE_SYMBOL
+ */
+
+void wxRichTextBulletsPage::OnChooseSymbolUpdate( wxUpdateUIEvent& event )
+{
+    OnSymbolUpdate(event);
+}
+/*!
+ * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
+ */
+
+void wxRichTextBulletsPage::OnSymbolfontctrlSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (m_dontUpdate)
+        return;
+    UpdatePreview();
+}
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
+ */
+
+void wxRichTextBulletsPage::OnSymbolfontctrlUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (m_dontUpdate)
+        return;
+    UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLFONTCTRL
+ */
+
+void wxRichTextBulletsPage::OnSymbolfontctrlUIUpdate( wxUpdateUIEvent& event )
+{
+    OnSymbolUpdate(event);
+}
+
+/// Update for symbol-related controls
+void wxRichTextBulletsPage::OnSymbolUpdate( wxUpdateUIEvent& event )
+{
+    int sel = m_styleListBox->GetSelection();
+    event.Enable(m_hasBulletStyle && (sel == 6));
+}
+
+/// Update for number-related controls
+void wxRichTextBulletsPage::OnNumberUpdate( wxUpdateUIEvent& event )
+{
+    int sel = m_styleListBox->GetSelection();
+    event.Enable( m_hasBulletStyle && (sel != 6 && sel != 7 && sel != 0));
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_SYMBOLSTATIC
+ */
+
+void wxRichTextBulletsPage::OnSymbolstaticUpdate( wxUpdateUIEvent& event )
+{
+    OnSymbolUpdate(event);
+}
+
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTBULLETSPAGE_NUMBERSTATIC
+ */
+
+void wxRichTextBulletsPage::OnNumberstaticUpdate( wxUpdateUIEvent& event )
+{
+    OnNumberUpdate(event);
+}
+
+
diff --git a/src/richtext/richtextfontpage.cpp b/src/richtext/richtextfontpage.cpp
new file mode 100644 (file)
index 0000000..316b599
--- /dev/null
@@ -0,0 +1,636 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/richtext/richeditfontpage.cpp
+// Purpose:     Font page for wxRichTextFormattingDialog
+// Author:      Julian Smart
+// Modified by:
+// Created:     2006-10-02
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+////@begin includes
+////@end includes
+
+#include "../../include/wx/richtext/richtextfontpage.h"
+
+////@begin XPM images
+////@end XPM images
+
+/*!
+ * wxRichTextFontPage type definition
+ */
+
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextFontPage, wxPanel )
+
+/*!
+ * wxRichTextFontPage event table definition
+ */
+
+BEGIN_EVENT_TABLE( wxRichTextFontPage, wxPanel )
+    EVT_LISTBOX( ID_RICHTEXTFONTPAGE_FACELISTBOX, wxRichTextFontPage::OnFaceListBoxSelected )
+    EVT_BUTTON( ID_RICHTEXTFONTPAGE_COLOURCTRL, wxRichTextFontPage::OnColourClicked )
+
+////@begin wxRichTextFontPage event table entries
+    EVT_TEXT( ID_RICHTEXTFONTPAGE_FACETEXTCTRL, wxRichTextFontPage::OnFaceTextCtrlUpdated )
+
+    EVT_TEXT( ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, wxRichTextFontPage::OnSizeTextCtrlUpdated )
+
+    EVT_LISTBOX( ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxRichTextFontPage::OnSizeListBoxSelected )
+
+    EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_STYLECTRL, wxRichTextFontPage::OnStyleCtrlSelected )
+
+    EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_WEIGHTCTRL, wxRichTextFontPage::OnWeightCtrlSelected )
+
+    EVT_COMBOBOX( ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, wxRichTextFontPage::OnUnderliningCtrlSelected )
+
+////@end wxRichTextFontPage event table entries
+
+END_EVENT_TABLE()
+
+/*!
+ * wxRichTextFontPage constructors
+ */
+
+wxRichTextFontPage::wxRichTextFontPage( )
+{
+    Init();
+}
+
+wxRichTextFontPage::wxRichTextFontPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+    Init();
+    Create(parent, id, pos, size, style);
+}
+
+/*!
+ * Initialise members
+ */
+void wxRichTextFontPage::Init()
+{
+    m_dontUpdate = false;
+    m_colourPresent = false;
+
+////@begin wxRichTextFontPage member initialisation
+    m_faceTextCtrl = NULL;
+    m_faceListBox = NULL;
+    m_sizeTextCtrl = NULL;
+    m_sizeListBox = NULL;
+    m_styleCtrl = NULL;
+    m_weightCtrl = NULL;
+    m_underliningCtrl = NULL;
+    m_colourCtrl = NULL;
+    m_previewCtrl = NULL;
+////@end wxRichTextFontPage member initialisation
+}
+
+/*!
+ * wxRichTextFontPage creator
+ */
+
+bool wxRichTextFontPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+////@begin wxRichTextFontPage creation
+    wxPanel::Create( parent, id, pos, size, style );
+
+    CreateControls();
+    if (GetSizer())
+    {
+        GetSizer()->SetSizeHints(this);
+    }
+    Centre();
+////@end wxRichTextFontPage creation
+    return true;
+}
+
+/*!
+ * Control creation for wxRichTextFontPage
+ */
+
+void wxRichTextFontPage::CreateControls()
+{
+////@begin wxRichTextFontPage content construction
+    wxRichTextFontPage* itemPanel1 = this;
+
+    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
+    itemPanel1->SetSizer(itemBoxSizer2);
+
+    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer3->Add(itemBoxSizer4, 1, wxGROW, 5);
+
+    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer5, 1, wxGROW, 5);
+
+    wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Font:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    m_faceTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_FACETEXTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
+    m_faceTextCtrl->SetHelpText(_("Type a font name."));
+    if (ShowToolTips())
+        m_faceTextCtrl->SetToolTip(_("Type a font name."));
+    itemBoxSizer5->Add(m_faceTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
+
+    m_faceListBox = new wxRichTextFontListBox( itemPanel1, ID_RICHTEXTFONTPAGE_FACELISTBOX, wxDefaultPosition, wxSize(200, 140), wxSIMPLE_BORDER );
+    m_faceListBox->SetHelpText(_("Lists the available fonts."));
+    if (ShowToolTips())
+        m_faceListBox->SetToolTip(_("Lists the available fonts."));
+    itemBoxSizer5->Add(m_faceListBox, 1, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer9, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Size:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer9->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    m_sizeTextCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_SIZETEXTCTRL, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
+    m_sizeTextCtrl->SetHelpText(_("Type a size in points."));
+    if (ShowToolTips())
+        m_sizeTextCtrl->SetToolTip(_("Type a size in points."));
+    itemBoxSizer9->Add(m_sizeTextCtrl, 0, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
+
+    wxString* m_sizeListBoxStrings = NULL;
+    m_sizeListBox = new wxListBox( itemPanel1, ID_RICHTEXTFONTPAGE_SIZELISTBOX, wxDefaultPosition, wxSize(50, -1), 0, m_sizeListBoxStrings, wxLB_SINGLE );
+    m_sizeListBox->SetHelpText(_("Lists font sizes in points."));
+    if (ShowToolTips())
+        m_sizeListBox->SetToolTip(_("Lists font sizes in points."));
+    itemBoxSizer9->Add(m_sizeListBox, 1, wxALIGN_CENTER_HORIZONTAL|wxALL|wxFIXED_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer3->Add(itemBoxSizer13, 0, wxGROW, 5);
+
+    wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer13->Add(itemBoxSizer14, 1, wxGROW, 5);
+
+    wxStaticText* itemStaticText15 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font st&yle:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_styleCtrlStrings = NULL;
+    m_styleCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_STYLECTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_styleCtrlStrings, wxCB_READONLY );
+    m_styleCtrl->SetHelpText(_("Select regular or italic style."));
+    if (ShowToolTips())
+        m_styleCtrl->SetToolTip(_("Select regular or italic style."));
+    itemBoxSizer14->Add(m_styleCtrl, 0, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer17 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer13->Add(itemBoxSizer17, 1, wxGROW, 5);
+
+    wxStaticText* itemStaticText18 = new wxStaticText( itemPanel1, wxID_STATIC, _("Font &weight:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer17->Add(itemStaticText18, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_weightCtrlStrings = NULL;
+    m_weightCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_WEIGHTCTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_weightCtrlStrings, wxCB_READONLY );
+    m_weightCtrl->SetHelpText(_("Select regular or bold."));
+    if (ShowToolTips())
+        m_weightCtrl->SetToolTip(_("Select regular or bold."));
+    itemBoxSizer17->Add(m_weightCtrl, 0, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer13->Add(itemBoxSizer20, 1, wxGROW, 5);
+
+    wxStaticText* itemStaticText21 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Underlining:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer20->Add(itemStaticText21, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_underliningCtrlStrings = NULL;
+    m_underliningCtrl = new wxComboBox( itemPanel1, ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_underliningCtrlStrings, wxCB_READONLY );
+    m_underliningCtrl->SetHelpText(_("Select underlining or no underlining."));
+    if (ShowToolTips())
+        m_underliningCtrl->SetToolTip(_("Select underlining or no underlining."));
+    itemBoxSizer20->Add(m_underliningCtrl, 0, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer13->Add(itemBoxSizer23, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText24 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Colour:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer23->Add(itemStaticText24, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    m_colourCtrl = new wxRichTextColourSwatchCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_COLOURCTRL, wxDefaultPosition, wxSize(40, 20), wxSIMPLE_BORDER );
+    m_colourCtrl->SetHelpText(_("Click to change the text colour."));
+    if (ShowToolTips())
+        m_colourCtrl->SetToolTip(_("Click to change the text colour."));
+    itemBoxSizer23->Add(m_colourCtrl, 0, wxALIGN_LEFT|wxALL, 5);
+
+    itemBoxSizer3->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    m_previewCtrl = new wxRichTextFontPreviewCtrl( itemPanel1, ID_RICHTEXTFONTPAGE_PREVIEWCTRL, wxDefaultPosition, wxSize(100, 80), wxSIMPLE_BORDER );
+    m_previewCtrl->SetHelpText(_("Shows a preview of the font settings."));
+    if (ShowToolTips())
+        m_previewCtrl->SetToolTip(_("Shows a preview of the font settings."));
+    itemBoxSizer3->Add(m_previewCtrl, 0, wxGROW|wxALL, 5);
+
+////@end wxRichTextFontPage content construction
+
+    m_faceListBox->UpdateFonts();
+
+    m_styleCtrl->Append(_("Regular"));
+    m_styleCtrl->Append(_("Italic"));
+
+    m_weightCtrl->Append(_("Regular"));
+    m_weightCtrl->Append(_("Bold"));
+
+    m_underliningCtrl->Append(_("Not underlined"));
+    m_underliningCtrl->Append(_("Underlined"));
+
+    wxString nStr;
+    int i;
+    for (i = 8; i < 40; i++)
+    {
+        nStr.Printf(wxT("%d"), i);
+        m_sizeListBox->Append(nStr);
+    }
+    m_sizeListBox->Append(wxT("48"));
+    m_sizeListBox->Append(wxT("72"));
+}
+
+/// Transfer data from/to window
+bool wxRichTextFontPage::TransferDataFromWindow()
+{
+    wxPanel::TransferDataFromWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (m_faceListBox->GetSelection() != wxNOT_FOUND)
+    {
+        wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection());
+        if (!faceName.IsEmpty())
+        {
+            wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
+            font.SetFaceName(faceName);
+            wxSetFontPreservingStyles(*attr, font);
+            attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_FACE);
+        }
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_FACE));
+
+    wxString strSize = m_sizeTextCtrl->GetValue();
+    if (!strSize.IsEmpty())
+    {
+        int sz = wxAtoi(strSize);
+        if (sz > 0)
+        {
+            wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
+            font.SetPointSize(sz);
+            wxSetFontPreservingStyles(*attr, font);
+            attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_SIZE);
+        }
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_SIZE));
+
+    if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        int style;
+        if (m_styleCtrl->GetStringSelection() == _("Italic"))
+            style = wxITALIC;
+        else
+            style = wxNORMAL;
+
+        wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
+        font.SetStyle(style);
+        wxSetFontPreservingStyles(*attr, font);
+        attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_ITALIC);
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_ITALIC));
+
+    if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        int weight;
+        if (m_weightCtrl->GetStringSelection() == _("Bold"))
+            weight = wxBOLD;
+        else
+            weight = wxNORMAL;
+
+        wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
+        font.SetWeight(weight);
+        wxSetFontPreservingStyles(*attr, font);
+        attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_WEIGHT);
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_WEIGHT));
+
+    if (m_underliningCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        bool underlined;
+        if (m_underliningCtrl->GetStringSelection() == _("Underlined"))
+            underlined = true;
+        else
+            underlined = false;
+
+        wxFont font(attr->GetFont().Ok() ? attr->GetFont() : *wxNORMAL_FONT);
+        font.SetUnderlined(underlined);
+        wxSetFontPreservingStyles(*attr, font);
+        attr->SetFlags(attr->GetFlags() | wxTEXT_ATTR_FONT_UNDERLINE);
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_FONT_UNDERLINE));
+
+    if (m_colourPresent)
+    {
+        attr->SetTextColour(m_colourCtrl->GetBackgroundColour());
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~ wxTEXT_ATTR_TEXT_COLOUR));
+
+    return true;
+}
+
+bool wxRichTextFontPage::TransferDataToWindow()
+{
+    wxPanel::TransferDataToWindow();
+
+    m_dontUpdate = true;
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (attr->HasFont() && attr->HasFaceName())
+    {
+        m_faceTextCtrl->SetValue(attr->GetFont().GetFaceName());
+        m_faceListBox->SetFaceNameSelection(attr->GetFont().GetFaceName());
+    }
+    else
+    {
+        m_faceTextCtrl->SetValue(wxEmptyString);
+        m_faceListBox->SetFaceNameSelection(wxEmptyString);
+    }
+
+    if (attr->HasFont() && attr->HasSize())
+    {
+        wxString strSize = wxString::Format(wxT("%d"), attr->GetFont().GetPointSize());
+        m_sizeTextCtrl->SetValue(strSize);
+        if (m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
+            m_sizeListBox->SetStringSelection(strSize);
+    }
+    else
+    {
+        m_sizeTextCtrl->SetValue(wxEmptyString);
+        m_sizeListBox->SetSelection(wxNOT_FOUND);
+    }
+
+    if (attr->HasFont() && attr->HasWeight())
+    {
+        if (attr->GetFont().GetWeight() == wxBOLD)
+            m_weightCtrl->SetSelection(1);
+        else
+            m_weightCtrl->SetSelection(0);
+    }
+    else
+    {
+        m_weightCtrl->SetSelection(wxNOT_FOUND);
+    }
+
+    if (attr->HasFont() && attr->HasItalic())
+    {
+        if (attr->GetFont().GetStyle() == wxITALIC)
+            m_styleCtrl->SetSelection(1);
+        else
+            m_styleCtrl->SetSelection(0);
+    }
+    else
+    {
+        m_styleCtrl->SetSelection(wxNOT_FOUND);
+    }
+
+    if (attr->HasFont() && attr->HasUnderlined())
+    {
+        if (attr->GetFont().GetUnderlined())
+            m_underliningCtrl->SetSelection(1);
+        else
+            m_underliningCtrl->SetSelection(0);
+    }
+    else
+    {
+        m_underliningCtrl->SetSelection(wxNOT_FOUND);
+    }
+
+    if (attr->HasTextColour())
+    {
+        m_colourCtrl->SetBackgroundColour(attr->GetTextColour());
+        m_colourPresent = true;
+    }
+
+    UpdatePreview();
+
+    m_dontUpdate = false;
+
+    return true;
+}
+
+wxTextAttrEx* wxRichTextFontPage::GetAttributes()
+{
+    return wxRichTextFormattingDialog::GetDialogAttributes(this);
+}
+
+/// Updates the font preview
+void wxRichTextFontPage::UpdatePreview()
+{
+    wxFont font(*wxNORMAL_FONT);
+
+    if (m_colourPresent)
+        m_previewCtrl->SetForegroundColour(m_colourCtrl->GetBackgroundColour());
+
+    if (m_faceListBox->GetSelection() != wxNOT_FOUND)
+    {
+        wxString faceName = m_faceListBox->GetFaceName(m_faceListBox->GetSelection());
+        font.SetFaceName(faceName);
+    }
+
+    wxString strSize = m_sizeTextCtrl->GetValue();
+    if (!strSize.IsEmpty())
+    {
+        int sz = wxAtoi(strSize);
+        if (sz > 0)
+            font.SetPointSize(sz);
+    }
+
+    if (m_styleCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        int style;
+        if (m_styleCtrl->GetStringSelection() == _("Italic"))
+            style = wxITALIC;
+        else
+            style = wxNORMAL;
+
+        font.SetStyle(style);
+    }
+
+    if (m_weightCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        int weight;
+        if (m_weightCtrl->GetStringSelection() == _("Bold"))
+            weight = wxBOLD;
+        else
+            weight = wxNORMAL;
+
+        font.SetWeight(weight);
+    }
+
+    if (m_underliningCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        bool underlined;
+        if (m_underliningCtrl->GetStringSelection() == _("Underlined"))
+            underlined = true;
+        else
+            underlined = false;
+
+        font.SetUnderlined(underlined);
+    }
+
+    m_previewCtrl->SetFont(font);
+    m_previewCtrl->Refresh();
+}
+
+/*!
+ * Should we show tooltips?
+ */
+
+bool wxRichTextFontPage::ShowToolTips()
+{
+    return true;
+}
+
+/*!
+ * Get bitmap resources
+ */
+
+wxBitmap wxRichTextFontPage::GetBitmapResource( const wxString& name )
+{
+    // Bitmap retrieval
+////@begin wxRichTextFontPage bitmap retrieval
+    wxUnusedVar(name);
+    return wxNullBitmap;
+////@end wxRichTextFontPage bitmap retrieval
+}
+
+/*!
+ * Get icon resources
+ */
+
+wxIcon wxRichTextFontPage::GetIconResource( const wxString& name )
+{
+    // Icon retrieval
+////@begin wxRichTextFontPage icon retrieval
+    wxUnusedVar(name);
+    return wxNullIcon;
+////@end wxRichTextFontPage icon retrieval
+}
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_FACETEXTCTRL
+ */
+
+void wxRichTextFontPage::OnFaceTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (m_dontUpdate)
+        return;
+
+    wxString facename = m_faceTextCtrl->GetValue();
+    if (!facename.IsEmpty())
+    {
+        if (m_faceListBox->HasFaceName(facename))
+        {
+            m_faceListBox->SetFaceNameSelection(facename);
+            UpdatePreview();
+        }
+        else
+        {
+            // Try to find a partial match
+            const wxArrayString& arr = m_faceListBox->GetFaceNames();
+            size_t i;
+            for (i = 0; i < arr.GetCount(); i++)
+            {
+                if (arr[i].Mid(0, facename.Length()).Lower() == facename.Lower())
+                {
+                    m_faceListBox->ScrollToLine(i);
+                    break;
+                }
+            }
+        }
+    }
+}
+
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTFONTPAGE_SIZETEXTCTRL
+ */
+
+void wxRichTextFontPage::OnSizeTextCtrlUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (m_dontUpdate)
+        return;
+
+    wxString strSize = m_sizeTextCtrl->GetValue();
+    if (!strSize.IsEmpty() && m_sizeListBox->FindString(strSize) != wxNOT_FOUND)
+        m_sizeListBox->SetStringSelection(strSize);
+    UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_SIZELISTBOX
+ */
+
+void wxRichTextFontPage::OnSizeListBoxSelected( wxCommandEvent& event )
+{
+    m_dontUpdate = true;
+
+    m_sizeTextCtrl->SetValue(event.GetString());
+
+    m_dontUpdate = false;
+
+    UpdatePreview();
+}
+
+/*!
+ * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_FACELISTBOX
+ */
+
+void wxRichTextFontPage::OnFaceListBoxSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    m_dontUpdate = true;
+
+    m_faceTextCtrl->SetValue(m_faceListBox->GetFaceName(m_faceListBox->GetSelection()));
+
+    m_dontUpdate = false;
+
+    UpdatePreview();
+}
+
+/*!
+ * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_STYLECTRL
+ */
+
+void wxRichTextFontPage::OnStyleCtrlSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_UNDERLINING_CTRL
+ */
+
+void wxRichTextFontPage::OnUnderliningCtrlSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTFONTPAGE_WEIGHTCTRL
+ */
+
+void wxRichTextFontPage::OnWeightCtrlSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    UpdatePreview();
+}
+
+void wxRichTextFontPage::OnColourClicked( wxCommandEvent& WXUNUSED(event) )
+{
+    m_colourPresent = true;
+
+    UpdatePreview();
+}
diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp
new file mode 100644 (file)
index 0000000..9a7d80a
--- /dev/null
@@ -0,0 +1,579 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/richtext/richtextformatdlg.cpp
+// Purpose:     Formatting dialog for wxRichTextCtrl
+// Author:      Julian Smart
+// Modified by:
+// Created:     2006-10-01
+// RCS-ID:      $Id$
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#include "wx/defs.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/listbox.h"
+    #include "wx/combobox.h"
+    #include "wx/textctrl.h"
+    #include "wx/sizer.h"
+    #include "wx/stattext.h"
+    #include "wx/statline.h"
+    #include "wx/radiobut.h"
+    #include "wx/icon.h"
+    #include "wx/bitmap.h"
+    #include "wx/dcclient.h"
+    #include "wx/frame.h"
+    #include "wx/imaglist.h"
+    #include "wx/checkbox.h"
+    #include "wx/button.h"
+#endif // WX_PRECOMP
+
+#if wxUSE_RICHTEXT
+
+#include "wx/bookctrl.h"
+#include "wx/colordlg.h"
+#include "wx/fontenum.h"
+#include "wx/settings.h"
+#include "wx/module.h"
+
+#include "wx/richtext/richtextformatdlg.h"
+#include "wx/richtext/richtextctrl.h"
+#include "wx/richtext/richtextstyles.h"
+
+#include "richtextfontpage.cpp"
+#include "richtextindentspage.cpp"
+#include "richtexttabspage.cpp"
+#include "richtextbulletspage.cpp"
+#include "richtextstylepage.cpp"
+
+#ifdef __WXMAC__
+#define wxRICHTEXT_USE_TOOLBOOK true
+#else
+#define wxRICHTEXT_USE_TOOLBOOK false
+#endif
+
+IMPLEMENT_CLASS(wxRichTextFormattingDialog, wxPropertySheetDialog)
+
+BEGIN_EVENT_TABLE(wxRichTextFormattingDialog, wxPropertySheetDialog)
+    EVT_NOTEBOOK_PAGE_CHANGED(-1, wxRichTextFormattingDialog::OnTabChanged)
+END_EVENT_TABLE()
+
+wxRichTextFormattingDialogFactory* wxRichTextFormattingDialog::ms_FormattingDialogFactory = NULL;
+
+void wxRichTextFormattingDialog::Init()
+{
+    m_imageList = NULL;
+    m_styleDefinition = NULL;
+    m_styleSheet = NULL;
+}
+
+wxRichTextFormattingDialog::~wxRichTextFormattingDialog()
+{
+    delete m_imageList;
+    delete m_styleDefinition;
+}
+
+bool wxRichTextFormattingDialog::Create(long flags, wxWindow* parent, const wxString& title, wxWindowID id,
+        const wxPoint& pos, const wxSize& sz, long style)
+{
+    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP|wxWS_EX_VALIDATE_RECURSIVELY);
+
+    int resizeBorder = wxRESIZE_BORDER;
+
+    GetFormattingDialogFactory()->SetSheetStyle(this);
+
+    wxPropertySheetDialog::Create(parent, id, title, pos, sz,
+        style | (int)wxPlatform::IfNot(wxWinCE, resizeBorder)
+    );
+
+    GetFormattingDialogFactory()->CreateButtons(this);
+    GetFormattingDialogFactory()->CreatePages(flags, this);
+
+    LayoutDialog();
+
+    return true;
+}
+
+/// Get attributes from the given range
+bool wxRichTextFormattingDialog::GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range)
+{
+    if (ctrl->GetBuffer().GetStyleForRange(range.ToInternal(), m_attributes))
+        return UpdateDisplay();
+    else
+        return false;
+}
+
+/// Apply attributes to the given range, only applying if necessary (wxRICHTEXT_SETSTYLE_OPTIMIZE)
+bool wxRichTextFormattingDialog::ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags)
+{
+    return ctrl->SetStyleEx(range, m_attributes, flags);
+}
+
+/// Set the attributes and optionally update the display
+bool wxRichTextFormattingDialog::SetStyle(const wxTextAttrEx& style, bool update)
+{
+    m_attributes = style;
+    if (update)
+        UpdateDisplay();
+    return true;
+}
+
+/// Set the style definition and optionally update the display
+bool wxRichTextFormattingDialog::SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update)
+{
+    m_styleSheet = sheet;
+
+    if (m_styleDefinition)
+        delete m_styleDefinition;
+    m_styleDefinition = styleDef.Clone();
+
+    return SetStyle(m_styleDefinition->GetStyle(), update);
+}
+
+/// Transfers the data and from to the window
+bool wxRichTextFormattingDialog::TransferDataToWindow()
+{
+    if (m_styleDefinition)
+        m_attributes = m_styleDefinition->GetStyle();
+
+    if (!wxPropertySheetDialog::TransferDataToWindow())
+        return false;
+
+    return true;
+}
+
+bool wxRichTextFormattingDialog::TransferDataFromWindow()
+{
+    if (!wxPropertySheetDialog::TransferDataFromWindow())
+        return false;
+
+    if (m_styleDefinition)
+        m_styleDefinition->GetStyle() = m_attributes;
+
+    return true;
+}
+
+/// Update the display
+bool wxRichTextFormattingDialog::UpdateDisplay()
+{
+    return TransferDataToWindow();
+}
+
+/// Apply the styles when a different tab is selected, so the previews are
+/// up to date
+void wxRichTextFormattingDialog::OnTabChanged(wxNotebookEvent& event)
+{
+    if (GetBookCtrl() != event.GetEventObject())
+    {
+        event.Skip();
+        return;
+    }
+
+    int oldPageId = event.GetOldSelection();
+    if (oldPageId != -1)
+    {
+        wxWindow* page = GetBookCtrl()->GetPage(oldPageId);
+        if (page)
+            page->TransferDataFromWindow();
+    }
+
+    int pageId = event.GetSelection();
+    if (pageId != -1)
+    {
+        wxWindow* page = GetBookCtrl()->GetPage(pageId);
+        if (page)
+            page->TransferDataToWindow();
+    }
+}
+
+void wxRichTextFormattingDialog::SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory)
+{
+    if (ms_FormattingDialogFactory)
+        delete ms_FormattingDialogFactory;
+    ms_FormattingDialogFactory = factory;
+}
+
+/*!
+ * Factory for formatting dialog
+ */
+
+/// Create all pages, under the dialog's book control, also calling AddPage
+bool wxRichTextFormattingDialogFactory::CreatePages(long pages, wxRichTextFormattingDialog* dialog)
+{
+    if (dialog->GetImageList())
+        dialog->GetBookCtrl()->SetImageList(dialog->GetImageList());
+
+    int availablePageCount = GetPageIdCount();
+    int i;
+    for (i = 0; i < availablePageCount; i ++)
+    {
+        int pageId = GetPageId(i);
+        if (pageId != -1 && (pages & pageId))
+        {
+            wxString title;
+            wxPanel* panel = CreatePage(pageId, title, dialog);
+            wxASSERT( panel != NULL );
+            if (panel)
+            {
+                int imageIndex = GetPageImage(pageId);
+                dialog->GetBookCtrl()->AddPage(panel, title, false, imageIndex);
+            }
+        }
+    }
+    return true;
+}
+
+/// Create a page, given a page identifier
+wxPanel* wxRichTextFormattingDialogFactory::CreatePage(int page, wxString& title, wxRichTextFormattingDialog* dialog)
+{
+    if (page == wxRICHTEXT_FORMAT_STYLE_EDITOR)
+    {
+        wxRichTextStylePage* page = new wxRichTextStylePage(dialog->GetBookCtrl(), wxID_ANY);
+        title = _("Style");
+        return page;
+    }
+    else if (page == wxRICHTEXT_FORMAT_FONT)
+    {
+        wxRichTextFontPage* page = new wxRichTextFontPage(dialog->GetBookCtrl(), wxID_ANY);
+        title = _("Font");
+        return page;
+    }
+    else if (page == wxRICHTEXT_FORMAT_INDENTS_SPACING)
+    {
+        wxRichTextIndentsSpacingPage* page = new wxRichTextIndentsSpacingPage(dialog->GetBookCtrl(), wxID_ANY);
+        title = _("Indents && Spacing");
+        return page;
+    }
+    else if (page == wxRICHTEXT_FORMAT_TABS)
+    {
+        wxRichTextTabsPage* page = new wxRichTextTabsPage(dialog->GetBookCtrl(), wxID_ANY);
+        title = _("Tabs");
+        return page;
+    }
+    else if (page == wxRICHTEXT_FORMAT_BULLETS)
+    {
+        wxRichTextBulletsPage* page = new wxRichTextBulletsPage(dialog->GetBookCtrl(), wxID_ANY);
+        title = _("Bullets");
+        return page;
+    }
+    else
+        return NULL;
+}
+
+/// Enumerate all available page identifiers
+int wxRichTextFormattingDialogFactory::GetPageId(int i) const
+{
+    int pages[] = {
+        wxRICHTEXT_FORMAT_STYLE_EDITOR,
+        wxRICHTEXT_FORMAT_FONT,
+        wxRICHTEXT_FORMAT_INDENTS_SPACING,
+        wxRICHTEXT_FORMAT_BULLETS,
+        wxRICHTEXT_FORMAT_TABS };
+
+    if (i < 0 || i > 4)
+        return -1;
+
+    return pages[i];
+}
+
+/// Get the number of available page identifiers
+int wxRichTextFormattingDialogFactory::GetPageIdCount() const
+{
+    return 5;
+}
+
+/// Set the sheet style, called at the start of wxRichTextFormattingDialog::Create
+bool wxRichTextFormattingDialogFactory::SetSheetStyle(wxRichTextFormattingDialog* dialog)
+{
+    bool useToolBook = wxRICHTEXT_USE_TOOLBOOK;
+    if (useToolBook)
+    {
+        int sheetStyle = wxPROPSHEET_SHRINKTOFIT;
+#ifdef __WXMAC__
+        sheetStyle |= wxPROPSHEET_BUTTONTOOLBOOK;
+#else
+        sheetStyle |= wxPROPSHEET_TOOLBOOK;
+#endif
+
+        dialog->SetSheetStyle(sheetStyle);
+        dialog->SetSheetInnerBorder(0);
+        dialog->SetSheetOuterBorder(0);
+    }
+
+    return true;
+}
+
+/// Create the main dialog buttons
+bool wxRichTextFormattingDialogFactory::CreateButtons(wxRichTextFormattingDialog* dialog)
+{
+    bool useToolBook = wxRICHTEXT_USE_TOOLBOOK;
+
+    // If using a toolbook, also follow Mac style and don't create buttons
+    int flags = wxOK|wxCANCEL;
+#ifndef __WXWINCE__
+    flags |= wxHELP;
+#endif
+
+    if (!useToolBook)
+        dialog->CreateButtons(flags);
+
+    return true;
+}
+
+/*
+ * Module to initialise and clean up handlers
+ */
+
+class wxRichTextFormattingDialogModule: public wxModule
+{
+DECLARE_DYNAMIC_CLASS(wxRichTextFormattingDialogModule)
+public:
+    wxRichTextFormattingDialogModule() {}
+    bool OnInit() { wxRichTextFormattingDialog::SetFormattingDialogFactory(new wxRichTextFormattingDialogFactory); return true; };
+    void OnExit() { wxRichTextFormattingDialog::SetFormattingDialogFactory(NULL); };
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxRichTextFormattingDialogModule, wxModule)
+
+/*
+ * Font preview control
+ */
+
+BEGIN_EVENT_TABLE(wxRichTextFontPreviewCtrl, wxWindow)
+    EVT_PAINT(wxRichTextFontPreviewCtrl::OnPaint)
+END_EVENT_TABLE()
+
+void wxRichTextFontPreviewCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
+{
+    wxPaintDC dc(this);
+
+    wxSize size = GetSize();
+    wxFont font = GetFont();
+
+    if ( font.Ok() )
+    {
+        dc.SetFont(font);
+        // Calculate vertical and horizontal centre
+        long w = 0, h = 0;
+
+        wxString text(_("ABCDEFGabcdefg12345"));
+
+        dc.GetTextExtent( text, &w, &h);
+        int cx = wxMax(2, (size.x/2) - (w/2));
+        int cy = wxMax(2, (size.y/2) - (h/2));
+
+        dc.SetTextForeground(GetForegroundColour());
+        dc.SetClippingRegion(2, 2, size.x-4, size.y-4);
+        dc.DrawText(text, cx, cy);
+        dc.DestroyClippingRegion();
+    }
+}
+
+// Helper for pages to get the top-level dialog
+wxRichTextFormattingDialog* wxRichTextFormattingDialog::GetDialog(wxWindow* win)
+{
+    wxWindow* p = win->GetParent();
+    while (p && !p->IsKindOf(CLASSINFO(wxRichTextFormattingDialog)))
+        p = p->GetParent();
+    wxRichTextFormattingDialog* dialog = wxDynamicCast(p, wxRichTextFormattingDialog);
+    return dialog;
+}
+
+
+// Helper for pages to get the attributes
+wxTextAttrEx* wxRichTextFormattingDialog::GetDialogAttributes(wxWindow* win)
+{
+    wxRichTextFormattingDialog* dialog = GetDialog(win);
+    if (dialog)
+        return & dialog->GetAttributes();
+    else
+        return NULL;
+}
+
+// Helper for pages to get the style
+wxRichTextStyleDefinition* wxRichTextFormattingDialog::GetDialogStyleDefinition(wxWindow* win)
+{
+    wxRichTextFormattingDialog* dialog = GetDialog(win);
+    if (dialog)
+        return dialog->GetStyleDefinition();
+    else
+        return NULL;
+}
+
+/*
+ * A control for displaying a small preview of a colour or bitmap
+ */
+
+BEGIN_EVENT_TABLE(wxRichTextColourSwatchCtrl, wxControl)
+    EVT_MOUSE_EVENTS(wxRichTextColourSwatchCtrl::OnMouseEvent)
+END_EVENT_TABLE()
+
+IMPLEMENT_CLASS(wxRichTextColourSwatchCtrl, wxControl)
+
+wxRichTextColourSwatchCtrl::wxRichTextColourSwatchCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
+    wxControl(parent, id, pos, size, style)
+{
+    SetColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
+    SetBackgroundStyle(wxBG_STYLE_COLOUR);
+}
+
+wxRichTextColourSwatchCtrl::~wxRichTextColourSwatchCtrl()
+{
+}
+
+void wxRichTextColourSwatchCtrl::OnMouseEvent(wxMouseEvent& event)
+{
+    if (event.LeftDown())
+    {
+        wxWindow* parent = GetParent();
+        while (parent != NULL && !parent->IsKindOf(CLASSINFO(wxDialog)) && !parent->IsKindOf(CLASSINFO(wxFrame)))
+            parent = parent->GetParent();
+
+        wxColourData data;
+        data.SetChooseFull(true);
+        data.SetColour(m_colour);
+        wxColourDialog *dialog = new wxColourDialog(parent, &data);
+        // Crashes on wxMac (no m_peer)
+#ifndef __WXMAC__
+        dialog->SetTitle(_("Background colour"));
+#endif
+        if (dialog->ShowModal() == wxID_OK)
+        {
+            wxColourData retData = dialog->GetColourData();
+            m_colour = retData.GetColour();
+            SetBackgroundColour(m_colour);
+        }
+        dialog->Destroy();
+        Refresh();
+
+        wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
+        GetEventHandler()->ProcessEvent(event);
+    }
+}
+
+#if wxUSE_HTML
+
+/*!
+ * wxRichTextFontListBox class declaration
+ * A listbox to display styles.
+ */
+
+IMPLEMENT_CLASS(wxRichTextFontListBox, wxHtmlListBox)
+
+BEGIN_EVENT_TABLE(wxRichTextFontListBox, wxHtmlListBox)
+END_EVENT_TABLE()
+
+wxRichTextFontListBox::wxRichTextFontListBox(wxWindow* parent, wxWindowID id, const wxPoint& pos,
+    const wxSize& size, long style)
+{
+    Init();
+    Create(parent, id, pos, size, style);
+}
+
+bool wxRichTextFontListBox::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos,
+        const wxSize& size, long style)
+{
+    return wxHtmlListBox::Create(parent, id, pos, size, style);
+}
+
+wxRichTextFontListBox::~wxRichTextFontListBox()
+{
+}
+
+/// Returns the HTML for this item
+wxString wxRichTextFontListBox::OnGetItem(size_t n) const
+{
+    if (m_faceNames.GetCount() == 0)
+        return wxEmptyString;
+
+    wxString str = CreateHTML(m_faceNames[n]);
+    return str;
+}
+
+/// Get font name for index
+wxString wxRichTextFontListBox::GetFaceName(size_t i) const
+{
+    return m_faceNames[i];
+}
+
+/// Set selection for string, returning the index.
+int wxRichTextFontListBox::SetFaceNameSelection(const wxString& name)
+{
+    int i = m_faceNames.Index(name);
+    SetSelection(i);
+
+    return i;
+}
+
+/// Updates the font list
+void wxRichTextFontListBox::UpdateFonts()
+{
+    wxFontEnumerator enumerator;
+    enumerator.EnumerateFacenames();
+    wxArrayString facenames = enumerator.GetFacenames();
+    m_faceNames = facenames;
+    m_faceNames.Sort();
+
+    SetItemCount(m_faceNames.GetCount());
+    Refresh();
+}
+
+#if 0
+// Convert a colour to a 6-digit hex string
+static wxString ColourToHexString(const wxColour& col)
+{
+    wxString hex;
+
+    hex += wxDecToHex(col.Red());
+    hex += wxDecToHex(col.Green());
+    hex += wxDecToHex(col.Blue());
+
+    return hex;
+}
+#endif
+
+/// Creates a suitable HTML fragment for a definition
+wxString wxRichTextFontListBox::CreateHTML(const wxString& facename) const
+{
+    wxString str = wxT("<font");
+
+    str << wxT(" size=\"+2\"");;
+
+    if (!facename.IsEmpty() && facename != _("(none)"))
+        str << wxT(" face=\"") << facename << wxT("\"");
+/*
+    if (def->GetStyle().GetTextColour().Ok())
+        str << wxT(" color=\"#") << ColourToHexString(def->GetStyle().GetTextColour()) << wxT("\"");
+*/
+
+    str << wxT(">");
+
+    bool hasBold = false;
+
+    if (hasBold)
+        str << wxT("<b>");
+
+    str += facename;
+
+    if (hasBold)
+        str << wxT("</b>");
+
+    str << wxT("</font>");
+
+    return str;
+}
+
+#endif
+    // wxUSE_HTML
+
+
+#endif
+    // wxUSE_RICHTEXT
+
diff --git a/src/richtext/richtextindentspage.cpp b/src/richtext/richtextindentspage.cpp
new file mode 100644 (file)
index 0000000..9175242
--- /dev/null
@@ -0,0 +1,638 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtextindentspage.cpp
+// Purpose:
+// Author:      Julian Smart
+// Modified by:
+// Created:     10/3/2006 2:28:21 PM
+// RCS-ID:
+// Copyright:   (c) Julian Smart
+// Licence:
+/////////////////////////////////////////////////////////////////////////////
+
+////@begin includes
+////@end includes
+
+#include "../../include/wx/richtext/richtextindentspage.h"
+
+////@begin XPM images
+////@end XPM images
+
+/*!
+ * wxRichTextIndentsSpacingPage type definition
+ */
+
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextIndentsSpacingPage, wxPanel )
+
+/*!
+ * wxRichTextIndentsSpacingPage event table definition
+ */
+
+BEGIN_EVENT_TABLE( wxRichTextIndentsSpacingPage, wxPanel )
+
+////@begin wxRichTextIndentsSpacingPage event table entries
+    EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT, wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected )
+
+    EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT, wxRichTextIndentsSpacingPage::OnAlignmentRightSelected )
+
+    EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED, wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected )
+
+    EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED, wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected )
+
+    EVT_RADIOBUTTON( ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE, wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected )
+
+    EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, wxRichTextIndentsSpacingPage::OnIndentLeftUpdated )
+
+    EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated )
+
+    EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, wxRichTextIndentsSpacingPage::OnIndentRightUpdated )
+
+    EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated )
+
+    EVT_TEXT( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated )
+
+    EVT_COMBOBOX( ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, wxRichTextIndentsSpacingPage::OnSpacingLineSelected )
+
+////@end wxRichTextIndentsSpacingPage event table entries
+
+END_EVENT_TABLE()
+
+/*!
+ * wxRichTextIndentsSpacingPage constructors
+ */
+
+wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( )
+{
+    Init();
+}
+
+wxRichTextIndentsSpacingPage::wxRichTextIndentsSpacingPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+    Init();
+    Create(parent, id, pos, size, style);
+}
+
+/*!
+ * Initialise members
+ */
+void wxRichTextIndentsSpacingPage::Init()
+{
+    m_dontUpdate = false;
+
+////@begin wxRichTextIndentsSpacingPage member initialisation
+    m_alignmentLeft = NULL;
+    m_alignmentRight = NULL;
+    m_alignmentJustified = NULL;
+    m_alignmentCentred = NULL;
+    m_alignmentIndeterminate = NULL;
+    m_indentLeft = NULL;
+    m_indentLeftFirst = NULL;
+    m_indentRight = NULL;
+    m_spacingBefore = NULL;
+    m_spacingAfter = NULL;
+    m_spacingLine = NULL;
+    m_previewCtrl = NULL;
+////@end wxRichTextIndentsSpacingPage member initialisation
+
+}
+
+/*!
+ * wxRichTextIndentsSpacingPage creator
+ */
+
+bool wxRichTextIndentsSpacingPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+////@begin wxRichTextIndentsSpacingPage creation
+    wxPanel::Create( parent, id, pos, size, style );
+
+    CreateControls();
+    if (GetSizer())
+    {
+        GetSizer()->SetSizeHints(this);
+    }
+    Centre();
+////@end wxRichTextIndentsSpacingPage creation
+    return true;
+}
+
+/*!
+ * Control creation for wxRichTextIndentsSpacingPage
+ */
+
+void wxRichTextIndentsSpacingPage::CreateControls()
+{
+////@begin wxRichTextIndentsSpacingPage content construction
+    wxRichTextIndentsSpacingPage* itemPanel1 = this;
+
+    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
+    itemPanel1->SetSizer(itemBoxSizer2);
+
+    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5);
+
+    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Alignment"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer5->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    itemBoxSizer7->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
+
+    wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer7->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5);
+
+    m_alignmentLeft = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT, _("&Left"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
+    m_alignmentLeft->SetValue(false);
+    itemBoxSizer9->Add(m_alignmentLeft, 0, wxALIGN_LEFT|wxALL, 5);
+
+    m_alignmentRight = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT, _("&Right"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_alignmentRight->SetValue(false);
+    itemBoxSizer9->Add(m_alignmentRight, 0, wxALIGN_LEFT|wxALL, 5);
+
+    m_alignmentJustified = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED, _("&Justified"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_alignmentJustified->SetValue(false);
+    itemBoxSizer9->Add(m_alignmentJustified, 0, wxALIGN_LEFT|wxALL, 5);
+
+    m_alignmentCentred = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED, _("Cen&tred"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_alignmentCentred->SetValue(false);
+    itemBoxSizer9->Add(m_alignmentCentred, 0, wxALIGN_LEFT|wxALL, 5);
+
+    m_alignmentIndeterminate = new wxRadioButton( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE, _("&Indeterminate"), wxDefaultPosition, wxDefaultSize, 0 );
+    m_alignmentIndeterminate->SetValue(false);
+    itemBoxSizer9->Add(m_alignmentIndeterminate, 0, wxALIGN_LEFT|wxALL, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxStaticLine* itemStaticLine16 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
+    itemBoxSizer4->Add(itemStaticLine16, 0, wxGROW|wxLEFT|wxBOTTOM, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxBoxSizer* itemBoxSizer18 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer18, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText19 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Indentation (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer18->Add(itemStaticText19, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer20 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer18->Add(itemBoxSizer20, 0, wxALIGN_LEFT|wxALL, 5);
+
+    itemBoxSizer20->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
+
+    wxFlexGridSizer* itemFlexGridSizer22 = new wxFlexGridSizer(2, 2, 0, 0);
+    itemBoxSizer20->Add(itemFlexGridSizer22, 0, wxALIGN_CENTER_VERTICAL, 5);
+
+    wxStaticText* itemStaticText23 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Left:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemFlexGridSizer22->Add(itemStaticText23, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer24 = new wxBoxSizer(wxHORIZONTAL);
+    itemFlexGridSizer22->Add(itemBoxSizer24, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+    m_indentLeft = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
+    itemBoxSizer24->Add(m_indentLeft, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    wxStaticText* itemStaticText26 = new wxStaticText( itemPanel1, wxID_STATIC, _("Left (&first line):"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemFlexGridSizer22->Add(itemStaticText26, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer27 = new wxBoxSizer(wxHORIZONTAL);
+    itemFlexGridSizer22->Add(itemBoxSizer27, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+    m_indentLeftFirst = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
+    itemBoxSizer27->Add(m_indentLeftFirst, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    wxStaticText* itemStaticText29 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Right:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemFlexGridSizer22->Add(itemStaticText29, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer30 = new wxBoxSizer(wxHORIZONTAL);
+    itemFlexGridSizer22->Add(itemBoxSizer30, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+    m_indentRight = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
+    itemBoxSizer30->Add(m_indentRight, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxStaticLine* itemStaticLine33 = new wxStaticLine( itemPanel1, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_VERTICAL );
+    itemBoxSizer4->Add(itemStaticLine33, 0, wxGROW|wxTOP|wxBOTTOM, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxBoxSizer* itemBoxSizer35 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer35, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText36 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Spacing (tenths of a mm)"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer35->Add(itemStaticText36, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer37 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer35->Add(itemBoxSizer37, 0, wxALIGN_LEFT|wxALL, 5);
+
+    itemBoxSizer37->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL, 5);
+
+    wxFlexGridSizer* itemFlexGridSizer39 = new wxFlexGridSizer(2, 2, 0, 0);
+    itemBoxSizer37->Add(itemFlexGridSizer39, 0, wxALIGN_CENTER_VERTICAL, 5);
+
+    wxStaticText* itemStaticText40 = new wxStaticText( itemPanel1, wxID_STATIC, _("Before a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemFlexGridSizer39->Add(itemStaticText40, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer41 = new wxBoxSizer(wxHORIZONTAL);
+    itemFlexGridSizer39->Add(itemBoxSizer41, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+    m_spacingBefore = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
+    itemBoxSizer41->Add(m_spacingBefore, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    wxStaticText* itemStaticText43 = new wxStaticText( itemPanel1, wxID_STATIC, _("After a paragraph:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemFlexGridSizer39->Add(itemStaticText43, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer44 = new wxBoxSizer(wxHORIZONTAL);
+    itemFlexGridSizer39->Add(itemBoxSizer44, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+    m_spacingAfter = new wxTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
+    itemBoxSizer44->Add(m_spacingAfter, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    wxStaticText* itemStaticText46 = new wxStaticText( itemPanel1, wxID_STATIC, _("Line spacing:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemFlexGridSizer39->Add(itemStaticText46, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
+
+    wxBoxSizer* itemBoxSizer47 = new wxBoxSizer(wxHORIZONTAL);
+    itemFlexGridSizer39->Add(itemBoxSizer47, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
+
+    wxString m_spacingLineStrings[] = {
+        _("Single"),
+        _("1.5"),
+        _("2")
+    };
+    m_spacingLine = new wxComboBox( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE, _("Single"), wxDefaultPosition, wxDefaultSize, 3, m_spacingLineStrings, wxCB_READONLY );
+    m_spacingLine->SetStringSelection(_("Single"));
+    itemBoxSizer47->Add(m_spacingLine, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
+
+    itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    m_previewCtrl = new wxRichTextCtrl( itemPanel1, ID_RICHTEXTINDENTSSPACINGPAGE_PREVIEW_CTRL, wxEmptyString, wxDefaultPosition, wxSize(350, 180), wxSUNKEN_BORDER );
+    m_previewCtrl->SetHelpText(_("Shows a preview of the paragraph settings."));
+    if (ShowToolTips())
+        m_previewCtrl->SetToolTip(_("Shows a preview of the paragraph settings."));
+    itemBoxSizer3->Add(m_previewCtrl, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+////@end wxRichTextIndentsSpacingPage content construction
+}
+
+wxTextAttrEx* wxRichTextIndentsSpacingPage::GetAttributes()
+{
+    return wxRichTextFormattingDialog::GetDialogAttributes(this);
+}
+
+/// Updates the font preview
+void wxRichTextIndentsSpacingPage::UpdatePreview()
+{
+    static const wxChar* s_para1 = wxT("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \
+Nullam ante sapien, vestibulum nonummy, pulvinar sed, luctus ut, lacus.");
+
+    static const wxChar* s_para2 = wxT("\nDuis pharetra consequat dui. Cum sociis natoque penatibus \
+et magnis dis parturient montes, nascetur ridiculus mus. Nullam vitae justo id mauris lobortis interdum.");
+
+    static const wxChar* s_para3 = wxT("\nInteger convallis dolor at augue \
+iaculis malesuada. Donec bibendum ipsum ut ante porta fringilla.\n");
+
+    TransferDataFromWindow();
+    wxTextAttrEx attr(*GetAttributes());
+    attr.SetFlags(attr.GetFlags() &
+      (wxTEXT_ATTR_ALIGNMENT|wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_PARA_SPACING_BEFORE|wxTEXT_ATTR_PARA_SPACING_AFTER|
+       wxTEXT_ATTR_LINE_SPACING|
+       wxTEXT_ATTR_BULLET_STYLE|wxTEXT_ATTR_BULLET_NUMBER|wxTEXT_ATTR_BULLET_SYMBOL));
+
+    wxFont font(m_previewCtrl->GetFont());
+    font.SetPointSize(9);
+    m_previewCtrl->SetFont(font);
+
+    font.SetWeight(wxBOLD);
+    attr.SetFont(font);
+
+    m_previewCtrl->Clear();
+
+    m_previewCtrl->WriteText(s_para1);
+    m_previewCtrl->BeginStyle(attr);
+    m_previewCtrl->WriteText(s_para2);
+    m_previewCtrl->EndStyle();
+    m_previewCtrl->WriteText(s_para3);
+}
+
+/// Transfer data from/to window
+bool wxRichTextIndentsSpacingPage::TransferDataFromWindow()
+{
+    wxPanel::TransferDataFromWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (m_alignmentLeft->GetValue())
+        attr->SetAlignment(wxTEXT_ALIGNMENT_LEFT);
+    else if (m_alignmentCentred->GetValue())
+        attr->SetAlignment(wxTEXT_ALIGNMENT_CENTRE);
+    else if (m_alignmentRight->GetValue())
+        attr->SetAlignment(wxTEXT_ALIGNMENT_RIGHT);
+    else if (m_alignmentJustified->GetValue())
+        attr->SetAlignment(wxTEXT_ALIGNMENT_JUSTIFIED);
+    else
+    {
+        attr->SetAlignment(wxTEXT_ALIGNMENT_DEFAULT);
+        attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_ALIGNMENT));
+    }
+
+    wxString leftIndent(m_indentLeft->GetValue());
+    wxString leftFirstIndent(m_indentLeftFirst->GetValue());
+    if (!leftIndent.IsEmpty())
+    {
+        int visualLeftIndent = wxAtoi(leftIndent);
+        int visualLeftFirstIndent = wxAtoi(leftFirstIndent);
+        int actualLeftIndent = visualLeftFirstIndent;
+        int actualLeftSubIndent = visualLeftIndent - visualLeftFirstIndent;
+
+        attr->SetLeftIndent(actualLeftIndent, actualLeftSubIndent);
+    }
+    else
+        attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LEFT_INDENT));
+
+    wxString rightIndent(m_indentRight->GetValue());
+    if (!rightIndent.IsEmpty())
+        attr->SetRightIndent(wxAtoi(rightIndent));
+    else
+        attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_RIGHT_INDENT));
+
+    wxString spacingAfter(m_spacingAfter->GetValue());
+    if (!spacingAfter.IsEmpty())
+        attr->SetParagraphSpacingAfter(wxAtoi(spacingAfter));
+    else
+        attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_AFTER));
+
+    wxString spacingBefore(m_spacingBefore->GetValue());
+    if (!spacingBefore.IsEmpty())
+        attr->SetParagraphSpacingBefore(wxAtoi(spacingBefore));
+    else
+        attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_PARA_SPACING_BEFORE));
+
+    int spacingIndex = m_spacingLine->GetSelection();
+    int lineSpacing = 0;
+    if (spacingIndex == 0)
+        lineSpacing = 10;
+    else if (spacingIndex == 1)
+        lineSpacing = 15;
+    else if (spacingIndex == 2)
+        lineSpacing = 20;
+
+    if (lineSpacing == 0)
+        attr->SetFlags(attr->GetFlags() & (~wxTEXT_ATTR_LINE_SPACING));
+    else
+        attr->SetLineSpacing(lineSpacing);
+
+    return true;
+}
+
+bool wxRichTextIndentsSpacingPage::TransferDataToWindow()
+{
+    m_dontUpdate = true;
+
+    wxPanel::TransferDataToWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (attr->HasAlignment())
+    {
+        if (attr->GetAlignment() == wxTEXT_ALIGNMENT_LEFT)
+            m_alignmentLeft->SetValue(true);
+        else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_RIGHT)
+            m_alignmentRight->SetValue(true);
+        else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_CENTRE)
+            m_alignmentCentred->SetValue(true);
+        else if (attr->GetAlignment() == wxTEXT_ALIGNMENT_JUSTIFIED)
+            m_alignmentJustified->SetValue(true);
+        else
+            m_alignmentIndeterminate->SetValue(true);
+    }
+    else
+        m_alignmentIndeterminate->SetValue(true);
+
+    if (attr->HasLeftIndent())
+    {
+        wxString leftIndent(wxString::Format(wxT("%d"), attr->GetLeftIndent() + attr->GetLeftSubIndent()));
+        wxString leftFirstIndent(wxString::Format(wxT("%d"), attr->GetLeftIndent()));
+
+        m_indentLeft->SetValue(leftIndent);
+        m_indentLeftFirst->SetValue(leftFirstIndent);
+    }
+    else
+    {
+        m_indentLeft->SetValue(wxEmptyString);
+        m_indentLeftFirst->SetValue(wxEmptyString);
+    }
+
+    if (attr->HasRightIndent())
+    {
+        wxString rightIndent(wxString::Format(wxT("%d"), attr->GetRightIndent()));
+
+        m_indentRight->SetValue(rightIndent);
+    }
+    else
+        m_indentRight->SetValue(wxEmptyString);
+
+    if (attr->HasParagraphSpacingAfter())
+    {
+        wxString spacingAfter(wxString::Format(wxT("%d"), attr->GetParagraphSpacingAfter()));
+
+        m_spacingAfter->SetValue(spacingAfter);
+    }
+    else
+        m_spacingAfter->SetValue(wxEmptyString);
+
+    if (attr->HasParagraphSpacingBefore())
+    {
+        wxString spacingBefore(wxString::Format(wxT("%d"), attr->GetParagraphSpacingBefore()));
+
+        m_spacingBefore->SetValue(spacingBefore);
+    }
+    else
+        m_spacingBefore->SetValue(wxEmptyString);
+
+    if (attr->HasLineSpacing())
+    {
+        int index = 0;
+
+        int lineSpacing = attr->GetLineSpacing();
+        if (lineSpacing == 10)
+            index = 0;
+        else if (lineSpacing == 15)
+            index = 1;
+        else if (lineSpacing == 20)
+            index = 2;
+        else
+            index = -1;
+
+        m_spacingLine->SetSelection(index);
+    }
+    else
+        m_spacingLine->SetSelection(-1);
+
+    UpdatePreview();
+
+    m_dontUpdate = false;
+
+    return true;
+}
+
+
+/*!
+ * Should we show tooltips?
+ */
+
+bool wxRichTextIndentsSpacingPage::ShowToolTips()
+{
+    return true;
+}
+
+/*!
+ * Get bitmap resources
+ */
+
+wxBitmap wxRichTextIndentsSpacingPage::GetBitmapResource( const wxString& name )
+{
+    // Bitmap retrieval
+////@begin wxRichTextIndentsSpacingPage bitmap retrieval
+    wxUnusedVar(name);
+    return wxNullBitmap;
+////@end wxRichTextIndentsSpacingPage bitmap retrieval
+}
+
+/*!
+ * Get icon resources
+ */
+
+wxIcon wxRichTextIndentsSpacingPage::GetIconResource( const wxString& name )
+{
+    // Icon retrieval
+////@begin wxRichTextIndentsSpacingPage icon retrieval
+    wxUnusedVar(name);
+    return wxNullIcon;
+////@end wxRichTextIndentsSpacingPage icon retrieval
+}
+/*!
+ * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_LEFT
+ */
+
+void wxRichTextIndentsSpacingPage::OnAlignmentLeftSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_RIGHT
+ */
+
+void wxRichTextIndentsSpacingPage::OnAlignmentRightSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_JUSTIFIED
+ */
+
+void wxRichTextIndentsSpacingPage::OnAlignmentJustifiedSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_CENTRED
+ */
+
+void wxRichTextIndentsSpacingPage::OnAlignmentCentredSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_RADIOBUTTON_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_ALIGNMENT_INDETERMINATE
+ */
+
+void wxRichTextIndentsSpacingPage::OnAlignmentIndeterminateSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT
+ */
+
+void wxRichTextIndentsSpacingPage::OnIndentLeftUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_LEFT_FIRST
+ */
+
+void wxRichTextIndentsSpacingPage::OnIndentLeftFirstUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_INDENT_RIGHT
+ */
+
+void wxRichTextIndentsSpacingPage::OnIndentRightUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_BEFORE
+ */
+
+void wxRichTextIndentsSpacingPage::OnSpacingBeforeUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
+/*!
+ * wxEVT_COMMAND_TEXT_UPDATED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_AFTER
+ */
+
+void wxRichTextIndentsSpacingPage::OnSpacingAfterUpdated( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+/*!
+ * wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_RICHTEXTINDENTSSPACINGPAGE_SPACING_LINE
+ */
+
+void wxRichTextIndentsSpacingPage::OnSpacingLineSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    if (!m_dontUpdate)
+        UpdatePreview();
+}
+
+
diff --git a/src/richtext/richtextstylepage.cpp b/src/richtext/richtextstylepage.cpp
new file mode 100644 (file)
index 0000000..2003459
--- /dev/null
@@ -0,0 +1,255 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtextstylepage.cpp
+// Purpose:     
+// Author:      Julian Smart
+// Modified by: 
+// Created:     10/5/2006 11:34:55 AM
+// RCS-ID:      
+// Copyright:   (c) Julian Smart
+// Licence:     
+/////////////////////////////////////////////////////////////////////////////
+
+////@begin includes
+////@end includes
+
+#include "../../include/wx/richtext/richtextstylepage.h"
+
+////@begin XPM images
+////@end XPM images
+
+/*!
+ * wxRichTextStylePage type definition
+ */
+
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextStylePage, wxPanel )
+
+/*!
+ * wxRichTextStylePage event table definition
+ */
+
+BEGIN_EVENT_TABLE( wxRichTextStylePage, wxPanel )
+
+////@begin wxRichTextStylePage event table entries
+    EVT_UPDATE_UI( ID_RICHTEXTSTYLEPAGE_NEXT_STYLE, wxRichTextStylePage::OnNextStyleUpdate )
+
+////@end wxRichTextStylePage event table entries
+
+END_EVENT_TABLE()
+
+/*!
+ * wxRichTextStylePage constructors
+ */
+
+wxRichTextStylePage::wxRichTextStylePage( )
+{
+    Init();
+}
+
+wxRichTextStylePage::wxRichTextStylePage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+    Init();
+    Create(parent, id, pos, size, style);
+}
+
+/*!
+ * Initialise members
+ */
+void wxRichTextStylePage::Init()
+{
+////@begin wxRichTextStylePage member initialisation
+    m_styleName = NULL;
+    m_basedOn = NULL;
+    m_nextStyle = NULL;
+////@end wxRichTextStylePage member initialisation
+}
+
+/*!
+ * wxRichTextStylePage creator
+ */
+
+bool wxRichTextStylePage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+////@begin wxRichTextStylePage creation
+    wxPanel::Create( parent, id, pos, size, style );
+
+    CreateControls();
+    if (GetSizer())
+    {
+        GetSizer()->SetSizeHints(this);
+    }
+    Centre();
+////@end wxRichTextStylePage creation
+    return true;
+}
+
+/*!
+ * Control creation for wxRichTextStylePage
+ */
+
+void wxRichTextStylePage::CreateControls()
+{    
+////@begin wxRichTextStylePage content construction
+    wxRichTextStylePage* itemPanel1 = this;
+
+    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
+    itemPanel1->SetSizer(itemBoxSizer2);
+
+    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_HORIZONTAL, 5);
+
+    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Style:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    m_styleName = new wxTextCtrl( itemPanel1, ID_RICHTEXTSTYLEPAGE_STYLE_NAME, _T(""), wxDefaultPosition, wxSize(300, -1), 0 );
+    itemBoxSizer5->Add(m_styleName, 0, wxGROW|wxALL, 5);
+
+    wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Based on:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText8, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_basedOnStrings = NULL;
+    m_basedOn = new wxComboBox( itemPanel1, ID_RICHTEXTSTYLEPAGE_BASED_ON, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_basedOnStrings, wxCB_DROPDOWN );
+    itemBoxSizer5->Add(m_basedOn, 0, wxGROW|wxALL, 5);
+
+    wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Next style:"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    wxString* m_nextStyleStrings = NULL;
+    m_nextStyle = new wxComboBox( itemPanel1, ID_RICHTEXTSTYLEPAGE_NEXT_STYLE, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_nextStyleStrings, wxCB_DROPDOWN );
+    itemBoxSizer5->Add(m_nextStyle, 0, wxGROW|wxALL, 5);
+
+    itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+////@end wxRichTextStylePage content construction
+}
+
+/// Transfer data from/to window
+bool wxRichTextStylePage::TransferDataFromWindow()
+{
+    wxPanel::TransferDataFromWindow();
+
+    wxRichTextStyleDefinition* def = wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
+    wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
+    if (paraDef)
+        paraDef->SetNextStyle(m_nextStyle->GetValue());
+
+    def->SetName(m_styleName->GetValue());
+    def->SetBaseStyle(m_basedOn->GetValue());
+
+    return true;
+}
+
+bool wxRichTextStylePage::TransferDataToWindow()
+{
+    wxPanel::TransferDataToWindow();
+
+    wxRichTextStyleDefinition* def = wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
+    wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition);
+    wxRichTextStyleSheet* sheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
+
+    m_styleName->SetValue(def->GetName());
+
+    if (paraDef)
+    {
+        if (m_nextStyle->GetCount() == 0)
+        {
+            if (sheet)
+            {
+                size_t i;
+                for (i = 0; i < sheet->GetParagraphStyleCount(); i++)
+                {
+                    wxRichTextParagraphStyleDefinition* p = wxDynamicCast(sheet->GetParagraphStyle(i), wxRichTextParagraphStyleDefinition);
+                    if (p)
+                        m_nextStyle->Append(p->GetName());
+                }
+            }
+        }
+        m_nextStyle->SetValue(paraDef->GetNextStyle());
+    }
+    
+    if (m_basedOn->GetCount() == 0)
+    {
+        if (sheet)
+        {
+            if (paraDef)
+            {
+                size_t i;
+                for (i = 0; i < sheet->GetParagraphStyleCount(); i++)
+                {
+                    wxRichTextParagraphStyleDefinition* p = wxDynamicCast(sheet->GetParagraphStyle(i), wxRichTextParagraphStyleDefinition);
+                    if (p)
+                        m_basedOn->Append(p->GetName());
+                }
+            }
+            else
+            {
+                size_t i;
+                for (i = 0; i < sheet->GetCharacterStyleCount(); i++)
+                {
+                    wxRichTextCharacterStyleDefinition* p = wxDynamicCast(sheet->GetCharacterStyle(i), wxRichTextCharacterStyleDefinition);
+                    if (p)
+                        m_basedOn->Append(p->GetName());
+                }
+            }
+        }
+    }
+    
+    m_basedOn->SetValue(def->GetBaseStyle());
+
+    return true;
+}
+
+wxTextAttrEx* wxRichTextStylePage::GetAttributes()
+{
+    return wxRichTextFormattingDialog::GetDialogAttributes(this);
+}
+
+/*!
+ * Should we show tooltips?
+ */
+
+bool wxRichTextStylePage::ShowToolTips()
+{
+    return true;
+}
+
+/*!
+ * Get bitmap resources
+ */
+
+wxBitmap wxRichTextStylePage::GetBitmapResource( const wxString& name )
+{
+    // Bitmap retrieval
+////@begin wxRichTextStylePage bitmap retrieval
+    wxUnusedVar(name);
+    return wxNullBitmap;
+////@end wxRichTextStylePage bitmap retrieval
+}
+
+/*!
+ * Get icon resources
+ */
+
+wxIcon wxRichTextStylePage::GetIconResource( const wxString& name )
+{
+    // Icon retrieval
+////@begin wxRichTextStylePage icon retrieval
+    wxUnusedVar(name);
+    return wxNullIcon;
+////@end wxRichTextStylePage icon retrieval
+}
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
+ */
+
+void wxRichTextStylePage::OnNextStyleUpdate( wxUpdateUIEvent& event )
+{
+    wxRichTextStyleDefinition* def = wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
+    event.Enable(def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition)));
+}
diff --git a/src/richtext/richtexttabspage.cpp b/src/richtext/richtexttabspage.cpp
new file mode 100644 (file)
index 0000000..3d03a74
--- /dev/null
@@ -0,0 +1,350 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        richtexttabspage.cpp
+// Purpose:
+// Author:      Julian Smart
+// Modified by:
+// Created:     10/4/2006 8:03:20 AM
+// RCS-ID:
+// Copyright:   (c) Julian Smart
+// Licence:
+/////////////////////////////////////////////////////////////////////////////
+
+////@begin includes
+////@end includes
+
+#include "../../include/wx/richtext/richtexttabspage.h"
+
+////@begin XPM images
+////@end XPM images
+
+/*!
+ * wxRichTextTabsPage type definition
+ */
+
+IMPLEMENT_DYNAMIC_CLASS( wxRichTextTabsPage, wxPanel )
+
+/*!
+ * wxRichTextTabsPage event table definition
+ */
+
+BEGIN_EVENT_TABLE( wxRichTextTabsPage, wxPanel )
+
+////@begin wxRichTextTabsPage event table entries
+    EVT_LISTBOX( ID_RICHTEXTTABSPAGE_TABLIST, wxRichTextTabsPage::OnTablistSelected )
+
+    EVT_BUTTON( ID_RICHTEXTTABSPAGE_NEW_TAB, wxRichTextTabsPage::OnNewTabClick )
+    EVT_UPDATE_UI( ID_RICHTEXTTABSPAGE_NEW_TAB, wxRichTextTabsPage::OnNewTabUpdate )
+
+    EVT_BUTTON( ID_RICHTEXTTABSPAGE_DELETE_TAB, wxRichTextTabsPage::OnDeleteTabClick )
+    EVT_UPDATE_UI( ID_RICHTEXTTABSPAGE_DELETE_TAB, wxRichTextTabsPage::OnDeleteTabUpdate )
+
+    EVT_BUTTON( ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS, wxRichTextTabsPage::OnDeleteAllTabsClick )
+    EVT_UPDATE_UI( ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS, wxRichTextTabsPage::OnDeleteAllTabsUpdate )
+
+////@end wxRichTextTabsPage event table entries
+
+END_EVENT_TABLE()
+
+/*!
+ * wxRichTextTabsPage constructors
+ */
+
+wxRichTextTabsPage::wxRichTextTabsPage( )
+{
+    Init();
+}
+
+wxRichTextTabsPage::wxRichTextTabsPage( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+    Init();
+    Create(parent, id, pos, size, style);
+}
+
+/*!
+ * Initialise members
+ */
+void wxRichTextTabsPage::Init()
+{
+    m_tabsPresent = false;
+
+////@begin wxRichTextTabsPage member initialisation
+    m_tabEditCtrl = NULL;
+    m_tabListCtrl = NULL;
+////@end wxRichTextTabsPage member initialisation
+}
+
+/*!
+ * wxRichTextTabsPage creator
+ */
+
+bool wxRichTextTabsPage::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style )
+{
+////@begin wxRichTextTabsPage creation
+    wxPanel::Create( parent, id, pos, size, style );
+
+    CreateControls();
+    if (GetSizer())
+    {
+        GetSizer()->SetSizeHints(this);
+    }
+    Centre();
+////@end wxRichTextTabsPage creation
+    return true;
+}
+
+/*!
+ * Control creation for wxRichTextTabsPage
+ */
+
+void wxRichTextTabsPage::CreateControls()
+{
+////@begin wxRichTextTabsPage content construction
+    wxRichTextTabsPage* itemPanel1 = this;
+
+    wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
+    itemPanel1->SetSizer(itemBoxSizer2);
+
+    wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 5);
+
+    wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
+    itemBoxSizer3->Add(itemBoxSizer4, 1, wxGROW, 5);
+
+    wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Position (tenths of a mm):"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
+
+    m_tabEditCtrl = new wxTextCtrl( itemPanel1, ID_RICHTEXTTABSPAGE_TABEDIT, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer5->Add(m_tabEditCtrl, 0, wxGROW|wxALL, 5);
+
+    wxString* m_tabListCtrlStrings = NULL;
+    m_tabListCtrl = new wxListBox( itemPanel1, ID_RICHTEXTTABSPAGE_TABLIST, wxDefaultPosition, wxSize(80, 200), 0, m_tabListCtrlStrings, wxLB_SINGLE );
+    itemBoxSizer5->Add(m_tabListCtrl, 1, wxGROW|wxLEFT|wxRIGHT|wxBOTTOM, 5);
+
+    itemBoxSizer4->Add(2, 1, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
+
+    wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxVERTICAL);
+    itemBoxSizer4->Add(itemBoxSizer10, 0, wxGROW, 5);
+
+    wxStaticText* itemStaticText11 = new wxStaticText( itemPanel1, wxID_STATIC, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer10->Add(itemStaticText11, 0, wxALIGN_CENTER_HORIZONTAL|wxBOTTOM|wxADJUST_MINSIZE, 5);
+
+    wxButton* itemButton12 = new wxButton( itemPanel1, ID_RICHTEXTTABSPAGE_NEW_TAB, _("&New"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer10->Add(itemButton12, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
+
+    wxButton* itemButton13 = new wxButton( itemPanel1, ID_RICHTEXTTABSPAGE_DELETE_TAB, _("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer10->Add(itemButton13, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
+
+    wxButton* itemButton14 = new wxButton( itemPanel1, ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS, _("Delete A&ll"), wxDefaultPosition, wxDefaultSize, 0 );
+    itemBoxSizer10->Add(itemButton14, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxBOTTOM, 5);
+
+////@end wxRichTextTabsPage content construction
+}
+
+/// Transfer data from/to window
+bool wxRichTextTabsPage::TransferDataFromWindow()
+{
+    wxPanel::TransferDataFromWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    if (m_tabsPresent)
+    {
+        wxArrayInt tabs;
+        size_t i;
+        for (i = 0; i < m_tabListCtrl->GetCount(); i++)
+        {
+            tabs.Add(wxAtoi(m_tabListCtrl->GetString(i)));
+        }
+        attr->SetTabs(tabs);
+    }
+    return true;
+}
+
+bool wxRichTextTabsPage::TransferDataToWindow()
+{
+    wxPanel::TransferDataToWindow();
+
+    wxTextAttrEx* attr = GetAttributes();
+
+    m_tabListCtrl->Clear();
+    m_tabEditCtrl->SetValue(wxEmptyString);
+
+    if (attr->HasTabs())
+    {
+        m_tabsPresent = true;
+        size_t i;
+        for (i = 0; i < attr->GetTabs().GetCount(); i++)
+        {
+            wxString s(wxString::Format(wxT("%d"), attr->GetTabs()[i]));
+            m_tabListCtrl->Append(s);
+        }
+    }
+
+    return true;
+}
+
+static int wxTabSortFunc(int* a, int* b)
+{
+    if ((*a) < (*b))
+        return -1;
+    else if ((*b) < (*a))
+        return 1;
+    else
+        return 0;
+}
+
+/// Sorts the tab array
+void wxRichTextTabsPage::SortTabs()
+{
+    wxArrayInt tabs;
+    size_t i;
+    for (i = 0; i < m_tabListCtrl->GetCount(); i++)
+    {
+        tabs.Add(wxAtoi(m_tabListCtrl->GetString(i)));
+    }
+    tabs.Sort(& wxTabSortFunc);
+
+    m_tabListCtrl->Clear();
+    for (i = 0; i < tabs.GetCount(); i++)
+    {
+        wxString s(wxString::Format(wxT("%d"), tabs[i]));
+        m_tabListCtrl->Append(s);
+    }
+}
+
+wxTextAttrEx* wxRichTextTabsPage::GetAttributes()
+{
+    return wxRichTextFormattingDialog::GetDialogAttributes(this);
+}
+
+/*!
+ * Should we show tooltips?
+ */
+
+bool wxRichTextTabsPage::ShowToolTips()
+{
+    return true;
+}
+
+/*!
+ * Get bitmap resources
+ */
+
+wxBitmap wxRichTextTabsPage::GetBitmapResource( const wxString& name )
+{
+    // Bitmap retrieval
+////@begin wxRichTextTabsPage bitmap retrieval
+    wxUnusedVar(name);
+    return wxNullBitmap;
+////@end wxRichTextTabsPage bitmap retrieval
+}
+
+/*!
+ * Get icon resources
+ */
+
+wxIcon wxRichTextTabsPage::GetIconResource( const wxString& name )
+{
+    // Icon retrieval
+////@begin wxRichTextTabsPage icon retrieval
+    wxUnusedVar(name);
+    return wxNullIcon;
+////@end wxRichTextTabsPage icon retrieval
+}
+
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTTABSPAGE_NEW_TAB
+ */
+
+void wxRichTextTabsPage::OnNewTabClick( wxCommandEvent& WXUNUSED(event) )
+{
+    wxString str = m_tabEditCtrl->GetValue();
+    if (!str.IsEmpty() && str.IsNumber())
+    {
+        wxString s(wxString::Format(wxT("%d"), wxAtoi(str)));
+
+        m_tabListCtrl->Append(s);
+        m_tabsPresent = true;
+
+        SortTabs();
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTTABSPAGE_NEW_TAB
+ */
+
+void wxRichTextTabsPage::OnNewTabUpdate( wxUpdateUIEvent& event )
+{
+    // This may be a bit expensive - consider updating New button when text
+    // changes in edit control
+    wxString str = m_tabEditCtrl->GetValue();
+    if (!str.IsEmpty() && str.IsNumber())
+    {
+        wxString s(wxString::Format(wxT("%d"), wxAtoi(str)));
+        event.Enable(m_tabListCtrl->FindString(s) == wxNOT_FOUND);
+    }
+    else
+        event.Enable(false);
+}
+
+
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTTABSPAGE_DELETE_TAB
+ */
+
+void wxRichTextTabsPage::OnDeleteTabClick( wxCommandEvent& WXUNUSED(event) )
+{
+    if (m_tabsPresent && m_tabListCtrl->GetCount() > 0 && m_tabListCtrl->GetSelection() != wxNOT_FOUND)
+    {
+        m_tabListCtrl->Delete(m_tabListCtrl->GetSelection());
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTTABSPAGE_DELETE_TAB
+ */
+
+void wxRichTextTabsPage::OnDeleteTabUpdate( wxUpdateUIEvent& event )
+{
+    event.Enable( m_tabsPresent && m_tabListCtrl->GetCount() > 0 && m_tabListCtrl->GetSelection() != wxNOT_FOUND );
+}
+
+
+/*!
+ * wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS
+ */
+
+void wxRichTextTabsPage::OnDeleteAllTabsClick( wxCommandEvent& WXUNUSED(event) )
+{
+    if (m_tabsPresent && m_tabListCtrl->GetCount() > 0)
+    {
+        m_tabListCtrl->Clear();
+        m_tabEditCtrl->SetValue(wxEmptyString);
+    }
+}
+
+/*!
+ * wxEVT_UPDATE_UI event handler for ID_RICHTEXTTABSPAGE_DELETE_ALL_TABS
+ */
+
+void wxRichTextTabsPage::OnDeleteAllTabsUpdate( wxUpdateUIEvent& event )
+{
+    event.Enable( m_tabsPresent && m_tabListCtrl->GetCount() > 0 );
+}
+
+
+/*!
+ * wxEVT_COMMAND_LISTBOX_SELECTED event handler for ID_RICHTEXTTABSPAGE_TABLIST
+ */
+
+void wxRichTextTabsPage::OnTablistSelected( wxCommandEvent& WXUNUSED(event) )
+{
+    wxString str = m_tabListCtrl->GetStringSelection();
+    if (!str.IsEmpty())
+        m_tabEditCtrl->SetValue(str);
+}