]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/richtext/richtext.cpp
Now we can build all tarballs on one (Unix shell) box using pre-flight.sh.
[wxWidgets.git] / samples / richtext / richtext.cpp
index 115d7106a48dbca87f5e745a3d557d5a9229b313..bf3bb2ae977fc64c3f7e1138eb9ff5b9ed1c9370 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        richedit.cpp
+// Name:        samples/richtext/richtext.cpp
 // Purpose:     wxWidgets rich text editor sample
 // Author:      Julian Smart
 // Modified by:
@@ -61,6 +61,7 @@
 #include "wx/richtext/richtextctrl.h"
 #include "wx/richtext/richtextstyles.h"
 #include "wx/richtext/richtextxml.h"
+#include "wx/richtext/richtexthtml.h"
 
 // ----------------------------------------------------------------------------
 // resources
@@ -311,6 +312,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());
@@ -474,12 +489,9 @@ 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);
 
     wxRichTextStyleListBox* styleListBox = new wxRichTextStyleListBox(splitter, wxID_ANY);
@@ -602,6 +614,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:"));
 
@@ -720,7 +745,7 @@ void MyFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
         path,
         filename,
         filter,
-        wxOPEN);
+        wxFD_OPEN);
 
     if (dialog.ShowModal() == wxID_OK)
     {
@@ -728,12 +753,10 @@ void MyFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
 
         if (!path.empty())
         {
-            int fileType = 0;
             int filterIndex = dialog.GetFilterIndex();
-            if (filterIndex < (int) fileTypes.GetCount())
-                fileType = fileTypes[filterIndex];
-            else
-                fileType = wxRICHTEXT_TYPE_TEXT;
+            int fileType = (filterIndex < (int) fileTypes.GetCount())
+                           ? fileTypes[filterIndex]
+                           : wxRICHTEXT_TYPE_TEXT;
             m_richTextCtrl->LoadFile(path, fileType);
         }
     }
@@ -760,7 +783,7 @@ void MyFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event))
         path,
         filename,
         filter,
-        wxSAVE);
+        wxFD_SAVE);
 
     if (dialog.ShowModal() == wxID_OK)
     {