]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/richtext/richtext.cpp
[ 1505048 ] wxHtml rendering of underlined text
[wxWidgets.git] / samples / richtext / richtext.cpp
index bf3bb2ae977fc64c3f7e1138eb9ff5b9ed1c9370..e0a9968d1ea164b826d82aec8019568bbe0f3c82 100644 (file)
 #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)
@@ -384,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;
@@ -451,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();
@@ -481,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);
@@ -494,8 +506,21 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
 
     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();
 
@@ -623,7 +648,7 @@ MyFrame::MyFrame(const wxString& title, wxWindowID id, const wxPoint& pos,
     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"));