+ iControlData[1].uValue =
+ (m_windowStyle & wxTE_DONTWRAP)
+ ? kTXNNoAutoWrap
+ : kTXNAutoWrap;
+ }
+
+ OSStatus err = TXNSetTXNObjectControls( m_txn, false, toptag, iControlTags, iControlData ) ;
+ verify_noerr( err );
+
+ // setting the default font:
+ // under 10.2 this causes a visible caret, therefore we avoid it
+
+ Str255 fontName ;
+ SInt16 fontSize ;
+ Style fontStyle ;
+
+ GetThemeFont( kThemeSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+
+ TXNTypeAttributes typeAttr[] =
+ {
+ { kTXNQDFontNameAttribute , kTXNQDFontNameAttributeSize , { (void*) fontName } } ,
+ { kTXNQDFontSizeAttribute , kTXNFontSizeAttributeSize , { (void*) (fontSize << 16) } } ,
+ { kTXNQDFontStyleAttribute , kTXNQDFontStyleAttributeSize , { (void*) normal } } ,
+ } ;
+
+ err = TXNSetTypeAttributes(
+ m_txn, sizeof(typeAttr) / sizeof(TXNTypeAttributes),
+ typeAttr, kTXNStartOffset, kTXNEndOffset );
+ verify_noerr( err );
+
+ if ( m_windowStyle & wxTE_PASSWORD )
+ {
+ UniChar c = 0x00A5 ;
+ err = TXNEchoMode( m_txn , c , 0 , true );
+ verify_noerr( err );
+ }
+
+ TXNBackground tback;
+ tback.bgType = kTXNBackgroundTypeRGB;
+ background.GetRGBColor( &tback.bg.color );
+ TXNSetBackground( m_txn , &tback );
+
+
+ TXNCommandEventSupportOptions options ;
+ if ( TXNGetCommandEventSupport( m_txn, &options ) == noErr )
+ {
+ options |=
+ kTXNSupportEditCommandProcessing
+ | kTXNSupportEditCommandUpdating
+ | kTXNSupportFontCommandProcessing
+ | kTXNSupportFontCommandUpdating;
+
+ // only spell check when not read-only
+ // use system options for the default
+ bool checkSpelling = false ;
+ if ( !(m_windowStyle & wxTE_READONLY) )
+ {
+#if wxUSE_SYSTEM_OPTIONS
+ if ( wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER ) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER ) == 1) )
+ {
+ checkSpelling = true ;
+ }
+#endif
+ }
+
+ if ( checkSpelling )
+ options |=
+ kTXNSupportSpellCheckCommandProcessing
+ | kTXNSupportSpellCheckCommandUpdating;
+
+ TXNSetCommandEventSupport( m_txn , options ) ;
+ }
+}
+
+void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
+{
+ TXNBackground tback;
+ tback.bgType = kTXNBackgroundTypeRGB;
+ col.GetRGBColor(&tback.bg.color);
+ TXNSetBackground( m_txn , &tback );
+}
+
+static inline int wxConvertToTXN(int x)
+{
+ return wx_static_cast(int, x / 254.0 * 72 + 0.5);
+}
+
+void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to )
+{
+ TXNTypeAttributes typeAttr[4] ;
+ RGBColor color ;
+ size_t typeAttrCount = 0 ;
+
+ TXNMargins margins;
+ TXNControlTag controlTags[4];
+ TXNControlData controlData[4];
+ size_t controlAttrCount = 0;
+
+ TXNTab* tabs = NULL;
+
+ bool relayout = false;
+ wxFont font ;
+
+ if ( style.HasFont() )
+ {
+ wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) );
+ font = style.GetFont() ;
+ typeAttr[typeAttrCount].tag = kTXNATSUIStyle ;
+ typeAttr[typeAttrCount].size = kTXNATSUIStyleSize ;
+ typeAttr[typeAttrCount].data.dataPtr = font.MacGetATSUStyle() ;
+ typeAttrCount++ ;
+ }
+
+ if ( style.HasTextColour() )
+ {
+ wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) );
+ style.GetTextColour().GetRGBColor( &color );
+ typeAttr[typeAttrCount].tag = kTXNQDFontColorAttribute ;
+ typeAttr[typeAttrCount].size = kTXNQDFontColorAttributeSize ;
+ typeAttr[typeAttrCount].data.dataPtr = (void*) &color ;
+ typeAttrCount++ ;