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
); 
  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
 
 128             The dialog's identifier. 
 130             The dialog's caption. 
 132             The dialog's position. 
 136             The dialog's window style. 
 138     wxRichTextFormattingDialog(long flags
, wxWindow
* parent
); 
 139     const wxPoint
& pos 
= wxDefaultPosition
, const wxSize
& sz 
= wxDefaultSize
, long style 
= wxDEFAULT_DIALOG_STYLE
) 
 140     wxRichTextFormattingDialog(); 
 146     ~wxRichTextFormattingDialog(); 
 149         Apply attributes to the given range, only changing attributes that need to be 
 152     bool ApplyStyle(wxRichTextCtrl
* ctrl
, 
 153                     const wxRichTextRange
& range
, 
 154                     int flags 
= wxRICHTEXT_SETSTYLE_WITH_UNDO
|wxRICHTEXT_SETSTYLE_OPTIMIZE
); 
 157         Creation: see @ref overview_wxrichtextformattingdialog "the constructor" for 
 158         details about the parameters. 
 160     bool Create(long flags
, wxWindow
* parent
, const wxString
& title
, 
 162                 const wxPoint
& pos 
= wxDefaultPosition
, 
 163                                      const wxSize
& sz 
= wxDefaultSize
, 
 164                                                         long style 
= wxDEFAULT_DIALOG_STYLE
); 
 168         Gets the attributes being edited. 
 170     const wxTextAttr 
GetAttributes(); 
 171     const wxTextAttr
&  GetAttributes(); 
 175         Helper for pages to get the top-level dialog. 
 177     wxRichTextFormattingDialog
* GetDialog(wxWindow
* win
); 
 180         Helper for pages to get the attributes. 
 182     wxTextAttr
* GetDialogAttributes(wxWindow
* win
); 
 185         Helper for pages to get the style. 
 187     wxRichTextStyleDefinition
* GetDialogStyleDefinition(wxWindow
* win
); 
 190         Returns the object to be used to customize the dialog and provide pages. 
 192     wxRichTextFormattingDialogFactory
* GetFormattingDialogFactory(); 
 195         Returns the image list associated with the dialog, used for example if showing 
 196         the dialog as a toolbook. 
 198     wxImageList
* GetImageList() const; 
 201         Gets common attributes from the given range and calls SetAttributes. Attributes 
 202         that do not have common values in the given range 
 203         will be omitted from the style's flags. 
 205     bool GetStyle(wxRichTextCtrl
* ctrl
, const wxRichTextRange
& range
); 
 208         Gets the associated style definition, if any. 
 210     wxRichTextStyleDefinition
* GetStyleDefinition() const; 
 213         Gets the associated style sheet, if any. 
 215     wxRichTextStyleSheet
* GetStyleSheet() const; 
 218         Sets the attributes to be edited. 
 220     void SetAttributes(const wxTextAttr
& attr
); 
 223         Sets the formatting factory object to be used for customization and page 
 225         It deletes the existing factory object. 
 227     void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory
* factory
); 
 230         Sets the image list associated with the dialog's property sheet. 
 232     void SetImageList(wxImageList
* imageList
); 
 235         Sets the attributes and optionally updates the display, if @a update is @true. 
 237     bool SetStyle(const wxTextAttr
& style
, bool update 
= true); 
 240         Sets the style definition and optionally update the display, if @a update is @c 
 243     bool SetStyleDefinition(const wxRichTextStyleDefinition
& styleDef
, 
 244                             wxRichTextStyleSheet
* sheet
, 
 250     bool UpdateDisplay();