const short kEmulatedMode = -1 ;
const short kUnsupportedMode = -2 ;
+extern TECObjectRef s_TECNativeCToUnicode ;
+
// set to 0 if problems arise
#define wxMAC_EXPERIMENTAL_DC 1
wxASSERT( dc->Ok() ) ;
GetPort( &m_oldPort ) ;
SetPort( (GrafPtr) dc->m_macPort ) ;
+ m_clipRgn = NewRgn() ;
+ GetClip( m_clipRgn ) ;
m_dc = dc ;
dc->MacSetupPort( NULL ) ;
}
~wxMacFastPortSetter()
{
+ SetPort( (GrafPtr) m_dc->m_macPort ) ;
+ SetClip( m_clipRgn ) ;
SetPort( m_oldPort ) ;
m_dc->MacCleanupPort( NULL ) ;
+ DisposeRgn( m_clipRgn ) ;
}
private :
+ RgnHandle m_clipRgn ;
GrafPtr m_oldPort ;
const wxDC* m_dc ;
} ;
typedef wxMacPortSetter wxMacFastPortSetter ;
#endif
+#if 0
+
+// start moving to a dual implementation for QD and CGContextRef
+
+class wxMacGraphicsContext
+{
+public :
+ void DrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask ) = 0 ;
+ void SetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) = 0 ;
+ void SetClippingRegion( const wxRegion ®ion ) = 0 ;
+ void DestroyClippingRegion() = 0 ;
+ void SetTextForeground( const wxColour &col ) = 0 ;
+ void SetTextBackground( const wxColour &col ) = 0 ;
+ void SetLogicalScale( double x , double y ) = 0 ;
+ void SetUserScale( double x , double y ) = 0;
+} ;
+
+class wxMacQuickDrawContext : public wxMacGraphicsContext
+{
+public :
+} ;
+
+#endif
+
wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win )
{
m_formerClip = NewRgn() ;
wxMacFastPortSetter helper(this) ;
MacInstallFont() ;
- wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
if ( 0 )
{
m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize);
- SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * font->m_macFontSize));
+ SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.GetMacFontSize()));
m_macAliasWasEnabled = true ;
}
OSStatus status = noErr ;
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) (const wxChar*) str , 0 , str.Length() , str.Length() , 1 ,
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
#else
- TECObjectRef ec;
- status = TECCreateConverter(&ec,
- wxApp::s_macDefaultEncodingIsPC
- ? (int)kTextEncodingWindowsLatin1
- : (int)kTextEncodingMacRoman,
- kTextEncodingUnicodeDefault);
-
- wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ;
- ByteCount byteOutLen ;
- ByteCount byteInLen = str.Length() ;
- ByteCount byteBufferLen = byteInLen *2 ;
- char* buf = new char[byteBufferLen] ;
- status = TECConvertText(ec, (ConstTextPtr)str.c_str() , byteInLen, &byteInLen,
- (TextPtr)buf, byteBufferLen, &byteOutLen);
- wxASSERT_MSG( status == noErr , wxT("couldn't convert text") ) ;
- status = TECDisposeConverter(ec);
- wxASSERT_MSG( status == noErr , wxT("couldn't dispose converter") ) ;
- status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) buf , 0 , byteOutLen / 2 , byteOutLen / 2 , 1 ,
+ wxWCharBuffer wchar = str.wc_str( wxConvLocal ) ;
+ int wlen = wxWcslen( wchar.data() ) ;
+ status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) wchar.data() , 0 , wlen , wlen , 1 ,
&chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ;
#endif
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
CalcBoundingBox(XDEV2LOG(rect.left), YDEV2LOG(rect.top) );
CalcBoundingBox(XDEV2LOG(rect.right), YDEV2LOG(rect.bottom) );
::ATSUDisposeTextLayout(atsuLayout);
-#if wxUSE_UNICODE
-#else
- delete[] buf ;
-#endif
}
void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y)
else
#endif
{
- wxCharBuffer text = wxMacStringToCString(linetext) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ;
line++ ;
::MoveTo( xx , yy + line*(fi.descent + fi.ascent + fi.leading) );
else
#endif
{
- wxCharBuffer text = wxMacStringToCString(linetext) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
::DrawText( text , 0 , strlen(text) ) ;
}
}
if ( externalLeading )
*externalLeading = YDEV2LOGREL( fi.leading ) ;
int length = strtext.Length() ;
- /*
- const char *text = NULL ;
- wxString macText ;
- if ( wxApp::s_macDefaultEncodingIsPC )
- {
- macText = wxMacMakeMacStringFromPC( string ) ;
- text = macText ;
- length = macText.Length() ;
- }
- else
- {
- text = string ;
- length = string.Length() ;
- }
- */
+
int laststop = 0 ;
int i = 0 ;
int curwidth = 0 ;
else
#endif
{
- wxCharBuffer text = wxMacStringToCString(linetext) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
}
if ( curwidth > *width )
else
#endif
{
- wxCharBuffer text = wxMacStringToCString(linetext) ;
+ wxCharBuffer text = linetext.mb_str(wxConvLocal) ;
curwidth = ::TextWidth( text , 0 , strlen(text) ) ;
}
if ( curwidth > *width )
// return ;
Pattern blackColor ;
MacSetupBackgroundForCurrentPort(m_backgroundBrush) ;
- wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
- if ( font )
+ if ( m_font.Ok() )
{
- ::TextFont( font->m_macFontNum ) ;
- ::TextSize( short(m_scaleY * font->m_macFontSize) ) ;
- ::TextFace( font->m_macFontStyle ) ;
+ ::TextFont( m_font.GetMacFontNum() ) ;
+ ::TextSize( (short)(m_scaleY * m_font.GetMacFontSize()) ) ;
+ ::TextFace( m_font.GetMacFontStyle() ) ;
m_macFontInstalled = true ;
m_macBrushInstalled = false ;
m_macPenInstalled = false ;
}
::PenMode( mode ) ;
OSStatus status = noErr ;
- Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ;
- Style qdStyle = font->m_macFontStyle ;
- ATSUFontID atsuFont = font->m_macATSUFontID ;
+ Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.GetMacFontSize()) ) ;
+ Style qdStyle = m_font.GetMacFontStyle() ;
+ ATSUFontID atsuFont = m_font.GetMacATSUFontID() ;
status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ;
wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
ATSUAttributeTag atsuTags[] =
Pattern gPatterns[] =
{ // hatch patterns
- { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } ,
- { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } ,
- { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } ,
- { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } ,
- { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } ,
- { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } ,
- { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } ,
+ { { 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF , 0xFF } } ,
+ { { 0x01 , 0x02 , 0x04 , 0x08 , 0x10 , 0x20 , 0x40 , 0x80 } } ,
+ { { 0x80 , 0x40 , 0x20 , 0x10 , 0x08 , 0x04 , 0x02 , 0x01 } } ,
+ { { 0x10 , 0x10 , 0x10 , 0xFF , 0x10 , 0x10 , 0x10 , 0x10 } } ,
+ { { 0x00 , 0x00 , 0x00 , 0xFF , 0x00 , 0x00 , 0x00 , 0x00 } } ,
+ { { 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 , 0x10 } } ,
+ { { 0x81 , 0x42 , 0x24 , 0x18 , 0x18 , 0x24 , 0x42 , 0x81 } } ,
// dash patterns
- { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } , // DOT
- { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } , // LONG_DASH
- { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } , // SHORT_DASH
- { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } , // DOT_DASH
+ { { 0xCC , 0x99 , 0x33 , 0x66 , 0xCC , 0x99 , 0x33 , 0x66 } } , // DOT
+ { { 0xFE , 0xFD , 0xFB , 0xF7 , 0xEF , 0xDF , 0xBF , 0x7F } } , // LONG_DASH
+ { { 0xEE , 0xDD , 0xBB , 0x77 , 0xEE , 0xDD , 0xBB , 0x77 } } , // SHORT_DASH
+ { { 0xDE , 0xBD , 0x7B , 0xF6 , 0xED , 0xDB , 0xB7 , 0x6F } } , // DOT_DASH
} ;
static void wxMacGetPattern(int penStyle, Pattern *pattern)
void wxDC::MacInstallPen() const
{
wxCHECK_RET(Ok(), wxT("Invalid DC"));
- Pattern blackColor;
+ //Pattern blackColor;
// if ( m_macPenInstalled )
// return ;
RGBColor forecolor = MAC_WXCOLORREF( m_pen.GetColour().GetPixel());