Small fixes to wxChoice, wxComboBox and wxListBox
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -63,6 +63,7 @@ class wxChoice: public wxControl
|
|||||||
const wxString& name = wxChoiceNameStr );
|
const wxString& name = wxChoiceNameStr );
|
||||||
void Append( const wxString &item );
|
void Append( const wxString &item );
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
|
void Delete(int n);
|
||||||
int FindString( const wxString &string ) const;
|
int FindString( const wxString &string ) const;
|
||||||
int GetColumns(void) const;
|
int GetColumns(void) const;
|
||||||
int GetSelection(void);
|
int GetSelection(void);
|
||||||
|
@@ -63,6 +63,7 @@ class wxChoice: public wxControl
|
|||||||
const wxString& name = wxChoiceNameStr );
|
const wxString& name = wxChoiceNameStr );
|
||||||
void Append( const wxString &item );
|
void Append( const wxString &item );
|
||||||
void Clear(void);
|
void Clear(void);
|
||||||
|
void Delete(int n);
|
||||||
int FindString( const wxString &string ) const;
|
int FindString( const wxString &string ) const;
|
||||||
int GetColumns(void) const;
|
int GetColumns(void) const;
|
||||||
int GetSelection(void);
|
int GetSelection(void);
|
||||||
|
@@ -141,12 +141,14 @@ const ID_CHOICE_SEL_NUM = 121;
|
|||||||
const ID_CHOICE_SEL_STR = 122;
|
const ID_CHOICE_SEL_STR = 122;
|
||||||
const ID_CHOICE_CLEAR = 123;
|
const ID_CHOICE_CLEAR = 123;
|
||||||
const ID_CHOICE_APPEND = 124;
|
const ID_CHOICE_APPEND = 124;
|
||||||
|
const ID_CHOICE_DELETE = 125;
|
||||||
|
|
||||||
const ID_COMBO = 140;
|
const ID_COMBO = 140;
|
||||||
const ID_COMBO_SEL_NUM = 141;
|
const ID_COMBO_SEL_NUM = 141;
|
||||||
const ID_COMBO_SEL_STR = 142;
|
const ID_COMBO_SEL_STR = 142;
|
||||||
const ID_COMBO_CLEAR = 143;
|
const ID_COMBO_CLEAR = 143;
|
||||||
const ID_COMBO_APPEND = 144;
|
const ID_COMBO_APPEND = 144;
|
||||||
|
const ID_COMBO_DELETE = 145;
|
||||||
|
|
||||||
const ID_TEXT = 150;
|
const ID_TEXT = 150;
|
||||||
|
|
||||||
@@ -167,11 +169,13 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel)
|
|||||||
EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons)
|
EVT_BUTTON (ID_CHOICE_SEL_STR, MyPanel::OnChoiceButtons)
|
||||||
EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons)
|
EVT_BUTTON (ID_CHOICE_CLEAR, MyPanel::OnChoiceButtons)
|
||||||
EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons)
|
EVT_BUTTON (ID_CHOICE_APPEND, MyPanel::OnChoiceButtons)
|
||||||
|
EVT_BUTTON (ID_CHOICE_DELETE, MyPanel::OnChoiceButtons)
|
||||||
EVT_CHOICE (ID_COMBO, MyPanel::OnCombo)
|
EVT_CHOICE (ID_COMBO, MyPanel::OnCombo)
|
||||||
EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
|
EVT_BUTTON (ID_COMBO_SEL_NUM, MyPanel::OnComboButtons)
|
||||||
EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
|
EVT_BUTTON (ID_COMBO_SEL_STR, MyPanel::OnComboButtons)
|
||||||
EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
|
EVT_BUTTON (ID_COMBO_CLEAR, MyPanel::OnComboButtons)
|
||||||
EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons)
|
EVT_BUTTON (ID_COMBO_APPEND, MyPanel::OnComboButtons)
|
||||||
|
EVT_BUTTON (ID_COMBO_DELETE, MyPanel::OnComboButtons)
|
||||||
EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio)
|
EVT_RADIOBOX (ID_RADIOBOX, MyPanel::OnRadio)
|
||||||
EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons)
|
EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyPanel::OnRadioButtons)
|
||||||
EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons)
|
EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyPanel::OnRadioButtons)
|
||||||
@@ -207,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_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_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_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");
|
m_notebook->AddPage(panel, "wxChoice");
|
||||||
|
|
||||||
panel = new wxPanel(m_notebook);
|
panel = new wxPanel(m_notebook);
|
||||||
@@ -215,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_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_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_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");
|
m_notebook->AddPage(panel, "wxComboBox");
|
||||||
|
|
||||||
wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE );
|
wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE );
|
||||||
@@ -233,8 +239,8 @@ void MyPanel::OnSize( wxSizeEvent& WXUNUSED(event) )
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
GetClientSize( &x, &y );
|
GetClientSize( &x, &y );
|
||||||
|
|
||||||
if (m_notebook) m_notebook->SetSize( 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+2, x-4, y/2-4 );
|
if (m_text) m_text->SetSize( 2, y*2/3+2, x-4, y/3-4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyPanel::OnListBox( wxCommandEvent &event )
|
void MyPanel::OnListBox( wxCommandEvent &event )
|
||||||
@@ -308,6 +314,12 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
|
|||||||
m_choice->Append( "Hi!" );
|
m_choice->Append( "Hi!" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ID_CHOICE_DELETE:
|
||||||
|
{
|
||||||
|
int idx = m_choice->GetSelection();
|
||||||
|
m_choice->Delete( idx );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,6 +354,12 @@ void MyPanel::OnComboButtons( wxCommandEvent &event )
|
|||||||
m_combo->Append( "Hi!" );
|
m_combo->Append( "Hi!" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case ID_COMBO_DELETE:
|
||||||
|
{
|
||||||
|
int idx = m_combo->GetSelection();
|
||||||
|
m_combo->Delete( idx );
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -103,6 +103,11 @@ void wxChoice::Clear(void)
|
|||||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxChoice::Delete( int WXUNUSED(n) )
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( "wxChoice:Delete not implemented" );
|
||||||
|
}
|
||||||
|
|
||||||
int wxChoice::FindString( const wxString &string ) const
|
int wxChoice::FindString( const wxString &string ) const
|
||||||
{
|
{
|
||||||
// If you read this code once and you think you understand
|
// If you read this code once and you think you understand
|
||||||
|
@@ -143,22 +143,33 @@ void wxComboBox::Append( const wxString &item, char *clientData )
|
|||||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||||
|
|
||||||
|
m_clientData.Append( (wxObject*)clientData );
|
||||||
|
|
||||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||||
|
|
||||||
gtk_widget_show( list_item );
|
gtk_widget_show( list_item );
|
||||||
|
|
||||||
m_clientData.Append( (wxObject*)clientData );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboBox::Delete( int n )
|
void wxComboBox::Delete( int n )
|
||||||
{
|
{
|
||||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||||
gtk_list_clear_items( GTK_LIST(list), n, n );
|
|
||||||
|
GList *child = g_list_nth( listbox->children, n );
|
||||||
|
|
||||||
|
if (!child)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG("wrong index");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GList *list = g_list_append( NULL, child->data );
|
||||||
|
gtk_list_remove_items( listbox, list );
|
||||||
|
g_list_free( list );
|
||||||
|
|
||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "wxComboBox: wrong index" );
|
wxFAIL_MSG( "wrong index" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_clientData.DeleteNode( node );
|
m_clientData.DeleteNode( node );
|
||||||
|
@@ -140,10 +140,10 @@ void wxListBox::Append( const wxString &item, char *clientData )
|
|||||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||||
|
|
||||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
|
||||||
|
|
||||||
m_clientData.Append( (wxObject*)clientData );
|
m_clientData.Append( (wxObject*)clientData );
|
||||||
|
|
||||||
|
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||||
|
|
||||||
gtk_widget_show( list_item );
|
gtk_widget_show( list_item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -103,6 +103,11 @@ void wxChoice::Clear(void)
|
|||||||
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxChoice::Delete( int WXUNUSED(n) )
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( "wxChoice:Delete not implemented" );
|
||||||
|
}
|
||||||
|
|
||||||
int wxChoice::FindString( const wxString &string ) const
|
int wxChoice::FindString( const wxString &string ) const
|
||||||
{
|
{
|
||||||
// If you read this code once and you think you understand
|
// If you read this code once and you think you understand
|
||||||
|
@@ -143,22 +143,33 @@ void wxComboBox::Append( const wxString &item, char *clientData )
|
|||||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||||
|
|
||||||
|
m_clientData.Append( (wxObject*)clientData );
|
||||||
|
|
||||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||||
|
|
||||||
gtk_widget_show( list_item );
|
gtk_widget_show( list_item );
|
||||||
|
|
||||||
m_clientData.Append( (wxObject*)clientData );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxComboBox::Delete( int n )
|
void wxComboBox::Delete( int n )
|
||||||
{
|
{
|
||||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
|
||||||
gtk_list_clear_items( GTK_LIST(list), n, n );
|
|
||||||
|
GList *child = g_list_nth( listbox->children, n );
|
||||||
|
|
||||||
|
if (!child)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG("wrong index");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
GList *list = g_list_append( NULL, child->data );
|
||||||
|
gtk_list_remove_items( listbox, list );
|
||||||
|
g_list_free( list );
|
||||||
|
|
||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
wxFAIL_MSG( "wxComboBox: wrong index" );
|
wxFAIL_MSG( "wrong index" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_clientData.DeleteNode( node );
|
m_clientData.DeleteNode( node );
|
||||||
|
@@ -140,10 +140,10 @@ void wxListBox::Append( const wxString &item, char *clientData )
|
|||||||
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
|
||||||
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
|
||||||
|
|
||||||
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
|
||||||
|
|
||||||
m_clientData.Append( (wxObject*)clientData );
|
m_clientData.Append( (wxObject*)clientData );
|
||||||
|
|
||||||
|
gtk_container_add( GTK_CONTAINER(m_list), list_item );
|
||||||
|
|
||||||
gtk_widget_show( list_item );
|
gtk_widget_show( list_item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user