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:
@@ -528,7 +528,7 @@ public:
|
|||||||
virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment);
|
virtual bool ApplyAlignmentToSelection(wxTextAttrAlignment alignment);
|
||||||
|
|
||||||
/// Apply a named style to the selection
|
/// Apply a named style to the selection
|
||||||
virtual void ApplyStyle(wxRichTextStyleDefinition* def);
|
virtual bool ApplyStyle(wxRichTextStyleDefinition* def);
|
||||||
|
|
||||||
/// Set style sheet, if any.
|
/// Set style sheet, if any.
|
||||||
void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); }
|
void SetStyleSheet(wxRichTextStyleSheet* styleSheet) { GetBuffer().SetStyleSheet(styleSheet); }
|
||||||
|
@@ -148,6 +148,9 @@ public:
|
|||||||
/// up to date
|
/// up to date
|
||||||
void OnTabChanged(wxBookCtrlEvent& event);
|
void OnTabChanged(wxBookCtrlEvent& event);
|
||||||
|
|
||||||
|
/// Respond to help command
|
||||||
|
void OnHelp(wxCommandEvent& event);
|
||||||
|
|
||||||
/// Set/get image list
|
/// Set/get image list
|
||||||
void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
|
void SetImageList(wxImageList* imageList) { m_imageList = imageList; }
|
||||||
wxImageList* GetImageList() const { return m_imageList; }
|
wxImageList* GetImageList() const { return m_imageList; }
|
||||||
@@ -165,12 +168,16 @@ public:
|
|||||||
/// Helper for pages to get the style
|
/// Helper for pages to get the style
|
||||||
static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
|
static wxRichTextStyleDefinition* GetDialogStyleDefinition(wxWindow* win);
|
||||||
|
|
||||||
|
/// Map book control page index to our page id
|
||||||
|
void AddPageId(int id) { m_pageIds.Add(id); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
wxImageList* m_imageList;
|
wxImageList* m_imageList;
|
||||||
wxTextAttrEx m_attributes;
|
wxTextAttrEx m_attributes;
|
||||||
wxRichTextStyleDefinition* m_styleDefinition;
|
wxRichTextStyleDefinition* m_styleDefinition;
|
||||||
wxRichTextStyleSheet* m_styleSheet;
|
wxRichTextStyleSheet* m_styleSheet;
|
||||||
|
wxArrayInt m_pageIds; // mapping of book control indexes to page ids
|
||||||
|
|
||||||
static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory;
|
static wxRichTextFormattingDialogFactory* ms_FormattingDialogFactory;
|
||||||
|
|
||||||
|
@@ -630,7 +630,7 @@ void wxRichTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
if (event.CmdDown() || event.AltDown())
|
if (event.CmdDown() || event.AltDown())
|
||||||
@@ -1721,14 +1721,14 @@ bool wxRichTextCtrl::SelectWord(long position)
|
|||||||
{
|
{
|
||||||
if (position < 0 || position > GetBuffer().GetRange().GetEnd())
|
if (position < 0 || position > GetBuffer().GetRange().GetEnd())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(position);
|
wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(position);
|
||||||
if (!para)
|
if (!para)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
long positionStart = position;
|
long positionStart = position;
|
||||||
long positionEnd = position;
|
long positionEnd = position;
|
||||||
|
|
||||||
for (positionStart = position; positionStart >= para->GetRange().GetStart(); positionStart --)
|
for (positionStart = position; positionStart >= para->GetRange().GetStart(); positionStart --)
|
||||||
{
|
{
|
||||||
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionStart, positionStart));
|
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionStart, positionStart));
|
||||||
@@ -1740,7 +1740,7 @@ bool wxRichTextCtrl::SelectWord(long position)
|
|||||||
}
|
}
|
||||||
if (positionStart < para->GetRange().GetStart())
|
if (positionStart < para->GetRange().GetStart())
|
||||||
positionStart = para->GetRange().GetStart();
|
positionStart = para->GetRange().GetStart();
|
||||||
|
|
||||||
for (positionEnd = position; positionEnd < para->GetRange().GetEnd(); positionEnd ++)
|
for (positionEnd = position; positionEnd < para->GetRange().GetEnd(); positionEnd ++)
|
||||||
{
|
{
|
||||||
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionEnd, positionEnd));
|
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionEnd, positionEnd));
|
||||||
@@ -1752,13 +1752,13 @@ bool wxRichTextCtrl::SelectWord(long position)
|
|||||||
}
|
}
|
||||||
if (positionEnd >= para->GetRange().GetEnd())
|
if (positionEnd >= para->GetRange().GetEnd())
|
||||||
positionEnd = para->GetRange().GetEnd();
|
positionEnd = para->GetRange().GetEnd();
|
||||||
|
|
||||||
SetSelection(positionStart, positionEnd+1);
|
SetSelection(positionStart, positionEnd+1);
|
||||||
|
|
||||||
if (positionStart >= 0)
|
if (positionStart >= 0)
|
||||||
{
|
{
|
||||||
MoveCaret(positionStart-1, true);
|
MoveCaret(positionStart-1, true);
|
||||||
SetDefaultStyleToCursorStyle();
|
SetDefaultStyleToCursorStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -2738,19 +2738,19 @@ bool wxRichTextCtrl::ApplyAlignmentToSelection(wxTextAttrAlignment alignment)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Apply a named style to the selection
|
/// 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
|
// Flags are defined within each definition, so only certain
|
||||||
// attributes are applied.
|
// attributes are applied.
|
||||||
wxRichTextAttr attr(def->GetStyle());
|
wxRichTextAttr attr(def->GetStyle());
|
||||||
|
|
||||||
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;
|
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;
|
||||||
|
|
||||||
// Make sure the attr has the style name
|
// Make sure the attr has the style name
|
||||||
if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition)))
|
if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition)))
|
||||||
{
|
{
|
||||||
attr.SetParagraphStyleName(def->GetName());
|
attr.SetParagraphStyleName(def->GetName());
|
||||||
|
|
||||||
// If applying a paragraph style, we only want the paragraph nodes to adopt these
|
// If applying a paragraph style, we only want the paragraph nodes to adopt these
|
||||||
// attributes, and not the leaf nodes. This will allow the context (e.g. text)
|
// attributes, and not the leaf nodes. This will allow the context (e.g. text)
|
||||||
// to change its style independently.
|
// to change its style independently.
|
||||||
@@ -2760,9 +2760,12 @@ void wxRichTextCtrl::ApplyStyle(wxRichTextStyleDefinition* def)
|
|||||||
attr.SetCharacterStyleName(def->GetName());
|
attr.SetCharacterStyleName(def->GetName());
|
||||||
|
|
||||||
if (HasSelection())
|
if (HasSelection())
|
||||||
SetStyleEx(GetSelectionRange(), attr, flags);
|
return SetStyleEx(GetSelectionRange(), attr, flags);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
SetAndShowDefaultStyle(attr);
|
SetAndShowDefaultStyle(attr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Apply the style sheet to the buffer, for example if the styles have changed.
|
/// Apply the style sheet to the buffer, for example if the styles have changed.
|
||||||
|
@@ -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)
|
void wxRichTextFormattingDialog::SetFormattingDialogFactory(wxRichTextFormattingDialogFactory* factory)
|
||||||
{
|
{
|
||||||
if (ms_FormattingDialogFactory)
|
if (ms_FormattingDialogFactory)
|
||||||
@@ -225,6 +237,8 @@ bool wxRichTextFormattingDialogFactory::CreatePages(long pages, wxRichTextFormat
|
|||||||
int imageIndex = GetPageImage(pageId);
|
int imageIndex = GetPageImage(pageId);
|
||||||
dialog->GetBookCtrl()->AddPage(panel, title, !selected, imageIndex);
|
dialog->GetBookCtrl()->AddPage(panel, title, !selected, imageIndex);
|
||||||
selected = true;
|
selected = true;
|
||||||
|
|
||||||
|
dialog->AddPageId(pageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user