diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index bc77b99ad8..9f7d40175e 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -237,7 +237,6 @@ wxSize wxChoice::DoGetBestSize() const #endif { wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - Rect drawRect ; wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( font ) { @@ -273,7 +272,6 @@ wxSize wxChoice::DoGetBestSize() const // Add room for the popup arrow lbWidth += 2 * lbHeight ; // And just a bit more - int cy = 12 ; int cx = ::TextWidth( "X" , 0 , 1 ) ; lbWidth += cx ; diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 9460b87304..593c01c367 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -1321,8 +1321,11 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; #else TECObjectRef ec; - status = TECCreateConverter(&ec, - wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + status = TECCreateConverter(&ec, + wxApp::s_macDefaultEncodingIsPC + ? (int)kTextEncodingWindowsLatin1 + : (int)kTextEncodingMacRoman, + kTextEncodingUnicodeDefault); wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ; ByteCount byteOutLen ; @@ -1369,8 +1372,8 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, &textBefore , &textAfter, &ascent , &descent ); - drawX += sin(angle/RAD2DEG) * FixedToInt(ascent) ; - drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; + drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent)); + drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent)); status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, IntToFixed(drawX) , IntToFixed(drawY) ); wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") ); @@ -1808,7 +1811,7 @@ void wxDC::MacInstallFont() const } ; Boolean kTrue = true ; Boolean kFalse = false ; - BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; + //BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = { diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index 1739308b03..f577bbc8a1 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -363,7 +363,7 @@ void wxMenu::MacEnableMenu( bool bDoEnable ) void wxMenu::MacBeforeDisplay( bool isSubMenu ) { wxMenuItem* previousItem = NULL ; - int pos ; + size_t pos ; wxMenuItemList::Node *node; wxMenuItem *item; for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) @@ -382,7 +382,9 @@ void wxMenu::MacBeforeDisplay( bool isSubMenu ) if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId) { ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 ); - if ( GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() ) + if ( GetMenuItems().GetCount() == pos + 1 && + previousItem != NULL && + previousItem->IsSeparator() ) { ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos , kMenuItemAttrHidden, 0 ); } diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 426fa98c7a..1a0f8d5121 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -234,8 +234,8 @@ void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data ) (int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ; data->SetMinMarginBottomRight( wxPoint ( - ((double) rPaper.right - rPage.right ) * pt2mm , - ((double) rPaper.bottom - rPage.bottom ) * pt2mm ) ) ; + (wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm), + (wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ; } } } diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 92d048a228..55a05b287b 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -325,8 +325,6 @@ bool wxToolBar::Realize() node = node->GetNext(); } - int separatorSize = GetToolSize().x / 4 ; - node = m_tools.GetFirst(); while (node) { diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index 34db5c2604..dd928635f1 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -844,7 +844,7 @@ void wxTopLevelWindowMac::MacFireMouseEvent( if ( kind == mouseDown ) { - if ( timestamp - gs_lastWhen <= GetDblTime() ) + if ( timestamp - gs_lastWhen <= (long) GetDblTime() ) { if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 ) { diff --git a/src/mac/carbon/utils.cpp b/src/mac/carbon/utils.cpp index cbc92280bc..126527c1be 100644 --- a/src/mac/carbon/utils.cpp +++ b/src/mac/carbon/utils.cpp @@ -57,7 +57,7 @@ bool wxGetHostName(wxChar *buf, int maxSize) // Gets Chooser name of user by examining a System resource. const short kComputerNameID = -16413; - + short oldResFile = CurResFile() ; UseResFile(0); StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); @@ -95,7 +95,7 @@ bool wxGetUserName(wxChar *buf, int maxSize) // Gets Chooser name of user by examining a System resource. const short kChooserNameID = -16096; - + short oldResFile = CurResFile() ; UseResFile(0); StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); @@ -143,7 +143,7 @@ bool wxShell(const wxString& command) return FALSE; } -// Shutdown or reboot the PC +// Shutdown or reboot the PC bool wxShutdown(wxShutdownFlags wFlags) { // TODO @@ -159,7 +159,7 @@ long wxGetFreeMemory() void wxUsleep(unsigned long milliseconds) { clock_t start = clock() ; - do + do { YieldToAnyThread() ; } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ; @@ -182,17 +182,17 @@ void wxDebugMsg(const char *fmt ...) { va_list ap; static char buffer[512]; - + if (!wxTheApp->GetWantDebugOutput()) return ; - + va_start(ap, fmt); - + vsprintf(buffer,fmt,ap) ; strcat(buffer,";g") ; c2pstr(buffer) ; DebugStr((unsigned char*) buffer) ; - + va_end(ap); } @@ -223,9 +223,9 @@ void wxBell() int wxGetOsVersion(int *majorVsn, int *minorVsn) { long theSystem ; - + // are there x-platform conventions ? - + Gestalt(gestaltSystemVersion, &theSystem) ; if (minorVsn != NULL) { *minorVsn = (theSystem & 0xFF ) ; @@ -338,7 +338,7 @@ void wxEndBusyCursor() { wxCHECK_RET( gs_wxBusyCursorCount > 0, wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); - + if (--gs_wxBusyCursorCount == 0) { gMacStoredActiveCursor.MacInstall() ; @@ -359,7 +359,7 @@ wxString wxMacFindFolder( short vol, short vRefNum ; long dirID ; wxString strDir ; - + if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr) { FSSpec file ; @@ -382,19 +382,19 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) { if ( path.empty() ) return FALSE; - + wxString p = path ; if (p[0] == ':' ) { p = wxGetCwd() + p ; } - + int pos = p.Find(':') ; if ( pos != wxNOT_FOUND ) { p = p.Mid(1,pos) ; } - + p = p + wxT(":") ; - + Str255 volumeName ; XVolumeParam pb ; @@ -457,11 +457,11 @@ void wxDisplaySize(int *width, int *height) { BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); - - if (width != NULL) { + + if (width != NULL) { *width = screenBits.bounds.right - screenBits.bounds.left ; } - if (height != NULL) { + if (height != NULL) { *height = screenBits.bounds.bottom - screenBits.bounds.top ; } } @@ -472,10 +472,10 @@ void wxDisplaySizeMM(int *width, int *height) // on mac 72 is fixed (at least now ;-) float cvPt2Mm = 25.4 / 72; - if (width != NULL) { + if (width != NULL) { *width = int( *width * cvPt2Mm ); } - if (height != NULL) { + if (height != NULL) { *height = int( *height * cvPt2Mm ); } } @@ -488,10 +488,10 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) if (x) *x = 0; if (y) *y = 0; - if (width != NULL) { + if (width != NULL) { *width = screenBits.bounds.right - screenBits.bounds.left ; } - if (height != NULL) { + if (height != NULL) { *height = screenBits.bounds.bottom - screenBits.bounds.top ; } @@ -501,7 +501,7 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) #else mheight = LMGetMBarHeight() ; #endif - if (height != NULL) { + if (height != NULL) { *height -= mheight ; } if (y) @@ -615,27 +615,35 @@ TECObjectRef s_TECNativeCToUnicode = NULL ; TECObjectRef s_TECUnicodeToNativeC = NULL ; TECObjectRef s_TECPlatformToNativeC = NULL ; TECObjectRef s_TECNativeCToPlatform = NULL ; -void wxMacSetupConverters() +void wxMacSetupConverters() { - // if we assume errors are happening here we need low level debugging since the high level assert will use the encoders that - // are not yet setup... - + // if we assume errors are happening here we need low level debugging + // since the high level assert will use the encoders that are not yet + // setup... + const int kEncoding = wxApp::s_macDefaultEncodingIsPC + ? (int)kTextEncodingWindowsLatin1 + : (int)kTextEncodingMacRoman; + OSStatus status = noErr ; - status = TECCreateConverter(&s_TECNativeCToUnicode, - wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + status = TECCreateConverter(&s_TECNativeCToUnicode, + kEncoding, + kTextEncodingUnicodeDefault); - status = TECCreateConverter(&s_TECUnicodeToNativeC, - kTextEncodingUnicodeDefault, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + status = TECCreateConverter(&s_TECUnicodeToNativeC, + kTextEncodingUnicodeDefault, + kEncoding); if ( wxApp::s_macDefaultEncodingIsPC ) { - status = TECCreateConverter(&s_TECPlatformToNativeC, - kTextEncodingMacRoman, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + status = TECCreateConverter(&s_TECPlatformToNativeC, + kTextEncodingMacRoman, + kTextEncodingWindowsLatin1); - - status = TECCreateConverter(&s_TECNativeCToPlatform, - wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingMacRoman ); + + status = TECCreateConverter(&s_TECNativeCToPlatform, + kTextEncodingWindowsLatin1, + kTextEncodingMacRoman); } } @@ -651,7 +659,7 @@ void wxMacCleanupConverters() status = TECDisposeConverter(s_TECNativeCToPlatform); } -wxWCharBuffer wxMacStringToWString( const wxString &from ) +wxWCharBuffer wxMacStringToWString( const wxString &from ) { #if wxUSE_UNICODE wxWCharBuffer result( from.wc_str() ) ; @@ -668,7 +676,7 @@ wxWCharBuffer wxMacStringToWString( const wxString &from ) return result ; } -wxString wxMacMakeStringFromCString( const char * from , int len ) +wxString wxMacMakeStringFromCString( const char * from , int len ) { OSStatus status = noErr ; wxString result ; @@ -685,7 +693,6 @@ wxString wxMacMakeStringFromCString( const char * from , int len ) memcpy( buf , from , len ) ; else { - OSStatus status = noErr ; ByteCount byteOutLen ; ByteCount byteInLen = len ; ByteCount byteBufferLen = byteInLen ; @@ -704,7 +711,7 @@ wxString wxMacMakeStringFromCString( const char * from ) return wxMacMakeStringFromCString( from , strlen(from) ) ; } -wxCharBuffer wxMacStringToCString( const wxString &from ) +wxCharBuffer wxMacStringToCString( const wxString &from ) { #if wxUSE_UNICODE OSStatus status = noErr ; @@ -733,7 +740,7 @@ wxCharBuffer wxMacStringToCString( const wxString &from ) #endif } -void wxMacStringToPascal( const wxString&from , StringPtr to ) +void wxMacStringToPascal( const wxString&from , StringPtr to ) { wxCharBuffer buf = wxMacStringToCString( from ) ; int len = strlen(buf) ; @@ -744,31 +751,31 @@ void wxMacStringToPascal( const wxString&from , StringPtr to ) memcpy( (char*) &to[1] , buf , len ) ; } -wxString wxMacMakeStringFromPascal( ConstStringPtr from ) +wxString wxMacMakeStringFromPascal( ConstStringPtr from ) { return wxMacMakeStringFromCString( (char*) &from[1] , from[0] ) ; } -// +// // CFStringRefs (Carbon only) // #if TARGET_CARBON // converts this string into a carbon foundation string with optional pc 2 mac encoding -void wxMacCFStringHolder::Assign( const wxString &str ) +void wxMacCFStringHolder::Assign( const wxString &str ) { #if wxUSE_UNICODE - m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault, + m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault, (const unsigned short*)str.wc_str(), str.Len() ); #else m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - wxApp::s_macDefaultEncodingIsPC ? + wxApp::s_macDefaultEncodingIsPC ? kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; #endif m_release = true ; } -wxString wxMacCFStringHolder::AsString() +wxString wxMacCFStringHolder::AsString() { wxString result ; Size len = CFStringGetLength( m_cfs ) ; @@ -776,7 +783,7 @@ wxString wxMacCFStringHolder::AsString() #if wxUSE_UNICODE CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ; #else - CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? + CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; #endif buf[len] = 0 ; @@ -826,7 +833,7 @@ wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding } } -// +// // Pascal Strings // diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index bc77b99ad8..9f7d40175e 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -237,7 +237,6 @@ wxSize wxChoice::DoGetBestSize() const #endif { wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ; - Rect drawRect ; wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( font ) { @@ -273,7 +272,6 @@ wxSize wxChoice::DoGetBestSize() const // Add room for the popup arrow lbWidth += 2 * lbHeight ; // And just a bit more - int cy = 12 ; int cx = ::TextWidth( "X" , 0 , 1 ) ; lbWidth += cx ; diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 9460b87304..593c01c367 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -1321,8 +1321,11 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, &chars , (ATSUStyle*) &m_macATSUIStyle , &atsuLayout ) ; #else TECObjectRef ec; - status = TECCreateConverter(&ec, - wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + status = TECCreateConverter(&ec, + wxApp::s_macDefaultEncodingIsPC + ? (int)kTextEncodingWindowsLatin1 + : (int)kTextEncodingMacRoman, + kTextEncodingUnicodeDefault); wxASSERT_MSG( status == noErr , wxT("couldn't start converter") ) ; ByteCount byteOutLen ; @@ -1369,8 +1372,8 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, status = ::ATSUMeasureText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, &textBefore , &textAfter, &ascent , &descent ); - drawX += sin(angle/RAD2DEG) * FixedToInt(ascent) ; - drawY += cos(angle/RAD2DEG) * FixedToInt(ascent) ; + drawX += (int)(sin(angle/RAD2DEG) * FixedToInt(ascent)); + drawY += (int)(cos(angle/RAD2DEG) * FixedToInt(ascent)); status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd, IntToFixed(drawX) , IntToFixed(drawY) ); wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") ); @@ -1808,7 +1811,7 @@ void wxDC::MacInstallFont() const } ; Boolean kTrue = true ; Boolean kFalse = false ; - BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; + //BslnBaselineClass kBaselineDefault = kBSLNHangingBaseline ; ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal; ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] = { diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp index 1739308b03..f577bbc8a1 100644 --- a/src/mac/menu.cpp +++ b/src/mac/menu.cpp @@ -363,7 +363,7 @@ void wxMenu::MacEnableMenu( bool bDoEnable ) void wxMenu::MacBeforeDisplay( bool isSubMenu ) { wxMenuItem* previousItem = NULL ; - int pos ; + size_t pos ; wxMenuItemList::Node *node; wxMenuItem *item; for (pos = 0, node = GetMenuItems().GetFirst(); node; node = node->GetNext(), pos++) @@ -382,7 +382,9 @@ void wxMenu::MacBeforeDisplay( bool isSubMenu ) if ( item->GetId() == wxApp::s_macPreferencesMenuItemId || item->GetId() == wxApp::s_macExitMenuItemId) { ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos + 1, kMenuItemAttrHidden, 0 ); - if ( GetMenuItems().GetCount() == pos + 1 && previousItem != NULL && previousItem->IsSeparator() ) + if ( GetMenuItems().GetCount() == pos + 1 && + previousItem != NULL && + previousItem->IsSeparator() ) { ChangeMenuItemAttributes( MAC_WXHMENU( GetHMenu() ) , pos , kMenuItemAttrHidden, 0 ); } diff --git a/src/mac/printmac.cpp b/src/mac/printmac.cpp index 426fa98c7a..1a0f8d5121 100644 --- a/src/mac/printmac.cpp +++ b/src/mac/printmac.cpp @@ -234,8 +234,8 @@ void wxMacCarbonPrintData::TransferTo( wxPageSetupData* data ) (int)(((double) rPage.top - rPaper.top ) * pt2mm) ) ) ; data->SetMinMarginBottomRight( wxPoint ( - ((double) rPaper.right - rPage.right ) * pt2mm , - ((double) rPaper.bottom - rPage.bottom ) * pt2mm ) ) ; + (wxCoord)(((double) rPaper.right - rPage.right ) * pt2mm), + (wxCoord)(((double) rPaper.bottom - rPage.bottom ) * pt2mm)) ) ; } } } diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 92d048a228..55a05b287b 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -325,8 +325,6 @@ bool wxToolBar::Realize() node = node->GetNext(); } - int separatorSize = GetToolSize().x / 4 ; - node = m_tools.GetFirst(); while (node) { diff --git a/src/mac/toplevel.cpp b/src/mac/toplevel.cpp index 34db5c2604..dd928635f1 100644 --- a/src/mac/toplevel.cpp +++ b/src/mac/toplevel.cpp @@ -844,7 +844,7 @@ void wxTopLevelWindowMac::MacFireMouseEvent( if ( kind == mouseDown ) { - if ( timestamp - gs_lastWhen <= GetDblTime() ) + if ( timestamp - gs_lastWhen <= (long) GetDblTime() ) { if ( abs( localwhere.h - gs_lastWhere.h ) < 3 && abs( localwhere.v - gs_lastWhere.v ) < 3 ) { diff --git a/src/mac/utils.cpp b/src/mac/utils.cpp index cbc92280bc..126527c1be 100644 --- a/src/mac/utils.cpp +++ b/src/mac/utils.cpp @@ -57,7 +57,7 @@ bool wxGetHostName(wxChar *buf, int maxSize) // Gets Chooser name of user by examining a System resource. const short kComputerNameID = -16413; - + short oldResFile = CurResFile() ; UseResFile(0); StringHandle chooserName = (StringHandle)::GetString(kComputerNameID); @@ -95,7 +95,7 @@ bool wxGetUserName(wxChar *buf, int maxSize) // Gets Chooser name of user by examining a System resource. const short kChooserNameID = -16096; - + short oldResFile = CurResFile() ; UseResFile(0); StringHandle chooserName = (StringHandle)::GetString(kChooserNameID); @@ -143,7 +143,7 @@ bool wxShell(const wxString& command) return FALSE; } -// Shutdown or reboot the PC +// Shutdown or reboot the PC bool wxShutdown(wxShutdownFlags wFlags) { // TODO @@ -159,7 +159,7 @@ long wxGetFreeMemory() void wxUsleep(unsigned long milliseconds) { clock_t start = clock() ; - do + do { YieldToAnyThread() ; } while( clock() - start < milliseconds / 1000.0 * CLOCKS_PER_SEC ) ; @@ -182,17 +182,17 @@ void wxDebugMsg(const char *fmt ...) { va_list ap; static char buffer[512]; - + if (!wxTheApp->GetWantDebugOutput()) return ; - + va_start(ap, fmt); - + vsprintf(buffer,fmt,ap) ; strcat(buffer,";g") ; c2pstr(buffer) ; DebugStr((unsigned char*) buffer) ; - + va_end(ap); } @@ -223,9 +223,9 @@ void wxBell() int wxGetOsVersion(int *majorVsn, int *minorVsn) { long theSystem ; - + // are there x-platform conventions ? - + Gestalt(gestaltSystemVersion, &theSystem) ; if (minorVsn != NULL) { *minorVsn = (theSystem & 0xFF ) ; @@ -338,7 +338,7 @@ void wxEndBusyCursor() { wxCHECK_RET( gs_wxBusyCursorCount > 0, wxT("no matching wxBeginBusyCursor() for wxEndBusyCursor()") ); - + if (--gs_wxBusyCursorCount == 0) { gMacStoredActiveCursor.MacInstall() ; @@ -359,7 +359,7 @@ wxString wxMacFindFolder( short vol, short vRefNum ; long dirID ; wxString strDir ; - + if ( FindFolder( vol, folderType, createFolder, &vRefNum, &dirID) == noErr) { FSSpec file ; @@ -382,19 +382,19 @@ bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) { if ( path.empty() ) return FALSE; - + wxString p = path ; if (p[0] == ':' ) { p = wxGetCwd() + p ; } - + int pos = p.Find(':') ; if ( pos != wxNOT_FOUND ) { p = p.Mid(1,pos) ; } - + p = p + wxT(":") ; - + Str255 volumeName ; XVolumeParam pb ; @@ -457,11 +457,11 @@ void wxDisplaySize(int *width, int *height) { BitMap screenBits; GetQDGlobalsScreenBits( &screenBits ); - - if (width != NULL) { + + if (width != NULL) { *width = screenBits.bounds.right - screenBits.bounds.left ; } - if (height != NULL) { + if (height != NULL) { *height = screenBits.bounds.bottom - screenBits.bounds.top ; } } @@ -472,10 +472,10 @@ void wxDisplaySizeMM(int *width, int *height) // on mac 72 is fixed (at least now ;-) float cvPt2Mm = 25.4 / 72; - if (width != NULL) { + if (width != NULL) { *width = int( *width * cvPt2Mm ); } - if (height != NULL) { + if (height != NULL) { *height = int( *height * cvPt2Mm ); } } @@ -488,10 +488,10 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) if (x) *x = 0; if (y) *y = 0; - if (width != NULL) { + if (width != NULL) { *width = screenBits.bounds.right - screenBits.bounds.left ; } - if (height != NULL) { + if (height != NULL) { *height = screenBits.bounds.bottom - screenBits.bounds.top ; } @@ -501,7 +501,7 @@ void wxClientDisplayRect(int *x, int *y, int *width, int *height) #else mheight = LMGetMBarHeight() ; #endif - if (height != NULL) { + if (height != NULL) { *height -= mheight ; } if (y) @@ -615,27 +615,35 @@ TECObjectRef s_TECNativeCToUnicode = NULL ; TECObjectRef s_TECUnicodeToNativeC = NULL ; TECObjectRef s_TECPlatformToNativeC = NULL ; TECObjectRef s_TECNativeCToPlatform = NULL ; -void wxMacSetupConverters() +void wxMacSetupConverters() { - // if we assume errors are happening here we need low level debugging since the high level assert will use the encoders that - // are not yet setup... - + // if we assume errors are happening here we need low level debugging + // since the high level assert will use the encoders that are not yet + // setup... + const int kEncoding = wxApp::s_macDefaultEncodingIsPC + ? (int)kTextEncodingWindowsLatin1 + : (int)kTextEncodingMacRoman; + OSStatus status = noErr ; - status = TECCreateConverter(&s_TECNativeCToUnicode, - wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman, kTextEncodingUnicodeDefault); + status = TECCreateConverter(&s_TECNativeCToUnicode, + kEncoding, + kTextEncodingUnicodeDefault); - status = TECCreateConverter(&s_TECUnicodeToNativeC, - kTextEncodingUnicodeDefault, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + status = TECCreateConverter(&s_TECUnicodeToNativeC, + kTextEncodingUnicodeDefault, + kEncoding); if ( wxApp::s_macDefaultEncodingIsPC ) { - status = TECCreateConverter(&s_TECPlatformToNativeC, - kTextEncodingMacRoman, wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman); + status = TECCreateConverter(&s_TECPlatformToNativeC, + kTextEncodingMacRoman, + kTextEncodingWindowsLatin1); - - status = TECCreateConverter(&s_TECNativeCToPlatform, - wxApp::s_macDefaultEncodingIsPC ? kTextEncodingWindowsLatin1 : kTextEncodingMacRoman , kTextEncodingMacRoman ); + + status = TECCreateConverter(&s_TECNativeCToPlatform, + kTextEncodingWindowsLatin1, + kTextEncodingMacRoman); } } @@ -651,7 +659,7 @@ void wxMacCleanupConverters() status = TECDisposeConverter(s_TECNativeCToPlatform); } -wxWCharBuffer wxMacStringToWString( const wxString &from ) +wxWCharBuffer wxMacStringToWString( const wxString &from ) { #if wxUSE_UNICODE wxWCharBuffer result( from.wc_str() ) ; @@ -668,7 +676,7 @@ wxWCharBuffer wxMacStringToWString( const wxString &from ) return result ; } -wxString wxMacMakeStringFromCString( const char * from , int len ) +wxString wxMacMakeStringFromCString( const char * from , int len ) { OSStatus status = noErr ; wxString result ; @@ -685,7 +693,6 @@ wxString wxMacMakeStringFromCString( const char * from , int len ) memcpy( buf , from , len ) ; else { - OSStatus status = noErr ; ByteCount byteOutLen ; ByteCount byteInLen = len ; ByteCount byteBufferLen = byteInLen ; @@ -704,7 +711,7 @@ wxString wxMacMakeStringFromCString( const char * from ) return wxMacMakeStringFromCString( from , strlen(from) ) ; } -wxCharBuffer wxMacStringToCString( const wxString &from ) +wxCharBuffer wxMacStringToCString( const wxString &from ) { #if wxUSE_UNICODE OSStatus status = noErr ; @@ -733,7 +740,7 @@ wxCharBuffer wxMacStringToCString( const wxString &from ) #endif } -void wxMacStringToPascal( const wxString&from , StringPtr to ) +void wxMacStringToPascal( const wxString&from , StringPtr to ) { wxCharBuffer buf = wxMacStringToCString( from ) ; int len = strlen(buf) ; @@ -744,31 +751,31 @@ void wxMacStringToPascal( const wxString&from , StringPtr to ) memcpy( (char*) &to[1] , buf , len ) ; } -wxString wxMacMakeStringFromPascal( ConstStringPtr from ) +wxString wxMacMakeStringFromPascal( ConstStringPtr from ) { return wxMacMakeStringFromCString( (char*) &from[1] , from[0] ) ; } -// +// // CFStringRefs (Carbon only) // #if TARGET_CARBON // converts this string into a carbon foundation string with optional pc 2 mac encoding -void wxMacCFStringHolder::Assign( const wxString &str ) +void wxMacCFStringHolder::Assign( const wxString &str ) { #if wxUSE_UNICODE - m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault, + m_cfs = CFStringCreateWithCharacters( kCFAllocatorDefault, (const unsigned short*)str.wc_str(), str.Len() ); #else m_cfs = CFStringCreateWithCString( kCFAllocatorSystemDefault , str.c_str() , - wxApp::s_macDefaultEncodingIsPC ? + wxApp::s_macDefaultEncodingIsPC ? kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; #endif m_release = true ; } -wxString wxMacCFStringHolder::AsString() +wxString wxMacCFStringHolder::AsString() { wxString result ; Size len = CFStringGetLength( m_cfs ) ; @@ -776,7 +783,7 @@ wxString wxMacCFStringHolder::AsString() #if wxUSE_UNICODE CFStringGetCharacters( m_cfs , CFRangeMake( 0 , len ) , (UniChar*) buf ) ; #else - CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? + CFStringGetCString( m_cfs , buf , len+1 , wxApp::s_macDefaultEncodingIsPC ? kCFStringEncodingWindowsLatin1 : CFStringGetSystemEncoding() ) ; #endif buf[len] = 0 ; @@ -826,7 +833,7 @@ wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding } } -// +// // Pascal Strings //