X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e8435fa381a3479dc5fe8c3d56d8e58b53568599..f4a8c29f7a3ffa7eb60d9b7f055565eb2df368d9:/samples/controls/controls.cpp diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 663f1b4c95..e0e3ea5cc1 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -92,14 +92,14 @@ IMPLEMENT_APP (MyApp) // MyApp //---------------------------------------------------------------------- -const MINIMAL_QUIT = 100; -const MINIMAL_TEXT = 101; -const MINIMAL_ABOUT = 102; +const int MINIMAL_QUIT = 100; +const int MINIMAL_TEXT = 101; +const int MINIMAL_ABOUT = 102; bool MyApp::OnInit(void) { // Create the main frame window - MyFrame *frame = new MyFrame(NULL, "Controls wxWindows App", 50, 50, 500, 420 ); + MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Controls wxWindows App", 50, 50, 500, 420 ); // Give it an icon #ifdef __WXMSW__ @@ -134,18 +134,21 @@ const ID_LISTBOX_SEL_NUM = 131; const ID_LISTBOX_SEL_STR = 132; const ID_LISTBOX_CLEAR = 133; const ID_LISTBOX_APPEND = 134; +const ID_LISTBOX_DELETE = 135; const ID_CHOICE = 120; const ID_CHOICE_SEL_NUM = 121; const ID_CHOICE_SEL_STR = 122; const ID_CHOICE_CLEAR = 123; const ID_CHOICE_APPEND = 124; +const ID_CHOICE_DELETE = 125; const ID_COMBO = 140; const ID_COMBO_SEL_NUM = 141; const ID_COMBO_SEL_STR = 142; const ID_COMBO_CLEAR = 143; const ID_COMBO_APPEND = 144; +const ID_COMBO_DELETE = 145; const ID_TEXT = 150; @@ -160,16 +163,19 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_BUTTON (ID_LISTBOX_SEL_STR, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons) + EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons) EVT_CHOICE (ID_CHOICE, 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_APPEND, MyPanel::OnChoiceButtons) + EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons) EVT_CHOICE (ID_COMBO, MyPanel::OnCombo) EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons) EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons) EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons) EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons) + EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons) EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio) EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons) EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons) @@ -196,6 +202,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) ); (void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) ); (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) ); + (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); m_notebook->AddPage(panel, "wxList"); panel = new wxPanel(m_notebook); @@ -204,6 +211,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : (void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) ); (void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) ); (void)new wxButton( panel, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) ); + (void)new wxButton( panel, ID_CHOICE_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); m_notebook->AddPage(panel, "wxChoice"); panel = new wxPanel(m_notebook); @@ -212,6 +220,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : (void)new wxButton( panel, ID_COMBO_SEL_STR, "Select 'This'", wxPoint(300,30), wxSize(100,30) ); (void)new wxButton( panel, ID_COMBO_CLEAR, "Clear", wxPoint(180,80), wxSize(100,30) ); (void)new wxButton( panel, ID_COMBO_APPEND, "Append 'Hi!'", wxPoint(300,80), wxSize(100,30) ); + (void)new wxButton( panel, ID_COMBO_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); m_notebook->AddPage(panel, "wxComboBox"); wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE ); @@ -230,8 +239,8 @@ void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) ) int y = 0; GetClientSize( &x, &y ); - if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y/2-4 ); - if (m_text) m_text->SetSize( 2, y/2+2, x-4, y/2-4 ); + if (m_notebook) m_notebook->SetSize( 2, 2, x-4, y*2/3-4 ); + if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 ); } void MyPanel::OnListBox( wxCommandEvent &event ) @@ -265,6 +274,12 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event ) m_listbox->Append( "Hi!" ); break; } + case ID_LISTBOX_DELETE: + { + int idx = m_listbox->GetSelection(); + m_listbox->Delete( idx ); + break; + } } } @@ -299,6 +314,12 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event ) m_choice->Append( "Hi!" ); break; } + case ID_CHOICE_DELETE: + { + int idx = m_choice->GetSelection(); + m_choice->Delete( idx ); + break; + } } } @@ -333,6 +354,12 @@ void MyPanel::OnComboButtons( wxCommandEvent &event ) m_combo->Append( "Hi!" ); break; } + case ID_COMBO_DELETE: + { + int idx = m_combo->GetSelection(); + m_combo->Delete( idx ); + break; + } } } @@ -372,7 +399,7 @@ END_EVENT_TABLE() MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h): wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) { - (void*) new MyPanel( this, 10, 10, 300, 100 ); + (void)new MyPanel( this, 10, 10, 300, 100 ); } void MyFrame::OnQuit (wxCommandEvent& WXUNUSED(event) )