1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextformatdlg.h
3 // Purpose: interface of wxRichTextFormattingDialogFactory
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRichTextFormattingDialogFactory
11 @headerfile richtextformatdlg.h wx/richtext/richtextformatdlg.h
13 This class provides pages for wxRichTextFormattingDialog, and allows other
14 customization of the dialog.
15 A default instance of this class is provided automatically. If you wish to
16 change the behaviour of the
17 formatting dialog (for example add or replace a page), you may derive from this
19 override one or more functions, and call the static function
20 wxRichTextFormattingDialog::SetFormattingDialogFactory.
25 class wxRichTextFormattingDialogFactory
: public wxObject
31 wxRichTextFormattingDialogFactory();
36 ~wxRichTextFormattingDialogFactory();
39 Creates the main dialog buttons.
41 virtual bool CreateButtons(wxRichTextFormattingDialog
* dialog
);
44 Creates a page, given a page identifier.
46 virtual wxPanel
* CreatePage(int page
, wxString
& title
,
47 wxRichTextFormattingDialog
* dialog
);
50 Creates all pages under the dialog's book control, also calling AddPage.
52 virtual bool CreatePages(long pages
,
53 wxRichTextFormattingDialog
* dialog
);
56 Enumerate all available page identifiers.
58 virtual int GetPageId(int i
) const;
61 Gets the number of available page identifiers.
63 virtual int GetPageIdCount() const;
66 Gets the image index for the given page identifier.
68 virtual int GetPageImage(int id
) const;
71 Set the property sheet style, called at the start of
72 wxRichTextFormattingDialog::Create.
74 virtual bool SetSheetStyle(wxRichTextFormattingDialog
* dialog
);
77 Invokes help for the dialog.
79 virtual bool ShowHelp(int page
,
80 wxRichTextFormattingDialog
* dialog
);
86 @class wxRichTextFormattingDialog
87 @headerfile richtextformatdlg.h wx/richtext/richtextformatdlg.h
89 This dialog allows the user to edit a character and/or paragraph style.
91 In the constructor, specify the pages that will be created. Use GetStyle
92 to retrieve the common style for a given range, and then use ApplyStyle
93 to apply the user-selected formatting to a control. For example:
96 wxRichTextRange range;
97 if (m_richTextCtrl-HasSelection())
98 range = m_richTextCtrl-GetSelectionRange();
100 range = wxRichTextRange(0, m_richTextCtrl-GetLastPosition()+1);
103 wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING|wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS;
105 wxRichTextFormattingDialog formatDlg(pages, this);
106 formatDlg.GetStyle(m_richTextCtrl, range);
108 if (formatDlg.ShowModal() == wxID_OK)
110 formatDlg.ApplyStyle(m_richTextCtrl, range);
117 class wxRichTextFormattingDialog
: public wxPropertySheetDialog
129 The dialog's identifier.
131 The dialog's caption.
133 The dialog's position.
137 The dialog's window style.
139 wxRichTextFormattingDialog(long flags
, wxWindow
* parent
);
140 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& sz
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
)
141 wxRichTextFormattingDialog();
147 ~wxRichTextFormattingDialog();
150 Apply attributes to the given range, only changing attributes that need to be
153 bool ApplyStyle(wxRichTextCtrl
* ctrl
,
154 const wxRichTextRange
& range
,
155 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
|wxRICHTEXT_SETSTYLE_OPTIMIZE
);
158 Creation: see @ref overview_wxrichtextformattingdialog "the constructor" for
159 details about the parameters.
161 bool Create(long flags
, wxWindow
* parent
, const wxString
& title
,
163 const wxPoint
& pos
= wxDefaultPosition
,
164 const wxSize
& sz
= wxDefaultSize
,
165 long style
= wxDEFAULT_DIALOG_STYLE
);
169 Gets the attributes being edited.
171 const wxTextAttr
GetAttributes();
172 const wxTextAttr
& GetAttributes();
176 Helper for pages to get the top-level dialog.
178 wxRichTextFormattingDialog
* GetDialog(wxWindow
* win
);
181 Helper for pages to get the attributes.
183 wxTextAttr
* GetDialogAttributes(wxWindow
* win
);
186 Helper for pages to get the style.
188 wxRichTextStyleDefinition
* GetDialogStyleDefinition(wxWindow
* win
);
191 Returns the object to be used to customize the dialog and provide pages.
193 wxRichTextFormattingDialogFactory
* GetFormattingDialogFactory();
196 Returns the image list associated with the dialog, used for example if showing
197 the dialog as a toolbook.
199 wxImageList
* GetImageList() const;
202 Gets common attributes from the given range and calls SetAttributes. Attributes
203 that do not have common values in the given range
204 will be omitted from the style's flags.
206 bool GetStyle(wxRichTextCtrl
* ctrl
, const wxRichTextRange
& range
);
209 Gets the associated style definition, if any.
211 wxRichTextStyleDefinition
* GetStyleDefinition() const;
214 Gets the associated style sheet, if any.
216 wxRichTextStyleSheet
* GetStyleSheet() const;
219 Sets the attributes to be edited.
221 void SetAttributes(const wxTextAttr
& attr
);
224 Sets the formatting factory object to be used for customization and page
226 It deletes the existing factory object.
228 void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory
* factory
);
231 Sets the image list associated with the dialog's property sheet.
233 void SetImageList(wxImageList
* imageList
);
236 Sets the attributes and optionally updates the display, if @a update is @true.
238 bool SetStyle(const wxTextAttr
& style
, bool update
= true);
241 Sets the style definition and optionally update the display, if @a update is @c
244 bool SetStyleDefinition(const wxRichTextStyleDefinition
& styleDef
,
245 wxRichTextStyleSheet
* sheet
,
251 bool UpdateDisplay();