added a few encoding convenience methods for pc-mac encoding and string handling, put message box buttons under translation, too
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
211cc8dc90
commit
3d2791f12c
@ -170,6 +170,27 @@ void wxMacConvertToPC( char * p ) ;
|
||||
void wxMacConvertToPC( unsigned char *p ) ;
|
||||
wxString wxMacMakePCStringFromMac( const char * p ) ;
|
||||
|
||||
// converts this string into a pascal with optional pc 2 mac encoding
|
||||
void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding ) ;
|
||||
|
||||
// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
||||
inline void wxMacStringToPascal( const char * from , StringPtr to )
|
||||
{ wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
|
||||
|
||||
// converts this string into a pascal with optional mac 2 pc encoding
|
||||
wxString wxMacMakeStringFromPascal( StringPtr from , bool mac2pcEncoding ) ;
|
||||
|
||||
// converts this pascal string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
||||
inline wxString wxMacMakeStringFromPascal( StringPtr from )
|
||||
{ return wxMacMakeStringFromPascal( from , wxApp::s_macDefaultEncodingIsPC ) ; }
|
||||
|
||||
// converts this c string into a wxString with optional mac 2 pc encoding
|
||||
wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
|
||||
|
||||
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
|
||||
inline wxString wxMacMakeStringFromMacString( const char* from )
|
||||
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
|
||||
|
||||
#endif
|
||||
// _WX_APP_H_
|
||||
|
||||
|
@ -89,8 +89,6 @@ wxWindow* wxApp::s_captureWindow = NULL ;
|
||||
int wxApp::s_lastMouseDown = 0 ;
|
||||
long wxApp::sm_lastMessageTime = 0;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
|
||||
bool wxApp::s_macDefaultEncodingIsPC = true ;
|
||||
bool wxApp::s_macSupportPCMenuShortcuts = true ;
|
||||
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
|
||||
@ -343,7 +341,44 @@ wxString wxMacMakePCStringFromMac( const char * p )
|
||||
return result ;
|
||||
}
|
||||
|
||||
#endif
|
||||
wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding )
|
||||
{
|
||||
if (mac2pcEncoding)
|
||||
{
|
||||
return wxMacMakePCStringFromMac( from ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxString( from ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxMacMakeStringFromPascal( StringPtr from , bool mac2pcEncoding )
|
||||
{
|
||||
// this is safe since a pascal string can never be larger than 256 bytes
|
||||
char s[256] ;
|
||||
CopyPascalStringToC( from , s ) ;
|
||||
if (mac2pcEncoding)
|
||||
{
|
||||
return wxMacMakePCStringFromMac( s ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxString( s ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding )
|
||||
{
|
||||
if (pc2macEncoding)
|
||||
{
|
||||
CopyCStringToPascal( wxMacMakeMacStringFromPC( from ) , to ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyCStringToPascal( from , to ) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
|
@ -89,8 +89,6 @@ wxWindow* wxApp::s_captureWindow = NULL ;
|
||||
int wxApp::s_lastMouseDown = 0 ;
|
||||
long wxApp::sm_lastMessageTime = 0;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
|
||||
bool wxApp::s_macDefaultEncodingIsPC = true ;
|
||||
bool wxApp::s_macSupportPCMenuShortcuts = true ;
|
||||
long wxApp::s_macAboutMenuItemId = wxID_ABOUT ;
|
||||
@ -343,7 +341,44 @@ wxString wxMacMakePCStringFromMac( const char * p )
|
||||
return result ;
|
||||
}
|
||||
|
||||
#endif
|
||||
wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding )
|
||||
{
|
||||
if (mac2pcEncoding)
|
||||
{
|
||||
return wxMacMakePCStringFromMac( from ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxString( from ) ;
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxMacMakeStringFromPascal( StringPtr from , bool mac2pcEncoding )
|
||||
{
|
||||
// this is safe since a pascal string can never be larger than 256 bytes
|
||||
char s[256] ;
|
||||
CopyPascalStringToC( from , s ) ;
|
||||
if (mac2pcEncoding)
|
||||
{
|
||||
return wxMacMakePCStringFromMac( s ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxString( s ) ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding )
|
||||
{
|
||||
if (pc2macEncoding)
|
||||
{
|
||||
CopyCStringToPascal( wxMacMakeMacStringFromPC( from ) , to ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
CopyCStringToPascal( from , to ) ;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
||||
|
||||
short language = 0 ;
|
||||
|
||||
void wxMacConvertNewlines( const char *source , char * destination ) ;
|
||||
void wxMacConvertNewlines( const char *source , char * destination )
|
||||
{
|
||||
const char *s = source ;
|
||||
@ -73,35 +74,25 @@ int wxMessageDialog::ShowModal()
|
||||
Str255 pascalTitle ;
|
||||
Str255 pascalText ;
|
||||
char cText[256] ;
|
||||
|
||||
Str255 yesPString ;
|
||||
Str255 noPString ;
|
||||
|
||||
wxMacStringToPascal( m_caption , pascalTitle ) ;
|
||||
wxMacStringToPascal( _("Yes") , yesPString ) ;
|
||||
wxMacStringToPascal( _("No") , noPString ) ;
|
||||
|
||||
if (wxApp::s_macDefaultEncodingIsPC)
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
|
||||
#else
|
||||
strcpy( (char *) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
|
||||
c2pstr( (char *) pascalTitle ) ;
|
||||
#endif
|
||||
strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) pascalTitle , m_caption ) ;
|
||||
#else
|
||||
strcpy( (char *) pascalTitle , m_caption ) ;
|
||||
c2pstr( (char *) pascalTitle ) ;
|
||||
#endif
|
||||
strcpy( cText , m_message ) ;
|
||||
}
|
||||
|
||||
wxMacConvertNewlines( cText , cText ) ;
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) pascalText , cText ) ;
|
||||
#else
|
||||
strcpy( (char *) pascalText , cText ) ;
|
||||
c2pstr( (char *) pascalText ) ;
|
||||
#endif
|
||||
CopyCStringToPascal( cText , pascalText ) ;
|
||||
|
||||
wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ;
|
||||
|
||||
@ -193,18 +184,18 @@ int wxMessageDialog::ShowModal()
|
||||
{
|
||||
if (m_dialogStyle & wxCANCEL)
|
||||
{
|
||||
param.defaultText = "\pYes" ;
|
||||
param.defaultText = yesPString ;
|
||||
param.cancelText = (StringPtr) kAlertDefaultCancelText;
|
||||
param.otherText = "\pNo";
|
||||
param.otherText = noPString ;
|
||||
param.helpButton = false ;
|
||||
param.defaultButton = kAlertStdAlertOKButton;
|
||||
param.cancelButton = kAlertStdAlertCancelButton;
|
||||
}
|
||||
else
|
||||
{
|
||||
param.defaultText = "\pYes" ;
|
||||
param.defaultText = yesPString ;
|
||||
param.cancelText = NULL;
|
||||
param.otherText = "\pNo";
|
||||
param.otherText = noPString ;
|
||||
param.helpButton = false ;
|
||||
param.defaultButton = kAlertStdAlertOKButton;
|
||||
param.cancelButton = 0;
|
||||
|
@ -29,6 +29,7 @@ IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
||||
|
||||
short language = 0 ;
|
||||
|
||||
void wxMacConvertNewlines( const char *source , char * destination ) ;
|
||||
void wxMacConvertNewlines( const char *source , char * destination )
|
||||
{
|
||||
const char *s = source ;
|
||||
@ -73,35 +74,25 @@ int wxMessageDialog::ShowModal()
|
||||
Str255 pascalTitle ;
|
||||
Str255 pascalText ;
|
||||
char cText[256] ;
|
||||
|
||||
Str255 yesPString ;
|
||||
Str255 noPString ;
|
||||
|
||||
wxMacStringToPascal( m_caption , pascalTitle ) ;
|
||||
wxMacStringToPascal( _("Yes") , yesPString ) ;
|
||||
wxMacStringToPascal( _("No") , noPString ) ;
|
||||
|
||||
if (wxApp::s_macDefaultEncodingIsPC)
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
|
||||
#else
|
||||
strcpy( (char *) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
|
||||
c2pstr( (char *) pascalTitle ) ;
|
||||
#endif
|
||||
strcpy(cText , wxMacMakeMacStringFromPC( m_message) ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) pascalTitle , m_caption ) ;
|
||||
#else
|
||||
strcpy( (char *) pascalTitle , m_caption ) ;
|
||||
c2pstr( (char *) pascalTitle ) ;
|
||||
#endif
|
||||
strcpy( cText , m_message ) ;
|
||||
}
|
||||
|
||||
wxMacConvertNewlines( cText , cText ) ;
|
||||
#if TARGET_CARBON
|
||||
c2pstrcpy( (StringPtr) pascalText , cText ) ;
|
||||
#else
|
||||
strcpy( (char *) pascalText , cText ) ;
|
||||
c2pstr( (char *) pascalText ) ;
|
||||
#endif
|
||||
CopyCStringToPascal( cText , pascalText ) ;
|
||||
|
||||
wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ;
|
||||
|
||||
@ -193,18 +184,18 @@ int wxMessageDialog::ShowModal()
|
||||
{
|
||||
if (m_dialogStyle & wxCANCEL)
|
||||
{
|
||||
param.defaultText = "\pYes" ;
|
||||
param.defaultText = yesPString ;
|
||||
param.cancelText = (StringPtr) kAlertDefaultCancelText;
|
||||
param.otherText = "\pNo";
|
||||
param.otherText = noPString ;
|
||||
param.helpButton = false ;
|
||||
param.defaultButton = kAlertStdAlertOKButton;
|
||||
param.cancelButton = kAlertStdAlertCancelButton;
|
||||
}
|
||||
else
|
||||
{
|
||||
param.defaultText = "\pYes" ;
|
||||
param.defaultText = yesPString ;
|
||||
param.cancelText = NULL;
|
||||
param.otherText = "\pNo";
|
||||
param.otherText = noPString ;
|
||||
param.helpButton = false ;
|
||||
param.defaultButton = kAlertStdAlertOKButton;
|
||||
param.cancelButton = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user