X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/56d74412d9bc8d61c389ddb3919f2a03e610a376..41ab357ed9b661d9bbc55c841420b323237dbc15:/src/mac/carbon/textctrl.cpp?ds=sidebyside diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index 9e5abb2531..5e3e75e155 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -9,10 +9,6 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "textctrl.h" -#endif - #include "wx/wxprec.h" #if wxUSE_TEXTCTRL @@ -182,11 +178,12 @@ public : virtual bool CanPaste() const ; virtual void SetEditable(bool editable) ; virtual wxTextPos GetLastPosition() const ; - virtual void Replace( long from , long to , const wxString str ) ; - virtual void Remove( long from , long to ) = 0 ; + virtual void Replace( long from , long to , const wxString &str ) ; + virtual void Remove( long from , long to ) ; virtual void SetSelection( long from , long to ) = 0 ; virtual void GetSelection( long* from, long* to) const = 0 ; virtual void WriteText(const wxString& str) = 0 ; + virtual bool HasOwnContextMenu() const { return false ; } virtual void Clear() ; virtual bool CanUndo() const; @@ -234,12 +231,25 @@ public : virtual bool CanPaste() const ; virtual void SetEditable(bool editable) ; virtual wxTextPos GetLastPosition() const ; - virtual void Replace( long from , long to , const wxString str ) ; + virtual void Replace( long from , long to , const wxString &str ) ; virtual void Remove( long from , long to ) ; virtual void GetSelection( long* from, long* to) const ; virtual void SetSelection( long from , long to ) ; virtual void WriteText(const wxString& str) ; + virtual bool HasOwnContextMenu() const + { +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if ( UMAGetSystemVersion() >= 0x1040 ) + { + TXNCommandEventSupportOptions options ; + TXNGetCommandEventSupport( m_txn , & options ) ; + return options & kTXNSupportEditCommandProcessing ; + } +#endif + return false ; + } + virtual void Clear() ; virtual bool CanUndo() const ; @@ -275,6 +285,7 @@ public : const wxSize& size, long style ) ; virtual OSStatus SetFocus( ControlFocusPart focusPart ) ; virtual bool HasFocus() const ; + virtual void SetBackground( const wxBrush &brush) ; protected : HIViewRef m_scrollView ; HIViewRef m_textView ; @@ -298,7 +309,6 @@ public : virtual void Paste(); virtual bool CanPaste() const; virtual void SetEditable(bool editable) ; - virtual void Remove( long from , long to ) ; virtual void GetSelection( long* from, long* to) const ; virtual void SetSelection( long from , long to ) ; virtual void WriteText(const wxString& str) ; @@ -389,7 +399,7 @@ BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) END_EVENT_TABLE() // Text item -void wxTextCtrl::Init() +void wxTextCtrl::Init() { m_editable = true ; m_dirty = false; @@ -1064,6 +1074,12 @@ void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent& event) void wxTextCtrl::OnContextMenu(wxContextMenuEvent& event) { + if ( GetPeer()->HasOwnContextMenu() ) + { + event.Skip() ; + return ; + } + if (m_privateContextMenu == NULL) { m_privateContextMenu = new wxMenu; @@ -1177,8 +1193,16 @@ wxTextPos wxMacTextControl::GetLastPosition() const return GetStringValue().Length() ; } -void wxMacTextControl::Replace( long from , long to , const wxString str ) +void wxMacTextControl::Replace( long from , long to , const wxString &val ) +{ + SetSelection( from , to ) ; + WriteText( val) ; +} + +void wxMacTextControl::Remove( long from , long to ) { + SetSelection( from , to ) ; + WriteText( wxEmptyString) ; } void wxMacTextControl::Clear() @@ -1374,9 +1398,6 @@ void wxMacUnicodeTextControl::SetEditable(bool editable) { SetData( 0 , kControlEditTextLockedTag , (Boolean) !editable ) ; } -void wxMacUnicodeTextControl::Remove( long from , long to ) -{ -} void wxMacUnicodeTextControl::GetSelection( long* from, long* to) const { @@ -1389,6 +1410,11 @@ void wxMacUnicodeTextControl::GetSelection( long* from, long* to) const void wxMacUnicodeTextControl::SetSelection( long from , long to ) { ControlEditTextSelectionRec sel ; + if ((from == -1) && (to == -1)) + { + from = 0 ; + to = 32767 ; // sel has 16 bit signed values, max is 32767 + } sel.selStart = from ; sel.selEnd = to ; SetData( 0 , kControlEditTextSelectionTag, &sel ) ; @@ -1637,6 +1663,21 @@ void wxMacMLTEControl::AdjustCreationAttributes( const wxColour &background, boo tback.bgType = kTXNBackgroundTypeRGB; tback.bg.color = MAC_WXCOLORREF( background.GetPixel() ); TXNSetBackground( m_txn , &tback); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 + if ( UMAGetSystemVersion() >= 0x1040 ) + { + TXNCommandEventSupportOptions options ; + if ( TXNGetCommandEventSupport( m_txn, &options) == noErr ) + { + options |= kTXNSupportEditCommandProcessing ; + options |= kTXNSupportSpellCheckCommandProcessing ; + options |= kTXNSupportFontCommandProcessing ; + options |= kTXNSupportFontCommandUpdating ; + + TXNSetCommandEventSupport( m_txn , options ) ; + } + } +#endif } void wxMacMLTEControl::SetBackground( const wxBrush &brush ) @@ -1756,7 +1797,7 @@ wxTextPos wxMacMLTEControl::GetLastPosition() const return actualsize ; } -void wxMacMLTEControl::Replace( long from , long to , const wxString str ) +void wxMacMLTEControl::Replace( long from , long to , const wxString &str ) { wxString value = str ; wxMacConvertNewlines10To13( &value ) ; @@ -2762,7 +2803,8 @@ wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl *wxPeer, wxString st = str ; wxMacConvertNewlines10To13( &st ) ; - HIRect hr = { bounds.left , bounds.top , bounds.right - bounds.left , bounds.bottom- bounds.top } ; + HIRect hr = { { bounds.left , bounds.top} , + { bounds.right - bounds.left , bounds.bottom - bounds.top} } ; m_scrollView = NULL ; TXNFrameOptions frameOptions = FrameOptionsFromWXStyle( style ) ; @@ -2814,6 +2856,25 @@ bool wxMacMLTEHIViewControl::HasFocus() const return control == m_textView ; } +void wxMacMLTEHIViewControl::SetBackground( const wxBrush &brush ) +{ + wxMacMLTEControl::SetBackground( brush ) ; +/* + CGColorSpaceRef rgbSpace = CGColorSpaceCreateDeviceRGB(); + RGBColor col = MAC_WXCOLORREF(brush.GetColour().GetPixel()) ; + + float component[4] ; + component[0] = col.red / 65536.0 ; + component[1] = col.green / 65536.0 ; + component[2] = col.blue / 65536.0 ; + component[3] = 1.0 ; // alpha + + CGColorRef color = CGColorCreate (rgbSpace , component ); + HITextViewSetBackgroundColor( m_textView , color ) ; + CGColorSpaceRelease( rgbSpace ); +*/ +} + #endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2