virtual wxString GetStringValue() const ;
virtual void SetStringValue( const wxString &str) ;
- static int ConvertAttribute( const wxTextAttr& style , TXNTypeAttributes attr[] ) ;
static TXNFrameOptions FrameOptionsFromWXStyle( long wxStyle ) ;
void AdjustCreationAttributes( const wxColour& background , bool visible ) ;
void SetTXNData( const wxString& st , TXNOffset start , TXNOffset end ) ;
protected :
+ void TXNSetAttribute( const wxTextAttr& style , long from , long to ) ;
TXNObject m_txn ;
} ;
const wxSize& size, long style ) ;
virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
virtual bool HasFocus() const ;
- virtual bool NeedsFocusRect() const ;
+ virtual bool NeedsFocusRect() const;
protected :
HIViewRef m_scrollView ;
HIViewRef m_textView ;
const wxSize& size, long style ) ;
~wxMacMLTEClassicControl() ;
virtual void VisibilityChanged(bool shown) ;
+ virtual bool NeedsFocusRect() const;
protected :
OSStatus DoCreate();
public :
{
// this control draws the border itself
if ( !HasFlag(wxNO_BORDER) )
+ {
m_windowStyle &= ~wxSUNKEN_BORDER ;
+ bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+ }
m_peer = new wxMacMLTEClassicControl( this , str , pos , size , style ) ;
}
return ;
GetPeer()->SetStringValue(str) ;
+
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
+ event.SetString( GetValue() ) ;
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(event);
}
void wxTextCtrl::SetMaxLength(unsigned long len)
GetPeer()->Cut() ;
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event.SetString( GetValue() ) ;
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
// eventually we should add setting the default style again
wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event.SetString( GetValue() ) ;
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
}
// while this is true for MLTE under classic, the HITextView is somehow
// transparent but background erase is not working correctly, so intercept
// things while we can...
+ event.Skip() ;
}
void wxTextCtrl::OnChar(wxKeyEvent& event)
return ;
}
+ // Check if we have reached the max # of chars, but still allow navigation and deletion
+ if ( !IsMultiLine() && GetValue().Length() >= m_maxLength &&
+ key != WXK_LEFT && key != WXK_RIGHT && key != WXK_TAB &&
+ key != WXK_BACK && !( key == WXK_RETURN && (m_windowStyle & wxPROCESS_ENTER) )
+ )
+ {
+ // eat it, we don't want to add more than allowed # of characters
+ return;
+ }
+
// assume that any key not processed yet is going to modify the control
m_dirty = true;
key == WXK_BACK)
{
wxCommandEvent event1(wxEVT_COMMAND_TEXT_UPDATED, m_windowId);
- event1.SetString( GetValue() ) ;
event1.SetEventObject( this );
wxPostEvent(GetEventHandler(),event1);
}
m_windowStyle = style ;
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
+ wxMacConvertNewlines10To13( &st ) ;
wxMacCFStringHolder cf(st , m_font.GetEncoding()) ;
CFStringRef cfr = cf ;
Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
wxMacCFStringHolder cf(value) ;
result = cf.AsString() ;
}
+#if '\n' == 10
+ wxMacConvertNewlines13To10( &result ) ;
+#else
wxMacConvertNewlines10To13( &result ) ;
+#endif
return result ;
}
void wxMacUnicodeTextControl::SetStringValue( const wxString &str)
{
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
+ wxMacConvertNewlines10To13( &st ) ;
wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
}
void wxMacUnicodeTextControl::WriteText(const wxString& str)
{
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
+ wxMacConvertNewlines10To13( &st ) ;
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ;
CFStringRef value = cf ;
}
#endif
}
+#if '\n' == 10
+ wxMacConvertNewlines13To10( &result ) ;
+#else
wxMacConvertNewlines10To13( &result ) ;
+#endif
return result ;
}
void wxMacMLTEControl::SetStringValue( const wxString &str)
{
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
+
+ wxMacConvertNewlines10To13( &st ) ;
EditHelper help(m_txn) ;
// wxMacWindowClipper c( this ) ;
TXNSetBackground( m_txn , &tback);
}
-int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttributes typeAttr[] )
+void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to)
{
+ TXNTypeAttributes typeAttr[4] ;
Str255 fontName = "\pMonaco" ;
SInt16 fontSize = 12 ;
Style fontStyle = normal ;
fontStyle |= bold ;
if ( font.GetStyle() == wxITALIC )
fontStyle |= italic ;
-
+
typeAttr[attrCounter].tag = kTXNQDFontNameAttribute ;
typeAttr[attrCounter].size = kTXNQDFontNameAttributeSize ;
typeAttr[attrCounter].data.dataPtr = (void*) fontName ;
color = MAC_WXCOLORREF(style.GetTextColour().GetPixel()) ;
attrCounter += 1 ;
}
- return attrCounter ;
+ if ( attrCounter > 0 )
+ {
+ verify_noerr( TXNSetTypeAttributes ( m_txn , attrCounter , typeAttr, from , to) );
+ }
}
void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle )
{
EditHelper help(m_txn) ;
- wxTextAttr style(foreground,wxNullColour,font) ;
- TXNTypeAttributes typeAttr[4] ;
- int attrCounter = ConvertAttribute( style , typeAttr ) ;
- if ( attrCounter > 0 )
- {
- verify_noerr( TXNSetTypeAttributes ( m_txn , attrCounter , typeAttr, kTXNStartOffset,kTXNEndOffset) );
- }
+ TXNSetAttribute( wxTextAttr(foreground,wxNullColour,font) , kTXNStartOffset,kTXNEndOffset ) ;
}
void wxMacMLTEControl::SetStyle(long start, long end, const wxTextAttr& style)
{
EditHelper help(m_txn) ;
- TXNTypeAttributes typeAttr[4] ;
- int attrCounter = ConvertAttribute( style , typeAttr ) ;
- if ( attrCounter > 0 )
- {
- verify_noerr( TXNSetTypeAttributes ( m_txn , attrCounter , typeAttr, start,end) );
- }
+ TXNSetAttribute( style , start,end ) ;
}
void wxMacMLTEControl::Copy()
void wxMacMLTEControl::Replace( long from , long to , const wxString str )
{
wxString value = str ;
- wxMacConvertNewlines13To10( &value ) ;
+ wxMacConvertNewlines10To13( &value ) ;
EditHelper help( m_txn ) ;
TXNSetSelection(m_txn , from , to ) ;
TXNClear( m_txn ) ;
- SetTXNData( str , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
+ SetTXNData( value , kTXNUseCurrentSelection, kTXNUseCurrentSelection ) ;
}
void wxMacMLTEControl::Remove( long from , long to )
{
EditHelper helper( m_txn ) ;
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
+ wxMacConvertNewlines10To13( &st ) ;
long start , end , dummy ;
GetSelection( &start , &dummy ) ;
currentHeight += lineHeight;
}
- Point thePoint = { firstPoint.v + Fix2Long(currentHeight), firstPoint.h + Fix2Long(0) };
+ Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) };
TXNOffset theOffset;
TXNPointToOffset(m_txn, thePoint, &theOffset);
currentHeight += lineHeight;
}
- Point thePoint = { firstPoint.v + Fix2Long(currentHeight), firstPoint.h + Fix2Long(0) };
+ Point thePoint = { firstPoint.v + (currentHeight >> 16), firstPoint.h + (0) };
TXNOffset theOffset;
TXNPointToOffset(m_txn, thePoint, &theOffset);
OSStatus MLTESetObjectVisibility( STPTextPaneVars *varsp, Boolean vis , long wxStyle)
{
OSStatus err = noErr ;
-#if TARGET_API_MAC_OSX
- TXNControlTag iControlTags[1] = { kTXNVisibilityTag };
- TXNControlData iControlData[1] = {{ vis }};
- err = ::TXNSetTXNObjectControls( varsp->fTXNRec, false, 1, iControlTags, iControlData );
-#endif
wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference(varsp->fUserPaneRec);
- if ( vis && textctrl )
+ if ( textctrl )
{
+#if TARGET_API_MAC_OSX
+ TXNControlTag iControlTags[1] = { kTXNVisibilityTag };
+ TXNControlData iControlData[1] = {{ vis }};
+ err = ::TXNSetTXNObjectControls( varsp->fTXNRec, false, 1, iControlTags, iControlData );
+#endif
Rect bounds ;
UMAGetControlBoundsInWindowCoords( varsp->fUserPaneRec, &bounds);
TPCalculateBounds( varsp , bounds ) ;
- wxMacWindowClipper cl(textctrl) ;
- TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left,
- varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame);
- TXNShowSelection( varsp->fTXNRec, kTXNShowStart);
+ if ( vis )
+ {
+ wxMacWindowClipper cl(textctrl) ;
+ TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top, varsp->fRTextArea.left,
+ varsp->fRTextArea.bottom, varsp->fRTextArea.right, varsp->fTXNFrame);
+ TXNShowSelection( varsp->fTXNRec, kTXNShowStart);
+ }
+ else
+ {
+#if TARGET_API_MAC_OSX
+ // in 10.2 the scrollbars are still actively redrawn when using only the code above
+ if ( UMAGetSystemVersion() < 0x1030 )
+ {
+ TXNSetFrameBounds( varsp->fTXNRec, varsp->fRTextArea.top + 20000 , varsp->fRTextArea.left + 20000 ,
+ varsp->fRTextArea.bottom + 20000 , varsp->fRTextArea.right + 20000 , varsp->fTXNFrame);
+
+ }
+#endif
+ }
}
return err ;
}
if (varsp->fFocusDrawState != (varsp->fIsActive && varsp->fInFocus))
{
varsp->fFocusDrawState = (varsp->fIsActive && varsp->fInFocus);
- DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState);
+ // DrawThemeFocusRect(&varsp->fRFocusOutline, varsp->fFocusDrawState);
}
}
m_windowStyle = style ;
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
-
- wxMacConvertNewlines13To10( &st ) ;
+ wxMacConvertNewlines10To13( &st ) ;
short featurSet;
InvalWindowRect( GetControlOwner( m_controlRef ) , &((STPTextPaneVars *)m_macTXNvars)->fRBounds ) ;
}
+bool wxMacMLTEClassicControl::NeedsFocusRect() const
+{
+ return true;
+}
+
OSStatus wxMacMLTEClassicControl::DoCreate()
{
Rect bounds;
m_windowStyle = style ;
Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ;
wxString st = str ;
- wxMacConvertNewlines13To10( &st ) ;
+ wxMacConvertNewlines10To13( &st ) ;
HIRect hr = { bounds.left , bounds.top , bounds.right - bounds.left , bounds.bottom- bounds.top } ;