X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fce161de8adea84b608dd8b19afb72c5493a7969..b48f51ca745c5d3dfd704947812bbea90a44a1eb:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 93c0feae07..3ee3663952 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -24,6 +24,7 @@ #include "wx/menu.h" #include "wx/settings.h" #include "wx/msgdlg.h" + #include "wx/toplevel.h" #endif #ifdef __DARWIN__ @@ -41,7 +42,6 @@ #endif #endif -#include "wx/toplevel.h" #include "wx/filefn.h" #include "wx/sysopt.h" @@ -118,7 +118,7 @@ public : m_param1 = p1 ; } - ~wxMacObjectFunctor1() {} + virtual ~wxMacObjectFunctor1() {} virtual void* operator()() { @@ -177,7 +177,7 @@ class wxMacTextControl : public wxMacControl { public : wxMacTextControl( wxTextCtrl *peer ) ; - ~wxMacTextControl() ; + virtual ~wxMacTextControl() ; virtual wxString GetStringValue() const = 0 ; virtual void SetStringValue( const wxString &val ) = 0 ; @@ -305,7 +305,7 @@ public : const wxString& str, const wxPoint& pos, const wxSize& size, long style ) ; - ~wxMacMLTEHIViewControl() ; + virtual ~wxMacMLTEHIViewControl() ; virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; virtual bool HasFocus() const ; @@ -326,7 +326,7 @@ public : const wxString& str, const wxPoint& pos, const wxSize& size, long style ) ; - ~wxMacUnicodeTextControl(); + virtual ~wxMacUnicodeTextControl(); virtual void VisibilityChanged(bool shown); virtual wxString GetStringValue() const ; @@ -362,7 +362,7 @@ public : const wxString& str, const wxPoint& pos, const wxSize& size, long style ) ; - ~wxMacMLTEClassicControl() ; + virtual ~wxMacMLTEClassicControl() ; virtual void VisibilityChanged(bool shown) ; virtual void SuperChangedPosition() ; @@ -414,9 +414,9 @@ private : }; -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxTextCtrlBase) -BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) +BEGIN_EVENT_TABLE(wxTextCtrl, wxTextCtrlBase) EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground ) EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_CHAR(wxTextCtrl::OnChar) @@ -475,10 +475,7 @@ bool wxTextCtrl::Create( wxWindow *parent, if ( m_windowStyle & wxTE_MULTILINE ) { - wxASSERT_MSG( - !(m_windowStyle & wxTE_PROCESS_ENTER), - wxT("wxTE_PROCESS_ENTER style is ignored for multiline text controls (they always process it)") ); - + // always turn on this style for multi-line controls m_windowStyle |= wxTE_PROCESS_ENTER; style |= wxTE_PROCESS_ENTER ; } @@ -708,11 +705,6 @@ void wxTextCtrl::SetSelection(long from, long to) GetPeer()->SetSelection( from , to ) ; } -bool wxTextCtrl::LoadFile(const wxString& file) -{ - return wxTextCtrlBase::LoadFile( file ); -} - void wxTextCtrl::WriteText(const wxString& str) { // TODO: this MPRemoting will be moved into a remoting peer proxy for any command @@ -962,15 +954,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) if ( !(m_windowStyle & wxTE_MULTILINE) ) { - wxWindow *parent = GetParent(); - while ( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) - { - parent = parent->GetParent() ; - } - - if ( parent && parent->GetDefaultItem() ) + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); + if ( tlw && tlw->GetDefaultItem() ) { - wxButton *def = wxDynamicCast(parent->GetDefaultItem(), wxButton); + wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); if ( def && def->IsEnabled() ) { wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); @@ -1004,6 +991,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) // This is necessary (don't know why); // otherwise the tab will not be inserted. WriteText(wxT("\t")); + eat_key = true; } break; @@ -1555,7 +1543,7 @@ void wxMacUnicodeTextControl::SetSelection( long from , long to ) if ( value ) { wxMacCFStringHolder cf(value) ; - textLength = cf.AsString().Length() ; + textLength = cf.AsString().length() ; } if ((from == -1) && (to == -1)) @@ -2210,7 +2198,7 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse { #if wxUSE_UNICODE #if SIZEOF_WCHAR_T == 2 - size_t len = st.Len() ; + size_t len = st.length() ; TXNSetData( m_txn, kTXNUnicodeTextData, (void*)st.wc_str(), len * 2, start, end ); #else wxMBConvUTF16 converter ; @@ -2490,7 +2478,6 @@ void wxMacMLTEClassicControl::MacUpdatePosition() wxMacWindowClipper cl( textctrl ) ; #ifdef __WXMAC_OSX__ - bool isCompositing = textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ; if ( m_sbHorizontal || m_sbVertical ) { int w = bounds.right - bounds.left ; @@ -2505,9 +2492,6 @@ void wxMacMLTEClassicControl::MacUpdatePosition() sbBounds.right = w + 1 ; sbBounds.bottom = h + 1 ; - if ( !isCompositing ) - OffsetRect( &sbBounds , m_txnControlBounds.left , m_txnControlBounds.top ) ; - SetControlBounds( m_sbHorizontal , &sbBounds ) ; SetControlViewSize( m_sbHorizontal , w ) ; } @@ -2521,9 +2505,6 @@ void wxMacMLTEClassicControl::MacUpdatePosition() sbBounds.right = w + 1 ; sbBounds.bottom = m_sbHorizontal ? h - 14 : h + 1 ; - if ( !isCompositing ) - OffsetRect( &sbBounds , m_txnControlBounds.left , m_txnControlBounds.top ) ; - SetControlBounds( m_sbVertical , &sbBounds ) ; SetControlViewSize( m_sbVertical , h ) ; } @@ -2612,13 +2593,10 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x, wxInt1 else { // sometimes we get the coords also in control local coordinates, therefore test again - if ( textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ) - { - int x = 0 , y = 0 ; - textctrl->MacClientToRootWindow( &x , &y ) ; - where.h += x ; - where.v += y ; - } + int x = 0 , y = 0 ; + textctrl->MacClientToRootWindow( &x , &y ) ; + where.h += x ; + where.v += y ; if (PtInRect( where, &m_txnControlBounds )) result = kControlEditTextPart ; @@ -2636,14 +2614,12 @@ wxInt16 wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x, wxIn if ( (textctrl != NULL) && textctrl->MacIsReallyShown() ) { Point startPt = { y , x } ; + // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them - if ( textctrl->MacGetTopLevelWindow()->MacUsesCompositing() ) - { - int x = 0 , y = 0 ; - textctrl->MacClientToRootWindow( &x , &y ) ; - startPt.h += x ; - startPt.v += y ; - } + int x = 0 , y = 0 ; + textctrl->MacClientToRootWindow( &x , &y ) ; + startPt.h += x ; + startPt.v += y ; switch (MacControlUserPaneHitTestProc( startPt.h , startPt.v )) {