class WXDLLEXPORT wxMacPortSaver
{
- DECLARE_NO_COPY_CLASS(wxMacPortSaver)
+ wxDECLARE_NO_COPY_CLASS(wxMacPortSaver);
public:
wxMacPortSaver( GrafPtr port );
class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
{
- DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
+ wxDECLARE_NO_COPY_CLASS(wxMacWindowClipper);
public:
wxMacWindowClipper( const wxWindow* win );
// common parts for implementations based on MLTE
-class wxMacMLTEControl : public wxMacTextControl
+class wxMacMLTEControl : public wxMacControl, public wxTextWidgetImpl
{
public :
wxMacMLTEControl( wxTextCtrl *peer ) ;
+ ~wxMacMLTEControl() {}
+
+ virtual bool CanFocus() const
+ { return true; }
virtual wxString GetStringValue() const ;
virtual void SetStringValue( const wxString &str ) ;
void AdjustCreationAttributes( const wxColour& background, bool visible ) ;
- virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle ) ;
+ virtual void SetFont( const wxFont & font, const wxColour& foreground, long windowStyle, bool ignoreBlack ) ;
virtual void SetBackgroundColour(const wxColour& col );
virtual void SetStyle( long start, long end, const wxTextAttr& style ) ;
virtual void Copy() ;
virtual void Paste() ;
virtual bool CanPaste() const ;
virtual void SetEditable( bool editable ) ;
- virtual wxTextPos GetLastPosition() const ;
+ virtual long GetLastPosition() const ;
virtual void Replace( long from, long to, const wxString &str ) ;
virtual void Remove( long from, long to ) ;
virtual void GetSelection( long* from, long* to ) const ;
const wxSize& size, long style ) ;
virtual ~wxMacMLTEHIViewControl() ;
- virtual OSStatus SetFocus( ControlFocusPart focusPart ) ;
+ virtual bool SetFocus() ;
virtual bool HasFocus() const ;
virtual void SetBackgroundColour(const wxColour& col ) ;
};
wxWidgetImplType* wxWidgetImpl::CreateTextControl( wxTextCtrl* wxpeer,
- wxWindowMac* parent,
- wxWindowID id,
+ wxWindowMac* WXUNUSED(parent),
+ wxWindowID WXUNUSED(id),
const wxString& str,
const wxPoint& pos,
const wxSize& size,
long style,
- long extraStyle)
+ long WXUNUSED(extraStyle))
{
bool forceMLTE = false ;
if ( UMAGetSystemVersion() >= 0x1050 )
forceMLTE = false;
- wxMacTextControl* peer = NULL;
+ wxMacControl* peer = NULL;
if ( !forceMLTE )
{
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacUnicodeTextControlEventHandler )
-wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) : wxMacTextControl( wxPeer )
+wxMacUnicodeTextControl::wxMacUnicodeTextControl( wxTextCtrl *wxPeer ) : wxMacControl( wxPeer )
{
}
const wxString& str,
const wxPoint& pos,
const wxSize& size, long style )
- : wxMacTextControl( wxPeer )
-{
- Create( wxPeer, str, pos, size, style );
-}
-
-bool wxMacUnicodeTextControl::Create( wxTextCtrl *wxPeer,
- const wxString& str,
- const wxPoint& pos,
- const wxSize& size, long style )
+ : wxMacControl( wxPeer )
{
m_font = wxPeer->GetFont() ;
m_windowStyle = style ;
wxString st = str ;
wxMacConvertNewlines10To13( &st ) ;
wxCFStringRef cf(st , m_font.GetEncoding()) ;
- CFStringRef cfr = cf ;
m_valueTag = kControlEditTextCFStringTag ;
- CreateControl( wxPeer, &bounds, cfr );
+ Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
+ if ( isPassword )
+ {
+ m_valueTag = kControlEditTextPasswordCFStringTag ;
+ }
+ OSStatus err = CreateEditUnicodeTextControl(
+ MAC_WXHWND(wxPeer->MacGetTopLevelWindowRef()), &bounds , cf ,
+ isPassword , NULL , &m_controlRef ) ;
+ verify_noerr( err );
if ( !(m_windowStyle & wxTE_MULTILINE) )
SetData<Boolean>( kControlEditTextPart , kControlEditTextSingleLineTag , true ) ;
+ InstallEventHandlers();
+}
+
+void wxMacUnicodeTextControl::InstallEventHandlers()
+{
::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(),
GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this,
- NULL);
-
- return true;
+ (EventHandlerRef*) &m_macTextCtrlEventHandler);
}
wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
{
+ ::RemoveEventHandler((EventHandlerRef) m_macTextCtrlEventHandler);
}
void wxMacUnicodeTextControl::VisibilityChanged(bool shown)
verify_noerr( SetData<CFStringRef>( 0, m_valueTag , cf ) ) ;
}
-void wxMacUnicodeTextControl::CreateControl( wxTextCtrl* peer, const Rect* bounds, CFStringRef cfr )
-{
- Boolean isPassword = ( m_windowStyle & wxTE_PASSWORD ) != 0 ;
- if ( isPassword )
- {
- m_valueTag = kControlEditTextPasswordCFStringTag ;
- }
- OSStatus err = CreateEditUnicodeTextControl(
- MAC_WXHWND(peer->MacGetTopLevelWindowRef()), bounds , cfr ,
- isPassword , NULL , &m_controlRef ) ;
- verify_noerr( err );
-}
-
void wxMacUnicodeTextControl::Copy()
{
SendHICommand( kHICommandCopy ) ;
} ;
wxMacMLTEControl::wxMacMLTEControl( wxTextCtrl *peer )
- : wxMacTextControl( peer )
+ : wxMacControl( peer )
{
SetNeedsFocusRect( true ) ;
}
static inline int wxConvertToTXN(int x)
{
- return wx_static_cast(int, x / 254.0 * 72 + 0.5);
+ return static_cast<int>(x / 254.0 * 72 + 0.5);
}
void wxMacMLTEControl::TXNSetAttribute( const wxTextAttr& style , long from , long to )
if ( typeAttrCount > 0 )
{
verify_noerr( TXNSetTypeAttributes( m_txn , typeAttrCount, typeAttr, from , to ) );
- relayout = true;
+ if (from != to)
+ relayout = true;
}
if ( tabs != NULL )
void wxMacMLTEControl::SetFont(const wxFont & font,
const wxColour& foreground,
- long WXUNUSED(windowStyle))
+ long WXUNUSED(windowStyle),
+ bool WXUNUSED(ignoreBlack))
{
wxMacEditHelper help( m_txn ) ;
TXNSetAttribute( wxTextAttr( foreground, wxNullColour, font ), kTXNStartOffset, kTXNEndOffset ) ;
TXNSetTXNObjectControls( m_txn, false, WXSIZEOF(tag), tag, data ) ;
}
-wxTextPos wxMacMLTEControl::GetLastPosition() const
+long wxMacMLTEControl::GetLastPosition() const
{
wxTextPos actualsize = 0 ;
Handle theText ;
+#if wxUSE_UNICODE
+ OSErr err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText, kTXNUnicodeTextData );
+ // all done
+ if ( err == noErr )
+ {
+ actualsize = GetHandleSize( theText )/sizeof(UniChar);
+ DisposeHandle( theText ) ;
+ }
+#else
OSErr err = TXNGetDataEncoded( m_txn, kTXNStartOffset, kTXNEndOffset, &theText, kTXNTextData );
// all done
actualsize = GetHandleSize( theText ) ;
DisposeHandle( theText ) ;
}
+#endif
else
{
actualsize = 0 ;
#else
wxMBConvUTF16 converter ;
ByteCount byteBufferLen = converter.WC2MB( NULL, st.wc_str(), 0 ) ;
- UniChar *unibuf = (UniChar*)malloc( byteBufferLen ) ;
- converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen ) ;
+ wxASSERT_MSG( byteBufferLen != wxCONV_FAILED,
+ _T("Conversion to UTF-16 unexpectedly failed") );
+ UniChar *unibuf = (UniChar*)malloc( byteBufferLen + 2 ) ; // 2 for NUL in UTF-16
+ converter.WC2MB( (char*)unibuf, st.wc_str(), byteBufferLen + 2 ) ;
TXNSetData( m_txn, kTXNUnicodeTextData, (void*)unibuf, byteBufferLen, start, end ) ;
free( unibuf ) ;
#endif
MAC_WXHWND(wxPeer->GetParent()->MacGetTopLevelWindowRef()),
&bounds, featureSet, &m_controlRef );
verify_noerr( err );
+ SetControlReference( m_controlRef , (URefCon) wxPeer );
DoCreate();
{
HIViewAddSubview( m_scrollView , m_textView ) ;
m_controlRef = m_scrollView ;
- wxMacControl::MacInstallEventHandler( m_textView, wxPeer ) ;
+ InstallEventHandler( (WXWidget) m_textView ) ;
}
else
{
{
}
-OSStatus wxMacMLTEHIViewControl::SetFocus( ControlFocusPart focusPart )
+bool wxMacMLTEHIViewControl::SetFocus()
{
- return SetKeyboardFocus( GetControlOwner( m_textView ), m_textView, focusPart ) ;
+ return SetKeyboardFocus( GetControlOwner( m_textView ), m_textView, kControlFocusNextPart ) == noErr ;
}
bool wxMacMLTEHIViewControl::HasFocus() const