From 30f82ea416c2b34d1d608cf6ebc369690eb2304e Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Tue, 1 Sep 1998 10:26:14 +0000 Subject: [PATCH] Fixed a few compile things Fixed wxListCtrl::SetItemState bug Tried to hunt down a bug in menu, which disappeared after recompiling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@642 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/confbase.h | 2 +- include/wx/fileconf.h | 4 +++ samples/controls/controls.cpp | 49 +++++++++++++++++++++-------------- src/generic/listctrl.cpp | 3 +-- src/gtk/listbox.cpp | 37 +++++++++++++++++++++++--- src/gtk/menu.cpp | 4 +-- src/gtk/window.cpp | 9 ++++++- src/gtk1/listbox.cpp | 37 +++++++++++++++++++++++--- src/gtk1/menu.cpp | 4 +-- src/gtk1/window.cpp | 9 ++++++- 10 files changed, 123 insertions(+), 35 deletions(-) diff --git a/include/wx/confbase.h b/include/wx/confbase.h index ae259b88ec..d1a669bb42 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -220,7 +220,7 @@ public: inline void SetAppName(const wxString& appName) { m_appName = appName; } inline void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; } - inline void SetStyle(long style) { m_style; } + inline void SetStyle(long style) { m_style = style; } inline long GetStyle() const { return m_style; } protected: diff --git a/include/wx/fileconf.h b/include/wx/fileconf.h index dcf9d10e42..6f5913f3ac 100644 --- a/include/wx/fileconf.h +++ b/include/wx/fileconf.h @@ -17,6 +17,10 @@ #pragma interface "fileconf.h" #endif +#include "wx/defs.h" +#include "wx/textfile.h" +#include "wx/string.h" + // ---------------------------------------------------------------------------- // compile options // ---------------------------------------------------------------------------- diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 399d1bee9c..f2c28e5dfd 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -127,31 +127,32 @@ bool MyApp::OnInit(void) // MyPanel //---------------------------------------------------------------------- -const int ID_NOTEBOOK = 1000; +const ID_NOTEBOOK = 1000; -const int ID_LISTBOX = 130; -const int ID_LISTBOX_SEL_NUM = 131; -const int ID_LISTBOX_SEL_STR = 132; -const int ID_LISTBOX_CLEAR = 133; -const int ID_LISTBOX_APPEND = 134; +const ID_LISTBOX = 130; +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 int ID_CHOICE = 120; -const int ID_CHOICE_SEL_NUM = 121; -const int ID_CHOICE_SEL_STR = 122; -const int ID_CHOICE_CLEAR = 123; -const int ID_CHOICE_APPEND = 124; +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 int ID_COMBO = 140; -const int ID_COMBO_SEL_NUM = 141; -const int ID_COMBO_SEL_STR = 142; -const int ID_COMBO_CLEAR = 143; -const int ID_COMBO_APPEND = 144; +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 int ID_TEXT = 150; +const ID_TEXT = 150; -const int ID_RADIOBOX = 160; -const int ID_RADIOBOX_SEL_NUM = 161; -const int ID_RADIOBOX_SEL_STR = 162; +const ID_RADIOBOX = 160; +const ID_RADIOBOX_SEL_NUM = 161; +const ID_RADIOBOX_SEL_STR = 162; BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_SIZE ( MyPanel::OnSize) @@ -160,6 +161,7 @@ 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) @@ -196,6 +198,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); @@ -265,6 +268,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; + } } } diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index bcfc387d6e..b484ac5033 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1604,8 +1604,7 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask ) wxListLineData *line = (wxListLineData*)node->Data(); bool on = state & wxLIST_STATE_SELECTED; line->Hilight( on ); - RefreshLine( m_current ); - RefreshLine( oldCurrent ); + RefreshLine( line ); }; }; }; diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 734b7fa0a6..00cb2e6ba5 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -156,12 +156,22 @@ void wxListBox::Clear(void) void wxListBox::Delete( int n ) { - gtk_list_clear_items( m_list, n, n ); + GList *child = g_list_nth( m_list->children, n ); + + if (!child) + { + wxFAIL_MSG("wrong listbox index"); + return; + } + + GList *list = g_list_append( NULL, child->data ); + gtk_list_remove_items( m_list, list ); + g_list_free( list ); wxNode *node = m_clientData.Nth( n ); if (!node) { - wxFAIL_MSG("wxListBox::Delete wrong index"); + wxFAIL_MSG("wrong listbox index"); } else m_clientData.DeleteNode( node ); @@ -184,6 +194,7 @@ int wxListBox::FindString( const wxString &item ) const count++; child = child->next; } + wxFAIL_MSG("wrong listbox index"); return -1; } @@ -191,6 +202,8 @@ char *wxListBox::GetClientData( int n ) const { wxNode *node = m_clientData.Nth( n ); if (node) return ((char*)node->Data()); + + wxFAIL_MSG("wrong listbox index"); return (char *) NULL; } @@ -208,6 +221,7 @@ int wxListBox::GetSelection(void) const child = child->next; } } + wxFAIL_MSG("wrong listbox index"); return -1; } @@ -245,6 +259,7 @@ wxString wxListBox::GetString( int n ) const GtkLabel *label = GTK_LABEL( bin->child ); return label->label; } + wxFAIL_MSG("wrong listbox index"); return ""; } @@ -257,6 +272,7 @@ wxString wxListBox::GetStringSelection(void) const wxString tmp = GTK_LABEL( bin->child )->label; return tmp; } + wxFAIL_MSG("no listbox selection available"); return ""; } @@ -280,25 +296,36 @@ bool wxListBox::Selected( int n ) child = child->next; } } + wxFAIL_MSG("wrong listbox index"); return FALSE; } void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) ) { + wxFAIL_MSG("wxListBox::Set not implemented"); } void wxListBox::SetClientData( int n, char *clientData ) { wxNode *node = m_clientData.Nth( n ); - if (node) node->SetData( (wxObject*)clientData ); + if (node) + { + node->SetData( (wxObject*)clientData ); + } + else + { + wxFAIL_MSG("wrong listbox index"); + } } void wxListBox::SetFirstItem( int WXUNUSED(n) ) { + wxFAIL_MSG("wxListBox::SetFirstItem not implemented"); } void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) ) { + wxFAIL_MSG("wxListBox::SetFirstItem not implemented"); } void wxListBox::SetSelection( int n, bool select ) @@ -318,6 +345,10 @@ void wxListBox::SetString( int n, const wxString &string ) GtkLabel *label = GTK_LABEL( bin->child ); gtk_label_set( label, string ); } + else + { + wxFAIL_MSG("wrong listbox index"); + } } void wxListBox::SetStringSelection( const wxString &string, bool select ) diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index a0c5707d0a..fad9d5bb8e 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -202,7 +202,7 @@ void wxMenuItem::SetText(const wxString& str) void wxMenuItem::Check( bool check ) { - wxCHECK_RET( IsCheckable(), _("Can't check uncheckable item!") ) + wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" ) m_isChecked = check; gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); @@ -410,7 +410,7 @@ wxMenuItem *wxMenu::FindItem(int id) const node = node->Next(); } - wxLogDebug(_("wxMenu::FindItem: item %d not found."), id); + wxLogDebug( "wxMenu::FindItem: item %d not found.", id); return (wxMenuItem *) NULL; } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 65993769f9..113d1b04f8 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -159,7 +159,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc //----------------------------------------------------------------------------- // key_press -gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gdk_event, wxWindow *win ) +gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { if (!win->HasVMT()) return FALSE; if (g_blockEventsOnDrag) return FALSE; @@ -262,6 +262,13 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd event.SetEventObject( win ); bool ret = win->ProcessEvent( event ); + + if (ret) + { + if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); + } + /* if (ret) printf( "found.\n") ; */ diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 734b7fa0a6..00cb2e6ba5 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -156,12 +156,22 @@ void wxListBox::Clear(void) void wxListBox::Delete( int n ) { - gtk_list_clear_items( m_list, n, n ); + GList *child = g_list_nth( m_list->children, n ); + + if (!child) + { + wxFAIL_MSG("wrong listbox index"); + return; + } + + GList *list = g_list_append( NULL, child->data ); + gtk_list_remove_items( m_list, list ); + g_list_free( list ); wxNode *node = m_clientData.Nth( n ); if (!node) { - wxFAIL_MSG("wxListBox::Delete wrong index"); + wxFAIL_MSG("wrong listbox index"); } else m_clientData.DeleteNode( node ); @@ -184,6 +194,7 @@ int wxListBox::FindString( const wxString &item ) const count++; child = child->next; } + wxFAIL_MSG("wrong listbox index"); return -1; } @@ -191,6 +202,8 @@ char *wxListBox::GetClientData( int n ) const { wxNode *node = m_clientData.Nth( n ); if (node) return ((char*)node->Data()); + + wxFAIL_MSG("wrong listbox index"); return (char *) NULL; } @@ -208,6 +221,7 @@ int wxListBox::GetSelection(void) const child = child->next; } } + wxFAIL_MSG("wrong listbox index"); return -1; } @@ -245,6 +259,7 @@ wxString wxListBox::GetString( int n ) const GtkLabel *label = GTK_LABEL( bin->child ); return label->label; } + wxFAIL_MSG("wrong listbox index"); return ""; } @@ -257,6 +272,7 @@ wxString wxListBox::GetStringSelection(void) const wxString tmp = GTK_LABEL( bin->child )->label; return tmp; } + wxFAIL_MSG("no listbox selection available"); return ""; } @@ -280,25 +296,36 @@ bool wxListBox::Selected( int n ) child = child->next; } } + wxFAIL_MSG("wrong listbox index"); return FALSE; } void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) ) { + wxFAIL_MSG("wxListBox::Set not implemented"); } void wxListBox::SetClientData( int n, char *clientData ) { wxNode *node = m_clientData.Nth( n ); - if (node) node->SetData( (wxObject*)clientData ); + if (node) + { + node->SetData( (wxObject*)clientData ); + } + else + { + wxFAIL_MSG("wrong listbox index"); + } } void wxListBox::SetFirstItem( int WXUNUSED(n) ) { + wxFAIL_MSG("wxListBox::SetFirstItem not implemented"); } void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) ) { + wxFAIL_MSG("wxListBox::SetFirstItem not implemented"); } void wxListBox::SetSelection( int n, bool select ) @@ -318,6 +345,10 @@ void wxListBox::SetString( int n, const wxString &string ) GtkLabel *label = GTK_LABEL( bin->child ); gtk_label_set( label, string ); } + else + { + wxFAIL_MSG("wrong listbox index"); + } } void wxListBox::SetStringSelection( const wxString &string, bool select ) diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index a0c5707d0a..fad9d5bb8e 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -202,7 +202,7 @@ void wxMenuItem::SetText(const wxString& str) void wxMenuItem::Check( bool check ) { - wxCHECK_RET( IsCheckable(), _("Can't check uncheckable item!") ) + wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" ) m_isChecked = check; gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); @@ -410,7 +410,7 @@ wxMenuItem *wxMenu::FindItem(int id) const node = node->Next(); } - wxLogDebug(_("wxMenu::FindItem: item %d not found."), id); + wxLogDebug( "wxMenu::FindItem: item %d not found.", id); return (wxMenuItem *) NULL; } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 65993769f9..113d1b04f8 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -159,7 +159,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc //----------------------------------------------------------------------------- // key_press -gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gdk_event, wxWindow *win ) +gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) { if (!win->HasVMT()) return FALSE; if (g_blockEventsOnDrag) return FALSE; @@ -262,6 +262,13 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd event.SetEventObject( win ); bool ret = win->ProcessEvent( event ); + + if (ret) + { + if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF)) + gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); + } + /* if (ret) printf( "found.\n") ; */ -- 2.45.2