ATSUStyle taken from font

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31611 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2005-01-27 21:43:06 +00:00
parent 1fd7e0f5f4
commit ba9a486d43

View File

@@ -9,10 +9,12 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dc.h" #pragma implementation "dc.h"
#endif #endif
#include "wx/wxprec.h"
#include "wx/dc.h" #include "wx/dc.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/mac/uma.h" #include "wx/mac/uma.h"
@@ -1676,39 +1678,21 @@ void wxDC::MacInstallFont() const
Pattern whiteColor ; Pattern whiteColor ;
::BackPat(GetQDGlobalsWhite(&whiteColor)); ::BackPat(GetQDGlobalsWhite(&whiteColor));
} }
if ( m_font.Ok() )
{ wxASSERT( m_font.Ok() ) ;
::TextFont( m_font.MacGetFontNum() ) ;
::TextSize( (short)(m_scaleY * m_font.MacGetFontSize()) ) ;
::TextFace( m_font.MacGetFontStyle() ) ; ::TextFont( m_font.MacGetFontNum() ) ;
m_macFontInstalled = true ; ::TextSize( (short)(m_scaleY * m_font.MacGetFontSize()) ) ;
m_macBrushInstalled = false ; ::TextFace( m_font.MacGetFontStyle() ) ;
m_macPenInstalled = false ; m_macFontInstalled = true ;
RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel()); m_macBrushInstalled = false ;
RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel()); m_macPenInstalled = false ;
::RGBForeColor( &forecolor ); RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
::RGBBackColor( &backcolor ); RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
} ::RGBForeColor( &forecolor );
else ::RGBBackColor( &backcolor );
{
FontFamilyID fontId ;
Str255 fontName ;
SInt16 fontSize ;
Style fontStyle ;
GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
GetFNum( fontName, &fontId );
::TextFont( fontId ) ;
::TextSize( short(m_scaleY * fontSize) ) ;
::TextFace( fontStyle ) ;
// todo reset after spacing changes - or store the current spacing somewhere
m_macFontInstalled = true ;
m_macBrushInstalled = false ;
m_macPenInstalled = false ;
RGBColor forecolor = MAC_WXCOLORREF( m_textForegroundColour.GetPixel());
RGBColor backcolor = MAC_WXCOLORREF( m_textBackgroundColour.GetPixel());
::RGBForeColor( &forecolor );
::RGBBackColor( &backcolor );
}
short mode = patCopy ; short mode = patCopy ;
// todo : // todo :
switch( m_logicalFunction ) switch( m_logicalFunction )
@@ -1749,57 +1733,31 @@ void wxDC::MacInstallFont() const
} }
::PenMode( mode ) ; ::PenMode( mode ) ;
OSStatus status = noErr ; OSStatus status = noErr ;
status = ATSUCreateAndCopyStyle( (ATSUStyle) m_font.MacGetATSUStyle() , (ATSUStyle*) &m_macATSUIStyle ) ;
wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.MacGetFontSize()) ) ; Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.MacGetFontSize()) ) ;
Style qdStyle = m_font.MacGetATSUAdditionalQDStyles() ;
ATSUFontID atsuFont = m_font.MacGetATSUFontID() ;
status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ;
wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
ATSUAttributeTag atsuTags[] = ATSUAttributeTag atsuTags[] =
{ {
kATSUFontTag ,
kATSUSizeTag , kATSUSizeTag ,
// kATSUColorTag ,
// kATSUBaselineClassTag ,
kATSUVerticalCharacterTag,
kATSUQDBoldfaceTag ,
kATSUQDItalicTag ,
kATSUQDUnderlineTag ,
kATSUQDCondensedTag ,
kATSUQDExtendedTag ,
} ; } ;
ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{ {
sizeof( ATSUFontID ) ,
sizeof( Fixed ) , sizeof( Fixed ) ,
// sizeof( RGBColor ) ,
// sizeof( BslnBaselineClass ) ,
sizeof( ATSUVerticalCharacterType),
sizeof( Boolean ) ,
sizeof( Boolean ) ,
sizeof( Boolean ) ,
sizeof( Boolean ) ,
sizeof( Boolean ) ,
} ; } ;
Boolean kTrue = true ; Boolean kTrue = true ;
Boolean kFalse = false ; Boolean kFalse = false ;
//BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ;
ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
{ {
&atsuFont ,
&atsuSize , &atsuSize ,
// &MAC_WXCOLORREF( m_textForegroundColour.GetPixel() ) ,
// &kBaselineDefault ,
&kHorizontal,
(qdStyle & bold) ? &kTrue : &kFalse ,
(qdStyle & italic) ? &kTrue : &kFalse ,
(qdStyle & underline) ? &kTrue : &kFalse ,
(qdStyle & condense) ? &kTrue : &kFalse ,
(qdStyle & extend) ? &kTrue : &kFalse ,
} ; } ;
status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) , status = ::ATSUSetAttributes((ATSUStyle)m_macATSUIStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) ,
atsuTags, atsuSizes, atsuValues); atsuTags, atsuSizes, atsuValues);
wxASSERT_MSG( status == noErr , wxT("couldn't set create ATSU style") ) ;
wxASSERT_MSG( status == noErr , wxT("couldn't Modify ATSU style") ) ;
} }
Pattern gPatterns[] = Pattern gPatterns[] =