reworked font handling for osx

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2009-03-20 13:56:57 +00:00
parent 0cc860a2ab
commit f1c40652a0
19 changed files with 1066 additions and 748 deletions

View File

@ -65,6 +65,7 @@ enum wxXLFDField
// functions, the user code can only get the objects of this type from
// somewhere and pass it somewhere else (possibly save them somewhere using
// ToString() and restore them using FromString())
class WXDLLIMPEXP_CORE wxNativeFontInfo
{
public:
@ -113,6 +114,77 @@ public:
FATTRS fa;
FONTMETRICS fm;
FACENAMEDESC fn;
#elif defined(__WXOSX__)
public:
wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); }
wxNativeFontInfo( int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
{ Init(size,family,style,weight,underlined,faceName,encoding); }
~wxNativeFontInfo() { Free(); }
wxNativeFontInfo& operator=(const wxNativeFontInfo& info)
{
if (this != &info)
{
Free();
Init(info);
}
return *this;
}
#if wxOSX_USE_CORE_TEXT
void Init(CTFontDescriptorRef descr);
#endif
void Init(const wxNativeFontInfo& info);
void Init(int size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
const wxString& faceName ,
wxFontEncoding encoding);
void Free();
void EnsureValid();
bool m_descriptorValid;
#if wxOSX_USE_CORE_TEXT
CTFontDescriptorRef m_ctFontDescriptor;
#endif
#if wxOSX_USE_ATSU_TEXT
bool m_atsuFontValid;
// the atsu font ID
wxUint32 m_atsuFontID;
// the qd styles that are not intrinsic to the font above
wxInt16 m_atsuAdditionalQDStyles;
#if wxOSX_USE_CARBON
wxInt16 m_qdFontFamily;
wxInt16 m_qdFontStyle;
#endif
#endif
#if wxOSX_USE_COCOA
WX_NSFontDescriptor m_nsFontDescriptor;
void ValidateNSFontDescriptor();
#endif
#if wxOSX_USE_IPHONE
#endif
int m_pointSize;
wxFontFamily m_family;
wxFontStyle m_style;
wxFontWeight m_weight;
bool m_underlined;
wxString m_faceName;
wxFontEncoding m_encoding;
public :
#else // other platforms
//
// This is a generic implementation that should work on all ports

View File

@ -726,7 +726,7 @@ private :
void wxMacCocoaRelease( void* obj );
void wxMacCocoaAutorelease( void* obj );
void wxMacCocoaRetain( void* obj );
void* wxMacCocoaRetain( void* obj );
#endif

View File

@ -16,6 +16,21 @@
// wxFont
// ----------------------------------------------------------------------------
// font styles
enum wxOSXSystemFont
{
wxOSX_SYSTEM_FONT_NONE = 0,
wxOSX_SYSTEM_FONT_NORMAL,
wxOSX_SYSTEM_FONT_BOLD,
wxOSX_SYSTEM_FONT_SMALL,
wxOSX_SYSTEM_FONT_SMALL_BOLD,
wxOSX_SYSTEM_FONT_MINI,
wxOSX_SYSTEM_FONT_MINI_BOLD,
wxOSX_SYSTEM_FONT_LABELS,
wxOSX_SYSTEM_FONT_VIEWS
};
class WXDLLIMPEXP_CORE wxFont : public wxFontBase
{
public:
@ -75,15 +90,8 @@ public:
bool Create(const wxNativeFontInfo& info);
#if wxOSX_USE_ATSU_TEXT
bool MacCreateFromThemeFont( wxUint16 themeFontID ) ;
#endif
#if wxOSX_USE_CORE_TEXT
bool MacCreateFromUIFont( wxUint32 coreTextFontType );
bool MacCreateFromCTFontDescriptor( const void * ctFontDescriptor, int pointSize = 0 );
bool MacCreateFromCTFont( const void * ctFont );
#endif
bool CreateSystemFont(wxOSXSystemFont font);
virtual ~wxFont();
// implement base class pure virtuals
@ -118,32 +126,42 @@ public:
// Mac-specific, risks to change, don't use in portable code
#if wxOSX_USE_ATSU_TEXT
#if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
wxUint16 MacGetThemeFontID() const ;
// 'old' Quickdraw accessors
short MacGetFontNum() const;
short MacGetFontSize() const;
wxByte MacGetFontStyle() const;
// 'new' ATSUI accessors
wxUint32 MacGetATSUFontID() const;
wxUint32 MacGetATSUAdditionalQDStyles() const;
wxUint16 MacGetThemeFontID() const ;
// Returns an ATSUStyle not ATSUStyle*
#endif
#if wxOSX_USE_COCOA_OR_CARBON
CGFontRef GetCGFont() const;
#endif
#if wxOSX_USE_CORE_TEXT
const void * MacGetCTFont() const;
CTFontRef GetCTFont() const;
#endif
#if wxOSX_USE_CORE_TEXT || wxOSX_USE_ATSU_TEXT
// Returns an ATSUStyle not ATSUStyle*
void* MacGetATSUStyle() const ;
#endif
#if wxOSX_USE_COCOA
WX_NSFont GetNSFont() const;
static WX_NSFont CreateNSFont(wxOSXSystemFont font, wxNativeFontInfo* info);
static WX_NSFont CreateNSFont(const wxNativeFontInfo* info);
#endif
#if wxOSX_USE_IPHONE
WX_UIFont GetUIFont() const;
static WX_NSFont CreateUIFont(wxOSXSystemFont font, wxNativeFontInfo* info);
#endif
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
private:
void Unshare();
DECLARE_DYNAMIC_CLASS(wxFont)
};

View File

@ -586,7 +586,7 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_)
// format there anyhow (but there is a well-defined standard for X11 fonts used
// by wxGTK and wxMotif)
#if defined(wxNO_NATIVE_FONTINFO) || defined(__WXMSW__) || defined (__WXPM__)
#if defined(wxNO_NATIVE_FONTINFO) || defined(__WXMSW__) || defined (__WXPM__) || defined(__WXOSX__)
wxString wxNativeFontInfo::ToUserString() const
{

View File

@ -692,7 +692,7 @@ wxCairoFontData::wxCairoFontData( wxGraphicsRenderer* renderer, const wxFont &fo
m_underlined = font.GetUnderlined();
#ifdef __WXMAC__
m_font = cairo_atsui_font_face_create_for_atsu_font_id( font.MacGetATSUFontID() );
m_font = cairo_quartz_font_face_create_for_cgfont( font.GetCGFont() );
#elif defined(__WXGTK__)
m_font = pango_font_description_copy( font.GetNativeFontInfo()->description );
#else

View File

@ -4305,13 +4305,9 @@ void wxGenericListCtrl::CreateOrDestroyHeaderWindowAsNeeded()
wxTAB_TRAVERSAL
);
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
#if defined( __WXMAC__ )
wxFont font;
#if wxOSX_USE_ATSU_TEXT
font.MacCreateFromThemeFont( kThemeSmallSystemFont );
#else
font.MacCreateFromUIFont( kCTFontSystemFontType );
#endif
font.CreateSystemFont( wxOSX_SYSTEM_FONT_SMALL );
m_headerWin->SetFont( font );
#endif

View File

@ -973,11 +973,7 @@ void wxGenericTreeCtrl::Init()
m_lastOnSame = false;
#if defined( __WXMAC__ )
#if wxOSX_USE_ATSU_TEXT
m_normalFont.MacCreateFromThemeFont( kThemeViewsFont ) ;
#else
m_normalFont.MacCreateFromUIFont( kCTFontViewsFontType ) ;
#endif
m_normalFont.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
#else
m_normalFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
#endif

View File

@ -1043,7 +1043,7 @@ wxVisualAttributes wxDataViewCtrl::GetClassDefaultAttributes(wxWindowVariant var
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
//attr.font.MacCreateFromThemeFont(kThemeViewsFont);
//attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
return attr;
}

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,7 @@
#endif
#include "wx/fontdlg.h"
#include "wx/fontutil.h"
#if wxOSX_USE_EXPERIMENTAL_FONTDIALOG
@ -82,7 +83,9 @@ wxMacCarbonFontPanelHandler(EventHandlerCallRef WXUNUSED(nextHandler),
if ( cEvent.GetParameter<CTFontDescriptorRef>( kEventParamCTFontDescriptor, typeCTFontDescriptorRef, &descr ) == noErr )
{
wxFont font;
font.MacCreateFromCTFontDescriptor(descr);
wxNativeFontInfo fontinfo;
fontinfo.Init(descr);
font.Create(fontinfo);
fontdata.SetChosenFont( font ) ;
setup = true;
}
@ -229,7 +232,7 @@ int wxFontDialog::ShowModal()
#if wxOSX_USE_CORE_TEXT
if ( UMAGetSystemVersion() >= 0x1050 )
{
CTFontDescriptorRef descr = (CTFontDescriptorRef) CTFontCopyFontDescriptor( (CTFontRef) font.MacGetCTFont() );
CTFontDescriptorRef descr = (CTFontDescriptorRef) CTFontCopyFontDescriptor( (CTFontRef) font.GetCTFont() );
err = SetFontInfoForSelection (kFontSelectionCoreTextType,1, &descr , NULL);
CFRelease( descr );
setup = true;

View File

@ -51,9 +51,6 @@ void wxStockGDIMac::OnExit()
{
}
extern wxFont* CreateNormalFont();
extern wxFont* CreateSmallFont();
const wxFont* wxStockGDIMac::GetFont(Item item)
{
wxFont* font = static_cast<wxFont*>(ms_stockObject[item]);
@ -61,31 +58,14 @@ const wxFont* wxStockGDIMac::GetFont(Item item)
{
switch (item)
{
#if wxOSX_USE_COCOA_OR_CARBON
case FONT_NORMAL:
font = new wxFont;
#if wxOSX_USE_ATSU_TEXT
font->MacCreateFromThemeFont(kThemeSystemFont);
#else
font->MacCreateFromUIFont(kCTFontSystemFontType);
#endif
font->CreateSystemFont(wxOSX_SYSTEM_FONT_NORMAL);
break;
case FONT_SMALL:
font = new wxFont;
#if wxOSX_USE_ATSU_TEXT
font->MacCreateFromThemeFont(kThemeSmallSystemFont);
#else
font->MacCreateFromUIFont(kCTFontSmallSystemFontType);
#endif
font->CreateSystemFont(wxOSX_SYSTEM_FONT_SMALL);
break;
#else
case FONT_NORMAL:
font = CreateNormalFont() ;
break;
case FONT_SMALL:
font = CreateSmallFont();
break;
#endif
default:
font = const_cast<wxFont*>(super::GetFont(item));
break;

View File

@ -171,7 +171,7 @@ CGColorRef wxMacCreateCGColor( const wxColour& col )
CTFontRef wxMacCreateCTFont( const wxFont& font )
{
#ifdef __WXMAC__
return wxCFRetain((CTFontRef) font.MacGetCTFont());
return wxCFRetain((CTFontRef) font.GetCTFont());
#else
return CTFontCreateWithName( wxCFStringRef( font.GetFaceName(), wxLocale::GetSystemEncoding() ) , font.GetPointSize() , NULL );
#endif
@ -859,7 +859,7 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
// we need the scale here ...
Fixed atsuSize = IntToFixed( int( 1 * font.MacGetFontSize()) );
Fixed atsuSize = IntToFixed( int( 1 * font.GetPointSize()) );
RGBColor atsuColor ;
col.GetRGBColor( &atsuColor );
ATSUAttributeTag atsuTags[] =

View File

@ -783,11 +783,7 @@ wxListCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
#if wxOSX_USE_ATSU_TEXT
attr.font.MacCreateFromThemeFont( kThemeViewsFont ) ;
#else
attr.font.MacCreateFromUIFont( kCTFontViewsFontType ) ;
#endif
attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
return attr;
}
@ -2857,7 +2853,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
if (font.Ok())
{
info.fontID = kThemeSpecifiedFont;
info.font = (CTFontRef) font.MacGetCTFont();
info.font = (CTFontRef) font.GetCTFont();
setup = true;
}
}
@ -2872,7 +2868,7 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
{
info.fontID = font.MacGetThemeFontID();
::TextSize( (short)(font.MacGetFontSize()) ) ;
::TextSize( (short)(font.GetPointSize()) ) ;
::TextFace( font.MacGetFontStyle() ) ;
}
}

View File

@ -21,6 +21,8 @@
#include "wx/osx/private.h"
#endif
#include "wx/fontutil.h"
#ifdef __WXMAC__
#if wxOSX_USE_CARBON
@ -79,17 +81,113 @@ void wxMacCocoaAutorelease( void* obj )
[(NSObject*)obj autorelease];
}
void wxMacCocoaRetain( void* obj )
void* wxMacCocoaRetain( void* obj )
{
[(NSObject*)obj retain];
return obj;
}
// ----------------------------------------------------------------------------
// NSFont Utils
// ----------------------------------------------------------------------------
#if wxOSX_USE_COCOA
WX_NSFont wxFont::CreateNSFont(wxOSXSystemFont font, wxNativeFontInfo* info)
{
NSFont* nsfont;
switch( font )
{
case wxOSX_SYSTEM_FONT_NORMAL:
nsfont = [NSFont systemFontOfSize:[NSFont systemFontSize]];
break;
case wxOSX_SYSTEM_FONT_BOLD:
nsfont = [NSFont boldSystemFontOfSize:[NSFont systemFontSize]];
break;
case wxOSX_SYSTEM_FONT_SMALL:
nsfont = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
break;
case wxOSX_SYSTEM_FONT_SMALL_BOLD:
nsfont = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
break;
case wxOSX_SYSTEM_FONT_MINI:
nsfont = [NSFont systemFontOfSize:[NSFont systemFontSize]];
break;
case wxOSX_SYSTEM_FONT_MINI_BOLD:
nsfont = [NSFont boldSystemFontOfSize:
[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
break;
case wxOSX_SYSTEM_FONT_LABELS:
nsfont = [NSFont labelFontOfSize:
[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
break;
case wxOSX_SYSTEM_FONT_VIEWS:
nsfont = [NSFont controlContentFontOfSize:0];
break;
default:
break;
}
[nsfont retain];
NSFontDescriptor*desc = [[nsfont fontDescriptor] retain];
if ( info->m_faceName.empty())
{
wxFontStyle fontstyle = wxFONTSTYLE_NORMAL;
wxFontWeight fontweight = wxFONTWEIGHT_NORMAL;
bool underlined = false;
int size = (int) ([desc pointSize]+0.5);
NSFontSymbolicTraits traits = [desc symbolicTraits];
if ( traits & NSFontBoldTrait )
fontweight = wxFONTWEIGHT_BOLD ;
else
fontweight = wxFONTWEIGHT_NORMAL ;
if ( traits & NSFontItalicTrait )
fontstyle = wxFONTSTYLE_ITALIC ;
wxCFStringRef fontname( [desc postscriptName] );
info->Init(size,wxFONTFAMILY_DEFAULT,fontstyle,fontweight,underlined,
fontname.AsString(), wxFONTENCODING_DEFAULT);
}
info->m_nsFontDescriptor = desc;
return nsfont;
}
void wxNativeFontInfo::ValidateNSFontDescriptor()
{
NSFontDescriptor* desc = [NSFont fontWithName:wxCFStringRef(m_faceName).AsNSString() size:m_pointSize];
NSFontSymbolicTraits traits = 0;
if (m_weight == wxFONTWEIGHT_BOLD)
traits |= NSFontBoldTrait;
if (m_style == wxFONTSTYLE_ITALIC || m_style == wxFONTSTYLE_SLANT)
traits |= NSFontItalicTrait;
if ( traits != 0 )
{
[desc autorelease];
desc = [desc fontDescriptorWithSymbolicTraits:traits];
}
m_nsFontDescriptor = desc;
}
WX_NSFont wxFont::CreateNSFont(const wxNativeFontInfo* info)
{
NSFont* nsFont;
nsFont = [NSFont fontWithDescriptor:info->m_nsFontDescriptor size:info->m_pointSize];
return nsFont;
}
#endif
// ----------------------------------------------------------------------------
// NSImage Utils
// ----------------------------------------------------------------------------
#if wxOSX_USE_COCOA
// From "Cocoa Drawing Guide:Working with Images"
WX_NSImage wxOSXCreateNSImageFromCGImage( CGImageRef image )
{

View File

@ -1228,7 +1228,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
flush = kHIThemeTextHorizontalFlushCenter;
else if ( ( windowStyle & wxALIGN_MASK ) & wxALIGN_RIGHT )
flush = kHIThemeTextHorizontalFlushRight;
HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.MacGetCTFont() );
HIViewSetTextFont( m_controlRef , part , (CTFontRef) font.GetCTFont() );
HIViewSetTextHorizontalFlush( m_controlRef, part, flush );
if ( foreground != *wxBLACK || ignoreBlack == false )
@ -1269,7 +1269,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
{
fontStyle.font = font.MacGetFontNum();
fontStyle.style = font.MacGetFontStyle();
fontStyle.size = font.MacGetFontSize();
fontStyle.size = font.GetPointSize();
fontStyle.flags = kControlUseFontMask | kControlUseFaceMask | kControlUseSizeMask;
}

View File

@ -27,14 +27,12 @@
#include <stdio.h>
@interface wxNSStaticTextView : NSTextView
@interface wxNSStaticTextView : NSTextField
{
wxWidgetCocoaImpl* impl;
}
- (void) setImplementation:(wxWidgetCocoaImpl*) item;
- (wxWidgetCocoaImpl*) implementation;
@end
@implementation wxNSStaticTextView
+ (void)initialize
@ -47,83 +45,46 @@
}
}
- (wxWidgetCocoaImpl*) implementation
{
return impl;
}
- (void) setImplementation:(wxWidgetCocoaImpl*) item
{
impl = item;
}
@end
class wxStaticTextCocoaImpl : public wxWidgetCocoaImpl
{
public:
wxStaticTextCocoaImpl( wxWindowMac* peer , WXWidget w ) : wxWidgetCocoaImpl(peer, w)
wxStaticTextCocoaImpl( wxWindowMac* peer , WXWidget w , NSLineBreakMode lineBreak) : wxWidgetCocoaImpl(peer, w)
{
m_lineBreak = lineBreak;
}
virtual void SetLabel(const wxString& title, wxFontEncoding encoding)
{
wxNSStaticTextView* v = (wxNSStaticTextView*)GetWXWidget();
wxWindow* wxpeer = GetWXPeer();
[v setString: wxCFStringRef( title , wxpeer->GetFont().GetEncoding() ).AsNSString()];
NSCell* cell = [v cell];
wxCFStringRef text( title , wxpeer->GetFont().GetEncoding() );
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineBreakMode:m_lineBreak];
int style = wxpeer->GetWindowStyleFlag();
NSRange allText = NSMakeRange(0, title.length());
if (style & wxALIGN_CENTER)
[v setAlignment: NSCenterTextAlignment range: allText];
[paragraphStyle setAlignment: NSCenterTextAlignment];
else if (style & wxALIGN_RIGHT)
[v setAlignment: NSRightTextAlignment range: allText];
[paragraphStyle setAlignment: NSRightTextAlignment];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:paragraphStyle, NSParagraphStyleAttributeName, nil];
NSAttributedString *attrstring = [[NSAttributedString alloc] initWithString:text.AsNSString() attributes:dict];
[cell setAttributedStringValue:attrstring];
[attrstring release];
[paragraphStyle release];
}
private :
NSLineBreakMode m_lineBreak;
};
wxSize wxStaticText::DoGetBestSize() const
{
Point bounds;
#if wxOSX_USE_ATSU_TEXT
OSStatus err = noErr;
wxCFStringRef str( m_label, GetFont().GetEncoding() );
SInt16 baseline;
if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
{
err = GetThemeTextDimensions(
(!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
verify_noerr( err );
}
else
#endif
{
wxClientDC dc(const_cast<wxStaticText*>(this));
wxCoord width, height ;
dc.GetMultiLineTextExtent( m_label , &width, &height);
// FIXME: The calculations returned by this function are too small
// for some strings, so we adjust manually.
bounds.h = width+12;
bounds.v = height+4;
}
if ( m_label.empty() )
bounds.h = 0;
bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize();
bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize();
return wxSize( bounds.h, bounds.v );
return wxWindowMac::DoGetBestSize() ;
}
// for wxST_ELLIPSIZE_* support:
/*
FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
to allow correct dynamic ellipsizing of the label
*/
wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
wxWindowMac* parent,
wxWindowID id,
@ -139,29 +100,26 @@ wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
[v setEditable:NO];
[v setDrawsBackground:NO];
[v setSelectable: NO];
wxWidgetCocoaImpl* c = new wxStaticTextCocoaImpl( wxpeer, v );
return c;
/*
Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
wxMacControl* peer = new wxMacControl( wxpeer );
OSStatus err = CreateStaticTextControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, NULL, NULL, peer->GetControlRefAddr() );
verify_noerr( err );
if ( ( style & wxST_ELLIPSIZE_END ) || ( style & wxST_ELLIPSIZE_MIDDLE ) )
[v setBezeled:NO];
[v setBordered:NO];
NSLineBreakMode linebreak = NSLineBreakByWordWrapping;
if ( ((wxStaticText*)wxpeer)->IsEllipsized() )
{
TruncCode tCode = truncEnd;
if ( style & wxST_ELLIPSIZE_MIDDLE )
tCode = truncMiddle;
err = peer->SetData( kControlStaticTextTruncTag, tCode );
err = peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
linebreak = NSLineBreakByTruncatingMiddle;
else if (style & wxST_ELLIPSIZE_END )
linebreak = NSLineBreakByTruncatingTail;
else if (style & wxST_ELLIPSIZE_START )
linebreak = NSLineBreakByTruncatingHead;
}
return peer;
*/
else
{
[[v cell] setWraps:YES];
}
wxWidgetCocoaImpl* c = new wxStaticTextCocoaImpl( wxpeer, v, linebreak );
return c;
}
#endif //if wxUSE_STATTEXT

View File

@ -1352,11 +1352,7 @@ void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
void wxWidgetCocoaImpl::SetFont(wxFont const& font, wxColour const&, long, bool)
{
if ([m_osxView respondsToSelector:@selector(setFont:)])
#if wxOSX_USE_CORE_TEXT
[m_osxView setFont: (NSFont*)font.MacGetCTFont()];
#else
#endif
[m_osxView setFont: font.GetNSFont()];
}
void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )

View File

@ -272,11 +272,7 @@ wxListBox::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
attr.colFg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
attr.colBg = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX );
#if wxOSX_USE_ATSU_TEXT
attr.font.MacCreateFromThemeFont(kThemeViewsFont);
#else
attr.font.MacCreateFromUIFont(kCTFontViewsFontType);
#endif
attr.font.CreateSystemFont(wxOSX_SYSTEM_FONT_VIEWS);
return attr;
}

View File

@ -57,7 +57,11 @@ void wxStaticText::SetLabel(const wxString& label)
m_labelOrig = label;
// middle/end ellipsization is handled by the OS:
if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE) )
if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE)
#if wxOSX_USE_COCOA // Cocoa has all three modes
|| HasFlag(wxST_ELLIPSIZE_START)
#endif
)
{
// remove markup
wxString str(label);