This dialog allows the user to edit a character and/or paragraph style.
In the constructor, specify the pages that will be created. Use GetStyle to retrieve the common style for a given range, and then use ApplyStyle to apply the user-selected formatting to a control. For example:
wxRichTextRange range; if (m_richTextCtrl->HasSelection()) range = m_richTextCtrl->GetSelectionRange(); else range = wxRichTextRange(0, m_richTextCtrl->GetLastPosition()+1); int pages = wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING|wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS; wxRichTextFormattingDialog formatDlg(pages, this); formatDlg.GetStyle(m_richTextCtrl, range); if (formatDlg.ShowModal() == wxID_OK) { formatDlg.ApplyStyle(m_richTextCtrl, range); }Derived from
Include files
<wx/richtext/richtextformatdlg.h>
Data structures
The following flags passed to the dialog constructor indicate the pages to be created:
#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 0x0010Members
wxRichTextFormattingDialog::wxRichTextFormattingDialog
wxRichTextFormattingDialog::~wxRichTextFormattingDialog
wxRichTextFormattingDialog::ApplyStyle
wxRichTextFormattingDialog::Create
wxRichTextFormattingDialog::GetAttributes
wxRichTextFormattingDialog::GetDialog
wxRichTextFormattingDialog::GetDialogAttributes
wxRichTextFormattingDialog::GetDialogStyleDefinition
wxRichTextFormattingDialog::GetFormattingDialogFactory
wxRichTextFormattingDialog::GetImageList
wxRichTextFormattingDialog::GetStyle
wxRichTextFormattingDialog::GetStyleDefinition
wxRichTextFormattingDialog::GetStyleSheet
wxRichTextFormattingDialog::SetAttributes
wxRichTextFormattingDialog::SetFormattingDialogFactory
wxRichTextFormattingDialog::SetImageList
wxRichTextFormattingDialog::SetStyle
wxRichTextFormattingDialog::SetStyleDefinition
wxRichTextFormattingDialog::UpdateDisplay
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)
wxRichTextFormattingDialog()
Constructors.
Parameters
flags
parent
id
title
pos
size
style
~wxRichTextFormattingDialog()
Destructor.
bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE)
Apply attributes to the given range, only changing attributes that need to be changed.
bool Create(long flags, wxWindow* parent, const wxString& title, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE)
Creation: see the constructor for details about the parameters.
const wxTextAttrEx& GetAttributes() const
wxTextAttrEx& GetAttributes()
Gets the attributes being edited.
wxRichTextFormattingDialog* GetDialog(wxWindow* win)
Helper for pages to get the top-level dialog.
wxTextAttrEx* GetDialogAttributes(wxWindow* win)
Helper for pages to get the attributes.
wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win)
Helper for pages to get the style.
wxRichTextFormattingDialogFactory* GetFormattingDialogFactory()
Returns the object to be used to customize the dialog and provide pages.
wxImageList* GetImageList() const
Returns the image list associated with the dialog, used for example if showing the dialog as a toolbook.
bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range)
Gets common attributes from the given range and calls SetAttributes. Attributes that do not have common values in the given range will be omitted from the style's flags.
wxRichTextStyleDefinition* GetStyleDefinition() const
Gets the associated style definition, if any.
wxRichTextStyleSheet* GetStyleSheet() const
Gets the associated style sheet, if any.
void SetAttributes(const wxTextAttrEx& attr)
Sets the attributes to be edited.
void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory)
Sets the formatting factory object to be used for customization and page creation. It deletes the existing factory object.
void SetImageList(wxImageList* imageList)
Sets the image list associated with the dialog's property sheet.
bool SetStyle(const wxTextAttrEx& style, bool update = true)
Sets the attributes and optionally updates the display, if update is true.
bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update = true)
Sets the style definition and optionally update the display, if update is true.
bool UpdateDisplay()
Updates the display.