Return type change

Added support for help button to formatting dialog


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41899 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-10-10 17:01:36 +00:00
parent 62a268cc71
commit 1807a1f3cf
4 changed files with 35 additions and 11 deletions

View File

@@ -528,7 +528,7 @@ public:
virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment);
/// Apply a named style to the selection
virtual void ApplyStyle(wxRichTextStyleDefinition* def);
virtual bool ApplyStyle(wxRichTextStyleDefinition* def);
/// Set style sheet, if any.
void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); }

View File

@@ -148,6 +148,9 @@ public:
/// up to date
void OnTabChanged(wxBookCtrlEvent& event);
/// Respond to help command
void OnHelp(wxCommandEvent& event);
/// Set/get image list
void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
wxImageList* GetImageList() const { return m_imageList; }
@@ -165,12 +168,16 @@ public:
/// Helper for pages to get the style
static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
/// Map book control page index to our page id
void AddPageId(int id) { m_pageIds.Add(id); }
protected:
wxImageList* m_imageList;
wxTextAttrEx m_attributes;
wxRichTextStyleDefinition* m_styleDefinition;
wxRichTextStyleSheet* m_styleSheet;
wxArrayInt m_pageIds; // mapping of book control indexes to page ids
static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory;

View File

@@ -2738,7 +2738,7 @@ bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment)
}
/// Apply a named style to the selection
void wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
bool wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
{
// Flags are defined within each definition, so only certain
// attributes are applied.
@@ -2760,9 +2760,12 @@ void wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
attr.SetCharacterStyleName(def->GetName());
if (HasSelection())
SetStyleEx(GetSelectionRange(), attr, flags);
return SetStyleEx(GetSelectionRange(), attr, flags);
else
{
SetAndShowDefaultStyle(attr);
return true;
}
}
/// Apply the style sheet to the buffer, for example if the styles have changed.

View File

@@ -192,6 +192,18 @@ void wxRichTextFormattingDialog::OnTabChanged(wxBookCtrlEvent& event)
}
}
/// Respond to help command
void wxRichTextFormattingDialog::OnHelp(wxCommandEvent& event)
{
int selPage = GetBookCtrl()->GetSelection();
if (selPage != wxNOT_FOUND)
{
int pageId = m_pageIds[selPage];
if (!GetFormattingDialogFactory()->ShowHelp(pageId, this))
event.Skip();
}
}
void wxRichTextFormattingDialog::SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory)
{
if (ms_FormattingDialogFactory)
@@ -225,6 +237,8 @@ bool wxRichTextFormattingDialogFactory::CreatePages(long pages, wxRichTextFormat
int imageIndex = GetPageImage(pageId);
dialog->GetBookCtrl()->AddPage(panel, title, !selected, imageIndex);
selected = true;
dialog->AddPageId(pageId);
}
}
}