2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: richtext/richtextformatdlg.h
|
2008-10-09 12:30:57 -04:00
|
|
|
// Purpose: interface of wxRichTextFormattingDialog*
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxRichTextFormattingDialogFactory
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class provides pages for wxRichTextFormattingDialog, and allows other
|
|
|
|
customization of the dialog.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
|
|
|
A default instance of this class is provided automatically.
|
|
|
|
If you wish to change the behaviour of the formatting dialog (for example add
|
|
|
|
or replace a page), you may derive from this class, override one or more
|
|
|
|
functions, and call the static function
|
2008-03-08 08:52:38 -05:00
|
|
|
wxRichTextFormattingDialog::SetFormattingDialogFactory.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxrichtext}
|
2008-10-09 12:30:57 -04:00
|
|
|
@category{richtext}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextFormattingDialogFactory : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextFormattingDialogFactory();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextFormattingDialogFactory();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the main dialog buttons.
|
|
|
|
*/
|
|
|
|
virtual bool CreateButtons(wxRichTextFormattingDialog* dialog);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a page, given a page identifier.
|
|
|
|
*/
|
|
|
|
virtual wxPanel* CreatePage(int page, wxString& title,
|
|
|
|
wxRichTextFormattingDialog* dialog);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Creates all pages under the dialog's book control, also calling AddPage().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual bool CreatePages(long pages,
|
|
|
|
wxRichTextFormattingDialog* dialog);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Enumerate all available page identifiers.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
virtual int GetPageId(int i) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the number of available page identifiers.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
virtual int GetPageIdCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the image index for the given page identifier.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
virtual int GetPageImage(int id) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the property sheet style, called at the start of
|
|
|
|
wxRichTextFormattingDialog::Create.
|
|
|
|
*/
|
|
|
|
virtual bool SetSheetStyle(wxRichTextFormattingDialog* dialog);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Invokes help for the dialog.
|
|
|
|
*/
|
|
|
|
virtual bool ShowHelp(int page,
|
|
|
|
wxRichTextFormattingDialog* dialog);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
#define wxRICHTEXT_FORMAT_STYLE_EDITOR 0x0001
|
|
|
|
#define wxRICHTEXT_FORMAT_FONT 0x0002
|
|
|
|
#define wxRICHTEXT_FORMAT_TABS 0x0004
|
|
|
|
#define wxRICHTEXT_FORMAT_BULLETS 0x0008
|
|
|
|
#define wxRICHTEXT_FORMAT_INDENTS_SPACING 0x0010
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextFormattingDialog
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This dialog allows the user to edit a character and/or paragraph style.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
In the constructor, specify the pages that will be created.
|
|
|
|
Use wxRichTextFormattingDialog::GetStyle() to retrieve the common style
|
|
|
|
for a given range, and then use wxRichTextFormattingDialog::ApplyStyle()
|
|
|
|
to apply the user-selected formatting to a control.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
For example:
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
2008-10-09 12:30:57 -04:00
|
|
|
wxRichTextRange range;
|
2008-03-08 08:52:38 -05:00
|
|
|
if (m_richTextCtrl-HasSelection())
|
|
|
|
range = m_richTextCtrl-GetSelectionRange();
|
|
|
|
else
|
|
|
|
range = wxRichTextRange(0, m_richTextCtrl-GetLastPosition()+1);
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
int pages = wxRICHTEXT_FORMAT_FONT|wxRICHTEXT_FORMAT_INDENTS_SPACING| \
|
|
|
|
wxRICHTEXT_FORMAT_TABS|wxRICHTEXT_FORMAT_BULLETS;
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxRichTextFormattingDialog formatDlg(pages, this);
|
|
|
|
formatDlg.GetStyle(m_richTextCtrl, range);
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
if (formatDlg.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
formatDlg.ApplyStyle(m_richTextCtrl, range);
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxrichtext}
|
2008-03-09 13:09:29 -04:00
|
|
|
@category{richtext}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextFormattingDialog : public wxPropertySheetDialog
|
|
|
|
{
|
|
|
|
public:
|
2012-05-20 08:25:22 -04:00
|
|
|
enum { Option_AllowPixelFontSize = 0x0001 };
|
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
/**
|
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxRichTextFormattingDialog();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructors.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param flags
|
2008-03-09 08:33:59 -04:00
|
|
|
The pages to show.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
The dialog's parent.
|
2009-01-08 11:33:08 -05:00
|
|
|
@param title
|
|
|
|
The dialog's title.
|
|
|
|
@param id
|
|
|
|
The dialog's ID.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
The dialog's position.
|
2008-10-09 12:30:57 -04:00
|
|
|
@param sz
|
2008-03-09 08:33:59 -04:00
|
|
|
The dialog's size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The dialog's window style.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-08 11:33:08 -05:00
|
|
|
wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = "Formatting",
|
|
|
|
wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& sz = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextFormattingDialog();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Apply attributes to the given range, only changing attributes that
|
|
|
|
need to be changed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range,
|
|
|
|
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Creation: see wxRichTextFormattingDialog() "the constructor" for
|
2008-03-08 08:52:38 -05:00
|
|
|
details about the parameters.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
bool Create(long flags, wxWindow* parent,
|
2009-01-18 16:46:46 -05:00
|
|
|
const wxString& title = wxGetTranslation("Formatting"), wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_DIALOG_STYLE);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Gets the attributes being edited.
|
|
|
|
*/
|
2008-10-09 12:30:57 -04:00
|
|
|
const wxTextAttr& GetAttributes() const;
|
|
|
|
wxTextAttr& GetAttributes();
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Helper for pages to get the top-level dialog.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
static wxRichTextFormattingDialog* GetDialog(wxWindow* win);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Helper for pages to get the attributes.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
static wxTextAttr* GetDialogAttributes(wxWindow* win);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Helper for pages to get the style.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the object to be used to customize the dialog and provide pages.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
static wxRichTextFormattingDialogFactory* GetFormattingDialogFactory();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the image list associated with the dialog, used for example if showing
|
|
|
|
the dialog as a toolbook.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxImageList* GetImageList() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Gets common attributes from the given range and calls SetAttributes().
|
|
|
|
Attributes that do not have common values in the given range
|
2008-03-08 08:52:38 -05:00
|
|
|
will be omitted from the style's flags.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the associated style definition, if any.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxRichTextStyleDefinition* GetStyleDefinition() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the associated style sheet, if any.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxRichTextStyleSheet* GetStyleSheet() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the attributes to be edited.
|
|
|
|
*/
|
|
|
|
void SetAttributes(const wxTextAttr& attr);
|
|
|
|
|
2012-05-20 08:25:22 -04:00
|
|
|
/**
|
|
|
|
Sets the dialog options, determining what the interface presents to the user.
|
|
|
|
Currently the only option is Option_AllowPixelFontSize.
|
|
|
|
*/
|
|
|
|
void SetOptions(int options) { m_options = options; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the dialog options, determining what the interface presents to the user.
|
|
|
|
Currently the only option is Option_AllowPixelFontSize.
|
|
|
|
*/
|
|
|
|
int GetOptions() const { return m_options; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the given option is present.
|
|
|
|
*/
|
|
|
|
bool HasOption(int option) const { return (m_options & option) != 0; }
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Sets the formatting factory object to be used for customization and page
|
|
|
|
creation.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
It deletes the existing factory object.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
static void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the image list associated with the dialog's property sheet.
|
|
|
|
*/
|
|
|
|
void SetImageList(wxImageList* imageList);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets the attributes and optionally updates the display, if @a update is @true.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool SetStyle(const wxTextAttr& style, bool update = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Sets the style definition and optionally update the display,
|
|
|
|
if @a update is @true.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef,
|
|
|
|
wxRichTextStyleSheet* sheet,
|
|
|
|
bool update = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Updates the display.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool UpdateDisplay();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|