]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/combobox.cpp
Changes for wxOGL since wxFatalError has been deprecated.
[wxWidgets.git] / samples / widgets / combobox.cpp
index b270e2656c412c3a69ddc9adae51897c9458654e..b4a4ecc9610e6d6e6dc8dc6e64d81451a280bfd6 100644 (file)
@@ -182,8 +182,6 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook,
                                        wxImageList *imaglist)
                   : WidgetsPage(notebook)
 {
                                        wxImageList *imaglist)
                   : WidgetsPage(notebook)
 {
-    imaglist->Add(wxBitmap(combobox_xpm));
-
     // init everything
     m_chkSort =
     m_chkReadonly = (wxCheckBox *)NULL;
     // init everything
     m_chkSort =
     m_chkReadonly = (wxCheckBox *)NULL;
@@ -191,6 +189,8 @@ ComboboxWidgetsPage::ComboboxWidgetsPage(wxNotebook *notebook,
     m_combobox = (wxComboBox *)NULL;
     m_sizerCombo = (wxSizer *)NULL;
 
     m_combobox = (wxComboBox *)NULL;
     m_sizerCombo = (wxSizer *)NULL;
 
+    imaglist->Add(wxBitmap(combobox_xpm));
+
     /*
        What we create here is a frame having 3 panes: style pane is the
        leftmost one, in the middle the pane with buttons allowing to perform
     /*
        What we create here is a frame having 3 panes: style pane is the
        leftmost one, in the middle the pane with buttons allowing to perform
@@ -441,38 +441,49 @@ void ComboboxWidgetsPage::OnButtonAddSeveral(wxCommandEvent& event)
 
 void ComboboxWidgetsPage::OnUpdateUICurText(wxUpdateUIEvent& event)
 {
 
 void ComboboxWidgetsPage::OnUpdateUICurText(wxUpdateUIEvent& event)
 {
-    event.SetText( wxString::Format(_T("%d"), m_combobox->GetSelection()) );
+    if (m_combobox)
+        event.SetText( wxString::Format(_T("%d"), m_combobox->GetSelection()) );
 }
 
 void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
 }
 
 void ComboboxWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
-    event.Enable( m_chkSort->GetValue() || m_chkReadonly->GetValue() );
+    if (m_combobox)
+        event.Enable( m_chkSort->GetValue() || m_chkReadonly->GetValue() );
 }
 
 void ComboboxWidgetsPage::OnUpdateUIDeleteButton(wxUpdateUIEvent& event)
 {
 }
 
 void ComboboxWidgetsPage::OnUpdateUIDeleteButton(wxUpdateUIEvent& event)
 {
-    unsigned long n;
-    event.Enable(m_textDelete->GetValue().ToULong(&n) &&
-                    (n < (unsigned)m_combobox->GetCount()));
+    if (m_combobox)
+    {
+      unsigned long n;
+      event.Enable(m_textDelete->GetValue().ToULong(&n) &&
+                (n < (unsigned)m_combobox->GetCount()));
+    }
 }
 
 void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
 {
 }
 
 void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
 {
-    event.Enable(m_combobox->GetSelection() != -1);
+    if (m_combobox)
+        event.Enable(m_combobox->GetSelection() != -1);
 }
 
 void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
 {
 }
 
 void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
 {
-    event.Enable(m_combobox->GetCount() != 0);
+    if (m_combobox)
+        event.Enable(m_combobox->GetCount() != 0);
 }
 
 void ComboboxWidgetsPage::OnUpdateUIAddSeveral(wxUpdateUIEvent& event)
 {
 }
 
 void ComboboxWidgetsPage::OnUpdateUIAddSeveral(wxUpdateUIEvent& event)
 {
-    event.Enable(!(m_combobox->GetWindowStyle() & wxCB_SORT));
+    if (m_combobox)
+        event.Enable(!(m_combobox->GetWindowStyle() & wxCB_SORT));
 }
 
 void ComboboxWidgetsPage::OnComboText(wxCommandEvent& event)
 {
 }
 
 void ComboboxWidgetsPage::OnComboText(wxCommandEvent& event)
 {
+    if (!m_combobox)
+       return;
+    
     wxString s = event.GetString();
 
     wxASSERT_MSG( s == m_combobox->GetValue(),
     wxString s = event.GetString();
 
     wxASSERT_MSG( s == m_combobox->GetValue(),