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__)
55 #include <MacTextEditor.h>
56 #include <ATSUnicode.h>
57 #include <TextCommon.h>
58 #include <TextEncodingConverter.h>
61 #include "wx/mac/uma.h"
62 #include "wx/mac/carbon/private/mactext.h"
67 kTXNVisibilityTag
= 'visb' // set the visibility state of the object
76 virtual ~wxMacFunctor() {}
78 virtual void* operator()() = 0 ;
80 static void* CallBackProc( void *param
)
82 wxMacFunctor
* f
= (wxMacFunctor
*) param
;
83 void *result
= (*f
)() ;
88 template<typename classtype
, typename param1type
>
90 class wxMacObjectFunctor1
: public wxMacFunctor
92 typedef void (classtype::*function
)( param1type p1
) ;
93 typedef void (classtype::*ref_function
)( const param1type
& p1
) ;
95 wxMacObjectFunctor1( classtype
*obj
, function f
, param1type p1
) :
103 wxMacObjectFunctor1( classtype
*obj
, ref_function f
, param1type p1
) :
111 virtual ~wxMacObjectFunctor1() {}
113 virtual void* operator()()
115 (m_object
->*m_function
)( m_param1
) ;
120 classtype
* m_object
;
121 param1type m_param1
;
124 function m_function
;
125 ref_function m_refFunction
;
129 template<typename classtype
, typename param1type
>
130 void* wxMacMPRemoteCall( classtype
*object
, void (classtype::*function
)( param1type p1
) , param1type p1
)
132 wxMacObjectFunctor1
<classtype
, param1type
> params(object
, function
, p1
) ;
134 MPRemoteCall( wxMacFunctor::CallBackProc
, ¶ms
, kMPOwningProcessRemoteContext
) ;
138 template<typename classtype
, typename param1type
>
139 void* wxMacMPRemoteCall( classtype
*object
, void (classtype::*function
)( const param1type
& p1
) , param1type p1
)
141 wxMacObjectFunctor1
<classtype
,param1type
> params(object
, function
, p1
) ;
143 MPRemoteCall( wxMacFunctor::CallBackProc
, ¶ms
, kMPOwningProcessRemoteContext
) ;
147 template<typename classtype
, typename param1type
>
148 void* wxMacMPRemoteGUICall( classtype
*object
, void (classtype::*function
)( param1type p1
) , param1type p1
)
151 void *result
= wxMacMPRemoteCall( object
, function
, p1
) ;
156 template<typename classtype
, typename param1type
>
157 void* wxMacMPRemoteGUICall( classtype
*object
, void (classtype::*function
)( const param1type
& p1
) , param1type p1
)
160 void *result
= wxMacMPRemoteCall( object
, function
, p1
) ;
166 // common parts for implementations based on MLTE
168 class wxMacMLTEControl
: public wxMacTextControl
171 wxMacMLTEControl( wxTextCtrl
*peer
) ;
173 virtual wxString
GetStringValue() const ;
174 virtual void SetStringValue( const wxString
&str
) ;
176 static TXNFrameOptions
FrameOptionsFromWXStyle( long wxStyle
) ;
178 void AdjustCreationAttributes( const wxColour
& background
, bool visible
) ;
180 virtual void SetFont( const wxFont
& font
, const wxColour
& foreground
, long windowStyle
) ;
181 virtual void SetBackground( const wxBrush
&brush
) ;
182 virtual void SetStyle( long start
, long end
, const wxTextAttr
& style
) ;
183 virtual void Copy() ;
185 virtual void Paste() ;
186 virtual bool CanPaste() const ;
187 virtual void SetEditable( bool editable
) ;
188 virtual wxTextPos
GetLastPosition() const ;
189 virtual void Replace( long from
, long to
, const wxString
&str
) ;
190 virtual void Remove( long from
, long to
) ;
191 virtual void GetSelection( long* from
, long* to
) const ;
192 virtual void SetSelection( long from
, long to
) ;
194 virtual void WriteText( const wxString
& str
) ;
196 virtual bool HasOwnContextMenu() const
198 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
199 if ( UMAGetSystemVersion() >= 0x1040 )
201 TXNCommandEventSupportOptions options
;
202 TXNGetCommandEventSupport( m_txn
, & options
) ;
203 return options
& kTXNSupportEditCommandProcessing
;
210 virtual void CheckSpelling(bool check
)
212 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
213 TXNSetSpellCheckAsYouType( m_txn
, (Boolean
) check
);
216 virtual void Clear() ;
218 virtual bool CanUndo() const ;
219 virtual void Undo() ;
220 virtual bool CanRedo() const;
221 virtual void Redo() ;
222 virtual int GetNumberOfLines() const ;
223 virtual long XYToPosition(long x
, long y
) const ;
224 virtual bool PositionToXY(long pos
, long *x
, long *y
) const ;
225 virtual void ShowPosition( long pos
) ;
226 virtual int GetLineLength(long lineNo
) const ;
227 virtual wxString
GetLineText(long lineNo
) const ;
229 void SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
) ;
230 TXNObject
GetTXNObject() { return m_txn
; }
233 void TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
) ;
238 #if TARGET_API_MAC_OSX
240 // implementation available under OSX
242 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
244 class wxMacMLTEHIViewControl
: public wxMacMLTEControl
247 wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
250 const wxSize
& size
, long style
) ;
251 virtual ~wxMacMLTEHIViewControl() ;
253 virtual OSStatus
SetFocus( ControlFocusPart focusPart
) ;
254 virtual bool HasFocus() const ;
255 virtual void SetBackground( const wxBrush
&brush
) ;
258 HIViewRef m_scrollView
;
259 HIViewRef m_textView
;
266 // 'classic' MLTE implementation
268 class wxMacMLTEClassicControl
: public wxMacMLTEControl
271 wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
274 const wxSize
& size
, long style
) ;
275 virtual ~wxMacMLTEClassicControl() ;
277 virtual void VisibilityChanged(bool shown
) ;
278 virtual void SuperChangedPosition() ;
280 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
281 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
282 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
283 virtual void MacControlUserPaneIdleProc() ;
284 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
285 virtual void MacControlUserPaneActivateProc(bool activating
) ;
286 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
287 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
289 virtual bool SetupCursor( const wxPoint
& WXUNUSED(pt
) )
291 MacControlUserPaneIdleProc();
295 virtual void SetRect( Rect
*r
) ;
300 void MacUpdatePosition() ;
301 void MacActivatePaneText(bool setActive
) ;
302 void MacFocusPaneText(bool setFocus
) ;
303 void MacSetObjectVisibility(bool vis
) ;
306 TXNFrameID m_txnFrameID
;
308 WindowRef m_txnWindow
;
309 // bounds of the control as we last did set the txn frames
310 Rect m_txnControlBounds
;
311 Rect m_txnVisBounds
;
314 static pascal void TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
) ;
315 static pascal void TXNScrollInfoProc(
316 SInt32 iValue
, SInt32 iMaximumValue
,
317 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
) ;
319 ControlRef m_sbHorizontal
;
320 SInt32 m_lastHorizontalValue
;
321 ControlRef m_sbVertical
;
322 SInt32 m_lastVerticalValue
;
327 IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl
, wxTextCtrlBase
)
329 BEGIN_EVENT_TABLE(wxTextCtrl
, wxTextCtrlBase
)
330 EVT_ERASE_BACKGROUND( wxTextCtrl::OnEraseBackground
)
331 EVT_DROP_FILES(wxTextCtrl::OnDropFiles
)
332 EVT_CHAR(wxTextCtrl::OnChar
)
333 EVT_MENU(wxID_CUT
, wxTextCtrl::OnCut
)
334 EVT_MENU(wxID_COPY
, wxTextCtrl::OnCopy
)
335 EVT_MENU(wxID_PASTE
, wxTextCtrl::OnPaste
)
336 EVT_MENU(wxID_UNDO
, wxTextCtrl::OnUndo
)
337 EVT_MENU(wxID_REDO
, wxTextCtrl::OnRedo
)
338 EVT_MENU(wxID_CLEAR
, wxTextCtrl::OnDelete
)
339 EVT_MENU(wxID_SELECTALL
, wxTextCtrl::OnSelectAll
)
341 EVT_CONTEXT_MENU(wxTextCtrl::OnContextMenu
)
343 EVT_UPDATE_UI(wxID_CUT
, wxTextCtrl::OnUpdateCut
)
344 EVT_UPDATE_UI(wxID_COPY
, wxTextCtrl::OnUpdateCopy
)
345 EVT_UPDATE_UI(wxID_PASTE
, wxTextCtrl::OnUpdatePaste
)
346 EVT_UPDATE_UI(wxID_UNDO
, wxTextCtrl::OnUpdateUndo
)
347 EVT_UPDATE_UI(wxID_REDO
, wxTextCtrl::OnUpdateRedo
)
348 EVT_UPDATE_UI(wxID_CLEAR
, wxTextCtrl::OnUpdateDelete
)
349 EVT_UPDATE_UI(wxID_SELECTALL
, wxTextCtrl::OnUpdateSelectAll
)
353 void wxTextCtrl::Init()
359 m_privateContextMenu
= NULL
;
360 m_triggerOnSetValue
= true ;
363 wxTextCtrl::~wxTextCtrl()
365 delete m_privateContextMenu
;
368 bool wxTextCtrl::Create( wxWindow
*parent
,
374 const wxValidator
& validator
,
375 const wxString
& name
)
377 m_macIsUserPane
= false ;
380 if ( ! (style
& wxNO_BORDER
) )
381 style
= (style
& ~wxBORDER_MASK
) | wxSUNKEN_BORDER
;
383 if ( !wxTextCtrlBase::Create( parent
, id
, pos
, size
, style
& ~(wxHSCROLL
| wxVSCROLL
), validator
, name
) )
386 if ( m_windowStyle
& wxTE_MULTILINE
)
388 // always turn on this style for multi-line controls
389 m_windowStyle
|= wxTE_PROCESS_ENTER
;
390 style
|= wxTE_PROCESS_ENTER
;
393 CreatePeer( str
, pos
, size
, style
);
395 MacPostControlCreate(pos
, size
) ;
397 // only now the embedding is correct and we can do a positioning update
399 MacSuperChangedPosition() ;
401 if ( m_windowStyle
& wxTE_READONLY
)
402 SetEditable( false ) ;
404 SetCursor( wxCursor( wxCURSOR_IBEAM
) ) ;
409 void wxTextCtrl::CreatePeer(
412 const wxSize
& size
, long style
)
414 bool forceMLTE
= false ;
416 #if wxUSE_SYSTEM_OPTIONS
417 if (wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_MLTE
) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_MLTE
) == 1))
423 if ( UMAGetSystemVersion() >= 0x1050 )
426 if ( UMAGetSystemVersion() >= 0x1030 && !forceMLTE
)
428 if ( m_windowStyle
& wxTE_MULTILINE
)
429 m_peer
= new wxMacMLTEHIViewControl( this , str
, pos
, size
, style
) ;
434 if ( !(m_windowStyle
& wxTE_MULTILINE
) && !forceMLTE
)
436 m_peer
= new wxMacUnicodeTextControl( this , str
, pos
, size
, style
) ;
440 // the horizontal single line scrolling bug that made us keep the classic implementation
442 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
444 m_peer
= new wxMacMLTEClassicControl( this , str
, pos
, size
, style
) ;
448 void wxTextCtrl::MacSuperChangedPosition()
450 wxWindow::MacSuperChangedPosition() ;
451 GetPeer()->SuperChangedPosition() ;
454 void wxTextCtrl::MacVisibilityChanged()
456 GetPeer()->VisibilityChanged( MacIsReallyShown() ) ;
459 void wxTextCtrl::MacEnabledStateChanged()
463 void wxTextCtrl::MacCheckSpelling(bool check
)
465 GetPeer()->CheckSpelling(check
);
468 wxString
wxTextCtrl::GetValue() const
470 return GetPeer()->GetStringValue() ;
473 void wxTextCtrl::GetSelection(long* from
, long* to
) const
475 GetPeer()->GetSelection( from
, to
) ;
478 void wxTextCtrl::DoSetValue(const wxString
& str
, int flags
)
481 if ( GetValue() == str
)
484 GetPeer()->SetStringValue( str
) ;
486 if ( (flags
& SetValue_SendEvent
) && m_triggerOnSetValue
)
488 SendTextUpdatedEvent();
492 void wxTextCtrl::SetMaxLength(unsigned long len
)
497 bool wxTextCtrl::SetFont( const wxFont
& font
)
499 if ( !wxTextCtrlBase::SetFont( font
) )
502 GetPeer()->SetFont( font
, GetForegroundColour() , GetWindowStyle() ) ;
507 bool wxTextCtrl::SetStyle(long start
, long end
, const wxTextAttr
& style
)
509 GetPeer()->SetStyle( start
, end
, style
) ;
514 bool wxTextCtrl::SetDefaultStyle(const wxTextAttr
& style
)
516 wxTextCtrlBase::SetDefaultStyle( style
) ;
517 SetStyle( kTXNUseCurrentSelection
, kTXNUseCurrentSelection
, GetDefaultStyle() ) ;
522 // Clipboard operations
524 void wxTextCtrl::Copy()
530 void wxTextCtrl::Cut()
536 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
537 event
.SetEventObject( this );
538 GetEventHandler()->ProcessEvent( event
);
542 void wxTextCtrl::Paste()
548 // TODO: eventually we should add setting the default style again
550 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
551 event
.SetEventObject( this );
552 GetEventHandler()->ProcessEvent( event
);
556 bool wxTextCtrl::CanCopy() const
558 // Can copy if there's a selection
560 GetSelection( &from
, &to
);
565 bool wxTextCtrl::CanCut() const
570 // Can cut if there's a selection
572 GetSelection( &from
, &to
);
577 bool wxTextCtrl::CanPaste() const
582 return GetPeer()->CanPaste() ;
585 void wxTextCtrl::SetEditable(bool editable
)
587 if ( editable
!= m_editable
)
589 m_editable
= editable
;
590 GetPeer()->SetEditable( editable
) ;
594 void wxTextCtrl::SetInsertionPoint(long pos
)
596 SetSelection( pos
, pos
) ;
599 void wxTextCtrl::SetInsertionPointEnd()
601 wxTextPos pos
= GetLastPosition();
602 SetInsertionPoint( pos
);
605 long wxTextCtrl::GetInsertionPoint() const
608 GetSelection( &begin
, &end
) ;
613 wxTextPos
wxTextCtrl::GetLastPosition() const
615 return GetPeer()->GetLastPosition() ;
618 void wxTextCtrl::Replace(long from
, long to
, const wxString
& str
)
620 GetPeer()->Replace( from
, to
, str
) ;
623 void wxTextCtrl::Remove(long from
, long to
)
625 GetPeer()->Remove( from
, to
) ;
628 void wxTextCtrl::SetSelection(long from
, long to
)
630 GetPeer()->SetSelection( from
, to
) ;
633 void wxTextCtrl::WriteText(const wxString
& str
)
635 // TODO: this MPRemoting will be moved into a remoting peer proxy for any command
636 if ( !wxIsMainThread() )
638 // unfortunately CW 8 is not able to correctly deduce the template types,
639 // so we have to instantiate explicitly
640 wxMacMPRemoteGUICall
<wxTextCtrl
,wxString
>( this , &wxTextCtrl::WriteText
, str
) ;
645 GetPeer()->WriteText( str
) ;
648 void wxTextCtrl::AppendText(const wxString
& text
)
650 SetInsertionPointEnd();
654 void wxTextCtrl::Clear()
659 bool wxTextCtrl::IsModified() const
664 bool wxTextCtrl::IsEditable() const
666 return IsEnabled() && m_editable
;
669 bool wxTextCtrl::AcceptsFocus() const
671 // we don't want focus if we can't be edited
672 return /*IsEditable() && */ wxControl::AcceptsFocus();
675 wxSize
wxTextCtrl::DoGetBestSize() const
679 // these are the numbers from the HIG:
680 // we reduce them by the borders first
683 switch ( m_windowVariant
)
685 case wxWINDOW_VARIANT_NORMAL
:
689 case wxWINDOW_VARIANT_SMALL
:
693 case wxWINDOW_VARIANT_MINI
:
702 // as the above numbers have some free space around the text
703 // we get 5 lines like this anyway
704 if ( m_windowStyle
& wxTE_MULTILINE
)
707 if ( !HasFlag(wxNO_BORDER
) )
710 return wxSize(wText
, hText
);
713 // ----------------------------------------------------------------------------
715 // ----------------------------------------------------------------------------
717 void wxTextCtrl::Undo()
723 void wxTextCtrl::Redo()
729 bool wxTextCtrl::CanUndo() const
734 return GetPeer()->CanUndo() ;
737 bool wxTextCtrl::CanRedo() const
742 return GetPeer()->CanRedo() ;
745 void wxTextCtrl::MarkDirty()
750 void wxTextCtrl::DiscardEdits()
755 int wxTextCtrl::GetNumberOfLines() const
757 return GetPeer()->GetNumberOfLines() ;
760 long wxTextCtrl::XYToPosition(long x
, long y
) const
762 return GetPeer()->XYToPosition( x
, y
) ;
765 bool wxTextCtrl::PositionToXY(long pos
, long *x
, long *y
) const
767 return GetPeer()->PositionToXY( pos
, x
, y
) ;
770 void wxTextCtrl::ShowPosition(long pos
)
772 return GetPeer()->ShowPosition(pos
) ;
775 int wxTextCtrl::GetLineLength(long lineNo
) const
777 return GetPeer()->GetLineLength(lineNo
) ;
780 wxString
wxTextCtrl::GetLineText(long lineNo
) const
782 return GetPeer()->GetLineText(lineNo
) ;
785 void wxTextCtrl::Command(wxCommandEvent
& event
)
787 SetValue(event
.GetString());
788 ProcessCommand(event
);
791 void wxTextCtrl::OnDropFiles(wxDropFilesEvent
& event
)
793 // By default, load the first file into the text window.
794 if (event
.GetNumberOfFiles() > 0)
795 LoadFile( event
.GetFiles()[0] );
798 void wxTextCtrl::OnEraseBackground(wxEraseEvent
& event
)
800 // all erasing should be done by the real mac control implementation
801 // while this is true for MLTE under classic, the HITextView is somehow
802 // transparent but background erase is not working correctly, so intercept
803 // things while we can...
807 void wxTextCtrl::OnChar(wxKeyEvent
& event
)
809 int key
= event
.GetKeyCode() ;
810 bool eat_key
= false ;
812 if ( key
== 'a' && event
.MetaDown() )
819 if ( key
== 'c' && event
.MetaDown() )
827 if ( !IsEditable() && key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_DOWN
&& key
!= WXK_UP
&& key
!= WXK_TAB
&&
828 !( key
== WXK_RETURN
&& ( (m_windowStyle
& wxTE_PROCESS_ENTER
) || (m_windowStyle
& wxTE_MULTILINE
) ) )
829 // && key != WXK_PAGEUP && key != WXK_PAGEDOWN && key != WXK_HOME && key != WXK_END
836 // Check if we have reached the max # of chars (if it is set), but still
837 // allow navigation and deletion
838 if ( !IsMultiLine() && m_maxLength
&& GetValue().length() >= m_maxLength
&&
839 key
!= WXK_LEFT
&& key
!= WXK_RIGHT
&& key
!= WXK_TAB
&&
840 key
!= WXK_BACK
&& !( key
== WXK_RETURN
&& (m_windowStyle
& wxTE_PROCESS_ENTER
) )
843 // eat it, we don't want to add more than allowed # of characters
845 // TODO: generate EVT_TEXT_MAXLEN()
849 // assume that any key not processed yet is going to modify the control
852 if ( key
== 'v' && event
.MetaDown() )
860 if ( key
== 'x' && event
.MetaDown() )
871 if (m_windowStyle
& wxTE_PROCESS_ENTER
)
873 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, m_windowId
);
874 event
.SetEventObject( this );
875 event
.SetString( GetValue() );
876 if ( GetEventHandler()->ProcessEvent(event
) )
880 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
882 wxTopLevelWindow
*tlw
= wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow
);
883 if ( tlw
&& tlw
->GetDefaultItem() )
885 wxButton
*def
= wxDynamicCast(tlw
->GetDefaultItem(), wxButton
);
886 if ( def
&& def
->IsEnabled() )
888 wxCommandEvent
event(wxEVT_COMMAND_BUTTON_CLICKED
, def
->GetId() );
889 event
.SetEventObject(def
);
896 // this will make wxWidgets eat the ENTER key so that
897 // we actually prevent line wrapping in a single line text control
903 if ( !(m_windowStyle
& wxTE_PROCESS_TAB
))
906 if (!event
.ShiftDown())
907 flags
|= wxNavigationKeyEvent::IsForward
;
908 if (event
.ControlDown())
909 flags
|= wxNavigationKeyEvent::WinChange
;
916 // This is necessary (don't know why);
917 // otherwise the tab will not be inserted.
918 WriteText(wxT("\t"));
929 // perform keystroke handling
933 if ( ( key
>= 0x20 && key
< WXK_START
) ||
934 ( key
>= WXK_NUMPAD0
&& key
<= WXK_DIVIDE
) ||
939 wxCommandEvent
event1(wxEVT_COMMAND_TEXT_UPDATED
, m_windowId
);
940 event1
.SetEventObject( this );
941 wxPostEvent( GetEventHandler(), event1
);
945 // ----------------------------------------------------------------------------
946 // standard handlers for standard edit menu events
947 // ----------------------------------------------------------------------------
949 void wxTextCtrl::OnCut(wxCommandEvent
& WXUNUSED(event
))
954 void wxTextCtrl::OnCopy(wxCommandEvent
& WXUNUSED(event
))
959 void wxTextCtrl::OnPaste(wxCommandEvent
& WXUNUSED(event
))
964 void wxTextCtrl::OnUndo(wxCommandEvent
& WXUNUSED(event
))
969 void wxTextCtrl::OnRedo(wxCommandEvent
& WXUNUSED(event
))
974 void wxTextCtrl::OnDelete(wxCommandEvent
& WXUNUSED(event
))
978 GetSelection( &from
, &to
);
979 if (from
!= -1 && to
!= -1)
983 void wxTextCtrl::OnSelectAll(wxCommandEvent
& WXUNUSED(event
))
985 SetSelection(-1, -1);
988 void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent
& event
)
990 event
.Enable( CanCut() );
993 void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent
& event
)
995 event
.Enable( CanCopy() );
998 void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent
& event
)
1000 event
.Enable( CanPaste() );
1003 void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent
& event
)
1005 event
.Enable( CanUndo() );
1008 void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent
& event
)
1010 event
.Enable( CanRedo() );
1013 void wxTextCtrl::OnUpdateDelete(wxUpdateUIEvent
& event
)
1017 GetSelection( &from
, &to
);
1018 event
.Enable( from
!= -1 && to
!= -1 && from
!= to
&& IsEditable() ) ;
1021 void wxTextCtrl::OnUpdateSelectAll(wxUpdateUIEvent
& event
)
1023 event
.Enable(GetLastPosition() > 0);
1026 // CS: Context Menus only work with MLTE implementations or non-multiline HIViews at the moment
1028 void wxTextCtrl::OnContextMenu(wxContextMenuEvent
& event
)
1030 if ( GetPeer()->HasOwnContextMenu() )
1036 if (m_privateContextMenu
== NULL
)
1038 m_privateContextMenu
= new wxMenu
;
1039 m_privateContextMenu
->Append(wxID_UNDO
, _("&Undo"));
1040 m_privateContextMenu
->Append(wxID_REDO
, _("&Redo"));
1041 m_privateContextMenu
->AppendSeparator();
1042 m_privateContextMenu
->Append(wxID_CUT
, _("Cu&t"));
1043 m_privateContextMenu
->Append(wxID_COPY
, _("&Copy"));
1044 m_privateContextMenu
->Append(wxID_PASTE
, _("&Paste"));
1045 m_privateContextMenu
->Append(wxID_CLEAR
, _("&Delete"));
1046 m_privateContextMenu
->AppendSeparator();
1047 m_privateContextMenu
->Append(wxID_SELECTALL
, _("Select &All"));
1050 if (m_privateContextMenu
!= NULL
)
1051 PopupMenu(m_privateContextMenu
);
1054 bool wxTextCtrl::MacSetupCursor( const wxPoint
& pt
)
1056 if ( !GetPeer()->SetupCursor( pt
) )
1057 return wxWindow::MacSetupCursor( pt
) ;
1062 #if !TARGET_API_MAC_OSX
1064 // user pane implementation
1066 void wxTextCtrl::MacControlUserPaneDrawProc(wxInt16 part
)
1068 GetPeer()->MacControlUserPaneDrawProc( part
) ;
1071 wxInt16
wxTextCtrl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
1073 return GetPeer()->MacControlUserPaneHitTestProc( x
, y
) ;
1076 wxInt16
wxTextCtrl::MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
)
1078 return GetPeer()->MacControlUserPaneTrackingProc( x
, y
, actionProc
) ;
1081 void wxTextCtrl::MacControlUserPaneIdleProc()
1083 GetPeer()->MacControlUserPaneIdleProc( ) ;
1086 wxInt16
wxTextCtrl::MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
1088 return GetPeer()->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
1091 void wxTextCtrl::MacControlUserPaneActivateProc(bool activating
)
1093 GetPeer()->MacControlUserPaneActivateProc( activating
) ;
1096 wxInt16
wxTextCtrl::MacControlUserPaneFocusProc(wxInt16 action
)
1098 return GetPeer()->MacControlUserPaneFocusProc( action
) ;
1101 void wxTextCtrl::MacControlUserPaneBackgroundProc(void* info
)
1103 GetPeer()->MacControlUserPaneBackgroundProc( info
) ;
1108 // ----------------------------------------------------------------------------
1109 // implementation base class
1110 // ----------------------------------------------------------------------------
1112 wxMacTextControl::wxMacTextControl(wxTextCtrl
* peer
) :
1113 wxMacControl( peer
)
1117 wxMacTextControl::~wxMacTextControl()
1121 void wxMacTextControl::SetStyle(long WXUNUSED(start
),
1123 const wxTextAttr
& WXUNUSED(style
))
1127 void wxMacTextControl::Copy()
1131 void wxMacTextControl::Cut()
1135 void wxMacTextControl::Paste()
1139 bool wxMacTextControl::CanPaste() const
1144 void wxMacTextControl::SetEditable(bool WXUNUSED(editable
))
1148 wxTextPos
wxMacTextControl::GetLastPosition() const
1150 return GetStringValue().length() ;
1153 void wxMacTextControl::Replace( long from
, long to
, const wxString
&val
)
1155 SetSelection( from
, to
) ;
1159 void wxMacTextControl::Remove( long from
, long to
)
1161 SetSelection( from
, to
) ;
1162 WriteText( wxEmptyString
) ;
1165 void wxMacTextControl::Clear()
1167 SetStringValue( wxEmptyString
) ;
1170 bool wxMacTextControl::CanUndo() const
1175 void wxMacTextControl::Undo()
1179 bool wxMacTextControl::CanRedo() const
1184 void wxMacTextControl::Redo()
1188 long wxMacTextControl::XYToPosition(long WXUNUSED(x
), long WXUNUSED(y
)) const
1193 bool wxMacTextControl::PositionToXY(long WXUNUSED(pos
),
1195 long *WXUNUSED(y
)) const
1200 void wxMacTextControl::ShowPosition( long WXUNUSED(pos
) )
1204 int wxMacTextControl::GetNumberOfLines() const
1206 ItemCount lines
= 0 ;
1207 wxString content
= GetStringValue() ;
1210 for (size_t i
= 0; i
< content
.length() ; i
++)
1212 if (content
[i
] == '\r')
1219 wxString
wxMacTextControl::GetLineText(long lineNo
) const
1221 // TODO: change this if possible to reflect real lines
1222 wxString content
= GetStringValue() ;
1226 for (size_t i
= 0; i
< content
.length() ; i
++)
1228 if (count
== lineNo
)
1230 // Add chars in line then
1233 for (size_t j
= i
; j
< content
.length(); j
++)
1235 if (content
[j
] == '\n')
1244 if (content
[i
] == '\n')
1248 return wxEmptyString
;
1251 int wxMacTextControl::GetLineLength(long lineNo
) const
1253 // TODO: change this if possible to reflect real lines
1254 wxString content
= GetStringValue() ;
1258 for (size_t i
= 0; i
< content
.length() ; i
++)
1260 if (count
== lineNo
)
1262 // Count chars in line then
1264 for (size_t j
= i
; j
< content
.length(); j
++)
1267 if (content
[j
] == '\n')
1274 if (content
[i
] == '\n')
1281 // ----------------------------------------------------------------------------
1282 // standard unicode control implementation
1283 // ----------------------------------------------------------------------------
1285 #if TARGET_API_MAC_OSX
1287 // the current unicode textcontrol implementation has a bug : only if the control
1288 // is currently having the focus, the selection can be retrieved by the corresponding
1289 // data tag. So we have a mirroring using a member variable
1290 // TODO : build event table using virtual member functions for wxMacControl
1292 static const EventTypeSpec unicodeTextControlEventList
[] =
1294 { kEventClassControl
, kEventControlSetFocusPart
} ,
1297 static pascal OSStatus
wxMacUnicodeTextControlControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
1299 OSStatus result
= eventNotHandledErr
;
1300 wxMacUnicodeTextControl
* focus
= (wxMacUnicodeTextControl
*) data
;
1301 wxMacCarbonEvent
cEvent( event
) ;
1303 switch ( GetEventKind( event
) )
1305 case kEventControlSetFocusPart
:
1307 ControlPartCode controlPart
= cEvent
.GetParameter
<ControlPartCode
>(kEventParamControlPart
, typeControlPartCode
);
1308 if ( controlPart
== kControlFocusNoPart
)
1310 // about to loose focus -> store selection to field
1311 focus
->GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
1313 result
= CallNextEventHandler(handler
,event
) ;
1314 if ( controlPart
!= kControlFocusNoPart
)
1316 // about to gain focus -> set selection from field
1317 focus
->SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &focus
->m_selection
);
1328 static pascal OSStatus
wxMacUnicodeTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
1330 OSStatus result
= eventNotHandledErr
;
1332 switch ( GetEventClass( event
) )
1334 case kEventClassControl
:
1335 result
= wxMacUnicodeTextControlControlEventHandler( handler
, event
, data
) ;
1344 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler
)
1346 wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
) : wxMacTextControl( wxPeer
)
1350 wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl
*wxPeer
,
1351 const wxString
& str
,
1353 const wxSize
& size
, long style
)
1354 : wxMacTextControl( wxPeer
)
1356 Create( wxPeer
, str
, pos
, size
, style
);
1359 bool wxMacUnicodeTextControl::Create( wxTextCtrl
*wxPeer
,
1360 const wxString
& str
,
1362 const wxSize
& size
, long style
)
1364 m_font
= wxPeer
->GetFont() ;
1365 m_windowStyle
= style
;
1366 m_selection
.selStart
= m_selection
.selEnd
= 0;
1367 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
1369 wxMacConvertNewlines10To13( &st
) ;
1370 wxMacCFStringHolder
cf(st
, m_font
.GetEncoding()) ;
1371 CFStringRef cfr
= cf
;
1373 m_valueTag
= kControlEditTextCFStringTag
;
1374 CreateControl( wxPeer
, &bounds
, cfr
);
1376 if ( !(m_windowStyle
& wxTE_MULTILINE
) )
1377 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextSingleLineTag
, true ) ;
1379 InstallControlEventHandler( m_controlRef
, GetwxMacUnicodeTextControlEventHandlerUPP(),
1380 GetEventTypeCount(unicodeTextControlEventList
), unicodeTextControlEventList
, this,
1386 wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
1390 void wxMacUnicodeTextControl::VisibilityChanged(bool shown
)
1392 if ( !(m_windowStyle
& wxTE_MULTILINE
) && shown
)
1394 // work around a refresh issue insofar as not always the entire content is shown,
1395 // even if this would be possible
1396 ControlEditTextSelectionRec sel
;
1397 CFStringRef value
= NULL
;
1399 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
1400 verify_noerr( GetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
1401 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, &value
) );
1402 verify_noerr( SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) );
1404 CFRelease( value
) ;
1408 wxString
wxMacUnicodeTextControl::GetStringValue() const
1411 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
1414 wxMacCFStringHolder
cf(value
) ;
1415 result
= cf
.AsString() ;
1419 wxMacConvertNewlines13To10( &result
) ;
1421 wxMacConvertNewlines10To13( &result
) ;
1427 void wxMacUnicodeTextControl::SetStringValue( const wxString
&str
)
1430 wxMacConvertNewlines10To13( &st
) ;
1431 wxMacCFStringHolder
cf( st
, m_font
.GetEncoding() ) ;
1432 verify_noerr( SetData
<CFStringRef
>( 0, m_valueTag
, cf
) ) ;
1435 void wxMacUnicodeTextControl::CreateControl( wxTextCtrl
* peer
, const Rect
* bounds
, CFStringRef cfr
)
1437 Boolean isPassword
= ( m_windowStyle
& wxTE_PASSWORD
) != 0 ;
1440 m_valueTag
= kControlEditTextPasswordCFStringTag
;
1442 OSStatus err
= CreateEditUnicodeTextControl(
1443 MAC_WXHWND(peer
->MacGetTopLevelWindowRef()), bounds
, cfr
,
1444 isPassword
, NULL
, &m_controlRef
) ;
1445 verify_noerr( err
);
1448 void wxMacUnicodeTextControl::Copy()
1450 SendHICommand( kHICommandCopy
) ;
1453 void wxMacUnicodeTextControl::Cut()
1455 SendHICommand( kHICommandCut
) ;
1458 void wxMacUnicodeTextControl::Paste()
1460 SendHICommand( kHICommandPaste
) ;
1463 bool wxMacUnicodeTextControl::CanPaste() const
1468 void wxMacUnicodeTextControl::SetEditable(bool WXUNUSED(editable
))
1470 #if 0 // leads to problem because text cannot be selected anymore
1471 SetData
<Boolean
>( kControlEditTextPart
, kControlEditTextLockedTag
, (Boolean
) !editable
) ;
1475 void wxMacUnicodeTextControl::GetSelection( long* from
, long* to
) const
1477 ControlEditTextSelectionRec sel
;
1479 verify_noerr( GetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ) ;
1484 *from
= sel
.selStart
;
1489 void wxMacUnicodeTextControl::SetSelection( long from
, long to
)
1491 ControlEditTextSelectionRec sel
;
1493 int textLength
= 0 ;
1494 CFStringRef value
= GetData
<CFStringRef
>(0, m_valueTag
) ;
1497 wxMacCFStringHolder
cf(value
) ;
1498 textLength
= cf
.AsString().length() ;
1501 if ((from
== -1) && (to
== -1))
1508 from
= wxMin(textLength
,wxMax(from
,0)) ;
1509 to
= wxMax(0,wxMin(textLength
,to
)) ;
1512 sel
.selStart
= from
;
1515 SetData
<ControlEditTextSelectionRec
>( 0, kControlEditTextSelectionTag
, &sel
) ;
1520 void wxMacUnicodeTextControl::WriteText( const wxString
& str
)
1523 wxMacConvertNewlines10To13( &st
) ;
1525 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
1528 wxMacCFStringHolder
cf(st
, m_font
.GetEncoding() ) ;
1529 CFStringRef value
= cf
;
1530 SetData
<CFStringRef
>( 0, kControlEditTextInsertCFStringRefTag
, &value
);
1535 wxString val
= GetStringValue() ;
1537 GetSelection( &start
, &end
) ;
1538 val
.Remove( start
, end
- start
) ;
1539 val
.insert( start
, str
) ;
1540 SetStringValue( val
) ;
1541 SetSelection( start
+ str
.length() , start
+ str
.length() ) ;
1547 // ----------------------------------------------------------------------------
1548 // MLTE control implementation (common part)
1549 // ----------------------------------------------------------------------------
1551 // if MTLE is read only, no changes at all are allowed, not even from
1552 // procedural API, in order to allow changes via API all the same we must undo
1553 // the readonly status while we are executing, this class helps to do so
1555 class wxMacEditHelper
1558 wxMacEditHelper( TXNObject txn
)
1560 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1562 TXNGetTXNObjectControls( m_txn
, 1 , tag
, m_data
) ;
1563 if ( m_data
[0].uValue
== kTXNReadOnly
)
1565 TXNControlData data
[] = { { kTXNReadWrite
} } ;
1566 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, data
) ;
1572 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1573 if ( m_data
[0].uValue
== kTXNReadOnly
)
1574 TXNSetTXNObjectControls( m_txn
, false , 1 , tag
, m_data
) ;
1579 TXNControlData m_data
[1] ;
1582 wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl
*peer
)
1583 : wxMacTextControl( peer
)
1585 SetNeedsFocusRect( true ) ;
1588 wxString
wxMacMLTEControl::GetStringValue() const
1592 Size actualSize
= 0;
1597 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNUnicodeTextData
);
1606 actualSize
= GetHandleSize( theText
) / sizeof(UniChar
) ;
1607 if ( actualSize
> 0 )
1609 wxChar
*ptr
= NULL
;
1611 #if SIZEOF_WCHAR_T == 2
1612 ptr
= new wxChar
[actualSize
+ 1] ;
1613 wxStrncpy( ptr
, (wxChar
*)(*theText
) , actualSize
) ;
1615 SetHandleSize( theText
, (actualSize
+ 1) * sizeof(UniChar
) ) ;
1617 (((UniChar
*)*theText
)[actualSize
]) = 0 ;
1618 wxMBConvUTF16 converter
;
1619 size_t noChars
= converter
.MB2WC( NULL
, (const char*)*theText
, 0 ) ;
1620 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Unable to count the number of characters in this string!") );
1621 ptr
= new wxChar
[noChars
+ 1] ;
1623 noChars
= converter
.MB2WC( ptr
, (const char*)*theText
, noChars
+ 1 ) ;
1624 wxASSERT_MSG( noChars
!= wxCONV_FAILED
, _T("Conversion of string failed!") );
1626 HUnlock( theText
) ;
1629 ptr
[actualSize
] = 0 ;
1630 result
= wxString( ptr
) ;
1634 DisposeHandle( theText
) ;
1638 err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
1647 actualSize
= GetHandleSize( theText
) ;
1648 if ( actualSize
> 0 )
1651 result
= wxString( *theText
, wxConvLocal
, actualSize
) ;
1652 HUnlock( theText
) ;
1655 DisposeHandle( theText
) ;
1661 wxMacConvertNewlines13To10( &result
) ;
1663 wxMacConvertNewlines10To13( &result
) ;
1669 void wxMacMLTEControl::SetStringValue( const wxString
&str
)
1672 wxMacConvertNewlines10To13( &st
);
1676 wxMacWindowClipper
c( m_peer
) ;
1680 wxMacEditHelper
help( m_txn
);
1681 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
);
1684 TXNSetSelection( m_txn
, 0, 0 );
1685 TXNShowSelection( m_txn
, kTXNShowStart
);
1689 TXNFrameOptions
wxMacMLTEControl::FrameOptionsFromWXStyle( long wxStyle
)
1691 TXNFrameOptions frameOptions
= kTXNDontDrawCaretWhenInactiveMask
;
1693 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
1694 frameOptions
|= kTXNDoFontSubstitutionMask
;
1697 if ( ! (wxStyle
& wxTE_NOHIDESEL
) )
1698 frameOptions
|= kTXNDontDrawSelectionWhenInactiveMask
;
1700 if ( wxStyle
& (wxHSCROLL
| wxTE_DONTWRAP
) )
1701 frameOptions
|= kTXNWantHScrollBarMask
;
1703 if ( wxStyle
& wxTE_MULTILINE
)
1705 frameOptions
|= kTXNAlwaysWrapAtViewEdgeMask
;
1707 if ( !(wxStyle
& wxTE_NO_VSCROLL
) )
1709 frameOptions
|= kTXNWantVScrollBarMask
;
1711 // The following code causes drawing problems on 10.4. Perhaps it can be restored for
1712 // older versions of the OS, but I'm not sure it's appropriate to put a grow icon here
1713 // anyways, as AFAIK users can't actually use it to resize the text ctrl.
1714 // if ( frameOptions & kTXNWantHScrollBarMask )
1715 // frameOptions |= kTXNDrawGrowIconMask ;
1720 frameOptions
|= kTXNSingleLineOnlyMask
;
1723 return frameOptions
;
1726 void wxMacMLTEControl::AdjustCreationAttributes(const wxColour
&background
,
1727 bool WXUNUSED(visible
))
1729 TXNControlTag iControlTags
[] =
1731 kTXNDoFontSubstitution
,
1732 kTXNWordWrapStateTag
,
1734 TXNControlData iControlData
[] =
1740 int toptag
= WXSIZEOF( iControlTags
) ;
1742 if ( m_windowStyle
& wxTE_MULTILINE
)
1744 iControlData
[1].uValue
=
1745 (m_windowStyle
& wxTE_DONTWRAP
)
1750 OSStatus err
= TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) ;
1751 verify_noerr( err
);
1753 // setting the default font:
1754 // under 10.2 this causes a visible caret, therefore we avoid it
1756 if ( UMAGetSystemVersion() >= 0x1030 )
1762 GetThemeFont( kThemeSystemFont
, GetApplicationScript() , fontName
, &fontSize
, &fontStyle
) ;
1764 TXNTypeAttributes typeAttr
[] =
1766 { kTXNQDFontNameAttribute
, kTXNQDFontNameAttributeSize
, { (void*) fontName
} } ,
1767 { kTXNQDFontSizeAttribute
, kTXNFontSizeAttributeSize
, { (void*) (fontSize
<< 16) } } ,
1768 { kTXNQDFontStyleAttribute
, kTXNQDFontStyleAttributeSize
, { (void*) normal
} } ,
1771 err
= TXNSetTypeAttributes(
1772 m_txn
, sizeof(typeAttr
) / sizeof(TXNTypeAttributes
),
1773 typeAttr
, kTXNStartOffset
, kTXNEndOffset
);
1774 verify_noerr( err
);
1777 if ( m_windowStyle
& wxTE_PASSWORD
)
1779 UniChar c
= 0x00A5 ;
1780 err
= TXNEchoMode( m_txn
, c
, 0 , true );
1781 verify_noerr( err
);
1784 TXNBackground tback
;
1785 tback
.bgType
= kTXNBackgroundTypeRGB
;
1786 tback
.bg
.color
= MAC_WXCOLORREF( background
.GetPixel() );
1787 TXNSetBackground( m_txn
, &tback
);
1789 #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
1790 if ( UMAGetSystemVersion() >= 0x1040 )
1792 TXNCommandEventSupportOptions options
;
1793 if ( TXNGetCommandEventSupport( m_txn
, &options
) == noErr
)
1796 kTXNSupportEditCommandProcessing
1797 | kTXNSupportEditCommandUpdating
1798 | kTXNSupportFontCommandProcessing
1799 | kTXNSupportFontCommandUpdating
;
1801 // only spell check when not read-only
1802 // use system options for the default
1803 bool checkSpelling
= false ;
1804 if ( !(m_windowStyle
& wxTE_READONLY
) )
1806 #if wxUSE_SYSTEM_OPTIONS
1807 if ( wxSystemOptions::HasOption( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER
) && (wxSystemOptions::GetOptionInt( wxMAC_TEXTCONTROL_USE_SPELL_CHECKER
) == 1) )
1809 checkSpelling
= true ;
1814 if ( checkSpelling
)
1816 kTXNSupportSpellCheckCommandProcessing
1817 | kTXNSupportSpellCheckCommandUpdating
;
1819 TXNSetCommandEventSupport( m_txn
, options
) ;
1825 void wxMacMLTEControl::SetBackground( const wxBrush
&brush
)
1827 // currently only solid background are supported
1828 TXNBackground tback
;
1830 tback
.bgType
= kTXNBackgroundTypeRGB
;
1831 tback
.bg
.color
= MAC_WXCOLORREF( brush
.GetColour().GetPixel() );
1832 TXNSetBackground( m_txn
, &tback
);
1835 void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr
& style
, long from
, long to
)
1837 TXNTypeAttributes typeAttr
[4] ;
1839 size_t typeAttrCount
= 0 ;
1842 TXNControlTag controlTags
[4];
1843 TXNControlData controlData
[4];
1844 size_t controlAttrCount
= 0;
1846 TXNTab
* tabs
= NULL
;
1848 bool relayout
= false;
1850 if ( style
.HasFont() )
1852 wxASSERT( typeAttrCount
< WXSIZEOF(typeAttr
) );
1853 const wxFont
&font
= style
.GetFont() ;
1854 typeAttr
[typeAttrCount
].tag
= kTXNATSUIStyle
;
1855 typeAttr
[typeAttrCount
].size
= kTXNATSUIStyleSize
;
1856 typeAttr
[typeAttrCount
].data
.dataPtr
= font
.MacGetATSUStyle() ;
1860 if ( style
.HasTextColour() )
1862 wxASSERT( typeAttrCount
< WXSIZEOF(typeAttr
) );
1863 color
= MAC_WXCOLORREF(style
.GetTextColour().GetPixel()) ;
1865 typeAttr
[typeAttrCount
].tag
= kTXNQDFontColorAttribute
;
1866 typeAttr
[typeAttrCount
].size
= kTXNQDFontColorAttributeSize
;
1867 typeAttr
[typeAttrCount
].data
.dataPtr
= (void*) &color
;
1871 if ( style
.HasAlignment() )
1873 wxASSERT( controlAttrCount
< WXSIZEOF(controlTags
) );
1876 switch ( style
.GetAlignment() )
1878 case wxTEXT_ALIGNMENT_LEFT
:
1879 align
= kTXNFlushLeft
;
1881 case wxTEXT_ALIGNMENT_CENTRE
:
1884 case wxTEXT_ALIGNMENT_RIGHT
:
1885 align
= kTXNFlushRight
;
1887 case wxTEXT_ALIGNMENT_JUSTIFIED
:
1888 align
= kTXNFullJust
;
1891 case wxTEXT_ALIGNMENT_DEFAULT
:
1892 align
= kTXNFlushDefault
;
1896 controlTags
[controlAttrCount
] = kTXNJustificationTag
;
1897 controlData
[controlAttrCount
].sValue
= align
;
1898 controlAttrCount
++ ;
1901 if ( style
.HasLeftIndent() || style
.HasRightIndent() )
1903 wxASSERT( controlAttrCount
< WXSIZEOF(controlTags
) );
1904 controlTags
[controlAttrCount
] = kTXNMarginsTag
;
1905 controlData
[controlAttrCount
].marginsPtr
= &margins
;
1906 verify_noerr( TXNGetTXNObjectControls (m_txn
, 1 ,
1907 &controlTags
[controlAttrCount
], &controlData
[controlAttrCount
]) );
1908 if ( style
.HasLeftIndent() )
1910 margins
.leftMargin
= style
.GetLeftIndent() / 254.0 * 72 + 0.5;
1912 if ( style
.HasRightIndent() )
1914 margins
.rightMargin
= style
.GetRightIndent() / 254.0 * 72 + 0.5;
1916 controlAttrCount
++ ;
1919 if ( style
.HasTabs() )
1921 const wxArrayInt
& tabarray
= style
.GetTabs();
1922 // unfortunately Mac only applies a tab distance, not individually different tabs
1923 controlTags
[controlAttrCount
] = kTXNTabSettingsTag
;
1924 if ( tabarray
.size() > 0 )
1925 controlData
[controlAttrCount
].tabValue
.value
= tabarray
[0] / 254.0 * 72 + 0.5;
1927 controlData
[controlAttrCount
].tabValue
.value
= 72 ;
1929 controlData
[controlAttrCount
].tabValue
.tabType
= kTXNLeftTab
;
1930 controlAttrCount
++ ;
1933 // unfortunately the relayout is not automatic
1934 if ( controlAttrCount
> 0 )
1936 verify_noerr( TXNSetTXNObjectControls (m_txn
, false /* don't clear all */, controlAttrCount
,
1937 controlTags
, controlData
) );
1941 if ( typeAttrCount
> 0 )
1943 verify_noerr( TXNSetTypeAttributes( m_txn
, typeAttrCount
, typeAttr
, from
, to
) );
1954 TXNRecalcTextLayout( m_txn
);
1958 void wxMacMLTEControl::SetFont(const wxFont
& font
,
1959 const wxColour
& foreground
,
1960 long WXUNUSED(windowStyle
))
1962 wxMacEditHelper
help( m_txn
) ;
1963 TXNSetAttribute( wxTextAttr( foreground
, wxNullColour
, font
), kTXNStartOffset
, kTXNEndOffset
) ;
1966 void wxMacMLTEControl::SetStyle( long start
, long end
, const wxTextAttr
& style
)
1968 wxMacEditHelper
help( m_txn
) ;
1969 TXNSetAttribute( style
, start
, end
) ;
1972 void wxMacMLTEControl::Copy()
1977 void wxMacMLTEControl::Cut()
1982 void wxMacMLTEControl::Paste()
1987 bool wxMacMLTEControl::CanPaste() const
1989 return TXNIsScrapPastable() ;
1992 void wxMacMLTEControl::SetEditable(bool editable
)
1994 TXNControlTag tag
[] = { kTXNIOPrivilegesTag
} ;
1995 TXNControlData data
[] = { { editable
? kTXNReadWrite
: kTXNReadOnly
} } ;
1996 TXNSetTXNObjectControls( m_txn
, false, WXSIZEOF(tag
), tag
, data
) ;
1999 wxTextPos
wxMacMLTEControl::GetLastPosition() const
2001 wxTextPos actualsize
= 0 ;
2004 OSErr err
= TXNGetDataEncoded( m_txn
, kTXNStartOffset
, kTXNEndOffset
, &theText
, kTXNTextData
);
2009 actualsize
= GetHandleSize( theText
) ;
2010 DisposeHandle( theText
) ;
2020 void wxMacMLTEControl::Replace( long from
, long to
, const wxString
&str
)
2022 wxString value
= str
;
2023 wxMacConvertNewlines10To13( &value
) ;
2025 wxMacEditHelper
help( m_txn
) ;
2027 wxMacWindowClipper
c( m_peer
) ;
2030 TXNSetSelection( m_txn
, from
, to
) ;
2032 SetTXNData( value
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
2035 void wxMacMLTEControl::Remove( long from
, long to
)
2038 wxMacWindowClipper
c( m_peer
) ;
2040 wxMacEditHelper
help( m_txn
) ;
2041 TXNSetSelection( m_txn
, from
, to
) ;
2045 void wxMacMLTEControl::GetSelection( long* from
, long* to
) const
2048 TXNGetSelection( m_txn
, &f
, &t
) ;
2053 void wxMacMLTEControl::SetSelection( long from
, long to
)
2056 wxMacWindowClipper
c( m_peer
) ;
2059 // change the selection
2060 if ((from
== -1) && (to
== -1))
2061 TXNSelectAll( m_txn
);
2063 TXNSetSelection( m_txn
, from
, to
);
2065 TXNShowSelection( m_txn
, kTXNShowStart
);
2068 void wxMacMLTEControl::WriteText( const wxString
& str
)
2071 wxMacConvertNewlines10To13( &st
) ;
2073 long start
, end
, dummy
;
2075 GetSelection( &start
, &dummy
) ;
2077 wxMacWindowClipper
c( m_peer
) ;
2081 wxMacEditHelper
helper( m_txn
) ;
2082 SetTXNData( st
, kTXNUseCurrentSelection
, kTXNUseCurrentSelection
) ;
2085 GetSelection( &dummy
, &end
) ;
2087 // TODO: SetStyle( start , end , GetDefaultStyle() ) ;
2090 void wxMacMLTEControl::Clear()
2093 wxMacWindowClipper
c( m_peer
) ;
2095 wxMacEditHelper
st( m_txn
) ;
2096 TXNSetSelection( m_txn
, kTXNStartOffset
, kTXNEndOffset
) ;
2100 bool wxMacMLTEControl::CanUndo() const
2102 return TXNCanUndo( m_txn
, NULL
) ;
2105 void wxMacMLTEControl::Undo()
2110 bool wxMacMLTEControl::CanRedo() const
2112 return TXNCanRedo( m_txn
, NULL
) ;
2115 void wxMacMLTEControl::Redo()
2120 int wxMacMLTEControl::GetNumberOfLines() const
2122 ItemCount lines
= 0 ;
2123 TXNGetLineCount( m_txn
, &lines
) ;
2128 long wxMacMLTEControl::XYToPosition(long x
, long y
) const
2133 // TODO: find a better implementation : while we can get the
2134 // line metrics of a certain line, we don't get its starting
2135 // position, so it would probably be rather a binary search
2136 // for the start position
2137 long xpos
= 0, ypos
= 0 ;
2138 int lastHeight
= 0 ;
2141 lastpos
= GetLastPosition() ;
2142 for ( n
= 0 ; n
<= (ItemCount
) lastpos
; ++n
)
2144 if ( y
== ypos
&& x
== xpos
)
2147 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
2149 if ( curpt
.v
> lastHeight
)
2155 lastHeight
= curpt
.v
;
2164 bool wxMacMLTEControl::PositionToXY( long pos
, long *x
, long *y
) const
2174 lastpos
= GetLastPosition() ;
2175 if ( pos
<= lastpos
)
2177 // TODO: find a better implementation - while we can get the
2178 // line metrics of a certain line, we don't get its starting
2179 // position, so it would probably be rather a binary search
2180 // for the start position
2181 long xpos
= 0, ypos
= 0 ;
2182 int lastHeight
= 0 ;
2185 for ( n
= 0 ; n
<= (ItemCount
) pos
; ++n
)
2187 TXNOffsetToPoint( m_txn
, n
, &curpt
) ;
2189 if ( curpt
.v
> lastHeight
)
2195 lastHeight
= curpt
.v
;
2210 void wxMacMLTEControl::ShowPosition( long pos
)
2212 Point current
, desired
;
2213 TXNOffset selstart
, selend
;
2215 TXNGetSelection( m_txn
, &selstart
, &selend
);
2216 TXNOffsetToPoint( m_txn
, selstart
, ¤t
);
2217 TXNOffsetToPoint( m_txn
, pos
, &desired
);
2219 // TODO: use HIPoints for 10.3 and above
2221 OSErr theErr
= noErr
;
2222 long dv
= desired
.v
- current
.v
;
2223 long dh
= desired
.h
- current
.h
;
2224 TXNShowSelection( m_txn
, kTXNShowStart
) ; // NB: should this be kTXNShowStart or kTXNShowEnd ??
2225 theErr
= TXNScroll( m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
, &dv
, &dh
);
2227 // there will be an error returned for classic MLTE implementation when the control is
2228 // invisible, but HITextView works correctly, so we don't assert that one
2229 // wxASSERT_MSG( theErr == noErr, _T("TXNScroll returned an error!") );
2232 void wxMacMLTEControl::SetTXNData( const wxString
& st
, TXNOffset start
, TXNOffset end
)
2235 #if SIZEOF_WCHAR_T == 2
2236 size_t len
= st
.length() ;
2237 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)st
.wc_str(), len
* 2, start
, end
);
2239 wxMBConvUTF16 converter
;
2240 ByteCount byteBufferLen
= converter
.WC2MB( NULL
, st
.wc_str(), 0 ) ;
2241 UniChar
*unibuf
= (UniChar
*)malloc( byteBufferLen
) ;
2242 converter
.WC2MB( (char*)unibuf
, st
.wc_str(), byteBufferLen
) ;
2243 TXNSetData( m_txn
, kTXNUnicodeTextData
, (void*)unibuf
, byteBufferLen
, start
, end
) ;
2247 wxCharBuffer text
= st
.mb_str( wxConvLocal
) ;
2248 TXNSetData( m_txn
, kTXNTextData
, (void*)text
.data(), strlen( text
), start
, end
) ;
2252 wxString
wxMacMLTEControl::GetLineText(long lineNo
) const
2256 if ( lineNo
< GetNumberOfLines() )
2259 Fixed lineWidth
, lineHeight
, currentHeight
;
2262 // get the first possible position in the control
2263 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
2265 // Iterate through the lines until we reach the one we want,
2266 // adding to our current y pixel point position
2269 while (ypos
< lineNo
)
2271 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
2272 currentHeight
+= lineHeight
;
2275 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
2276 TXNOffset theOffset
;
2277 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
2279 wxString content
= GetStringValue() ;
2280 Point currentPoint
= thePoint
;
2281 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
2283 line
+= content
[theOffset
];
2284 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
2291 int wxMacMLTEControl::GetLineLength(long lineNo
) const
2295 if ( lineNo
< GetNumberOfLines() )
2298 Fixed lineWidth
, lineHeight
, currentHeight
;
2301 // get the first possible position in the control
2302 TXNOffsetToPoint(m_txn
, 0, &firstPoint
);
2304 // Iterate through the lines until we reach the one we want,
2305 // adding to our current y pixel point position
2308 while (ypos
< lineNo
)
2310 TXNGetLineMetrics(m_txn
, ypos
++, &lineWidth
, &lineHeight
);
2311 currentHeight
+= lineHeight
;
2314 Point thePoint
= { firstPoint
.v
+ (currentHeight
>> 16), firstPoint
.h
+ (0) };
2315 TXNOffset theOffset
;
2316 TXNPointToOffset(m_txn
, thePoint
, &theOffset
);
2318 wxString content
= GetStringValue() ;
2319 Point currentPoint
= thePoint
;
2320 while (thePoint
.v
== currentPoint
.v
&& theOffset
< content
.length())
2323 TXNOffsetToPoint(m_txn
, ++theOffset
, ¤tPoint
);
2330 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
2332 // ----------------------------------------------------------------------------
2333 // MLTE control implementation (classic part)
2334 // ----------------------------------------------------------------------------
2336 // OS X Notes : We still don't have a full replacement for MLTE, so this implementation
2337 // has to live on. We have different problems coming from outdated implementations on the
2338 // various OS X versions. Most deal with the scrollbars: they are not correctly embedded
2339 // while this can be solved on 10.3 by reassigning them the correct place, on 10.2 there is
2340 // no way out, therefore we are using our own implementation and our own scrollbars ....
2342 #ifdef __WXMAC_OSX__
2344 TXNScrollInfoUPP gTXNScrollInfoProc
= NULL
;
2345 ControlActionUPP gTXNScrollActionProc
= NULL
;
2347 pascal void wxMacMLTEClassicControl::TXNScrollInfoProc(
2348 SInt32 iValue
, SInt32 iMaximumValue
,
2349 TXNScrollBarOrientation iScrollBarOrientation
, SInt32 iRefCon
)
2351 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) iRefCon
;
2352 SInt32 value
= wxMax( iValue
, 0 ) ;
2353 SInt32 maximum
= wxMax( iMaximumValue
, 0 ) ;
2355 if ( iScrollBarOrientation
== kTXNHorizontal
)
2357 if ( mlte
->m_sbHorizontal
)
2359 SetControl32BitValue( mlte
->m_sbHorizontal
, value
) ;
2360 SetControl32BitMaximum( mlte
->m_sbHorizontal
, maximum
) ;
2361 mlte
->m_lastHorizontalValue
= value
;
2364 else if ( iScrollBarOrientation
== kTXNVertical
)
2366 if ( mlte
->m_sbVertical
)
2368 SetControl32BitValue( mlte
->m_sbVertical
, value
) ;
2369 SetControl32BitMaximum( mlte
->m_sbVertical
, maximum
) ;
2370 mlte
->m_lastVerticalValue
= value
;
2375 pascal void wxMacMLTEClassicControl::TXNScrollActionProc( ControlRef controlRef
, ControlPartCode partCode
)
2377 wxMacMLTEClassicControl
* mlte
= (wxMacMLTEClassicControl
*) GetControlReference( controlRef
) ;
2381 if ( controlRef
!= mlte
->m_sbVertical
&& controlRef
!= mlte
->m_sbHorizontal
)
2385 bool isHorizontal
= ( controlRef
== mlte
->m_sbHorizontal
) ;
2387 SInt32 minimum
= 0 ;
2388 SInt32 maximum
= GetControl32BitMaximum( controlRef
) ;
2389 SInt32 value
= GetControl32BitValue( controlRef
) ;
2394 case kControlDownButtonPart
:
2398 case kControlUpButtonPart
:
2402 case kControlPageDownPart
:
2403 delta
= GetControlViewSize( controlRef
) ;
2406 case kControlPageUpPart
:
2407 delta
= -GetControlViewSize( controlRef
) ;
2410 case kControlIndicatorPart
:
2411 delta
= value
- (isHorizontal
? mlte
->m_lastHorizontalValue
: mlte
->m_lastVerticalValue
) ;
2420 SInt32 newValue
= value
;
2422 if ( partCode
!= kControlIndicatorPart
)
2424 if ( value
+ delta
< minimum
)
2425 delta
= minimum
- value
;
2426 if ( value
+ delta
> maximum
)
2427 delta
= maximum
- value
;
2429 SetControl32BitValue( controlRef
, value
+ delta
) ;
2430 newValue
= value
+ delta
;
2433 SInt32 verticalDelta
= isHorizontal
? 0 : delta
;
2434 SInt32 horizontalDelta
= isHorizontal
? delta
: 0 ;
2437 mlte
->m_txn
, kTXNScrollUnitsInPixels
, kTXNScrollUnitsInPixels
,
2438 &verticalDelta
, &horizontalDelta
);
2439 verify_noerr( err
);
2442 mlte
->m_lastHorizontalValue
= newValue
;
2444 mlte
->m_lastVerticalValue
= newValue
;
2449 // make correct activations
2450 void wxMacMLTEClassicControl::MacActivatePaneText(bool setActive
)
2452 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference(m_controlRef
);
2454 wxMacWindowClipper
clipper( textctrl
) ;
2455 TXNActivate( m_txn
, m_txnFrameID
, setActive
);
2457 ControlRef controlFocus
= 0 ;
2458 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2459 if ( controlFocus
== m_controlRef
)
2460 TXNFocus( m_txn
, setActive
);
2463 void wxMacMLTEClassicControl::MacFocusPaneText(bool setFocus
)
2465 TXNFocus( m_txn
, setFocus
);
2468 // guards against inappropriate redraw (hidden objects drawing onto window)
2470 void wxMacMLTEClassicControl::MacSetObjectVisibility(bool vis
)
2472 ControlRef controlFocus
= 0 ;
2473 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2475 if ( !vis
&& (controlFocus
== m_controlRef
) )
2476 SetKeyboardFocus( m_txnWindow
, m_controlRef
, kControlFocusNoPart
) ;
2478 TXNControlTag iControlTags
[1] = { kTXNVisibilityTag
};
2479 TXNControlData iControlData
[1] = { { (UInt32
)false } };
2481 verify_noerr( TXNGetTXNObjectControls( m_txn
, 1, iControlTags
, iControlData
) ) ;
2483 if ( iControlData
[0].uValue
!= vis
)
2485 iControlData
[0].uValue
= vis
;
2486 verify_noerr( TXNSetTXNObjectControls( m_txn
, false , 1, iControlTags
, iControlData
) ) ;
2489 // currently, we always clip as partial visibility (overlapped) visibility is also a problem,
2490 // if we run into further problems we might set the FrameBounds to an empty rect here
2493 // make sure that the TXNObject is at the right position
2495 void wxMacMLTEClassicControl::MacUpdatePosition()
2497 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2498 if ( textctrl
== NULL
)
2502 UMAGetControlBoundsInWindowCoords( m_controlRef
, &bounds
);
2504 wxRect visRect
= textctrl
->MacGetClippedClientRect() ;
2505 Rect visBounds
= { visRect
.y
, visRect
.x
, visRect
.y
+ visRect
.height
, visRect
.x
+ visRect
.width
} ;
2508 textctrl
->MacWindowToRootWindow( &x
, &y
) ;
2509 OffsetRect( &visBounds
, x
, y
) ;
2511 if ( !EqualRect( &bounds
, &m_txnControlBounds
) || !EqualRect( &visBounds
, &m_txnVisBounds
) )
2513 m_txnControlBounds
= bounds
;
2514 m_txnVisBounds
= visBounds
;
2515 wxMacWindowClipper
cl( textctrl
) ;
2517 #ifdef __WXMAC_OSX__
2518 if ( m_sbHorizontal
|| m_sbVertical
)
2520 int w
= bounds
.right
- bounds
.left
;
2521 int h
= bounds
.bottom
- bounds
.top
;
2523 if ( m_sbHorizontal
)
2527 sbBounds
.left
= -1 ;
2528 sbBounds
.top
= h
- 14 ;
2529 sbBounds
.right
= w
+ 1 ;
2530 sbBounds
.bottom
= h
+ 1 ;
2532 SetControlBounds( m_sbHorizontal
, &sbBounds
) ;
2533 SetControlViewSize( m_sbHorizontal
, w
) ;
2540 sbBounds
.left
= w
- 14 ;
2542 sbBounds
.right
= w
+ 1 ;
2543 sbBounds
.bottom
= m_sbHorizontal
? h
- 14 : h
+ 1 ;
2545 SetControlBounds( m_sbVertical
, &sbBounds
) ;
2546 SetControlViewSize( m_sbVertical
, h
) ;
2551 TXNLongRect olddestRect
;
2552 TXNGetRectBounds( m_txn
, &oldviewRect
, &olddestRect
, NULL
) ;
2554 Rect viewRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2555 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
2556 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
2557 TXNLongRect destRect
= { m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2558 m_txnControlBounds
.bottom
- ( m_sbHorizontal
? 14 : 0 ) ,
2559 m_txnControlBounds
.right
- ( m_sbVertical
? 14 : 0 ) } ;
2561 if ( olddestRect
.right
>= 10000 )
2562 destRect
.right
= destRect
.left
+ 32000 ;
2564 if ( olddestRect
.bottom
>= 0x20000000 )
2565 destRect
.bottom
= destRect
.top
+ 0x40000000 ;
2567 SectRect( &viewRect
, &visBounds
, &viewRect
) ;
2568 TXNSetRectBounds( m_txn
, &viewRect
, &destRect
, true ) ;
2573 m_txnControlBounds
.top
,
2574 m_txnControlBounds
.left
,
2575 m_txnControlBounds
.bottom
- (m_sbHorizontal
? 14 : 0),
2576 m_txnControlBounds
.right
- (m_sbVertical
? 14 : 0),
2582 m_txn
, m_txnControlBounds
.top
, m_txnControlBounds
.left
,
2583 wxMax( m_txnControlBounds
.bottom
, m_txnControlBounds
.top
),
2584 wxMax( m_txnControlBounds
.right
, m_txnControlBounds
.left
), m_txnFrameID
);
2587 // the SetFrameBounds method under Classic sometimes does not correctly scroll a selection into sight after a
2588 // movement, therefore we have to force it
2590 // this problem has been reported in OSX as well, so we use this here once again
2592 TXNLongRect textRect
;
2593 TXNGetRectBounds( m_txn
, NULL
, NULL
, &textRect
) ;
2594 if ( textRect
.left
< m_txnControlBounds
.left
)
2595 TXNShowSelection( m_txn
, kTXNShowStart
) ;
2599 void wxMacMLTEClassicControl::SetRect( Rect
*r
)
2601 wxMacControl::SetRect( r
) ;
2602 MacUpdatePosition() ;
2605 void wxMacMLTEClassicControl::MacControlUserPaneDrawProc(wxInt16
WXUNUSED(thePart
))
2607 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2608 if ( textctrl
== NULL
)
2611 if ( textctrl
->MacIsReallyShown() )
2613 wxMacWindowClipper
clipper( textctrl
) ;
2614 TXNDraw( m_txn
, NULL
) ;
2618 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
)
2620 Point where
= { y
, x
} ;
2621 ControlPartCode result
= kControlNoPart
;
2623 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
2624 if ( (textctrl
!= NULL
) && textctrl
->MacIsReallyShown() )
2626 if (PtInRect( where
, &m_txnControlBounds
))
2628 result
= kControlEditTextPart
;
2632 // sometimes we get the coords also in control local coordinates, therefore test again
2634 textctrl
->MacClientToRootWindow( &x
, &y
) ;
2638 if (PtInRect( where
, &m_txnControlBounds
))
2639 result
= kControlEditTextPart
;
2646 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneTrackingProc( wxInt16 x
, wxInt16 y
, void* WXUNUSED(actionProc
) )
2648 ControlPartCode result
= kControlNoPart
;
2650 wxTextCtrl
* textctrl
= (wxTextCtrl
*) GetControlReference( m_controlRef
);
2651 if ( (textctrl
!= NULL
) && textctrl
->MacIsReallyShown() )
2653 Point startPt
= { y
, x
} ;
2655 // for compositing, we must convert these into toplevel window coordinates, because hittesting expects them
2657 textctrl
->MacClientToRootWindow( &x
, &y
) ;
2661 switch (MacControlUserPaneHitTestProc( startPt
.h
, startPt
.v
))
2663 case kControlEditTextPart
:
2665 wxMacWindowClipper
clipper( textctrl
) ;
2668 ConvertEventRefToEventRecord( (EventRef
) wxTheApp
->MacGetCurrentEvent() , &rec
) ;
2669 TXNClick( m_txn
, &rec
);
2681 void wxMacMLTEClassicControl::MacControlUserPaneIdleProc()
2683 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2684 if ( textctrl
== NULL
)
2687 if (textctrl
->MacIsReallyShown())
2689 if (IsControlActive(m_controlRef
))
2693 wxMacWindowClipper
clipper( textctrl
) ;
2698 if (PtInRect(mousep
, &m_txnControlBounds
))
2700 RgnHandle theRgn
= NewRgn();
2701 RectRgn(theRgn
, &m_txnControlBounds
);
2702 TXNAdjustCursor(m_txn
, theRgn
);
2709 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneKeyDownProc (wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
)
2711 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2712 if ( textctrl
== NULL
)
2713 return kControlNoPart
;
2715 wxMacWindowClipper
clipper( textctrl
) ;
2718 memset( &ev
, 0 , sizeof( ev
) ) ;
2720 ev
.modifiers
= modifiers
;
2721 ev
.message
= ((keyCode
<< 8) & keyCodeMask
) | (charCode
& charCodeMask
);
2722 TXNKeyDown( m_txn
, &ev
);
2724 return kControlEntireControl
;
2727 void wxMacMLTEClassicControl::MacControlUserPaneActivateProc(bool activating
)
2729 MacActivatePaneText( activating
);
2732 wxInt16
wxMacMLTEClassicControl::MacControlUserPaneFocusProc(wxInt16 action
)
2734 ControlPartCode focusResult
= kControlFocusNoPart
;
2736 wxTextCtrl
* textctrl
= (wxTextCtrl
*)GetControlReference( m_controlRef
);
2737 if ( textctrl
== NULL
)
2740 wxMacWindowClipper
clipper( textctrl
) ;
2742 ControlRef controlFocus
= NULL
;
2743 GetKeyboardFocus( m_txnWindow
, &controlFocus
) ;
2744 bool wasFocused
= ( controlFocus
== m_controlRef
) ;
2748 case kControlFocusPrevPart
:
2749 case kControlFocusNextPart
:
2750 MacFocusPaneText( !wasFocused
);
2751 focusResult
= (!wasFocused
? (ControlPartCode
) kControlEditTextPart
: (ControlPartCode
) kControlFocusNoPart
);
2754 case kControlFocusNoPart
:
2756 MacFocusPaneText( false );
2757 focusResult
= kControlFocusNoPart
;
2764 void wxMacMLTEClassicControl::MacControlUserPaneBackgroundProc( void *WXUNUSED(info
) )
2768 wxMacMLTEClassicControl::wxMacMLTEClassicControl( wxTextCtrl
*wxPeer
,
2769 const wxString
& str
,
2771 const wxSize
& size
, long style
)
2772 : wxMacMLTEControl( wxPeer
)
2774 m_font
= wxPeer
->GetFont() ;
2775 m_windowStyle
= style
;
2776 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
2779 kControlSupportsEmbedding
| kControlSupportsFocus
| kControlWantsIdle
2780 | kControlWantsActivate
| kControlHandlesTracking
2781 // | kControlHasSpecialBackground
2782 | kControlGetsFocusOnClick
| kControlSupportsLiveFeedback
;
2784 OSStatus err
= ::CreateUserPaneControl(
2785 MAC_WXHWND(wxPeer
->GetParent()->MacGetTopLevelWindowRef()),
2786 &bounds
, featureSet
, &m_controlRef
);
2787 verify_noerr( err
);
2791 AdjustCreationAttributes( *wxWHITE
, true ) ;
2793 MacSetObjectVisibility( wxPeer
->MacIsReallyShown() ) ;
2797 wxMacConvertNewlines10To13( &st
) ;
2798 wxMacWindowClipper
clipper( m_peer
) ;
2799 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
2800 TXNSetSelection( m_txn
, 0, 0 ) ;
2804 wxMacMLTEClassicControl::~wxMacMLTEClassicControl()
2806 TXNDeleteObject( m_txn
);
2810 void wxMacMLTEClassicControl::VisibilityChanged(bool shown
)
2812 MacSetObjectVisibility( shown
) ;
2813 wxMacControl::VisibilityChanged( shown
) ;
2816 void wxMacMLTEClassicControl::SuperChangedPosition()
2818 MacUpdatePosition() ;
2819 wxMacControl::SuperChangedPosition() ;
2822 #ifdef __WXMAC_OSX__
2824 ControlUserPaneDrawUPP gTPDrawProc
= NULL
;
2825 ControlUserPaneHitTestUPP gTPHitProc
= NULL
;
2826 ControlUserPaneTrackingUPP gTPTrackProc
= NULL
;
2827 ControlUserPaneIdleUPP gTPIdleProc
= NULL
;
2828 ControlUserPaneKeyDownUPP gTPKeyProc
= NULL
;
2829 ControlUserPaneActivateUPP gTPActivateProc
= NULL
;
2830 ControlUserPaneFocusUPP gTPFocusProc
= NULL
;
2832 static pascal void wxMacControlUserPaneDrawProc(ControlRef control
, SInt16 part
)
2834 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2835 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2837 win
->MacControlUserPaneDrawProc( part
) ;
2840 static pascal ControlPartCode
wxMacControlUserPaneHitTestProc(ControlRef control
, Point where
)
2842 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2843 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2845 return win
->MacControlUserPaneHitTestProc( where
.h
, where
.v
) ;
2847 return kControlNoPart
;
2850 static pascal ControlPartCode
wxMacControlUserPaneTrackingProc(ControlRef control
, Point startPt
, ControlActionUPP actionProc
)
2852 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2853 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2855 return win
->MacControlUserPaneTrackingProc( startPt
.h
, startPt
.v
, (void*) actionProc
) ;
2857 return kControlNoPart
;
2860 static pascal void wxMacControlUserPaneIdleProc(ControlRef control
)
2862 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2863 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2865 win
->MacControlUserPaneIdleProc() ;
2868 static pascal ControlPartCode
wxMacControlUserPaneKeyDownProc(ControlRef control
, SInt16 keyCode
, SInt16 charCode
, SInt16 modifiers
)
2870 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2871 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2873 return win
->MacControlUserPaneKeyDownProc( keyCode
, charCode
, modifiers
) ;
2875 return kControlNoPart
;
2878 static pascal void wxMacControlUserPaneActivateProc(ControlRef control
, Boolean activating
)
2880 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2881 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2883 win
->MacControlUserPaneActivateProc( activating
) ;
2886 static pascal ControlPartCode
wxMacControlUserPaneFocusProc(ControlRef control
, ControlFocusPart action
)
2888 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2889 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2891 return win
->MacControlUserPaneFocusProc( action
) ;
2893 return kControlNoPart
;
2897 static pascal void wxMacControlUserPaneBackgroundProc(ControlRef control
, ControlBackgroundPtr info
)
2899 wxTextCtrl
*textCtrl
= wxDynamicCast( wxFindControlFromMacControl(control
) , wxTextCtrl
) ;
2900 wxMacMLTEClassicControl
* win
= textCtrl
? (wxMacMLTEClassicControl
*)(textCtrl
->GetPeer()) : NULL
;
2902 win
->MacControlUserPaneBackgroundProc(info
) ;
2906 #endif // __WXMAC_OSX__
2908 // TXNRegisterScrollInfoProc
2910 OSStatus
wxMacMLTEClassicControl::DoCreate()
2913 OSStatus err
= noErr
;
2915 // set up our globals
2916 #ifdef __WXMAC_OSX__
2917 if (gTPDrawProc
== NULL
) gTPDrawProc
= NewControlUserPaneDrawUPP(wxMacControlUserPaneDrawProc
);
2918 if (gTPHitProc
== NULL
) gTPHitProc
= NewControlUserPaneHitTestUPP(wxMacControlUserPaneHitTestProc
);
2919 if (gTPTrackProc
== NULL
) gTPTrackProc
= NewControlUserPaneTrackingUPP(wxMacControlUserPaneTrackingProc
);
2920 if (gTPIdleProc
== NULL
) gTPIdleProc
= NewControlUserPaneIdleUPP(wxMacControlUserPaneIdleProc
);
2921 if (gTPKeyProc
== NULL
) gTPKeyProc
= NewControlUserPaneKeyDownUPP(wxMacControlUserPaneKeyDownProc
);
2922 if (gTPActivateProc
== NULL
) gTPActivateProc
= NewControlUserPaneActivateUPP(wxMacControlUserPaneActivateProc
);
2923 if (gTPFocusProc
== NULL
) gTPFocusProc
= NewControlUserPaneFocusUPP(wxMacControlUserPaneFocusProc
);
2925 if (gTXNScrollInfoProc
== NULL
) gTXNScrollInfoProc
= NewTXNScrollInfoUPP(TXNScrollInfoProc
) ;
2926 if (gTXNScrollActionProc
== NULL
) gTXNScrollActionProc
= NewControlActionUPP(TXNScrollActionProc
) ;
2929 // set the initial settings for our private data
2931 m_txnWindow
= GetControlOwner(m_controlRef
);
2932 m_txnPort
= (GrafPtr
) GetWindowPort(m_txnWindow
);
2934 #ifdef __WXMAC_OSX__
2935 // set up the user pane procedures
2936 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneDrawProcTag
, sizeof(gTPDrawProc
), &gTPDrawProc
);
2937 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneHitTestProcTag
, sizeof(gTPHitProc
), &gTPHitProc
);
2938 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneTrackingProcTag
, sizeof(gTPTrackProc
), &gTPTrackProc
);
2939 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneIdleProcTag
, sizeof(gTPIdleProc
), &gTPIdleProc
);
2940 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneKeyDownProcTag
, sizeof(gTPKeyProc
), &gTPKeyProc
);
2941 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneActivateProcTag
, sizeof(gTPActivateProc
), &gTPActivateProc
);
2942 SetControlData(m_controlRef
, kControlEntireControl
, kControlUserPaneFocusProcTag
, sizeof(gTPFocusProc
), &gTPFocusProc
);
2945 // calculate the rectangles used by the control
2946 UMAGetControlBoundsInWindowCoords( m_controlRef
, &bounds
);
2948 m_txnControlBounds
= bounds
;
2949 m_txnVisBounds
= bounds
;
2954 GetGWorld( &origPort
, &origDev
) ;
2955 SetPort( m_txnPort
);
2957 // create the new edit field
2958 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( m_windowStyle
);
2960 #ifdef __WXMAC_OSX__
2961 // the scrollbars are not correctly embedded but are inserted at the root:
2962 // this gives us problems as we have erratic redraws even over the structure area
2964 m_sbHorizontal
= 0 ;
2966 m_lastHorizontalValue
= 0 ;
2967 m_lastVerticalValue
= 0 ;
2969 Rect sb
= { 0 , 0 , 0 , 0 } ;
2970 if ( frameOptions
& kTXNWantVScrollBarMask
)
2972 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbVertical
);
2973 SetControlReference( m_sbVertical
, (SInt32
)this );
2974 SetControlAction( m_sbVertical
, gTXNScrollActionProc
);
2975 ShowControl( m_sbVertical
);
2976 EmbedControl( m_sbVertical
, m_controlRef
);
2977 frameOptions
&= ~kTXNWantVScrollBarMask
;
2980 if ( frameOptions
& kTXNWantHScrollBarMask
)
2982 CreateScrollBarControl( m_txnWindow
, &sb
, 0, 0, 100, 1, true, gTXNScrollActionProc
, &m_sbHorizontal
);
2983 SetControlReference( m_sbHorizontal
, (SInt32
)this );
2984 SetControlAction( m_sbHorizontal
, gTXNScrollActionProc
);
2985 ShowControl( m_sbHorizontal
);
2986 EmbedControl( m_sbHorizontal
, m_controlRef
);
2987 frameOptions
&= ~(kTXNWantHScrollBarMask
| kTXNDrawGrowIconMask
);
2993 NULL
, m_txnWindow
, &bounds
, frameOptions
,
2994 kTXNTextEditStyleFrameType
, kTXNTextensionFile
, kTXNSystemDefaultEncoding
,
2995 &m_txn
, &m_txnFrameID
, NULL
);
2996 verify_noerr( err
);
2999 TXNControlTag iControlTags
[] = { kTXNUseCarbonEvents
};
3000 TXNControlData iControlData
[] = { { (UInt32
)&cInfo
} };
3001 int toptag
= WXSIZEOF( iControlTags
) ;
3002 TXNCarbonEventInfo cInfo
;
3003 cInfo
.useCarbonEvents
= false ;
3006 cInfo
.fDictionary
= NULL
;
3008 verify_noerr( TXNSetTXNObjectControls( m_txn
, false, toptag
, iControlTags
, iControlData
) );
3011 #ifdef __WXMAC_OSX__
3012 TXNRegisterScrollInfoProc( m_txn
, gTXNScrollInfoProc
, (SInt32
)this );
3015 SetGWorld( origPort
, origDev
) ;
3021 // ----------------------------------------------------------------------------
3022 // MLTE control implementation (OSX part)
3023 // ----------------------------------------------------------------------------
3025 #if TARGET_API_MAC_OSX
3027 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
3029 // tiger multi-line textcontrols with no CR in the entire content
3030 // don't scroll automatically, so we need a hack.
3031 // This attempt only works 'before' the key (ie before CallNextEventHandler)
3032 // is processed, thus the scrolling always occurs one character too late, but
3033 // better than nothing ...
3035 static const EventTypeSpec eventList
[] =
3037 { kEventClassTextInput
, kEventTextInputUnicodeForKeyEvent
} ,
3040 static pascal OSStatus
wxMacUnicodeTextEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
3042 OSStatus result
= eventNotHandledErr
;
3043 wxMacMLTEHIViewControl
* focus
= (wxMacMLTEHIViewControl
*) data
;
3045 switch ( GetEventKind( event
) )
3047 case kEventTextInputUnicodeForKeyEvent
:
3049 if ( UMAGetSystemVersion() >= 0x1040 )
3051 TXNOffset from
, to
;
3052 TXNGetSelection( focus
->GetTXNObject() , &from
, &to
) ;
3054 TXNShowSelection( focus
->GetTXNObject() , kTXNShowStart
);
3056 result
= CallNextEventHandler(handler
,event
);
3066 static pascal OSStatus
wxMacTextControlEventHandler( EventHandlerCallRef handler
, EventRef event
, void *data
)
3068 OSStatus result
= eventNotHandledErr
;
3070 switch ( GetEventClass( event
) )
3072 case kEventClassTextInput
:
3073 result
= wxMacUnicodeTextEventHandler( handler
, event
, data
) ;
3082 DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacTextControlEventHandler
)
3084 wxMacMLTEHIViewControl::wxMacMLTEHIViewControl( wxTextCtrl
*wxPeer
,
3085 const wxString
& str
,
3087 const wxSize
& size
, long style
) : wxMacMLTEControl( wxPeer
)
3089 m_font
= wxPeer
->GetFont() ;
3090 m_windowStyle
= style
;
3091 Rect bounds
= wxMacGetBoundsForControl( wxPeer
, pos
, size
) ;
3093 wxMacConvertNewlines10To13( &st
) ;
3096 { bounds
.left
, bounds
.top
},
3097 { bounds
.right
- bounds
.left
, bounds
.bottom
- bounds
.top
} } ;
3099 m_scrollView
= NULL
;
3100 TXNFrameOptions frameOptions
= FrameOptionsFromWXStyle( style
) ;
3101 if (( frameOptions
& (kTXNWantVScrollBarMask
| kTXNWantHScrollBarMask
)) || !(frameOptions
&kTXNSingleLineOnlyMask
))
3103 if ( frameOptions
& (kTXNWantVScrollBarMask
| kTXNWantHScrollBarMask
) )
3106 (frameOptions
& kTXNWantHScrollBarMask
? kHIScrollViewOptionsHorizScroll
: 0)
3107 | (frameOptions
& kTXNWantVScrollBarMask
? kHIScrollViewOptionsVertScroll
: 0) ,
3112 HIScrollViewCreate(kHIScrollViewOptionsVertScroll
,&m_scrollView
);
3113 HIScrollViewSetScrollBarAutoHide(m_scrollView
,true);
3116 HIViewSetFrame( m_scrollView
, &hr
);
3117 HIViewSetVisible( m_scrollView
, true );
3121 HITextViewCreate( NULL
, 0, frameOptions
, &m_textView
) ;
3122 m_txn
= HITextViewGetTXNObject( m_textView
) ;
3123 HIViewSetVisible( m_textView
, true ) ;
3126 HIViewAddSubview( m_scrollView
, m_textView
) ;
3127 m_controlRef
= m_scrollView
;
3128 wxPeer
->MacInstallEventHandler( (WXWidget
) m_textView
) ;
3132 HIViewSetFrame( m_textView
, &hr
);
3133 m_controlRef
= m_textView
;
3136 AdjustCreationAttributes( *wxWHITE
, true ) ;
3138 wxMacWindowClipper
c( m_peer
) ;
3140 SetTXNData( st
, kTXNStartOffset
, kTXNEndOffset
) ;
3142 TXNSetSelection( m_txn
, 0, 0 );
3143 TXNShowSelection( m_txn
, kTXNShowStart
);
3145 InstallControlEventHandler( m_textView
, GetwxMacTextControlEventHandlerUPP(),
3146 GetEventTypeCount(eventList
), eventList
, this,
3150 wxMacMLTEHIViewControl::~wxMacMLTEHIViewControl()
3154 OSStatus
wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart
)
3156 return SetKeyboardFocus( GetControlOwner( m_textView
), m_textView
, focusPart
) ;
3159 bool wxMacMLTEHIViewControl::HasFocus() const
3161 ControlRef control
;
3162 if ( GetUserFocusWindow() == NULL
)
3165 GetKeyboardFocus( GetUserFocusWindow() , &control
) ;
3166 return control
== m_textView
;
3169 void wxMacMLTEHIViewControl::SetBackground( const wxBrush
&brush
)
3171 wxMacMLTEControl::SetBackground( brush
) ;
3174 CGColorSpaceRef rgbSpace
= CGColorSpaceCreateDeviceRGB();
3175 RGBColor col
= MAC_WXCOLORREF(brush
.GetColour().GetPixel()) ;
3177 float component
[4] ;
3178 component
[0] = col
.red
/ 65536.0 ;
3179 component
[1] = col
.green
/ 65536.0 ;
3180 component
[2] = col
.blue
/ 65536.0 ;
3181 component
[3] = 1.0 ; // alpha
3183 CGColorRef color
= CGColorCreate( rgbSpace
, component
);
3184 HITextViewSetBackgroundColor( m_textView
, color
);
3185 CGColorSpaceRelease( rgbSpace
);
3189 #endif // MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
3194 #endif // wxUSE_TEXTCTRL