]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/text/text.cpp
toplevel creation respecting wxDefaultPosition again
[wxWidgets.git] / samples / text / text.cpp
index a8c9ef126a614561c14cbcef38a627df3d78d4d8..c5f32c8d0e7d3befdfdf8e164b01efc522766c9d 100644 (file)
@@ -42,6 +42,7 @@
 
 #include "wx/colordlg.h"
 #include "wx/fontdlg.h"
+#include "wx/numdlg.h"
 
 //----------------------------------------------------------------------
 // class definitions
@@ -97,10 +98,10 @@ class MyPanel: public wxPanel
 {
 public:
     MyPanel(wxFrame *frame, int x, int y, int w, int h);
-    virtual ~MyPanel() 
-    { 
+    virtual ~MyPanel()
+    {
 #if wxUSE_LOG
-        delete wxLog::SetActiveTarget(m_logOld); 
+        delete wxLog::SetActiveTarget(m_logOld);
 #endif // wxUSE_LOG
     }
 
@@ -201,6 +202,27 @@ public:
             wxLogMessage(_T("Already at the top"));
     }
 
+    void OnGetLine(wxCommandEvent& WXUNUSED(event))
+    {
+        long nLine = wxGetNumberFromUser(wxT("Which line would you like to get?"),
+                                         wxT("Enter which line you would like to get"),
+                                         wxT("Get a line from the tabbed multiline text control") );
+
+        wxMessageBox(m_panel->m_tab->GetLineText(nLine));
+    }
+
+    void OnGetLineLength(wxCommandEvent& WXUNUSED(event))
+    {
+        long nLine = wxGetNumberFromUser(wxT("Which line would you like to get?"),
+                                         wxT("Enter which line you would like to get"),
+                                         wxT("Get length of a line from the tabbed multiline text control") );
+
+        wxMessageBox(wxString::Format(wxT("Length of line %i is:%i"),
+                                      (int) nLine,
+                                      m_panel->m_tab->GetLineLength(nLine))
+                    );
+    }
+
 #if wxUSE_LOG
     void OnLogClear(wxCommandEvent& event);
 #endif // wxUSE_LOG
@@ -336,6 +358,10 @@ enum
     TEXT_LINE_UP,
     TEXT_PAGE_DOWN,
     TEXT_PAGE_UP,
+
+    TEXT_GET_LINE,
+    TEXT_GET_LINELENGTH,
+
     TEXT_REMOVE,
     TEXT_REPLACE,
     TEXT_SELECT,
@@ -410,7 +436,10 @@ bool MyApp::OnInit()
     menuText->Append(TEXT_LINE_DOWN, _T("Scroll text one line down"));
     menuText->Append(TEXT_LINE_UP, _T("Scroll text one line up"));
     menuText->Append(TEXT_PAGE_DOWN, _T("Scroll text one page down"));
-    menuText->Append(TEXT_PAGE_DOWN, _T("Scroll text one page up"));
+    menuText->Append(TEXT_PAGE_UP, _T("Scroll text one page up"));
+    menuText->AppendSeparator();
+    menuText->Append(TEXT_GET_LINE, _T("Get the text of a line of the tabbed multiline"));
+    menuText->Append(TEXT_GET_LINELENGTH, _T("Get the length of a line of the tabbed multiline"));
     menu_bar->Append(menuText, _T("Te&xt"));
 
 #if wxUSE_LOG
@@ -1212,6 +1241,9 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(TEXT_PAGE_DOWN,          MyFrame::OnScrollPageDown)
     EVT_MENU(TEXT_PAGE_UP,            MyFrame::OnScrollPageUp)
 
+    EVT_MENU(TEXT_GET_LINE,            MyFrame::OnGetLine)
+    EVT_MENU(TEXT_GET_LINELENGTH,            MyFrame::OnGetLineLength)
+
     EVT_MENU(TEXT_SET,                MyFrame::OnSetText)
 
     EVT_IDLE(MyFrame::OnIdle)
@@ -1521,7 +1553,7 @@ void RichTextFrame::OnChangeFont(wxCommandEvent& WXUNUSED(event))
 
         wxTextAttr attr;
         attr.SetFont(font);
-        
+
         long start, end;
         m_textCtrl->GetSelection(& start, & end);
         m_textCtrl->SetStyle(start, end, attr);
@@ -1537,7 +1569,7 @@ void RichTextFrame::OnChangeTextColour(wxCommandEvent& WXUNUSED(event))
     data.SetChooseFull(true);
     for (int i = 0; i < 16; i++)
     {
-        wxColour colour(i*16, i*16, i*16);
+        wxColour colour((unsigned char)(i*16), (unsigned char)(i*16), (unsigned char)(i*16));
         data.SetCustomColour(i, colour);
     }
 
@@ -1550,7 +1582,7 @@ void RichTextFrame::OnChangeTextColour(wxCommandEvent& WXUNUSED(event))
 
         wxTextAttr attr;
         attr.SetTextColour(col);
-        
+
         long start, end;
         m_textCtrl->GetSelection(& start, & end);
         m_textCtrl->SetStyle(start, end, attr);
@@ -1566,7 +1598,7 @@ void RichTextFrame::OnChangeBackgroundColour(wxCommandEvent& WXUNUSED(event))
     data.SetChooseFull(true);
     for (int i = 0; i < 16; i++)
     {
-        wxColour colour(i*16, i*16, i*16);
+        wxColour colour((unsigned char)(i*16), (unsigned char)(i*16), (unsigned char)(i*16));
         data.SetCustomColour(i, colour);
     }
 
@@ -1579,7 +1611,7 @@ void RichTextFrame::OnChangeBackgroundColour(wxCommandEvent& WXUNUSED(event))
 
         wxTextAttr attr;
         attr.SetBackgroundColour(col);
-        
+
         long start, end;
         m_textCtrl->GetSelection(& start, & end);
         m_textCtrl->SetStyle(start, end, attr);
@@ -1603,7 +1635,7 @@ void RichTextFrame::OnLeftIndent(wxCommandEvent& WXUNUSED(event))
 
         wxTextAttr attr;
         attr.SetLeftIndent(indent);
-        
+
         long start, end;
         m_textCtrl->GetSelection(& start, & end);
         m_textCtrl->SetStyle(start, end, attr);
@@ -1627,7 +1659,7 @@ void RichTextFrame::OnRightIndent(wxCommandEvent& WXUNUSED(event))
 
         wxTextAttr attr;
         attr.SetRightIndent(indent);
-        
+
         long start, end;
         m_textCtrl->GetSelection(& start, & end);
         m_textCtrl->SetStyle(start, end, attr);
@@ -1664,6 +1696,21 @@ void RichTextFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
                 (const wxChar*) facename,
                 attr.GetTextColour().Red(), attr.GetTextColour().Green(), attr.GetTextColour().Blue(),
                 (const wxChar*) alignment);
+
+            if (attr.HasFont())
+            {
+                if (attr.GetFont().GetWeight() == wxBOLD)
+                    msg += wxT(" BOLD");
+                else if (attr.GetFont().GetWeight() == wxNORMAL)
+                    msg += wxT(" NORMAL");
+
+                if (attr.GetFont().GetStyle() == wxITALIC)
+                    msg += wxT(" ITALIC");
+
+                if (attr.GetFont().GetUnderlined())
+                    msg += wxT(" UNDERLINED");
+            }
+
             SetStatusText(msg);
         }
 #endif // wxUSE_STATUSBAR