void wxWindowMac::Init()
{
- // generic
- InitBase();
-
- m_isBeingDeleted = FALSE;
m_backgroundTransparent = FALSE;
// as all windows are created with WS_VISIBLE style...
m_hScrollBar = NULL ;
m_vScrollBar = NULL ;
-
- m_label = wxEmptyString;
}
// Destructor
gFocusWindow = NULL ;
}
- // CS: copied from MSW :
- // VS: destroy children first and _then_ detach *this from its parent.
- // If we'd do it the other way around, children wouldn't be able
- // find their parent frame (see above).
DestroyChildren();
- if ( m_parent )
- m_parent->RemoveChild(this);
-
// delete our drop target if we've got one
#if wxUSE_DRAG_AND_DROP
if ( m_dropTarget != NULL )
bool partialRepaint = false ;
- if ( HasFlag(wxNO_FULL_REPAINT_ON_RESIZE) )
+ if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) )
{
wxPoint oldPos( m_x , m_y ) ;
wxPoint newPos( actualX , actualY ) ;
}
}
-#if wxUSE_CARET && WXWIN_COMPATIBILITY
-// ---------------------------------------------------------------------------
-// Caret manipulation
-// ---------------------------------------------------------------------------
-
-void wxWindowMac::CreateCaret(int w, int h)
-{
- SetCaret(new wxCaret(this, w, h));
-}
-
-void wxWindowMac::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
-{
- wxFAIL_MSG("not implemented");
-}
-
-void wxWindowMac::ShowCaret(bool show)
-{
- wxCHECK_RET( m_caret, "no caret to show" );
-
- m_caret->Show(show);
-}
-
-void wxWindowMac::DestroyCaret()
-{
- SetCaret(NULL);
-}
-
-void wxWindowMac::SetCaretPos(int x, int y)
-{
- wxCHECK_RET( m_caret, "no caret to move" );
-
- m_caret->Move(x, y);
-}
-
-void wxWindowMac::GetCaretPos(int *x, int *y) const
-{
- wxCHECK_RET( m_caret, "no caret to get position of" );
-
- m_caret->GetPosition(x, y);
-}
-#endif // wxUSE_CARET
-
wxWindowMac *wxGetActiveWindow()
{
// actually this is a windows-only concept
// Does a physical scroll
void wxWindowMac::ScrollWindow(int dx, int dy, const wxRect *rect)
{
- wxClientDC dc(this) ;
- wxMacPortSetter helper(&dc) ;
+ if( dx == 0 && dy ==0 )
+ return ;
+
{
+ wxClientDC dc(this) ;
+ wxMacPortSetter helper(&dc) ;
+
int width , height ;
GetClientSize( &width , &height ) ;
SectRect( &scrollrect , &r , &scrollrect ) ;
}
ScrollRect( &scrollrect , dx , dy , updateRgn ) ;
- InvalWindowRgn( (WindowRef) MacGetRootWindow() , updateRgn ) ;
+ // we also have to scroll the update rgn in this rectangle
+ // in order not to loose updates
+ WindowRef rootWindow = (WindowRef) MacGetRootWindow() ;
+ RgnHandle formerUpdateRgn = NewRgn() ;
+ RgnHandle scrollRgn = NewRgn() ;
+ RectRgn( scrollRgn , &scrollrect ) ;
+ GetWindowUpdateRgn( rootWindow , formerUpdateRgn ) ;
+ Point pt = {0,0} ;
+ LocalToGlobal( &pt ) ;
+ OffsetRgn( formerUpdateRgn , -pt.h , -pt.v ) ;
+ SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
+ if ( !EmptyRgn( formerUpdateRgn ) )
+ {
+ MacOffsetRgn( formerUpdateRgn , dx , dy ) ;
+ SectRgn( formerUpdateRgn , scrollRgn , formerUpdateRgn ) ;
+ InvalWindowRgn(rootWindow , formerUpdateRgn ) ;
+ }
+ InvalWindowRgn(rootWindow , updateRgn ) ;
DisposeRgn( updateRgn ) ;
+ DisposeRgn( formerUpdateRgn ) ;
+ DisposeRgn( scrollRgn ) ;
}
for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
child->GetSize( &w, &h );
child->SetSize( x+dx, y+dy, w, h );
}
+
+ Update() ;
}
return gFocusWindow ;
}
-#if WXWIN_COMPATIBILITY
-// If nothing defined for this, try the parent.
-// E.g. we may be a button loaded from a resource, with no callback function
-// defined.
-void wxWindowMac::OnCommand(wxWindowMac& win, wxCommandEvent& event)
-{
- if ( GetEventHandler()->ProcessEvent(event) )
- return;
- if ( m_parent )
- m_parent->GetEventHandler()->OnCommand(win, event);
-}
-#endif // WXWIN_COMPATIBILITY_2
-
-#if WXWIN_COMPATIBILITY
-wxObject* wxWindowMac::GetChild(int number) const
-{
- // Return a pointer to the Nth object in the Panel
- wxNode *node = GetChildren().GetFirst();
- int n = number;
- while (node && n--)
- node = node->GetNext();
- if ( node )
- {
- wxObject *obj = (wxObject *)node->GetData();
- return(obj);
- }
- else
- return NULL;
-}
-#endif // WXWIN_COMPATIBILITY
-
void wxWindowMac::OnSetFocus(wxFocusEvent& event)
{
// panel wants to track the window which was the last to have focus in it,
void wxWindowMac::Update()
{
- wxTopLevelWindowMac* win = MacGetTopLevelWindow( ) ;
- if ( win )
- {
- win->MacUpdate( 0 ) ;
+ wxRegion visRgn = MacGetVisibleRegion( false ) ;
+ int top = 0 , left = 0 ;
+ MacWindowToRootWindow( &left , &top ) ;
+ WindowRef rootWindow = (WindowRef) MacGetRootWindow() ;
+ RgnHandle updateRgn = NewRgn() ;
+ // getting the update region in macos local coordinates
+ GetWindowUpdateRgn( rootWindow , updateRgn ) ;
+ GrafPtr port ;
+ ::GetPort( &port ) ;
+ ::SetPort( UMAGetWindowPort( rootWindow ) ) ;
+ Point pt = {0,0} ;
+ LocalToGlobal( &pt ) ;
+ ::SetPort( port ) ;
+ OffsetRgn( updateRgn , -pt.h , -pt.v ) ;
+ // translate to window local coordinates
+ OffsetRgn( updateRgn , -left , -top ) ;
+ SectRgn( updateRgn , (RgnHandle) visRgn.GetWXHRGN() , updateRgn ) ;
+ MacRedraw( updateRgn , 0 , true ) ;
+ // for flushing and validating we need macos-local coordinates again
+ OffsetRgn( updateRgn , left , top ) ;
#if TARGET_API_MAC_CARBON
- if ( QDIsPortBuffered( GetWindowPort( (WindowRef) win->MacGetWindowRef() ) ) )
- {
- QDFlushPortBuffer( GetWindowPort( (WindowRef) win->MacGetWindowRef() ) , NULL ) ;
- }
+ if ( QDIsPortBuffered( GetWindowPort( rootWindow ) ) )
+ {
+ QDFlushPortBuffer( GetWindowPort( rootWindow ) , updateRgn ) ;
+ }
#endif
- }
+ ValidWindowRgn( rootWindow , updateRgn ) ;
+ DisposeRgn( updateRgn ) ;
}
wxTopLevelWindowMac* wxWindowMac::MacGetTopLevelWindow() const
DisposeRgn( ownUpdateRgn ) ;
if ( !m_updateRegion.Empty() )
{
+ wxWindowList hiddenWindows ;
+ for (wxWindowListNode *node = GetChildren().GetFirst(); node; node = node->GetNext())
+ {
+ wxControl *child = wxDynamicCast( ( wxWindow*)node->GetData() , wxControl ) ;
+
+ if ( child && child->MacGetRootWindow() == window && child->IsShown() && child->GetMacControl() )
+ {
+ SetControlVisibility( (ControlHandle) child->GetMacControl() , false , false ) ;
+ hiddenWindows.Append( child ) ;
+ }
+ }
+
wxPaintEvent event;
event.m_timeStamp = time ;
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
+
+ for (wxWindowListNode *node = hiddenWindows.GetFirst(); node; node = node->GetNext())
+ {
+ wxControl *child = wxDynamicCast( ( wxWindow*)node->GetData() , wxControl ) ;
+
+ if ( child && child->GetMacControl() )
+ {
+ SetControlVisibility( (ControlHandle) child->GetMacControl() , true , false ) ;
+ }
+ }
}
}