/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
- #pragma interface "text.cpp"
#pragma implementation "text.cpp"
#endif
{ m_panel->DoCopyToClipboard(); }
#endif // wxUSE_CLIPBOARD
+ void OnAddTextFreeze( wxCommandEvent& event )
+ { DoAddText(true); }
+ void OnAddText( wxCommandEvent& event )
+ { DoAddText(false); }
+
void OnMoveToEndOfText( wxCommandEvent &event )
{ m_panel->DoMoveToEndOfText(); }
void OnMoveToEndOfEntry( wxCommandEvent &event )
void OnIdle( wxIdleEvent& event );
private:
+ void DoAddText(bool freeze)
+ {
+ wxTextCtrl *text = m_panel->m_textrich;
+ if ( freeze )
+ text->Freeze();
+
+ for ( int i = 0; i < 100; i++ )
+ text->AppendText(wxString::Format("Line %i\n", i));
+
+ text->SetInsertionPoint(0);
+
+ if ( freeze )
+ text->Thaw();
+ }
+
MyPanel *m_panel;
DECLARE_EVENT_TABLE()
TEXT_TOOLTIPS_ENABLE,
// text menu
- TEXT_MOVE_ENDTEXT = 400,
+ TEXT_ADD_SOME = 400,
+ TEXT_ADD_FREEZE,
+ TEXT_MOVE_ENDTEXT,
TEXT_MOVE_ENDENTRY,
TEXT_SET_EDITABLE,
TEXT_SET_ENABLED
{
// Create the main frame window
MyFrame *frame = new MyFrame((wxFrame *) NULL,
- "Text wxWindows sample", 50, 50, 660, 420);
+ "Text wxWindows sample", 50, 50, 700, 420);
frame->SetSizeHints( 500, 400 );
wxMenu *file_menu = new wxMenu;
#endif // wxUSE_CLIPBOARD
wxMenu *menuText = new wxMenu;
+ menuText->Append(TEXT_ADD_SOME, "&Append some text\tCtrl-A");
+ menuText->Append(TEXT_ADD_FREEZE, "&Append text with freeze/thaw\tShift-Ctrl-A");
menuText->Append(TEXT_MOVE_ENDTEXT, "Move cursor to the end of &text");
menuText->Append(TEXT_MOVE_ENDENTRY, "Move cursor to the end of &entry");
menuText->Append(TEXT_SET_EDITABLE, "Toggle &editable state", "", TRUE);
"and a very very very very very "
"very very very long line to test"
"wxHSCROLL style",
- wxPoint(450, 10), wxSize(200, 230),
+ wxPoint(450, 10), wxSize(230, 230),
wxTE_RICH | wxTE_MULTILINE | wxHSCROLL);
- m_textrich->SetForegroundColour(wxColour(0, 255, 255));
- m_textrich->SetBackgroundColour(*wxBLUE);
+
+ m_textrich->SetStyle(0, 10, *wxRED);
+ m_textrich->SetStyle(10, 20, *wxBLUE);
+ m_textrich->SetStyle(30, 40,
+ wxTextAttr(*wxGREEN, wxNullColour, *wxITALIC_FONT));
+ m_textrich->SetDefaultStyle(wxTextAttr());
+ m_textrich->AppendText(_T("\n\nFirst 10 characters should be in red\n"));
+ m_textrich->AppendText(_T("Next 10 characters should be in blue\n"));
+ m_textrich->AppendText(_T("Next 10 characters should be normal\n"));
+ m_textrich->AppendText(_T("And the next 10 characters should be green and italic\n"));
+ m_textrich->SetDefaultStyle(wxTextAttr(*wxCYAN, *wxBLUE));
+ m_textrich->AppendText(_T("This text should be cyan on blue\n"));
+ m_textrich->SetDefaultStyle(*wxBLUE);
+ m_textrich->AppendText(_T("And this should be in blue and the text you ")
+ _T("type should be in blue as well"));
}
void MyPanel::OnSize( wxSizeEvent &event )
EVT_MENU(TEXT_CLIPBOARD_COPY, MyFrame::OnCopyToClipboard)
#endif // wxUSE_CLIPBOARD
+ EVT_MENU(TEXT_ADD_SOME, MyFrame::OnAddText)
+ EVT_MENU(TEXT_ADD_FREEZE, MyFrame::OnAddTextFreeze)
EVT_MENU(TEXT_MOVE_ENDTEXT, MyFrame::OnMoveToEndOfText)
EVT_MENU(TEXT_MOVE_ENDENTRY, MyFrame::OnMoveToEndOfEntry)