/// 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; }
/// 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;
event.Skip();
return;
}
-
+
default:
{
if (event.CmdDown() || event.AltDown())
{
if (position < 0 || position > GetBuffer().GetRange().GetEnd())
return false;
-
+
wxRichTextParagraph* para = GetBuffer().GetParagraphAtPosition(position);
if (!para)
return false;
long positionStart = position;
long positionEnd = position;
-
+
for (positionStart = position; positionStart >= para->GetRange().GetStart(); positionStart --)
{
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionStart, positionStart));
}
if (positionStart < para->GetRange().GetStart())
positionStart = para->GetRange().GetStart();
-
+
for (positionEnd = position; positionEnd < para->GetRange().GetEnd(); positionEnd ++)
{
wxString text = GetBuffer().GetTextForRange(wxRichTextRange(positionEnd, positionEnd));
}
if (positionEnd >= para->GetRange().GetEnd())
positionEnd = para->GetRange().GetEnd();
-
+
SetSelection(positionStart, positionEnd+1);
if (positionStart >= 0)
{
MoveCaret(positionStart-1, true);
- SetDefaultStyleToCursorStyle();
+ SetDefaultStyleToCursorStyle();
}
return true;
}
/// 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.
wxRichTextAttr attr(def->GetStyle());
-
+
int flags = wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_OPTIMIZE;
// Make sure the attr has the style name
if (def->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition)))
{
attr.SetParagraphStyleName(def->GetName());
-
+
// 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)
// to change its style independently.
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.
}
}
+/// 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)
int imageIndex = GetPageImage(pageId);
dialog->GetBookCtrl()->AddPage(panel, title, !selected, imageIndex);
selected = true;
+
+ dialog->AddPageId(pageId);
}
}
}