1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextformatdlg.h
3 // Purpose: documentation for wxRichTextFormattingDialogFactory class
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
);
61 Gets the number of available page identifiers.
63 virtual int GetPageIdCount();
66 Gets the image index for the given page identifier.
68 virtual int GetPageImage(int id
);
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
);
85 @class wxRichTextFormattingDialog
86 @headerfile richtextformatdlg.h wx/richtext/richtextformatdlg.h
88 This dialog allows the user to edit a character and/or paragraph style.
90 In the constructor, specify the pages that will be created. Use GetStyle
91 to retrieve the common style for a given range, and then use ApplyStyle
92 to apply the user-selected formatting to a control. For example:
95 wxRichTextRange range;
96 if (m_richTextCtrl-HasSelection())
97 range = m_richTextCtrl-GetSelectionRange();
99 range = wxRichTextRange(0, m_richTextCtrl-GetLastPosition()+1);
102 wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING|wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS;
104 wxRichTextFormattingDialog formatDlg(pages, this);
105 formatDlg.GetStyle(m_richTextCtrl, range);
107 if (formatDlg.ShowModal() == wxID_OK)
109 formatDlg.ApplyStyle(m_richTextCtrl, range);
116 class wxRichTextFormattingDialog
: public wxPropertySheetDialog
130 The dialog's identifier.
133 The dialog's caption.
136 The dialog's position.
142 The dialog's window style.
144 wxRichTextFormattingDialog(long flags
, wxWindow
* parent
);
145 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& sz
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
)
146 wxRichTextFormattingDialog();
152 ~wxRichTextFormattingDialog();
155 Apply attributes to the given range, only changing attributes that need to be
158 bool ApplyStyle(wxRichTextCtrl
* ctrl
,
159 const wxRichTextRange
& range
,
160 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
|wxRICHTEXT_SETSTYLE_OPTIMIZE
);
163 Creation: see @ref overview_wxrichtextformattingdialog "the constructor" for
164 details about the parameters.
166 bool Create(long flags
, wxWindow
* parent
, const wxString
& title
,
168 const wxPoint
& pos
= wxDefaultPosition
,
169 const wxSize
& sz
= wxDefaultSize
,
170 long style
= wxDEFAULT_DIALOG_STYLE
);
174 Gets the attributes being edited.
176 const wxTextAttr
GetAttributes();
177 wxTextAttr
GetAttributes();
181 Helper for pages to get the top-level dialog.
183 wxRichTextFormattingDialog
* GetDialog(wxWindow
* win
);
186 Helper for pages to get the attributes.
188 wxTextAttr
* GetDialogAttributes(wxWindow
* win
);
191 Helper for pages to get the style.
193 wxRichTextStyleDefinition
* GetDialogStyleDefinition(wxWindow
* win
);
196 Returns the object to be used to customize the dialog and provide pages.
198 wxRichTextFormattingDialogFactory
* GetFormattingDialogFactory();
201 Returns the image list associated with the dialog, used for example if showing
202 the dialog as a toolbook.
204 wxImageList
* GetImageList();
207 Gets common attributes from the given range and calls SetAttributes. Attributes
208 that do not have common values in the given range
209 will be omitted from the style's flags.
211 bool GetStyle(wxRichTextCtrl
* ctrl
, const wxRichTextRange
& range
);
214 Gets the associated style definition, if any.
216 wxRichTextStyleDefinition
* GetStyleDefinition();
219 Gets the associated style sheet, if any.
221 wxRichTextStyleSheet
* GetStyleSheet();
224 Sets the attributes to be edited.
226 void SetAttributes(const wxTextAttr
& attr
);
229 Sets the formatting factory object to be used for customization and page
231 It deletes the existing factory object.
233 void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory
* factory
);
236 Sets the image list associated with the dialog's property sheet.
238 void SetImageList(wxImageList
* imageList
);
241 Sets the attributes and optionally updates the display, if @e update is @true.
243 bool SetStyle(const wxTextAttr
& style
, bool update
= @
true);
246 Sets the style definition and optionally update the display, if @e update is @c
249 bool SetStyleDefinition(const wxRichTextStyleDefinition
& styleDef
,
250 wxRichTextStyleSheet
* sheet
,
251 bool update
= @
true);
256 bool UpdateDisplay();