X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a0a2b5c41c8448c478e05b7819b4c173c22c46a8..bbd92d1dbea02db8c28e9c17bfacc0563d855b25:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index f0c765b9cb..a8bcfbdef9 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -44,6 +44,7 @@ #include "wx/filefn.h" #include "wx/sysopt.h" +#include "wx/thread.h" #include "wx/mac/uma.h" #include "wx/mac/carbon/private/mactext.h" @@ -170,6 +171,51 @@ private: RgnHandle m_newClip; }; +wxMacPortSaver::wxMacPortSaver( GrafPtr port ) +{ + ::GetPort( &m_port ); + ::SetPort( port ); +} + +wxMacPortSaver::~wxMacPortSaver() +{ + ::SetPort( m_port ); +} + +wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) : +wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ) +{ + m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ; + m_formerClip = NewRgn() ; + m_newClip = NewRgn() ; + GetClip( m_formerClip ) ; + + if ( win ) + { + // guard against half constructed objects, this just leads to a empty clip + if ( win->GetPeer() ) + { + int x = 0 , y = 0; + win->MacWindowToRootWindow( &x, &y ) ; + + // get area including focus rect + HIShapeGetAsQDRgn( ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ); + if ( !EmptyRgn( m_newClip ) ) + OffsetRgn( m_newClip , x , y ) ; + } + + SetClip( m_newClip ) ; + } +} + +wxMacWindowClipper::~wxMacWindowClipper() +{ + SetPort( m_newPort ) ; + SetClip( m_formerClip ) ; + DisposeRgn( m_newClip ) ; + DisposeRgn( m_formerClip ) ; +} + // common parts for implementations based on MLTE class wxMacMLTEControl : public wxMacTextControl @@ -412,7 +458,7 @@ void wxTextCtrl::CreatePeer( if ( !forceMLTE ) { - if ( m_windowStyle & wxTE_MULTILINE ) + if ( m_windowStyle & wxTE_MULTILINE || ( UMAGetSystemVersion() >= 0x1050 ) ) m_peer = new wxMacMLTEHIViewControl( this , str , pos , size , style ) ; } @@ -518,7 +564,7 @@ void wxTextCtrl::Cut() wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId ); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); + HandleWindowEvent( event ); } } @@ -532,7 +578,7 @@ void wxTextCtrl::Paste() wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId ); event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); + HandleWindowEvent( event ); } } @@ -847,7 +893,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); event.SetEventObject( this ); event.SetString( GetValue() ); - if ( GetEventHandler()->ProcessEvent(event) ) + if ( HandleWindowEvent(event) ) return; } @@ -1293,7 +1339,7 @@ bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer, Rect bounds = wxMacGetBoundsForControl( wxPeer , pos , size ) ; wxString st = str ; wxMacConvertNewlines10To13( &st ) ; - wxMacCFStringHolder cf(st , m_font.GetEncoding()) ; + wxCFStringRef cf(st , m_font.GetEncoding()) ; CFStringRef cfr = cf ; m_valueTag = kControlEditTextCFStringTag ; @@ -1337,7 +1383,7 @@ wxString wxMacUnicodeTextControl::GetStringValue() const CFStringRef value = GetData(0, m_valueTag) ; if ( value ) { - wxMacCFStringHolder cf(value) ; + wxCFStringRef cf(value) ; result = cf.AsString() ; } @@ -1354,7 +1400,7 @@ void wxMacUnicodeTextControl::SetStringValue( const wxString &str ) { wxString st = str ; wxMacConvertNewlines10To13( &st ) ; - wxMacCFStringHolder cf( st , m_font.GetEncoding() ) ; + wxCFStringRef cf( st , m_font.GetEncoding() ) ; verify_noerr( SetData( 0, m_valueTag , cf ) ) ; } @@ -1420,7 +1466,7 @@ void wxMacUnicodeTextControl::SetSelection( long from , long to ) CFStringRef value = GetData(0, m_valueTag) ; if ( value ) { - wxMacCFStringHolder cf(value) ; + wxCFStringRef cf(value) ; textLength = cf.AsString().length() ; } @@ -1453,7 +1499,7 @@ void wxMacUnicodeTextControl::WriteText( const wxString& str ) if ( HasFocus() ) { - wxMacCFStringHolder cf(st , m_font.GetEncoding() ) ; + wxCFStringRef cf(st , m_font.GetEncoding() ) ; CFStringRef value = cf ; SetData( 0, kControlEditTextInsertCFStringRefTag, &value ); } @@ -1625,7 +1671,8 @@ TXNFrameOptions wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle ) if ( wxStyle & wxTE_MULTILINE ) { - frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ; + if ( ! (wxStyle & wxTE_DONTWRAP ) ) + frameOptions |= kTXNAlwaysWrapAtViewEdgeMask ; if ( !(wxStyle & wxTE_NO_VSCROLL) ) { @@ -2257,40 +2304,6 @@ int wxMacMLTEControl::GetLineLength(long lineNo) const // while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is // no way out, therefore we are using our own implementation and our own scrollbars .... -wxMacWindowClipper::wxMacWindowClipper( const wxWindow* win ) : - wxMacPortSaver( (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ) -{ - m_newPort = (GrafPtr) GetWindowPort( (WindowRef) win->MacGetTopLevelWindowRef() ) ; - m_formerClip = NewRgn() ; - m_newClip = NewRgn() ; - GetClip( m_formerClip ) ; - - if ( win ) - { - // guard against half constructed objects, this just leads to a empty clip - if ( win->GetPeer() ) - { - int x = 0 , y = 0; - win->MacWindowToRootWindow( &x, &y ) ; - - // get area including focus rect - HIShapeGetAsQDRgn( ((wxWindow*)win)->MacGetVisibleRegion(true).GetWXHRGN() , m_newClip ); - if ( !EmptyRgn( m_newClip ) ) - OffsetRgn( m_newClip , x , y ) ; - } - - SetClip( m_newClip ) ; - } -} - -wxMacWindowClipper::~wxMacWindowClipper() -{ - SetPort( m_newPort ) ; - SetClip( m_formerClip ) ; - DisposeRgn( m_newClip ) ; - DisposeRgn( m_formerClip ) ; -} - TXNScrollInfoUPP gTXNScrollInfoProc = NULL ; ControlActionUPP gTXNScrollActionProc = NULL ; @@ -3019,7 +3032,7 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer, m_scrollView = NULL ; TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ; - if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || !(frameOptions &kTXNSingleLineOnlyMask)) + if (( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask)) || (frameOptions &kTXNSingleLineOnlyMask)) { if ( frameOptions & (kTXNWantVScrollBarMask | kTXNWantHScrollBarMask) ) {