letting the peer declare whether it wants to draw its borders itself (eg the search control has a round border on mac)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59427 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -208,6 +208,9 @@ public :
|
|||||||
virtual bool NeedsFocusRect() const;
|
virtual bool NeedsFocusRect() const;
|
||||||
virtual void SetNeedsFocusRect( bool needs );
|
virtual void SetNeedsFocusRect( bool needs );
|
||||||
|
|
||||||
|
virtual bool NeedsFrame() const;
|
||||||
|
virtual void SetNeedsFrame( bool needs );
|
||||||
|
|
||||||
virtual bool CanFocus() const = 0;
|
virtual bool CanFocus() const = 0;
|
||||||
// return true if successful
|
// return true if successful
|
||||||
virtual bool SetFocus() = 0;
|
virtual bool SetFocus() = 0;
|
||||||
@@ -445,6 +448,7 @@ protected :
|
|||||||
bool m_isRootControl;
|
bool m_isRootControl;
|
||||||
wxWindowMac* m_wxPeer;
|
wxWindowMac* m_wxPeer;
|
||||||
bool m_needsFocusRect;
|
bool m_needsFocusRect;
|
||||||
|
bool m_needsFrame;
|
||||||
|
|
||||||
DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
|
DECLARE_ABSTRACT_CLASS(wxWidgetImpl)
|
||||||
};
|
};
|
||||||
|
@@ -1381,50 +1381,35 @@ void wxWindowMac::MacPaintBorders( int WXUNUSED(leftOrigin) , int WXUNUSED(right
|
|||||||
CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
|
CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
|
||||||
rect.bottom - rect.top ) ;
|
rect.bottom - rect.top ) ;
|
||||||
|
|
||||||
HIThemeFrameDrawInfo info ;
|
|
||||||
memset( &info, 0 , sizeof(info) ) ;
|
|
||||||
|
|
||||||
info.version = 0 ;
|
|
||||||
info.kind = 0 ;
|
|
||||||
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
|
||||||
info.isFocused = hasFocus ;
|
|
||||||
|
|
||||||
CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
|
CGContextRef cgContext = (CGContextRef) GetParent()->MacGetCGContextRef() ;
|
||||||
wxASSERT( cgContext ) ;
|
wxASSERT( cgContext ) ;
|
||||||
|
|
||||||
if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
if ( m_peer->NeedsFrame() )
|
||||||
{
|
{
|
||||||
info.kind = kHIThemeFrameTextFieldSquare ;
|
HIThemeFrameDrawInfo info ;
|
||||||
HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
|
memset( &info, 0 , sizeof(info) ) ;
|
||||||
|
|
||||||
|
info.version = 0 ;
|
||||||
|
info.kind = 0 ;
|
||||||
|
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
||||||
|
info.isFocused = hasFocus ;
|
||||||
|
|
||||||
|
if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
|
||||||
|
{
|
||||||
|
info.kind = kHIThemeFrameTextFieldSquare ;
|
||||||
|
HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
|
||||||
|
}
|
||||||
|
else if ( HasFlag(wxSIMPLE_BORDER) )
|
||||||
|
{
|
||||||
|
info.kind = kHIThemeFrameListBox ;
|
||||||
|
HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if ( HasFlag(wxSIMPLE_BORDER) )
|
|
||||||
{
|
if ( hasFocus )
|
||||||
info.kind = kHIThemeFrameListBox ;
|
|
||||||
HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
|
|
||||||
}
|
|
||||||
else if ( hasFocus )
|
|
||||||
{
|
{
|
||||||
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
HIThemeDrawFocusRect( &cgrect , true , cgContext , kHIThemeOrientationNormal ) ;
|
||||||
}
|
}
|
||||||
#if 0 // TODO REMOVE now done in a separate call earlier in drawing the window itself
|
|
||||||
m_peer->GetRect( &rect ) ;
|
|
||||||
if ( MacHasScrollBarCorner() )
|
|
||||||
{
|
|
||||||
int variant = (m_hScrollBar == NULL ? m_vScrollBar : m_hScrollBar ) ->GetWindowVariant();
|
|
||||||
int size = m_hScrollBar ? m_hScrollBar->GetSize().y : ( m_vScrollBar ? m_vScrollBar->GetSize().x : MAC_SCROLLBAR_SIZE ) ;
|
|
||||||
CGRect cgrect = CGRectMake( rect.right - size , rect.bottom - size , size , size ) ;
|
|
||||||
CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
|
|
||||||
HIThemeGrowBoxDrawInfo info ;
|
|
||||||
memset( &info, 0, sizeof(info) ) ;
|
|
||||||
info.version = 0 ;
|
|
||||||
info.state = IsEnabled() ? kThemeStateActive : kThemeStateInactive ;
|
|
||||||
info.kind = kHIThemeGrowBoxKindNone ;
|
|
||||||
// contrary to the docs ...SizeSmall does not work
|
|
||||||
info.size = kHIThemeGrowBoxSizeNormal ;
|
|
||||||
info.direction = 0 ;
|
|
||||||
HIThemeDrawGrowBox( &cgpoint , &info , cgContext , kHIThemeOrientationNormal ) ;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif // wxOSX_USE_COCOA_OR_CARBON
|
#endif // wxOSX_USE_COCOA_OR_CARBON
|
||||||
}
|
}
|
||||||
@@ -2097,25 +2082,28 @@ long wxWindowMac::MacGetLeftBorderSize() const
|
|||||||
|
|
||||||
SInt32 border = 0 ;
|
SInt32 border = 0 ;
|
||||||
|
|
||||||
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER))
|
if ( m_peer->NeedsFrame() )
|
||||||
{
|
{
|
||||||
|
if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER))
|
||||||
|
{
|
||||||
#if wxOSX_USE_COCOA_OR_CARBON
|
#if wxOSX_USE_COCOA_OR_CARBON
|
||||||
// this metric is only the 'outset' outside the simple frame rect
|
// this metric is only the 'outset' outside the simple frame rect
|
||||||
GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
|
GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
|
||||||
border += 1;
|
border += 1;
|
||||||
#else
|
#else
|
||||||
border += 2;
|
border += 2;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (HasFlag(wxSIMPLE_BORDER))
|
else if (HasFlag(wxSIMPLE_BORDER))
|
||||||
{
|
{
|
||||||
#if wxOSX_USE_COCOA_OR_CARBON
|
#if wxOSX_USE_COCOA_OR_CARBON
|
||||||
// this metric is only the 'outset' outside the simple frame rect
|
// this metric is only the 'outset' outside the simple frame rect
|
||||||
GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
|
GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
|
||||||
border += 1;
|
border += 1;
|
||||||
#else
|
#else
|
||||||
border += 1;
|
border += 1;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return border ;
|
return border ;
|
||||||
@@ -2398,6 +2386,7 @@ void wxWidgetImpl::Init()
|
|||||||
m_isRootControl = false;
|
m_isRootControl = false;
|
||||||
m_wxPeer = NULL;
|
m_wxPeer = NULL;
|
||||||
m_needsFocusRect = false;
|
m_needsFocusRect = false;
|
||||||
|
m_needsFrame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetImpl::SetNeedsFocusRect( bool needs )
|
void wxWidgetImpl::SetNeedsFocusRect( bool needs )
|
||||||
@@ -2410,3 +2399,12 @@ bool wxWidgetImpl::NeedsFocusRect() const
|
|||||||
return m_needsFocusRect;
|
return m_needsFocusRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWidgetImpl::SetNeedsFrame( bool needs )
|
||||||
|
{
|
||||||
|
m_needsFrame = needs;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxWidgetImpl::NeedsFrame() const
|
||||||
|
{
|
||||||
|
return m_needsFrame;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user