]> git.saurik.com Git - wxWidgets.git/commitdiff
tests for sorted wxChoice added
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Oct 1999 13:13:51 +0000 (13:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 22 Oct 1999 13:13:51 +0000 (13:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4137 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/controls/controls.cpp

index 76d3d3e3433b96230d3a77a60c8fe31e3c31e2c1..22ad1497208845b79b1937b39d558364d116a56a 100644 (file)
@@ -105,7 +105,8 @@ public:
 #endif // wxUSE_SPINBUTTON
 
     wxListBox     *m_listbox;
 #endif // wxUSE_SPINBUTTON
 
     wxListBox     *m_listbox;
-    wxChoice      *m_choice;
+    wxChoice      *m_choice,
+                  *m_choiceSorted;
     wxComboBox    *m_combo;
     wxRadioBox    *m_radio;
     wxGauge       *m_gauge;
     wxComboBox    *m_combo;
     wxRadioBox    *m_radio;
     wxGauge       *m_gauge;
@@ -234,6 +235,7 @@ const int  ID_CHOICE_APPEND     = 124;
 const int  ID_CHOICE_DELETE     = 125;
 const int  ID_CHOICE_FONT       = 126;
 const int  ID_CHOICE_ENABLE     = 127;
 const int  ID_CHOICE_DELETE     = 125;
 const int  ID_CHOICE_FONT       = 126;
 const int  ID_CHOICE_ENABLE     = 127;
+const int  ID_CHOICE_SORTED     = 128;
 
 const int  ID_COMBO             = 140;
 const int  ID_COMBO_SEL_NUM     = 141;
 
 const int  ID_COMBO             = 140;
 const int  ID_COMBO_SEL_NUM     = 141;
@@ -275,6 +277,7 @@ EVT_BUTTON    (ID_LISTBOX_DELETE,       MyPanel::OnListBoxButtons)
 EVT_BUTTON    (ID_LISTBOX_FONT,         MyPanel::OnListBoxButtons)
 EVT_CHECKBOX  (ID_LISTBOX_ENABLE,       MyPanel::OnListBoxButtons)
 EVT_CHOICE    (ID_CHOICE,               MyPanel::OnChoice)
 EVT_BUTTON    (ID_LISTBOX_FONT,         MyPanel::OnListBoxButtons)
 EVT_CHECKBOX  (ID_LISTBOX_ENABLE,       MyPanel::OnListBoxButtons)
 EVT_CHOICE    (ID_CHOICE,               MyPanel::OnChoice)
+EVT_CHOICE    (ID_CHOICE_SORTED,        MyPanel::OnChoice)
 EVT_BUTTON    (ID_CHOICE_SEL_NUM,       MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_SEL_STR,       MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_CLEAR,         MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_SEL_NUM,       MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_SEL_STR,       MyPanel::OnChoiceButtons)
 EVT_BUTTON    (ID_CHOICE_CLEAR,         MyPanel::OnChoiceButtons)
@@ -411,6 +414,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
 
     panel = new wxPanel(m_notebook);
     m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
 
     panel = new wxPanel(m_notebook);
     m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
+    m_choiceSorted = new wxChoice( panel, ID_CHOICE_SORTED, wxPoint(10,70), wxSize(120,-1),
+                                   5, choices, wxCB_SORT );
     m_choice->SetSelection(2);
     m_choice->SetBackgroundColour( "red" );
     (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
     m_choice->SetSelection(2);
     m_choice->SetBackgroundColour( "red" );
     (void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
@@ -672,9 +677,11 @@ void MyPanel::OnChoice( wxCommandEvent &event )
     m_text->AppendText( "Choice event selection string is: " );
     m_text->AppendText( event.GetString() );
     m_text->AppendText( "\n" );
     m_text->AppendText( "Choice event selection string is: " );
     m_text->AppendText( event.GetString() );
     m_text->AppendText( "\n" );
-    m_text->AppendText( "Choice control selection string is: " );
+    m_text->AppendText( "Choice control selection string is: '" );
     m_text->AppendText( m_choice->GetStringSelection() );
     m_text->AppendText( m_choice->GetStringSelection() );
-    m_text->AppendText( "\n" );
+    m_text->AppendText( "' (for unsorted control)\nand '" );
+    m_text->AppendText( m_choiceSorted->GetStringSelection() );
+    m_text->AppendText( "' (for sorted control)\n" );
 }
 
 void MyPanel::OnChoiceButtons( wxCommandEvent &event )
 }
 
 void MyPanel::OnChoiceButtons( wxCommandEvent &event )
@@ -684,37 +691,45 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
         case ID_CHOICE_ENABLE:
             {
                 m_choice->Enable( event.GetInt() == 0 );
         case ID_CHOICE_ENABLE:
             {
                 m_choice->Enable( event.GetInt() == 0 );
+                m_choiceSorted->Enable( event.GetInt() == 0 );
                 break;
             }
         case ID_CHOICE_SEL_NUM:
             {
                 m_choice->SetSelection( 2 );
                 break;
             }
         case ID_CHOICE_SEL_NUM:
             {
                 m_choice->SetSelection( 2 );
+                m_choiceSorted->SetSelection( 2 );
                 break;
             }
         case ID_CHOICE_SEL_STR:
             {
                 m_choice->SetStringSelection( "This" );
                 break;
             }
         case ID_CHOICE_SEL_STR:
             {
                 m_choice->SetStringSelection( "This" );
+                m_choiceSorted->SetStringSelection( "This" );
                 break;
             }
         case ID_CHOICE_CLEAR:
             {
                 m_choice->Clear();
                 break;
             }
         case ID_CHOICE_CLEAR:
             {
                 m_choice->Clear();
+                m_choiceSorted->Clear();
                 break;
             }
         case ID_CHOICE_APPEND:
             {
                 m_choice->Append( "Hi!" );
                 break;
             }
         case ID_CHOICE_APPEND:
             {
                 m_choice->Append( "Hi!" );
+                m_choiceSorted->Append( "Hi!" );
                 break;
             }
         case ID_CHOICE_DELETE:
             {
                 int idx = m_choice->GetSelection();
                 m_choice->Delete( idx );
                 break;
             }
         case ID_CHOICE_DELETE:
             {
                 int idx = m_choice->GetSelection();
                 m_choice->Delete( idx );
+                idx = m_choiceSorted->GetSelection();
+                m_choiceSorted->Delete( idx );
                 break;
             }
         case ID_CHOICE_FONT:
             {
                 m_choice->SetFont( *wxITALIC_FONT );
                 break;
             }
         case ID_CHOICE_FONT:
             {
                 m_choice->SetFont( *wxITALIC_FONT );
+                m_choiceSorted->SetFont( *wxITALIC_FONT );
                 break;
             }
     }
                 break;
             }
     }