1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mac/carbon/textctrl.cpp
4 // Author: Stefan Csomor
5 // Modified by: Ryan Norton (MLTE GetLineLength and GetLineText)
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/textctrl.h"
23 #include "wx/button.h"
25 #include "wx/settings.h"
26 #include "wx/msgdlg.h"
27 #include "wx/toplevel.h"
31 #include <sys/types.h>
37 #if wxUSE_STD_IOSTREAM
45 #include "wx/filefn.h"
46 #include "wx/sysopt.h"
48 #if defined(__BORLANDC__) && !defined(__WIN32__)
50 #elif !defined(__MWERKS__) && !defined(__GNUWIN32) && !defined(__DARWIN__)
59 #include <MacTextEditor.h>
60 #include <ATSUnicode.h>
61 #include <TextCommon.h>
62 #include <TextEncodingConverter.h>
65 #include "wx/mac/uma.h"
70 kTXNVisibilityTag
= 'visb' // set the visibility state of the object
79 virtual ~wxMacFunctor() {}
81 virtual void* operator()() = 0 ;
83 static void* CallBackProc( void *param
)
85 wxMacFunctor
* f
= (wxMacFunctor
*) param
;
86 void *result
= (*f
)() ;
91 template<typename classtype
, typename param1type
>
93 class wxMacObjectFunctor1
: public wxMacFunctor
95 typedef void (classtype::*function
)( param1type p1
) ;
96 typedef void (classtype::*ref_function
)( const param1type
& p1
) ;
98 wxMacObjectFunctor1( classtype
*obj
, function f
, param1type p1
) :
106 wxMacObjectFunctor1( classtype
*obj
, ref_function f
, param1type p1
) :
114 virtual ~wxMacObjectFunctor1() {}
116 virtual void* operator()()
118 (m_object
->*m_function
)( m_param1
) ;
123 classtype
* m_object
;
124 param1type m_param1
;
127 function m_function
;
128 ref_function m_refFunction
;
132 template<typename classtype
, typename param1type
>
133 void* wxMacMPRemoteCall( classtype
*object
, void (classtype::*function
)( param1type p1
) , param1type p1
)
135 wxMacObjectFunctor1
<classtype
, param1type
> params(object
, function
, p1
) ;
137 MPRemoteCall( wxMacFunctor::CallBackProc
, ¶ms
, kMPOwningProcessRemoteContext
) ;
141 template<typename classtype
, typename param1type
>
142 void* wxMacMPRemoteCall( classtype
*object
, void (classtype::*function
)( const param1type
& p1
) , param1type p1
)
144 wxMacObjectFunctor1
<classtype
,param1type
> params(object
, function
, p1
) ;
146 MPRemoteCall( wxMacFunctor::CallBackProc
, ¶ms
, kMPOwningProcessRemoteContext
) ;
150 template<typename classtype
, typename param1type
>
151 void* wxMacMPRemoteGUICall( classtype
*object
, void (classtype::*function
)( param1type p1
) , param1type p1
)
154 void *result
= wxMacMPRemoteCall( object
, function
, p1
) ;
159 template<typename classtype
, typename param1type
>
160 void* wxMacMPRemoteGUICall( classtype
*object
, void (classtype::*function
)( const param1type
& p1
) , param1type p1
)
163 void *result
= wxMacMPRemoteCall( object
, function
, p1
) ;
168 // common interface for all implementations
169 class wxMacTextControl
: public wxMacControl
172 wxMacTextControl( wxTextCtrl
*peer
) ;
173 virtual ~wxMacTextControl() ;
175 virtual wxString
GetStringValue() const = 0 ;
176 virtual void SetStringValue( const wxString
&val
) = 0 ;
177 virtual void SetSelection( long from
, long to
) = 0 ;
178 virtual void GetSelection( long* from
, long* to
) const = 0 ;
179 virtual void WriteText( const wxString
& str
) = 0 ;
181 virtual void SetStyle( long start
, long end
, const wxTextAttr
& style
) ;
182 virtual void Copy() ;
184 virtual void Paste() ;
185 virtual bool CanPaste() const ;
186 virtual void SetEditable( bool editable
) ;
187 virtual wxTextPos
GetLastPosition() const ;
188 virtual void Replace( long from
, long to
, const wxString
&str
) ;
189 virtual void Remove( long from
, long to
) ;
192 virtual bool HasOwnContextMenu() const
195 virtual bool SetupCursor( const wxPoint
& pt
)
198 virtual void Clear() ;
199 virtual bool CanUndo() const;
200 virtual void Undo() ;
201 virtual bool CanRedo() const;
202 virtual void Redo() ;
203 virtual int GetNumberOfLines() const ;
204 virtual long XYToPosition(long x
, long y
) const;
205 virtual bool PositionToXY(long pos
, long *x
, long *y
) const ;
206 virtual void ShowPosition(long WXUNUSED(pos
)) ;
207 virtual int GetLineLength(long lineNo
) const ;
208 virtual wxString
GetLineText(long lineNo
) const ;
210 #ifndef __WXMAC_OSX__
211 virtual void MacControlUserPaneDrawProc(wxInt16 part
) = 0 ;
212 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) = 0 ;
213 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) = 0 ;
214 virtual void MacControlUserPaneIdleProc() = 0 ;
215 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) = 0 ;
216 virtual void MacControlUserPaneActivateProc(bool activating
) = 0 ;
217 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) = 0 ;
218 virtual void MacControlUserPaneBackgroundProc(void* info
) = 0 ;
222 // common parts for implementations based on MLTE
224 class wxMacMLTEControl
: public wxMacTextControl
227 wxMacMLTEControl( wxTextCtrl
*peer
) ;
229 virtual wxString
GetStringValue() const ;
230 virtual void SetStringValue( const wxString
&str
) ;
232 static TXNFrameOptions
FrameOptionsFromWXStyle( long wxStyle
) ;
234 void AdjustCreationAttributes( const wxColour
& background
, bool visible
) ;
236 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
) ;
237 virtual void SetBackground( const wxBrush
&brush
) ;
238 virtual void SetStyle( long start
, long end
, const wxTextAttr
& style
) ;
239 virtual void Copy() ;
241 virtual void Paste() ;
242 virtual bool CanPaste() const ;
243 virtual void SetEditable( bool editable
) ;
244 virtual wxTextPos
GetLastPosition() const ;
245 virtual void Replace( long from
, long to
, const wxString
&str
) ;
246 virtual void Remove( long from
, long to
) ;
247 virtual void GetSelection( long* from
, long* to
) const ;
248 virtual void SetSelection( long from
, long to
) ;
250 virtual void WriteText( const wxString
& str
) ;
252 virtual bool HasOwnContextMenu() const
254 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
255 if ( UMAGetSystemVersion() >= 0x1040 )
257 TXNCommandEventSupportOptions options
;
258 TXNGetCommandEventSupport( m_txn
, & options
) ;
259 return options
& kTXNSupportEditCommandProcessing
;
266 virtual void Clear() ;
268 virtual bool CanUndo() const ;
269 virtual void Undo() ;
270 virtual bool CanRedo() const;
271 virtual void Redo() ;
272 virtual int GetNumberOfLines() const ;
273 virtual long XYToPosition(long x
, long y
) const ;
274 virtual bool PositionToXY(long pos
, long *x
, long *y
) const ;
275 virtual void ShowPosition( long pos
) ;
276 virtual int GetLineLength(long lineNo
) const ;
277 virtual wxString
GetLineText(long lineNo
) const ;
279 void SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
) ;
280 TXNObject
GetTXNObject() { return m_txn
; }
283 void TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
) ;
288 #if TARGET_API_MAC_OSX
290 // implementation available under OSX
292 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
294 class wxMacMLTEHIViewControl
: public wxMacMLTEControl
297 wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
300 const wxSize
& size
, long style
) ;
301 virtual ~wxMacMLTEHIViewControl() ;
303 virtual OSStatus
SetFocus( ControlFocusPart focusPart
) ;
304 virtual bool HasFocus() const ;
305 virtual void SetBackground( const wxBrush
&brush
) ;
308 HIViewRef m_scrollView
;
309 HIViewRef m_textView
;
310 EventHandlerRef m_textEventHandlerRef
;
315 class wxMacUnicodeTextControl
: public wxMacTextControl
318 wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
,
321 const wxSize
& size
, long style
) ;
322 virtual ~wxMacUnicodeTextControl();
324 virtual void VisibilityChanged(bool shown
);
325 virtual wxString
GetStringValue() const ;
326 virtual void SetStringValue( const wxString
&str
) ;
329 virtual void Paste();
330 virtual bool CanPaste() const;
331 virtual void SetEditable(bool editable
) ;
332 virtual void GetSelection( long* from
, long* to
) const ;
333 virtual void SetSelection( long from
, long to
) ;
334 virtual void WriteText(const wxString
& str
) ;
337 // contains the tag for the content (is different for password and non-password controls)
340 // as the selection tag only works correctly when the control has the focus we have to mirror the
342 EventHandlerRef m_focusHandlerRef
;
344 ControlEditTextSelectionRec m_selection
;
349 // 'classic' MLTE implementation
351 class wxMacMLTEClassicControl
: public wxMacMLTEControl
354 wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
357 const wxSize
& size
, long style
) ;
358 virtual ~wxMacMLTEClassicControl() ;
360 virtual void VisibilityChanged(bool shown
) ;
361 virtual void SuperChangedPosition() ;
363 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
364 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
365 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
366 virtual void MacControlUserPaneIdleProc() ;
367 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
368 virtual void MacControlUserPaneActivateProc(bool activating
) ;
369 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
370 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
372 virtual bool SetupCursor( const wxPoint
& WXUNUSED(pt
) )
374 MacControlUserPaneIdleProc();
378 virtual void SetRect( Rect
*r
) ;
383 void MacUpdatePosition() ;
384 void MacActivatePaneText(bool setActive
) ;
385 void MacFocusPaneText(bool setFocus
) ;
386 void MacSetObjectVisibility(bool vis
) ;
389 TXNFrameID m_txnFrameID
;
391 WindowRef m_txnWindow
;
392 // bounds of the control as we last did set the txn frames
393 Rect m_txnControlBounds
;
394 Rect m_txnVisBounds
;
397 static pascal void TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
) ;
398 static pascal void TXNScrollInfoProc(
399 SInt32 iValue
, SInt32 iMaximumValue
,
400 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
) ;
402 ControlRef m_sbHorizontal
;
403 SInt32 m_lastHorizontalValue
;
404 ControlRef m_sbVertical
;
405 SInt32 m_lastVerticalValue
;
410 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl
, wxTextCtrlBase
)
412 BEGIN_EVENT_TABLE(wxTextCtrl
, wxTextCtrlBase
)
413 EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground
)
414 EVT_DROP_FILES(wxTextCtrl::OnDropFiles
)
415 EVT_CHAR(wxTextCtrl::OnChar
)
416 EVT_MENU(wxID_CUT
, wxTextCtrl::OnCut
)
417 EVT_MENU(wxID_COPY
, wxTextCtrl::OnCopy
)
418 EVT_MENU(wxID_PASTE
, wxTextCtrl::OnPaste
)
419 EVT_MENU(wxID_UNDO
, wxTextCtrl::OnUndo
)
420 EVT_MENU(wxID_REDO
, wxTextCtrl::OnRedo
)
421 EVT_MENU(wxID_CLEAR
, wxTextCtrl::OnDelete
)
422 EVT_MENU(wxID_SELECTALL
, wxTextCtrl::OnSelectAll
)
424 EVT_CONTEXT_MENU(wxTextCtrl::OnContextMenu
)
426 EVT_UPDATE_UI(wxID_CUT
, wxTextCtrl::OnUpdateCut
)
427 EVT_UPDATE_UI(wxID_COPY
, wxTextCtrl::OnUpdateCopy
)
428 EVT_UPDATE_UI(wxID_PASTE
, wxTextCtrl::OnUpdatePaste
)
429 EVT_UPDATE_UI(wxID_UNDO
, wxTextCtrl::OnUpdateUndo
)
430 EVT_UPDATE_UI(wxID_REDO
, wxTextCtrl::OnUpdateRedo
)
431 EVT_UPDATE_UI(wxID_CLEAR
, wxTextCtrl::OnUpdateDelete
)
432 EVT_UPDATE_UI(wxID_SELECTALL
, wxTextCtrl::OnUpdateSelectAll
)
436 void wxTextCtrl::Init()
442 m_privateContextMenu
= NULL
;
443 m_triggerOnSetValue
= true ;
446 wxTextCtrl::~wxTextCtrl()
448 delete m_privateContextMenu
;
451 bool wxTextCtrl::Create( wxWindow
*parent
,
457 const wxValidator
& validator
,
458 const wxString
& name
)
460 m_macIsUserPane
= false ;
463 if ( ! (style
& wxNO_BORDER
) )
464 style
= (style
& ~wxBORDER_MASK
) | wxSUNKEN_BORDER
;
466 if ( !wxTextCtrlBase::Create( parent
, id
, pos
, size
, style
& ~(wxHSCROLL
| wxVSCROLL
), validator
, name
) )
469 if ( m_windowStyle
& wxTE_MULTILINE
)
471 // always turn on this style for multi-line controls
472 m_windowStyle
|= wxTE_PROCESS_ENTER
;
473 style
|= wxTE_PROCESS_ENTER
;
476 bool forceMLTE
= false ;
478 #if wxUSE_SYSTEM_OPTIONS
479 if (wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE
) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE
) == 1))
486 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
487 if ( UMAGetSystemVersion() >= 0x1030 && !forceMLTE
)
489 if ( m_windowStyle
& wxTE_MULTILINE
)
490 m_peer
= new wxMacMLTEHIViewControl( this , str
, pos
, size
, style
) ;
496 if ( !(m_windowStyle
& wxTE_MULTILINE
) && !forceMLTE
)
497 m_peer
= new wxMacUnicodeTextControl( this , str
, pos
, size
, style
) ;
502 m_peer
= new wxMacMLTEClassicControl( this , str
, pos
, size
, style
) ;
504 MacPostControlCreate(pos
, size
) ;
506 // only now the embedding is correct and we can do a positioning update
508 MacSuperChangedPosition() ;
510 if ( m_windowStyle
& wxTE_READONLY
)
511 SetEditable( false ) ;
513 SetCursor( wxCursor( wxCURSOR_IBEAM
) ) ;
518 void wxTextCtrl::MacSuperChangedPosition()
520 wxWindow::MacSuperChangedPosition() ;
521 GetPeer()->SuperChangedPosition() ;
524 void wxTextCtrl::MacVisibilityChanged()
526 GetPeer()->VisibilityChanged( MacIsReallyShown() ) ;
529 void wxTextCtrl::MacEnabledStateChanged()
533 wxString
wxTextCtrl::GetValue() const
535 return GetPeer()->GetStringValue() ;
538 void wxTextCtrl::GetSelection(long* from
, long* to
) const
540 GetPeer()->GetSelection( from
, to
) ;
543 void wxTextCtrl::DoSetValue(const wxString
& str
, int flags
)
546 if ( GetValue() == str
)
549 GetPeer()->SetStringValue( str
) ;
551 if ( (flags
& SetValue_SendEvent
) && m_triggerOnSetValue
)
553 SendTextUpdatedEvent();
557 void wxTextCtrl::SetMaxLength(unsigned long len
)
562 bool wxTextCtrl::SetFont( const wxFont
& font
)
564 if ( !wxTextCtrlBase::SetFont( font
) )
567 GetPeer()->SetFont( font
, GetForegroundColour() , GetWindowStyle() ) ;
572 bool wxTextCtrl::SetStyle(long start
, long end
, const wxTextAttr
& style
)
574 GetPeer()->SetStyle( start
, end
, style
) ;
579 bool wxTextCtrl::SetDefaultStyle(const wxTextAttr
& style
)
581 wxTextCtrlBase::SetDefaultStyle( style
) ;
582 SetStyle( kTXNUseCurrentSelection
, kTXNUseCurrentSelection
, GetDefaultStyle() ) ;
587 // Clipboard operations
589 void wxTextCtrl::Copy()
595 void wxTextCtrl::Cut()
601 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
602 event
.SetEventObject( this );
603 GetEventHandler()->ProcessEvent( event
);
607 void wxTextCtrl::Paste()
613 // TODO: eventually we should add setting the default style again
615 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
616 event
.SetEventObject( this );
617 GetEventHandler()->ProcessEvent( event
);
621 bool wxTextCtrl::CanCopy() const
623 // Can copy if there's a selection
625 GetSelection( &from
, &to
);
630 bool wxTextCtrl::CanCut() const
635 // Can cut if there's a selection
637 GetSelection( &from
, &to
);
642 bool wxTextCtrl::CanPaste() const
647 return GetPeer()->CanPaste() ;
650 void wxTextCtrl::SetEditable(bool editable
)
652 if ( editable
!= m_editable
)
654 m_editable
= editable
;
655 GetPeer()->SetEditable( editable
) ;
659 void wxTextCtrl::SetInsertionPoint(long pos
)
661 SetSelection( pos
, pos
) ;
664 void wxTextCtrl::SetInsertionPointEnd()
666 wxTextPos pos
= GetLastPosition();
667 SetInsertionPoint( pos
);
670 long wxTextCtrl::GetInsertionPoint() const
673 GetSelection( &begin
, &end
) ;
678 wxTextPos
wxTextCtrl::GetLastPosition() const
680 return GetPeer()->GetLastPosition() ;
683 void wxTextCtrl::Replace(long from
, long to
, const wxString
& str
)
685 GetPeer()->Replace( from
, to
, str
) ;
688 void wxTextCtrl::Remove(long from
, long to
)
690 GetPeer()->Remove( from
, to
) ;
693 void wxTextCtrl::SetSelection(long from
, long to
)
695 GetPeer()->SetSelection( from
, to
) ;
698 void wxTextCtrl::WriteText(const wxString
& str
)
700 // TODO: this MPRemoting will be moved into a remoting peer proxy for any command
701 if ( !wxIsMainThread() )
703 // unfortunately CW 8 is not able to correctly deduce the template types,
704 // so we have to instantiate explicitly
705 wxMacMPRemoteGUICall
<wxTextCtrl
,wxString
>( this , &wxTextCtrl::WriteText
, str
) ;
710 GetPeer()->WriteText( str
) ;
713 void wxTextCtrl::AppendText(const wxString
& text
)
715 SetInsertionPointEnd();
719 void wxTextCtrl::Clear()
724 bool wxTextCtrl::IsModified() const
729 bool wxTextCtrl::IsEditable() const
731 return IsEnabled() && m_editable
;
734 bool wxTextCtrl::AcceptsFocus() const
736 // we don't want focus if we can't be edited
737 return /*IsEditable() && */ wxControl::AcceptsFocus();
740 wxSize
wxTextCtrl::DoGetBestSize() const
744 // these are the numbers from the HIG:
745 // we reduce them by the borders first
748 switch ( m_windowVariant
)
750 case wxWINDOW_VARIANT_NORMAL
:
754 case wxWINDOW_VARIANT_SMALL
:
758 case wxWINDOW_VARIANT_MINI
:
767 // as the above numbers have some free space around the text
768 // we get 5 lines like this anyway
769 if ( m_windowStyle
& wxTE_MULTILINE
)
772 if ( !HasFlag(wxNO_BORDER
) )
775 return wxSize(wText
, hText
);
778 // ----------------------------------------------------------------------------
780 // ----------------------------------------------------------------------------
782 void wxTextCtrl::Undo()
788 void wxTextCtrl::Redo()
794 bool wxTextCtrl::CanUndo() const
799 return GetPeer()->CanUndo() ;
802 bool wxTextCtrl::CanRedo() const
807 return GetPeer()->CanRedo() ;
810 void wxTextCtrl::MarkDirty()
815 void wxTextCtrl::DiscardEdits()
820 int wxTextCtrl::GetNumberOfLines() const
822 return GetPeer()->GetNumberOfLines() ;
825 long wxTextCtrl::XYToPosition(long x
, long y
) const
827 return GetPeer()->XYToPosition( x
, y
) ;
830 bool wxTextCtrl::PositionToXY(long pos
, long *x
, long *y
) const
832 return GetPeer()->PositionToXY( pos
, x
, y
) ;
835 void wxTextCtrl::ShowPosition(long pos
)
837 return GetPeer()->ShowPosition(pos
) ;
840 int wxTextCtrl::GetLineLength(long lineNo
) const
842 return GetPeer()->GetLineLength(lineNo
) ;
845 wxString
wxTextCtrl::GetLineText(long lineNo
) const
847 return GetPeer()->GetLineText(lineNo
) ;
850 void wxTextCtrl::Command(wxCommandEvent
& event
)
852 SetValue(event
.GetString());
853 ProcessCommand(event
);
856 void wxTextCtrl::OnDropFiles(wxDropFilesEvent
& event
)
858 // By default, load the first file into the text window.
859 if (event
.GetNumberOfFiles() > 0)
860 LoadFile( event
.GetFiles()[0] );
863 void wxTextCtrl::OnEraseBackground(wxEraseEvent
& event
)
865 // all erasing should be done by the real mac control implementation
866 // while this is true for MLTE under classic, the HITextView is somehow
867 // transparent but background erase is not working correctly, so intercept
868 // things while we can...
872 void wxTextCtrl::OnChar(wxKeyEvent
& event
)
874 int key
= event
.GetKeyCode() ;
875 bool eat_key
= false ;
877 if ( key
== 'a' && event
.MetaDown() )
884 if ( key
== 'c' && event
.MetaDown() )
892 if ( !IsEditable() && key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_DOWN
&& key
!= WXK_UP
&& key
!= WXK_TAB
&&
893 !( key
== WXK_RETURN
&& ( (m_windowStyle
& wxTE_PROCESS_ENTER
) || (m_windowStyle
& wxTE_MULTILINE
) ) )
894 // && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
901 // Check if we have reached the max # of chars (if it is set), but still
902 // allow navigation and deletion
903 if ( !IsMultiLine() && m_maxLength
&& GetValue().length() >= m_maxLength
&&
904 key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_TAB
&&
905 key
!= WXK_BACK
&& !( key
== WXK_RETURN
&& (m_windowStyle
& wxTE_PROCESS_ENTER
) )
908 // eat it, we don't want to add more than allowed # of characters
910 // TODO: generate EVT_TEXT_MAXLEN()
914 // assume that any key not processed yet is going to modify the control
917 if ( key
== 'v' && event
.MetaDown() )
925 if ( key
== 'x' && event
.MetaDown() )
936 if (m_windowStyle
& wxTE_PROCESS_ENTER
)
938 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, m_windowId
);
939 event
.SetEventObject( this );
940 event
.SetString( GetValue() );
941 if ( GetEventHandler()->ProcessEvent(event
) )
945 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
947 wxTopLevelWindow
*tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
948 if ( tlw
&& tlw
->GetDefaultItem() )
950 wxButton
*def
= wxDynamicCast(tlw
->GetDefaultItem(), wxButton
);
951 if ( def
&& def
->IsEnabled() )
953 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
954 event
.SetEventObject(def
);
961 // this will make wxWidgets eat the ENTER key so that
962 // we actually prevent line wrapping in a single line text control
968 if ( !(m_windowStyle
& wxTE_PROCESS_TAB
))
971 if (!event
.ShiftDown())
972 flags
|= wxNavigationKeyEvent::IsForward
;
973 if (event
.ControlDown())
974 flags
|= wxNavigationKeyEvent::WinChange
;
981 // This is necessary (don't know why);
982 // otherwise the tab will not be inserted.
983 WriteText(wxT("\t"));
994 // perform keystroke handling
998 if ( ( key
>= 0x20 && key
< WXK_START
) ||
999 ( key
>= WXK_NUMPAD0
&& key
<= WXK_DIVIDE
) ||
1000 key
== WXK_RETURN
||
1001 key
== WXK_DELETE
||
1004 wxCommandEvent
event1(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
1005 event1
.SetEventObject( this );
1006 wxPostEvent( GetEventHandler(), event1
);
1010 // ----------------------------------------------------------------------------
1011 // standard handlers for standard edit menu events
1012 // ----------------------------------------------------------------------------
1014 void wxTextCtrl::OnCut(wxCommandEvent
& WXUNUSED(event
))
1019 void wxTextCtrl::OnCopy(wxCommandEvent
& WXUNUSED(event
))
1024 void wxTextCtrl::OnPaste(wxCommandEvent
& WXUNUSED(event
))
1029 void wxTextCtrl::OnUndo(wxCommandEvent
& WXUNUSED(event
))
1034 void wxTextCtrl::OnRedo(wxCommandEvent
& WXUNUSED(event
))
1039 void wxTextCtrl::OnDelete(wxCommandEvent
& WXUNUSED(event
))
1043 GetSelection( &from
, &to
);
1044 if (from
!= -1 && to
!= -1)
1048 void wxTextCtrl::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
1050 SetSelection(-1, -1);
1053 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent
& event
)
1055 event
.Enable( CanCut() );
1058 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent
& event
)
1060 event
.Enable( CanCopy() );
1063 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent
& event
)
1065 event
.Enable( CanPaste() );
1068 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent
& event
)
1070 event
.Enable( CanUndo() );
1073 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent
& event
)
1075 event
.Enable( CanRedo() );
1078 void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent
& event
)
1082 GetSelection( &from
, &to
);
1083 event
.Enable( from
!= -1 && to
!= -1 && from
!= to
&& IsEditable() ) ;
1086 void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent
& event
)
1088 event
.Enable(GetLastPosition() > 0);
1091 // CS: Context Menus only work with MLTE implementations or non-multiline HIViews at the moment
1093 void wxTextCtrl::OnContextMenu(wxContextMenuEvent
& event
)
1095 if ( GetPeer()->HasOwnContextMenu() )
1101 if (m_privateContextMenu
== NULL
)
1103 m_privateContextMenu
= new wxMenu
;
1104 m_privateContextMenu
->Append(wxID_UNDO
, _("&Undo"));
1105 m_privateContextMenu
->Append(wxID_REDO
, _("&Redo"));
1106 m_privateContextMenu
->AppendSeparator();
1107 m_privateContextMenu
->Append(wxID_CUT
, _("Cu&t"));
1108 m_privateContextMenu
->Append(wxID_COPY
, _("&Copy"));
1109 m_privateContextMenu
->Append(wxID_PASTE
, _("&Paste"));
1110 m_privateContextMenu
->Append(wxID_CLEAR
, _("&Delete"));
1111 m_privateContextMenu
->AppendSeparator();
1112 m_privateContextMenu
->Append(wxID_SELECTALL
, _("Select &All"));
1115 if (m_privateContextMenu
!= NULL
)
1116 PopupMenu(m_privateContextMenu
);
1119 bool wxTextCtrl::MacSetupCursor( const wxPoint
& pt
)
1121 if ( !GetPeer()->SetupCursor( pt
) )
1122 return wxWindow::MacSetupCursor( pt
) ;
1127 #if !TARGET_API_MAC_OSX
1129 // user pane implementation
1131 void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part
)
1133 GetPeer()->MacControlUserPaneDrawProc( part
) ;
1136 wxInt16
wxTextCtrl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
1138 return GetPeer()->MacControlUserPaneHitTestProc( x
, y
) ;
1141 wxInt16
wxTextCtrl::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
1143 return GetPeer()->MacControlUserPaneTrackingProc( x
, y
, actionProc
) ;
1146 void wxTextCtrl::MacControlUserPaneIdleProc()
1148 GetPeer()->MacControlUserPaneIdleProc( ) ;
1151 wxInt16
wxTextCtrl::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
1153 return GetPeer()->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
1156 void wxTextCtrl::MacControlUserPaneActivateProc(bool activating
)
1158 GetPeer()->MacControlUserPaneActivateProc( activating
) ;
1161 wxInt16
wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action
)
1163 return GetPeer()->MacControlUserPaneFocusProc( action
) ;
1166 void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info
)
1168 GetPeer()->MacControlUserPaneBackgroundProc( info
) ;
1173 // ----------------------------------------------------------------------------
1174 // implementation base class
1175 // ----------------------------------------------------------------------------
1177 wxMacTextControl::wxMacTextControl(wxTextCtrl
* peer
) :
1178 wxMacControl( peer
)
1182 wxMacTextControl::~wxMacTextControl()
1186 void wxMacTextControl::SetStyle(long start
, long end
, const wxTextAttr
& style
)
1190 void wxMacTextControl::Copy()
1194 void wxMacTextControl::Cut()
1198 void wxMacTextControl::Paste()
1202 bool wxMacTextControl::CanPaste() const
1207 void wxMacTextControl::SetEditable(bool editable
)
1211 wxTextPos
wxMacTextControl::GetLastPosition() const
1213 return GetStringValue().length() ;
1216 void wxMacTextControl::Replace( long from
, long to
, const wxString
&val
)
1218 SetSelection( from
, to
) ;
1222 void wxMacTextControl::Remove( long from
, long to
)
1224 SetSelection( from
, to
) ;
1225 WriteText( wxEmptyString
) ;
1228 void wxMacTextControl::Clear()
1230 SetStringValue( wxEmptyString
) ;
1233 bool wxMacTextControl::CanUndo() const
1238 void wxMacTextControl::Undo()
1242 bool wxMacTextControl::CanRedo() const
1247 void wxMacTextControl::Redo()
1251 long wxMacTextControl::XYToPosition(long x
, long y
) const
1256 bool wxMacTextControl::PositionToXY(long pos
, long *x
, long *y
) const
1261 void wxMacTextControl::ShowPosition( long WXUNUSED(pos
) )
1265 int wxMacTextControl::GetNumberOfLines() const
1267 ItemCount lines
= 0 ;
1268 wxString content
= GetStringValue() ;
1271 for (size_t i
= 0; i
< content
.length() ; i
++)
1273 if (content
[i
] == '\r')
1280 wxString
wxMacTextControl::GetLineText(long lineNo
) const
1282 // TODO: change this if possible to reflect real lines
1283 wxString content
= GetStringValue() ;
1287 for (size_t i
= 0; i
< content
.length() ; i
++)
1289 if (count
== lineNo
)
1291 // Add chars in line then
1294 for (size_t j
= i
; j
< content
.length(); j
++)
1296 if (content
[j
] == '\n')
1305 if (content
[i
] == '\n')
1309 return wxEmptyString
;
1312 int wxMacTextControl::GetLineLength(long lineNo
) const
1314 // TODO: change this if possible to reflect real lines
1315 wxString content
= GetStringValue() ;
1319 for (size_t i
= 0; i
< content
.length() ; i
++)
1321 if (count
== lineNo
)
1323 // Count chars in line then
1325 for (size_t j
= i
; j
< content
.length(); j
++)
1328 if (content
[j
] == '\n')
1335 if (content
[i
] == '\n')
1342 // ----------------------------------------------------------------------------
1343 // standard unicode control implementation
1344 // ----------------------------------------------------------------------------
1346 #if TARGET_API_MAC_OSX
1348 // the current unicode textcontrol implementation has a bug : only if the control
1349 // is currently having the focus, the selection can be retrieved by the corresponding
1350 // data tag. So we have a mirroring using a member variable
1351 // TODO : build event table using virtual member functions for wxMacControl
1353 static const EventTypeSpec unicodeTextControlEventList
[] =
1355 { kEventClassControl
, kEventControlSetFocusPart
} ,
1358 static pascal OSStatus
wxMacUnicodeTextControlControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
1360 OSStatus result
= eventNotHandledErr
;
1361 wxMacUnicodeTextControl
* focus
= (wxMacUnicodeTextControl
*) data
;
1362 wxMacCarbonEvent
cEvent( event
) ;
1364 switch ( GetEventKind( event
) )
1366 case kEventControlSetFocusPart
:
1368 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
1369 if ( controlPart
== kControlFocusNoPart
)
1371 // about to loose focus -> store selection to field
1372 focus
->GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
1374 result
= CallNextEventHandler(handler
,event
) ;
1375 if ( controlPart
!= kControlFocusNoPart
)
1377 // about to gain focus -> set selection from field
1378 focus
->SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
1389 static pascal OSStatus
wxMacUnicodeTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
1391 OSStatus result
= eventNotHandledErr
;
1393 switch ( GetEventClass( event
) )
1395 case kEventClassControl
:
1396 result
= wxMacUnicodeTextControlControlEventHandler( handler
, event
, data
) ;
1405 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler
)
1407 wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
,
1408 const wxString
& str
,
1410 const wxSize
& size
, long style
)
1411 : wxMacTextControl( wxPeer
)
1413 m_font
= wxPeer
->GetFont() ;
1414 m_windowStyle
= style
;
1415 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
1417 wxMacConvertNewlines10To13( &st
) ;
1418 wxMacCFStringHolder
cf(st
, m_font
.GetEncoding()) ;
1419 CFStringRef cfr
= cf
;
1420 Boolean isPassword
= ( m_windowStyle
& wxTE_PASSWORD
) != 0 ;
1421 m_valueTag
= isPassword
? kControlEditTextPasswordCFStringTag
: kControlEditTextCFStringTag
;
1423 OSStatus err
= CreateEditUnicodeTextControl(
1424 MAC_WXHWND(wxPeer
->MacGetTopLevelWindowRef()), &bounds
, cfr
,
1425 isPassword
, NULL
, &m_controlRef
) ;
1426 verify_noerr( err
);
1428 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
1429 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextSingleLineTag
, true ) ;
1431 InstallControlEventHandler( m_controlRef
, GetwxMacUnicodeTextControlEventHandlerUPP(),
1432 GetEventTypeCount(unicodeTextControlEventList
), unicodeTextControlEventList
, this,
1433 &m_focusHandlerRef
);
1436 wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
1438 ::RemoveEventHandler( m_focusHandlerRef
);
1441 void wxMacUnicodeTextControl::VisibilityChanged(bool shown
)
1443 if ( !(m_windowStyle
& wxTE_MULTILINE
) && shown
)
1445 // work around a refresh issue insofar as not always the entire content is shown,
1446 // even if this would be possible
1447 ControlEditTextSelectionRec sel
;
1448 CFStringRef value
= NULL
;
1450 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
1451 verify_noerr( GetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
1452 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
1453 verify_noerr( SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
1455 CFRelease( value
) ;
1459 wxString
wxMacUnicodeTextControl::GetStringValue() const
1462 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
1465 wxMacCFStringHolder
cf(value
) ;
1466 result
= cf
.AsString() ;
1470 wxMacConvertNewlines13To10( &result
) ;
1472 wxMacConvertNewlines10To13( &result
) ;
1478 void wxMacUnicodeTextControl::SetStringValue( const wxString
&str
)
1481 wxMacConvertNewlines10To13( &st
) ;
1482 wxMacCFStringHolder
cf( st
, m_font
.GetEncoding() ) ;
1483 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, cf
) ) ;
1486 void wxMacUnicodeTextControl::Copy()
1488 SendHICommand( kHICommandCopy
) ;
1491 void wxMacUnicodeTextControl::Cut()
1493 SendHICommand( kHICommandCut
) ;
1496 void wxMacUnicodeTextControl::Paste()
1498 SendHICommand( kHICommandPaste
) ;
1501 bool wxMacUnicodeTextControl::CanPaste() const
1506 void wxMacUnicodeTextControl::SetEditable(bool editable
)
1508 #if 0 // leads to problem because text cannot be selected anymore
1509 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextLockedTag
, (Boolean
) !editable
) ;
1513 void wxMacUnicodeTextControl::GetSelection( long* from
, long* to
) const
1515 ControlEditTextSelectionRec sel
;
1517 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ) ;
1522 *from
= sel
.selStart
;
1527 void wxMacUnicodeTextControl::SetSelection( long from
, long to
)
1529 ControlEditTextSelectionRec sel
;
1531 int textLength
= 0 ;
1532 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
1535 wxMacCFStringHolder
cf(value
) ;
1536 textLength
= cf
.AsString().length() ;
1539 if ((from
== -1) && (to
== -1))
1546 from
= wxMin(textLength
,wxMax(from
,0)) ;
1547 to
= wxMax(0,wxMin(textLength
,to
)) ;
1550 sel
.selStart
= from
;
1553 SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ;
1558 void wxMacUnicodeTextControl::WriteText( const wxString
& str
)
1561 wxMacConvertNewlines10To13( &st
) ;
1563 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
1566 wxMacCFStringHolder
cf(st
, m_font
.GetEncoding() ) ;
1567 CFStringRef value
= cf
;
1568 SetData
<CFStringRef
>( 0, kControlEditTextInsertCFStringRefTag
, &value
);
1573 wxString val
= GetStringValue() ;
1575 GetSelection( &start
, &end
) ;
1576 val
.Remove( start
, end
- start
) ;
1577 val
.insert( start
, str
) ;
1578 SetStringValue( val
) ;
1579 SetSelection( start
+ str
.length() , start
+ str
.length() ) ;
1585 // ----------------------------------------------------------------------------
1586 // MLTE control implementation (common part)
1587 // ----------------------------------------------------------------------------
1589 // if MTLE is read only, no changes at all are allowed, not even from
1590 // procedural API, in order to allow changes via API all the same we must undo
1591 // the readonly status while we are executing, this class helps to do so
1593 class wxMacEditHelper
1596 wxMacEditHelper( TXNObject txn
)
1598 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1600 TXNGetTXNObjectControls( m_txn
, 1 , tag
, m_data
) ;
1601 if ( m_data
[0].uValue
== kTXNReadOnly
)
1603 TXNControlData data
[] = { { kTXNReadWrite
} } ;
1604 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, data
) ;
1610 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1611 if ( m_data
[0].uValue
== kTXNReadOnly
)
1612 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, m_data
) ;
1617 TXNControlData m_data
[1] ;
1620 wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl
*peer
)
1621 : wxMacTextControl( peer
)
1623 SetNeedsFocusRect( true ) ;
1626 wxString
wxMacMLTEControl::GetStringValue() const
1630 Size actualSize
= 0;
1635 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNUnicodeTextData
);
1644 actualSize
= GetHandleSize( theText
) / sizeof(UniChar
) ;
1645 if ( actualSize
> 0 )
1647 wxChar
*ptr
= NULL
;
1649 #if SIZEOF_WCHAR_T == 2
1650 ptr
= new wxChar
[actualSize
+ 1] ;
1651 wxStrncpy( ptr
, (wxChar
*)(*theText
) , actualSize
) ;
1653 SetHandleSize( theText
, (actualSize
+ 1) * sizeof(UniChar
) ) ;
1655 (((UniChar
*)*theText
)[actualSize
]) = 0 ;
1656 wxMBConvUTF16 converter
;
1657 size_t noChars
= converter
.MB2WC( NULL
, (const char*)*theText
, 0 ) ;
1658 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Unable to count the number of characters in this string!") );
1659 ptr
= new wxChar
[noChars
+ 1] ;
1661 noChars
= converter
.MB2WC( ptr
, (const char*)*theText
, noChars
+ 1 ) ;
1662 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Conversion of string failed!") );
1664 HUnlock( theText
) ;
1667 ptr
[actualSize
] = 0 ;
1668 result
= wxString( ptr
) ;
1672 DisposeHandle( theText
) ;
1676 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1685 actualSize
= GetHandleSize( theText
) ;
1686 if ( actualSize
> 0 )
1689 result
= wxString( *theText
, wxConvLocal
, actualSize
) ;
1690 HUnlock( theText
) ;
1693 DisposeHandle( theText
) ;
1699 wxMacConvertNewlines13To10( &result
) ;
1701 wxMacConvertNewlines10To13( &result
) ;
1707 void wxMacMLTEControl::SetStringValue( const wxString
&str
)
1710 wxMacConvertNewlines10To13( &st
);
1713 wxMacWindowClipper
c( m_peer
);
1716 wxMacEditHelper
help( m_txn
);
1717 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
);
1720 TXNSetSelection( m_txn
, 0, 0 );
1721 TXNShowSelection( m_txn
, kTXNShowStart
);
1725 TXNFrameOptions
wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle
)
1727 TXNFrameOptions frameOptions
= kTXNDontDrawCaretWhenInactiveMask
;
1729 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1730 frameOptions
|= kTXNDoFontSubstitutionMask
;
1733 if ( ! (wxStyle
& wxTE_NOHIDESEL
) )
1734 frameOptions
|= kTXNDontDrawSelectionWhenInactiveMask
;
1736 if ( wxStyle
& (wxHSCROLL
| wxTE_DONTWRAP
) )
1737 frameOptions
|= kTXNWantHScrollBarMask
;
1739 if ( wxStyle
& wxTE_MULTILINE
)
1741 frameOptions
|= kTXNAlwaysWrapAtViewEdgeMask
;
1743 if ( !(wxStyle
& wxTE_NO_VSCROLL
) )
1745 frameOptions
|= kTXNWantVScrollBarMask
;
1747 // The following code causes drawing problems on 10.4. Perhaps it can be restored for
1748 // older versions of the OS, but I'm not sure it's appropriate to put a grow icon here
1749 // anyways, as AFAIK users can't actually use it to resize the text ctrl.
1750 // if ( frameOptions & kTXNWantHScrollBarMask )
1751 // frameOptions |= kTXNDrawGrowIconMask ;
1756 frameOptions
|= kTXNSingleLineOnlyMask
;
1759 return frameOptions
;
1762 void wxMacMLTEControl::AdjustCreationAttributes( const wxColour
&background
, bool visible
)
1764 TXNControlTag iControlTags
[] =
1766 kTXNDoFontSubstitution
,
1767 kTXNWordWrapStateTag
,
1769 TXNControlData iControlData
[] =
1775 int toptag
= WXSIZEOF( iControlTags
) ;
1777 if ( m_windowStyle
& wxTE_MULTILINE
)
1779 iControlData
[1].uValue
=
1780 (m_windowStyle
& wxTE_DONTWRAP
)
1785 OSStatus err
= TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) ;
1786 verify_noerr( err
);
1788 // setting the default font:
1789 // under 10.2 this causes a visible caret, therefore we avoid it
1791 if ( UMAGetSystemVersion() >= 0x1030 )
1797 GetThemeFont( kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1799 TXNTypeAttributes typeAttr
[] =
1801 { kTXNQDFontNameAttribute
, kTXNQDFontNameAttributeSize
, { (void*) fontName
} } ,
1802 { kTXNQDFontSizeAttribute
, kTXNFontSizeAttributeSize
, { (void*) (fontSize
<< 16) } } ,
1803 { kTXNQDFontStyleAttribute
, kTXNQDFontStyleAttributeSize
, { (void*) normal
} } ,
1806 err
= TXNSetTypeAttributes(
1807 m_txn
, sizeof(typeAttr
) / sizeof(TXNTypeAttributes
),
1808 typeAttr
, kTXNStartOffset
, kTXNEndOffset
);
1809 verify_noerr( err
);
1812 if ( m_windowStyle
& wxTE_PASSWORD
)
1814 UniChar c
= 0x00A5 ;
1815 err
= TXNEchoMode( m_txn
, c
, 0 , true );
1816 verify_noerr( err
);
1819 TXNBackground tback
;
1820 tback
.bgType
= kTXNBackgroundTypeRGB
;
1821 tback
.bg
.color
= MAC_WXCOLORREF( background
.GetPixel() );
1822 TXNSetBackground( m_txn
, &tback
);
1824 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1825 if ( UMAGetSystemVersion() >= 0x1040 )
1827 TXNCommandEventSupportOptions options
;
1828 if ( TXNGetCommandEventSupport( m_txn
, &options
) == noErr
)
1831 kTXNSupportEditCommandProcessing
1832 | kTXNSupportEditCommandUpdating
1833 | kTXNSupportSpellCheckCommandProcessing
1834 | kTXNSupportSpellCheckCommandUpdating
1835 | kTXNSupportFontCommandProcessing
1836 | kTXNSupportFontCommandUpdating
;
1838 TXNSetCommandEventSupport( m_txn
, options
) ;
1844 void wxMacMLTEControl::SetBackground( const wxBrush
&brush
)
1846 // currently only solid background are supported
1847 TXNBackground tback
;
1849 tback
.bgType
= kTXNBackgroundTypeRGB
;
1850 tback
.bg
.color
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() );
1851 TXNSetBackground( m_txn
, &tback
);
1854 void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
)
1856 TXNTypeAttributes typeAttr
[4] ;
1860 if ( style
.HasFont() )
1862 const wxFont
&font
= style
.GetFont() ;
1864 #if 0 // old version
1865 Str255 fontName
= "\pMonaco" ;
1866 SInt16 fontSize
= 12 ;
1867 Style fontStyle
= normal
;
1868 wxMacStringToPascal( font
.GetFaceName() , fontName
) ;
1869 fontSize
= font
.GetPointSize() ;
1870 if ( font
.GetUnderlined() )
1871 fontStyle
|= underline
;
1872 if ( font
.GetWeight() == wxBOLD
)
1874 if ( font
.GetStyle() == wxITALIC
)
1875 fontStyle
|= italic
;
1877 typeAttr
[attrCount
].tag
= kTXNQDFontNameAttribute
;
1878 typeAttr
[attrCount
].size
= kTXNQDFontNameAttributeSize
;
1879 typeAttr
[attrCount
].data
.dataPtr
= (void*)fontName
;
1882 typeAttr
[attrCount
].tag
= kTXNQDFontSizeAttribute
;
1883 typeAttr
[attrCount
].size
= kTXNFontSizeAttributeSize
;
1884 typeAttr
[attrCount
].data
.dataValue
= (fontSize
<< 16) ;
1887 typeAttr
[attrCount
].tag
= kTXNQDFontStyleAttribute
;
1888 typeAttr
[attrCount
].size
= kTXNQDFontStyleAttributeSize
;
1889 typeAttr
[attrCount
].data
.dataValue
= fontStyle
;
1892 typeAttr
[attrCount
].tag
= kTXNATSUIStyle
;
1893 typeAttr
[attrCount
].size
= kTXNATSUIStyleSize
;
1894 typeAttr
[attrCount
].data
.dataValue
= (UInt32
)font
.MacGetATSUStyle() ;
1899 if ( style
.HasTextColour() )
1901 color
= MAC_WXCOLORREF(style
.GetTextColour().GetPixel()) ;
1903 typeAttr
[attrCount
].tag
= kTXNQDFontColorAttribute
;
1904 typeAttr
[attrCount
].size
= kTXNQDFontColorAttributeSize
;
1905 typeAttr
[attrCount
].data
.dataPtr
= (void*) &color
;
1909 if ( attrCount
> 0 )
1911 verify_noerr( TXNSetTypeAttributes( m_txn
, attrCount
, typeAttr
, from
, to
) );
1912 // unfortunately the relayout is not automatic
1913 TXNRecalcTextLayout( m_txn
);
1917 void wxMacMLTEControl::SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
)
1919 wxMacEditHelper
help( m_txn
) ;
1920 TXNSetAttribute( wxTextAttr( foreground
, wxNullColour
, font
), kTXNStartOffset
, kTXNEndOffset
) ;
1923 void wxMacMLTEControl::SetStyle( long start
, long end
, const wxTextAttr
& style
)
1925 wxMacEditHelper
help( m_txn
) ;
1926 TXNSetAttribute( style
, start
, end
) ;
1929 void wxMacMLTEControl::Copy()
1931 ClearCurrentScrap();
1933 TXNConvertToPublicScrap();
1936 void wxMacMLTEControl::Cut()
1938 ClearCurrentScrap();
1940 TXNConvertToPublicScrap();
1943 void wxMacMLTEControl::Paste()
1945 TXNConvertFromPublicScrap();
1949 bool wxMacMLTEControl::CanPaste() const
1951 return TXNIsScrapPastable() ;
1954 void wxMacMLTEControl::SetEditable(bool editable
)
1956 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1957 TXNControlData data
[] = { { editable
? kTXNReadWrite
: kTXNReadOnly
} } ;
1958 TXNSetTXNObjectControls( m_txn
, false, WXSIZEOF(tag
), tag
, data
) ;
1961 wxTextPos
wxMacMLTEControl::GetLastPosition() const
1963 wxTextPos actualsize
= 0 ;
1966 OSErr err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1971 actualsize
= GetHandleSize( theText
) ;
1972 DisposeHandle( theText
) ;
1982 void wxMacMLTEControl::Replace( long from
, long to
, const wxString
&str
)
1984 wxString value
= str
;
1985 wxMacConvertNewlines10To13( &value
) ;
1987 wxMacEditHelper
help( m_txn
) ;
1988 wxMacWindowClipper
c( m_peer
) ;
1990 TXNSetSelection( m_txn
, from
, to
) ;
1992 SetTXNData( value
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
1995 void wxMacMLTEControl::Remove( long from
, long to
)
1997 wxMacWindowClipper
c( m_peer
) ;
1998 wxMacEditHelper
help( m_txn
) ;
1999 TXNSetSelection( m_txn
, from
, to
) ;
2003 void wxMacMLTEControl::GetSelection( long* from
, long* to
) const
2005 TXNGetSelection( m_txn
, (TXNOffset
*) from
, (TXNOffset
*) to
) ;
2008 void wxMacMLTEControl::SetSelection( long from
, long to
)
2010 wxMacWindowClipper
c( m_peer
) ;
2012 // change the selection
2013 if ((from
== -1) && (to
== -1))
2014 TXNSelectAll( m_txn
);
2016 TXNSetSelection( m_txn
, from
, to
);
2018 TXNShowSelection( m_txn
, kTXNShowStart
);
2021 void wxMacMLTEControl::WriteText( const wxString
& str
)
2024 wxMacConvertNewlines10To13( &st
) ;
2026 long start
, end
, dummy
;
2028 GetSelection( &start
, &dummy
) ;
2029 wxMacWindowClipper
c( m_peer
) ;
2032 wxMacEditHelper
helper( m_txn
) ;
2033 SetTXNData( st
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
2036 GetSelection( &dummy
, &end
) ;
2038 // TODO: SetStyle( start , end , GetDefaultStyle() ) ;
2041 void wxMacMLTEControl::Clear()
2043 wxMacWindowClipper
c( m_peer
) ;
2044 wxMacEditHelper
st( m_txn
) ;
2045 TXNSetSelection( m_txn
, kTXNStartOffset
, kTXNEndOffset
) ;
2049 bool wxMacMLTEControl::CanUndo() const
2051 return TXNCanUndo( m_txn
, NULL
) ;
2054 void wxMacMLTEControl::Undo()
2059 bool wxMacMLTEControl::CanRedo() const
2061 return TXNCanRedo( m_txn
, NULL
) ;
2064 void wxMacMLTEControl::Redo()
2069 int wxMacMLTEControl::GetNumberOfLines() const
2071 ItemCount lines
= 0 ;
2072 TXNGetLineCount( m_txn
, &lines
) ;
2077 long wxMacMLTEControl::XYToPosition(long x
, long y
) const
2082 // TODO: find a better implementation : while we can get the
2083 // line metrics of a certain line, we don't get its starting
2084 // position, so it would probably be rather a binary search
2085 // for the start position
2086 long xpos
= 0, ypos
= 0 ;
2087 int lastHeight
= 0 ;
2090 lastpos
= GetLastPosition() ;
2091 for ( n
= 0 ; n
<= (ItemCount
) lastpos
; ++n
)
2093 if ( y
== ypos
&& x
== xpos
)
2096 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
2098 if ( curpt
.v
> lastHeight
)
2104 lastHeight
= curpt
.v
;
2113 bool wxMacMLTEControl::PositionToXY( long pos
, long *x
, long *y
) const
2123 lastpos
= GetLastPosition() ;
2124 if ( pos
<= lastpos
)
2126 // TODO: find a better implementation - while we can get the
2127 // line metrics of a certain line, we don't get its starting
2128 // position, so it would probably be rather a binary search
2129 // for the start position
2130 long xpos
= 0, ypos
= 0 ;
2131 int lastHeight
= 0 ;
2134 for ( n
= 0 ; n
<= (ItemCount
) pos
; ++n
)
2136 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
2138 if ( curpt
.v
> lastHeight
)
2144 lastHeight
= curpt
.v
;
2159 void wxMacMLTEControl::ShowPosition( long pos
)
2161 #if TARGET_RT_MAC_MACHO && defined(AVAILABLE_MAC_OS_X_VERSION_10_2_AND_LATER)
2163 Point current
, desired
;
2164 TXNOffset selstart
, selend
;
2166 TXNGetSelection( m_txn
, &selstart
, &selend
);
2167 TXNOffsetToPoint( m_txn
, selstart
, ¤t
);
2168 TXNOffsetToPoint( m_txn
, pos
, &desired
);
2170 // TODO: use HIPoints for 10.3 and above
2171 if ( (UInt32
)TXNScroll
!= (UInt32
)kUnresolvedCFragSymbolAddress
)
2173 OSErr theErr
= noErr
;
2174 SInt32 dv
= desired
.v
- current
.v
;
2175 SInt32 dh
= desired
.h
- current
.h
;
2176 TXNShowSelection( m_txn
, kTXNShowStart
) ; // NB: should this be kTXNShowStart or kTXNShowEnd ??
2177 theErr
= TXNScroll( m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
, &dv
, &dh
);
2179 // there will be an error returned for classic MLTE implementation when the control is
2180 // invisible, but HITextView works correctly, so we don't assert that one
2181 // wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
2187 void wxMacMLTEControl::SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
)
2190 #if SIZEOF_WCHAR_T == 2
2191 size_t len
= st
.length() ;
2192 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)st
.wc_str(), len
* 2, start
, end
);
2194 wxMBConvUTF16 converter
;
2195 ByteCount byteBufferLen
= converter
.WC2MB( NULL
, st
.wc_str(), 0 ) ;
2196 UniChar
*unibuf
= (UniChar
*)malloc( byteBufferLen
) ;
2197 converter
.WC2MB( (char*)unibuf
, st
.wc_str(), byteBufferLen
) ;
2198 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)unibuf
, byteBufferLen
, start
, end
) ;
2202 wxCharBuffer text
= st
.mb_str( wxConvLocal
) ;
2203 TXNSetData( m_txn
, kTXNTextData
, (void*)text
.data(), strlen( text
), start
, end
) ;
2207 wxString
wxMacMLTEControl::GetLineText(long lineNo
) const
2211 if ( lineNo
< GetNumberOfLines() )
2214 Fixed lineWidth
, lineHeight
, currentHeight
;
2217 // get the first possible position in the control
2218 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
2220 // Iterate through the lines until we reach the one we want,
2221 // adding to our current y pixel point position
2224 while (ypos
< lineNo
)
2226 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
2227 currentHeight
+= lineHeight
;
2230 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
2231 TXNOffset theOffset
;
2232 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
2234 wxString content
= GetStringValue() ;
2235 Point currentPoint
= thePoint
;
2236 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
2238 line
+= content
[theOffset
];
2239 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
2246 int wxMacMLTEControl::GetLineLength(long lineNo
) const
2250 if ( lineNo
< GetNumberOfLines() )
2253 Fixed lineWidth
, lineHeight
, currentHeight
;
2256 // get the first possible position in the control
2257 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
2259 // Iterate through the lines until we reach the one we want,
2260 // adding to our current y pixel point position
2263 while (ypos
< lineNo
)
2265 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
2266 currentHeight
+= lineHeight
;
2269 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
2270 TXNOffset theOffset
;
2271 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
2273 wxString content
= GetStringValue() ;
2274 Point currentPoint
= thePoint
;
2275 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
2278 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
2285 // ----------------------------------------------------------------------------
2286 // MLTE control implementation (classic part)
2287 // ----------------------------------------------------------------------------
2289 // OS X Notes : We still don't have a full replacement for MLTE, so this implementation
2290 // has to live on. We have different problems coming from outdated implementations on the
2291 // various OS X versions. Most deal with the scrollbars: they are not correctly embedded
2292 // while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
2293 // no way out, therefore we are using our own implementation and our own scrollbars ....
2295 #ifdef __WXMAC_OSX__
2297 TXNScrollInfoUPP gTXNScrollInfoProc
= NULL
;
2298 ControlActionUPP gTXNScrollActionProc
= NULL
;
2300 pascal void wxMacMLTEClassicControl::TXNScrollInfoProc(
2301 SInt32 iValue
, SInt32 iMaximumValue
,
2302 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
)
2304 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) iRefCon
;
2305 SInt32 value
= wxMax( iValue
, 0 ) ;
2306 SInt32 maximum
= wxMax( iMaximumValue
, 0 ) ;
2308 if ( iScrollBarOrientation
== kTXNHorizontal
)
2310 if ( mlte
->m_sbHorizontal
)
2312 SetControl32BitValue( mlte
->m_sbHorizontal
, value
) ;
2313 SetControl32BitMaximum( mlte
->m_sbHorizontal
, maximum
) ;
2314 mlte
->m_lastHorizontalValue
= value
;
2317 else if ( iScrollBarOrientation
== kTXNVertical
)
2319 if ( mlte
->m_sbVertical
)
2321 SetControl32BitValue( mlte
->m_sbVertical
, value
) ;
2322 SetControl32BitMaximum( mlte
->m_sbVertical
, maximum
) ;
2323 mlte
->m_lastVerticalValue
= value
;
2328 pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
)
2330 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) GetControlReference( controlRef
) ;
2334 if ( controlRef
!= mlte
->m_sbVertical
&& controlRef
!= mlte
->m_sbHorizontal
)
2338 bool isHorizontal
= ( controlRef
== mlte
->m_sbHorizontal
) ;
2340 SInt32 minimum
= 0 ;
2341 SInt32 maximum
= GetControl32BitMaximum( controlRef
) ;
2342 SInt32 value
= GetControl32BitValue( controlRef
) ;
2347 case kControlDownButtonPart
:
2351 case kControlUpButtonPart
:
2355 case kControlPageDownPart
:
2356 delta
= GetControlViewSize( controlRef
) ;
2359 case kControlPageUpPart
:
2360 delta
= -GetControlViewSize( controlRef
) ;
2363 case kControlIndicatorPart
:
2364 delta
= value
- (isHorizontal
? mlte
->m_lastHorizontalValue
: mlte
->m_lastVerticalValue
) ;
2373 SInt32 newValue
= value
;
2375 if ( partCode
!= kControlIndicatorPart
)
2377 if ( value
+ delta
< minimum
)
2378 delta
= minimum
- value
;
2379 if ( value
+ delta
> maximum
)
2380 delta
= maximum
- value
;
2382 SetControl32BitValue( controlRef
, value
+ delta
) ;
2383 newValue
= value
+ delta
;
2386 SInt32 verticalDelta
= isHorizontal
? 0 : delta
;
2387 SInt32 horizontalDelta
= isHorizontal
? delta
: 0 ;
2390 mlte
->m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
,
2391 &verticalDelta
, &horizontalDelta
);
2392 verify_noerr( err
);
2395 mlte
->m_lastHorizontalValue
= newValue
;
2397 mlte
->m_lastVerticalValue
= newValue
;
2402 // make correct activations
2403 void wxMacMLTEClassicControl::MacActivatePaneText(bool setActive
)
2405 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference(m_controlRef
);
2407 wxMacWindowClipper
clipper( textctrl
) ;
2408 TXNActivate( m_txn
, m_txnFrameID
, setActive
);
2410 ControlRef controlFocus
= 0 ;
2411 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2412 if ( controlFocus
== m_controlRef
)
2413 TXNFocus( m_txn
, setActive
);
2416 void wxMacMLTEClassicControl::MacFocusPaneText(bool setFocus
)
2418 TXNFocus( m_txn
, setFocus
);
2421 // guards against inappropriate redraw (hidden objects drawing onto window)
2423 void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis
)
2425 ControlRef controlFocus
= 0 ;
2426 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2428 if ( !vis
&& (controlFocus
== m_controlRef
) )
2429 SetKeyboardFocus( m_txnWindow
, m_controlRef
, kControlFocusNoPart
) ;
2431 TXNControlTag iControlTags
[1] = { kTXNVisibilityTag
};
2432 TXNControlData iControlData
[1] = { { (UInt32
)false } };
2434 verify_noerr( TXNGetTXNObjectControls( m_txn
, 1, iControlTags
, iControlData
) ) ;
2436 if ( iControlData
[0].uValue
!= vis
)
2438 iControlData
[0].uValue
= vis
;
2439 verify_noerr( TXNSetTXNObjectControls( m_txn
, false , 1, iControlTags
, iControlData
) ) ;
2442 // currently, we always clip as partial visibility (overlapped) visibility is also a problem,
2443 // if we run into further problems we might set the FrameBounds to an empty rect here
2446 // make sure that the TXNObject is at the right position
2448 void wxMacMLTEClassicControl::MacUpdatePosition()
2450 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2451 if ( textctrl
== NULL
)
2455 UMAGetControlBoundsInWindowCoords( m_controlRef
, &bounds
);
2457 wxRect visRect
= textctrl
->MacGetClippedClientRect() ;
2458 Rect visBounds
= { visRect
.y
, visRect
.x
, visRect
.y
+ visRect
.height
, visRect
.x
+ visRect
.width
} ;
2461 textctrl
->MacWindowToRootWindow( &x
, &y
) ;
2462 OffsetRect( &visBounds
, x
, y
) ;
2464 if ( !EqualRect( &bounds
, &m_txnControlBounds
) || !EqualRect( &visBounds
, &m_txnVisBounds
) )
2466 m_txnControlBounds
= bounds
;
2467 m_txnVisBounds
= visBounds
;
2468 wxMacWindowClipper
cl( textctrl
) ;
2470 #ifdef __WXMAC_OSX__
2471 if ( m_sbHorizontal
|| m_sbVertical
)
2473 int w
= bounds
.right
- bounds
.left
;
2474 int h
= bounds
.bottom
- bounds
.top
;
2476 if ( m_sbHorizontal
)
2480 sbBounds
.left
= -1 ;
2481 sbBounds
.top
= h
- 14 ;
2482 sbBounds
.right
= w
+ 1 ;
2483 sbBounds
.bottom
= h
+ 1 ;
2485 SetControlBounds( m_sbHorizontal
, &sbBounds
) ;
2486 SetControlViewSize( m_sbHorizontal
, w
) ;
2493 sbBounds
.left
= w
- 14 ;
2495 sbBounds
.right
= w
+ 1 ;
2496 sbBounds
.bottom
= m_sbHorizontal
? h
- 14 : h
+ 1 ;
2498 SetControlBounds( m_sbVertical
, &sbBounds
) ;
2499 SetControlViewSize( m_sbVertical
, h
) ;
2504 TXNLongRect olddestRect
;
2505 TXNGetRectBounds( m_txn
, &oldviewRect
, &olddestRect
, NULL
) ;
2507 Rect viewRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2508 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
2509 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
2510 TXNLongRect destRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2511 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
2512 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
2514 if ( olddestRect
.right
>= 10000 )
2515 destRect
.right
= destRect
.left
+ 32000 ;
2517 if ( olddestRect
.bottom
>= 0x20000000 )
2518 destRect
.bottom
= destRect
.top
+ 0x40000000 ;
2520 SectRect( &viewRect
, &visBounds
, &viewRect
) ;
2521 TXNSetRectBounds( m_txn
, &viewRect
, &destRect
, true ) ;
2526 m_txnControlBounds
.top
,
2527 m_txnControlBounds
.left
,
2528 m_txnControlBounds
.bottom
- (m_sbHorizontal
? 14 : 0),
2529 m_txnControlBounds
.right
- (m_sbVertical
? 14 : 0),
2535 m_txn
, m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2536 wxMax( m_txnControlBounds
.bottom
, m_txnControlBounds
.top
),
2537 wxMax( m_txnControlBounds
.right
, m_txnControlBounds
.left
), m_txnFrameID
);
2540 // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
2541 // movement, therefore we have to force it
2543 // this problem has been reported in OSX as well, so we use this here once again
2545 TXNLongRect textRect
;
2546 TXNGetRectBounds( m_txn
, NULL
, NULL
, &textRect
) ;
2547 if ( textRect
.left
< m_txnControlBounds
.left
)
2548 TXNShowSelection( m_txn
, kTXNShowStart
) ;
2552 void wxMacMLTEClassicControl::SetRect( Rect
*r
)
2554 wxMacControl::SetRect( r
) ;
2555 MacUpdatePosition() ;
2558 void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16 thePart
)
2560 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2561 if ( textctrl
== NULL
)
2564 if ( textctrl
->MacIsReallyShown() )
2566 wxMacWindowClipper
clipper( textctrl
) ;
2567 TXNDraw( m_txn
, NULL
) ;
2571 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
2573 Point where
= { y
, x
} ;
2574 ControlPartCode result
= kControlNoPart
;
2576 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
2577 if ( (textctrl
!= NULL
) && textctrl
->MacIsReallyShown() )
2579 if (PtInRect( where
, &m_txnControlBounds
))
2581 result
= kControlEditTextPart
;
2585 // sometimes we get the coords also in control local coordinates, therefore test again
2587 textctrl
->MacClientToRootWindow( &x
, &y
) ;
2591 if (PtInRect( where
, &m_txnControlBounds
))
2592 result
= kControlEditTextPart
;
2599 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x
, wxInt16 y
, void* actionProc
)
2601 ControlPartCode result
= kControlNoPart
;
2603 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
2604 if ( (textctrl
!= NULL
) && textctrl
->MacIsReallyShown() )
2606 Point startPt
= { y
, x
} ;
2608 // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them
2610 textctrl
->MacClientToRootWindow( &x
, &y
) ;
2614 switch (MacControlUserPaneHitTestProc( startPt
.h
, startPt
.v
))
2616 case kControlEditTextPart
:
2618 wxMacWindowClipper
clipper( textctrl
) ;
2621 ConvertEventRefToEventRecord( (EventRef
) wxTheApp
->MacGetCurrentEvent() , &rec
) ;
2622 TXNClick( m_txn
, &rec
);
2634 void wxMacMLTEClassicControl::MacControlUserPaneIdleProc()
2636 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2637 if ( textctrl
== NULL
)
2640 if (textctrl
->MacIsReallyShown())
2642 if (IsControlActive(m_controlRef
))
2646 wxMacWindowClipper
clipper( textctrl
) ;
2651 if (PtInRect(mousep
, &m_txnControlBounds
))
2653 RgnHandle theRgn
= NewRgn();
2654 RectRgn(theRgn
, &m_txnControlBounds
);
2655 TXNAdjustCursor(m_txn
, theRgn
);
2662 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneKeyDownProc (wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
2664 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2665 if ( textctrl
== NULL
)
2666 return kControlNoPart
;
2668 wxMacWindowClipper
clipper( textctrl
) ;
2671 memset( &ev
, 0 , sizeof( ev
) ) ;
2673 ev
.modifiers
= modifiers
;
2674 ev
.message
= ((keyCode
<< 8) & keyCodeMask
) | (charCode
& charCodeMask
);
2675 TXNKeyDown( m_txn
, &ev
);
2677 return kControlEntireControl
;
2680 void wxMacMLTEClassicControl::MacControlUserPaneActivateProc(bool activating
)
2682 MacActivatePaneText( activating
);
2685 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action
)
2687 ControlPartCode focusResult
= kControlFocusNoPart
;
2689 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2690 if ( textctrl
== NULL
)
2693 wxMacWindowClipper
clipper( textctrl
) ;
2695 ControlRef controlFocus
= NULL
;
2696 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2697 bool wasFocused
= ( controlFocus
== m_controlRef
) ;
2701 case kControlFocusPrevPart
:
2702 case kControlFocusNextPart
:
2703 MacFocusPaneText( !wasFocused
);
2704 focusResult
= (!wasFocused
? (ControlPartCode
) kControlEditTextPart
: (ControlPartCode
) kControlFocusNoPart
);
2707 case kControlFocusNoPart
:
2709 MacFocusPaneText( false );
2710 focusResult
= kControlFocusNoPart
;
2717 void wxMacMLTEClassicControl::MacControlUserPaneBackgroundProc( void *info
)
2721 wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
2722 const wxString
& str
,
2724 const wxSize
& size
, long style
)
2725 : wxMacMLTEControl( wxPeer
)
2727 m_font
= wxPeer
->GetFont() ;
2728 m_windowStyle
= style
;
2729 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
2732 kControlSupportsEmbedding
| kControlSupportsFocus
| kControlWantsIdle
2733 | kControlWantsActivate
| kControlHandlesTracking
2734 // | kControlHasSpecialBackground
2735 | kControlGetsFocusOnClick
| kControlSupportsLiveFeedback
;
2737 OSStatus err
= ::CreateUserPaneControl(
2738 MAC_WXHWND(wxPeer
->GetParent()->MacGetTopLevelWindowRef()),
2739 &bounds
, featureSet
, &m_controlRef
);
2740 verify_noerr( err
);
2744 AdjustCreationAttributes( *wxWHITE
, true ) ;
2746 MacSetObjectVisibility( wxPeer
->MacIsReallyShown() ) ;
2750 wxMacConvertNewlines10To13( &st
) ;
2751 wxMacWindowClipper
clipper( m_peer
) ;
2752 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
2753 TXNSetSelection( m_txn
, 0, 0 ) ;
2757 wxMacMLTEClassicControl::~wxMacMLTEClassicControl()
2759 TXNDeleteObject( m_txn
);
2763 void wxMacMLTEClassicControl::VisibilityChanged(bool shown
)
2765 MacSetObjectVisibility( shown
) ;
2766 wxMacControl::VisibilityChanged( shown
) ;
2769 void wxMacMLTEClassicControl::SuperChangedPosition()
2771 MacUpdatePosition() ;
2772 wxMacControl::SuperChangedPosition() ;
2775 #ifdef __WXMAC_OSX__
2777 ControlUserPaneDrawUPP gTPDrawProc
= NULL
;
2778 ControlUserPaneHitTestUPP gTPHitProc
= NULL
;
2779 ControlUserPaneTrackingUPP gTPTrackProc
= NULL
;
2780 ControlUserPaneIdleUPP gTPIdleProc
= NULL
;
2781 ControlUserPaneKeyDownUPP gTPKeyProc
= NULL
;
2782 ControlUserPaneActivateUPP gTPActivateProc
= NULL
;
2783 ControlUserPaneFocusUPP gTPFocusProc
= NULL
;
2785 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
2787 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2788 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2790 win
->MacControlUserPaneDrawProc( part
) ;
2793 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
2795 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2796 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2798 return win
->MacControlUserPaneHitTestProc( where
.h
, where
.v
) ;
2800 return kControlNoPart
;
2803 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
2805 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2806 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2808 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
2810 return kControlNoPart
;
2813 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
2815 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2816 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2818 win
->MacControlUserPaneIdleProc() ;
2821 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
2823 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2824 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2826 return win
->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
2828 return kControlNoPart
;
2831 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
2833 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2834 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2836 win
->MacControlUserPaneActivateProc( activating
) ;
2839 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
2841 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2842 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2844 return win
->MacControlUserPaneFocusProc( action
) ;
2846 return kControlNoPart
;
2850 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
2852 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2853 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2855 win
->MacControlUserPaneBackgroundProc(info
) ;
2859 #endif // __WXMAC_OSX__
2861 // TXNRegisterScrollInfoProc
2863 OSStatus
wxMacMLTEClassicControl::DoCreate()
2866 OSStatus err
= noErr
;
2868 // set up our globals
2869 #ifdef __WXMAC_OSX__
2870 if (gTPDrawProc
== NULL
) gTPDrawProc
= NewControlUserPaneDrawUPP(wxMacControlUserPaneDrawProc
);
2871 if (gTPHitProc
== NULL
) gTPHitProc
= NewControlUserPaneHitTestUPP(wxMacControlUserPaneHitTestProc
);
2872 if (gTPTrackProc
== NULL
) gTPTrackProc
= NewControlUserPaneTrackingUPP(wxMacControlUserPaneTrackingProc
);
2873 if (gTPIdleProc
== NULL
) gTPIdleProc
= NewControlUserPaneIdleUPP(wxMacControlUserPaneIdleProc
);
2874 if (gTPKeyProc
== NULL
) gTPKeyProc
= NewControlUserPaneKeyDownUPP(wxMacControlUserPaneKeyDownProc
);
2875 if (gTPActivateProc
== NULL
) gTPActivateProc
= NewControlUserPaneActivateUPP(wxMacControlUserPaneActivateProc
);
2876 if (gTPFocusProc
== NULL
) gTPFocusProc
= NewControlUserPaneFocusUPP(wxMacControlUserPaneFocusProc
);
2878 if (gTXNScrollInfoProc
== NULL
) gTXNScrollInfoProc
= NewTXNScrollInfoUPP(TXNScrollInfoProc
) ;
2879 if (gTXNScrollActionProc
== NULL
) gTXNScrollActionProc
= NewControlActionUPP(TXNScrollActionProc
) ;
2882 // set the initial settings for our private data
2884 m_txnWindow
= GetControlOwner(m_controlRef
);
2885 m_txnPort
= (GrafPtr
) GetWindowPort(m_txnWindow
);
2887 #ifdef __WXMAC_OSX__
2888 // set up the user pane procedures
2889 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneDrawProcTag
, sizeof(gTPDrawProc
), &gTPDrawProc
);
2890 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneHitTestProcTag
, sizeof(gTPHitProc
), &gTPHitProc
);
2891 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneTrackingProcTag
, sizeof(gTPTrackProc
), &gTPTrackProc
);
2892 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneIdleProcTag
, sizeof(gTPIdleProc
), &gTPIdleProc
);
2893 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneKeyDownProcTag
, sizeof(gTPKeyProc
), &gTPKeyProc
);
2894 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneActivateProcTag
, sizeof(gTPActivateProc
), &gTPActivateProc
);
2895 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneFocusProcTag
, sizeof(gTPFocusProc
), &gTPFocusProc
);
2898 // calculate the rectangles used by the control
2899 UMAGetControlBoundsInWindowCoords( m_controlRef
, &bounds
);
2901 m_txnControlBounds
= bounds
;
2902 m_txnVisBounds
= bounds
;
2907 GetGWorld( &origPort
, &origDev
) ;
2908 SetPort( m_txnPort
);
2910 // create the new edit field
2911 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( m_windowStyle
);
2913 #ifdef __WXMAC_OSX__
2914 // the scrollbars are not correctly embedded but are inserted at the root:
2915 // this gives us problems as we have erratic redraws even over the structure area
2917 m_sbHorizontal
= 0 ;
2919 m_lastHorizontalValue
= 0 ;
2920 m_lastVerticalValue
= 0 ;
2922 Rect sb
= { 0 , 0 , 0 , 0 } ;
2923 if ( frameOptions
& kTXNWantVScrollBarMask
)
2925 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbVertical
);
2926 SetControlReference( m_sbVertical
, (SInt32
)this );
2927 SetControlAction( m_sbVertical
, gTXNScrollActionProc
);
2928 ShowControl( m_sbVertical
);
2929 EmbedControl( m_sbVertical
, m_controlRef
);
2930 frameOptions
&= ~kTXNWantVScrollBarMask
;
2933 if ( frameOptions
& kTXNWantHScrollBarMask
)
2935 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbHorizontal
);
2936 SetControlReference( m_sbHorizontal
, (SInt32
)this );
2937 SetControlAction( m_sbHorizontal
, gTXNScrollActionProc
);
2938 ShowControl( m_sbHorizontal
);
2939 EmbedControl( m_sbHorizontal
, m_controlRef
);
2940 frameOptions
&= ~(kTXNWantHScrollBarMask
| kTXNDrawGrowIconMask
);
2946 NULL
, m_txnWindow
, &bounds
, frameOptions
,
2947 kTXNTextEditStyleFrameType
, kTXNTextensionFile
, kTXNSystemDefaultEncoding
,
2948 &m_txn
, &m_txnFrameID
, NULL
);
2949 verify_noerr( err
);
2952 TXNControlTag iControlTags
[] = { kTXNUseCarbonEvents
};
2953 TXNControlData iControlData
[] = { { (UInt32
)&cInfo
} };
2954 int toptag
= WXSIZEOF( iControlTags
) ;
2955 TXNCarbonEventInfo cInfo
;
2956 cInfo
.useCarbonEvents
= false ;
2959 cInfo
.fDictionary
= NULL
;
2961 verify_noerr( TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) );
2964 #ifdef __WXMAC_OSX__
2965 TXNRegisterScrollInfoProc( m_txn
, gTXNScrollInfoProc
, (SInt32
)this );
2968 SetGWorld( origPort
, origDev
) ;
2973 // ----------------------------------------------------------------------------
2974 // MLTE control implementation (OSX part)
2975 // ----------------------------------------------------------------------------
2977 #if TARGET_API_MAC_OSX
2979 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
2981 // tiger multi-line textcontrols with no CR in the entire content
2982 // don't scroll automatically, so we need a hack.
2983 // This attempt only works 'before' the key (ie before CallNextEventHandler)
2984 // is processed, thus the scrolling always occurs one character too late, but
2985 // better than nothing ...
2987 static const EventTypeSpec eventList
[] =
2989 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
2992 static pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
2994 OSStatus result
= eventNotHandledErr
;
2995 wxMacMLTEHIViewControl
* focus
= (wxMacMLTEHIViewControl
*) data
;
2997 switch ( GetEventKind( event
) )
2999 case kEventTextInputUnicodeForKeyEvent
:
3001 if ( UMAGetSystemVersion() >= 0x1040 )
3003 TXNOffset from
, to
;
3004 TXNGetSelection( focus
->GetTXNObject() , &from
, &to
) ;
3006 TXNShowSelection( focus
->GetTXNObject() , kTXNShowStart
);
3008 result
= CallNextEventHandler(handler
,event
);
3018 static pascal OSStatus
wxMacTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
3020 OSStatus result
= eventNotHandledErr
;
3022 switch ( GetEventClass( event
) )
3024 case kEventClassTextInput
:
3025 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
3034 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTextControlEventHandler
)
3036 wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
3037 const wxString
& str
,
3039 const wxSize
& size
, long style
) : wxMacMLTEControl( wxPeer
)
3041 m_font
= wxPeer
->GetFont() ;
3042 m_windowStyle
= style
;
3043 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
3045 wxMacConvertNewlines10To13( &st
) ;
3048 { bounds
.left
, bounds
.top
},
3049 { bounds
.right
- bounds
.left
, bounds
.bottom
- bounds
.top
} } ;
3051 m_scrollView
= NULL
;
3052 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( style
) ;
3053 if ( frameOptions
& (kTXNWantVScrollBarMask
| kTXNWantHScrollBarMask
) )
3056 (frameOptions
& kTXNWantHScrollBarMask
? kHIScrollViewOptionsHorizScroll
: 0)
3057 | (frameOptions
& kTXNWantVScrollBarMask
? kHIScrollViewOptionsVertScroll
: 0) ,
3060 HIViewSetFrame( m_scrollView
, &hr
);
3061 HIViewSetVisible( m_scrollView
, true );
3065 HITextViewCreate( NULL
, 0, frameOptions
, &m_textView
) ;
3066 m_txn
= HITextViewGetTXNObject( m_textView
) ;
3067 HIViewSetVisible( m_textView
, true ) ;
3070 HIViewAddSubview( m_scrollView
, m_textView
) ;
3071 m_controlRef
= m_scrollView
;
3072 wxPeer
->MacInstallEventHandler( (WXWidget
) m_textView
) ;
3076 HIViewSetFrame( m_textView
, &hr
);
3077 m_controlRef
= m_textView
;
3080 AdjustCreationAttributes( *wxWHITE
, true ) ;
3082 wxMacWindowClipper
c( m_peer
) ;
3083 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
3085 TXNSetSelection( m_txn
, 0, 0 );
3086 TXNShowSelection( m_txn
, kTXNShowStart
);
3088 InstallControlEventHandler( m_textView
, GetwxMacTextControlEventHandlerUPP(),
3089 GetEventTypeCount(eventList
), eventList
, this,
3090 &m_textEventHandlerRef
);
3093 wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl()
3095 ::RemoveEventHandler( m_textEventHandlerRef
) ;
3098 OSStatus
wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart
)
3100 return SetKeyboardFocus( GetControlOwner( m_textView
), m_textView
, focusPart
) ;
3103 bool wxMacMLTEHIViewControl::HasFocus() const
3105 ControlRef control
;
3106 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
3107 return control
== m_textView
;
3110 void wxMacMLTEHIViewControl::SetBackground( const wxBrush
&brush
)
3112 wxMacMLTEControl::SetBackground( brush
) ;
3115 CGColorSpaceRef rgbSpace
= CGColorSpaceCreateDeviceRGB();
3116 RGBColor col
= MAC_WXCOLORREF(brush
.GetColour().GetPixel()) ;
3118 float component
[4] ;
3119 component
[0] = col
.red
/ 65536.0 ;
3120 component
[1] = col
.green
/ 65536.0 ;
3121 component
[2] = col
.blue
/ 65536.0 ;
3122 component
[3] = 1.0 ; // alpha
3124 CGColorRef color
= CGColorCreate( rgbSpace
, component
);
3125 HITextViewSetBackgroundColor( m_textView
, color
);
3126 CGColorSpaceRelease( rgbSpace
);
3130 #endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
3135 #endif // wxUSE_TEXTCTRL