#include "wx/menuitem.h"
#include "wx/spinctrl.h"
#include "wx/log.h"
+#include "wx/geometry.h"
#if wxUSE_CARET
#include "wx/caret.h"
{
s_lastMouseWindow = NULL ;
}
+
+ wxFrame* frame = wxDynamicCast( wxGetTopLevelParent( this ) , wxFrame ) ;
+ if ( frame )
+ {
+ if ( frame->GetLastFocus() == this )
+ frame->SetLastFocus( NULL ) ;
+ }
if ( gFocusWindow == this )
{
::InsertMenu( (MenuHandle) menu->GetHMenu() , -1 ) ;
long menuResult = ::PopUpMenuSelect((MenuHandle) menu->GetHMenu() ,y,x, 0) ;
- menu->MacMenuSelect( this , TickCount() , HiWord(menuResult) , LoWord(menuResult) ) ;
+ if ( HiWord(menuResult) != 0 )
+ {
+ MenuCommand id ;
+ GetMenuItemCommandID( GetMenuHandle(HiWord(menuResult)) , LoWord(menuResult) , &id ) ;
+
+ wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id );
+ event.m_timeStamp = TickCount() ;
+ event.SetEventObject(this->GetEventHandler());
+ event.SetInt( id );
+ GetEventHandler()->ProcessEvent(event);
+ }
::DeleteMenu( menu->MacGetMenuId() ) ;
menu->SetInvokingWindow(NULL);
MacRootWindowToWindow( x , y ) ;
if ( x )
- x -= MacGetLeftBorderSize() ;
+ *x -= MacGetLeftBorderSize() ;
if ( y )
- y -= MacGetTopBorderSize() ;
+ *y -= MacGetTopBorderSize() ;
}
void wxWindowMac::DoClientToScreen(int *x, int *y) const
WindowRef window = (WindowRef) MacGetRootWindow() ;
if ( x )
- x += MacGetLeftBorderSize() ;
+ *x += MacGetLeftBorderSize() ;
if ( y )
- y += MacGetTopBorderSize() ;
+ *y += MacGetTopBorderSize() ;
MacWindowToRootWindow( x , y ) ;
{
// erase former position
- Refresh() ;
+ bool partialRepaint = false ;
+
+ if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) )
+ {
+ wxPoint oldPos( m_x , m_y ) ;
+ wxPoint newPos( actualX , actualY ) ;
+ MacWindowToRootWindow( &oldPos.x , &oldPos.y ) ;
+ MacWindowToRootWindow( &newPos.x , &newPos.y ) ;
+ if ( oldPos == newPos )
+ {
+ partialRepaint = true ;
+ RgnHandle oldRgn,newRgn,diffRgn ;
+ oldRgn = NewRgn() ;
+ newRgn = NewRgn() ;
+ diffRgn = NewRgn() ;
+ SetRectRgn(oldRgn , oldPos.x , oldPos.y , oldPos.x + m_width , oldPos.y + m_height ) ;
+ SetRectRgn(newRgn , newPos.x , newPos.y , newPos.x + actualWidth , newPos.y + actualHeight ) ;
+ DiffRgn( newRgn , oldRgn , diffRgn ) ;
+ InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
+ DiffRgn( oldRgn , newRgn , diffRgn ) ;
+ InvalWindowRgn( (WindowRef) MacGetRootWindow() , diffRgn ) ;
+ DisposeRgn(oldRgn) ;
+ DisposeRgn(newRgn) ;
+ DisposeRgn(diffRgn) ;
+ }
+ }
+
+ if ( !partialRepaint )
+ Refresh() ;
m_x = actualX ;
m_y = actualY ;
m_width = actualWidth ;
m_height = actualHeight ;
+ // update any low-level frame-relative positions
+
+ MacUpdateDimensions() ;
// erase new position
- Refresh() ;
+ if ( !partialRepaint )
+ Refresh() ;
if ( doMove )
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
if (child == m_vScrollBar) continue;
if (child == m_hScrollBar) continue;
if (child->IsTopLevel()) continue;
+
int x,y;
child->GetPosition( &x, &y );
int w,h;
return FALSE ;
}
-extern int wxBusyCursorCount ;
static wxWindow *gs_lastWhich = NULL;
+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);
+ if ( processedEvtSetCursor && event.HasCursor() )
+ {
+ cursor = event.GetCursor() ;
+ }
+ 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
+ // point
+ if ( !processedEvtSetCursor && m_cursor.Ok() )
+ {
+ cursor = m_cursor ;
+ }
+ if ( wxIsBusy() )
+ {
+ }
+ else
+ {
+ if ( !GetParent() )
+ cursor = *wxSTANDARD_CURSOR ;
+ }
+ }
+ if ( cursor.Ok() )
+ cursor.MacInstall() ;
+ }
+ return cursor.Ok() ;
+}
+
bool wxWindowMac::MacDispatchMouseEvent(wxMouseEvent& event)
{
if ((event.m_x < m_x) || (event.m_y < m_y) ||
return FALSE;
- if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) || IsKindOf( CLASSINFO( wxSpinCtrl ) ))
+ if ( IsKindOf( CLASSINFO ( wxStaticBox ) ) /* || IsKindOf( CLASSINFO( wxSpinCtrl ) ) */)
return FALSE ;
WindowRef window = (WindowRef) MacGetRootWindow() ;
}
}
- event.m_x = x ;
- event.m_y = y ;
- event.SetEventObject( this ) ;
+ wxWindow* cursorTarget = this ;
+ wxPoint cursorPoint( x , y ) ;
- if ( wxBusyCursorCount == 0 )
+ while( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
{
- m_cursor.MacInstall() ;
+ cursorTarget = cursorTarget->GetParent() ;
+ if ( cursorTarget )
+ cursorPoint += cursorTarget->GetPosition() ;
}
+ event.m_x = x ;
+ event.m_y = y ;
+ event.SetEventObject( this ) ;
if ( event.GetEventType() == wxEVT_LEFT_DOWN )
{
return win ;
}
-const wxRegion& wxWindowMac::MacGetVisibleRegion()
+const wxRegion& wxWindowMac::MacGetVisibleRegion( bool respectChildrenAndSiblings )
{
RgnHandle visRgn = NewRgn() ;
RgnHandle tempRgn = NewRgn() ;
+ RgnHandle tempStaticBoxRgn = NewRgn() ;
SetRectRgn( visRgn , 0 , 0 , m_width , m_height ) ;
int borderTop = 14 ;
int borderOther = 4 ;
- SetRectRgn( tempRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ;
- DiffRgn( visRgn , tempRgn , visRgn ) ;
+ SetRectRgn( tempStaticBoxRgn , borderOther , borderTop , m_width - borderOther , m_height - borderOther ) ;
+ DiffRgn( visRgn , tempStaticBoxRgn , visRgn ) ;
}
if ( !IsTopLevel() )
x = y = 0 ;
parent->MacWindowToRootWindow( &x, &y ) ;
MacRootWindowToWindow( &x , &y ) ;
- SetRectRgn( tempRgn , x , y , x + size.x , y + size.y ) ;
+
+ SetRectRgn( tempRgn ,
+ x + parent->MacGetLeftBorderSize() , y + parent->MacGetTopBorderSize() ,
+ x + size.x - parent->MacGetRightBorderSize(),
+ y + size.y - parent->MacGetBottomBorderSize()) ;
+
SectRgn( visRgn , tempRgn , visRgn ) ;
if ( parent->IsTopLevel() )
break ;
parent = parent->GetParent() ;
}
}
- if ( GetWindowStyle() & wxCLIP_CHILDREN )
+ if ( respectChildrenAndSiblings )
{
- for (wxNode *node = GetChildren().First(); node; node = node->Next())
- {
- wxWindowMac *child = (wxWindowMac*)node->Data();
-
- if ( !child->IsTopLevel() && child->IsShown() )
+ if ( GetWindowStyle() & wxCLIP_CHILDREN )
+ {
+ for (wxNode *node = GetChildren().First(); node; node = node->Next())
{
- SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
- DiffRgn( visRgn , tempRgn , visRgn ) ;
- }
- }
- }
+ wxWindowMac *child = (wxWindowMac*)node->Data();
- if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() )
- {
- bool thisWindowThrough = false ;
- for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next())
- {
- wxWindowMac *sibling = (wxWindowMac*)node->Data();
- if ( sibling == this )
- {
- thisWindowThrough = true ;
- continue ;
- }
- if( !thisWindowThrough )
- {
- continue ;
+ if ( !child->IsTopLevel() && child->IsShown() )
+ {
+ SetRectRgn( tempRgn , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
+ if ( child->IsKindOf( CLASSINFO( wxStaticBox ) ) )
+ {
+ int borderTop = 14 ;
+ int borderOther = 4 ;
+
+ SetRectRgn( tempStaticBoxRgn , child->m_x + borderOther , child->m_y + borderTop , child->m_x + child->m_width - borderOther , child->m_y + child->m_height - borderOther ) ;
+ DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
+ }
+ DiffRgn( visRgn , tempRgn , visRgn ) ;
+ }
}
+ }
- if ( !sibling->IsTopLevel() && sibling->IsShown() )
+ if ( (GetWindowStyle() & wxCLIP_SIBLINGS) && GetParent() )
+ {
+ bool thisWindowThrough = false ;
+ for (wxNode *node = GetParent()->GetChildren().First(); node; node = node->Next())
{
- SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ;
- DiffRgn( visRgn , tempRgn , visRgn ) ;
+ wxWindowMac *sibling = (wxWindowMac*)node->Data();
+ if ( sibling == this )
+ {
+ thisWindowThrough = true ;
+ continue ;
+ }
+ if( !thisWindowThrough )
+ {
+ continue ;
+ }
+
+ if ( !sibling->IsTopLevel() && sibling->IsShown() )
+ {
+ SetRectRgn( tempRgn , sibling->m_x - m_x , sibling->m_y - m_y , sibling->m_x + sibling->m_width - m_x , sibling->m_y + sibling->m_height - m_y ) ;
+ if ( sibling->IsKindOf( CLASSINFO( wxStaticBox ) ) )
+ {
+ int borderTop = 14 ;
+ int borderOther = 4 ;
+
+ SetRectRgn( tempStaticBoxRgn , sibling->m_x - m_x + borderOther , sibling->m_y - m_y + borderTop , sibling->m_x + sibling->m_width - m_x - borderOther , sibling->m_y + sibling->m_height - m_y - borderOther ) ;
+ DiffRgn( tempRgn , tempStaticBoxRgn , tempRgn ) ;
+ }
+ DiffRgn( visRgn , tempRgn , visRgn ) ;
+ }
}
- }
+ }
}
m_macVisibleRegion = visRgn ;
DisposeRgn( visRgn ) ;
DisposeRgn( tempRgn ) ;
+ DisposeRgn( tempStaticBoxRgn ) ;
return m_macVisibleRegion ;
}