X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fbfb8bcc3fa17e079d4219655b173f8ed2ccc65a..41ab357ed9b661d9bbc55c841420b323237dbc15:/src/mac/carbon/textctrl.cpp diff --git a/src/mac/carbon/textctrl.cpp b/src/mac/carbon/textctrl.cpp index e8d8fa060f..5e3e75e155 100644 --- a/src/mac/carbon/textctrl.cpp +++ b/src/mac/carbon/textctrl.cpp @@ -178,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; @@ -230,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 ; @@ -271,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 ; @@ -294,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) ; @@ -385,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; @@ -1060,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; @@ -1173,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() @@ -1370,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 { @@ -1638,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 ) @@ -1757,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 ) ; @@ -2555,7 +2595,7 @@ static pascal void wxMacControlUserPaneDrawProc(ControlRef control, SInt16 part) win->MacControlUserPaneDrawProc(part) ; } -static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, const Point& where) +static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control, Point where) { wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ; wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; @@ -2565,7 +2605,7 @@ static pascal ControlPartCode wxMacControlUserPaneHitTestProc(ControlRef control return kControlNoPart ; } -static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, const Point& startPt, ControlActionUPP actionProc) +static pascal ControlPartCode wxMacControlUserPaneTrackingProc(ControlRef control, Point startPt, ControlActionUPP actionProc) { wxTextCtrl *textCtrl = wxDynamicCast( wxFindControlFromMacControl(control) , wxTextCtrl ) ; wxMacMLTEClassicControl * win = textCtrl ? (wxMacMLTEClassicControl*)(textCtrl->GetPeer()) : NULL ; @@ -2816,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