X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ad604d0f8d50abf9f3a7b844f90c9a039ab0e348..f418332658bb166101c228e0ed8208787fccbf59:/src/mac/carbon/textctrl.cpp?ds=sidebyside diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index e1aad6cff3..6994913a85 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -22,6 +22,9 @@ #include "wx/dc.h" #include "wx/button.h" #include "wx/menu.h" + #include "wx/settings.h" + #include "wx/msgdlg.h" + #include "wx/toplevel.h" #endif #ifdef __DARWIN__ @@ -31,8 +34,6 @@ #include #endif -#include "wx/msgdlg.h" - #if wxUSE_STD_IOSTREAM #if wxUSE_IOSTREAMH #include @@ -41,8 +42,6 @@ #endif #endif -#include "wx/toplevel.h" -#include "wx/settings.h" #include "wx/filefn.h" #include "wx/sysopt.h" @@ -119,7 +118,7 @@ public : m_param1 = p1 ; } - ~wxMacObjectFunctor1() {} + virtual ~wxMacObjectFunctor1() {} virtual void* operator()() { @@ -178,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 ; @@ -202,7 +201,7 @@ public : virtual bool SetupCursor( const wxPoint& pt ) { return false ; } - + virtual void Clear() ; virtual bool CanUndo() const; virtual void Undo() ; @@ -306,8 +305,8 @@ public : const wxString& str, const wxPoint& pos, const wxSize& size, long style ) ; - ~wxMacMLTEHIViewControl() ; - + virtual ~wxMacMLTEHIViewControl() ; + virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; virtual bool HasFocus() const ; virtual void SetBackground( const wxBrush &brush) ; @@ -327,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 ; @@ -363,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() ; @@ -415,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) @@ -963,15 +962,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() ); @@ -1005,6 +999,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; @@ -1019,6 +1014,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) } if ( ( key >= 0x20 && key < WXK_START ) || + ( key >= WXK_NUMPAD0 && key <= WXK_DIVIDE ) || key == WXK_RETURN || key == WXK_DELETE || key == WXK_BACK) @@ -1382,7 +1378,7 @@ static pascal OSStatus wxMacUnicodeTextControlControlEventHandler( EventHandlerC OSStatus result = eventNotHandledErr ; wxMacUnicodeTextControl* focus = (wxMacUnicodeTextControl*) data ; wxMacCarbonEvent cEvent( event ) ; - + switch ( GetEventKind( event ) ) { case kEventControlSetFocusPart : @@ -1404,20 +1400,20 @@ static pascal OSStatus wxMacUnicodeTextControlControlEventHandler( EventHandlerC default: break ; } - + return result ; } static pascal OSStatus wxMacUnicodeTextControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; - + switch ( GetEventClass( event ) ) { case kEventClassControl : result = wxMacUnicodeTextControlControlEventHandler( handler , event , data ) ; break ; - + default : break ; } @@ -1539,7 +1535,7 @@ void wxMacUnicodeTextControl::GetSelection( long* from, long* to ) const verify_noerr( GetData( 0, kControlEditTextSelectionTag, &sel ) ) ; else sel = m_selection ; - + if ( from ) *from = sel.selStart ; if ( to ) @@ -1555,13 +1551,13 @@ 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)) { from = 0 ; - to = textLength ; + to = textLength ; } else { @@ -1589,6 +1585,7 @@ void wxMacUnicodeTextControl::WriteText( const wxString& str ) CFStringRef value = cf ; SetData( 0, kControlEditTextInsertCFStringRefTag, &value ); } + else #endif { wxString val = GetStringValue() ; @@ -1855,7 +1852,7 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo | kTXNSupportSpellCheckCommandUpdating | kTXNSupportFontCommandProcessing | kTXNSupportFontCommandUpdating; - + TXNSetCommandEventSupport( m_txn , options ) ; } } @@ -1881,7 +1878,7 @@ void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , lo if ( style.HasFont() ) { const wxFont &font = style.GetFont() ; - + #if 0 // old version Str255 fontName = "\pMonaco" ; SInt16 fontSize = 12 ; @@ -2209,7 +2206,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 ; @@ -2489,7 +2486,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 ; @@ -2504,9 +2500,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 ) ; } @@ -2520,9 +2513,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 ) ; } @@ -2611,13 +2601,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 ; @@ -2635,14 +2622,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 )) { @@ -3012,7 +2997,7 @@ OSStatus wxMacMLTEClassicControl::DoCreate() #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 // tiger multi-line textcontrols with no CR in the entire content -// don't scroll automatically, so we need a hack. +// don't scroll automatically, so we need a hack. // This attempt only works 'before' the key (ie before CallNextEventHandler) // is processed, thus the scrolling always occurs one character too late, but // better than nothing ... @@ -3021,12 +3006,12 @@ static const EventTypeSpec eventList[] = { { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent } , } ; - + static pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; wxMacMLTEHIViewControl* focus = (wxMacMLTEHIViewControl*) data ; - + switch ( GetEventKind( event ) ) { case kEventTextInputUnicodeForKeyEvent : @@ -3044,20 +3029,20 @@ static pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef handler default: break ; } - + return result ; } static pascal OSStatus wxMacTextControlEventHandler( EventHandlerCallRef handler , EventRef event , void *data ) { OSStatus result = eventNotHandledErr ; - + switch ( GetEventClass( event ) ) { case kEventClassTextInput : result = wxMacUnicodeTextEventHandler( handler , event , data ) ; break ; - + default : break ; }