#endif
BEGIN_EVENT_TABLE(wxWindowMac, wxWindowBase)
- EVT_NC_PAINT(wxWindowMac::OnNcPaint)
- EVT_ERASE_BACKGROUND(wxWindowMac::OnEraseBackground)
EVT_MOUSE_EVENTS(wxWindowMac::OnMouseEvent)
END_EVENT_TABLE()
return NULL;
}
-//
-// TODO END move to window_osx.cpp
-//
-
// ---------------------------------------------------------------------------
// Utility Routines to move between different coordinate systems
// ---------------------------------------------------------------------------
return true ;
}
+static bool wxIsWindowOrParentDisabled(wxWindow* w)
+{
+ while (w && !w->IsTopLevel())
+ {
+ if (!w->IsEnabled())
+ return true;
+ w = w->GetParent();
+ }
+ return false;
+}
+
void wxWindowMac::SetFocus()
{
if ( !AcceptsFocus() )
return ;
+ if (wxIsWindowOrParentDisabled((wxWindow*) this))
+ return;
+
wxWindow* former = FindFocus() ;
if ( former == this )
return ;
x = (int)pos.x;
y = (int)pos.y;
- w = WidthDefault( size.x );
- h = HeightDefault( size.y );
+ w = WidthDefault( size.x );
+ h = HeightDefault( size.y );
x += MacGetLeftBorderSize() ;
y += MacGetTopBorderSize() ;
void wxWindowMac::DoGetPosition(int *x, int *y) const
{
int x1, y1;
-
+
m_peer->GetPosition( x1, y1 ) ;
// get the wx window position from the native one
int innerwidth, innerheight;
int left, top;
int outerwidth, outerheight;
-
+
m_peer->GetContentArea( left, top, innerwidth, innerheight );
m_peer->GetSize( outerwidth, outerheight );
-
+
sizeTotal.x += outerwidth-innerwidth;
sizeTotal.y += outerheight-innerheight;
-
+
sizeTotal.x += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
sizeTotal.y += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
int ww, hh;
int left, top;
-
+
m_peer->GetContentArea( left, top, ww, hh );
if (m_hScrollBar && m_hScrollBar->IsShown() )
// now we know that we have something to do at all
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
wxRect rightupdate( tx+tw, ty, outerBorder, th );
wxRect topupdate( tx-outerBorder, ty-outerBorder, tw + 2 * outerBorder, outerBorder );
wxRect bottomupdate( tx-outerBorder, ty + th, tw + 2 * outerBorder, outerBorder );
-
+
if (GetParent()) {
GetParent()->m_peer->SetNeedsDisplay(&leftupdate);
GetParent()->m_peer->SetNeedsDisplay(&rightupdate);
int actualX = x;
int actualY = y;
+#if 0
+ // min and max sizes are only for sizers, not for explicit size setting
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;
+#endif
bool doMove = false, doResize = false ;
MacInvalidateBorders() ;
m_cachedClippedRectValid = false ;
-
+
m_peer->Move( bounds.x, bounds.y, bounds.width, bounds.height);
wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified
else
{
wxRect r ;
-
+
m_peer->GetBestRect(&r);
if ( r.GetWidth() == 0 && r.GetHeight() == 0 )
}
}
- int bestWidth = r.width + MacGetLeftBorderSize() +
+ int bestWidth = r.width + MacGetLeftBorderSize() +
MacGetRightBorderSize();
- int bestHeight = r.height + MacGetTopBorderSize() +
+ int bestHeight = r.height + MacGetTopBorderSize() +
MacGetBottomBorderSize();
if ( bestHeight < 10 )
bestHeight = 13 ;
void wxWindowMac::SetLabel(const wxString& title)
{
+ if ( title == m_label )
+ return;
+
m_label = title ;
- if ( m_peer && m_peer->IsOk() && !(IsKindOf( CLASSINFO(wxButton) ) && GetId() == wxID_HELP) )
+ InvalidateBestSize();
+
+ if ( m_peer && m_peer->IsOk() )
m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
// do not trigger refreshes upon invisible and possible partly created objects
return width;
}
-void wxWindowMac::GetTextExtent(const wxString& str, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont ) const
+void wxWindowMac::DoGetTextExtent(const wxString& str,
+ int *x, int *y,
+ int *descent,
+ int *externalLeading,
+ const wxFont *theFont) const
{
const wxFont *fontToUse = theFont;
wxFont tempFont;
wxDouble h , d , e , w;
ctx->GetTextExtent( str, &w, &h, &d, &e );
-
+
delete ctx;
-
+
if ( externalLeading )
*externalLeading = (wxCoord)(e+0.5);
if ( descent )
if ( !IsShownOnScreen() )
return ;
-
+
m_peer->SetNeedsDisplay( rect ) ;
}
// We really don't move the mouse programmatically under Mac.
}
-void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
-{
- if ( MacGetTopLevelWindow() == NULL )
- return ;
-/*
-#if TARGET_API_MAC_OSX
- if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
- {
- }
- else
-#endif
-*/
- if ( GetBackgroundStyle() == wxBG_STYLE_COLOUR )
- {
- event.GetDC()->Clear() ;
- }
- else if ( GetBackgroundStyle() == wxBG_STYLE_CUSTOM )
- {
- // don't skip the event here, custom background means that the app
- // is drawing it itself in its OnPaint(), so don't draw it at all
- // now to avoid flicker
- }
- else
- {
- event.Skip() ;
- }
-}
-
-void wxWindowMac::OnNcPaint( wxNcPaintEvent& event )
-{
- event.Skip() ;
-}
-
int wxWindowMac::GetScrollPos(int orient) const
{
if ( orient == wxHORIZONTAL )
wxASSERT( cgContext ) ;
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
// back to the surrounding frame rectangle
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
}
}
-
+
if ( hasFocus )
{
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
}
}
-// Get the window with the focus
wxWindow *wxWindowBase::DoFindFocus()
{
-#if wxOSX_USE_CARBON
- ControlRef control ;
- GetKeyboardFocus( GetUserFocusWindow() , &control ) ;
- return wxFindWindowFromWXWidget( (WXWidget) control ) ;
-#else
- return NULL;
-#endif
+ return wxFindWindowFromWXWidget(wxWidgetImpl::FindFocus());
}
void wxWindowMac::OnInternalIdle()
Rect rIncludingOuterStructures ;
int tx,ty,tw,th;
-
+
m_peer->GetSize( tw, th );
m_peer->GetPosition( tx, ty );
bool wxWindowMac::MacDoRedraw( long time )
{
bool handled = false ;
-
+
wxRegion formerUpdateRgn = m_updateRegion;
wxRegion clientUpdateRgn = formerUpdateRgn;
- wxSize sz = GetClientSize() ;
- wxPoint origin = GetClientAreaOrigin() ;
-
- clientUpdateRgn.Intersect(origin.x , origin.y , origin.x + sz.x , origin.y + sz.y);
-
+ const wxRect clientRect = GetClientRect();
+
+ clientUpdateRgn.Intersect(clientRect);
+
// first send an erase event to the entire update area
+ const wxBackgroundStyle bgStyle = GetBackgroundStyle();
+ switch ( bgStyle )
{
- // for the toplevel window this really is the entire area
- // for all the others only their client area, otherwise they
- // might be drawing with full alpha and eg put blue into
- // the grow-box area of a scrolled window (scroll sample)
- wxDC* dc = new wxWindowDC(this);
- if ( IsTopLevel() )
- dc->SetDeviceClippingRegion(formerUpdateRgn);
- else
- dc->SetDeviceClippingRegion(clientUpdateRgn);
+ case wxBG_STYLE_ERASE:
+ case wxBG_STYLE_SYSTEM:
+ {
+ // for the toplevel window this really is the entire area for
+ // all the others only their client area, otherwise they might
+ // be drawing with full alpha and eg put blue into the grow-box
+ // area of a scrolled window (scroll sample)
+ wxWindowDC dc(this);
+ if ( IsTopLevel() )
+ dc.SetDeviceClippingRegion(formerUpdateRgn);
+ else
+ dc.SetDeviceClippingRegion(clientUpdateRgn);
+
+ if ( bgStyle == wxBG_STYLE_ERASE )
+ {
+ wxEraseEvent eevent( GetId(), &dc );
+ eevent.SetEventObject( this );
+ if ( ProcessWindowEvent( eevent ) )
+ break;
+ }
- wxEraseEvent eevent( GetId(), dc );
- eevent.SetEventObject( this );
- HandleWindowEvent( eevent );
- delete dc ;
+ if ( UseBgCol() )
+ {
+ dc.SetBackground(GetBackgroundColour());
+ dc.Clear();
+ }
+ }
+ break;
+
+ case wxBG_STYLE_PAINT:
+ // nothing to do, user-defined EVT_PAINT handler will overwrite the
+ // entire window client area
+ break;
+
+ default:
+ wxFAIL_MSG( "unsupported background style" );
}
MacPaintGrowBox();
- // calculate a client-origin version of the update rgn and set m_updateRegion to that
- clientUpdateRgn.Offset( -origin.x , -origin.y );
+ // calculate a client-origin version of the update rgn and set
+ // m_updateRegion to that
+ clientUpdateRgn.Offset(-clientRect.GetPosition());
m_updateRegion = clientUpdateRgn ;
if ( !m_updateRegion.Empty() )
child->GetPosition( &x, &y );
child->GetSize( &w, &h );
-
+
if ( m_updateRegion.Contains(clientOrigin.x+x-10, clientOrigin.y+y-10, w+20, h+20) )
{
// paint custom borders
WXWindow wxWindowMac::MacGetTopLevelWindowRef() const
{
- wxNonOwnedWindow* tlw = MacGetTopLevelWindow();
+ wxNonOwnedWindow* tlw = MacGetTopLevelWindow();
return tlw ? tlw->GetWXWindow() : NULL ;
}
bool wxWindowMac::AcceptsFocus() const
{
- return m_peer->CanFocus() && wxWindowBase::AcceptsFocus();
+ if ( MacIsUserPane() )
+ return wxWindowBase::AcceptsFocus();
+ else
+ return m_peer->CanFocus();
}
void wxWindowMac::MacSuperChangedPosition()
return bounds ;
}
-bool wxWindowMac::OSXHandleClicked( double timestampsec )
+bool wxWindowMac::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
return false;
}
#if wxOSX_USE_COCOA_OR_CARBON
if ( OSXHandleClicked( GetEventTime((EventRef)event) ) )
return noErr;
-
+
return eventNotHandledErr ;
#else
return 0;
}
//
-// wxWidgetImpl
+// wxWidgetImpl
//
WX_DECLARE_HASH_MAP(WXWidget, wxWidgetImpl*, wxPointerHash, wxPointerEqual, MacControlMap);
wxWidgetImpl* impl = wxWidgetImpl::FindFromWXWidget( inControl );
if ( impl )
return impl->GetWXPeer();
-
+
return NULL;
}