X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/de923e4f508d751267da1b730e7b8c4fc1f4793c..1111cedc6a23b41737d84f8530aa8df898cbddc5:/src/mac/control.cpp?ds=inline diff --git a/src/mac/control.cpp b/src/mac/control.cpp index 31e38de31a..f44ff6bc7f 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -196,6 +196,8 @@ wxControl::~wxControl() } if ( (ControlHandle) m_macControl ) { + // in case the callback might be called during destruction + ::SetControlColorProc( (ControlHandle) m_macControl , NULL ) ; ::DisposeControl( (ControlHandle) m_macControl ) ; m_macControl = NULL ; } @@ -207,13 +209,16 @@ void wxControl::SetLabel(const wxString& title) if ( m_macControl ) { - UMASetControlTitle( (ControlHandle) m_macControl , m_label ) ; + UMASetControlTitle( (ControlHandle) m_macControl , m_label , m_font.GetEncoding() ) ; } Refresh() ; } wxSize wxControl::DoGetBestSize() const { + if ( (ControlHandle) m_macControl == NULL ) + return wxWindow::DoGetBestSize() ; + Rect bestsize = { 0 , 0 , 0 , 0 } ; short baselineoffset ; int bestWidth, bestHeight ; @@ -235,18 +240,7 @@ wxSize wxControl::DoGetBestSize() const } } - if ( IsKindOf( CLASSINFO( wxButton ) ) ) - { - bestWidth = m_label.Length() * 8 + 12 ; - if ( bestWidth < 70 ) - bestWidth = 70 ; - } - else if ( IsKindOf( CLASSINFO( wxStaticText ) ) ) - { - bestWidth = m_label.Length() * 8 ; - } - else - bestWidth = bestsize.right - bestsize.left ; + bestWidth = bestsize.right - bestsize.left ; bestWidth += 2 * m_macHorizontalBorder ; @@ -319,7 +313,8 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l void wxControl::MacPostControlCreate() { wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; - + DoSetWindowVariant( m_windowVariant ) ; + /* if ( IsKindOf( CLASSINFO( wxScrollBar ) ) ) { // no font @@ -338,12 +333,13 @@ void wxControl::MacPostControlCreate() controlstyle.flags = kControlUseFontMask ; if (IsKindOf( CLASSINFO( wxButton ) ) ) - controlstyle.font = kControlFontSmallSystemFont ; // eventually kControlFontBigSystemFont ; + controlstyle.font = kControlFontBigSystemFont ; // eventually kControlFontBigSystemFont ; else controlstyle.font = kControlFontSmallSystemFont ; ::SetControlFontStyle( (ControlHandle) m_macControl , &controlstyle ) ; } + */ ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ; wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ; ::EmbedControl( (ControlHandle) m_macControl , container ) ; @@ -400,7 +396,7 @@ void wxControl::MacPostControlCreate() SetSize(pos.x, pos.y, new_size.x, new_size.y); #if wxUSE_UNICODE - UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) ) ; + UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ; #endif if ( m_macControlIsShown ) @@ -462,8 +458,7 @@ void wxControl::MacAdjustControlRect() m_height += 2 * m_macVerticalBorder + MacGetTopBorderSize() + MacGetBottomBorderSize() ; } - MacUpdateDimensions() ; -// UMASizeControl( (ControlHandle) m_macControl , m_width - 2 * m_macHorizontalBorder, m_height - 2 * m_macVerticalBorder ) ; + MacUpdateDimensions() ; } } @@ -757,3 +752,58 @@ void wxControl::MacHandleControlClick( WXWidget control , wxInt16 controlpart , wxASSERT_MSG( (ControlHandle) m_macControl != NULL , wxT("No valid mac control") ) ; } +void wxControl::DoSetWindowVariant( wxWindowVariant variant ) +{ + if ( m_macControl == NULL ) + { + wxWindow::SetWindowVariant( variant ) ; + return ; + + } + m_windowVariant = variant ; + + ControlSize size ; + ControlFontStyleRec fontStyle; + fontStyle.flags = kControlUseFontMask ; + + // we will get that from the settings later + // and make this NORMAL later, but first + // we have a few calculations that we must fix + + if ( variant == wxWINDOW_VARIANT_DEFAULT ) + variant = wxWINDOW_VARIANT_SMALL ; + + switch ( variant ) + { + case wxWINDOW_VARIANT_NORMAL : + size = kControlSizeNormal; + fontStyle.font = kControlFontBigSystemFont; + break ; + case wxWINDOW_VARIANT_SMALL : + size = kControlSizeSmall; + fontStyle.font = kControlFontSmallSystemFont; + break ; + case wxWINDOW_VARIANT_MINI : + if (UMAGetSystemVersion() >= 0x1030 ) + { + size = 3 ; // not always defined in the header + fontStyle.font = -5 ; // not always defined in the header + } + else + { + size = kControlSizeSmall; + fontStyle.font = kControlFontSmallSystemFont; + } + break; + break ; + case wxWINDOW_VARIANT_LARGE : + size = kControlSizeLarge; + fontStyle.font = kControlFontBigSystemFont; + break ; + default: + wxFAIL_MSG(_T("unexpected window variant")); + break ; + } + ::SetControlData( (ControlHandle) m_macControl , kControlEntireControl, kControlSizeTag, sizeof( ControlSize ), &size ); + ::SetControlFontStyle( (ControlHandle) m_macControl , &fontStyle ); +}