X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ff3e84ffdc91ee8a52b3ab646e48d44d62de80e1..67a083dd38d1ad1df8c6a25a58bb2f0ec4f3a936:/samples/richtext/richtext.cpp diff --git a/samples/richtext/richtext.cpp b/samples/richtext/richtext.cpp index 12af81541b..e0a9968d1e 100644 --- a/samples/richtext/richtext.cpp +++ b/samples/richtext/richtext.cpp @@ -35,7 +35,10 @@ #include "wx/sstream.h" #include "wx/html/htmlwin.h" -#include "bitmaps/sample.xpm" +#ifndef __WXMSW__ + #include "../sample.xpm" +#endif + #include "bitmaps/smiley.xpm" // #include "bitmaps/idea.xpm" #include "bitmaps/zebra.xpm" @@ -264,7 +267,7 @@ bool MyApp::OnInit() #endif // create the main application window - MyFrame *frame = new MyFrame(_T("wxRichTextCtrl Sample"), wxID_ANY, wxDefaultPosition, wxSize(600, 500)); + MyFrame *frame = new MyFrame(_T("wxRichTextCtrl Sample"), wxID_ANY, wxDefaultPosition, wxSize(700, 600)); // and show it (the frames, unlike simple controls, are not shown when // created initially) @@ -312,6 +315,20 @@ void MyApp::CreateStyles() m_styleSheet->AddParagraphStyle(indentedPara); + wxRichTextParagraphStyleDefinition* indentedPara2 = new wxRichTextParagraphStyleDefinition(wxT("Red Bold Indented")); + wxRichTextAttr indentedAttr2; + indentedAttr2.SetFontFaceName(romanFont.GetFaceName()); + indentedAttr2.SetFontSize(12); + indentedAttr2.SetFontWeight(wxBOLD); + indentedAttr2.SetTextColour(*wxRED); + indentedAttr2.SetFontSize(12); + indentedAttr2.SetLeftIndent(100, 0); + // We want to affect indentation, font and text colour + indentedAttr2.SetFlags(wxTEXT_ATTR_LEFT_INDENT|wxTEXT_ATTR_RIGHT_INDENT|wxTEXT_ATTR_FONT|wxTEXT_ATTR_TEXT_COLOUR); + indentedPara2->SetStyle(indentedAttr2); + + m_styleSheet->AddParagraphStyle(indentedPara2); + wxRichTextParagraphStyleDefinition* flIndentedPara = new wxRichTextParagraphStyleDefinition(wxT("First Line Indented")); wxRichTextAttr flIndentedAttr; flIndentedAttr.SetFontFaceName(swissFont.GetFaceName()); @@ -370,7 +387,7 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, : wxFrame(NULL, id, title, pos, size, style) { // set the frame icon - SetIcon(sample_xpm); + SetIcon(wxICON(sample)); // create a menu bar wxMenu *fileMenu = new wxMenu; @@ -437,9 +454,15 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, SetMenuBar(menuBar); // create a status bar just for fun (by default with 1 pane only) + // but don't create it on limited screen space (WinCE) + bool is_pda = wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA; + #if wxUSE_STATUSBAR - CreateStatusBar(2); - SetStatusText(_T("Welcome to wxRichTextCtrl!")); + if ( !is_pda ) + { + CreateStatusBar(2); + SetStatusText(_T("Welcome to wxRichTextCtrl!")); + } #endif wxToolBar* toolBar = CreateToolBar(); @@ -467,6 +490,9 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, toolBar->AddSeparator(); toolBar->AddTool(ID_FORMAT_FONT, wxBitmap(font_xpm), wxNullBitmap, false, -1, -1, (wxObject *) NULL, _("Font")); + wxRichTextStyleComboCtrl* combo = new wxRichTextStyleComboCtrl(toolBar, wxID_ANY, wxDefaultPosition, wxSize(200, -1)); + toolBar->AddControl(combo); + toolBar->Realize(); wxSplitterWindow* splitter = new wxSplitterWindow(this, wxID_ANY, wxDefaultPosition, GetClientSize(), wxSP_NO_XP_THEME|wxSP_3D|wxSP_LIVE_UPDATE); @@ -475,16 +501,26 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, wxFont boldFont = wxFont(12, wxROMAN, wxNORMAL, wxBOLD); wxFont italicFont = wxFont(12, wxROMAN, wxITALIC, wxNORMAL); - m_richTextCtrl = new wxRichTextCtrl(splitter, wxID_ANY, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER); + m_richTextCtrl = new wxRichTextCtrl(splitter, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(200, 200), wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS); wxFont font(12, wxROMAN, wxNORMAL, wxNORMAL); -#ifdef __WXMAC__ - font.SetNoAntiAliasing(true); -#endif m_richTextCtrl->SetFont(font); + combo->SetStyleSheet(wxGetApp().GetStyleSheet()); + combo->SetRichTextCtrl(m_richTextCtrl); + combo->UpdateStyles(); + wxRichTextStyleListBox* styleListBox = new wxRichTextStyleListBox(splitter, wxID_ANY); - splitter->SplitVertically(m_richTextCtrl, styleListBox, 400); + + wxSize display = wxGetDisplaySize(); + if ( is_pda && ( display.GetWidth() < display.GetHeight() ) ) + { + splitter->SplitHorizontally(m_richTextCtrl, styleListBox); + } + else + { + splitter->SplitVertically(m_richTextCtrl, styleListBox, 500); + } splitter->UpdateSize(); @@ -603,6 +639,19 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos, r.EndLineSpacing(); r.EndAlignment(); + wxArrayInt tabs; + tabs.Add(400); + tabs.Add(600); + tabs.Add(800); + tabs.Add(1000); + wxTextAttrEx attr; + attr.SetFlags(wxTEXT_ATTR_TABS); + attr.SetTabs(tabs); + r.SetDefaultStyle(attr); + + r.Newline(); + r.WriteText(wxT("This line contains tabs:\tFirst tab\tSecond tab\tThird tab")); + r.Newline(); r.WriteText(wxT("Other notable features of wxRichTextCtrl include:"));