// Destructor
wxWindowMac::~wxWindowMac()
{
+ SendDestroyEvent();
+
// deleting a window while it is shown invalidates the region
if ( IsShown() ) {
wxWindowMac* iter = this ;
{
s_lastMouseWindow = NULL ;
}
-
+
wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ;
if ( frame )
{
{
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindowMac without parent") );
+#if wxUSE_STATBOX
+ // wxGTK doesn't allow to create controls with static box as the parent so
+ // this will result in a crash when the program is ported to wxGTK - warn
+ // about it
+ //
+ // the correct solution is to create the controls as siblings of the
+ // static box
+ wxASSERT_MSG( !wxDynamicCast(parent, wxStaticBox),
+ _T("wxStaticBox can't be used as a window parent!") );
+#endif // wxUSE_STATBOX
+
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
return FALSE;
{
if (gFocusWindow )
{
- #if wxUSE_CARET
+#if wxUSE_CARET
// Deal with caret
if ( gFocusWindow->m_caret )
{
gFocusWindow->m_caret->OnKillFocus();
}
- #endif // wxUSE_CARET
- #ifndef __WXUNIVERSAL__
+#endif // wxUSE_CARET
+#ifndef __WXUNIVERSAL__
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
if ( control && control->GetMacControl() )
{
UMASetKeyboardFocus( (WindowRef) gFocusWindow->MacGetRootWindow() , (ControlHandle) control->GetMacControl() , kControlFocusNoPart ) ;
control->MacRedrawControl() ;
}
- #endif
- wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId);
- event.SetEventObject(gFocusWindow);
- gFocusWindow->GetEventHandler()->ProcessEvent(event) ;
+#endif
+ // Without testing the window id, for some reason
+ // a kill focus event can still be sent to
+ // the control just being focussed.
+ int thisId = this->m_windowId;
+ int gFocusWindowId = gFocusWindow->m_windowId;
+ if (gFocusWindowId != thisId)
+ {
+ wxFocusEvent event(wxEVT_KILL_FOCUS, gFocusWindow->m_windowId);
+ event.SetEventObject(gFocusWindow);
+ gFocusWindow->GetEventHandler()->ProcessEvent(event) ;
+ }
}
gFocusWindow = this ;
{
if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) )
{
- wxPoint oldPos( m_x , m_y ) ;
+ wxPoint oldPos( m_x , m_y ) ;
wxPoint newPos( actualX , actualY ) ;
MacWindowToRootWindow( &oldPos.x , &oldPos.y ) ;
MacWindowToRootWindow( &newPos.x , &newPos.y ) ;
if (child == m_vScrollBar) continue;
if (child == m_hScrollBar) continue;
if (child->IsTopLevel()) continue;
-
+
int x,y;
child->GetPosition( &x, &y );
int w,h;
static wxWindow *gs_lastWhich = NULL;
-bool wxWindowMac::MacSetupCursor( const wxPoint& pt)
+bool wxWindowMac::MacSetupCursor( const wxPoint& pt)
{
// first trigger a set cursor event
-
+
wxPoint clientorigin = GetClientAreaOrigin() ;
wxSize clientsize = GetClientSize() ;
wxCursor cursor ;
if ( wxRect2DInt( clientorigin.x , clientorigin.y , clientsize.x , clientsize.y ).Contains( wxPoint2DInt( pt ) ) )
- {
+ {
wxSetCursorEvent event( pt.x , pt.y );
bool processedEvtSetCursor = GetEventHandler()->ProcessEvent(event);
}
else
{
-
+
// the test for processedEvtSetCursor is here to prevent using m_cursor
// if the user code caught EVT_SET_CURSOR() and returned nothing from
// it - this is a way to say that our cursor shouldn't be used for this
parent->MacWindowToRootWindow( &x, &y ) ;
MacRootWindowToWindow( &x , &y ) ;
- SetRectRgn( tempRgn ,
- x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
- x + size.x - parent->MacGetRightBorderSize(),
+ SetRectRgn( tempRgn ,
+ x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
+ x + size.x - parent->MacGetRightBorderSize(),
y + size.y - parent->MacGetBottomBorderSize()) ;
SectRgn( visRgn , tempRgn , visRgn ) ;
if ( erase && !EmptyRgn(ownUpdateRgn) )
{
wxWindowDC dc(this);
- dc.SetClippingRegion(wxRegion(ownUpdateRgn));
+ if (!EmptyRgn(ownUpdateRgn))
+ dc.SetClippingRegion(wxRegion(ownUpdateRgn));
wxEraseEvent eevent( GetId(), &dc );
eevent.SetEventObject( this );
GetEventHandler()->ProcessEvent( eevent );