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

@@ -184,7 +184,7 @@ wxSize wxControl::DoGetBestSize() const
bool wxControl::ProcessCommand(wxCommandEvent& event)
{
return GetEventHandler()->ProcessEvent(event);
return HandleWindowEvent(event);
}
WXHBRUSH wxControl::OnCtlColor(WXHDC hWxDC,

View File

@@ -433,7 +433,7 @@ void wxFrame::OnSysColourChanged(
wxSysColourChangedEvent vEvent2;
vEvent2.SetEventObject(m_frameStatusBar);
m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2);
m_frameStatusBar->HandleWindowEvent(vEvent2);
}
#endif //wxUSE_STATUSBAR
@@ -570,7 +570,7 @@ bool wxFrame::ShowFullScreen( bool bShow, long lStyle )
wxSize sz( nWidth, nHeight );
wxSizeEvent vEvent( sz, GetId() );
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
return true;
}
else
@@ -1051,7 +1051,7 @@ bool wxFrame::HandleMenuSelect( WXWORD nItem,
wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nItem);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent); // return value would be ignored by PM
HandleWindowEvent(vEvent); // return value would be ignored by PM
}
else
{

View File

@@ -660,7 +660,7 @@ bool wxListBox::OS2Command(
n = -1;
}
vEvent.SetInt(n);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxListBox::OS2Command
// ----------------------------------------------------------------------------

View File

@@ -2750,7 +2750,7 @@ MRESULT wxListCtrl::OS2WindowProc( WXUINT uMsg,
//
}
vEvent.SetEventType(vEventType);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
bProcessed = HandleWindowEvent(vEvent);
break;
}
if (!bProcessed)

View File

@@ -223,14 +223,14 @@ int wxNotebook::SetSelection( size_t nPage )
vEvent.SetSelection(nPage);
vEvent.SetOldSelection(m_nSelection);
vEvent.SetEventObject(this);
if (!GetEventHandler()->ProcessEvent(vEvent) || vEvent.IsAllowed())
if (!HandleWindowEvent(vEvent) || vEvent.IsAllowed())
{
//
// Program allows the page change
//
vEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
::WinSendMsg( GetHWND()
,BKM_TURNTOPAGE
@@ -800,7 +800,7 @@ void wxNotebook::OnNavigationKey (
wxWindow* pPage = m_pages[m_nSelection];
if (!pPage->GetEventHandler()->ProcessEvent(rEvent))
if (!pPage->HandleWindowEvent(rEvent))
{
pPage->SetFocus();
}
@@ -822,7 +822,7 @@ void wxNotebook::OnNavigationKey (
if (pParent)
{
rEvent.SetCurrentFocus(this);
pParent->GetEventHandler()->ProcessEvent(rEvent);
pParent->HandleWindowEvent(rEvent);
}
}
}

View File

@@ -225,7 +225,7 @@ bool wxScrollBar::OS2OnScroll ( int WXUNUSED(nOrientation),
vEvent.SetOrientation(IsVertical() ? wxVERTICAL : wxHORIZONTAL);
vEvent.SetPosition(nPosition);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxScrollBar::OS2OnScroll
void wxScrollBar::SetThumbPosition ( int nViewStart )

View File

@@ -972,13 +972,13 @@ bool wxSlider::OS2OnScroll( int WXUNUSED(nOrientation),
vEvent.SetPosition(nNewPos);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
wxCommandEvent vCevent( wxEVT_COMMAND_SLIDER_UPDATED, GetId() );
vCevent.SetInt(nNewPos);
vCevent.SetEventObject(this);
return (GetEventHandler()->ProcessEvent(vCevent));
return (HandleWindowEvent(vCevent));
} // end of wxSlider::OS2OnScroll
void wxSlider::SetLineSize( int nLineSize )

View File

@@ -194,7 +194,7 @@ bool wxSpinButton::OS2OnScroll( int WXUNUSED(nOrientation),
vEvent.SetPosition(nVal);
vEvent.SetEventObject(this);
return(GetEventHandler()->ProcessEvent(vEvent));
return(HandleWindowEvent(vEvent));
} // end of wxSpinButton::OS2OnScroll
bool wxSpinButton::OS2Command( WXUINT WXUNUSED(uCmd),

View File

@@ -333,7 +333,7 @@ void wxSpinCtrl::OnChar (
InitCommandEvent(vEvent);
vEvent.SetString(sVal);
vEvent.SetInt(GetValue());
if (GetEventHandler()->ProcessEvent(vEvent))
if (HandleWindowEvent(vEvent))
return;
break;
}
@@ -351,7 +351,7 @@ void wxSpinCtrl::OnChar (
vEventNav.SetDirection(!rEvent.ShiftDown());
vEventNav.SetWindowChange(rEvent.ControlDown());
vEventNav.SetEventObject(this);
if (GetParent()->GetEventHandler()->ProcessEvent(vEventNav))
if (GetParent()->HandleWindowEvent(vEventNav))
return;
}
break;
@@ -373,7 +373,7 @@ void wxSpinCtrl::OnSpinChange(
vEvent.SetEventObject(this);
vEvent.SetInt(rEventSpin.GetPosition());
(void)GetEventHandler()->ProcessEvent(vEvent);
(void)HandleWindowEvent(vEvent);
if (rEventSpin.GetSkipped())
{
vEvent.Skip();
@@ -406,7 +406,7 @@ bool wxSpinCtrl::ProcessTextCommand( WXWORD wCmd,
vEvent.SetString(sVal);
vEvent.SetInt(GetValue());
return (GetEventHandler()->ProcessEvent(vEvent));
return (HandleWindowEvent(vEvent));
}
case SPBN_SETFOCUS:
@@ -417,7 +417,7 @@ bool wxSpinCtrl::ProcessTextCommand( WXWORD wCmd,
);
vEvent.SetEventObject(this);
return(GetEventHandler()->ProcessEvent(vEvent));
return(HandleWindowEvent(vEvent));
}
default:
break;

View File

@@ -1049,7 +1049,7 @@ void wxTextCtrl::OnChar(
wxCommandEvent vEvent(wxEVT_COMMAND_TEXT_ENTER, m_windowId);
vEvent.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(vEvent))
if ( HandleWindowEvent(vEvent))
return;
}
//else: multiline controls need Enter for themselves
@@ -1071,7 +1071,7 @@ void wxTextCtrl::OnChar(
vEventNav.SetWindowChange(false);
vEventNav.SetEventObject(this);
if ( GetEventHandler()->ProcessEvent(vEventNav) )
if ( HandleWindowEvent(vEventNav) )
return;
}
break;
@@ -1095,7 +1095,7 @@ bool wxTextCtrl::OS2Command(
);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
}
break;

View File

@@ -790,7 +790,7 @@ bool wxTopLevelWindowOS2::Show( bool bShow )
::WinEnableWindow(m_hFrame, TRUE);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
}
else
{
@@ -965,7 +965,7 @@ bool wxTopLevelWindowOS2::ShowFullScreen( bool bShow,
wxSize full( nWidth, nHeight );
wxSizeEvent vEvent( full, GetId() );
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
return true;
}
else

View File

@@ -1591,7 +1591,7 @@ void wxTreeCtrl::Delete (
delete (wxTreeItemAttr *)m_vAttrs.Delete((long)rItem.m_pItem);
}
vEvent.SetEventType(vEventType);
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
} // end of wxTreeCtrl::Delete
// delete all children (but don't delete the item itself)
@@ -2058,7 +2058,7 @@ MRESULT wxTreeCtrl::OS2WindowProc (
break;
}
vEvent.SetEventType(vEventType);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
bProcessed = HandleWindowEvent(vEvent);
break;
}
if (!bProcessed)

View File

@@ -1082,7 +1082,7 @@ void wxWindowOS2::OnIdle(
,vPoint.y
,nState
);
(void)GetEventHandler()->ProcessEvent(rEvent);
(void)HandleWindowEvent(rEvent);
}
}
if (wxUpdateUIEvent::CanUpdate(this))
@@ -1620,7 +1620,7 @@ void wxWindowOS2::DoSetClientSize( int nWidth,
wxSize size( nWidth, nHeight );
wxSizeEvent vEvent( size, m_windowId );
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
HandleWindowEvent(vEvent);
} // end of wxWindowOS2::DoSetClientSize
// ---------------------------------------------------------------------------
@@ -2001,7 +2001,7 @@ bool wxWindowOS2::OS2ProcessMessage( WXMSG* pMsg )
vEvent.SetWindowChange(bWindowChange);
vEvent.SetEventObject(this);
if (GetEventHandler()->ProcessEvent(vEvent))
if (HandleWindowEvent(vEvent))
{
wxButton* pBtn = wxDynamicCast(FindFocus(), wxButton);
@@ -3027,7 +3027,7 @@ bool wxWindowOS2::HandleCreate( WXLPCREATESTRUCT WXUNUSED(vCs),
{
wxWindowCreateEvent vEvent((wxWindow*)this);
(void)GetEventHandler()->ProcessEvent(vEvent);
(void)HandleWindowEvent(vEvent);
*pbMayCreate = true;
return true;
} // end of wxWindowOS2::HandleCreate
@@ -3036,7 +3036,7 @@ bool wxWindowOS2::HandleDestroy()
{
wxWindowDestroyEvent vEvent((wxWindow*)this);
vEvent.SetId(GetId());
(void)GetEventHandler()->ProcessEvent(vEvent);
(void)HandleWindowEvent(vEvent);
//
// Delete our drop target if we've got one
@@ -3075,7 +3075,7 @@ bool wxWindowOS2::HandleActivate(
,m_windowId
);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleActivate
bool wxWindowOS2::HandleSetFocus( WXHWND WXUNUSED(hWnd) )
@@ -3085,7 +3085,7 @@ bool wxWindowOS2::HandleSetFocus( WXHWND WXUNUSED(hWnd) )
// purposes that we got it
//
wxChildFocusEvent vEventFocus((wxWindow *)this);
(void)GetEventHandler()->ProcessEvent(vEventFocus);
(void)HandleWindowEvent(vEventFocus);
#if wxUSE_CARET
//
@@ -3109,7 +3109,7 @@ bool wxWindowOS2::HandleSetFocus( WXHWND WXUNUSED(hWnd) )
wxFocusEvent vEvent(wxEVT_SET_FOCUS, m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleSetFocus
bool wxWindowOS2::HandleKillFocus( WXHWND hWnd )
@@ -3156,7 +3156,7 @@ bool wxWindowOS2::HandleKillFocus( WXHWND hWnd )
// wxFindWinFromHandle() may return NULL, it is ok
//
vEvent.SetWindow(wxFindWinFromHandle(hWnd));
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleKillFocus
// ---------------------------------------------------------------------------
@@ -3171,7 +3171,7 @@ bool wxWindowOS2::HandleShow(
wxShowEvent vEvent(GetId(), bShow);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleShow
bool wxWindowOS2::HandleInitDialog( WXHWND WXUNUSED(hWndFocus) )
@@ -3179,7 +3179,7 @@ bool wxWindowOS2::HandleInitDialog( WXHWND WXUNUSED(hWndFocus) )
wxInitDialogEvent vEvent(GetId());
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleInitDialog
bool wxWindowOS2::HandleEndDrag(WXWPARAM WXUNUSED(wParam))
@@ -3416,7 +3416,7 @@ bool wxWindowOS2::HandleSysColorChange()
wxSysColourChangedEvent vEvent;
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleSysColorChange
bool wxWindowOS2::HandleCtlColor( WXHBRUSH* WXUNUSED(phBrush) )
@@ -3449,7 +3449,7 @@ bool wxWindowOS2::HandlePaletteChanged()
vEvent.SetEventObject(this);
vEvent.SetChangedWindow(wxFindWinFromHandle(hWndPalChange));
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandlePaletteChanged
//
@@ -3473,7 +3473,7 @@ void wxWindowOS2::OnSysColourChanged(
wxSysColourChangedEvent vEvent;
rEvent.SetEventObject(pWin);
pWin->GetEventHandler()->ProcessEvent(vEvent);
pWin->HandleWindowEvent(vEvent);
}
node = node->GetNext();
}
@@ -3558,7 +3558,7 @@ bool wxWindowOS2::HandlePaint()
m_updateRegion = wxRegion(hRgn, hPS);
vEvent.SetEventObject(this);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
bProcessed = HandleWindowEvent(vEvent);
if (!bProcessed &&
IsKindOf(CLASSINFO(wxPanel)) &&
@@ -3681,7 +3681,7 @@ bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC )
vEvent.SetEventObject(this);
rc = GetEventHandler()->ProcessEvent(vEvent);
rc = HandleWindowEvent(vEvent);
vDC.m_hPS = NULLHANDLE;
return true;
@@ -3707,7 +3707,7 @@ bool wxWindowOS2::HandleMinimize()
wxIconizeEvent vEvent(m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleMinimize
bool wxWindowOS2::HandleMaximize()
@@ -3715,7 +3715,7 @@ bool wxWindowOS2::HandleMaximize()
wxMaximizeEvent vEvent(m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleMaximize
bool wxWindowOS2::HandleMove( int nX, int nY )
@@ -3724,7 +3724,7 @@ bool wxWindowOS2::HandleMove( int nX, int nY )
wxMoveEvent vEvent(pt, m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleMove
bool wxWindowOS2::HandleSize( int nWidth,
@@ -3735,7 +3735,7 @@ bool wxWindowOS2::HandleSize( int nWidth,
wxSizeEvent vEvent(sz, m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::HandleSize
bool wxWindowOS2::HandleGetMinMaxInfo( PSWP pSwp )
@@ -3880,7 +3880,7 @@ bool wxWindowOS2::HandleMouseEvent( WXUINT uMsg,
,uFlags
);
bProcessed = GetEventHandler()->ProcessEvent(vEvent);
bProcessed = HandleWindowEvent(vEvent);
if (!bProcessed)
{
HPOINTER hCursor = (HPOINTER)GetCursor().GetHCURSOR();
@@ -3914,7 +3914,7 @@ bool wxWindowOS2::HandleMouseMove( int nX,
,uFlags
);
(void)GetEventHandler()->ProcessEvent(vEvent);
(void)HandleWindowEvent(vEvent);
}
return HandleMouseEvent( WM_MOUSEMOVE
,nX
@@ -4036,7 +4036,7 @@ bool wxWindowOS2::HandleChar( WXWPARAM WXUNUSED(wParam),
vEvent.m_controlDown = true;
}
return (GetEventHandler()->ProcessEvent(vEvent));
return (HandleWindowEvent(vEvent));
}
bool wxWindowOS2::HandleKeyDown( WXWPARAM wParam,
@@ -4060,7 +4060,7 @@ bool wxWindowOS2::HandleKeyDown( WXWPARAM wParam,
,(MPARAM)wParam
));
if (GetEventHandler()->ProcessEvent(vEvent))
if (HandleWindowEvent(vEvent))
{
return true;
}
@@ -4089,7 +4089,7 @@ bool wxWindowOS2::HandleKeyUp( WXWPARAM wParam,
,(MPARAM)wParam
));
if (GetEventHandler()->ProcessEvent(vEvent))
if (HandleWindowEvent(vEvent))
return true;
}
return false;
@@ -4155,7 +4155,7 @@ bool wxWindowOS2::OS2OnScroll( int nOrientation,
default:
return false;
}
return GetEventHandler()->ProcessEvent(vEvent);
return HandleWindowEvent(vEvent);
} // end of wxWindowOS2::OS2OnScroll
//