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
This commit is contained in:
Robert Roebling
1998-09-01 10:26:14 +00:00
parent 34da0970a0
commit 30f82ea416
10 changed files with 123 additions and 35 deletions

View File

@@ -220,7 +220,7 @@ public:
inline void SetAppName(const wxString& appName) { m_appName = appName; } inline void SetAppName(const wxString& appName) { m_appName = appName; }
inline void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; } 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; } inline long GetStyle() const { return m_style; }
protected: protected:

View File

@@ -17,6 +17,10 @@
#pragma interface "fileconf.h" #pragma interface "fileconf.h"
#endif #endif
#include "wx/defs.h"
#include "wx/textfile.h"
#include "wx/string.h"
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// compile options // compile options
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -127,31 +127,32 @@ bool MyApp::OnInit(void)
// MyPanel // MyPanel
//---------------------------------------------------------------------- //----------------------------------------------------------------------
const int ID_NOTEBOOK = 1000; const ID_NOTEBOOK = 1000;
const int ID_LISTBOX = 130; const ID_LISTBOX = 130;
const int ID_LISTBOX_SEL_NUM = 131; const ID_LISTBOX_SEL_NUM = 131;
const int ID_LISTBOX_SEL_STR = 132; const ID_LISTBOX_SEL_STR = 132;
const int ID_LISTBOX_CLEAR = 133; const ID_LISTBOX_CLEAR = 133;
const int ID_LISTBOX_APPEND = 134; const ID_LISTBOX_APPEND = 134;
const ID_LISTBOX_DELETE = 135;
const int ID_CHOICE = 120; const ID_CHOICE = 120;
const int ID_CHOICE_SEL_NUM = 121; const ID_CHOICE_SEL_NUM = 121;
const int ID_CHOICE_SEL_STR = 122; const ID_CHOICE_SEL_STR = 122;
const int ID_CHOICE_CLEAR = 123; const ID_CHOICE_CLEAR = 123;
const int ID_CHOICE_APPEND = 124; const ID_CHOICE_APPEND = 124;
const int ID_COMBO = 140; const ID_COMBO = 140;
const int ID_COMBO_SEL_NUM = 141; const ID_COMBO_SEL_NUM = 141;
const int ID_COMBO_SEL_STR = 142; const ID_COMBO_SEL_STR = 142;
const int ID_COMBO_CLEAR = 143; const ID_COMBO_CLEAR = 143;
const int ID_COMBO_APPEND = 144; const ID_COMBO_APPEND = 144;
const int ID_TEXT = 150; const ID_TEXT = 150;
const int ID_RADIOBOX = 160; const ID_RADIOBOX = 160;
const int ID_RADIOBOX_SEL_NUM = 161; const ID_RADIOBOX_SEL_NUM = 161;
const int ID_RADIOBOX_SEL_STR = 162; const ID_RADIOBOX_SEL_STR = 162;
BEGIN_EVENT_TABLE(MyPanel, wxPanel) BEGIN_EVENT_TABLE(MyPanel, wxPanel)
EVT_SIZE ( MyPanel::OnSize) 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_SEL_STR, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_CLEAR, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons) EVT_BUTTON (ID_LISTBOX_APPEND, MyPanel::OnListBoxButtons)
EVT_BUTTON (ID_LISTBOX_DELETE, MyPanel::OnListBoxButtons)
EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice) EVT_CHOICE (ID_CHOICE, MyPanel::OnChoice)
EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons) EVT_BUTTON (ID_CHOICE_SEL_NUM, MyPanel::OnChoiceButtons)
EVT_BUTTON (ID_CHOICE_SEL_STR, 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_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_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_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"); m_notebook->AddPage(panel, "wxList");
panel = new wxPanel(m_notebook); panel = new wxPanel(m_notebook);
@@ -265,6 +268,12 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
m_listbox->Append( "Hi!" ); m_listbox->Append( "Hi!" );
break; break;
} }
case ID_LISTBOX_DELETE:
{
int idx = m_listbox->GetSelection();
m_listbox->Delete( idx );
break;
}
} }
} }

View File

@@ -1604,8 +1604,7 @@ void wxListMainWindow::SetItemState( long item, long state, long stateMask )
wxListLineData *line = (wxListLineData*)node->Data(); wxListLineData *line = (wxListLineData*)node->Data();
bool on = state & wxLIST_STATE_SELECTED; bool on = state & wxLIST_STATE_SELECTED;
line->Hilight( on ); line->Hilight( on );
RefreshLine( m_current ); RefreshLine( line );
RefreshLine( oldCurrent );
}; };
}; };
}; };

View File

@@ -156,12 +156,22 @@ void wxListBox::Clear(void)
void wxListBox::Delete( int n ) 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 ); wxNode *node = m_clientData.Nth( n );
if (!node) if (!node)
{ {
wxFAIL_MSG("wxListBox::Delete wrong index"); wxFAIL_MSG("wrong listbox index");
} }
else else
m_clientData.DeleteNode( node ); m_clientData.DeleteNode( node );
@@ -184,6 +194,7 @@ int wxListBox::FindString( const wxString &item ) const
count++; count++;
child = child->next; child = child->next;
} }
wxFAIL_MSG("wrong listbox index");
return -1; return -1;
} }
@@ -191,6 +202,8 @@ char *wxListBox::GetClientData( int n ) const
{ {
wxNode *node = m_clientData.Nth( n ); wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data()); if (node) return ((char*)node->Data());
wxFAIL_MSG("wrong listbox index");
return (char *) NULL; return (char *) NULL;
} }
@@ -208,6 +221,7 @@ int wxListBox::GetSelection(void) const
child = child->next; child = child->next;
} }
} }
wxFAIL_MSG("wrong listbox index");
return -1; return -1;
} }
@@ -245,6 +259,7 @@ wxString wxListBox::GetString( int n ) const
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
return label->label; return label->label;
} }
wxFAIL_MSG("wrong listbox index");
return ""; return "";
} }
@@ -257,6 +272,7 @@ wxString wxListBox::GetStringSelection(void) const
wxString tmp = GTK_LABEL( bin->child )->label; wxString tmp = GTK_LABEL( bin->child )->label;
return tmp; return tmp;
} }
wxFAIL_MSG("no listbox selection available");
return ""; return "";
} }
@@ -280,25 +296,36 @@ bool wxListBox::Selected( int n )
child = child->next; child = child->next;
} }
} }
wxFAIL_MSG("wrong listbox index");
return FALSE; return FALSE;
} }
void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) ) void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
{ {
wxFAIL_MSG("wxListBox::Set not implemented");
} }
void wxListBox::SetClientData( int n, char *clientData ) void wxListBox::SetClientData( int n, char *clientData )
{ {
wxNode *node = m_clientData.Nth( n ); 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) ) void wxListBox::SetFirstItem( int WXUNUSED(n) )
{ {
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
} }
void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) ) void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
{ {
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
} }
void wxListBox::SetSelection( int n, bool select ) 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 ); GtkLabel *label = GTK_LABEL( bin->child );
gtk_label_set( label, string ); gtk_label_set( label, string );
} }
else
{
wxFAIL_MSG("wrong listbox index");
}
} }
void wxListBox::SetStringSelection( const wxString &string, bool select ) void wxListBox::SetStringSelection( const wxString &string, bool select )

View File

@@ -202,7 +202,7 @@ void wxMenuItem::SetText(const wxString& str)
void wxMenuItem::Check( bool check ) void wxMenuItem::Check( bool check )
{ {
wxCHECK_RET( IsCheckable(), _("Can't check uncheckable item!") ) wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" )
m_isChecked = check; m_isChecked = check;
gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)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(); node = node->Next();
} }
wxLogDebug(_("wxMenu::FindItem: item %d not found."), id); wxLogDebug( "wxMenu::FindItem: item %d not found.", id);
return (wxMenuItem *) NULL; return (wxMenuItem *) NULL;
} }

View File

@@ -159,7 +159,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// key_press // 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 (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) 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 ); event.SetEventObject( win );
bool ret = win->ProcessEvent( event ); 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") ; if (ret) printf( "found.\n") ;
*/ */

View File

@@ -156,12 +156,22 @@ void wxListBox::Clear(void)
void wxListBox::Delete( int n ) 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 ); wxNode *node = m_clientData.Nth( n );
if (!node) if (!node)
{ {
wxFAIL_MSG("wxListBox::Delete wrong index"); wxFAIL_MSG("wrong listbox index");
} }
else else
m_clientData.DeleteNode( node ); m_clientData.DeleteNode( node );
@@ -184,6 +194,7 @@ int wxListBox::FindString( const wxString &item ) const
count++; count++;
child = child->next; child = child->next;
} }
wxFAIL_MSG("wrong listbox index");
return -1; return -1;
} }
@@ -191,6 +202,8 @@ char *wxListBox::GetClientData( int n ) const
{ {
wxNode *node = m_clientData.Nth( n ); wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data()); if (node) return ((char*)node->Data());
wxFAIL_MSG("wrong listbox index");
return (char *) NULL; return (char *) NULL;
} }
@@ -208,6 +221,7 @@ int wxListBox::GetSelection(void) const
child = child->next; child = child->next;
} }
} }
wxFAIL_MSG("wrong listbox index");
return -1; return -1;
} }
@@ -245,6 +259,7 @@ wxString wxListBox::GetString( int n ) const
GtkLabel *label = GTK_LABEL( bin->child ); GtkLabel *label = GTK_LABEL( bin->child );
return label->label; return label->label;
} }
wxFAIL_MSG("wrong listbox index");
return ""; return "";
} }
@@ -257,6 +272,7 @@ wxString wxListBox::GetStringSelection(void) const
wxString tmp = GTK_LABEL( bin->child )->label; wxString tmp = GTK_LABEL( bin->child )->label;
return tmp; return tmp;
} }
wxFAIL_MSG("no listbox selection available");
return ""; return "";
} }
@@ -280,25 +296,36 @@ bool wxListBox::Selected( int n )
child = child->next; child = child->next;
} }
} }
wxFAIL_MSG("wrong listbox index");
return FALSE; return FALSE;
} }
void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) ) void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
{ {
wxFAIL_MSG("wxListBox::Set not implemented");
} }
void wxListBox::SetClientData( int n, char *clientData ) void wxListBox::SetClientData( int n, char *clientData )
{ {
wxNode *node = m_clientData.Nth( n ); 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) ) void wxListBox::SetFirstItem( int WXUNUSED(n) )
{ {
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
} }
void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) ) void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
{ {
wxFAIL_MSG("wxListBox::SetFirstItem not implemented");
} }
void wxListBox::SetSelection( int n, bool select ) 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 ); GtkLabel *label = GTK_LABEL( bin->child );
gtk_label_set( label, string ); gtk_label_set( label, string );
} }
else
{
wxFAIL_MSG("wrong listbox index");
}
} }
void wxListBox::SetStringSelection( const wxString &string, bool select ) void wxListBox::SetStringSelection( const wxString &string, bool select )

View File

@@ -202,7 +202,7 @@ void wxMenuItem::SetText(const wxString& str)
void wxMenuItem::Check( bool check ) void wxMenuItem::Check( bool check )
{ {
wxCHECK_RET( IsCheckable(), _("Can't check uncheckable item!") ) wxCHECK_RET( IsCheckable(), "Can't check uncheckable item!" )
m_isChecked = check; m_isChecked = check;
gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)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(); node = node->Next();
} }
wxLogDebug(_("wxMenu::FindItem: item %d not found."), id); wxLogDebug( "wxMenu::FindItem: item %d not found.", id);
return (wxMenuItem *) NULL; return (wxMenuItem *) NULL;
} }

View File

@@ -159,7 +159,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// key_press // 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 (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) 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 ); event.SetEventObject( win );
bool ret = win->ProcessEvent( event ); 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") ; if (ret) printf( "found.\n") ;
*/ */