+
+void MyFrame::OnManageStyles(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextStyleSheet* sheet = m_richTextCtrl->GetStyleSheet();
+
+ int flags = wxRICHTEXT_ORGANISER_CREATE_STYLES|wxRICHTEXT_ORGANISER_EDIT_STYLES;
+
+ wxRichTextStyleOrganiserDialog dlg(flags, sheet, NULL, this, wxID_ANY, _("Style Manager"));
+ dlg.ShowModal();
+}
+
+void MyFrame::OnInsertSymbol(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextAttr attr;
+ attr.SetFlags(wxTEXT_ATTR_FONT);
+ m_richTextCtrl->GetStyle(m_richTextCtrl->GetInsertionPoint(), attr);
+
+ wxString currentFontName;
+ if (attr.HasFont() && attr.GetFont().Ok())
+ currentFontName = attr.GetFont().GetFaceName();
+
+ // Don't set the initial font in the dialog (so the user is choosing
+ // 'normal text', i.e. the current font) but do tell the dialog
+ // what 'normal text' is.
+
+ wxSymbolPickerDialog dlg(wxT("*"), wxEmptyString, currentFontName, this);
+
+ if (dlg.ShowModal() == wxID_OK)
+ {
+ if (dlg.HasSelection())
+ {
+ long insertionPoint = m_richTextCtrl->GetInsertionPoint();
+
+ m_richTextCtrl->WriteText(dlg.GetSymbol());
+
+ if (!dlg.UseNormalFont())
+ {
+ wxFont font(attr.GetFont());
+ font.SetFaceName(dlg.GetFontName());
+ attr.SetFont(font);
+ m_richTextCtrl->SetStyle(insertionPoint, insertionPoint+1, attr);
+ }
+ }
+ }
+}
+
+void MyFrame::OnNumberList(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_richTextCtrl->HasSelection())
+ {
+ wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
+ m_richTextCtrl->SetListStyle(range, wxT("Numbered List 1"), wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_RENUMBER);
+ }
+}
+
+void MyFrame::OnBulletsAndNumbering(wxCommandEvent& WXUNUSED(event))
+{
+ wxRichTextStyleSheet* sheet = m_richTextCtrl->GetStyleSheet();
+
+ int flags = wxRICHTEXT_ORGANISER_BROWSE_NUMBERING;
+
+ wxRichTextStyleOrganiserDialog dlg(flags, sheet, m_richTextCtrl, this, wxID_ANY, _("Bullets and Numbering"));
+ if (dlg.ShowModal() == wxID_OK)
+ {
+ if (dlg.GetSelectedStyleDefinition())
+ dlg.ApplyStyle();
+ }
+}
+
+void MyFrame::OnItemizeList(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_richTextCtrl->HasSelection())
+ {
+ wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
+ m_richTextCtrl->SetListStyle(range, wxT("Bullet List 1"));
+ }
+}
+
+void MyFrame::OnRenumberList(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_richTextCtrl->HasSelection())
+ {
+ wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
+ m_richTextCtrl->NumberList(range, NULL, wxRICHTEXT_SETSTYLE_WITH_UNDO|wxRICHTEXT_SETSTYLE_RENUMBER);
+ }
+}
+
+void MyFrame::OnPromoteList(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_richTextCtrl->HasSelection())
+ {
+ wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
+ m_richTextCtrl->PromoteList(1, range, NULL);
+ }
+}
+
+void MyFrame::OnDemoteList(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_richTextCtrl->HasSelection())
+ {
+ wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
+ m_richTextCtrl->PromoteList(-1, range, NULL);
+ }
+}
+
+void MyFrame::OnClearList(wxCommandEvent& WXUNUSED(event))
+{
+ if (m_richTextCtrl->HasSelection())
+ {
+ wxRichTextRange range = m_richTextCtrl->GetSelectionRange();
+ m_richTextCtrl->ClearListStyle(range);
+ }
+}
+
+void MyFrame::OnInsertURL(wxCommandEvent& WXUNUSED(event))
+{
+ wxString url = wxGetTextFromUser(_("URL:"), _("Insert URL"));
+ if (!url.IsEmpty())
+ {
+ // Make a style suitable for showing a URL
+ wxRichTextAttr urlStyle;
+ urlStyle.SetTextColour(*wxBLUE);
+ urlStyle.SetFontUnderlined(true);
+
+ m_richTextCtrl->BeginStyle(urlStyle);
+ m_richTextCtrl->BeginURL(url);
+ m_richTextCtrl->WriteText(url);
+ m_richTextCtrl->EndURL();
+ m_richTextCtrl->EndStyle();
+ }
+}
+
+void MyFrame::OnInsertImage(wxCommandEvent& WXUNUSED(event))
+{
+ wxFileDialog dialog(this, _("Choose an image"), "", "", "BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png");
+ if (dialog.ShowModal() == wxID_OK)
+ {
+ wxString path = dialog.GetPath();
+ m_richTextCtrl->WriteImage(path, wxBITMAP_TYPE_ANY);
+ }
+}
+
+void MyFrame::OnURL(wxTextUrlEvent& event)
+{
+ wxMessageBox(event.GetString());
+}
+
+// Veto style sheet replace events when loading from XML, since we want
+// to keep the original style sheet.
+void MyFrame::OnStyleSheetReplacing(wxRichTextEvent& event)
+{
+ event.Veto();
+}
+
+void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
+{
+ wxGetApp().GetPrinting()->PrintBuffer(m_richTextCtrl->GetBuffer());
+}
+
+void MyFrame::OnPreview(wxCommandEvent& WXUNUSED(event))
+{
+ wxGetApp().GetPrinting()->PreviewBuffer(m_richTextCtrl->GetBuffer());
+}
+
+void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
+{
+ wxDialog dialog(this, wxID_ANY, wxT("Testing"), wxPoint(10, 10), wxSize(400, 300), wxDEFAULT_DIALOG_STYLE);
+
+ wxNotebook* nb = new wxNotebook(& dialog, wxID_ANY, wxPoint(5, 5), wxSize(300, 250));
+ wxPanel* panel = new wxPanel(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+ wxPanel* panel2 = new wxPanel(nb, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+
+ new wxRichTextCtrl(panel, wxID_ANY, wxEmptyString, wxPoint(5, 5), wxSize(200, 150), wxVSCROLL|wxTE_READONLY);
+ nb->AddPage(panel, wxT("Page 1"));
+
+ new wxRichTextCtrl(panel2, wxID_ANY, wxEmptyString, wxPoint(5, 5), wxSize(200, 150), wxVSCROLL|wxTE_READONLY);
+ nb->AddPage(panel2, wxT("Page 2"));
+
+ new wxButton(& dialog, wxID_OK, wxT("OK"), wxPoint(5, 180));
+
+ dialog.ShowModal();
+
+// wxGetApp().GetPrinting()->PageSetup();
+}