]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/textctrl.cpp
Add an informational message to the file picker page of widgets sample.
[wxWidgets.git] / samples / widgets / textctrl.cpp
index 4a7c0dd6595118e2f88b4f595ec82ea82c3c9b38..c69f23d0b5127ace47b82fddca3de58e5093019e 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     27.03.01
 // Id:          $Id$
 // Copyright:   (c) 2001 Vadim Zeitlin
-// License:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -106,6 +106,7 @@ static const struct ControlValues
 
     bool password;
     bool readonly;
+    bool processEnter;
     bool filename;
 
     WrapStyle wrapStyle;
@@ -118,6 +119,7 @@ static const struct ControlValues
     TextLines_Multi,    // multiline
     false,              // not password
     false,              // not readonly
+    true,               // do process enter
     false,              // not filename
     WrapStyle_Word,     // wrap on word boundaries
 #ifdef __WXMSW__
@@ -169,6 +171,7 @@ protected:
 
     void OnText(wxCommandEvent& event);
     void OnTextEnter(wxCommandEvent& event);
+    void OnTextPasted(wxClipboardTextEvent& event);
 
     void OnCheckOrRadioBox(wxCommandEvent& event);
 
@@ -205,6 +208,7 @@ protected:
     // the checkboxes controlling text ctrl styles
     wxCheckBox *m_chkPassword,
                *m_chkReadonly,
+               *m_chkProcessEnter,
                *m_chkFilename;
 
     // under MSW we test rich edit controls as well here
@@ -323,6 +327,7 @@ BEGIN_EVENT_TABLE(TextWidgetsPage, WidgetsPage)
 
     EVT_TEXT(TextPage_Textctrl, TextWidgetsPage::OnText)
     EVT_TEXT_ENTER(TextPage_Textctrl, TextWidgetsPage::OnTextEnter)
+    EVT_TEXT_PASTE(TextPage_Textctrl, TextWidgetsPage::OnTextPasted)
 
     EVT_CHECKBOX(wxID_ANY, TextWidgetsPage::OnCheckOrRadioBox)
     EVT_RADIOBOX(wxID_ANY, TextWidgetsPage::OnCheckOrRadioBox)
@@ -364,6 +369,7 @@ TextWidgetsPage::TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
 
     m_chkPassword =
     m_chkReadonly =
+    m_chkProcessEnter =
     m_chkFilename = (wxCheckBox *)NULL;
 
     m_text =
@@ -410,6 +416,9 @@ void TextWidgetsPage::CreateContent()
     m_chkReadonly = CreateCheckBoxAndAddToSizer(
                         sizerLeft, wxT("&Read-only mode")
                     );
+    m_chkProcessEnter = CreateCheckBoxAndAddToSizer(
+                        sizerLeft, wxT("Process &Enter")
+                    );
     m_chkFilename = CreateCheckBoxAndAddToSizer(
                         sizerLeft, wxT("&Filename control")
                     );
@@ -611,6 +620,7 @@ void TextWidgetsPage::Reset()
 
     m_chkPassword->SetValue(DEFAULTS.password);
     m_chkReadonly->SetValue(DEFAULTS.readonly);
+    m_chkProcessEnter->SetValue(DEFAULTS.processEnter);
     m_chkFilename->SetValue(DEFAULTS.filename);
 
     m_radioWrap->SetSelection(DEFAULTS.wrapStyle);
@@ -641,6 +651,8 @@ void TextWidgetsPage::CreateText()
         flags |= wxTE_PASSWORD;
     if ( m_chkReadonly->GetValue() )
         flags |= wxTE_READONLY;
+    if ( m_chkProcessEnter->GetValue() )
+        flags |= wxTE_PROCESS_ENTER;
 
     switch ( m_radioWrap->GetSelection() )
     {
@@ -885,6 +897,7 @@ void TextWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 #endif // __WXMSW__
                   (m_chkPassword->GetValue() != DEFAULTS.password) ||
                   (m_chkReadonly->GetValue() != DEFAULTS.readonly) ||
+                  (m_chkProcessEnter->GetValue() != DEFAULTS.processEnter) ||
                   (m_chkFilename->GetValue() != DEFAULTS.filename) ||
                   (m_radioWrap->GetSelection() != DEFAULTS.wrapStyle) );
 }
@@ -910,6 +923,12 @@ void TextWidgetsPage::OnTextEnter(wxCommandEvent& event)
     event.Skip();
 }
 
+void TextWidgetsPage::OnTextPasted(wxClipboardTextEvent& event)
+{
+    wxLogMessage("Text pasted from clipboard.");
+    event.Skip();
+}
+
 void TextWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
 {
     CreateText();