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:
#pragma interface "fileconf.h"
#endif
+#include "wx/defs.h"
+#include "wx/textfile.h"
+#include "wx/string.h"
+
// ----------------------------------------------------------------------------
// compile options
// ----------------------------------------------------------------------------
// 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)
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)
(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);
m_listbox->Append( "Hi!" );
break;
}
+ case ID_LISTBOX_DELETE:
+ {
+ int idx = m_listbox->GetSelection();
+ m_listbox->Delete( idx );
+ break;
+ }
}
}
wxListLineData *line = (wxListLineData*)node->Data();
bool on = state & wxLIST_STATE_SELECTED;
line->Hilight( on );
- RefreshLine( m_current );
- RefreshLine( oldCurrent );
+ RefreshLine( line );
};
};
};
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 );
count++;
child = child->next;
}
+ wxFAIL_MSG("wrong listbox index");
return -1;
}
{
wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
+
+ wxFAIL_MSG("wrong listbox index");
return (char *) NULL;
}
child = child->next;
}
}
+ wxFAIL_MSG("wrong listbox index");
return -1;
}
GtkLabel *label = GTK_LABEL( bin->child );
return label->label;
}
+ wxFAIL_MSG("wrong listbox index");
return "";
}
wxString tmp = GTK_LABEL( bin->child )->label;
return tmp;
}
+ wxFAIL_MSG("no listbox selection available");
return "";
}
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 )
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 )
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 );
node = node->Next();
}
- wxLogDebug(_("wxMenu::FindItem: item %d not found."), id);
+ wxLogDebug( "wxMenu::FindItem: item %d not found.", id);
return (wxMenuItem *) NULL;
}
//-----------------------------------------------------------------------------
// 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;
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") ;
*/
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 );
count++;
child = child->next;
}
+ wxFAIL_MSG("wrong listbox index");
return -1;
}
{
wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
+
+ wxFAIL_MSG("wrong listbox index");
return (char *) NULL;
}
child = child->next;
}
}
+ wxFAIL_MSG("wrong listbox index");
return -1;
}
GtkLabel *label = GTK_LABEL( bin->child );
return label->label;
}
+ wxFAIL_MSG("wrong listbox index");
return "";
}
wxString tmp = GTK_LABEL( bin->child )->label;
return tmp;
}
+ wxFAIL_MSG("no listbox selection available");
return "";
}
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 )
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 )
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 );
node = node->Next();
}
- wxLogDebug(_("wxMenu::FindItem: item %d not found."), id);
+ wxLogDebug( "wxMenu::FindItem: item %d not found.", id);
return (wxMenuItem *) NULL;
}
//-----------------------------------------------------------------------------
// 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;
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") ;
*/