X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/99404ab05fa5b5a81df1120cb871b0a645b5e3fc..a8e87569b7ea3494ef29ac9caa6cb7f219329c50:/samples/richtext/richtext.cpp diff --git a/samples/richtext/richtext.cpp b/samples/richtext/richtext.cpp index 94b224cff4..168a2046f9 100644 --- a/samples/richtext/richtext.cpp +++ b/samples/richtext/richtext.cpp @@ -181,6 +181,8 @@ public: void OnPreview(wxCommandEvent& event); void OnPageSetup(wxCommandEvent& event); +protected: + // Forward command events to the current rich text control, if any bool ProcessEvent(wxEvent& event); @@ -379,7 +381,7 @@ bool MyApp::OnInit() #endif // create the main application window - MyFrame *frame = new MyFrame(_T("wxRichTextCtrl Sample"), wxID_ANY, wxDefaultPosition, wxSize(700, 600)); + MyFrame *frame = new MyFrame(wxT("wxRichTextCtrl Sample"), wxID_ANY, wxDefaultPosition, wxSize(700, 600)); m_printing->SetParentWindow(frame); @@ -435,7 +437,7 @@ void MyApp::CreateStyles() wxRichTextAttr indentedAttr2; indentedAttr2.SetFontFaceName(romanFont.GetFaceName()); indentedAttr2.SetFontSize(12); - indentedAttr2.SetFontWeight(wxBOLD); + indentedAttr2.SetFontWeight(wxFONTWEIGHT_BOLD); indentedAttr2.SetTextColour(*wxRED); indentedAttr2.SetFontSize(12); indentedAttr2.SetLeftIndent(100, 0); @@ -462,7 +464,7 @@ void MyApp::CreateStyles() wxRichTextAttr boldAttr; boldAttr.SetFontFaceName(romanFont.GetFaceName()); boldAttr.SetFontSize(12); - boldAttr.SetFontWeight(wxBOLD); + boldAttr.SetFontWeight(wxFONTWEIGHT_BOLD); // We only want to affect boldness boldAttr.SetFlags(wxTEXT_ATTR_FONT_WEIGHT); boldDef->SetStyle(boldAttr); @@ -473,7 +475,7 @@ void MyApp::CreateStyles() wxRichTextAttr italicAttr; italicAttr.SetFontFaceName(romanFont.GetFaceName()); italicAttr.SetFontSize(12); - italicAttr.SetFontStyle(wxITALIC); + italicAttr.SetFontStyle(wxFONTSTYLE_ITALIC); // We only want to affect italics italicAttr.SetFlags(wxTEXT_ATTR_FONT_ITALIC); italicDef->SetStyle(italicAttr); @@ -484,7 +486,7 @@ void MyApp::CreateStyles() wxRichTextAttr redAttr; redAttr.SetFontFaceName(romanFont.GetFaceName()); redAttr.SetFontSize(12); - redAttr.SetFontWeight(wxBOLD); + redAttr.SetFontWeight(wxFONTWEIGHT_BOLD); redAttr.SetTextColour(*wxRED); // We only want to affect colour, weight and face redAttr.SetFlags(wxTEXT_ATTR_FONT_FACE|wxTEXT_ATTR_FONT_WEIGHT|wxTEXT_ATTR_TEXT_COLOUR); @@ -567,21 +569,21 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, // the "About" item should be in the help menu wxMenu *helpMenu = new wxMenu; - helpMenu->Append(ID_About, _T("&About...\tF1"), _T("Show about dialog")); + helpMenu->Append(ID_About, wxT("&About...\tF1"), wxT("Show about dialog")); - fileMenu->Append(wxID_OPEN, _T("&Open\tCtrl+O"), _T("Open a file")); - fileMenu->Append(wxID_SAVE, _T("&Save\tCtrl+S"), _T("Save a file")); - fileMenu->Append(wxID_SAVEAS, _T("&Save As...\tF12"), _T("Save to a new file")); + fileMenu->Append(wxID_OPEN, wxT("&Open\tCtrl+O"), wxT("Open a file")); + fileMenu->Append(wxID_SAVE, wxT("&Save\tCtrl+S"), wxT("Save a file")); + fileMenu->Append(wxID_SAVEAS, wxT("&Save As...\tF12"), wxT("Save to a new file")); fileMenu->AppendSeparator(); - fileMenu->Append(ID_RELOAD, _T("&Reload Text\tF2"), _T("Reload the initial text")); + fileMenu->Append(ID_RELOAD, wxT("&Reload Text\tF2"), wxT("Reload the initial text")); fileMenu->AppendSeparator(); - fileMenu->Append(ID_PAGE_SETUP, _T("Page Set&up..."), _T("Page setup")); - fileMenu->Append(ID_PRINT, _T("&Print...\tCtrl+P"), _T("Print")); - fileMenu->Append(ID_PREVIEW, _T("Print Pre&view"), _T("Print preview")); + fileMenu->Append(ID_PAGE_SETUP, wxT("Page Set&up..."), wxT("Page setup")); + fileMenu->Append(ID_PRINT, wxT("&Print...\tCtrl+P"), wxT("Print")); + fileMenu->Append(ID_PREVIEW, wxT("Print Pre&view"), wxT("Print preview")); fileMenu->AppendSeparator(); - fileMenu->Append(ID_VIEW_HTML, _T("&View as HTML"), _T("View HTML")); + fileMenu->Append(ID_VIEW_HTML, wxT("&View as HTML"), wxT("View HTML")); fileMenu->AppendSeparator(); - fileMenu->Append(ID_Quit, _T("E&xit\tAlt+X"), _T("Quit this program")); + fileMenu->Append(ID_Quit, wxT("E&xit\tAlt+X"), wxT("Quit this program")); wxMenu* editMenu = new wxMenu; editMenu->Append(wxID_UNDO, _("&Undo\tCtrl+Z")); @@ -641,12 +643,12 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, // now append the freshly created menu to the menu bar... wxMenuBar *menuBar = new wxMenuBar(); - menuBar->Append(fileMenu, _T("&File")); - menuBar->Append(editMenu, _T("&Edit")); - menuBar->Append(formatMenu, _T("F&ormat")); - menuBar->Append(listsMenu, _T("&Lists")); - menuBar->Append(insertMenu, _T("&Insert")); - menuBar->Append(helpMenu, _T("&Help")); + menuBar->Append(fileMenu, wxT("&File")); + menuBar->Append(editMenu, wxT("&Edit")); + menuBar->Append(formatMenu, wxT("F&ormat")); + menuBar->Append(listsMenu, wxT("&Lists")); + menuBar->Append(insertMenu, wxT("&Insert")); + menuBar->Append(helpMenu, wxT("&Help")); // ... and attach this menu bar to the frame SetMenuBar(menuBar); @@ -659,34 +661,34 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, if ( !is_pda ) { CreateStatusBar(2); - SetStatusText(_T("Welcome to wxRichTextCtrl!")); + SetStatusText(wxT("Welcome to wxRichTextCtrl!")); } #endif wxToolBar* toolBar = CreateToolBar(); - toolBar->AddTool(wxID_OPEN, wxBitmap(open_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Open")); - toolBar->AddTool(wxID_SAVEAS, wxBitmap(save_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Save")); + toolBar->AddTool(wxID_OPEN, wxEmptyString, wxBitmap(open_xpm), _("Open")); + toolBar->AddTool(wxID_SAVEAS, wxEmptyString, wxBitmap(save_xpm), _("Save")); toolBar->AddSeparator(); - toolBar->AddTool(wxID_CUT, wxBitmap(cut_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Cut")); - toolBar->AddTool(wxID_COPY, wxBitmap(copy_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Copy")); - toolBar->AddTool(wxID_PASTE, wxBitmap(paste_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Paste")); + toolBar->AddTool(wxID_CUT, wxEmptyString, wxBitmap(cut_xpm), _("Cut")); + toolBar->AddTool(wxID_COPY, wxEmptyString, wxBitmap(copy_xpm), _("Copy")); + toolBar->AddTool(wxID_PASTE, wxEmptyString, wxBitmap(paste_xpm), _("Paste")); toolBar->AddSeparator(); - toolBar->AddTool(wxID_UNDO, wxBitmap(undo_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Undo")); - toolBar->AddTool(wxID_REDO, wxBitmap(redo_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Redo")); + toolBar->AddTool(wxID_UNDO, wxEmptyString, wxBitmap(undo_xpm), _("Undo")); + toolBar->AddTool(wxID_REDO, wxEmptyString, wxBitmap(redo_xpm), _("Redo")); toolBar->AddSeparator(); - toolBar->AddTool(ID_FORMAT_BOLD, wxBitmap(bold_xpm), wxNullBitmap, true, -1, -1, (wxObject *) NULL, _("Bold")); - toolBar->AddTool(ID_FORMAT_ITALIC, wxBitmap(italic_xpm), wxNullBitmap, true, -1, -1, (wxObject *) NULL, _("Italic")); - toolBar->AddTool(ID_FORMAT_UNDERLINE, wxBitmap(underline_xpm), wxNullBitmap, true, -1, -1, (wxObject *) NULL, _("Underline")); + toolBar->AddCheckTool(ID_FORMAT_BOLD, wxEmptyString, wxBitmap(bold_xpm), wxNullBitmap, _("Bold")); + toolBar->AddCheckTool(ID_FORMAT_ITALIC, wxEmptyString, wxBitmap(italic_xpm), wxNullBitmap, _("Italic")); + toolBar->AddCheckTool(ID_FORMAT_UNDERLINE, wxEmptyString, wxBitmap(underline_xpm), wxNullBitmap, _("Underline")); toolBar->AddSeparator(); - toolBar->AddTool(ID_FORMAT_ALIGN_LEFT, wxBitmap(alignleft_xpm), wxNullBitmap, true, -1, -1, (wxObject *) NULL, _("Align Left")); - toolBar->AddTool(ID_FORMAT_ALIGN_CENTRE, wxBitmap(centre_xpm), wxNullBitmap, true, -1, -1, (wxObject *) NULL, _("Centre")); - toolBar->AddTool(ID_FORMAT_ALIGN_RIGHT, wxBitmap(alignright_xpm), wxNullBitmap, true, -1, -1, (wxObject *) NULL, _("Align Right")); + toolBar->AddCheckTool(ID_FORMAT_ALIGN_LEFT, wxEmptyString, wxBitmap(alignleft_xpm), wxNullBitmap, _("Align Left")); + toolBar->AddCheckTool(ID_FORMAT_ALIGN_CENTRE, wxEmptyString, wxBitmap(centre_xpm), wxNullBitmap, _("Centre")); + toolBar->AddCheckTool(ID_FORMAT_ALIGN_RIGHT, wxEmptyString, wxBitmap(alignright_xpm), wxNullBitmap, _("Align Right")); toolBar->AddSeparator(); - toolBar->AddTool(ID_FORMAT_INDENT_LESS, wxBitmap(indentless_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Indent Less")); - toolBar->AddTool(ID_FORMAT_INDENT_MORE, wxBitmap(indentmore_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Indent More")); + toolBar->AddTool(ID_FORMAT_INDENT_LESS, wxEmptyString, wxBitmap(indentless_xpm), _("Indent Less")); + toolBar->AddTool(ID_FORMAT_INDENT_MORE, wxEmptyString, wxBitmap(indentmore_xpm), _("Indent More")); toolBar->AddSeparator(); - toolBar->AddTool(ID_FORMAT_FONT, wxBitmap(font_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Font")); + toolBar->AddTool(ID_FORMAT_FONT, wxEmptyString, wxBitmap(font_xpm), _("Font")); wxRichTextStyleComboCtrl* combo = new wxRichTextStyleComboCtrl(toolBar, ID_RICHTEXT_STYLE_COMBO, wxDefaultPosition, wxSize(200, -1)); toolBar->AddControl(combo); @@ -935,8 +937,8 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxString msg; - msg.Printf( _T("This is a demo for wxRichTextCtrl, a control for editing styled text.\n(c) Julian Smart, 2005")); - wxMessageBox(msg, _T("About wxRichTextCtrl Sample"), wxOK | wxICON_INFORMATION, this); + msg.Printf( wxT("This is a demo for wxRichTextCtrl, a control for editing styled text.\n(c) Julian Smart, 2005")); + wxMessageBox(msg, wxT("About wxRichTextCtrl Sample"), wxOK | wxICON_INFORMATION, this); } // Forward command events to the current rich text control, if any @@ -958,7 +960,7 @@ bool MyFrame::ProcessEvent(wxEvent& event) s_id = event.GetId(); wxWindow* focusWin = wxFindFocusDescendant(this); - if (focusWin && focusWin->ProcessEvent(event)) + if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event)) { //s_command = NULL; s_eventType = 0;