#include "wx/setup.h"
#include "wx/menu.h"
+#include "wx/window.h"
#include "wx/dc.h"
#include "wx/dcclient.h"
#include "wx/utils.h"
#include "wx/tabctrl.h"
#include "wx/tooltip.h"
#include "wx/statusbr.h"
-// TODO remove the line below, just for lookup-up convenience CS
-#include "wx/window.h"
-
#include "wx/menuitem.h"
#include "wx/log.h"
// constructors and such
// ----------------------------------------------------------------------------
+WindowRef wxWindow::s_macWindowInUpdate = NULL;
+
void wxWindow::Init()
{
// generic
InitBase();
+ m_macEraseOnRedraw = true ;
+
// MSW specific
m_doubleClickAllowed = 0;
m_winCaptured = FALSE;
m_isShown = TRUE;
m_macWindowData = NULL ;
+ m_macEraseOnRedraw = true ;
m_x = 0;
m_y = 0 ;
bool wxWindow::SetCursor(const wxCursor& cursor)
{
- if ( !wxWindowBase::SetCursor(cursor) )
- {
- // no change
+ if (m_cursor == cursor)
return FALSE;
- }
+
+ if (wxNullCursor == cursor)
+ {
+ if ( ! wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ) )
+ return FALSE ;
+ }
+ else
+ {
+ if ( ! wxWindowBase::SetCursor( cursor ) )
+ return FALSE ;
+ }
wxASSERT_MSG( m_cursor.Ok(),
wxT("cursor must be valid after call to the base version"));
{
if ( mouseWin == this && !wxIsBusy() )
{
- cursor.MacInstall() ;
+ m_cursor.MacInstall() ;
}
}
bool wxWindow::MacIsReallyShown() const
{
+ if ( m_isShown && (m_parent != NULL) ) {
+ return m_parent->MacIsReallyShown();
+ }
+ return m_isShown;
+/*
bool status = m_isShown ;
wxWindow * win = this ;
while ( status && win->m_parent != NULL )
status = win->m_isShown ;
}
return status ;
+*/
}
int wxWindow::GetCharHeight() const
wxClientDC dc( (wxWindow*) this ) ;
long lx,ly,ld,le ;
- dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
if ( externalLeading )
*externalLeading = le ;
if ( descent )
void wxWindow::MacEraseBackground( Rect *rect )
{
+/*
WindowRef window = GetMacRootWindow() ;
if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
{
}
}
}
+*/
}
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
}
InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
}
+ if ( !eraseBack )
+ m_macEraseOnRedraw = false ;
+ else
+ m_macEraseOnRedraw = true ;
}
// Responds to colour changes: passes event on to children.
{
wclass = kMovableModalWindowClass ;
}
- else if ( HasFlag( wxDIALOG_MODELESS ) )
+ else
{
wclass = kDocumentWindowClass ;
}
- /*
- else
- {
- if ( HasFlag( wxCAPTION ) )
- {
- wclass = kDocumentWindowClass ;
- }
- else
- {
- wclass = kModalWindowClass ;
- }
- }
- */
}
else
{
}
void wxWindow::MacActivate( EventRecord *ev , bool inIsActivating )
{
- wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating);
+ wxActivateEvent event(wxEVT_ACTIVATE, inIsActivating , m_windowId);
event.m_timeStamp = ev->when ;
event.SetEventObject(this);
{
// updatergn is always already clipped to our boundaries
WindowRef window = GetMacRootWindow() ;
+ // ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children
+ RgnHandle ownUpdateRgn = NewRgn() ;
+ CopyRgn( updatergn , ownUpdateRgn ) ;
wxWindow* win = wxFindWinFromMacWindow( window ) ;
{
wxMacDrawingHelper focus( this ) ; // was client
{
RGBBackColor( &m_backgroundColour.GetPixel()) ;
}
+ // subtract all non transparent children from updatergn
+
+ RgnHandle childarea = NewRgn() ;
+ for (wxNode *node = GetChildren().First(); node; node = node->Next())
+ {
+ wxWindow *child = (wxWindow*)node->Data();
+ // eventually test for transparent windows
+ if ( child->GetMacRootWindow() == window && child->IsShown() )
+ {
+ if ( !child->IsKindOf( CLASSINFO( wxNotebook ) ) && !child->IsKindOf( CLASSINFO( wxTabCtrl ) ) )
+ {
+ SetRectRgn( childarea , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
+ DiffRgn( ownUpdateRgn , childarea , ownUpdateRgn ) ;
+ }
+ }
+ }
+ DisposeRgn( childarea ) ;
+
if ( GetParent() && m_backgroundColour != GetParent()->GetBackgroundColour() )
eraseBackground = true ;
SetClip( updatergn ) ;
- if ( eraseBackground )
- {
- EraseRgn( updatergn ) ;
- }
+ if ( m_macEraseOnRedraw ) {
+ if ( eraseBackground )
+ {
+ EraseRgn( ownUpdateRgn ) ;
+ }
+ }
+ else {
+ m_macEraseOnRedraw = true ;
+ }
}
- m_macUpdateRgn = updatergn ;
{
RgnHandle newupdate = NewRgn() ;
wxSize point = GetClientSize() ;
wxPoint origin = GetClientAreaOrigin() ;
SetRectRgn( newupdate , origin.x , origin.y , origin.x + point.x , origin.y+point.y ) ;
- SectRgn( newupdate , m_macUpdateRgn , newupdate ) ;
+ SectRgn( newupdate , ownUpdateRgn , newupdate ) ;
OffsetRgn( newupdate , -origin.x , -origin.y ) ;
m_updateRegion = newupdate ;
DisposeRgn( newupdate ) ;
{
wxWindow *child = (wxWindow*)node->Data();
SetRectRgn( childupdate , child->m_x , child->m_y , child->m_x + child->m_width , child->m_y + child->m_height ) ;
- SectRgn( childupdate , m_macUpdateRgn , childupdate ) ;
+ SectRgn( childupdate , updatergn , childupdate ) ;
OffsetRgn( childupdate , -child->m_x , -child->m_y ) ;
if ( child->GetMacRootWindow() == window && child->IsShown() && !EmptyRgn( childupdate ) )
{
Rect portRect ;
GetPortBounds( m_currentPort , &portRect ) ;
ClipRect( &portRect ) ;
- wxDC::MacInvalidateSetup() ;
}
if ( m_formerPort != m_currentPort )