2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: richtext/richtextstyles.h
|
2008-03-09 13:09:29 -04:00
|
|
|
// Purpose: interface of wxRichTextStyleListCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxRichTextStyleListCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
This class incorporates a wxRichTextStyleListBox and a choice control that
|
|
|
|
allows the user to select the category of style to view.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
It is demonstrated in the wxRichTextCtrl sample in @c samples/richtext.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
To use wxRichTextStyleListCtrl, add the control to your window hierarchy and
|
2008-10-09 12:30:57 -04:00
|
|
|
call wxRichTextStyleListCtrl::SetStyleType with one of
|
|
|
|
wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
|
2008-03-08 08:52:38 -05:00
|
|
|
wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH,
|
|
|
|
wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER and
|
|
|
|
wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST to set the current view.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Associate the control with a style sheet and rich text control with
|
2008-10-09 12:30:57 -04:00
|
|
|
SetStyleSheet and SetRichTextCtrl, so that when a style is double-clicked,
|
|
|
|
it is applied to the selection.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR}
|
2008-03-08 08:52:38 -05:00
|
|
|
This style hides the category selection control.
|
|
|
|
@endStyleTable
|
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 wxRichTextStyleListCtrl : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Constructors.
|
|
|
|
*/
|
|
|
|
wxRichTextStyleListCtrl(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
2008-03-08 09:43:31 -05:00
|
|
|
wxRichTextStyleListCtrl();
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the windows.
|
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the associated rich text control, if any.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextCtrl* GetRichTextCtrl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the wxChoice control used for selecting the style category.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxChoice* GetStyleChoice() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the wxListBox control used to view the style list.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleListBox* GetStyleListBox() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the associated style sheet, if any.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleSheet* GetStyleSheet() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the type of style to show in the list box.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleListBox::wxRichTextStyleType GetStyleType() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Associates the control with a wxRichTextCtrl.
|
|
|
|
*/
|
|
|
|
void SetRichTextCtrl(wxRichTextCtrl* ctrl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Associates the control with a style sheet.
|
|
|
|
*/
|
|
|
|
void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Sets the style type to display.
|
|
|
|
|
|
|
|
One of
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH,
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetStyleType(wxRichTextStyleListBox::wxRichTextStyleType styleType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Updates the style list box.
|
|
|
|
*/
|
|
|
|
void UpdateStyles();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextStyleDefinition
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a base class for paragraph and character styles.
|
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 wxRichTextStyleDefinition : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextStyleDefinition(const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextStyleDefinition();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style on which this style is based.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxString GetBaseStyle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style's description.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxString GetDescription() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxString GetName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Returns the attributes associated with this style.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxTextAttr GetStyle() const;
|
|
|
|
const wxTextAttr GetStyle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style attributes combined with the attributes of the specified base
|
|
|
|
style, if any. This function works recursively.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxTextAttr GetStyleMergedWithBase(wxRichTextStyleSheet* sheet) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the name of the style that this style is based on.
|
|
|
|
*/
|
|
|
|
void SetBaseStyle(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the style description.
|
|
|
|
*/
|
|
|
|
void SetDescription(const wxString& descr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the name of the style.
|
|
|
|
*/
|
|
|
|
void SetName(const wxString& name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the attributes for this style.
|
|
|
|
*/
|
|
|
|
void SetStyle(const wxTextAttr& style);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextParagraphStyleDefinition
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a paragraph style definition, usually added to a
|
|
|
|
wxRichTextStyleSheet.
|
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 wxRichTextParagraphStyleDefinition : public wxRichTextStyleDefinition
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextParagraphStyleDefinition(const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextParagraphStyleDefinition();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style that should normally follow this style.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxString GetNextStyle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the style that should normally follow this style.
|
|
|
|
*/
|
|
|
|
void SetNextStyle(const wxString& name);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextStyleListBox
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a listbox that can display the styles in a wxRichTextStyleSheet,
|
|
|
|
and apply the selection to an associated wxRichTextCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
See @c samples/richtext for an example of how to use it.
|
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 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
@see wxRichTextStyleComboCtrl, @ref overview_richtextctrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextStyleListBox : public wxHtmlListBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextStyleListBox(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextStyleListBox();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Applies the @e ith style to the associated rich text control.
|
|
|
|
*/
|
|
|
|
void ApplyStyle(int i);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Converts units in tenths of a millimetre to device units.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int ConvertTenthsMMToPixels(wxDC& dc, int units) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates a suitable HTML fragment for a definition.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString CreateHTML(wxRichTextStyleDefinition* def) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
If the return value is @true, clicking on a style name in the list will
|
2008-10-09 12:30:57 -04:00
|
|
|
immediately apply the style to the associated rich text control.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool GetApplyOnSelection() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the wxRichTextCtrl associated with this listbox.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextCtrl* GetRichTextCtrl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets a style for a listbox index.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleDefinition* GetStyle(size_t i) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style sheet associated with this listbox.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleSheet* GetStyleSheet() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the type of style to show in the list box.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleListBox::wxRichTextStyleType GetStyleType() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the HTML for this item.
|
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual wxString OnGetItem(size_t n) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Implements left click behaviour, applying the clicked style to the
|
|
|
|
wxRichTextCtrl.
|
|
|
|
*/
|
|
|
|
void OnLeftDown(wxMouseEvent& event);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Reacts to selection.
|
|
|
|
*/
|
|
|
|
void OnSelect(wxCommandEvent& event);
|
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a applyOnSelection is @true, clicking on a style name in the list will
|
2008-10-09 12:30:57 -04:00
|
|
|
immediately apply the style to the associated rich text control.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetApplyOnSelection(bool applyOnSelection);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Associates the listbox with a wxRichTextCtrl.
|
|
|
|
*/
|
|
|
|
void SetRichTextCtrl(wxRichTextCtrl* ctrl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Associates the control with a style sheet.
|
|
|
|
*/
|
|
|
|
void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the style type to display. One of
|
2008-10-09 12:30:57 -04:00
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_ALL,
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_PARAGRAPH,
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_CHARACTER
|
|
|
|
- wxRichTextStyleListBox::wxRICHTEXT_STYLE_LIST.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetStyleType(wxRichTextStyleListBox::wxRichTextStyleType styleType);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Updates the list from the associated style sheet.
|
|
|
|
*/
|
|
|
|
void UpdateStyles();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextStyleComboCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a combo control that can display the styles in a wxRichTextStyleSheet,
|
|
|
|
and apply the selection to an associated wxRichTextCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
See @c samples/richtext for an example of how to use it.
|
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 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
@see wxRichTextStyleListBox, @ref overview_richtextctrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextStyleComboCtrl : public wxComboCtrl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextStyleComboCtrl(wxWindow* parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextStyleComboCtrl();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the wxRichTextCtrl associated with this control.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextCtrl* GetRichTextCtrl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style sheet associated with this control.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleSheet* GetStyleSheet() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Associates the control with a wxRichTextCtrl.
|
|
|
|
*/
|
|
|
|
void SetRichTextCtrl(wxRichTextCtrl* ctrl);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Associates the control with a style sheet.
|
|
|
|
*/
|
|
|
|
void SetStyleSheet(wxRichTextStyleSheet* styleSheet);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Updates the combo control from the associated style sheet.
|
|
|
|
*/
|
|
|
|
void UpdateStyles();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextCharacterStyleDefinition
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a character style definition, usually added to a
|
|
|
|
wxRichTextStyleSheet.
|
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 wxRichTextCharacterStyleDefinition : public wxRichTextStyleDefinition
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextCharacterStyleDefinition(const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextCharacterStyleDefinition();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextListStyleDefinition
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a list style definition, usually added to a
|
|
|
|
wxRichTextStyleSheet.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
The class inherits paragraph attributes from wxRichTextStyleParagraphDefinition,
|
|
|
|
and adds 10 further attribute objects, one for each level of a list.
|
2008-03-08 08:52:38 -05:00
|
|
|
When applying a list style to a paragraph, the list style's base and
|
2008-10-09 12:30:57 -04:00
|
|
|
appropriate level attributes are merged with the paragraph's existing attributes.
|
|
|
|
|
|
|
|
You can apply a list style to one or more paragraphs using wxRichTextCtrl::SetListStyle.
|
|
|
|
You can also use the functions wxRichTextCtrl::NumberList, wxRichTextCtrl::PromoteList and
|
|
|
|
wxRichTextCtrl::ClearListStyle.
|
|
|
|
|
|
|
|
As usual, there are wxRichTextBuffer versions of these functions
|
2008-03-08 08:52:38 -05:00
|
|
|
so that you can apply them directly to a buffer without requiring a control.
|
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 wxRichTextListStyleDefinition : public wxRichTextParagraphStyleDefinition
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextListStyleDefinition(const wxString& name = wxEmptyString);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextListStyleDefinition();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This function combines the given paragraph style with the list style's base
|
|
|
|
attributes and level style matching the given indent, returning the combined attributes.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a styleSheet is specified, the base style for this definition will also be
|
2008-03-08 08:52:38 -05:00
|
|
|
included in the result.
|
|
|
|
*/
|
|
|
|
wxTextAttr CombineWithParagraphStyle(int indent,
|
|
|
|
const wxTextAttr& paraStyle,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxRichTextStyleSheet* styleSheet = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This function finds the level (from 0 to 9) whose indentation attribute mostly
|
2008-03-09 08:33:59 -04:00
|
|
|
closely matches @a indent (expressed in tenths of a millimetre).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int FindLevelForIndent(int indent) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This function combines the list style's base attributes and the level style
|
|
|
|
matching the given indent, returning the combined attributes.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a styleSheet is specified, the base style for this definition will also be
|
2008-03-08 08:52:38 -05:00
|
|
|
included in the result.
|
|
|
|
*/
|
|
|
|
wxTextAttr GetCombinedStyle(int indent,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleSheet* styleSheet = NULL) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This function combines the list style's base attributes and the style for the
|
|
|
|
specified level, returning the combined attributes.
|
2008-10-09 12:30:57 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
If @a styleSheet is specified, the base style for this definition will also be
|
2008-03-08 08:52:38 -05:00
|
|
|
included in the result.
|
|
|
|
*/
|
|
|
|
wxTextAttr GetCombinedStyleLevel(int level,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleSheet* styleSheet = NULL) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Returns the style for the given level. @a level is a number between 0 and 9.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxTextAttr* GetLevelAttributes(int level) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of levels. This is hard-wired to 10.
|
|
|
|
Returns the style for the given level. @e level is a number between 0 and 9.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetLevelCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the given level has numbered list attributes.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int IsNumbered(int level) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-09 08:33:59 -04:00
|
|
|
Sets the style for the given level. @a level is a number between 0 and 9.
|
2008-03-08 08:52:38 -05:00
|
|
|
The first and most flexible form uses a wxTextAttr object, while the second
|
|
|
|
form is for convenient setting of the most commonly-used attributes.
|
|
|
|
*/
|
|
|
|
void SetLevelAttributes(int level, const wxTextAttr& attr);
|
2008-03-08 09:43:31 -05:00
|
|
|
void SetLevelAttributes(int level, int leftIndent,
|
|
|
|
int leftSubIndent,
|
|
|
|
int bulletStyle,
|
|
|
|
const wxString& bulletSymbol = wxEmptyString);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextStyleSheet
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
A style sheet contains named paragraph and character styles that make it
|
|
|
|
easy for a user to apply combinations of attributes to a wxRichTextCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
You can use a wxRichTextStyleListBox in your user interface to show available
|
|
|
|
styles to the user, and allow application of styles to the control.
|
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 wxRichTextStyleSheet : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
|
|
|
wxRichTextStyleSheet();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxRichTextStyleSheet();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a definition to the character style list.
|
|
|
|
*/
|
|
|
|
bool AddCharacterStyle(wxRichTextCharacterStyleDefinition* def);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a definition to the list style list.
|
|
|
|
*/
|
|
|
|
bool AddListStyle(wxRichTextListStyleDefinition* def);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a definition to the paragraph style list.
|
|
|
|
*/
|
|
|
|
bool AddParagraphStyle(wxRichTextParagraphStyleDefinition* def);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds a definition to the appropriate style list.
|
|
|
|
*/
|
|
|
|
bool AddStyle(wxRichTextStyleDefinition* def);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deletes all styles.
|
|
|
|
*/
|
|
|
|
void DeleteStyles();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Finds a character definition by name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextCharacterStyleDefinition* FindCharacterStyle(const wxString& name) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finds a list definition by name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextListStyleDefinition* FindListStyle(const wxString& name) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finds a paragraph definition by name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextParagraphStyleDefinition* FindParagraphStyle(const wxString& name) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Finds a style definition by name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextStyleDefinition* FindStyle(const wxString& name) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the @e nth character style.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextCharacterStyleDefinition* GetCharacterStyle(size_t n) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of character styles.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
size_t GetCharacterStyleCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style sheet's description.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxString GetDescription() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the @e nth list style.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextListStyleDefinition* GetListStyle(size_t n) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of list styles.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
size_t GetListStyleCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the style sheet's name.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
const wxString GetName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the @e nth paragraph style.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextParagraphStyleDefinition* GetParagraphStyle(size_t n) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the number of paragraph styles.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
size_t GetParagraphStyleCount() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Removes a character style.
|
|
|
|
*/
|
|
|
|
bool RemoveCharacterStyle(wxRichTextStyleDefinition* def,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool deleteStyle = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Removes a list style.
|
|
|
|
*/
|
|
|
|
bool RemoveListStyle(wxRichTextStyleDefinition* def,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool deleteStyle = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Removes a paragraph style.
|
|
|
|
*/
|
|
|
|
bool RemoveParagraphStyle(wxRichTextStyleDefinition* def,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool deleteStyle = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Removes a style.
|
|
|
|
*/
|
|
|
|
bool RemoveStyle(wxRichTextStyleDefinition* def,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool deleteStyle = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the style sheet's description.
|
|
|
|
*/
|
|
|
|
void SetDescription(const wxString& descr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the style sheet's name.
|
|
|
|
*/
|
|
|
|
void SetName(const wxString& name);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|