From 2c1a331259c998fdf79ae0303a1845863de6afbb Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 28 Mar 2003 17:30:20 +0000 Subject: [PATCH] unicode fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19852 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/choice.cpp | 15 ++++++++++++++- src/mac/carbon/listbox.cpp | 15 ++++++++++++++- src/mac/carbon/tooltip.cpp | 1 - src/mac/choice.cpp | 15 ++++++++++++++- src/mac/listbox.cpp | 15 ++++++++++++++- src/mac/tooltip.cpp | 1 - 6 files changed, 56 insertions(+), 6 deletions(-) diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 19f8e405d2..37f432cff0 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -238,7 +238,20 @@ wxSize wxChoice::DoGetBestSize() const // Find the widest line for(int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + #if wxUSE_UNICODE + Point bounds={0,0} ; + SInt16 baseline ; + ::GetThemeTextDimensions( wxMacCFStringHolder( str ) , + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + wLine = bounds.h ; + #else + wxCharBuffer text = wxMacStringToCString( str ) ; + wLine = ::TextWidth( text , 0 , strlen(text) ) ; + #endif lbWidth = wxMax(lbWidth, wLine); } // Add room for the popup arrow diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 12e2c048bb..656a835b6e 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -620,7 +620,20 @@ wxSize wxListBox::DoGetBestSize() const // Find the widest line for(int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + #if wxUSE_UNICODE + Point bounds={0,0} ; + SInt16 baseline ; + ::GetThemeTextDimensions( wxMacCFStringHolder( str ) , + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + wLine = bounds.h ; + #else + wxCharBuffer text = wxMacStringToCString( str ) ; + wLine = ::TextWidth( text , 0 , strlen(text) ) ; + #endif lbWidth = wxMax(lbWidth, wLine); } diff --git a/src/mac/carbon/tooltip.cpp b/src/mac/carbon/tooltip.cpp index bee14fc9fb..042a6f2c35 100644 --- a/src/mac/carbon/tooltip.cpp +++ b/src/mac/carbon/tooltip.cpp @@ -256,7 +256,6 @@ void wxMacToolTip::Draw() ::GetFontInfo(&fontInfo); short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; short height = 0 ; - // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; int i = 0 ; int length = m_label.Length() ; diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 19f8e405d2..37f432cff0 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -238,7 +238,20 @@ wxSize wxChoice::DoGetBestSize() const // Find the widest line for(int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + #if wxUSE_UNICODE + Point bounds={0,0} ; + SInt16 baseline ; + ::GetThemeTextDimensions( wxMacCFStringHolder( str ) , + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + wLine = bounds.h ; + #else + wxCharBuffer text = wxMacStringToCString( str ) ; + wLine = ::TextWidth( text , 0 , strlen(text) ) ; + #endif lbWidth = wxMax(lbWidth, wLine); } // Add room for the popup arrow diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 12e2c048bb..656a835b6e 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -620,7 +620,20 @@ wxSize wxListBox::DoGetBestSize() const // Find the widest line for(int i = 0; i < GetCount(); i++) { wxString str(GetString(i)); - wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ; + #if wxUSE_UNICODE + Point bounds={0,0} ; + SInt16 baseline ; + ::GetThemeTextDimensions( wxMacCFStringHolder( str ) , + kThemeCurrentPortFont, + kThemeStateActive, + false, + &bounds, + &baseline ); + wLine = bounds.h ; + #else + wxCharBuffer text = wxMacStringToCString( str ) ; + wLine = ::TextWidth( text , 0 , strlen(text) ) ; + #endif lbWidth = wxMax(lbWidth, wLine); } diff --git a/src/mac/tooltip.cpp b/src/mac/tooltip.cpp index bee14fc9fb..042a6f2c35 100644 --- a/src/mac/tooltip.cpp +++ b/src/mac/tooltip.cpp @@ -256,7 +256,6 @@ void wxMacToolTip::Draw() ::GetFontInfo(&fontInfo); short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading; short height = 0 ; - // short width = TextWidth( m_label , 0 ,m_label.Length() ) ; int i = 0 ; int length = m_label.Length() ; -- 2.45.2