]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/richtext/richtextformatdlg.h
support for iPhone callbacks
[wxWidgets.git] / interface / wx / richtext / richtextformatdlg.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: richtext/richtextformatdlg.h
9e7ad1ca 3// Purpose: interface of wxRichTextFormattingDialog*
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxRichTextFormattingDialogFactory
7c913512 11
23324ae1
FM
12 This class provides pages for wxRichTextFormattingDialog, and allows other
13 customization of the dialog.
9e7ad1ca
FM
14
15 A default instance of this class is provided automatically.
16 If you wish to change the behaviour of the formatting dialog (for example add
17 or replace a page), you may derive from this class, override one or more
18 functions, and call the static function
23324ae1 19 wxRichTextFormattingDialog::SetFormattingDialogFactory.
7c913512 20
23324ae1 21 @library{wxrichtext}
9e7ad1ca 22 @category{richtext}
23324ae1
FM
23*/
24class wxRichTextFormattingDialogFactory : public wxObject
25{
26public:
27 /**
28 Constructor.
29 */
30 wxRichTextFormattingDialogFactory();
31
32 /**
33 Destructor.
34 */
adaaa686 35 virtual ~wxRichTextFormattingDialogFactory();
23324ae1
FM
36
37 /**
38 Creates the main dialog buttons.
39 */
40 virtual bool CreateButtons(wxRichTextFormattingDialog* dialog);
41
42 /**
43 Creates a page, given a page identifier.
44 */
45 virtual wxPanel* CreatePage(int page, wxString& title,
46 wxRichTextFormattingDialog* dialog);
47
48 /**
9e7ad1ca 49 Creates all pages under the dialog's book control, also calling AddPage().
23324ae1
FM
50 */
51 virtual bool CreatePages(long pages,
52 wxRichTextFormattingDialog* dialog);
53
54 /**
55 Enumerate all available page identifiers.
56 */
328f5751 57 virtual int GetPageId(int i) const;
23324ae1
FM
58
59 /**
60 Gets the number of available page identifiers.
61 */
328f5751 62 virtual int GetPageIdCount() const;
23324ae1
FM
63
64 /**
65 Gets the image index for the given page identifier.
66 */
328f5751 67 virtual int GetPageImage(int id) const;
23324ae1
FM
68
69 /**
70 Set the property sheet style, called at the start of
71 wxRichTextFormattingDialog::Create.
72 */
73 virtual bool SetSheetStyle(wxRichTextFormattingDialog* dialog);
74
75 /**
76 Invokes help for the dialog.
77 */
78 virtual bool ShowHelp(int page,
79 wxRichTextFormattingDialog* dialog);
80};
81
82
e54c96f1 83
9e7ad1ca
FM
84#define wxRICHTEXT_FORMAT_STYLE_EDITOR 0x0001
85#define wxRICHTEXT_FORMAT_FONT 0x0002
86#define wxRICHTEXT_FORMAT_TABS 0x0004
87#define wxRICHTEXT_FORMAT_BULLETS 0x0008
88#define wxRICHTEXT_FORMAT_INDENTS_SPACING 0x0010
89
23324ae1
FM
90/**
91 @class wxRichTextFormattingDialog
7c913512 92
23324ae1 93 This dialog allows the user to edit a character and/or paragraph style.
7c913512 94
9e7ad1ca
FM
95 In the constructor, specify the pages that will be created.
96 Use wxRichTextFormattingDialog::GetStyle() to retrieve the common style
97 for a given range, and then use wxRichTextFormattingDialog::ApplyStyle()
98 to apply the user-selected formatting to a control.
7c913512 99
9e7ad1ca 100 For example:
23324ae1 101 @code
9e7ad1ca 102 wxRichTextRange range;
23324ae1
FM
103 if (m_richTextCtrl-HasSelection())
104 range = m_richTextCtrl-GetSelectionRange();
105 else
106 range = wxRichTextRange(0, m_richTextCtrl-GetLastPosition()+1);
7c913512 107
9e7ad1ca
FM
108 int pages = wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING| \
109 wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS;
7c913512 110
23324ae1
FM
111 wxRichTextFormattingDialog formatDlg(pages, this);
112 formatDlg.GetStyle(m_richTextCtrl, range);
7c913512 113
23324ae1
FM
114 if (formatDlg.ShowModal() == wxID_OK)
115 {
116 formatDlg.ApplyStyle(m_richTextCtrl, range);
117 }
118 @endcode
7c913512 119
23324ae1 120 @library{wxrichtext}
21b447dc 121 @category{richtext}
23324ae1
FM
122*/
123class wxRichTextFormattingDialog : public wxPropertySheetDialog
124{
125public:
32423dd8
JS
126 enum { Option_AllowPixelFontSize = 0x0001 };
127
9e7ad1ca
FM
128 /**
129 Default ctor.
130 */
131 wxRichTextFormattingDialog();
132
23324ae1
FM
133 /**
134 Constructors.
9e7ad1ca 135
7c913512 136 @param flags
4cc4bfaf 137 The pages to show.
7c913512 138 @param parent
4cc4bfaf 139 The dialog's parent.
ccf39540
FM
140 @param title
141 The dialog's title.
142 @param id
143 The dialog's ID.
7c913512 144 @param pos
4cc4bfaf 145 The dialog's position.
9e7ad1ca 146 @param sz
4cc4bfaf 147 The dialog's size.
7c913512 148 @param style
4cc4bfaf 149 The dialog's window style.
23324ae1 150 */
ccf39540
FM
151 wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = "Formatting",
152 wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
153 const wxSize& sz = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE);
23324ae1
FM
154
155 /**
156 Destructor.
157 */
adaaa686 158 virtual ~wxRichTextFormattingDialog();
23324ae1
FM
159
160 /**
9e7ad1ca
FM
161 Apply attributes to the given range, only changing attributes that
162 need to be changed.
23324ae1 163 */
0004982c
FM
164 virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range,
165 int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE);
23324ae1
FM
166
167 /**
9e7ad1ca 168 Creation: see wxRichTextFormattingDialog() "the constructor" for
23324ae1
FM
169 details about the parameters.
170 */
5267aefd 171 bool Create(long flags, wxWindow* parent,
f8ebb70d
FM
172 const wxString& title = wxGetTranslation("Formatting"), wxWindowID id = wxID_ANY,
173 const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize,
174 long style = wxDEFAULT_DIALOG_STYLE);
23324ae1
FM
175
176 //@{
177 /**
178 Gets the attributes being edited.
179 */
9e7ad1ca
FM
180 const wxTextAttr& GetAttributes() const;
181 wxTextAttr& GetAttributes();
23324ae1
FM
182 //@}
183
184 /**
185 Helper for pages to get the top-level dialog.
186 */
adaaa686 187 static wxRichTextFormattingDialog* GetDialog(wxWindow* win);
23324ae1
FM
188
189 /**
190 Helper for pages to get the attributes.
191 */
adaaa686 192 static wxTextAttr* GetDialogAttributes(wxWindow* win);
23324ae1
FM
193
194 /**
195 Helper for pages to get the style.
196 */
adaaa686 197 static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
23324ae1
FM
198
199 /**
200 Returns the object to be used to customize the dialog and provide pages.
201 */
adaaa686 202 static wxRichTextFormattingDialogFactory* GetFormattingDialogFactory();
23324ae1
FM
203
204 /**
205 Returns the image list associated with the dialog, used for example if showing
206 the dialog as a toolbook.
207 */
328f5751 208 wxImageList* GetImageList() const;
23324ae1
FM
209
210 /**
9e7ad1ca
FM
211 Gets common attributes from the given range and calls SetAttributes().
212 Attributes that do not have common values in the given range
23324ae1
FM
213 will be omitted from the style's flags.
214 */
adaaa686 215 virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range);
23324ae1
FM
216
217 /**
218 Gets the associated style definition, if any.
219 */
adaaa686 220 virtual wxRichTextStyleDefinition* GetStyleDefinition() const;
23324ae1
FM
221
222 /**
223 Gets the associated style sheet, if any.
224 */
adaaa686 225 virtual wxRichTextStyleSheet* GetStyleSheet() const;
23324ae1
FM
226
227 /**
228 Sets the attributes to be edited.
229 */
230 void SetAttributes(const wxTextAttr& attr);
231
32423dd8
JS
232 /**
233 Sets the dialog options, determining what the interface presents to the user.
234 Currently the only option is Option_AllowPixelFontSize.
235 */
236 void SetOptions(int options) { m_options = options; }
237
238 /**
239 Gets the dialog options, determining what the interface presents to the user.
240 Currently the only option is Option_AllowPixelFontSize.
241 */
242 int GetOptions() const { return m_options; }
243
244 /**
245 Returns @true if the given option is present.
246 */
247 bool HasOption(int option) const { return (m_options & option) != 0; }
248
23324ae1
FM
249 /**
250 Sets the formatting factory object to be used for customization and page
251 creation.
9e7ad1ca 252
23324ae1
FM
253 It deletes the existing factory object.
254 */
adaaa686 255 static void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory);
23324ae1
FM
256
257 /**
258 Sets the image list associated with the dialog's property sheet.
259 */
260 void SetImageList(wxImageList* imageList);
261
262 /**
4cc4bfaf 263 Sets the attributes and optionally updates the display, if @a update is @true.
23324ae1 264 */
adaaa686 265 virtual bool SetStyle(const wxTextAttr& style, bool update = true);
23324ae1
FM
266
267 /**
9e7ad1ca
FM
268 Sets the style definition and optionally update the display,
269 if @a update is @true.
23324ae1 270 */
adaaa686
FM
271 virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef,
272 wxRichTextStyleSheet* sheet,
273 bool update = true);
23324ae1
FM
274
275 /**
276 Updates the display.
277 */
adaaa686 278 virtual bool UpdateDisplay();
23324ae1 279};
e54c96f1 280