extern wxList wxPendingDelete;
wxWindowMac* gFocusWindow = NULL ;
+#ifdef __WXUNIVERSAL__
+ IMPLEMENT_ABSTRACT_CLASS(wxWindowMac, wxWindowBase)
+#else // __WXMAC__
+ IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase)
+#endif // __WXUNIVERSAL__/__WXMAC__
+
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxWindowMac, wxEvtHandler)
-BEGIN_EVENT_TABLE(wxWindowMac, wxEvtHandler)
+
+BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
EVT_SYS_COLOUR_CHANGED(wxWindowMac::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindowMac::OnInitDialog)
}
#endif // wxUSE_CARET
// panel wants to track the window which was the last to have focus in it
- wxPanel *panel = wxDynamicCast(GetParent(), wxPanel);
- if ( panel )
- {
- panel->SetLastFocus((wxWindow*)this);
- }
+ wxChildFocusEvent eventFocus(this);
+ (void)GetEventHandler()->ProcessEvent(eventFocus);
+
#ifndef __WXUNIVERSAL__
wxControl* control = wxDynamicCast( gFocusWindow , wxControl ) ;
if ( control && control->GetMacControl() )
// Get total size
void wxWindowMac::DoGetSize(int *x, int *y) const
{
- *x = m_width ;
- *y = m_height ;
+ if(x) *x = m_width ;
+ if(y) *y = m_height ;
}
void wxWindowMac::DoGetPosition(int *x, int *y) const
{
- *x = m_x ;
- *y = m_y ;
+ int xx,yy;
+
+ xx = m_x ;
+ yy = m_y ;
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
- *x -= pt.x;
- *y -= pt.y;
+ xx -= pt.x;
+ yy -= pt.y;
}
+ if(x) *x = xx;
+ if(y) *y = yy;
}
#if wxUSE_MENUS
{
WindowRef window = GetMacRootWindow() ;
- Point localwhere ;
- localwhere.h = * x ;
- localwhere.v = * y ;
+ Point localwhere = {0,0} ;
+
+ if(x) localwhere.h = * x ;
+ if(y) localwhere.v = * y ;
GrafPtr port ;
::GetPort( &port ) ;
::GlobalToLocal( &localwhere ) ;
::SetPort( port ) ;
- *x = localwhere.h ;
- *y = localwhere.v ;
+ if(x) *x = localwhere.h ;
+ if(y) *y = localwhere.v ;
MacRootWindowToClient( x , y ) ;
}
MacClientToRootWindow( x , y ) ;
- Point localwhere ;
- localwhere.h = * x ;
- localwhere.v = * y ;
+ Point localwhere = { 0,0 };
+ if(x) localwhere.h = * x ;
+ if(y) localwhere.v = * y ;
GrafPtr port ;
::GetPort( &port ) ;
::SetOrigin( 0 , 0 ) ;
::LocalToGlobal( &localwhere ) ;
::SetPort( port ) ;
- *x = localwhere.h ;
- *y = localwhere.v ;
+ if(x) *x = localwhere.h ;
+ if(y) *y = localwhere.v ;
}
void wxWindowMac::MacClientToRootWindow( int *x , int *y ) const
{
- if ( m_macWindowData )
+ if ( m_macWindowData == NULL)
{
- }
- else
- {
- *x += m_x ;
- *y += m_y ;
+ if(x) *x += m_x ;
+ if(y) *y += m_y ;
GetParent()->MacClientToRootWindow( x , y ) ;
}
}
void wxWindowMac::MacRootWindowToClient( int *x , int *y ) const
{
- if ( m_macWindowData )
- {
- }
- else
+ if ( m_macWindowData == NULL)
{
- *x -= m_x ;
- *y -= m_y ;
+ if(x) *x -= m_x ;
+ if(y) *y -= m_y ;
GetParent()->MacRootWindowToClient( x , y ) ;
}
}
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindowMac::DoGetClientSize(int *x, int *y) const
{
- *x = m_width ;
- *y = m_height ;
+ int ww, hh;
+ ww = m_width ;
+ hh = m_height ;
- *x -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
- *y -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
+ ww -= MacGetLeftBorderSize( ) + MacGetRightBorderSize( ) ;
+ hh -= MacGetTopBorderSize( ) + MacGetBottomBorderSize( );
if ( (m_vScrollBar && m_vScrollBar->IsShown()) || (m_hScrollBar && m_hScrollBar->IsShown()) )
{
MacClientToRootWindow( &x1 , &y1 ) ;
MacClientToRootWindow( &w , &h ) ;
- WindowRef window = NULL ;
wxWindowMac *iter = (wxWindowMac*)this ;
int totW = 10000 , totH = 10000;
if (m_hScrollBar && m_hScrollBar->IsShown() )
{
- (*y) -= MAC_SCROLLBAR_SIZE;
+ hh -= MAC_SCROLLBAR_SIZE;
if ( h-y1 >= totH )
{
- (*y)+= 1 ;
+ hh += 1 ;
}
}
if (m_vScrollBar && m_vScrollBar->IsShown() )
{
- (*x) -= MAC_SCROLLBAR_SIZE;
+ ww -= MAC_SCROLLBAR_SIZE;
if ( w-x1 >= totW )
{
- (*x) += 1 ;
+ ww += 1 ;
}
}
}
+ if(x) *x = ww;
+ if(y) *y = hh;
}
void wxWindowMac::DoMoveWindow(int x, int y, int width, int height)
{
- DoSetSize( x,y, width, height ) ;
-}
-
-// set the size of the window: if the dimensions are positive, just use them,
-// but if any of them is equal to -1, it means that we must find the value for
-// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
-// which case -1 is a valid value for x and y)
-//
-// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
-// the width/height to best suit our contents, otherwise we reuse the current
-// width/height
-void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
-{
-
int former_x = m_x ;
int former_y = m_y ;
int former_w = m_width ;
int former_h = m_height ;
- int currentX, currentY;
- GetPosition(¤tX, ¤tY);
- int currentW,currentH;
- GetSize(¤tW, ¤tH);
-
int actualWidth = width;
int actualHeight = height;
int actualX = x;
int actualY = y;
- if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- actualX = currentX;
- if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- actualY = currentY;
-
- wxSize size( -1 , -1 ) ;
- if (width == -1 || height == -1 )
- {
- size = DoGetBestSize() ;
- }
-
- if ( width == -1 )
- {
- if ( sizeFlags & wxSIZE_AUTO_WIDTH )
- {
- actualWidth = size.x ;
- if ( actualWidth == -1 )
- actualWidth = 80 ;
- }
- else
- {
- actualWidth = currentW ;
- }
- }
- if (height == -1)
- {
- if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
- {
- actualHeight = size.y ;
- if ( actualHeight == -1 )
- actualHeight = 26 ;
- }
- else
- {
- actualHeight = currentH ;
- }
- }
-
if ((m_minWidth != -1) && (actualWidth < m_minWidth))
actualWidth = m_minWidth;
if ((m_minHeight != -1) && (actualHeight < m_minHeight))
actualWidth = m_maxWidth;
if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))
actualHeight = m_maxHeight;
- if ( actualX == currentX && actualY == currentY && actualWidth == currentW && actualHeight == currentH)
- {
- MacRepositionScrollBars() ; // we might have a real position shift
- return ;
- }
- AdjustForParentClientOrigin(actualX, actualY, sizeFlags);
-
-
bool doMove = false ;
bool doResize = false ;
}
if ( doResize )
{
- MacRepositionScrollBars() ;
- wxSize size(m_width, m_height);
- wxSizeEvent event(size, m_windowId);
- event.SetEventObject(this);
- GetEventHandler()->ProcessEvent(event);
+ MacRepositionScrollBars() ;
+ wxSize size(m_width, m_height);
+ wxSizeEvent event(size, m_windowId);
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
}
}
+
+}
+
+// set the size of the window: if the dimensions are positive, just use them,
+// but if any of them is equal to -1, it means that we must find the value for
+// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
+// which case -1 is a valid value for x and y)
+//
+// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
+// the width/height to best suit our contents, otherwise we reuse the current
+// width/height
+void wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ // get the current size and position...
+ int currentX, currentY;
+ GetPosition(¤tX, ¤tY);
+ int currentW,currentH;
+ GetSize(¤tW, ¤tH);
+
+ // ... and don't do anything (avoiding flicker) if it's already ok
+ if ( x == currentX && y == currentY &&
+ width == currentW && height == currentH )
+ {
+ MacRepositionScrollBars() ; // we might have a real position shift
+ return;
+ }
+
+ if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ x = currentX;
+ if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
+ y = currentY;
+
+ AdjustForParentClientOrigin(x, y, sizeFlags);
+
+ wxSize size(-1, -1);
+ if ( width == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
+ {
+ size = DoGetBestSize();
+ width = size.x;
+ }
+ else
+ {
+ // just take the current one
+ width = currentW;
+ }
+ }
+
+ if ( height == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
+ {
+ if ( size.x == -1 )
+ {
+ size = DoGetBestSize();
+ }
+ //else: already called DoGetBestSize() above
+
+ height = size.y;
+ }
+ else
+ {
+ // just take the current one
+ height = currentH;
+ }
+ }
+
+ DoMoveWindow(x, y, width, height);
+
}
// For implementation purposes - sometimes decorations make the client area
// smaller
{
WindowRef window = GetMacRootWindow() ;
wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
- if ( !win->m_isBeingDeleted )
+ if ( win && !win->m_isBeingDeleted )
Refresh() ;
}
else
// notice that it's also important to do it upwards the tree becaus
// otherwise when the top level panel gets focus, it won't set it back to
// us, but to some other sibling
- wxWindowMac *win = this;
- while ( win )
- {
- wxWindowMac *parent = win->GetParent();
- wxPanel *panel = wxDynamicCast(parent, wxPanel);
- if ( panel )
- {
- panel->SetLastFocus(win);
- }
-
- win = parent;
- }
+
+ // CS:don't know if this is still needed:
+ //wxChildFocusEvent eventFocus(this);
+ //(void)GetEventHandler()->ProcessEvent(eventFocus);
event.Skip();
}
void wxWindowMac::MacMouseUp( EventRecord *ev , short part)
{
- WindowPtr frontWindow ;
switch (part)
{
case inContent:
void wxWindowMac::MacMouseMoved( EventRecord *ev , short part)
{
- WindowPtr frontWindow ;
switch (part)
{
case inContent:
// ownUpdateRgn is the area that this window has to invalidate i.e. its own area without its children
RgnHandle ownUpdateRgn = NewRgn() ;
CopyRgn( updatergn , ownUpdateRgn ) ;
- wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
+
{
wxMacDrawingHelper focus( this ) ; // was client
if ( focus.Ok() )
WindowRef wxWindowMac::GetMacRootWindow() const
{
- WindowRef window = NULL ;
wxWindowMac *iter = (wxWindowMac*)this ;
while( iter )
MacClientToRootWindow( &x , &y ) ;
MacClientToRootWindow( &w , &h ) ;
- WindowRef window = NULL ;
wxWindowMac *iter = (wxWindowMac*)this ;
int totW = 10000 , totH = 10000;