1. added wxEvtHandler::SafelyProcessEvent() and wxWindow::HandleWindowEvent() to correctly handle exceptions in even handlers in wxGTK

2. use HandleWindowEvent() everywhere as more obvious and convenient shortcut for GetEventHandler()->ProcessEvent(); also for consistency with wxGTK where it's required

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50329 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-11-29 17:00:58 +00:00
parent 787f0fc4f3
commit 937013e0fd
152 changed files with 638 additions and 552 deletions

View File

@@ -1066,7 +1066,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
if ( wxTranslateGTKKeyEventToWx(event, win, gdk_event) )
{
// Emit KEY_DOWN event
ret = win->GetEventHandler()->ProcessEvent( event );
ret = win->HandleWindowEvent( event );
}
else
{
@@ -1122,12 +1122,12 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
if (parent)
{
event.SetEventType( wxEVT_CHAR_HOOK );
ret = parent->GetEventHandler()->ProcessEvent( event );
ret = parent->HandleWindowEvent( event );
}
if (!ret)
{
event.SetEventType(wxEVT_CHAR);
win->GetEventHandler()->ProcessEvent( event );
win->HandleWindowEvent( event );
}
}
return true;
@@ -1146,7 +1146,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
if (command != -1)
{
wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
ret = ancestor->GetEventHandler()->ProcessEvent( command_event );
ret = ancestor->HandleWindowEvent( command_event );
break;
}
if (ancestor->IsTopLevel())
@@ -1191,13 +1191,13 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
if (parent)
{
event.SetEventType( wxEVT_CHAR_HOOK );
ret = parent->GetEventHandler()->ProcessEvent( event );
ret = parent->HandleWindowEvent( event );
}
if (!ret)
{
event.SetEventType(wxEVT_CHAR);
ret = win->GetEventHandler()->ProcessEvent( event );
ret = win->HandleWindowEvent( event );
}
}
}
@@ -1227,7 +1227,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
// CTRL-TAB changes the (parent) window, i.e. switch notebook page
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
new_event.SetCurrentFocus( win );
ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event );
ret = win->GetParent()->HandleWindowEvent( new_event );
}
// generate wxID_CANCEL if <esc> has been pressed (typically in dialogs)
@@ -1263,7 +1263,7 @@ static gint gtk_window_key_press_callback( GtkWidget *widget,
{
wxCommandEvent eventClick(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
eventClick.SetEventObject(btnCancel);
ret = btnCancel->GetEventHandler()->ProcessEvent(eventClick);
ret = btnCancel->HandleWindowEvent(eventClick);
}
}
@@ -1304,7 +1304,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget,
return FALSE;
}
if ( !win->GetEventHandler()->ProcessEvent( event ) )
if ( !win->HandleWindowEvent( event ) )
return FALSE;
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" );
@@ -1616,7 +1616,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
}
}
if (win->GetEventHandler()->ProcessEvent( event ))
if (win->HandleWindowEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
g_lastMouseEvent = NULL;
@@ -1638,7 +1638,7 @@ static gint gtk_window_button_press_callback( GtkWidget *widget,
win->GetId(),
win->ClientToScreen(event.GetPosition()));
evtCtx.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(evtCtx);
return win->HandleWindowEvent(evtCtx);
}
return FALSE;
@@ -1701,7 +1701,7 @@ static gint gtk_window_button_release_callback( GtkWidget *widget,
if ( !g_captureWindow )
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
if (win->GetEventHandler()->ProcessEvent( event ))
if (win->HandleWindowEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
return TRUE;
@@ -1771,7 +1771,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget,
: wxEVT_LEAVE_WINDOW);
InitMouseEvent(win, eventM, gdk_event);
eventM.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(eventM);
win->HandleWindowEvent(eventM);
}
}
else // no capture
@@ -1779,7 +1779,7 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget,
win = FindWindowForMouseEvent(win, event.m_x, event.m_y);
}
bool ret = win->GetEventHandler()->ProcessEvent( event );
bool ret = win->HandleWindowEvent( event );
g_lastMouseEvent = NULL;
if ( ret )
@@ -1802,12 +1802,12 @@ static bool DoSendFocusEvents(wxWindow *win)
// Notify the parent keeping track of focus for the kbd navigation
// purposes that we got it.
wxChildFocusEvent eventChildFocus(win);
(void)win->GetEventHandler()->ProcessEvent(eventChildFocus);
(void)win->HandleWindowEvent(eventChildFocus);
wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId());
eventFocus.SetEventObject(win);
return win->GetEventHandler()->ProcessEvent(eventFocus);
return win->HandleWindowEvent(eventFocus);
}
extern "C" {
@@ -1908,7 +1908,7 @@ static gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget),
// 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;
@@ -1950,7 +1950,7 @@ gint gtk_window_enter_callback( GtkWidget *widget,
event.m_x = x + pt.x;
event.m_y = y + pt.y;
if (win->GetEventHandler()->ProcessEvent( event ))
if (win->HandleWindowEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
return TRUE;
@@ -2002,7 +2002,7 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
event.m_x = x + pt.x;
event.m_y = y + pt.y;
if (win->GetEventHandler()->ProcessEvent( event ))
if (win->HandleWindowEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
return TRUE;
@@ -2042,7 +2042,7 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust,
wxScrollWinEvent event( command, value, wxVERTICAL );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
win->HandleWindowEvent( event );
}
}
@@ -2075,7 +2075,7 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust,
wxScrollWinEvent event( command, value, wxHORIZONTAL );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
win->HandleWindowEvent( event );
}
}
@@ -2141,7 +2141,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
wxScrollWinEvent event( command, value, dir );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
win->HandleWindowEvent( event );
}
win->m_isScrolling = false;
@@ -2179,7 +2179,7 @@ gtk_window_realized_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
wxWindowCreateEvent event( win );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
win->HandleWindowEvent( event );
return FALSE;
}
@@ -2213,7 +2213,7 @@ void gtk_window_size_callback( GtkWidget *WXUNUSED(widget),
{
wxSizeEvent event( win->GetSize(), win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
win->HandleWindowEvent( event );
}
}
}
@@ -2917,7 +2917,7 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags
{
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
GetEventHandler()->ProcessEvent( event );
HandleWindowEvent( event );
}
m_resizing = false;
@@ -3208,7 +3208,7 @@ bool wxWindowGTK::Show( bool show )
wxShowEvent eventShow(GetId(), show);
eventShow.SetEventObject(this);
GetEventHandler()->ProcessEvent(eventShow);
HandleWindowEvent(eventShow);
return true;
}
@@ -3596,7 +3596,7 @@ void wxWindowGTK::GtkSendPaintEvents()
wxEraseEvent erase_event( GetId(), &dc );
erase_event.SetEventObject( this );
if (!GetEventHandler()->ProcessEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
if (!HandleWindowEvent(erase_event) && GetBackgroundStyle() != wxBG_STYLE_CUSTOM)
{
if (!g_eraseGC)
{
@@ -3618,11 +3618,11 @@ void wxWindowGTK::GtkSendPaintEvents()
wxNcPaintEvent nc_paint_event( GetId() );
nc_paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( nc_paint_event );
HandleWindowEvent( nc_paint_event );
wxPaintEvent paint_event( GetId() );
paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( paint_event );
HandleWindowEvent( paint_event );
m_clipPaintRegion = false;