WXWidget wxWindowMac::GetHandle() const
{
- return (WXWidget) m_peer->GetWXWidget() ;
+ if ( m_peer )
+ return (WXWidget) m_peer->GetWXWidget() ;
+ return NULL;
}
-//
-// TODO END move to window_osx.cpp
-//
-
// ---------------------------------------------------------------------------
// Utility Routines to move between different coordinate systems
// ---------------------------------------------------------------------------
m_peer->SetData<ControlSize>(kControlEntireControl, kControlSizeTag, &size ) ;
#endif
-#if wxOSX_USE_COCOA_OR_CARBON
wxFont font ;
-#if wxOSX_USE_ATSU_TEXT
- ThemeFontID themeFont = kThemeSystemFont ;
-
- // we will get that from the settings later
- // and make this NORMAL later, but first
- // we have a few calculations that we must fix
+ wxOSXSystemFont systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
switch ( variant )
{
case wxWINDOW_VARIANT_NORMAL :
- themeFont = kThemeSystemFont ;
+ systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
break ;
case wxWINDOW_VARIANT_SMALL :
- themeFont = kThemeSmallSystemFont ;
+ systemFont = wxOSX_SYSTEM_FONT_SMALL ;
break ;
case wxWINDOW_VARIANT_MINI :
- // not always defined in the headers
- themeFont = 109 ;
+ systemFont = wxOSX_SYSTEM_FONT_MINI ;
break ;
case wxWINDOW_VARIANT_LARGE :
- themeFont = kThemeSystemFont ;
+ systemFont = wxOSX_SYSTEM_FONT_NORMAL ;
break ;
default:
break ;
}
- font.MacCreateFromThemeFont( themeFont ) ;
-#else
- CTFontUIFontType themeFont = kCTFontSystemFontType ;
- switch ( variant )
- {
- case wxWINDOW_VARIANT_NORMAL :
- themeFont = kCTFontSystemFontType;
- break ;
-
- case wxWINDOW_VARIANT_SMALL :
- themeFont = kCTFontSmallSystemFontType;
- break ;
-
- case wxWINDOW_VARIANT_MINI :
- themeFont = kCTFontMiniSystemFontType;
- break ;
-
- case wxWINDOW_VARIANT_LARGE :
- themeFont = kCTFontSystemFontType;
- break ;
-
- default:
- wxFAIL_MSG(_T("unexpected window variant"));
- break ;
- }
- font.MacCreateFromUIFont( themeFont ) ;
-#endif
+ font.CreateSystemFont( systemFont ) ;
SetFont( font ) ;
-#endif
}
void wxWindowMac::MacUpdateControlFont()
return ;
int outerBorder = MacGetLeftBorderSize() ;
-#if wxOSX_USE_CARBON
- if ( m_peer->NeedsFocusRect() /* && m_peer->HasFocus() */ )
+
+ if ( m_peer->NeedsFocusRect() )
outerBorder += 4 ;
-#endif
if ( outerBorder == 0 )
return ;
// now we know that we have something to do at all
-
int tx,ty,tw,th;
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 ;
{
m_label = title ;
- if ( m_peer && m_peer->IsOk() )
+ if ( m_peer && m_peer->IsOk() && !(IsKindOf( CLASSINFO(wxButton) ) && GetId() == wxID_HELP) )
m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics), GetFont().GetEncoding() ) ;
// do not trigger refreshes upon invisible and possible partly created objects
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 ) ;
CGContextSaveGState( cgContext );
if ( m_backgroundColour.Ok() )
CGRect cgrect = CGRectMake( rect.left , rect.top , rect.right - rect.left ,
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() ;
wxASSERT( cgContext ) ;
- if ( HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER) )
+ if ( m_peer->NeedsFrame() )
{
- info.kind = kHIThemeFrameTextFieldSquare ;
- HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
- }
- else if ( HasFlag(wxSIMPLE_BORDER) )
- {
- info.kind = kHIThemeFrameListBox ;
- HIThemeDrawFrame( &cgrect , &info , cgContext , kHIThemeOrientationNormal ) ;
+ HIThemeFrameDrawInfo info ;
+ 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 ( hasFocus )
+
+ if ( hasFocus )
{
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
}
}
}
-// 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()
bool wxWindowMac::AcceptsFocus() const
{
- return m_peer->CanFocus() && wxWindowBase::AcceptsFocus();
+ if ( MacIsUserPane() )
+ return wxWindowBase::AcceptsFocus();
+ else
+ return m_peer->CanFocus();
}
void wxWindowMac::MacSuperChangedPosition()
SInt32 border = 0 ;
- if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER))
+ if ( m_peer && m_peer->NeedsFrame() )
{
+ if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) || HasFlag(wxDOUBLE_BORDER))
+ {
#if wxOSX_USE_COCOA_OR_CARBON
- // this metric is only the 'outset' outside the simple frame rect
- GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
- border += 1;
+ // this metric is only the 'outset' outside the simple frame rect
+ GetThemeMetric( kThemeMetricEditTextFrameOutset , &border ) ;
+ border += 1;
#else
- border += 2;
+ border += 2;
#endif
- }
- else if (HasFlag(wxSIMPLE_BORDER))
- {
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
#if wxOSX_USE_COCOA_OR_CARBON
- // this metric is only the 'outset' outside the simple frame rect
- GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
- border += 1;
+ // this metric is only the 'outset' outside the simple frame rect
+ GetThemeMetric( kThemeMetricListBoxFrameOutset , &border ) ;
+ border += 1;
#else
- border += 1;
+ border += 1;
#endif
+ }
}
return border ;
return bounds ;
}
-bool wxWindowMac::OSXHandleClicked( double timestampsec )
+bool wxWindowMac::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
return false;
}
m_isRootControl = false;
m_wxPeer = NULL;
m_needsFocusRect = false;
+ m_needsFrame = true;
}
void wxWidgetImpl::SetNeedsFocusRect( bool needs )
return m_needsFocusRect;
}
+void wxWidgetImpl::SetNeedsFrame( bool needs )
+{
+ m_needsFrame = needs;
+}
+
+bool wxWidgetImpl::NeedsFrame() const
+{
+ return m_needsFrame;
+}