]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/text/text.cpp
add a radio box to select the combobox type (#9845)
[wxWidgets.git] / samples / text / text.cpp
index e40562aeb4443032c6e39c0d7081abf849b27c8a..f8ed400e59a9ae14b365f73ce4b4301ad9de7017 100644 (file)
@@ -194,6 +194,12 @@ public:
     }
 #endif // wxUSE_CLIPBOARD
 
     }
 #endif // wxUSE_CLIPBOARD
 
+    void OnAddTextLine(wxCommandEvent& WXUNUSED(event))
+    {
+        static int s_n = 0;
+        m_panel->m_textrich->AppendText(wxString::Format("Line %d\n", ++s_n));
+    }
+
     void OnAddTextFreeze( wxCommandEvent& WXUNUSED(event) )
         { DoAddText(true); }
     void OnAddText( wxCommandEvent& WXUNUSED(event) )
     void OnAddTextFreeze( wxCommandEvent& WXUNUSED(event) )
         { DoAddText(true); }
     void OnAddText( wxCommandEvent& WXUNUSED(event) )
@@ -311,20 +317,21 @@ private:
     void DoAddText(bool freeze)
     {
         wxTextCtrl * const text = m_panel->m_textrich;
     void DoAddText(bool freeze)
     {
         wxTextCtrl * const text = m_panel->m_textrich;
-        text->Clear();
 
         if ( freeze )
             text->Freeze();
 
 
         if ( freeze )
             text->Freeze();
 
+        text->Clear();
+
         for ( int i = 0; i < 100; i++ )
         {
             text->AppendText(wxString::Format(wxT("Line %i\n"), i));
         }
 
         for ( int i = 0; i < 100; i++ )
         {
             text->AppendText(wxString::Format(wxT("Line %i\n"), i));
         }
 
+        text->SetInsertionPoint(0);
+
         if ( freeze )
             text->Thaw();
         if ( freeze )
             text->Thaw();
-
-        text->SetInsertionPoint(0);
     }
 
     MyPanel *m_panel;
     }
 
     MyPanel *m_panel;
@@ -394,6 +401,7 @@ enum
     // text menu
     TEXT_ADD_SOME = 400,
     TEXT_ADD_FREEZE,
     // text menu
     TEXT_ADD_SOME = 400,
     TEXT_ADD_FREEZE,
+    TEXT_ADD_LINE,
     TEXT_MOVE_ENDTEXT,
     TEXT_MOVE_ENDENTRY,
     TEXT_SET_EDITABLE,
     TEXT_MOVE_ENDTEXT,
     TEXT_MOVE_ENDENTRY,
     TEXT_SET_EDITABLE,
@@ -475,6 +483,7 @@ bool MyApp::OnInit()
     wxMenu *menuText = new wxMenu;
     menuText->Append(TEXT_ADD_SOME, _T("&Append some text\tCtrl-A"));
     menuText->Append(TEXT_ADD_FREEZE, _T("&Append text with freeze/thaw\tShift-Ctrl-A"));
     wxMenu *menuText = new wxMenu;
     menuText->Append(TEXT_ADD_SOME, _T("&Append some text\tCtrl-A"));
     menuText->Append(TEXT_ADD_FREEZE, _T("&Append text with freeze/thaw\tShift-Ctrl-A"));
+    menuText->Append(TEXT_ADD_LINE, _T("Append a new &line\tAlt-Shift-A"));
     menuText->Append(TEXT_REMOVE, _T("&Remove first 10 characters\tCtrl-Y"));
     menuText->Append(TEXT_REPLACE, _T("&Replace characters 4 to 8 with ABC\tCtrl-R"));
     menuText->Append(TEXT_SELECT, _T("&Select characters 4 to 8\tCtrl-I"));
     menuText->Append(TEXT_REMOVE, _T("&Remove first 10 characters\tCtrl-Y"));
     menuText->Append(TEXT_REPLACE, _T("&Replace characters 4 to 8 with ABC\tCtrl-R"));
     menuText->Append(TEXT_SELECT, _T("&Select characters 4 to 8\tCtrl-I"));
@@ -921,6 +930,10 @@ void MyTextCtrl::OnKeyDown(wxKeyEvent& event)
                 wxLogMessage(_T("Selection = '%s' (len = %u)"),
                              sel.c_str(),
                              (unsigned int) sel.length());
                 wxLogMessage(_T("Selection = '%s' (len = %u)"),
                              sel.c_str(),
                              (unsigned int) sel.length());
+
+                const wxString text = GetLineText(line);
+                wxLogMessage(_T("Current line: \"%s\"; length = %lu"),
+                             text.c_str(), text.length());
             }
             break;
 
             }
             break;
 
@@ -1140,7 +1153,6 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
     topSizer->Add( m_log, 1, wxALL | wxEXPAND, 10 );
 #endif
 
     topSizer->Add( m_log, 1, wxALL | wxEXPAND, 10 );
 #endif
 
-    SetAutoLayout( true );
     SetSizer(topSizer);
 }
 
     SetSizer(topSizer);
 }
 
@@ -1333,6 +1345,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(TEXT_SELECT,             MyFrame::OnSelectText)
     EVT_MENU(TEXT_ADD_SOME,           MyFrame::OnAddText)
     EVT_MENU(TEXT_ADD_FREEZE,         MyFrame::OnAddTextFreeze)
     EVT_MENU(TEXT_SELECT,             MyFrame::OnSelectText)
     EVT_MENU(TEXT_ADD_SOME,           MyFrame::OnAddText)
     EVT_MENU(TEXT_ADD_FREEZE,         MyFrame::OnAddTextFreeze)
+    EVT_MENU(TEXT_ADD_LINE,           MyFrame::OnAddTextLine)
     EVT_MENU(TEXT_MOVE_ENDTEXT,       MyFrame::OnMoveToEndOfText)
     EVT_MENU(TEXT_MOVE_ENDENTRY,      MyFrame::OnMoveToEndOfEntry)
 
     EVT_MENU(TEXT_MOVE_ENDTEXT,       MyFrame::OnMoveToEndOfText)
     EVT_MENU(TEXT_MOVE_ENDENTRY,      MyFrame::OnMoveToEndOfEntry)
 
@@ -1495,13 +1508,13 @@ void MyFrame::OnIdle( wxIdleEvent& event )
         wxString msg;
         msg.Printf(
 #ifdef __WXMSW__
         wxString msg;
         msg.Printf(
 #ifdef __WXMSW__
-                _T("Focus: wxWindow = %p, HWND = %08x"),
+                _T("Focus: wxWindow = %p, HWND = %p"),
 #else
                 _T("Focus: wxWindow = %p"),
 #endif
                 s_windowFocus
 #ifdef __WXMSW__
 #else
                 _T("Focus: wxWindow = %p"),
 #endif
                 s_windowFocus
 #ifdef __WXMSW__
-                , (unsigned int) s_windowFocus->GetHWND()
+                , s_windowFocus->GetHWND()
 #endif
                   );
 
 #endif
                   );