+void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size)
+{
+ wxASSERT_MSG( (ControlRef) m_macControl != NULL , wxT("No valid mac control") ) ;
+
+ wxAssociateControlWithMacControl( (ControlRef) m_macControl , this ) ;
+ ::SetControlReference( (ControlRef) m_macControl , (long) this ) ;
+
+ MacInstallEventHandler();
+
+ ControlRef container = (ControlRef) GetParent()->GetHandle() ;
+ wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
+ ::EmbedControl( (ControlRef) m_macControl , container ) ;
+
+ // adjust font, controlsize etc
+ DoSetWindowVariant( m_windowVariant ) ;
+
+#if !TARGET_API_MAC_OSX
+ // eventually we can fix some clipping issues be reactivating this hook
+ //if ( m_macIsUserPane )
+ // SetControlColorProc( (ControlRef) m_macControl , wxMacSetupControlBackgroundUPP ) ;
+#endif
+
+ UMASetControlTitle( (ControlRef) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ;
+
+ wxSize new_size = size ;
+ if (!m_macIsUserPane)
+ {
+ wxSize best_size( DoGetBestSize() );
+
+ if (size.x == -1) {
+ new_size.x = best_size.x;
+ }
+ if (size.y == -1) {
+ new_size.y = best_size.y;
+ }
+ SetSize( pos.x, pos.y , new_size.x, new_size.y,wxSIZE_USE_EXISTING );
+ }
+
+ SetCursor( *wxSTANDARD_CURSOR ) ;
+
+}
+
+void wxWindowMac::DoSetWindowVariant( wxWindowVariant variant )
+{
+ wxASSERT( m_macControl != NULL ) ;
+
+ m_windowVariant = variant ;
+
+ ControlSize size ;
+ 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
+
+ switch ( variant )
+ {
+ case wxWINDOW_VARIANT_NORMAL :
+ size = kControlSizeNormal;
+ themeFont = kThemeSystemFont ;
+ break ;
+ case wxWINDOW_VARIANT_SMALL :
+ size = kControlSizeSmall;
+ themeFont = kThemeSmallSystemFont ;
+ break ;
+ case wxWINDOW_VARIANT_MINI :
+ if (UMAGetSystemVersion() >= 0x1030 )
+ {
+ // not always defined in the headers
+ size = 3 ;
+ themeFont = 109 ;
+ }
+ else
+ {
+ size = kControlSizeSmall;
+ themeFont = kThemeSmallSystemFont ;
+ }
+ break ;
+ case wxWINDOW_VARIANT_LARGE :
+ size = kControlSizeLarge;
+ themeFont = kThemeSystemFont ;
+ break ;
+ default:
+ wxFAIL_MSG(_T("unexpected window variant"));
+ break ;
+ }
+ ::SetControlData( (ControlRef) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size );
+
+ wxFont font ;
+ font.MacCreateThemeFont( themeFont ) ;
+ SetFont( font ) ;
+}
+
+void wxWindowMac::MacUpdateControlFont()
+{
+ ControlFontStyleRec fontStyle;
+ if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
+ {
+ switch( m_font.MacGetThemeFontID() )
+ {
+ case kThemeSmallSystemFont : fontStyle.font = kControlFontSmallSystemFont ; break ;
+ case 109 /*mini font */ : fontStyle.font = -5 ; break ;
+ case kThemeSystemFont : fontStyle.font = kControlFontBigSystemFont ; break ;
+ default : fontStyle.font = kControlFontBigSystemFont ; break ;
+ }
+ fontStyle.flags = kControlUseFontMask ;
+ }
+ else
+ {
+ fontStyle.font = m_font.MacGetFontNum() ;
+ fontStyle.style = m_font.MacGetFontStyle() ;
+ fontStyle.size = m_font.MacGetFontSize() ;
+ fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask ;
+ }
+ fontStyle.foreColor = MAC_WXCOLORREF(GetForegroundColour().GetPixel() ) ;
+ fontStyle.flags |= kControlUseForeColorMask ;
+ ::SetControlFontStyle( (ControlRef) m_macControl , &fontStyle );
+ Refresh() ;
+}
+
+bool wxWindowMac::SetFont(const wxFont& font)
+{
+ bool retval = !wxWindowBase::SetFont( font ) ;
+
+ MacUpdateControlFont() ;
+
+ return retval;
+}
+
+bool wxWindowMac::SetForegroundColour(const wxColour& col )
+{
+ if ( !wxWindowBase::SetForegroundColour(col) )
+ return false ;
+
+ MacUpdateControlFont() ;
+
+ return true ;
+}
+
+bool wxWindowMac::SetBackgroundColour(const wxColour& col )
+{
+ if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol )
+ return false ;
+
+ wxBrush brush ;
+ if ( col == wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE) )
+ {
+ brush.MacSetTheme( kThemeBrushDocumentWindowBackground ) ;
+ }
+ else if ( col == wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE ) )
+ {
+ brush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
+ }
+ else
+ {
+ brush.SetColour( col ) ;
+ }
+ MacSetBackgroundBrush( brush ) ;
+
+ MacUpdateControlFont() ;
+
+ return true ;
+}
+
+
+bool wxWindowMac::MacCanFocus() const
+{
+ wxASSERT( m_macControl != NULL ) ;
+
+ return true ;
+}
+
+