]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/textctrl.cpp
remove semicolon from wxDECLARE_EVENT; having it there was inconsistent with other...
[wxWidgets.git] / src / osx / carbon / textctrl.cpp
index f385f45e0666e815f0648b61c98bce2e8792a9f7..bf54b621eb83527521602b5a2a9591ccf502ebe6 100644 (file)
@@ -144,7 +144,7 @@ void* wxMacMPRemoteGUICall( classtype *object , void (classtype::*function)( con
 
 class WXDLLEXPORT wxMacPortSaver
 {
-    DECLARE_NO_COPY_CLASS(wxMacPortSaver)
+    wxDECLARE_NO_COPY_CLASS(wxMacPortSaver);
 
 public:
     wxMacPortSaver( GrafPtr port );
@@ -160,7 +160,7 @@ private :
 
 class WXDLLEXPORT wxMacWindowClipper : public wxMacPortSaver
 {
-    DECLARE_NO_COPY_CLASS(wxMacWindowClipper)
+    wxDECLARE_NO_COPY_CLASS(wxMacWindowClipper);
 
 public:
     wxMacWindowClipper( const wxWindow* win );
@@ -362,13 +362,13 @@ private :
 };
 
 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 ;
 
@@ -509,11 +509,12 @@ void wxMacUnicodeTextControl::InstallEventHandlers()
 {
     ::InstallControlEventHandler( m_controlRef , GetwxMacUnicodeTextControlEventHandlerUPP(),
                                 GetEventTypeCount(unicodeTextControlEventList), unicodeTextControlEventList, this,
-                                NULL);
+                                (EventHandlerRef*) &m_macTextCtrlEventHandler);
 }
 
 wxMacUnicodeTextControl::~wxMacUnicodeTextControl()
 {
+    ::RemoveEventHandler((EventHandlerRef) m_macTextCtrlEventHandler);
 }
 
 void wxMacUnicodeTextControl::VisibilityChanged(bool shown)
@@ -950,7 +951,7 @@ void wxMacMLTEControl::SetBackgroundColour(const wxColour& col )
 
 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 )
@@ -1371,8 +1372,10 @@ void wxMacMLTEControl::SetTXNData( const wxString& st, TXNOffset start, TXNOffse
 #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