X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7246375492ba068a7ef0006ce6d57ecf786fffeb..bc57786b5554a590c4a8abc9c42584fcc8e0a9eb:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 73b7aa5dc0..7129086a11 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -204,6 +204,7 @@ public : void AdjustCreationAttributes( const wxColour& background , bool visible ) ; virtual void SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) ; + virtual void SetBackground( const wxBrush &brush) ; virtual void SetStyle(long start, long end, const wxTextAttr& style) ; virtual void Copy() ; virtual void Cut() ; @@ -312,6 +313,7 @@ public : IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) + EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground ) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_CHAR(wxTextCtrl::OnChar) EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) @@ -352,14 +354,12 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, m_macIsUserPane = FALSE ; m_editable = true ; - if ( !HasFlag(wxNO_BORDER) ) - style |= wxSUNKEN_BORDER ; + if ( ! ( style & wxNO_BORDER) ) + style = ( style & ~wxBORDER_MASK) | wxSUNKEN_BORDER ; if ( !wxTextCtrlBase::Create(parent, id, pos, size, style & ~(wxHSCROLL|wxVSCROLL), validator, name) ) return FALSE; - wxSize mySize = size ; - Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; if ( m_windowStyle & wxTE_MULTILINE ) @@ -758,6 +758,14 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) } } +void wxTextCtrl::OnEraseBackground(wxEraseEvent& event) +{ + // all erasing should be done by the real mac control implementation + // 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... +} + void wxTextCtrl::OnChar(wxKeyEvent& event) { int key = event.GetKeyCode() ; @@ -1252,7 +1260,7 @@ void wxMacUnicodeTextControl::WriteText(const wxString& str) val.Remove( start , end - start ) ; val.insert( start , str ) ; SetStringValue( val ) ; - SetInsertionPoint( start + str.Length() ) ; + SetSelection( start + str.Length() , start + str.Length() ) ; #endif } @@ -1463,6 +1471,15 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo TXNSetBackground( m_txn , &tback); } +void wxMacMLTEControl::SetBackground( const wxBrush &brush ) +{ + // currently only solid background are supported + TXNBackground tback; + tback.bgType = kTXNBackgroundTypeRGB; + tback.bg.color = MAC_WXCOLORREF( brush.GetColour().GetPixel() ); + TXNSetBackground( m_txn , &tback); +} + int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttributes typeAttr[] ) { Str255 fontName = "\pMonaco" ; @@ -1492,7 +1509,6 @@ int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttribu typeAttr[attrCounter+2].size = kTXNQDFontStyleAttributeSize ; typeAttr[attrCounter+2].data.dataValue = fontStyle ; attrCounter += 3 ; - } if ( style.HasTextColour() ) { @@ -1508,7 +1524,7 @@ int wxMacMLTEControl::ConvertAttribute( const wxTextAttr& style , TXNTypeAttribu void wxMacMLTEControl::SetFont( const wxFont & font , const wxColour& foreground , long windowStyle ) { EditHelper help(m_txn) ; - wxTextAttr style(wxNullColour,wxNullColour,font) ; + wxTextAttr style(foreground,wxNullColour,font) ; TXNTypeAttributes typeAttr[4] ; int attrCounter = ConvertAttribute( style , typeAttr ) ; if ( attrCounter > 0 ) @@ -2452,6 +2468,8 @@ OSStatus wxMacMLTEClassicControl::DoCreate() #if TARGET_API_MAC_OSX +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 + wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxWindow *wxPeer, const wxString& str, const wxPoint& pos, @@ -2519,6 +2537,9 @@ bool wxMacMLTEHIViewControl::NeedsFocusRect() const return m_windowStyle & wxNO_BORDER ? false : true; } +#endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 + + #endif #endif // wxUSE_TEXTCTRL