X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b1294ada8e87725409f290328da02306e5c8f4eb..12bb29f5432174ecbd65549bda832d70d34a98ae:/src/gtk1/listbox.cpp diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index d5fcf07764..316e4914db 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -93,9 +93,9 @@ static gint wxlistbox_idle_callback( gpointer gdata ) //----------------------------------------------------------------------------- extern "C" { -static gint gtk_listitem_focus_in_callback( GtkWidget *widget, - GdkEvent *WXUNUSED(event), - wxWindow *win ) +static gint gtk_listitem_focus_in_callback( GtkWidget *WXUNUSED(widget), + GdkEvent *WXUNUSED(event), + wxWindow *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -110,12 +110,12 @@ static gint gtk_listitem_focus_in_callback( GtkWidget *widget, win->m_hasFocus = true; wxChildFocusEvent eventChildFocus(win); - (void)win->GetEventHandler()->ProcessEvent(eventChildFocus); + (void)win->HandleWindowEvent(eventChildFocus); wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId()); eventFocus.SetEventObject(win); - (void)win->GetEventHandler()->ProcessEvent(eventFocus); + (void)win->HandleWindowEvent(eventFocus); } return FALSE; @@ -127,12 +127,14 @@ static gint gtk_listitem_focus_in_callback( GtkWidget *widget, //----------------------------------------------------------------------------- extern "C" { -static gint gtk_listitem_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk_event, wxWindowGTK *win ) +static gint gtk_listitem_focus_out_callback( GtkWidget *WXUNUSED(widget), + GdkEventFocus *WXUNUSED(gdk_event), + wxWindowGTK *win ) { if (g_isIdle) wxapp_install_idle_handler(); - g_focusWindow = (wxWindowGTK *)NULL; + g_focusWindow = NULL; // don't send the window a kill focus event if it thinks that it doesn't // have focus already @@ -147,7 +149,7 @@ static gint gtk_listitem_focus_out_callback( GtkWidget *widget, GdkEventFocus *g // process it too as otherwise bad things happen, especially in GTK2 // where the text control simply aborts the program if it doesn't get // the matching focus out event - (void)win->GetEventHandler()->ProcessEvent( event ); + (void)win->HandleWindowEvent( event ); } return FALSE; @@ -158,7 +160,7 @@ static gint gtk_listitem_focus_out_callback( GtkWidget *widget, GdkEventFocus *g // "button_release_event" //----------------------------------------------------------------------------- -/* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once +/* we would normally emit a wxEVT_LISTBOX_DCLICK event once a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event. this can lead to race conditions so that we emit the dclick event @@ -179,7 +181,7 @@ gtk_listbox_button_release_callback( GtkWidget * WXUNUSED(widget), if (!g_hasDoubleClicked) return FALSE; - wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() ); + wxCommandEvent event( wxEVT_LISTBOX_DCLICK, listbox->GetId() ); event.SetEventObject( listbox ); wxArrayInt aSelections; @@ -200,7 +202,7 @@ gtk_listbox_button_release_callback( GtkWidget * WXUNUSED(widget), event.SetInt(n); - listbox->GetEventHandler()->ProcessEvent( event ); + listbox->HandleWindowEvent( event ); return FALSE; } @@ -232,10 +234,10 @@ gtk_listbox_button_press_callback( GtkWidget *widget, clb->Check( sel, !clb->IsChecked(sel) ); - wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() ); + wxCommandEvent event( wxEVT_CHECKLISTBOX, listbox->GetId() ); event.SetEventObject( listbox ); event.SetInt( sel ); - listbox->GetEventHandler()->ProcessEvent( event ); + listbox->HandleWindowEvent( event ); } #endif // wxUSE_CHECKLISTBOX @@ -255,7 +257,7 @@ gtk_listbox_button_press_callback( GtkWidget *widget, return false; } - /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */ + /* emit wxEVT_LISTBOX_DCLICK later */ g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS); return FALSE; @@ -286,7 +288,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ); new_event.SetCurrentFocus( listbox ); - ret = listbox->GetEventHandler()->ProcessEvent( new_event ); + ret = listbox->HandleWindowEvent( new_event ); } if ((gdk_event->keyval == GDK_Return) && (!ret)) @@ -304,10 +306,10 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis clb->Check( sel, !clb->IsChecked(sel) ); - wxCommandEvent new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() ); + wxCommandEvent new_event( wxEVT_CHECKLISTBOX, listbox->GetId() ); new_event.SetEventObject( listbox ); new_event.SetInt( sel ); - ret = listbox->GetEventHandler()->ProcessEvent( new_event ); + ret = listbox->HandleWindowEvent( new_event ); } #endif // wxUSE_CHECKLISTBOX @@ -327,7 +329,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis else gtk_list_select_item( listbox->m_list, sel ); - wxCommandEvent new_event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); + wxCommandEvent new_event(wxEVT_LISTBOX, listbox->GetId() ); new_event.SetEventObject( listbox ); wxArrayInt aSelections; int n, count = listbox->GetSelections(aSelections); @@ -345,7 +347,7 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis n = -1; } new_event.SetInt(n); - listbox->GetEventHandler()->ProcessEvent( new_event ); + listbox->HandleWindowEvent( new_event ); } } @@ -374,7 +376,7 @@ static void gtk_listitem_select_cb( GtkWidget *widget, if (listbox->m_blockEvent) return; - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); + wxCommandEvent event(wxEVT_LISTBOX, listbox->GetId() ); event.SetEventObject( listbox ); // indicate whether this is a selection or a deselection @@ -410,7 +412,7 @@ static void gtk_listitem_select_cb( GtkWidget *widget, // No longer required with new code in wxLB_SINGLE // listbox->GetEventHandler()->AddPendingEvent( event ); - listbox->GetEventHandler()->ProcessEvent( event ); + listbox->HandleWindowEvent( event ); } extern "C" { @@ -433,7 +435,7 @@ static void gtk_listitem_deselect_callback( GtkWidget *widget, wxListBox *listbo extern "C" { static gint -gtk_listbox_realized_callback( GtkWidget *m_widget, wxListBox *win ) +gtk_listbox_realized_callback( GtkWidget *WXUNUSED(widget), wxListBox *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -450,15 +452,13 @@ gtk_listbox_realized_callback( GtkWidget *m_widget, wxListBox *win ) // wxListBox //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControlWithItems) - // ---------------------------------------------------------------------------- // construction // ---------------------------------------------------------------------------- wxListBox::wxListBox() { - m_list = (GtkList *) NULL; + m_list = NULL; #if wxUSE_CHECKLISTBOX m_hasCheckBoxes = false; #endif // wxUSE_CHECKLISTBOX @@ -494,7 +494,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, return false; } - m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL ); + m_widget = gtk_scrolled_window_new( NULL, NULL ); if (style & wxLB_ALWAYS_SB) { gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget), @@ -546,7 +546,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, } else { - m_strings = (wxSortedArrayString *)NULL; + m_strings = NULL; } Append(n, choices); @@ -565,8 +565,7 @@ wxListBox::~wxListBox() Clear(); - if (m_strings) - delete m_strings; + delete m_strings; } // ---------------------------------------------------------------------------- @@ -600,7 +599,7 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, const unsigned idx = m_strings ? m_strings->Add(item) : pos; - GtkAddItem(item, idx == GetCount() ? -1 : idx); + GtkAddItem(item, idx == GetCount() ? (unsigned) -1 : idx); m_clientList.Insert(idx, NULL); @@ -721,7 +720,7 @@ void wxListBox::DoDeleteOneItem(unsigned int n) wxCHECK_RET( child, wxT("wrong listbox index") ); - GList *list = g_list_append( (GList*) NULL, child->data ); + GList *list = g_list_append( NULL, child->data ); gtk_list_remove_items( m_list, list ); g_list_free( list ); @@ -773,7 +772,7 @@ wxString wxListBox::GetRealLabel(GList *item) const str = wxString( label->label ); #if wxUSE_CHECKLISTBOX - // checklistboxes have "[±] " prepended to their lables, remove it + // checklistboxes have "[±] " prepended to their lables, remove it // // NB: 4 below is the length of wxCHECKLBOX_STRING from wx/gtk1/checklst.h if ( m_hasCheckBoxes ) @@ -993,7 +992,7 @@ void wxListBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) GList *child = m_list->children; while (child) { - gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConvCurrent->cWX2MB(tip), (gchar*) NULL ); + gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConvCurrent->cWX2MB(tip), NULL ); child = child->next; } } @@ -1007,28 +1006,13 @@ GtkWidget *wxListBox::GetConnectWidget() bool wxListBox::IsOwnGtkWindow( GdkWindow *window ) { - return true; - -#if 0 - if (m_widget->window == window) return true; - - if (GTK_WIDGET(m_list)->window == window) return true; - - GList *child = m_list->children; - while (child) - { - GtkWidget *bin = GTK_WIDGET( child->data ); - if (bin->window == window) return true; - child = child->next; - } - - return false; -#endif + return m_widget->window == window || + GTK_WIDGET(m_list)->window == window; } void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style) { - if (m_hasBgCol && m_backgroundColour.Ok()) + if (m_hasBgCol && m_backgroundColour.IsOk()) { GdkWindow *window = GTK_WIDGET(m_list)->window; if ( window ) @@ -1055,9 +1039,9 @@ void wxListBox::DoApplyWidgetStyle(GtkRcStyle *style) void wxListBox::OnInternalIdle() { wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; + if (g_globalCursor.IsOk()) cursor = g_globalCursor; - if (GTK_WIDGET(m_list)->window && cursor.Ok()) + if (GTK_WIDGET(m_list)->window && cursor.IsOk()) { /* I now set the cursor the anew in every OnInternalIdle call as setting the cursor in a parent window also effects the