X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/787f0fc4f3eb08f1065d86e44ace8d7453e1b1b3..5c7b506103cfc078a821860766e31c47d595e07f:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 46c842a1a7..79c591439c 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 @@ -440,7 +486,7 @@ void wxTextCtrl::MacSuperChangedPosition() void wxTextCtrl::MacVisibilityChanged() { - GetPeer()->VisibilityChanged( MacIsReallyShown() ) ; + GetPeer()->VisibilityChanged( GetPeer()->IsVisible() ); } void wxTextCtrl::MacCheckSpelling(bool check) @@ -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 ); } @@ -1766,11 +1812,12 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo TXNTab* tabs = NULL; bool relayout = false; + wxFont font ; if ( style.HasFont() ) { wxASSERT( typeAttrCount < WXSIZEOF(typeAttr) ); - const wxFont &font = style.GetFont() ; + font = style.GetFont() ; typeAttr[typeAttrCount].tag = kTXNATSUIStyle ; typeAttr[typeAttrCount].size = kTXNATSUIStyleSize ; typeAttr[typeAttrCount].data.dataPtr = font.MacGetATSUStyle() ; @@ -2258,51 +2305,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 .... -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 ) ; -} - TXNScrollInfoUPP gTXNScrollInfoProc = NULL ; ControlActionUPP gTXNScrollActionProc = NULL ; @@ -2561,7 +2563,7 @@ void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16 WXUNUSED(thePar if ( textctrl == NULL ) return ; - if ( textctrl->MacIsReallyShown() ) + if ( textctrl->IsShownOnScreen() ) { wxMacWindowClipper clipper( textctrl ) ; TXNDraw( m_txn , NULL ) ; @@ -2574,7 +2576,7 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt1 ControlPartCode result = kControlNoPart; wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef ); - if ( (textctrl != NULL) && textctrl->MacIsReallyShown() ) + if ( (textctrl != NULL) && textctrl->IsShownOnScreen() ) { if (PtInRect( where, &m_txnControlBounds )) { @@ -2601,7 +2603,7 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x, wxIn ControlPartCode result = kControlNoPart; wxTextCtrl* textctrl = (wxTextCtrl*) GetControlReference( m_controlRef ); - if ( (textctrl != NULL) && textctrl->MacIsReallyShown() ) + if ( (textctrl != NULL) && textctrl->IsShownOnScreen() ) { Point startPt = { y , x } ; @@ -2637,7 +2639,7 @@ void wxMacMLTEClassicControl::MacControlUserPaneIdleProc() if ( textctrl == NULL ) return ; - if (textctrl->MacIsReallyShown()) + if (textctrl->IsShownOnScreen()) { if (IsControlActive(m_controlRef)) { @@ -2743,7 +2745,7 @@ wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl *wxPeer, AdjustCreationAttributes( *wxWHITE , true ) ; - MacSetObjectVisibility( wxPeer->MacIsReallyShown() ) ; + MacSetObjectVisibility( wxPeer->IsShownOnScreen() ) ; { wxString st = str ; @@ -3031,7 +3033,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) ) {