wxMac Unicode support

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2003-03-27 20:14:39 +00:00
parent 76806f5906
commit c4e41ce37a
36 changed files with 276 additions and 95 deletions

View File

@@ -991,6 +991,18 @@
# endif /* wxUSE_DYNAMIC_LOADER */ # endif /* wxUSE_DYNAMIC_LOADER */
#endif /* wxMSW */ #endif /* wxMSW */
/* wxMAC-specific dependencies */
#ifdef __WXMAC__
# if wxUSE_UNICODE
# if !TARGET_CARBON
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_UNICODE is only supported for Carbon Targets."
# else
# define wxUSE_UNICODE 0
# endif
# endif
# endif
#endif /* wxMAC */
/* wxMotif-specific dependencies */ /* wxMotif-specific dependencies */
#if defined(__WXMOTIF__) && wxUSE_NOTEBOOK && !wxUSE_TAB_DIALOG #if defined(__WXMOTIF__) && wxUSE_NOTEBOOK && !wxUSE_TAB_DIALOG
# undef wxUSE_TAB_DIALOG # undef wxUSE_TAB_DIALOG

View File

@@ -143,6 +143,9 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
#if wxUSE_UNICODE #if wxUSE_UNICODE
# define wxNEED_WX_UNISTD_H # define wxNEED_WX_UNISTD_H
#if defined(__MWERKS__) && defined(macintosh)
#include <sys/stat.h>
#endif
WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf ); WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf );
WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode ); WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode );
WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode ); WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode );

View File

@@ -18,7 +18,7 @@
#include "wx/button.h" #include "wx/button.h"
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr;
#define wxDEFAULT_BUTTON_MARGIN 4 #define wxDEFAULT_BUTTON_MARGIN 4

View File

@@ -19,7 +19,7 @@
#include "wx/control.h" #include "wx/control.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr;
// Pushbutton // Pushbutton
class WXDLLEXPORT wxButton: public wxButtonBase class WXDLLEXPORT wxButton: public wxButtonBase

View File

@@ -20,7 +20,7 @@
#include "wx/dynarray.h" #include "wx/dynarray.h"
WXDLLEXPORT_DATA(extern const char*) wxChoiceNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr;
WX_DEFINE_ARRAY( char * , wxChoiceDataArray ) ; WX_DEFINE_ARRAY( char * , wxChoiceDataArray ) ;

View File

@@ -36,7 +36,7 @@ public:
wxColour( const wxString &colourName ) wxColour( const wxString &colourName )
: m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
{ InitFromName(colourName); } { InitFromName(colourName); }
wxColour( const char *colourName ) wxColour( const wxChar *colourName )
: m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
{ InitFromName(colourName); } { InitFromName(colourName); }

View File

@@ -19,8 +19,8 @@
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/choice.h" #include "wx/choice.h"
WXDLLEXPORT_DATA(extern const char*) wxComboBoxNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString; WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
// Combobox item // Combobox item
class WXDLLEXPORT wxComboBox: public wxChoice class WXDLLEXPORT wxComboBox: public wxChoice

View File

@@ -18,7 +18,7 @@
#include "wx/panel.h" #include "wx/panel.h"
WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;

View File

@@ -22,8 +22,8 @@
* File selector * File selector
*/ */
WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr; WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr;
WXDLLEXPORT_DATA(extern const char*) wxFileSelectorDefaultWildcardStr; WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr;
class WXDLLEXPORT wxFileDialog: public wxDialog class WXDLLEXPORT wxFileDialog: public wxDialog
{ {
@@ -41,7 +41,7 @@ protected:
int m_filterIndex; int m_filterIndex;
public: public:
wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr, wxFileDialog(wxWindow *parent, const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = "", const wxString& defaultFile = "", const wxString& wildCard = wxFileSelectorDefaultWildcardStr, const wxString& defaultDir = wxEmptyString, const wxString& defaultFile = wxEmptyString, const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = 0, const wxPoint& pos = wxDefaultPosition); long style = 0, const wxPoint& pos = wxDefaultPosition);
inline void SetMessage(const wxString& message) { m_message = message; } inline void SetMessage(const wxString& message) { m_message = message; }
@@ -78,22 +78,22 @@ public:
#define wxFILE_MUST_EXIST 0x0010 #define wxFILE_MUST_EXIST 0x0010
// File selector - backward compatibility // File selector - backward compatibility
WXDLLEXPORT wxString wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL, WXDLLEXPORT wxString wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, const wxChar *default_path = NULL,
const char *default_filename = NULL, const char *default_extension = NULL, const wxChar *default_filename = NULL, const wxChar *default_extension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1); wxWindow *parent = NULL, int x = -1, int y = -1);
// An extended version of wxFileSelector // An extended version of wxFileSelector
WXDLLEXPORT wxString wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL, WXDLLEXPORT wxString wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, const wxChar *default_path = NULL,
const char *default_filename = NULL, int *indexDefaultExtension = NULL, const wxChar *default_filename = NULL, int *indexDefaultExtension = NULL,
const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0,
wxWindow *parent = NULL, int x = -1, int y = -1); wxWindow *parent = NULL, int x = -1, int y = -1);
// Generic file load dialog // Generic file load dialog
WXDLLEXPORT wxString wxLoadFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL); WXDLLEXPORT wxString wxLoadFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name = NULL, wxWindow *parent = NULL);
// Generic file save dialog // Generic file save dialog
WXDLLEXPORT wxString wxSaveFileSelector(const char *what, const char *extension, const char *default_name = NULL, wxWindow *parent = NULL); WXDLLEXPORT wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name = NULL, wxWindow *parent = NULL);
#endif #endif
// _WX_FILEDLG_H_ // _WX_FILEDLG_H_

View File

@@ -27,7 +27,7 @@ public:
, m_style(wxNORMAL) , m_style(wxNORMAL)
, m_weight(wxNORMAL) , m_weight(wxNORMAL)
, m_underlined(FALSE) , m_underlined(FALSE)
, m_faceName("Geneva") , m_faceName(wxT("Geneva"))
, m_encoding(wxFONTENCODING_DEFAULT) , m_encoding(wxFONTENCODING_DEFAULT)
, m_macFontNum(0) , m_macFontNum(0)
, m_macFontSize(0) , m_macFontSize(0)
@@ -35,7 +35,7 @@ public:
, m_macATSUFontID() , m_macATSUFontID()
{ {
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
"Geneva", wxFONTENCODING_DEFAULT); wxT("Geneva"), wxFONTENCODING_DEFAULT);
} }
wxFontRefData(const wxFontRefData& data) wxFontRefData(const wxFontRefData& data)

View File

@@ -21,8 +21,8 @@
#include "wx/accel.h" #include "wx/accel.h"
#include "wx/icon.h" #include "wx/icon.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxMenuBar;
class WXDLLEXPORT wxStatusBar; class WXDLLEXPORT wxStatusBar;

View File

@@ -18,7 +18,7 @@
#include "wx/control.h" #include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxGaugeNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxGaugeNameStr;
// Group box // Group box
class WXDLLEXPORT wxGauge: public wxGaugeBase class WXDLLEXPORT wxGauge: public wxGaugeBase

View File

@@ -69,7 +69,7 @@ public:
void SetCurrent(); void SetCurrent();
void Update(); // must be called after window drag/grows/zoom or clut change void Update(); // must be called after window drag/grows/zoom or clut change
void SetColour(const char *colour); void SetColour(const wxChar *colour);
void SwapBuffers(); void SwapBuffers();
@@ -88,15 +88,15 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow
public: public:
wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, wxGLCanvas(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette); const wxString& name = wxT("GLCanvas") , int *attribList = 0, const wxPalette& palette = wxNullPalette);
wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = "GLCanvas", const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("GLCanvas"),
int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette ); int *attribList = (int*) NULL, const wxPalette& palette = wxNullPalette );
wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1, wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = "GLCanvas", int *attribList = 0, const wxPalette& palette = wxNullPalette ); const wxString& name = wxT("GLCanvas"), int *attribList = 0, const wxPalette& palette = wxNullPalette );
~wxGLCanvas(); ~wxGLCanvas();
@@ -105,7 +105,7 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow
int *attribList, const wxPalette& palette); int *attribList, const wxPalette& palette);
void SetCurrent(); void SetCurrent();
void SetColour(const char *colour); void SetColour(const wxChar *colour);
void SwapBuffers(); void SwapBuffers();
void UpdateContext(); void UpdateContext();
void SetViewport(); void SetViewport();

View File

@@ -76,8 +76,8 @@ class WXDLLEXPORT wxICONResourceHandler: public wxBitmapHandler
public: public:
inline wxICONResourceHandler() inline wxICONResourceHandler()
{ {
m_name = "ICON resource"; m_name = wxT("ICON resource");
m_extension = ""; m_extension = wxEmptyString;
m_type = wxBITMAP_TYPE_ICON_RESOURCE; m_type = wxBITMAP_TYPE_ICON_RESOURCE;
}; };

View File

@@ -123,9 +123,9 @@ public:
protected: protected:
void MacDestroy() ; void MacDestroy() ;
void MacDelete( int n ) ; void MacDelete( int n ) ;
void MacInsert( int n , const char * text) ; void MacInsert( int n , const wxString& item) ;
void MacAppend( const char * text) ; void MacAppend( const wxString& item) ;
void MacSet( int n , const char *text ) ; void MacSet( int n , const wxString& item ) ;
void MacClear() ; void MacClear() ;
void MacSetSelection( int n , bool select ) ; void MacSetSelection( int n , bool select ) ;
int MacGetSelection() const ; int MacGetSelection() const ;

View File

@@ -20,8 +20,8 @@
#include "wx/frame.h" #include "wx/frame.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr;
class WXDLLEXPORT wxMDIClientWindow; class WXDLLEXPORT wxMDIClientWindow;
class WXDLLEXPORT wxMDIChildFrame; class WXDLLEXPORT wxMDIChildFrame;

View File

@@ -55,7 +55,7 @@ class WXDLLEXPORT wxMetafile: public wxGDIObject
: wxGDIObject() : wxGDIObject()
{ Ref(metafile); } { Ref(metafile); }
wxMetafile(const wxString& file = ""); wxMetafile(const wxString& file = wxEmptyString);
~wxMetafile(void); ~wxMetafile(void);
// After this is called, the metafile cannot be used for anything // After this is called, the metafile cannot be used for anything
@@ -84,7 +84,7 @@ class WXDLLEXPORT wxMetafileDC: public wxDC
public: public:
// Don't supply origin and extent // Don't supply origin and extent
// Supply them to wxMakeMetaFilePlaceable instead. // Supply them to wxMakeMetaFilePlaceable instead.
wxMetafileDC(const wxString& file = ""); wxMetafileDC(const wxString& file = wxEmptyString);
// Supply origin and extent (recommended). // Supply origin and extent (recommended).
// Then don't need to supply them to wxMakeMetaFilePlaceable. // Then don't need to supply them to wxMakeMetaFilePlaceable.

View File

@@ -24,7 +24,7 @@
* Message box dialog * Message box dialog
*/ */
WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr; WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog class WXDLLEXPORT wxMessageDialog: public wxDialog
{ {

View File

@@ -48,14 +48,14 @@ public:
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0, long style = 0,
const wxString& name = "notebook"); const wxString& name = wxT("notebook"));
// Create() function // Create() function
bool Create(wxWindow *parent, bool Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = 0, long style = 0,
const wxString& name = "notebook"); const wxString& name = wxT("notebook"));
// dtor // dtor
~wxNotebook(); ~wxNotebook();

View File

@@ -22,8 +22,8 @@ class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler
public: public:
inline wxPNGFileHandler(void) inline wxPNGFileHandler(void)
{ {
m_name = "PNG bitmap file"; m_name = wxT("PNG bitmap file");
m_extension = "bmp"; m_extension = wxT("bmp");
m_type = wxBITMAP_TYPE_PNG; m_type = wxBITMAP_TYPE_PNG;
}; };

View File

@@ -110,6 +110,7 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ;
// filefn.h // filefn.h
WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ; WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ;
WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ; WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ;
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ;
# ifndef __DARWIN__ # ifndef __DARWIN__
// Mac file names are POSIX (Unix style) under Darwin, so these are not needed // Mac file names are POSIX (Unix style) under Darwin, so these are not needed
WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ; WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ;
@@ -146,15 +147,106 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi
// wxMac string conversions // wxMac string conversions
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void wxMacSetupConverters() ;
void wxMacCleanupConverters() ;
void wxMacStringToPascal( const wxString&from , StringPtr to ) ;
wxString wxMacMakeStringFromPascal( ConstStringPtr from ) ;
wxCharBuffer wxMacStringToCString( const wxString &from ) ;
wxWCharBuffer wxMacStringToWString( const wxString &from ) ;
wxString wxMacMakeStringFromCString( const char * from , int len ) ;
wxString wxMacMakeStringFromCString( const char * from ) ;
#if TARGET_CARBON
class wxMacCFStringHolder
{
public:
wxMacCFStringHolder()
{
m_cfs = NULL ;
m_release = false ;
}
wxMacCFStringHolder(const wxString &str)
{
m_cfs = NULL ;
m_release = false ;
Assign( str ) ;
}
wxMacCFStringHolder(CFStringRef ref , bool release = true )
{
m_cfs = ref ;
m_release = release ;
}
~wxMacCFStringHolder()
{
Release() ;
}
wxMacCFStringHolder& operator=(const wxString& str)
{
Release() ;
Assign( str ) ;
return *this;
}
CFStringRef Detach()
{
CFStringRef retval = m_cfs ;
m_release = false ;
m_cfs = NULL ;
return retval ;
}
void Release()
{
if ( m_release && m_cfs)
CFRelease( m_cfs ) ;
m_cfs = NULL ;
}
operator CFStringRef () { return m_cfs; }
wxString AsString() ;
private:
void Assign( const wxString &str ) ;
CFStringRef m_cfs;
bool m_release ;
} ;
// CFStringRef wxMacStringToCFString( const wxString &str ) ;
// wxString wxMacMakeStringFromCFString( CFStringRef cf ) ;
#endif
#if 0
void wxMacConvertToPC( const char *from , char *to , int len ) ; void wxMacConvertToPC( const char *from , char *to , int len ) ;
void wxMacConvertFromPC( const char *from , char *to , int len ) ; void wxMacConvertFromPC( const char *from , char *to , int len ) ;
void wxMacConvertToPC( const char *from , char *to , int len ) ; void wxMacConvertToPC( const char *from , char *to , int len ) ;
wxString wxMacMakeMacStringFromPC( const wxChar * p ) ;
wxString wxMacMakePCStringFromMac( const wxChar * p ) ;
// converts this c string into a wxString with optional mac 2 pc encoding
wxString wxMacMakeStringFromMacString( const wxChar* from , bool mac2pcEncoding ) ;
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline wxString wxMacMakeStringFromMacString( const wxChar* from )
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
#if wxUSE_UNICODE
wxString wxMacMakeMacStringFromPC( const char * p ) ; wxString wxMacMakeMacStringFromPC( const char * p ) ;
wxString wxMacMakePCStringFromMac( const char * p ) ; wxString wxMacMakePCStringFromMac( const char * p ) ;
// converts this c string into a wxString with optional mac 2 pc encoding // converts this c string into a wxString with optional mac 2 pc encoding
wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ; wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ;
@@ -162,6 +254,8 @@ wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding )
inline wxString wxMacMakeStringFromMacString( const char* from ) inline wxString wxMacMakeStringFromMacString( const char* from )
{ return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; } { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; }
#endif
// converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline wxString wxMacMakeStringFromMacString( const wxString& from ) inline wxString wxMacMakeStringFromMacString( const wxString& from )
{ return wxApp::s_macDefaultEncodingIsPC ? { return wxApp::s_macDefaultEncodingIsPC ?
@@ -172,10 +266,10 @@ inline wxString wxMacMakeStringFromMacString( const wxString& from )
// //
// converts this string into a pascal with optional pc 2 mac encoding // converts this string into a pascal with optional pc 2 mac encoding
void wxMacStringToPascal( const char * from , StringPtr to , bool pc2macEncoding ) ; void wxMacStringToPascal( const wxChar * from , StringPtr to , bool pc2macEncoding ) ;
// converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC // converts this string into a pascal with pc 2 mac encoding if s_macDefaultEncodingIsPC
inline void wxMacStringToPascal( const char * from , StringPtr to ) inline void wxMacStringToPascal( const wxChar * from , StringPtr to )
{ wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; } { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; }
// converts this string into a pascal with optional mac 2 pc encoding // converts this string into a pascal with optional mac 2 pc encoding
@@ -191,14 +285,15 @@ inline wxString wxMacMakeStringFromPascal( ConstStringPtr from )
#if TARGET_CARBON #if TARGET_CARBON
// converts this string into a carbon foundation string with optional pc 2 mac encoding // converts this string into a carbon foundation string with optional pc 2 mac encoding
CFStringRef wxMacCreateCFString( const wxString &str , bool pc2macEncoding ) ; CFStringRef wxMacStringToCFString( const wxString &str , bool pc2macEncoding ) ;
// converts this string into a carbon foundation string with optional pc 2 mac encoding // converts this string into a carbon foundation string with optional pc 2 mac encoding
inline CFStringRef wxMacCreateCFString( const wxString &str ) inline CFStringRef wxMacStringToCFString( const wxString &str )
{ return wxMacCreateCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; } { return wxMacStringToCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; }
#endif //TARGET_CARBON #endif //TARGET_CARBON
#endif
#endif #endif
// _WX_PRIVATE_H_ // _WX_PRIVATE_H_

View File

@@ -18,7 +18,7 @@
#include "wx/control.h" #include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxScrollBarNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxScrollBarNameStr;
// Scrollbar item // Scrollbar item
class WXDLLEXPORT wxScrollBar: public wxControl class WXDLLEXPORT wxScrollBar: public wxControl

View File

@@ -20,7 +20,7 @@
#include "wx/slider.h" #include "wx/slider.h"
#include "wx/stattext.h" #include "wx/stattext.h"
WXDLLEXPORT_DATA(extern const char*) wxSliderNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxSliderNameStr;
// Slider // Slider
class WXDLLEXPORT wxSlider: public wxControl class WXDLLEXPORT wxSlider: public wxControl

View File

@@ -40,7 +40,7 @@ public:
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL | wxSP_ARROW_KEYS, long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
const wxString& name = "wxSpinButton") const wxString& name = wxT("wxSpinButton"))
{ {
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
} }
@@ -52,7 +52,7 @@ public:
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL | wxSP_ARROW_KEYS, long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
const wxString& name = "wxSpinButton"); const wxString& name = wxT("wxSpinButton"));
// accessors // accessors

View File

@@ -18,7 +18,7 @@
#include "wx/control.h" #include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxStaticBoxNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBoxNameStr;
// Group box // Group box
class WXDLLEXPORT wxStaticBox: public wxControl class WXDLLEXPORT wxStaticBox: public wxControl

View File

@@ -38,7 +38,7 @@ class WXDLLEXPORT wxTabCtrl: public wxControl
wxTabCtrl(); wxTabCtrl();
inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, inline wxTabCtrl(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "tabCtrl") long style = 0, const wxString& name = wxT("tabCtrl"))
{ {
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
} }
@@ -97,7 +97,7 @@ class WXDLLEXPORT wxTabCtrl: public wxControl
// Operations // Operations
bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "tabCtrl"); long style = 0, const wxString& name = wxT("tabCtrl"));
// Delete all items // Delete all items
bool DeleteAllItems(); bool DeleteAllItems();

View File

@@ -29,7 +29,7 @@ public:
// Accessors // Accessors
// Operations // Operations
bool SetIcon(const wxIcon& icon, const wxString& tooltip = ""); bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString);
bool RemoveIcon(); bool RemoveIcon();
// Overridables // Overridables

View File

@@ -18,8 +18,8 @@
#include "wx/control.h" #include "wx/control.h"
WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString; WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
// Single-line text item // Single-line text item
class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase

View File

@@ -21,7 +21,7 @@
#include "wx/tbarbase.h" #include "wx/tbarbase.h"
#include "wx/dynarray.h" #include "wx/dynarray.h"
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
class WXDLLEXPORT wxToolBar: public wxToolBarBase class WXDLLEXPORT wxToolBar: public wxToolBarBase
{ {

View File

@@ -56,7 +56,7 @@ OSStatus UMAPrClose(void *macPrintSession) ;
GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) ; GrafPtr UMAGetWindowPort( WindowRef inWindowRef ) ;
void UMADisposeWindow( WindowRef inWindowRef ) ; void UMADisposeWindow( WindowRef inWindowRef ) ;
void UMASetWTitleC( WindowRef inWindowRef , const char *title ) ; void UMASetWTitle( WindowRef inWindowRef , const wxString& title ) ;
void UMAGetWTitleC( WindowRef inWindowRef , char *title ) ; void UMAGetWTitleC( WindowRef inWindowRef , char *title ) ;
void UMADrawGrowIcon( WindowRef inWindowRef ) ; void UMADrawGrowIcon( WindowRef inWindowRef ) ;
@@ -75,6 +75,7 @@ void UMAShowControl (ControlHandle theControl
void UMAHideControl (ControlHandle theControl); void UMAHideControl (ControlHandle theControl);
void UMAActivateControl (ControlHandle inControl); void UMAActivateControl (ControlHandle inControl);
void UMADeactivateControl (ControlHandle inControl); void UMADeactivateControl (ControlHandle inControl);
void UMASetControlTitle( ControlHandle inControl , const wxString& title ) ;
void UMAMoveControl( ControlHandle inControl , short x , short y ) ; void UMAMoveControl( ControlHandle inControl , short x , short y ) ;
void UMASizeControl( ControlHandle inControl , short x , short y ) ; void UMASizeControl( ControlHandle inControl , short x , short y ) ;

View File

@@ -146,7 +146,7 @@ WXDLLEXPORT_DATA(extern wxMBConv *) wxConvCurrent;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// filenames are multibyte on Unix and probably widechar on Windows? // filenames are multibyte on Unix and probably widechar on Windows?
#if defined(__UNIX__) || defined(__BORLANDC__) #if defined(__UNIX__) || defined(__BORLANDC__) || defined(__WXMAC__ )
#define wxMBFILES 1 #define wxMBFILES 1
#else #else
#define wxMBFILES 0 #define wxMBFILES 0

View File

@@ -434,7 +434,70 @@
#define wxNEED_WX_STDIO_H #define wxNEED_WX_STDIO_H
#define wxNEED_WX_STDLIB_H #define wxNEED_WX_STDLIB_H
#define wxNEED_WX_TIME_H #define wxNEED_WX_TIME_H
#else // !glibc #elif defined(__MWERKS__) && defined(macintosh)
// ctype.h functions (wctype.h)
#define wxIsalnum iswalnum
#define wxIsalpha iswalpha
#define wxIsctrl iswcntrl
#define wxIsdigit iswdigit
#define wxIsgraph iswgraph
#define wxIslower iswlower
#define wxIsprint iswprint
#define wxIspunct iswpunct
#define wxIsspace iswspace
#define wxIsupper iswupper
#define wxIsxdigit iswxdigit
#define wxTolower towlower
#define wxToupper towupper
// string.h functions (wchar.h)
#define wxStrcat wcscat
#define wxStrchr wcschr
#define wxStrcmp wcscmp
#define wxStrcoll wcscoll
#define wxStrcpy wcscpy
#define wxStrcspn wcscspn
#define wxStrlen_ wxWcslen // wxStrlen_() is used in wxStrlen()
#define wxStrncat wcsncat
#define wxStrncmp wcsncmp
#define wxStrncpy wcsncpy
#define wxStrpbrk wcspbrk
#define wxStrrchr wcsrchr
#define wxStrspn wcsspn
#define wxStrstr wcsstr
#define wxStrtod wcstod
#define wxStrtol wcstol
#define wxStrtoul wcstoul
#define wxStrxfrm wcsxfrm
#define wxFgetc fgetwc
#define wxFgetchar fgetwchar
#define wxFgets fgetws
#define wxFputc fputwc
#define wxFputchar fputwchar
#define wxGetc getwc
#define wxGetchar getwchar
#define wxGets getws
#define wxUngetc ungetwc
#define wxNEED_FPUTWC
#include <stdio.h>
int wxFputs(const wxChar *ch, FILE *stream);
int wxPutc(wxChar ch, FILE *stream);
#define wxPuts(ws) wxFputs(ws, stdout)
#define wxPutchar(wch) wxPutc(wch, stdout)
// we need %s to %ls conversion for printf and scanf etc
#define wxNEED_PRINTF_CONVERSION
// glibc doesn't have wide char equivalents of the other stuff so
// use our own versions
#define wxNEED_WX_STDIO_H
#define wxNEED_WX_STDLIB_H
#define wxNEED_WX_TIME_H
#else // !metrowerks for apple
#error "Please define wide character functions for your environment" #error "Please define wide character functions for your environment"
#endif #endif
#else // ASCII #else // ASCII
@@ -813,6 +876,9 @@ WXDLLEXPORT int wxSystem(const wxChar *psz);
// time.h functions // time.h functions
#ifdef wxNEED_WX_TIME_H #ifdef wxNEED_WX_TIME_H
#if defined(__MWERKS__) && defined(macintosh)
#include <time.h>
#endif
WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max,
const wxChar *fmt, const struct tm *tm); const wxChar *fmt, const struct tm *tm);
#endif // wxNEED_WX_TIME_H #endif // wxNEED_WX_TIME_H

View File

@@ -310,12 +310,8 @@ void *wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name, bool *su
CFragSymbolClass symClass; CFragSymbolClass symClass;
Str255 symName; Str255 symName;
#if TARGET_CARBON wxMacStringToPascal( name.c_str() , symName ) ;
c2pstrcpy( (StringPtr) symName, name );
#else
strcpy( (char *) symName, name );
c2pstr( (char *) symName );
#endif
if( FindSymbol( ((CFragConnectionID)dllHandle), symName, &symAddress, &symClass ) == noErr ) if( FindSymbol( ((CFragConnectionID)dllHandle), symName, &symAddress, &symClass ) == noErr )
symbol = (void *)symAddress; symbol = (void *)symAddress;

View File

@@ -201,7 +201,7 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
{ {
// if bOverwrite we create a new file or truncate the existing one, // if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists // otherwise we only create the new file and fail if it already exists
#if defined(__WXMAC__) && !defined(__UNIX__) #if defined(__WXMAC__) && !defined(__UNIX__) && !wxUSE_UNICODE
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace // Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
// int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access); // int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat( szFileName , accessMode); int fd = creat( szFileName , accessMode);

View File

@@ -331,7 +331,7 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile)
if ( wxStrchr(szFile, wxT('.')) == NULL ) if ( wxStrchr(szFile, wxT('.')) == NULL )
#if defined( __WXMAC__ ) #if defined( __WXMAC__ )
str << " Preferences"; str << wxT(" Preferences") ;
#elif defined( __UNIX__ ) #elif defined( __UNIX__ )
str << wxT(".conf"); str << wxT(".conf");
#else // Windows #else // Windows
@@ -364,7 +364,7 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile)
#endif #endif
#ifdef __WXMAC__ #ifdef __WXMAC__
str << " Preferences"; str << wxT(" Preferences") ;
#endif #endif
return str; return str;

View File

@@ -63,6 +63,7 @@
#include <stat.h> #include <stat.h>
#include <unistd.h> #include <unistd.h>
#include <unix.h> #include <unix.h>
#include <fcntl.h>
#endif #endif
#ifdef __UNIX__ #ifdef __UNIX__
@@ -935,7 +936,7 @@ wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
(*myPath)[length-1] = 0 ; (*myPath)[length-1] = 0 ;
// create path string for return value // create path string for return value
wxString result( (char*) *myPath ) ; wxString result = wxMacMakeStringFromCString( *myPath ) ;
// free allocated handle // free allocated handle
::HUnlock( myPath ) ; ::HUnlock( myPath ) ;
@@ -948,7 +949,8 @@ wxString wxMacFSSpec2MacFilename( const FSSpec *spec )
// Mac file names are POSIX (Unix style) under Darwin // Mac file names are POSIX (Unix style) under Darwin
// therefore the conversion functions below are not needed // therefore the conversion functions below are not needed
static char sMacFileNameConversion[ 1000 ] ; static wxChar sMacFileNameConversion[ 1000 ] ;
static char scMacFileNameConversion[ 1000 ] ;
#endif #endif
void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
@@ -965,10 +967,10 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
if ( strchr( path , ':' ) == NULL ) if ( strchr( path , ':' ) == NULL )
{ {
// try whether it is a volume / or a mounted volume // try whether it is a volume / or a mounted volume
strncpy( sMacFileNameConversion , path , 1000 ) ; strncpy( scMacFileNameConversion , path , 1000 ) ;
sMacFileNameConversion[998] = 0 ; scMacFileNameConversion[998] = 0 ;
strcat( sMacFileNameConversion , ":" ) ; strcat( scMacFileNameConversion , ":" ) ;
err = FSpLocationFromFullPath( strlen(sMacFileNameConversion) , sMacFileNameConversion , spec ) ; err = FSpLocationFromFullPath( strlen(scMacFileNameConversion) , scMacFileNameConversion , spec ) ;
} }
else else
{ {
@@ -977,15 +979,22 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec )
#endif #endif
} }
#if wxUSE_UNICODE
WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec )
{
return wxMacFilename2FSSpec( wxMacStringToCString( wxString( path ) ) , spec ) ;
}
#endif
#ifndef __DARWIN__ #ifndef __DARWIN__
wxString wxMac2UnixFilename (const char *str) wxString wxMac2UnixFilename (const wxChar *str)
{ {
char *s = sMacFileNameConversion ; wxChar *s = sMacFileNameConversion ;
strcpy( s , str ) ; wxStrcpy( s , str ) ;
if (s) if (s)
{ {
memmove( s+1 , s ,strlen( s ) + 1) ; memmove( s+1 , s ,wxStrlen( s ) + 1 * sizeof(wxChar)) ;
if ( *s == ':' ) if ( *s == ':' )
*s = '.' ; *s = '.' ;
else else
@@ -1003,25 +1012,25 @@ wxString wxMac2UnixFilename (const char *str)
return wxString(sMacFileNameConversion) ; return wxString(sMacFileNameConversion) ;
} }
wxString wxUnix2MacFilename (const char *str) wxString wxUnix2MacFilename (const wxChar *str)
{ {
char *s = sMacFileNameConversion ; wxChar *s = sMacFileNameConversion ;
strcpy( s , str ) ; wxStrcpy( s , str ) ;
if (s) if (s)
{ {
if ( *s == '.' ) if ( *s == '.' )
{ {
// relative path , since it goes on with slash which is translated to a : // relative path , since it goes on with slash which is translated to a :
memmove( s , s+1 ,strlen( s ) ) ; memmove( s , s+1 ,wxStrlen( s ) * sizeof(wxChar)) ;
} }
else if ( *s == '/' ) else if ( *s == '/' )
{ {
// absolute path -> on mac just start with the drive name // absolute path -> on mac just start with the drive name
memmove( s , s+1 ,strlen( s ) ) ; memmove( s , s+1 ,wxStrlen( s ) * sizeof(wxChar) ) ;
} }
else else
{ {
wxASSERT_MSG( 1 , "unkown path beginning" ) ; wxASSERT_MSG( 1 , wxT("unkown path beginning") ) ;
} }
while (*s) while (*s)
{ {
@@ -1031,7 +1040,7 @@ wxString wxUnix2MacFilename (const char *str)
if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) ) if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
{ {
*s = ':'; *s = ':';
memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ; memmove( s+1 , s+3 ,(wxStrlen( s+3 ) + 1)*sizeof(wxChar) ) ;
} }
else else
*s = ':'; *s = ':';
@@ -1255,6 +1264,8 @@ bool wxRemoveFile(const wxString& file)
|| defined(__WATCOMC__) \ || defined(__WATCOMC__) \
|| defined(__GNUWIN32__) || defined(__GNUWIN32__)
int res = wxRemove(file); int res = wxRemove(file);
#elif defined(__WXMAC__)
int res = unlink(wxFNCONV(file));
#else #else
int res = unlink(OS_FILENAME(file)); int res = unlink(OS_FILENAME(file));
#endif #endif
@@ -1265,7 +1276,7 @@ bool wxRemoveFile(const wxString& file)
bool wxMkdir(const wxString& dir, int perm) bool wxMkdir(const wxString& dir, int perm)
{ {
#if defined(__WXMAC__) && !defined(__UNIX__) #if defined(__WXMAC__) && !defined(__UNIX__)
return (mkdir( dir , 0 ) == 0); return (mkdir( wxFNCONV(dir) , 0 ) == 0);
#else // !Mac #else // !Mac
const wxChar *dirname = dir.c_str(); const wxChar *dirname = dir.c_str();
@@ -1497,10 +1508,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
cwdSpec.parID = pb.ioFCBParID; cwdSpec.parID = pb.ioFCBParID;
cwdSpec.name[0] = 0 ; cwdSpec.name[0] = 0 ;
wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ; wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ;
wxStrcpy( buf , res ) ;
strcpy( cbuf , res ) ;
cbuf[res.length()]=0 ;
ok = TRUE; ok = TRUE;
} }
else else
@@ -1518,7 +1526,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz)
ok = getcwd(cbuf, sz) != NULL; ok = getcwd(cbuf, sz) != NULL;
#endif // platform #endif // platform
#if wxUSE_UNICODE #if wxUSE_UNICODE && !defined(__WXMAC__)
// finally convert the result to Unicode if needed // finally convert the result to Unicode if needed
wxConvFile.MB2WC(buf, cbuf, sz); wxConvFile.MB2WC(buf, cbuf, sz);
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE