1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextformatdlg.h
3 // Purpose: interface of wxRichTextFormattingDialogFactory
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRichTextFormattingDialogFactory
12 This class provides pages for wxRichTextFormattingDialog, and allows other
13 customization of the dialog.
14 A default instance of this class is provided automatically. If you wish to
15 change the behaviour of the
16 formatting dialog (for example add or replace a page), you may derive from this
18 override one or more functions, and call the static function
19 wxRichTextFormattingDialog::SetFormattingDialogFactory.
24 class wxRichTextFormattingDialogFactory
: public wxObject
30 wxRichTextFormattingDialogFactory();
35 virtual ~wxRichTextFormattingDialogFactory();
38 Creates the main dialog buttons.
40 virtual bool CreateButtons(wxRichTextFormattingDialog
* dialog
);
43 Creates a page, given a page identifier.
45 virtual wxPanel
* CreatePage(int page
, wxString
& title
,
46 wxRichTextFormattingDialog
* dialog
);
49 Creates all pages under the dialog's book control, also calling AddPage.
51 virtual bool CreatePages(long pages
,
52 wxRichTextFormattingDialog
* dialog
);
55 Enumerate all available page identifiers.
57 virtual int GetPageId(int i
) const;
60 Gets the number of available page identifiers.
62 virtual int GetPageIdCount() const;
65 Gets the image index for the given page identifier.
67 virtual int GetPageImage(int id
) const;
70 Set the property sheet style, called at the start of
71 wxRichTextFormattingDialog::Create.
73 virtual bool SetSheetStyle(wxRichTextFormattingDialog
* dialog
);
76 Invokes help for the dialog.
78 virtual bool ShowHelp(int page
,
79 wxRichTextFormattingDialog
* dialog
);
85 @class wxRichTextFormattingDialog
87 This dialog allows the user to edit a character and/or paragraph style.
89 In the constructor, specify the pages that will be created. Use GetStyle
90 to retrieve the common style for a given range, and then use ApplyStyle
91 to apply the user-selected formatting to a control. For example:
94 wxRichTextRange range;
95 if (m_richTextCtrl-HasSelection())
96 range = m_richTextCtrl-GetSelectionRange();
98 range = wxRichTextRange(0, m_richTextCtrl-GetLastPosition()+1);
101 wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING|wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS;
103 wxRichTextFormattingDialog formatDlg(pages, this);
104 formatDlg.GetStyle(m_richTextCtrl, range);
106 if (formatDlg.ShowModal() == wxID_OK)
108 formatDlg.ApplyStyle(m_richTextCtrl, range);
115 class wxRichTextFormattingDialog
: public wxPropertySheetDialog
127 The dialog's identifier.
129 The dialog's caption.
131 The dialog's position.
135 The dialog's window style.
137 wxRichTextFormattingDialog(long flags
, wxWindow
* parent
);
138 const wxPoint
& pos
= wxDefaultPosition
, const wxSize
& sz
= wxDefaultSize
, long style
= wxDEFAULT_DIALOG_STYLE
)
139 wxRichTextFormattingDialog();
145 virtual ~wxRichTextFormattingDialog();
148 Apply attributes to the given range, only changing attributes that need to be
151 bool ApplyStyle(wxRichTextCtrl
* ctrl
,
152 const wxRichTextRange
& range
,
153 int flags
= wxRICHTEXT_SETSTYLE_WITH_UNDO
|wxRICHTEXT_SETSTYLE_OPTIMIZE
);
156 Creation: see @ref overview_wxrichtextformattingdialog "the constructor" for
157 details about the parameters.
159 bool Create(long flags
, wxWindow
* parent
, const wxString
& title
,
161 const wxPoint
& pos
= wxDefaultPosition
,
162 const wxSize
& sz
= wxDefaultSize
,
163 long style
= wxDEFAULT_DIALOG_STYLE
);
167 Gets the attributes being edited.
169 const wxTextAttr
GetAttributes();
170 const wxTextAttr
& GetAttributes();
174 Helper for pages to get the top-level dialog.
176 static wxRichTextFormattingDialog
* GetDialog(wxWindow
* win
);
179 Helper for pages to get the attributes.
181 static wxTextAttr
* GetDialogAttributes(wxWindow
* win
);
184 Helper for pages to get the style.
186 static wxRichTextStyleDefinition
* GetDialogStyleDefinition(wxWindow
* win
);
189 Returns the object to be used to customize the dialog and provide pages.
191 static wxRichTextFormattingDialogFactory
* GetFormattingDialogFactory();
194 Returns the image list associated with the dialog, used for example if showing
195 the dialog as a toolbook.
197 wxImageList
* GetImageList() const;
200 Gets common attributes from the given range and calls SetAttributes. Attributes
201 that do not have common values in the given range
202 will be omitted from the style's flags.
204 virtual bool GetStyle(wxRichTextCtrl
* ctrl
, const wxRichTextRange
& range
);
207 Gets the associated style definition, if any.
209 virtual wxRichTextStyleDefinition
* GetStyleDefinition() const;
212 Gets the associated style sheet, if any.
214 virtual wxRichTextStyleSheet
* GetStyleSheet() const;
217 Sets the attributes to be edited.
219 void SetAttributes(const wxTextAttr
& attr
);
222 Sets the formatting factory object to be used for customization and page
224 It deletes the existing factory object.
226 static void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory
* factory
);
229 Sets the image list associated with the dialog's property sheet.
231 void SetImageList(wxImageList
* imageList
);
234 Sets the attributes and optionally updates the display, if @a update is @true.
236 virtual bool SetStyle(const wxTextAttr
& style
, bool update
= true);
239 Sets the style definition and optionally update the display, if @a update is @c
242 virtual bool SetStyleDefinition(const wxRichTextStyleDefinition
& styleDef
,
243 wxRichTextStyleSheet
* sheet
,
249 virtual bool UpdateDisplay();