X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/97ff49b3834325cfe53813aeb53d326d7661f184..43c42c18d36c703a88b1b7b697bac27fe5608eca:/include/wx/richtext/richtextformatdlg.h diff --git a/include/wx/richtext/richtextformatdlg.h b/include/wx/richtext/richtextformatdlg.h index 234594ddb8..ec785a5b00 100644 --- a/include/wx/richtext/richtextformatdlg.h +++ b/include/wx/richtext/richtextformatdlg.h @@ -21,18 +21,23 @@ #if wxUSE_RICHTEXT #include "wx/propdlg.h" +#include "wx/bookctrl.h" +#include "wx/withimages.h" + #if wxUSE_HTML #include "wx/htmllbox.h" #endif #include "wx/richtext/richtextbuffer.h" #include "wx/richtext/richtextstyles.h" +#include "wx/richtext/richtextuicustomization.h" -class WXDLLEXPORT wxNotebookEvent; -class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog; +class WXDLLIMPEXP_FWD_RICHTEXT wxRichTextFormattingDialog; +class WXDLLIMPEXP_FWD_CORE wxComboBox; +class WXDLLIMPEXP_FWD_CORE wxCheckBox; /*! - * Flags determining the pages to be created in the dialog + * Flags determining the pages and buttons to be created in the dialog */ #define wxRICHTEXT_FORMAT_STYLE_EDITOR 0x0001 @@ -40,6 +45,30 @@ class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog; #define wxRICHTEXT_FORMAT_TABS 0x0004 #define wxRICHTEXT_FORMAT_BULLETS 0x0008 #define wxRICHTEXT_FORMAT_INDENTS_SPACING 0x0010 +#define wxRICHTEXT_FORMAT_LIST_STYLE 0x0020 +#define wxRICHTEXT_FORMAT_MARGINS 0x0040 +#define wxRICHTEXT_FORMAT_SIZE 0x0080 +#define wxRICHTEXT_FORMAT_BORDERS 0x0100 +#define wxRICHTEXT_FORMAT_BACKGROUND 0x0200 + +#define wxRICHTEXT_FORMAT_HELP_BUTTON 0x1000 + +/*! + * Indices for bullet styles in list control + */ + +enum { + wxRICHTEXT_BULLETINDEX_NONE = 0, + wxRICHTEXT_BULLETINDEX_ARABIC, + wxRICHTEXT_BULLETINDEX_UPPER_CASE, + wxRICHTEXT_BULLETINDEX_LOWER_CASE, + wxRICHTEXT_BULLETINDEX_UPPER_CASE_ROMAN, + wxRICHTEXT_BULLETINDEX_LOWER_CASE_ROMAN, + wxRICHTEXT_BULLETINDEX_OUTLINE, + wxRICHTEXT_BULLETINDEX_SYMBOL, + wxRICHTEXT_BULLETINDEX_BITMAP, + wxRICHTEXT_BULLETINDEX_STANDARD +}; /*! * Shorthand for common combinations of pages @@ -59,7 +88,7 @@ public: wxRichTextFormattingDialogFactory() {} virtual ~wxRichTextFormattingDialogFactory() {} -// Overrideables +// Overridables /// Create all pages, under the dialog's book control, also calling AddPage virtual bool CreatePages(long pages, wxRichTextFormattingDialog* dialog); @@ -77,7 +106,7 @@ public: virtual int GetPageImage(int WXUNUSED(id)) const { return -1; } /// Invoke help for the dialog - virtual bool ShowHelp(int WXUNUSED(page), wxRichTextFormattingDialog* WXUNUSED(dialog)) { return false; } + virtual bool ShowHelp(int page, wxRichTextFormattingDialog* dialog); /// Set the sheet style, called at the start of wxRichTextFormattingDialog::Create virtual bool SetSheetStyle(wxRichTextFormattingDialog* dialog); @@ -90,13 +119,18 @@ public: * Formatting dialog for a wxRichTextCtrl */ -class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog: public wxPropertySheetDialog +class WXDLLIMPEXP_RICHTEXT wxRichTextFormattingDialog: public wxPropertySheetDialog, + public wxWithImages { DECLARE_CLASS(wxRichTextFormattingDialog) +DECLARE_HELP_PROVISION() + public: + enum { Option_AllowPixelFontSize = 0x0001 }; + wxRichTextFormattingDialog() { Init(); } - wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = _("Formatting"), wxWindowID id = wxID_ANY, + wxRichTextFormattingDialog(long flags, wxWindow* parent, const wxString& title = wxGetTranslation(wxT("Formatting")), wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE) { @@ -108,7 +142,7 @@ public: void Init(); - bool Create(long flags, wxWindow* parent, const wxString& title, wxWindowID id, + bool Create(long flags, wxWindow* parent, const wxString& title = wxGetTranslation(wxT("Formatting")), wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); @@ -116,7 +150,7 @@ public: virtual bool GetStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range); /// Set the attributes and optionally update the display - virtual bool SetStyle(const wxTextAttrEx& style, bool update = true); + virtual bool SetStyle(const wxRichTextAttr& style, bool update = true); /// Set the style definition and optionally update the display virtual bool SetStyleDefinition(const wxRichTextStyleDefinition& styleDef, wxRichTextStyleSheet* sheet, bool update = true); @@ -133,10 +167,29 @@ public: /// Apply attributes to the given range virtual bool ApplyStyle(wxRichTextCtrl* ctrl, const wxRichTextRange& range, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE); + /// Apply attributes to the object being edited, if any + virtual bool ApplyStyle(wxRichTextCtrl* ctrl, int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO); + /// Gets and sets the attributes - const wxTextAttrEx& GetAttributes() const { return m_attributes; } - wxTextAttrEx& GetAttributes() { return m_attributes; } - void SetAttributes(const wxTextAttrEx& attr) { m_attributes = attr; } + const wxRichTextAttr& GetAttributes() const { return m_attributes; } + wxRichTextAttr& GetAttributes() { return m_attributes; } + void SetAttributes(const wxRichTextAttr& attr) { m_attributes = attr; } + + /// 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; } + + /// If editing the attributes for a particular object, such as an image, + /// set the object so the code can initialize attributes such as size correctly. + wxRichTextObject* GetObject() const { return m_object; } + void SetObject(wxRichTextObject* obj) { m_object = obj; } /// Transfers the data and from to the window virtual bool TransferDataToWindow(); @@ -144,11 +197,11 @@ public: /// Apply the styles when a different tab is selected, so the previews are /// up to date - void OnTabChanged(wxNotebookEvent& event); + void OnTabChanged(wxBookCtrlEvent& event); - /// Set/get image list - void SetImageList(wxImageList* imageList) { m_imageList = imageList; } - wxImageList* GetImageList() const { return m_imageList; } + /// Respond to help command + void OnHelp(wxCommandEvent& event); + void OnUpdateHelp(wxUpdateUIEvent& event); /// Get/set formatting factory object static void SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory); @@ -158,19 +211,46 @@ public: static wxRichTextFormattingDialog* GetDialog(wxWindow* win); /// Helper for pages to get the attributes - static wxTextAttrEx* GetDialogAttributes(wxWindow* win); + static wxRichTextAttr* GetDialogAttributes(wxWindow* win); + + /// Helper for pages to get the reset attributes + static wxRichTextAttr* GetDialogResetAttributes(wxWindow* win); /// Helper for pages to get the style static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win); + /// Should we show tooltips? + static bool ShowToolTips() { return sm_showToolTips; } + + /// Determines whether tooltips will be shown + static void SetShowToolTips(bool show) { sm_showToolTips = show; } + + /// Set the dimension into the value and units controls + static void SetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl, wxCheckBox* checkBox); + + /// Get the dimension from the value and units controls + static void GetDimensionValue(wxTextAttrDimension& dim, wxTextCtrl* valueCtrl, wxComboBox* unitsCtrl, wxCheckBox* checkBox); + + /// Convert CM to MM + static bool ConvertFromString(const wxString& string, int& ret, int scale); + + /// Map book control page index to our page id + void AddPageId(int id) { m_pageIds.Add(id); } + + /// Find a page by class + wxWindow* FindPage(wxClassInfo* info) const; + protected: - wxImageList* m_imageList; - wxTextAttrEx m_attributes; + wxRichTextAttr m_attributes; wxRichTextStyleDefinition* m_styleDefinition; wxRichTextStyleSheet* m_styleSheet; + wxRichTextObject* m_object; + wxArrayInt m_pageIds; // mapping of book control indexes to page ids + int m_options; // UI options static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory; + static bool sm_showToolTips; DECLARE_EVENT_TABLE() }; @@ -182,13 +262,14 @@ DECLARE_EVENT_TABLE() class WXDLLIMPEXP_RICHTEXT wxRichTextFontPreviewCtrl : public wxWindow { public: - wxRichTextFontPreviewCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = 0) : - wxWindow(parent, id, pos, sz, style) - { - SetBackgroundColour(*wxWHITE); - } + wxRichTextFontPreviewCtrl(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, long style = 0); + + void SetTextEffects(int effects) { m_textEffects = effects; } + int GetTextEffects() const { return m_textEffects; } private: + int m_textEffects; + void OnPaint(wxPaintEvent& event); DECLARE_EVENT_TABLE() }; @@ -204,7 +285,6 @@ public: wxRichTextColourSwatchCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0); ~wxRichTextColourSwatchCtrl(); - void OnPaint(wxPaintEvent& event); void OnMouseEvent(wxMouseEvent& event); void SetColour(const wxColour& colour) { m_colour = colour; SetBackgroundColour(m_colour); } @@ -277,4 +357,3 @@ private: #endif // _WX_RICHTEXTFORMATDLG_H_ -