]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/core/strconv_cf.cpp
Added wxMSW wxChoice::GetClassDefaultAttributes(), initially used in wxComboCtrl
[wxWidgets.git] / src / osx / core / strconv_cf.cpp
index e68d8e4ef6af34cc614ea77ffed0fd2427dc4c74..aba24024113a9daba1f4ee588dcd3fac58031de6 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        src/mac/corefoundation/strconv.cpp
+// Name:        src/osx/corefoundation/strconv.cpp
 // Purpose:     Unicode conversion classes
 // Author:      David Elliott
 // Modified by:
@@ -21,8 +21,8 @@
 
 #ifdef __DARWIN__
 
-#include "wx/mac/corefoundation/private/strconv_cf.h"
-#include "wx/mac/corefoundation/cfref.h"
+#include "wx/osx/core/private/strconv_cf.h"
+#include "wx/osx/core/cfref.h"
 
 
 // ============================================================================
@@ -33,6 +33,7 @@
  * assume ABI compatibility even within a given wxWidgets release.
  */
 
+#if wxUSE_FONTMAP
 WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf( const char* name)
 {
     wxMBConv_cf *result = new wxMBConv_cf(name);
@@ -44,6 +45,7 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf( const char* name)
     else
         return result;
 }
+#endif // wxUSE_FONTMAP
 
 WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
 {
@@ -85,7 +87,8 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
                                                 false //no BOM/external representation
                                                 ));
 
-        wxCHECK(theString != NULL, wxCONV_FAILED);
+        if ( theString == NULL )
+            return wxCONV_FAILED;
 
         /* NOTE: The string content includes the NULL element if the source string did
          * That means we have to do nothing special because the destination will have
@@ -114,8 +117,7 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
                     dstSize * sizeof(wchar_t),
                     &usedBufLen);
 
-            // charsConverted is > 0 iff conversion succeeded
-            if(charsConverted <= 0)
+            if(charsConverted < CFStringGetLength(theString))
                 return wxCONV_FAILED;
 
             /* usedBufLen is the number of bytes written, so we divide by
@@ -130,11 +132,11 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
         else
         {
             // NOTE: Includes NULL iff source did
-            /* NOTE: This is an approximation.  The eventual UTF-32 will    
+            /* NOTE: This is an approximation.  The eventual UTF-32 will
              * possibly have less elements but certainly not more.
              */
             size_t returnSize = CFStringGetLength(theString);
-    
+
             if (dstSize == 0 || dst == NULL)
             {
                 return returnSize;
@@ -144,13 +146,13 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
             // for an undersized UTF-32 destination buffer.
             CFRange fullStringRange = CFRangeMake(0, CFStringGetLength(theString));
             UniChar *szUniCharBuffer = new UniChar[fullStringRange.length];
-    
+
             CFStringGetCharacters(theString, fullStringRange, szUniCharBuffer);
-    
+
             wxMBConvUTF16 converter;
             returnSize = converter.ToWChar( dst, dstSize, (const char*)szUniCharBuffer, fullStringRange.length );
             delete [] szUniCharBuffer;
-    
+
             return returnSize;
         }
         // NOTREACHED
@@ -205,7 +207,7 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
         CFIndex usedBufLen;
 
         CFIndex charsConverted = CFStringGetBytes(
-                theString, 
+                theString,
                 CFRangeMake(0, CFStringGetLength(theString)),
                 m_encoding,
                 0, // FAIL on unconvertible characters
@@ -216,8 +218,7 @@ WXDLLIMPEXP_BASE wxMBConv* new_wxMBConv_cf(wxFontEncoding encoding)
                 &usedBufLen
             );
 
-        // charsConverted is > 0 iff conversion succeeded
-        if(charsConverted <= 0)
+        if(charsConverted < CFStringGetLength(theString) )
             return wxCONV_FAILED;
 
         return usedBufLen;