]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/combobox.cpp
fixes potential crash under gatekeeper
[wxWidgets.git] / samples / widgets / combobox.cpp
index 5eb34f42da30f4750e1b087f10cdc70deeaaef9c..d0bf973a3b7076de2789b5bb3416082b8d2b69f8 100644 (file)
@@ -124,6 +124,7 @@ protected:
     void OnCloseup(wxCommandEvent& event);
     void OnComboBox(wxCommandEvent& event);
     void OnComboText(wxCommandEvent& event);
     void OnCloseup(wxCommandEvent& event);
     void OnComboBox(wxCommandEvent& event);
     void OnComboText(wxCommandEvent& event);
+    void OnComboTextPasted(wxClipboardTextEvent& event);
 
     void OnCheckOrRadioBox(wxCommandEvent& event);
 
 
     void OnCheckOrRadioBox(wxCommandEvent& event);
 
@@ -152,7 +153,7 @@ protected:
     // the checkboxes for styles
     wxCheckBox *m_chkSort,
                *m_chkReadonly,
     // the checkboxes for styles
     wxCheckBox *m_chkSort,
                *m_chkReadonly,
-               *m_chkFilename;
+               *m_chkProcessEnter;
 
     // the combobox itself and the sizer it is in
     wxComboBox *m_combobox;
 
     // the combobox itself and the sizer it is in
     wxComboBox *m_combobox;
@@ -215,6 +216,7 @@ BEGIN_EVENT_TABLE(ComboboxWidgetsPage, WidgetsPage)
     EVT_COMBOBOX_CLOSEUP(ComboPage_Combo, ComboboxWidgetsPage::OnCloseup)
     EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
     EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
     EVT_COMBOBOX_CLOSEUP(ComboPage_Combo, ComboboxWidgetsPage::OnCloseup)
     EVT_TEXT(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
     EVT_TEXT_ENTER(ComboPage_Combo, ComboboxWidgetsPage::OnComboText)
+    EVT_TEXT_PASTE(ComboPage_Combo, ComboboxWidgetsPage::OnComboTextPasted)
 
     EVT_CHECKBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox)
     EVT_RADIOBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox)
 
     EVT_CHECKBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox)
     EVT_RADIOBOX(wxID_ANY, ComboboxWidgetsPage::OnCheckOrRadioBox)
@@ -241,7 +243,7 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(WidgetsBookCtrl *book,
     // init everything
     m_chkSort =
     m_chkReadonly =
     // init everything
     m_chkSort =
     m_chkReadonly =
-    m_chkFilename = (wxCheckBox *)NULL;
+    m_chkProcessEnter = (wxCheckBox *)NULL;
 
     m_combobox = (wxComboBox *)NULL;
     m_sizerCombo = (wxSizer *)NULL;
 
     m_combobox = (wxComboBox *)NULL;
     m_sizerCombo = (wxSizer *)NULL;
@@ -276,8 +278,7 @@ void ComboboxWidgetsPage::CreateContent()
 
     m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&Sort items"));
     m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&Read only"));
 
     m_chkSort = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&Sort items"));
     m_chkReadonly = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&Read only"));
-    m_chkFilename = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("&File name"));
-    m_chkFilename->Disable(); // not implemented yet
+    m_chkProcessEnter = CreateCheckBoxAndAddToSizer(sizerLeftTop, wxT("Process &Enter"));
 
     sizerLeftTop->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
     sizerLeftTop->Add(m_radioKind, 0, wxGROW | wxALL, 5);
 
     sizerLeftTop->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
     sizerLeftTop->Add(m_radioKind, 0, wxGROW | wxALL, 5);
@@ -296,7 +297,7 @@ void ComboboxWidgetsPage::CreateContent()
     wxSizer *sizerLeft = new wxBoxSizer(wxVERTICAL);
     sizerLeft->Add(sizerLeftTop);
     sizerLeft->AddSpacer(10);
     wxSizer *sizerLeft = new wxBoxSizer(wxVERTICAL);
     sizerLeft->Add(sizerLeftTop);
     sizerLeft->AddSpacer(10);
-    sizerLeft->Add(sizerLeftBottom);
+    sizerLeft->Add(sizerLeftBottom, wxSizerFlags().Expand());
 
     // middle pane
     wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY,
 
     // middle pane
     wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY,
@@ -402,7 +403,7 @@ void ComboboxWidgetsPage::Reset()
 {
     m_chkSort->SetValue(false);
     m_chkReadonly->SetValue(false);
 {
     m_chkSort->SetValue(false);
     m_chkReadonly->SetValue(false);
-    m_chkFilename->SetValue(false);
+    m_chkProcessEnter->SetValue(false);
 }
 
 void ComboboxWidgetsPage::CreateCombo()
 }
 
 void ComboboxWidgetsPage::CreateCombo()
@@ -413,6 +414,9 @@ void ComboboxWidgetsPage::CreateCombo()
         flags |= wxCB_SORT;
     if ( m_chkReadonly->GetValue() )
         flags |= wxCB_READONLY;
         flags |= wxCB_SORT;
     if ( m_chkReadonly->GetValue() )
         flags |= wxCB_READONLY;
+    if ( m_chkProcessEnter->GetValue() )
+        flags |= wxTE_PROCESS_ENTER;
+
 
     switch ( m_radioKind->GetSelection() )
     {
 
     switch ( m_radioKind->GetSelection() )
     {
@@ -450,11 +454,6 @@ void ComboboxWidgetsPage::CreateCombo()
                                 0, NULL,
                                 flags);
 
                                 0, NULL,
                                 flags);
 
-#if 0
-    if ( m_chkFilename->GetValue() )
-        ;
-#endif // TODO
-
     unsigned int count = items.GetCount();
     for ( unsigned int n = 0; n < count; n++ )
     {
     unsigned int count = items.GetCount();
     for ( unsigned int n = 0; n < count; n++ )
     {
@@ -481,11 +480,7 @@ void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
     int sel = m_combobox->GetSelection();
     if ( sel != wxNOT_FOUND )
     {
     int sel = m_combobox->GetSelection();
     if ( sel != wxNOT_FOUND )
     {
-#ifndef __WXGTK__
         m_combobox->SetString(sel, m_textChange->GetValue());
         m_combobox->SetString(sel, m_textChange->GetValue());
-#else
-        wxLogMessage(wxT("Not implemented in wxGTK"));
-#endif
     }
 }
 
     }
 }
 
@@ -596,7 +591,7 @@ void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
     event.Enable( m_chkSort->GetValue() ||
                     m_chkReadonly->GetValue() ||
 {
     event.Enable( m_chkSort->GetValue() ||
                     m_chkReadonly->GetValue() ||
-                        m_chkFilename->GetValue() );
+                        m_chkProcessEnter->GetValue() );
 }
 
 void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event)
 }
 
 void ComboboxWidgetsPage::OnUpdateUIInsert(wxUpdateUIEvent& event)
@@ -656,7 +651,7 @@ void ComboboxWidgetsPage::OnComboText(wxCommandEvent& event)
     wxASSERT_MSG( s == m_combobox->GetValue(),
                   wxT("event and combobox values should be the same") );
 
     wxASSERT_MSG( s == m_combobox->GetValue(),
                   wxT("event and combobox values should be the same") );
 
-    if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER)
+    if (event.GetEventType() == wxEVT_TEXT_ENTER)
     {
         wxLogMessage(wxT("Combobox enter pressed (now '%s')"), s.c_str());
     }
     {
         wxLogMessage(wxT("Combobox enter pressed (now '%s')"), s.c_str());
     }
@@ -666,6 +661,12 @@ void ComboboxWidgetsPage::OnComboText(wxCommandEvent& event)
     }
 }
 
     }
 }
 
+void ComboboxWidgetsPage::OnComboTextPasted(wxClipboardTextEvent& event)
+{
+    wxLogMessage("Text pasted from clipboard.");
+    event.Skip();
+}
+
 void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event)
 {
     long sel = event.GetInt();
 void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event)
 {
     long sel = event.GetInt();
@@ -676,6 +677,12 @@ void ComboboxWidgetsPage::OnComboBox(wxCommandEvent& event)
     wxLogMessage(wxT("Combobox item %ld selected"), sel);
 
     wxLogMessage(wxT("Combobox GetValue(): %s"), m_combobox->GetValue().c_str() );
     wxLogMessage(wxT("Combobox item %ld selected"), sel);
 
     wxLogMessage(wxT("Combobox GetValue(): %s"), m_combobox->GetValue().c_str() );
+
+    if ( event.GetString() != m_combobox->GetValue() )
+    {
+        wxLogMessage("ERROR: Event has different string \"%s\"",
+                     event.GetString());
+    }
 }
 
 void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
 }
 
 void ComboboxWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))