]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/utils.cpp
compilation fix for yet another broken version of mingw (ENSESSION_LOGOFF not defined)
[wxWidgets.git] / src / mac / carbon / utils.cpp
index 014225901ca9f2972b2c5564070a39c8ddad2be0..cbc92280bc90e3dc760e8534cb36d8b945072112 100644 (file)
@@ -458,8 +458,12 @@ void wxDisplaySize(int *width, int *height)
     BitMap screenBits;
     GetQDGlobalsScreenBits( &screenBits );
     
-    *width = screenBits.bounds.right - screenBits.bounds.left  ;
-    *height = screenBits.bounds.bottom - screenBits.bounds.top ;
+    if (width != NULL) { 
+        *width = screenBits.bounds.right - screenBits.bounds.left  ;
+    }
+    if (height != NULL) { 
+        *height = screenBits.bounds.bottom - screenBits.bounds.top ;
+    }
 }
 
 void wxDisplaySizeMM(int *width, int *height)
@@ -467,8 +471,13 @@ void wxDisplaySizeMM(int *width, int *height)
     wxDisplaySize(width, height);
     // on mac 72 is fixed (at least now ;-)
     float cvPt2Mm = 25.4 / 72;
-    *width = int( *width * cvPt2Mm );
-    *height = int( *height * cvPt2Mm );
+
+    if (width != NULL) { 
+        *width = int( *width * cvPt2Mm );
+    }
+    if (height != NULL) { 
+        *height = int( *height * cvPt2Mm );
+    }
 }
 
 void wxClientDisplayRect(int *x, int *y, int *width, int *height)
@@ -479,8 +488,12 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
     if (x) *x = 0;
     if (y) *y = 0;
 
-    *width = screenBits.bounds.right - screenBits.bounds.left  ;
-    *height = screenBits.bounds.bottom - screenBits.bounds.top ;
+    if (width != NULL) { 
+        *width = screenBits.bounds.right - screenBits.bounds.left  ;
+    }
+    if (height != NULL) { 
+        *height = screenBits.bounds.bottom - screenBits.bounds.top ;
+    }
 
     SInt16 mheight ;
 #if TARGET_CARBON
@@ -488,8 +501,10 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height)
 #else
     mheight = LMGetMBarHeight() ;
 #endif
-    *height -= mheight ;
-    if ( y )
+    if (height != NULL) { 
+        *height -= mheight ;
+    }
+    if (y)
         *y = mheight ;
 }
 
@@ -598,8 +613,8 @@ void wxMacConvertToPC( const char *from , char *to , int len )
 
 TECObjectRef s_TECNativeCToUnicode = NULL ;
 TECObjectRef s_TECUnicodeToNativeC = NULL ;
-TECObjectRef s_TECPCToNativeC = NULL ;
-TECObjectRef s_TECNativeCToPC = NULL ;
+TECObjectRef s_TECPlatformToNativeC = NULL ;
+TECObjectRef s_TECNativeCToPlatform = NULL ;
 void wxMacSetupConverters() 
 {
     // if we assume errors are happening here we need low level debugging since the high level assert will use the encoders that 
@@ -613,14 +628,14 @@ void wxMacSetupConverters()
     status = TECCreateConverter(&s_TECUnicodeToNativeC, 
        kTextEncodingUnicodeDefault, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman);
 
-    if ( !wxApp::s_macDefaultEncodingIsPC )
+    if ( wxApp::s_macDefaultEncodingIsPC )
     {
-        status = TECCreateConverter(&s_TECPCToNativeC, 
-               kTextEncodingWindowsLatin1, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman);
+        status = TECCreateConverter(&s_TECPlatformToNativeC, 
+               kTextEncodingMacRoman, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman);
 
                
-        status = TECCreateConverter(&s_TECNativeCToPC
-               wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingWindowsLatin1 );
+        status = TECCreateConverter(&s_TECNativeCToPlatform
+               wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingMacRoman );
     }
 }
 
@@ -631,9 +646,9 @@ void wxMacCleanupConverters()
 
     status = TECDisposeConverter(s_TECUnicodeToNativeC);
 
-    status = TECDisposeConverter(s_TECPCToNativeC);
+    status = TECDisposeConverter(s_TECPlatformToNativeC);
 
-    status = TECDisposeConverter(s_TECNativeCToPC);
+    status = TECDisposeConverter(s_TECNativeCToPlatform);
 }
 
 wxWCharBuffer wxMacStringToWString( const wxString &from ) 
@@ -666,7 +681,7 @@ wxString wxMacMakeStringFromCString( const char * from , int len )
     status = TECConvertText(s_TECNativeCToUnicode, (ConstTextPtr)from , byteInLen, &byteInLen,
         (TextPtr)buf, byteBufferLen, &byteOutLen);
 #else
-    if ( wxApp::s_macDefaultEncodingIsPC )
+    if ( !wxApp::s_macDefaultEncodingIsPC )
         memcpy( buf , from , len ) ;
     else
     {
@@ -675,7 +690,7 @@ wxString wxMacMakeStringFromCString( const char * from , int len )
         ByteCount byteInLen = len ;
         ByteCount byteBufferLen = byteInLen ;
 
-        status = TECConvertText(s_TECNativeCToPC, (ConstTextPtr)from , byteInLen, &byteInLen,
+        status = TECConvertText(s_TECPlatformToNativeC, (ConstTextPtr)from , byteInLen, &byteInLen,
             (TextPtr)buf, byteBufferLen, &byteOutLen);
     }
 #endif
@@ -701,7 +716,7 @@ wxCharBuffer wxMacStringToCString( const wxString &from )
         (TextPtr)result.data(), byteBufferLen, &byteOutLen);
     return result ;
 #else
-    if ( wxApp::s_macDefaultEncodingIsPC )
+    if ( !wxApp::s_macDefaultEncodingIsPC )
         return wxCharBuffer( from.c_str() ) ;
     else
     {
@@ -711,7 +726,7 @@ wxCharBuffer wxMacStringToCString( const wxString &from )
         ByteCount byteInLen = from.Length() ;
         ByteCount byteBufferLen = byteInLen ;
 
-        status = TECConvertText(s_TECPCToNativeC, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen,
+        status = TECConvertText(s_TECNativeCToPlatform, (ConstTextPtr)from.c_str() , byteInLen, &byteInLen,
             (TextPtr)result.data(), byteBufferLen, &byteOutLen);
         return result ;
     }
@@ -761,7 +776,7 @@ wxString wxMacCFStringHolder::AsString()
 #if wxUSE_UNICODE
     CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
 #else
-    CFStringGetCString( m_cfs , buf , len+1 , s_macDefaultEncodingIsPC ? 
+    CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? 
         kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ;
 #endif
     buf[len] = 0 ;