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))
484 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
489 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
490 if ( UMAGetSystemVersion() >= 0x1030 && !forceMLTE
)
492 if ( m_windowStyle
& wxTE_MULTILINE
)
493 m_peer
= new wxMacMLTEHIViewControl( this , str
, pos
, size
, style
) ;
499 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
500 if ( !(m_windowStyle
& wxTE_MULTILINE
) && !forceMLTE
)
503 m_peer
= new wxMacUnicodeTextControl( this , str
, pos
, size
, style
) ;
508 // the horizontal single line scrolling bug that made us keep
509 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
511 m_peer
= new wxMacMLTEClassicControl( this , str
, pos
, size
, style
) ;
514 MacPostControlCreate(pos
, size
) ;
516 // only now the embedding is correct and we can do a positioning update
518 MacSuperChangedPosition() ;
520 if ( m_windowStyle
& wxTE_READONLY
)
521 SetEditable( false ) ;
523 SetCursor( wxCursor( wxCURSOR_IBEAM
) ) ;
528 void wxTextCtrl::MacSuperChangedPosition()
530 wxWindow::MacSuperChangedPosition() ;
531 GetPeer()->SuperChangedPosition() ;
534 void wxTextCtrl::MacVisibilityChanged()
536 GetPeer()->VisibilityChanged( MacIsReallyShown() ) ;
539 void wxTextCtrl::MacEnabledStateChanged()
543 wxString
wxTextCtrl::GetValue() const
545 return GetPeer()->GetStringValue() ;
548 void wxTextCtrl::GetSelection(long* from
, long* to
) const
550 GetPeer()->GetSelection( from
, to
) ;
553 void wxTextCtrl::DoSetValue(const wxString
& str
, int flags
)
556 if ( GetValue() == str
)
559 GetPeer()->SetStringValue( str
) ;
561 if ( (flags
& SetValue_SendEvent
) && m_triggerOnSetValue
)
563 SendTextUpdatedEvent();
567 void wxTextCtrl::SetMaxLength(unsigned long len
)
572 bool wxTextCtrl::SetFont( const wxFont
& font
)
574 if ( !wxTextCtrlBase::SetFont( font
) )
577 GetPeer()->SetFont( font
, GetForegroundColour() , GetWindowStyle() ) ;
582 bool wxTextCtrl::SetStyle(long start
, long end
, const wxTextAttr
& style
)
584 GetPeer()->SetStyle( start
, end
, style
) ;
589 bool wxTextCtrl::SetDefaultStyle(const wxTextAttr
& style
)
591 wxTextCtrlBase::SetDefaultStyle( style
) ;
592 SetStyle( kTXNUseCurrentSelection
, kTXNUseCurrentSelection
, GetDefaultStyle() ) ;
597 // Clipboard operations
599 void wxTextCtrl::Copy()
605 void wxTextCtrl::Cut()
611 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
612 event
.SetEventObject( this );
613 GetEventHandler()->ProcessEvent( event
);
617 void wxTextCtrl::Paste()
623 // TODO: eventually we should add setting the default style again
625 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
626 event
.SetEventObject( this );
627 GetEventHandler()->ProcessEvent( event
);
631 bool wxTextCtrl::CanCopy() const
633 // Can copy if there's a selection
635 GetSelection( &from
, &to
);
640 bool wxTextCtrl::CanCut() const
645 // Can cut if there's a selection
647 GetSelection( &from
, &to
);
652 bool wxTextCtrl::CanPaste() const
657 return GetPeer()->CanPaste() ;
660 void wxTextCtrl::SetEditable(bool editable
)
662 if ( editable
!= m_editable
)
664 m_editable
= editable
;
665 GetPeer()->SetEditable( editable
) ;
669 void wxTextCtrl::SetInsertionPoint(long pos
)
671 SetSelection( pos
, pos
) ;
674 void wxTextCtrl::SetInsertionPointEnd()
676 wxTextPos pos
= GetLastPosition();
677 SetInsertionPoint( pos
);
680 long wxTextCtrl::GetInsertionPoint() const
683 GetSelection( &begin
, &end
) ;
688 wxTextPos
wxTextCtrl::GetLastPosition() const
690 return GetPeer()->GetLastPosition() ;
693 void wxTextCtrl::Replace(long from
, long to
, const wxString
& str
)
695 GetPeer()->Replace( from
, to
, str
) ;
698 void wxTextCtrl::Remove(long from
, long to
)
700 GetPeer()->Remove( from
, to
) ;
703 void wxTextCtrl::SetSelection(long from
, long to
)
705 GetPeer()->SetSelection( from
, to
) ;
708 void wxTextCtrl::WriteText(const wxString
& str
)
710 // TODO: this MPRemoting will be moved into a remoting peer proxy for any command
711 if ( !wxIsMainThread() )
713 // unfortunately CW 8 is not able to correctly deduce the template types,
714 // so we have to instantiate explicitly
715 wxMacMPRemoteGUICall
<wxTextCtrl
,wxString
>( this , &wxTextCtrl::WriteText
, str
) ;
720 GetPeer()->WriteText( str
) ;
723 void wxTextCtrl::AppendText(const wxString
& text
)
725 SetInsertionPointEnd();
729 void wxTextCtrl::Clear()
734 bool wxTextCtrl::IsModified() const
739 bool wxTextCtrl::IsEditable() const
741 return IsEnabled() && m_editable
;
744 bool wxTextCtrl::AcceptsFocus() const
746 // we don't want focus if we can't be edited
747 return /*IsEditable() && */ wxControl::AcceptsFocus();
750 wxSize
wxTextCtrl::DoGetBestSize() const
754 // these are the numbers from the HIG:
755 // we reduce them by the borders first
758 switch ( m_windowVariant
)
760 case wxWINDOW_VARIANT_NORMAL
:
764 case wxWINDOW_VARIANT_SMALL
:
768 case wxWINDOW_VARIANT_MINI
:
777 // as the above numbers have some free space around the text
778 // we get 5 lines like this anyway
779 if ( m_windowStyle
& wxTE_MULTILINE
)
782 if ( !HasFlag(wxNO_BORDER
) )
785 return wxSize(wText
, hText
);
788 // ----------------------------------------------------------------------------
790 // ----------------------------------------------------------------------------
792 void wxTextCtrl::Undo()
798 void wxTextCtrl::Redo()
804 bool wxTextCtrl::CanUndo() const
809 return GetPeer()->CanUndo() ;
812 bool wxTextCtrl::CanRedo() const
817 return GetPeer()->CanRedo() ;
820 void wxTextCtrl::MarkDirty()
825 void wxTextCtrl::DiscardEdits()
830 int wxTextCtrl::GetNumberOfLines() const
832 return GetPeer()->GetNumberOfLines() ;
835 long wxTextCtrl::XYToPosition(long x
, long y
) const
837 return GetPeer()->XYToPosition( x
, y
) ;
840 bool wxTextCtrl::PositionToXY(long pos
, long *x
, long *y
) const
842 return GetPeer()->PositionToXY( pos
, x
, y
) ;
845 void wxTextCtrl::ShowPosition(long pos
)
847 return GetPeer()->ShowPosition(pos
) ;
850 int wxTextCtrl::GetLineLength(long lineNo
) const
852 return GetPeer()->GetLineLength(lineNo
) ;
855 wxString
wxTextCtrl::GetLineText(long lineNo
) const
857 return GetPeer()->GetLineText(lineNo
) ;
860 void wxTextCtrl::Command(wxCommandEvent
& event
)
862 SetValue(event
.GetString());
863 ProcessCommand(event
);
866 void wxTextCtrl::OnDropFiles(wxDropFilesEvent
& event
)
868 // By default, load the first file into the text window.
869 if (event
.GetNumberOfFiles() > 0)
870 LoadFile( event
.GetFiles()[0] );
873 void wxTextCtrl::OnEraseBackground(wxEraseEvent
& event
)
875 // all erasing should be done by the real mac control implementation
876 // while this is true for MLTE under classic, the HITextView is somehow
877 // transparent but background erase is not working correctly, so intercept
878 // things while we can...
882 void wxTextCtrl::OnChar(wxKeyEvent
& event
)
884 int key
= event
.GetKeyCode() ;
885 bool eat_key
= false ;
887 if ( key
== 'a' && event
.MetaDown() )
894 if ( key
== 'c' && event
.MetaDown() )
902 if ( !IsEditable() && key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_DOWN
&& key
!= WXK_UP
&& key
!= WXK_TAB
&&
903 !( key
== WXK_RETURN
&& ( (m_windowStyle
& wxTE_PROCESS_ENTER
) || (m_windowStyle
& wxTE_MULTILINE
) ) )
904 // && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
911 // Check if we have reached the max # of chars (if it is set), but still
912 // allow navigation and deletion
913 if ( !IsMultiLine() && m_maxLength
&& GetValue().length() >= m_maxLength
&&
914 key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_TAB
&&
915 key
!= WXK_BACK
&& !( key
== WXK_RETURN
&& (m_windowStyle
& wxTE_PROCESS_ENTER
) )
918 // eat it, we don't want to add more than allowed # of characters
920 // TODO: generate EVT_TEXT_MAXLEN()
924 // assume that any key not processed yet is going to modify the control
927 if ( key
== 'v' && event
.MetaDown() )
935 if ( key
== 'x' && event
.MetaDown() )
946 if (m_windowStyle
& wxTE_PROCESS_ENTER
)
948 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, m_windowId
);
949 event
.SetEventObject( this );
950 event
.SetString( GetValue() );
951 if ( GetEventHandler()->ProcessEvent(event
) )
955 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
957 wxTopLevelWindow
*tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
958 if ( tlw
&& tlw
->GetDefaultItem() )
960 wxButton
*def
= wxDynamicCast(tlw
->GetDefaultItem(), wxButton
);
961 if ( def
&& def
->IsEnabled() )
963 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
964 event
.SetEventObject(def
);
971 // this will make wxWidgets eat the ENTER key so that
972 // we actually prevent line wrapping in a single line text control
978 if ( !(m_windowStyle
& wxTE_PROCESS_TAB
))
981 if (!event
.ShiftDown())
982 flags
|= wxNavigationKeyEvent::IsForward
;
983 if (event
.ControlDown())
984 flags
|= wxNavigationKeyEvent::WinChange
;
991 // This is necessary (don't know why);
992 // otherwise the tab will not be inserted.
993 WriteText(wxT("\t"));
1004 // perform keystroke handling
1008 if ( ( key
>= 0x20 && key
< WXK_START
) ||
1009 ( key
>= WXK_NUMPAD0
&& key
<= WXK_DIVIDE
) ||
1010 key
== WXK_RETURN
||
1011 key
== WXK_DELETE
||
1014 wxCommandEvent
event1(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
1015 event1
.SetEventObject( this );
1016 wxPostEvent( GetEventHandler(), event1
);
1020 // ----------------------------------------------------------------------------
1021 // standard handlers for standard edit menu events
1022 // ----------------------------------------------------------------------------
1024 void wxTextCtrl::OnCut(wxCommandEvent
& WXUNUSED(event
))
1029 void wxTextCtrl::OnCopy(wxCommandEvent
& WXUNUSED(event
))
1034 void wxTextCtrl::OnPaste(wxCommandEvent
& WXUNUSED(event
))
1039 void wxTextCtrl::OnUndo(wxCommandEvent
& WXUNUSED(event
))
1044 void wxTextCtrl::OnRedo(wxCommandEvent
& WXUNUSED(event
))
1049 void wxTextCtrl::OnDelete(wxCommandEvent
& WXUNUSED(event
))
1053 GetSelection( &from
, &to
);
1054 if (from
!= -1 && to
!= -1)
1058 void wxTextCtrl::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
1060 SetSelection(-1, -1);
1063 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent
& event
)
1065 event
.Enable( CanCut() );
1068 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent
& event
)
1070 event
.Enable( CanCopy() );
1073 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent
& event
)
1075 event
.Enable( CanPaste() );
1078 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent
& event
)
1080 event
.Enable( CanUndo() );
1083 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent
& event
)
1085 event
.Enable( CanRedo() );
1088 void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent
& event
)
1092 GetSelection( &from
, &to
);
1093 event
.Enable( from
!= -1 && to
!= -1 && from
!= to
&& IsEditable() ) ;
1096 void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent
& event
)
1098 event
.Enable(GetLastPosition() > 0);
1101 // CS: Context Menus only work with MLTE implementations or non-multiline HIViews at the moment
1103 void wxTextCtrl::OnContextMenu(wxContextMenuEvent
& event
)
1105 if ( GetPeer()->HasOwnContextMenu() )
1111 if (m_privateContextMenu
== NULL
)
1113 m_privateContextMenu
= new wxMenu
;
1114 m_privateContextMenu
->Append(wxID_UNDO
, _("&Undo"));
1115 m_privateContextMenu
->Append(wxID_REDO
, _("&Redo"));
1116 m_privateContextMenu
->AppendSeparator();
1117 m_privateContextMenu
->Append(wxID_CUT
, _("Cu&t"));
1118 m_privateContextMenu
->Append(wxID_COPY
, _("&Copy"));
1119 m_privateContextMenu
->Append(wxID_PASTE
, _("&Paste"));
1120 m_privateContextMenu
->Append(wxID_CLEAR
, _("&Delete"));
1121 m_privateContextMenu
->AppendSeparator();
1122 m_privateContextMenu
->Append(wxID_SELECTALL
, _("Select &All"));
1125 if (m_privateContextMenu
!= NULL
)
1126 PopupMenu(m_privateContextMenu
);
1129 bool wxTextCtrl::MacSetupCursor( const wxPoint
& pt
)
1131 if ( !GetPeer()->SetupCursor( pt
) )
1132 return wxWindow::MacSetupCursor( pt
) ;
1137 #if !TARGET_API_MAC_OSX
1139 // user pane implementation
1141 void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part
)
1143 GetPeer()->MacControlUserPaneDrawProc( part
) ;
1146 wxInt16
wxTextCtrl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
1148 return GetPeer()->MacControlUserPaneHitTestProc( x
, y
) ;
1151 wxInt16
wxTextCtrl::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
1153 return GetPeer()->MacControlUserPaneTrackingProc( x
, y
, actionProc
) ;
1156 void wxTextCtrl::MacControlUserPaneIdleProc()
1158 GetPeer()->MacControlUserPaneIdleProc( ) ;
1161 wxInt16
wxTextCtrl::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
1163 return GetPeer()->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
1166 void wxTextCtrl::MacControlUserPaneActivateProc(bool activating
)
1168 GetPeer()->MacControlUserPaneActivateProc( activating
) ;
1171 wxInt16
wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action
)
1173 return GetPeer()->MacControlUserPaneFocusProc( action
) ;
1176 void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info
)
1178 GetPeer()->MacControlUserPaneBackgroundProc( info
) ;
1183 // ----------------------------------------------------------------------------
1184 // implementation base class
1185 // ----------------------------------------------------------------------------
1187 wxMacTextControl::wxMacTextControl(wxTextCtrl
* peer
) :
1188 wxMacControl( peer
)
1192 wxMacTextControl::~wxMacTextControl()
1196 void wxMacTextControl::SetStyle(long start
, long end
, const wxTextAttr
& style
)
1200 void wxMacTextControl::Copy()
1204 void wxMacTextControl::Cut()
1208 void wxMacTextControl::Paste()
1212 bool wxMacTextControl::CanPaste() const
1217 void wxMacTextControl::SetEditable(bool editable
)
1221 wxTextPos
wxMacTextControl::GetLastPosition() const
1223 return GetStringValue().length() ;
1226 void wxMacTextControl::Replace( long from
, long to
, const wxString
&val
)
1228 SetSelection( from
, to
) ;
1232 void wxMacTextControl::Remove( long from
, long to
)
1234 SetSelection( from
, to
) ;
1235 WriteText( wxEmptyString
) ;
1238 void wxMacTextControl::Clear()
1240 SetStringValue( wxEmptyString
) ;
1243 bool wxMacTextControl::CanUndo() const
1248 void wxMacTextControl::Undo()
1252 bool wxMacTextControl::CanRedo() const
1257 void wxMacTextControl::Redo()
1261 long wxMacTextControl::XYToPosition(long x
, long y
) const
1266 bool wxMacTextControl::PositionToXY(long pos
, long *x
, long *y
) const
1271 void wxMacTextControl::ShowPosition( long WXUNUSED(pos
) )
1275 int wxMacTextControl::GetNumberOfLines() const
1277 ItemCount lines
= 0 ;
1278 wxString content
= GetStringValue() ;
1281 for (size_t i
= 0; i
< content
.length() ; i
++)
1283 if (content
[i
] == '\r')
1290 wxString
wxMacTextControl::GetLineText(long lineNo
) const
1292 // TODO: change this if possible to reflect real lines
1293 wxString content
= GetStringValue() ;
1297 for (size_t i
= 0; i
< content
.length() ; i
++)
1299 if (count
== lineNo
)
1301 // Add chars in line then
1304 for (size_t j
= i
; j
< content
.length(); j
++)
1306 if (content
[j
] == '\n')
1315 if (content
[i
] == '\n')
1319 return wxEmptyString
;
1322 int wxMacTextControl::GetLineLength(long lineNo
) const
1324 // TODO: change this if possible to reflect real lines
1325 wxString content
= GetStringValue() ;
1329 for (size_t i
= 0; i
< content
.length() ; i
++)
1331 if (count
== lineNo
)
1333 // Count chars in line then
1335 for (size_t j
= i
; j
< content
.length(); j
++)
1338 if (content
[j
] == '\n')
1345 if (content
[i
] == '\n')
1352 // ----------------------------------------------------------------------------
1353 // standard unicode control implementation
1354 // ----------------------------------------------------------------------------
1356 #if TARGET_API_MAC_OSX
1358 // the current unicode textcontrol implementation has a bug : only if the control
1359 // is currently having the focus, the selection can be retrieved by the corresponding
1360 // data tag. So we have a mirroring using a member variable
1361 // TODO : build event table using virtual member functions for wxMacControl
1363 static const EventTypeSpec unicodeTextControlEventList
[] =
1365 { kEventClassControl
, kEventControlSetFocusPart
} ,
1368 static pascal OSStatus
wxMacUnicodeTextControlControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
1370 OSStatus result
= eventNotHandledErr
;
1371 wxMacUnicodeTextControl
* focus
= (wxMacUnicodeTextControl
*) data
;
1372 wxMacCarbonEvent
cEvent( event
) ;
1374 switch ( GetEventKind( event
) )
1376 case kEventControlSetFocusPart
:
1378 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
1379 if ( controlPart
== kControlFocusNoPart
)
1381 // about to loose focus -> store selection to field
1382 focus
->GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
1384 result
= CallNextEventHandler(handler
,event
) ;
1385 if ( controlPart
!= kControlFocusNoPart
)
1387 // about to gain focus -> set selection from field
1388 focus
->SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
1399 static pascal OSStatus
wxMacUnicodeTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
1401 OSStatus result
= eventNotHandledErr
;
1403 switch ( GetEventClass( event
) )
1405 case kEventClassControl
:
1406 result
= wxMacUnicodeTextControlControlEventHandler( handler
, event
, data
) ;
1415 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler
)
1417 wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
,
1418 const wxString
& str
,
1420 const wxSize
& size
, long style
)
1421 : wxMacTextControl( wxPeer
)
1423 m_font
= wxPeer
->GetFont() ;
1424 m_windowStyle
= style
;
1425 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
1427 wxMacConvertNewlines10To13( &st
) ;
1428 wxMacCFStringHolder
cf(st
, m_font
.GetEncoding()) ;
1429 CFStringRef cfr
= cf
;
1430 Boolean isPassword
= ( m_windowStyle
& wxTE_PASSWORD
) != 0 ;
1431 m_valueTag
= isPassword
? kControlEditTextPasswordCFStringTag
: kControlEditTextCFStringTag
;
1433 OSStatus err
= CreateEditUnicodeTextControl(
1434 MAC_WXHWND(wxPeer
->MacGetTopLevelWindowRef()), &bounds
, cfr
,
1435 isPassword
, NULL
, &m_controlRef
) ;
1436 verify_noerr( err
);
1438 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
1439 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextSingleLineTag
, true ) ;
1441 InstallControlEventHandler( m_controlRef
, GetwxMacUnicodeTextControlEventHandlerUPP(),
1442 GetEventTypeCount(unicodeTextControlEventList
), unicodeTextControlEventList
, this,
1443 &m_focusHandlerRef
);
1446 wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
1448 ::RemoveEventHandler( m_focusHandlerRef
);
1451 void wxMacUnicodeTextControl::VisibilityChanged(bool shown
)
1453 if ( !(m_windowStyle
& wxTE_MULTILINE
) && shown
)
1455 // work around a refresh issue insofar as not always the entire content is shown,
1456 // even if this would be possible
1457 ControlEditTextSelectionRec sel
;
1458 CFStringRef value
= NULL
;
1460 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
1461 verify_noerr( GetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
1462 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
1463 verify_noerr( SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
1465 CFRelease( value
) ;
1469 wxString
wxMacUnicodeTextControl::GetStringValue() const
1472 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
1475 wxMacCFStringHolder
cf(value
) ;
1476 result
= cf
.AsString() ;
1480 wxMacConvertNewlines13To10( &result
) ;
1482 wxMacConvertNewlines10To13( &result
) ;
1488 void wxMacUnicodeTextControl::SetStringValue( const wxString
&str
)
1491 wxMacConvertNewlines10To13( &st
) ;
1492 wxMacCFStringHolder
cf( st
, m_font
.GetEncoding() ) ;
1493 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, cf
) ) ;
1496 void wxMacUnicodeTextControl::Copy()
1498 SendHICommand( kHICommandCopy
) ;
1501 void wxMacUnicodeTextControl::Cut()
1503 SendHICommand( kHICommandCut
) ;
1506 void wxMacUnicodeTextControl::Paste()
1508 SendHICommand( kHICommandPaste
) ;
1511 bool wxMacUnicodeTextControl::CanPaste() const
1516 void wxMacUnicodeTextControl::SetEditable(bool editable
)
1518 #if 0 // leads to problem because text cannot be selected anymore
1519 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextLockedTag
, (Boolean
) !editable
) ;
1523 void wxMacUnicodeTextControl::GetSelection( long* from
, long* to
) const
1525 ControlEditTextSelectionRec sel
;
1527 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ) ;
1532 *from
= sel
.selStart
;
1537 void wxMacUnicodeTextControl::SetSelection( long from
, long to
)
1539 ControlEditTextSelectionRec sel
;
1541 int textLength
= 0 ;
1542 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
1545 wxMacCFStringHolder
cf(value
) ;
1546 textLength
= cf
.AsString().length() ;
1549 if ((from
== -1) && (to
== -1))
1556 from
= wxMin(textLength
,wxMax(from
,0)) ;
1557 to
= wxMax(0,wxMin(textLength
,to
)) ;
1560 sel
.selStart
= from
;
1563 SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ;
1568 void wxMacUnicodeTextControl::WriteText( const wxString
& str
)
1571 wxMacConvertNewlines10To13( &st
) ;
1573 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
1576 wxMacCFStringHolder
cf(st
, m_font
.GetEncoding() ) ;
1577 CFStringRef value
= cf
;
1578 SetData
<CFStringRef
>( 0, kControlEditTextInsertCFStringRefTag
, &value
);
1583 wxString val
= GetStringValue() ;
1585 GetSelection( &start
, &end
) ;
1586 val
.Remove( start
, end
- start
) ;
1587 val
.insert( start
, str
) ;
1588 SetStringValue( val
) ;
1589 SetSelection( start
+ str
.length() , start
+ str
.length() ) ;
1595 // ----------------------------------------------------------------------------
1596 // MLTE control implementation (common part)
1597 // ----------------------------------------------------------------------------
1599 // if MTLE is read only, no changes at all are allowed, not even from
1600 // procedural API, in order to allow changes via API all the same we must undo
1601 // the readonly status while we are executing, this class helps to do so
1603 class wxMacEditHelper
1606 wxMacEditHelper( TXNObject txn
)
1608 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1610 TXNGetTXNObjectControls( m_txn
, 1 , tag
, m_data
) ;
1611 if ( m_data
[0].uValue
== kTXNReadOnly
)
1613 TXNControlData data
[] = { { kTXNReadWrite
} } ;
1614 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, data
) ;
1620 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1621 if ( m_data
[0].uValue
== kTXNReadOnly
)
1622 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, m_data
) ;
1627 TXNControlData m_data
[1] ;
1630 wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl
*peer
)
1631 : wxMacTextControl( peer
)
1633 SetNeedsFocusRect( true ) ;
1636 wxString
wxMacMLTEControl::GetStringValue() const
1640 Size actualSize
= 0;
1645 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNUnicodeTextData
);
1654 actualSize
= GetHandleSize( theText
) / sizeof(UniChar
) ;
1655 if ( actualSize
> 0 )
1657 wxChar
*ptr
= NULL
;
1659 #if SIZEOF_WCHAR_T == 2
1660 ptr
= new wxChar
[actualSize
+ 1] ;
1661 wxStrncpy( ptr
, (wxChar
*)(*theText
) , actualSize
) ;
1663 SetHandleSize( theText
, (actualSize
+ 1) * sizeof(UniChar
) ) ;
1665 (((UniChar
*)*theText
)[actualSize
]) = 0 ;
1666 wxMBConvUTF16 converter
;
1667 size_t noChars
= converter
.MB2WC( NULL
, (const char*)*theText
, 0 ) ;
1668 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Unable to count the number of characters in this string!") );
1669 ptr
= new wxChar
[noChars
+ 1] ;
1671 noChars
= converter
.MB2WC( ptr
, (const char*)*theText
, noChars
+ 1 ) ;
1672 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Conversion of string failed!") );
1674 HUnlock( theText
) ;
1677 ptr
[actualSize
] = 0 ;
1678 result
= wxString( ptr
) ;
1682 DisposeHandle( theText
) ;
1686 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1695 actualSize
= GetHandleSize( theText
) ;
1696 if ( actualSize
> 0 )
1699 result
= wxString( *theText
, wxConvLocal
, actualSize
) ;
1700 HUnlock( theText
) ;
1703 DisposeHandle( theText
) ;
1709 wxMacConvertNewlines13To10( &result
) ;
1711 wxMacConvertNewlines10To13( &result
) ;
1717 void wxMacMLTEControl::SetStringValue( const wxString
&str
)
1720 wxMacConvertNewlines10To13( &st
);
1724 wxMacWindowClipper
c( m_peer
) ;
1728 wxMacEditHelper
help( m_txn
);
1729 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
);
1732 TXNSetSelection( m_txn
, 0, 0 );
1733 TXNShowSelection( m_txn
, kTXNShowStart
);
1737 TXNFrameOptions
wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle
)
1739 TXNFrameOptions frameOptions
= kTXNDontDrawCaretWhenInactiveMask
;
1741 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1742 frameOptions
|= kTXNDoFontSubstitutionMask
;
1745 if ( ! (wxStyle
& wxTE_NOHIDESEL
) )
1746 frameOptions
|= kTXNDontDrawSelectionWhenInactiveMask
;
1748 if ( wxStyle
& (wxHSCROLL
| wxTE_DONTWRAP
) )
1749 frameOptions
|= kTXNWantHScrollBarMask
;
1751 if ( wxStyle
& wxTE_MULTILINE
)
1753 frameOptions
|= kTXNAlwaysWrapAtViewEdgeMask
;
1755 if ( !(wxStyle
& wxTE_NO_VSCROLL
) )
1757 frameOptions
|= kTXNWantVScrollBarMask
;
1759 // The following code causes drawing problems on 10.4. Perhaps it can be restored for
1760 // older versions of the OS, but I'm not sure it's appropriate to put a grow icon here
1761 // anyways, as AFAIK users can't actually use it to resize the text ctrl.
1762 // if ( frameOptions & kTXNWantHScrollBarMask )
1763 // frameOptions |= kTXNDrawGrowIconMask ;
1768 frameOptions
|= kTXNSingleLineOnlyMask
;
1771 return frameOptions
;
1774 void wxMacMLTEControl::AdjustCreationAttributes( const wxColour
&background
, bool visible
)
1776 TXNControlTag iControlTags
[] =
1778 kTXNDoFontSubstitution
,
1779 kTXNWordWrapStateTag
,
1781 TXNControlData iControlData
[] =
1787 int toptag
= WXSIZEOF( iControlTags
) ;
1789 if ( m_windowStyle
& wxTE_MULTILINE
)
1791 iControlData
[1].uValue
=
1792 (m_windowStyle
& wxTE_DONTWRAP
)
1797 OSStatus err
= TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) ;
1798 verify_noerr( err
);
1800 // setting the default font:
1801 // under 10.2 this causes a visible caret, therefore we avoid it
1803 if ( UMAGetSystemVersion() >= 0x1030 )
1809 GetThemeFont( kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1811 TXNTypeAttributes typeAttr
[] =
1813 { kTXNQDFontNameAttribute
, kTXNQDFontNameAttributeSize
, { (void*) fontName
} } ,
1814 { kTXNQDFontSizeAttribute
, kTXNFontSizeAttributeSize
, { (void*) (fontSize
<< 16) } } ,
1815 { kTXNQDFontStyleAttribute
, kTXNQDFontStyleAttributeSize
, { (void*) normal
} } ,
1818 err
= TXNSetTypeAttributes(
1819 m_txn
, sizeof(typeAttr
) / sizeof(TXNTypeAttributes
),
1820 typeAttr
, kTXNStartOffset
, kTXNEndOffset
);
1821 verify_noerr( err
);
1824 if ( m_windowStyle
& wxTE_PASSWORD
)
1826 UniChar c
= 0x00A5 ;
1827 err
= TXNEchoMode( m_txn
, c
, 0 , true );
1828 verify_noerr( err
);
1831 TXNBackground tback
;
1832 tback
.bgType
= kTXNBackgroundTypeRGB
;
1833 tback
.bg
.color
= MAC_WXCOLORREF( background
.GetPixel() );
1834 TXNSetBackground( m_txn
, &tback
);
1836 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1837 if ( UMAGetSystemVersion() >= 0x1040 )
1839 TXNCommandEventSupportOptions options
;
1840 if ( TXNGetCommandEventSupport( m_txn
, &options
) == noErr
)
1843 kTXNSupportEditCommandProcessing
1844 | kTXNSupportEditCommandUpdating
1845 | kTXNSupportSpellCheckCommandProcessing
1846 | kTXNSupportSpellCheckCommandUpdating
1847 | kTXNSupportFontCommandProcessing
1848 | kTXNSupportFontCommandUpdating
;
1850 TXNSetCommandEventSupport( m_txn
, options
) ;
1856 void wxMacMLTEControl::SetBackground( const wxBrush
&brush
)
1858 // currently only solid background are supported
1859 TXNBackground tback
;
1861 tback
.bgType
= kTXNBackgroundTypeRGB
;
1862 tback
.bg
.color
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() );
1863 TXNSetBackground( m_txn
, &tback
);
1866 void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
)
1868 TXNTypeAttributes typeAttr
[4] ;
1872 if ( style
.HasFont() )
1874 const wxFont
&font
= style
.GetFont() ;
1876 #if 0 // old version
1877 Str255 fontName
= "\pMonaco" ;
1878 SInt16 fontSize
= 12 ;
1879 Style fontStyle
= normal
;
1880 wxMacStringToPascal( font
.GetFaceName() , fontName
) ;
1881 fontSize
= font
.GetPointSize() ;
1882 if ( font
.GetUnderlined() )
1883 fontStyle
|= underline
;
1884 if ( font
.GetWeight() == wxBOLD
)
1886 if ( font
.GetStyle() == wxITALIC
)
1887 fontStyle
|= italic
;
1889 typeAttr
[attrCount
].tag
= kTXNQDFontNameAttribute
;
1890 typeAttr
[attrCount
].size
= kTXNQDFontNameAttributeSize
;
1891 typeAttr
[attrCount
].data
.dataPtr
= (void*)fontName
;
1894 typeAttr
[attrCount
].tag
= kTXNQDFontSizeAttribute
;
1895 typeAttr
[attrCount
].size
= kTXNFontSizeAttributeSize
;
1896 typeAttr
[attrCount
].data
.dataValue
= (fontSize
<< 16) ;
1899 typeAttr
[attrCount
].tag
= kTXNQDFontStyleAttribute
;
1900 typeAttr
[attrCount
].size
= kTXNQDFontStyleAttributeSize
;
1901 typeAttr
[attrCount
].data
.dataValue
= fontStyle
;
1904 typeAttr
[attrCount
].tag
= kTXNATSUIStyle
;
1905 typeAttr
[attrCount
].size
= kTXNATSUIStyleSize
;
1906 typeAttr
[attrCount
].data
.dataPtr
= font
.MacGetATSUStyle() ;
1911 if ( style
.HasTextColour() )
1913 color
= MAC_WXCOLORREF(style
.GetTextColour().GetPixel()) ;
1915 typeAttr
[attrCount
].tag
= kTXNQDFontColorAttribute
;
1916 typeAttr
[attrCount
].size
= kTXNQDFontColorAttributeSize
;
1917 typeAttr
[attrCount
].data
.dataPtr
= (void*) &color
;
1921 if ( attrCount
> 0 )
1923 verify_noerr( TXNSetTypeAttributes( m_txn
, attrCount
, typeAttr
, from
, to
) );
1924 // unfortunately the relayout is not automatic
1925 TXNRecalcTextLayout( m_txn
);
1929 void wxMacMLTEControl::SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
)
1931 wxMacEditHelper
help( m_txn
) ;
1932 TXNSetAttribute( wxTextAttr( foreground
, wxNullColour
, font
), kTXNStartOffset
, kTXNEndOffset
) ;
1935 void wxMacMLTEControl::SetStyle( long start
, long end
, const wxTextAttr
& style
)
1937 wxMacEditHelper
help( m_txn
) ;
1938 TXNSetAttribute( style
, start
, end
) ;
1941 void wxMacMLTEControl::Copy()
1943 ClearCurrentScrap();
1945 TXNConvertToPublicScrap();
1948 void wxMacMLTEControl::Cut()
1950 ClearCurrentScrap();
1952 TXNConvertToPublicScrap();
1955 void wxMacMLTEControl::Paste()
1957 TXNConvertFromPublicScrap();
1961 bool wxMacMLTEControl::CanPaste() const
1963 return TXNIsScrapPastable() ;
1966 void wxMacMLTEControl::SetEditable(bool editable
)
1968 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1969 TXNControlData data
[] = { { editable
? kTXNReadWrite
: kTXNReadOnly
} } ;
1970 TXNSetTXNObjectControls( m_txn
, false, WXSIZEOF(tag
), tag
, data
) ;
1973 wxTextPos
wxMacMLTEControl::GetLastPosition() const
1975 wxTextPos actualsize
= 0 ;
1978 OSErr err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1983 actualsize
= GetHandleSize( theText
) ;
1984 DisposeHandle( theText
) ;
1994 void wxMacMLTEControl::Replace( long from
, long to
, const wxString
&str
)
1996 wxString value
= str
;
1997 wxMacConvertNewlines10To13( &value
) ;
1999 wxMacEditHelper
help( m_txn
) ;
2001 wxMacWindowClipper
c( m_peer
) ;
2004 TXNSetSelection( m_txn
, from
, to
) ;
2006 SetTXNData( value
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
2009 void wxMacMLTEControl::Remove( long from
, long to
)
2012 wxMacWindowClipper
c( m_peer
) ;
2014 wxMacEditHelper
help( m_txn
) ;
2015 TXNSetSelection( m_txn
, from
, to
) ;
2019 void wxMacMLTEControl::GetSelection( long* from
, long* to
) const
2021 TXNGetSelection( m_txn
, (TXNOffset
*) from
, (TXNOffset
*) to
) ;
2024 void wxMacMLTEControl::SetSelection( long from
, long to
)
2027 wxMacWindowClipper
c( m_peer
) ;
2030 // change the selection
2031 if ((from
== -1) && (to
== -1))
2032 TXNSelectAll( m_txn
);
2034 TXNSetSelection( m_txn
, from
, to
);
2036 TXNShowSelection( m_txn
, kTXNShowStart
);
2039 void wxMacMLTEControl::WriteText( const wxString
& str
)
2042 wxMacConvertNewlines10To13( &st
) ;
2044 long start
, end
, dummy
;
2046 GetSelection( &start
, &dummy
) ;
2048 wxMacWindowClipper
c( m_peer
) ;
2052 wxMacEditHelper
helper( m_txn
) ;
2053 SetTXNData( st
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
2056 GetSelection( &dummy
, &end
) ;
2058 // TODO: SetStyle( start , end , GetDefaultStyle() ) ;
2061 void wxMacMLTEControl::Clear()
2064 wxMacWindowClipper
c( m_peer
) ;
2066 wxMacEditHelper
st( m_txn
) ;
2067 TXNSetSelection( m_txn
, kTXNStartOffset
, kTXNEndOffset
) ;
2071 bool wxMacMLTEControl::CanUndo() const
2073 return TXNCanUndo( m_txn
, NULL
) ;
2076 void wxMacMLTEControl::Undo()
2081 bool wxMacMLTEControl::CanRedo() const
2083 return TXNCanRedo( m_txn
, NULL
) ;
2086 void wxMacMLTEControl::Redo()
2091 int wxMacMLTEControl::GetNumberOfLines() const
2093 ItemCount lines
= 0 ;
2094 TXNGetLineCount( m_txn
, &lines
) ;
2099 long wxMacMLTEControl::XYToPosition(long x
, long y
) const
2104 // TODO: find a better implementation : while we can get the
2105 // line metrics of a certain line, we don't get its starting
2106 // position, so it would probably be rather a binary search
2107 // for the start position
2108 long xpos
= 0, ypos
= 0 ;
2109 int lastHeight
= 0 ;
2112 lastpos
= GetLastPosition() ;
2113 for ( n
= 0 ; n
<= (ItemCount
) lastpos
; ++n
)
2115 if ( y
== ypos
&& x
== xpos
)
2118 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
2120 if ( curpt
.v
> lastHeight
)
2126 lastHeight
= curpt
.v
;
2135 bool wxMacMLTEControl::PositionToXY( long pos
, long *x
, long *y
) const
2145 lastpos
= GetLastPosition() ;
2146 if ( pos
<= lastpos
)
2148 // TODO: find a better implementation - while we can get the
2149 // line metrics of a certain line, we don't get its starting
2150 // position, so it would probably be rather a binary search
2151 // for the start position
2152 long xpos
= 0, ypos
= 0 ;
2153 int lastHeight
= 0 ;
2156 for ( n
= 0 ; n
<= (ItemCount
) pos
; ++n
)
2158 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
2160 if ( curpt
.v
> lastHeight
)
2166 lastHeight
= curpt
.v
;
2181 void wxMacMLTEControl::ShowPosition( long pos
)
2183 Point current
, desired
;
2184 TXNOffset selstart
, selend
;
2186 TXNGetSelection( m_txn
, &selstart
, &selend
);
2187 TXNOffsetToPoint( m_txn
, selstart
, ¤t
);
2188 TXNOffsetToPoint( m_txn
, pos
, &desired
);
2190 // TODO: use HIPoints for 10.3 and above
2192 OSErr theErr
= noErr
;
2193 long dv
= desired
.v
- current
.v
;
2194 long dh
= desired
.h
- current
.h
;
2195 TXNShowSelection( m_txn
, kTXNShowStart
) ; // NB: should this be kTXNShowStart or kTXNShowEnd ??
2196 theErr
= TXNScroll( m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
, &dv
, &dh
);
2198 // there will be an error returned for classic MLTE implementation when the control is
2199 // invisible, but HITextView works correctly, so we don't assert that one
2200 // wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
2203 void wxMacMLTEControl::SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
)
2206 #if SIZEOF_WCHAR_T == 2
2207 size_t len
= st
.length() ;
2208 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)st
.wc_str(), len
* 2, start
, end
);
2210 wxMBConvUTF16 converter
;
2211 ByteCount byteBufferLen
= converter
.WC2MB( NULL
, st
.wc_str(), 0 ) ;
2212 UniChar
*unibuf
= (UniChar
*)malloc( byteBufferLen
) ;
2213 converter
.WC2MB( (char*)unibuf
, st
.wc_str(), byteBufferLen
) ;
2214 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)unibuf
, byteBufferLen
, start
, end
) ;
2218 wxCharBuffer text
= st
.mb_str( wxConvLocal
) ;
2219 TXNSetData( m_txn
, kTXNTextData
, (void*)text
.data(), strlen( text
), start
, end
) ;
2223 wxString
wxMacMLTEControl::GetLineText(long lineNo
) const
2227 if ( lineNo
< GetNumberOfLines() )
2230 Fixed lineWidth
, lineHeight
, currentHeight
;
2233 // get the first possible position in the control
2234 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
2236 // Iterate through the lines until we reach the one we want,
2237 // adding to our current y pixel point position
2240 while (ypos
< lineNo
)
2242 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
2243 currentHeight
+= lineHeight
;
2246 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
2247 TXNOffset theOffset
;
2248 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
2250 wxString content
= GetStringValue() ;
2251 Point currentPoint
= thePoint
;
2252 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
2254 line
+= content
[theOffset
];
2255 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
2262 int wxMacMLTEControl::GetLineLength(long lineNo
) const
2266 if ( lineNo
< GetNumberOfLines() )
2269 Fixed lineWidth
, lineHeight
, currentHeight
;
2272 // get the first possible position in the control
2273 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
2275 // Iterate through the lines until we reach the one we want,
2276 // adding to our current y pixel point position
2279 while (ypos
< lineNo
)
2281 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
2282 currentHeight
+= lineHeight
;
2285 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
2286 TXNOffset theOffset
;
2287 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
2289 wxString content
= GetStringValue() ;
2290 Point currentPoint
= thePoint
;
2291 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
2294 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
2301 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
2303 // ----------------------------------------------------------------------------
2304 // MLTE control implementation (classic part)
2305 // ----------------------------------------------------------------------------
2307 // OS X Notes : We still don't have a full replacement for MLTE, so this implementation
2308 // has to live on. We have different problems coming from outdated implementations on the
2309 // various OS X versions. Most deal with the scrollbars: they are not correctly embedded
2310 // while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
2311 // no way out, therefore we are using our own implementation and our own scrollbars ....
2313 #ifdef __WXMAC_OSX__
2315 TXNScrollInfoUPP gTXNScrollInfoProc
= NULL
;
2316 ControlActionUPP gTXNScrollActionProc
= NULL
;
2318 pascal void wxMacMLTEClassicControl::TXNScrollInfoProc(
2319 SInt32 iValue
, SInt32 iMaximumValue
,
2320 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
)
2322 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) iRefCon
;
2323 SInt32 value
= wxMax( iValue
, 0 ) ;
2324 SInt32 maximum
= wxMax( iMaximumValue
, 0 ) ;
2326 if ( iScrollBarOrientation
== kTXNHorizontal
)
2328 if ( mlte
->m_sbHorizontal
)
2330 SetControl32BitValue( mlte
->m_sbHorizontal
, value
) ;
2331 SetControl32BitMaximum( mlte
->m_sbHorizontal
, maximum
) ;
2332 mlte
->m_lastHorizontalValue
= value
;
2335 else if ( iScrollBarOrientation
== kTXNVertical
)
2337 if ( mlte
->m_sbVertical
)
2339 SetControl32BitValue( mlte
->m_sbVertical
, value
) ;
2340 SetControl32BitMaximum( mlte
->m_sbVertical
, maximum
) ;
2341 mlte
->m_lastVerticalValue
= value
;
2346 pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
)
2348 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) GetControlReference( controlRef
) ;
2352 if ( controlRef
!= mlte
->m_sbVertical
&& controlRef
!= mlte
->m_sbHorizontal
)
2356 bool isHorizontal
= ( controlRef
== mlte
->m_sbHorizontal
) ;
2358 SInt32 minimum
= 0 ;
2359 SInt32 maximum
= GetControl32BitMaximum( controlRef
) ;
2360 SInt32 value
= GetControl32BitValue( controlRef
) ;
2365 case kControlDownButtonPart
:
2369 case kControlUpButtonPart
:
2373 case kControlPageDownPart
:
2374 delta
= GetControlViewSize( controlRef
) ;
2377 case kControlPageUpPart
:
2378 delta
= -GetControlViewSize( controlRef
) ;
2381 case kControlIndicatorPart
:
2382 delta
= value
- (isHorizontal
? mlte
->m_lastHorizontalValue
: mlte
->m_lastVerticalValue
) ;
2391 SInt32 newValue
= value
;
2393 if ( partCode
!= kControlIndicatorPart
)
2395 if ( value
+ delta
< minimum
)
2396 delta
= minimum
- value
;
2397 if ( value
+ delta
> maximum
)
2398 delta
= maximum
- value
;
2400 SetControl32BitValue( controlRef
, value
+ delta
) ;
2401 newValue
= value
+ delta
;
2404 SInt32 verticalDelta
= isHorizontal
? 0 : delta
;
2405 SInt32 horizontalDelta
= isHorizontal
? delta
: 0 ;
2408 mlte
->m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
,
2409 &verticalDelta
, &horizontalDelta
);
2410 verify_noerr( err
);
2413 mlte
->m_lastHorizontalValue
= newValue
;
2415 mlte
->m_lastVerticalValue
= newValue
;
2420 // make correct activations
2421 void wxMacMLTEClassicControl::MacActivatePaneText(bool setActive
)
2423 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference(m_controlRef
);
2425 wxMacWindowClipper
clipper( textctrl
) ;
2426 TXNActivate( m_txn
, m_txnFrameID
, setActive
);
2428 ControlRef controlFocus
= 0 ;
2429 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2430 if ( controlFocus
== m_controlRef
)
2431 TXNFocus( m_txn
, setActive
);
2434 void wxMacMLTEClassicControl::MacFocusPaneText(bool setFocus
)
2436 TXNFocus( m_txn
, setFocus
);
2439 // guards against inappropriate redraw (hidden objects drawing onto window)
2441 void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis
)
2443 ControlRef controlFocus
= 0 ;
2444 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2446 if ( !vis
&& (controlFocus
== m_controlRef
) )
2447 SetKeyboardFocus( m_txnWindow
, m_controlRef
, kControlFocusNoPart
) ;
2449 TXNControlTag iControlTags
[1] = { kTXNVisibilityTag
};
2450 TXNControlData iControlData
[1] = { { (UInt32
)false } };
2452 verify_noerr( TXNGetTXNObjectControls( m_txn
, 1, iControlTags
, iControlData
) ) ;
2454 if ( iControlData
[0].uValue
!= vis
)
2456 iControlData
[0].uValue
= vis
;
2457 verify_noerr( TXNSetTXNObjectControls( m_txn
, false , 1, iControlTags
, iControlData
) ) ;
2460 // currently, we always clip as partial visibility (overlapped) visibility is also a problem,
2461 // if we run into further problems we might set the FrameBounds to an empty rect here
2464 // make sure that the TXNObject is at the right position
2466 void wxMacMLTEClassicControl::MacUpdatePosition()
2468 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2469 if ( textctrl
== NULL
)
2473 UMAGetControlBoundsInWindowCoords( m_controlRef
, &bounds
);
2475 wxRect visRect
= textctrl
->MacGetClippedClientRect() ;
2476 Rect visBounds
= { visRect
.y
, visRect
.x
, visRect
.y
+ visRect
.height
, visRect
.x
+ visRect
.width
} ;
2479 textctrl
->MacWindowToRootWindow( &x
, &y
) ;
2480 OffsetRect( &visBounds
, x
, y
) ;
2482 if ( !EqualRect( &bounds
, &m_txnControlBounds
) || !EqualRect( &visBounds
, &m_txnVisBounds
) )
2484 m_txnControlBounds
= bounds
;
2485 m_txnVisBounds
= visBounds
;
2486 wxMacWindowClipper
cl( textctrl
) ;
2488 #ifdef __WXMAC_OSX__
2489 if ( m_sbHorizontal
|| m_sbVertical
)
2491 int w
= bounds
.right
- bounds
.left
;
2492 int h
= bounds
.bottom
- bounds
.top
;
2494 if ( m_sbHorizontal
)
2498 sbBounds
.left
= -1 ;
2499 sbBounds
.top
= h
- 14 ;
2500 sbBounds
.right
= w
+ 1 ;
2501 sbBounds
.bottom
= h
+ 1 ;
2503 SetControlBounds( m_sbHorizontal
, &sbBounds
) ;
2504 SetControlViewSize( m_sbHorizontal
, w
) ;
2511 sbBounds
.left
= w
- 14 ;
2513 sbBounds
.right
= w
+ 1 ;
2514 sbBounds
.bottom
= m_sbHorizontal
? h
- 14 : h
+ 1 ;
2516 SetControlBounds( m_sbVertical
, &sbBounds
) ;
2517 SetControlViewSize( m_sbVertical
, h
) ;
2522 TXNLongRect olddestRect
;
2523 TXNGetRectBounds( m_txn
, &oldviewRect
, &olddestRect
, NULL
) ;
2525 Rect viewRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2526 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
2527 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
2528 TXNLongRect destRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2529 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
2530 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
2532 if ( olddestRect
.right
>= 10000 )
2533 destRect
.right
= destRect
.left
+ 32000 ;
2535 if ( olddestRect
.bottom
>= 0x20000000 )
2536 destRect
.bottom
= destRect
.top
+ 0x40000000 ;
2538 SectRect( &viewRect
, &visBounds
, &viewRect
) ;
2539 TXNSetRectBounds( m_txn
, &viewRect
, &destRect
, true ) ;
2544 m_txnControlBounds
.top
,
2545 m_txnControlBounds
.left
,
2546 m_txnControlBounds
.bottom
- (m_sbHorizontal
? 14 : 0),
2547 m_txnControlBounds
.right
- (m_sbVertical
? 14 : 0),
2553 m_txn
, m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2554 wxMax( m_txnControlBounds
.bottom
, m_txnControlBounds
.top
),
2555 wxMax( m_txnControlBounds
.right
, m_txnControlBounds
.left
), m_txnFrameID
);
2558 // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
2559 // movement, therefore we have to force it
2561 // this problem has been reported in OSX as well, so we use this here once again
2563 TXNLongRect textRect
;
2564 TXNGetRectBounds( m_txn
, NULL
, NULL
, &textRect
) ;
2565 if ( textRect
.left
< m_txnControlBounds
.left
)
2566 TXNShowSelection( m_txn
, kTXNShowStart
) ;
2570 void wxMacMLTEClassicControl::SetRect( Rect
*r
)
2572 wxMacControl::SetRect( r
) ;
2573 MacUpdatePosition() ;
2576 void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16 thePart
)
2578 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2579 if ( textctrl
== NULL
)
2582 if ( textctrl
->MacIsReallyShown() )
2584 wxMacWindowClipper
clipper( textctrl
) ;
2585 TXNDraw( m_txn
, NULL
) ;
2589 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
2591 Point where
= { y
, x
} ;
2592 ControlPartCode result
= kControlNoPart
;
2594 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
2595 if ( (textctrl
!= NULL
) && textctrl
->MacIsReallyShown() )
2597 if (PtInRect( where
, &m_txnControlBounds
))
2599 result
= kControlEditTextPart
;
2603 // sometimes we get the coords also in control local coordinates, therefore test again
2605 textctrl
->MacClientToRootWindow( &x
, &y
) ;
2609 if (PtInRect( where
, &m_txnControlBounds
))
2610 result
= kControlEditTextPart
;
2617 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x
, wxInt16 y
, void* actionProc
)
2619 ControlPartCode result
= kControlNoPart
;
2621 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
2622 if ( (textctrl
!= NULL
) && textctrl
->MacIsReallyShown() )
2624 Point startPt
= { y
, x
} ;
2626 // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them
2628 textctrl
->MacClientToRootWindow( &x
, &y
) ;
2632 switch (MacControlUserPaneHitTestProc( startPt
.h
, startPt
.v
))
2634 case kControlEditTextPart
:
2636 wxMacWindowClipper
clipper( textctrl
) ;
2639 ConvertEventRefToEventRecord( (EventRef
) wxTheApp
->MacGetCurrentEvent() , &rec
) ;
2640 TXNClick( m_txn
, &rec
);
2652 void wxMacMLTEClassicControl::MacControlUserPaneIdleProc()
2654 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2655 if ( textctrl
== NULL
)
2658 if (textctrl
->MacIsReallyShown())
2660 if (IsControlActive(m_controlRef
))
2664 wxMacWindowClipper
clipper( textctrl
) ;
2669 if (PtInRect(mousep
, &m_txnControlBounds
))
2671 RgnHandle theRgn
= NewRgn();
2672 RectRgn(theRgn
, &m_txnControlBounds
);
2673 TXNAdjustCursor(m_txn
, theRgn
);
2680 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneKeyDownProc (wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
2682 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2683 if ( textctrl
== NULL
)
2684 return kControlNoPart
;
2686 wxMacWindowClipper
clipper( textctrl
) ;
2689 memset( &ev
, 0 , sizeof( ev
) ) ;
2691 ev
.modifiers
= modifiers
;
2692 ev
.message
= ((keyCode
<< 8) & keyCodeMask
) | (charCode
& charCodeMask
);
2693 TXNKeyDown( m_txn
, &ev
);
2695 return kControlEntireControl
;
2698 void wxMacMLTEClassicControl::MacControlUserPaneActivateProc(bool activating
)
2700 MacActivatePaneText( activating
);
2703 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action
)
2705 ControlPartCode focusResult
= kControlFocusNoPart
;
2707 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2708 if ( textctrl
== NULL
)
2711 wxMacWindowClipper
clipper( textctrl
) ;
2713 ControlRef controlFocus
= NULL
;
2714 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2715 bool wasFocused
= ( controlFocus
== m_controlRef
) ;
2719 case kControlFocusPrevPart
:
2720 case kControlFocusNextPart
:
2721 MacFocusPaneText( !wasFocused
);
2722 focusResult
= (!wasFocused
? (ControlPartCode
) kControlEditTextPart
: (ControlPartCode
) kControlFocusNoPart
);
2725 case kControlFocusNoPart
:
2727 MacFocusPaneText( false );
2728 focusResult
= kControlFocusNoPart
;
2735 void wxMacMLTEClassicControl::MacControlUserPaneBackgroundProc( void *info
)
2739 wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
2740 const wxString
& str
,
2742 const wxSize
& size
, long style
)
2743 : wxMacMLTEControl( wxPeer
)
2745 m_font
= wxPeer
->GetFont() ;
2746 m_windowStyle
= style
;
2747 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
2750 kControlSupportsEmbedding
| kControlSupportsFocus
| kControlWantsIdle
2751 | kControlWantsActivate
| kControlHandlesTracking
2752 // | kControlHasSpecialBackground
2753 | kControlGetsFocusOnClick
| kControlSupportsLiveFeedback
;
2755 OSStatus err
= ::CreateUserPaneControl(
2756 MAC_WXHWND(wxPeer
->GetParent()->MacGetTopLevelWindowRef()),
2757 &bounds
, featureSet
, &m_controlRef
);
2758 verify_noerr( err
);
2762 AdjustCreationAttributes( *wxWHITE
, true ) ;
2764 MacSetObjectVisibility( wxPeer
->MacIsReallyShown() ) ;
2768 wxMacConvertNewlines10To13( &st
) ;
2769 wxMacWindowClipper
clipper( m_peer
) ;
2770 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
2771 TXNSetSelection( m_txn
, 0, 0 ) ;
2775 wxMacMLTEClassicControl::~wxMacMLTEClassicControl()
2777 TXNDeleteObject( m_txn
);
2781 void wxMacMLTEClassicControl::VisibilityChanged(bool shown
)
2783 MacSetObjectVisibility( shown
) ;
2784 wxMacControl::VisibilityChanged( shown
) ;
2787 void wxMacMLTEClassicControl::SuperChangedPosition()
2789 MacUpdatePosition() ;
2790 wxMacControl::SuperChangedPosition() ;
2793 #ifdef __WXMAC_OSX__
2795 ControlUserPaneDrawUPP gTPDrawProc
= NULL
;
2796 ControlUserPaneHitTestUPP gTPHitProc
= NULL
;
2797 ControlUserPaneTrackingUPP gTPTrackProc
= NULL
;
2798 ControlUserPaneIdleUPP gTPIdleProc
= NULL
;
2799 ControlUserPaneKeyDownUPP gTPKeyProc
= NULL
;
2800 ControlUserPaneActivateUPP gTPActivateProc
= NULL
;
2801 ControlUserPaneFocusUPP gTPFocusProc
= NULL
;
2803 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
2805 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2806 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2808 win
->MacControlUserPaneDrawProc( part
) ;
2811 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
2813 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2814 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2816 return win
->MacControlUserPaneHitTestProc( where
.h
, where
.v
) ;
2818 return kControlNoPart
;
2821 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
2823 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2824 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2826 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
2828 return kControlNoPart
;
2831 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
2833 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2834 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2836 win
->MacControlUserPaneIdleProc() ;
2839 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
2841 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2842 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2844 return win
->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
2846 return kControlNoPart
;
2849 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
2851 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2852 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2854 win
->MacControlUserPaneActivateProc( activating
) ;
2857 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
2859 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2860 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2862 return win
->MacControlUserPaneFocusProc( action
) ;
2864 return kControlNoPart
;
2868 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
2870 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2871 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2873 win
->MacControlUserPaneBackgroundProc(info
) ;
2877 #endif // __WXMAC_OSX__
2879 // TXNRegisterScrollInfoProc
2881 OSStatus
wxMacMLTEClassicControl::DoCreate()
2884 OSStatus err
= noErr
;
2886 // set up our globals
2887 #ifdef __WXMAC_OSX__
2888 if (gTPDrawProc
== NULL
) gTPDrawProc
= NewControlUserPaneDrawUPP(wxMacControlUserPaneDrawProc
);
2889 if (gTPHitProc
== NULL
) gTPHitProc
= NewControlUserPaneHitTestUPP(wxMacControlUserPaneHitTestProc
);
2890 if (gTPTrackProc
== NULL
) gTPTrackProc
= NewControlUserPaneTrackingUPP(wxMacControlUserPaneTrackingProc
);
2891 if (gTPIdleProc
== NULL
) gTPIdleProc
= NewControlUserPaneIdleUPP(wxMacControlUserPaneIdleProc
);
2892 if (gTPKeyProc
== NULL
) gTPKeyProc
= NewControlUserPaneKeyDownUPP(wxMacControlUserPaneKeyDownProc
);
2893 if (gTPActivateProc
== NULL
) gTPActivateProc
= NewControlUserPaneActivateUPP(wxMacControlUserPaneActivateProc
);
2894 if (gTPFocusProc
== NULL
) gTPFocusProc
= NewControlUserPaneFocusUPP(wxMacControlUserPaneFocusProc
);
2896 if (gTXNScrollInfoProc
== NULL
) gTXNScrollInfoProc
= NewTXNScrollInfoUPP(TXNScrollInfoProc
) ;
2897 if (gTXNScrollActionProc
== NULL
) gTXNScrollActionProc
= NewControlActionUPP(TXNScrollActionProc
) ;
2900 // set the initial settings for our private data
2902 m_txnWindow
= GetControlOwner(m_controlRef
);
2903 m_txnPort
= (GrafPtr
) GetWindowPort(m_txnWindow
);
2905 #ifdef __WXMAC_OSX__
2906 // set up the user pane procedures
2907 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneDrawProcTag
, sizeof(gTPDrawProc
), &gTPDrawProc
);
2908 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneHitTestProcTag
, sizeof(gTPHitProc
), &gTPHitProc
);
2909 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneTrackingProcTag
, sizeof(gTPTrackProc
), &gTPTrackProc
);
2910 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneIdleProcTag
, sizeof(gTPIdleProc
), &gTPIdleProc
);
2911 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneKeyDownProcTag
, sizeof(gTPKeyProc
), &gTPKeyProc
);
2912 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneActivateProcTag
, sizeof(gTPActivateProc
), &gTPActivateProc
);
2913 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneFocusProcTag
, sizeof(gTPFocusProc
), &gTPFocusProc
);
2916 // calculate the rectangles used by the control
2917 UMAGetControlBoundsInWindowCoords( m_controlRef
, &bounds
);
2919 m_txnControlBounds
= bounds
;
2920 m_txnVisBounds
= bounds
;
2925 GetGWorld( &origPort
, &origDev
) ;
2926 SetPort( m_txnPort
);
2928 // create the new edit field
2929 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( m_windowStyle
);
2931 #ifdef __WXMAC_OSX__
2932 // the scrollbars are not correctly embedded but are inserted at the root:
2933 // this gives us problems as we have erratic redraws even over the structure area
2935 m_sbHorizontal
= 0 ;
2937 m_lastHorizontalValue
= 0 ;
2938 m_lastVerticalValue
= 0 ;
2940 Rect sb
= { 0 , 0 , 0 , 0 } ;
2941 if ( frameOptions
& kTXNWantVScrollBarMask
)
2943 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbVertical
);
2944 SetControlReference( m_sbVertical
, (SInt32
)this );
2945 SetControlAction( m_sbVertical
, gTXNScrollActionProc
);
2946 ShowControl( m_sbVertical
);
2947 EmbedControl( m_sbVertical
, m_controlRef
);
2948 frameOptions
&= ~kTXNWantVScrollBarMask
;
2951 if ( frameOptions
& kTXNWantHScrollBarMask
)
2953 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbHorizontal
);
2954 SetControlReference( m_sbHorizontal
, (SInt32
)this );
2955 SetControlAction( m_sbHorizontal
, gTXNScrollActionProc
);
2956 ShowControl( m_sbHorizontal
);
2957 EmbedControl( m_sbHorizontal
, m_controlRef
);
2958 frameOptions
&= ~(kTXNWantHScrollBarMask
| kTXNDrawGrowIconMask
);
2964 NULL
, m_txnWindow
, &bounds
, frameOptions
,
2965 kTXNTextEditStyleFrameType
, kTXNTextensionFile
, kTXNSystemDefaultEncoding
,
2966 &m_txn
, &m_txnFrameID
, NULL
);
2967 verify_noerr( err
);
2970 TXNControlTag iControlTags
[] = { kTXNUseCarbonEvents
};
2971 TXNControlData iControlData
[] = { { (UInt32
)&cInfo
} };
2972 int toptag
= WXSIZEOF( iControlTags
) ;
2973 TXNCarbonEventInfo cInfo
;
2974 cInfo
.useCarbonEvents
= false ;
2977 cInfo
.fDictionary
= NULL
;
2979 verify_noerr( TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) );
2982 #ifdef __WXMAC_OSX__
2983 TXNRegisterScrollInfoProc( m_txn
, gTXNScrollInfoProc
, (SInt32
)this );
2986 SetGWorld( origPort
, origDev
) ;
2992 // ----------------------------------------------------------------------------
2993 // MLTE control implementation (OSX part)
2994 // ----------------------------------------------------------------------------
2996 #if TARGET_API_MAC_OSX
2998 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
3000 // tiger multi-line textcontrols with no CR in the entire content
3001 // don't scroll automatically, so we need a hack.
3002 // This attempt only works 'before' the key (ie before CallNextEventHandler)
3003 // is processed, thus the scrolling always occurs one character too late, but
3004 // better than nothing ...
3006 static const EventTypeSpec eventList
[] =
3008 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
3011 static pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
3013 OSStatus result
= eventNotHandledErr
;
3014 wxMacMLTEHIViewControl
* focus
= (wxMacMLTEHIViewControl
*) data
;
3016 switch ( GetEventKind( event
) )
3018 case kEventTextInputUnicodeForKeyEvent
:
3020 if ( UMAGetSystemVersion() >= 0x1040 )
3022 TXNOffset from
, to
;
3023 TXNGetSelection( focus
->GetTXNObject() , &from
, &to
) ;
3025 TXNShowSelection( focus
->GetTXNObject() , kTXNShowStart
);
3027 result
= CallNextEventHandler(handler
,event
);
3037 static pascal OSStatus
wxMacTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
3039 OSStatus result
= eventNotHandledErr
;
3041 switch ( GetEventClass( event
) )
3043 case kEventClassTextInput
:
3044 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
3053 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTextControlEventHandler
)
3055 wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
3056 const wxString
& str
,
3058 const wxSize
& size
, long style
) : wxMacMLTEControl( wxPeer
)
3060 m_font
= wxPeer
->GetFont() ;
3061 m_windowStyle
= style
;
3062 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
3064 wxMacConvertNewlines10To13( &st
) ;
3067 { bounds
.left
, bounds
.top
},
3068 { bounds
.right
- bounds
.left
, bounds
.bottom
- bounds
.top
} } ;
3070 m_scrollView
= NULL
;
3071 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( style
) ;
3072 if ( frameOptions
& (kTXNWantVScrollBarMask
| kTXNWantHScrollBarMask
) )
3075 (frameOptions
& kTXNWantHScrollBarMask
? kHIScrollViewOptionsHorizScroll
: 0)
3076 | (frameOptions
& kTXNWantVScrollBarMask
? kHIScrollViewOptionsVertScroll
: 0) ,
3079 HIViewSetFrame( m_scrollView
, &hr
);
3080 HIViewSetVisible( m_scrollView
, true );
3084 HITextViewCreate( NULL
, 0, frameOptions
, &m_textView
) ;
3085 m_txn
= HITextViewGetTXNObject( m_textView
) ;
3086 HIViewSetVisible( m_textView
, true ) ;
3089 HIViewAddSubview( m_scrollView
, m_textView
) ;
3090 m_controlRef
= m_scrollView
;
3091 wxPeer
->MacInstallEventHandler( (WXWidget
) m_textView
) ;
3095 HIViewSetFrame( m_textView
, &hr
);
3096 m_controlRef
= m_textView
;
3099 AdjustCreationAttributes( *wxWHITE
, true ) ;
3101 wxMacWindowClipper
c( m_peer
) ;
3103 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
3105 TXNSetSelection( m_txn
, 0, 0 );
3106 TXNShowSelection( m_txn
, kTXNShowStart
);
3108 InstallControlEventHandler( m_textView
, GetwxMacTextControlEventHandlerUPP(),
3109 GetEventTypeCount(eventList
), eventList
, this,
3110 &m_textEventHandlerRef
);
3113 wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl()
3115 ::RemoveEventHandler( m_textEventHandlerRef
) ;
3118 OSStatus
wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart
)
3120 return SetKeyboardFocus( GetControlOwner( m_textView
), m_textView
, focusPart
) ;
3123 bool wxMacMLTEHIViewControl::HasFocus() const
3125 ControlRef control
;
3126 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
3127 return control
== m_textView
;
3130 void wxMacMLTEHIViewControl::SetBackground( const wxBrush
&brush
)
3132 wxMacMLTEControl::SetBackground( brush
) ;
3135 CGColorSpaceRef rgbSpace
= CGColorSpaceCreateDeviceRGB();
3136 RGBColor col
= MAC_WXCOLORREF(brush
.GetColour().GetPixel()) ;
3138 float component
[4] ;
3139 component
[0] = col
.red
/ 65536.0 ;
3140 component
[1] = col
.green
/ 65536.0 ;
3141 component
[2] = col
.blue
/ 65536.0 ;
3142 component
[3] = 1.0 ; // alpha
3144 CGColorRef color
= CGColorCreate( rgbSpace
, component
);
3145 HITextViewSetBackgroundColor( m_textView
, color
);
3146 CGColorSpaceRelease( rgbSpace
);
3150 #endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
3155 #endif // wxUSE_TEXTCTRL