From c4e41ce37ac7bcb43663241439cee68ebeff7ffc Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 27 Mar 2003 20:14:39 +0000 Subject: [PATCH] wxMac Unicode support git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/chkconf.h | 12 +++++ include/wx/filefn.h | 3 ++ include/wx/mac/bmpbuttn.h | 2 +- include/wx/mac/button.h | 2 +- include/wx/mac/choice.h | 2 +- include/wx/mac/colour.h | 2 +- include/wx/mac/combobox.h | 4 +- include/wx/mac/dialog.h | 2 +- include/wx/mac/filedlg.h | 22 ++++---- include/wx/mac/font.h | 4 +- include/wx/mac/frame.h | 4 +- include/wx/mac/gauge.h | 2 +- include/wx/mac/glcanvas.h | 10 ++-- include/wx/mac/icon.h | 4 +- include/wx/mac/listbox.h | 6 +-- include/wx/mac/mdi.h | 4 +- include/wx/mac/metafile.h | 4 +- include/wx/mac/msgdlg.h | 2 +- include/wx/mac/notebook.h | 4 +- include/wx/mac/pnghand.h | 4 +- include/wx/mac/private.h | 107 +++++++++++++++++++++++++++++++++++--- include/wx/mac/scrolbar.h | 2 +- include/wx/mac/slider.h | 2 +- include/wx/mac/spinbutt.h | 4 +- include/wx/mac/statbox.h | 2 +- include/wx/mac/tabctrl.h | 4 +- include/wx/mac/taskbar.h | 2 +- include/wx/mac/textctrl.h | 4 +- include/wx/mac/toolbar.h | 2 +- include/wx/mac/uma.h | 3 +- include/wx/strconv.h | 2 +- include/wx/wxchar.h | 68 +++++++++++++++++++++++- src/common/dynlib.cpp | 8 +-- src/common/file.cpp | 2 +- src/common/fileconf.cpp | 4 +- src/common/filefn.cpp | 56 +++++++++++--------- 36 files changed, 276 insertions(+), 95 deletions(-) diff --git a/include/wx/chkconf.h b/include/wx/chkconf.h index f6b3916ad2..421e34f0fb 100644 --- a/include/wx/chkconf.h +++ b/include/wx/chkconf.h @@ -991,6 +991,18 @@ # endif /* wxUSE_DYNAMIC_LOADER */ #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 */ #if defined(__WXMOTIF__) && wxUSE_NOTEBOOK && !wxUSE_TAB_DIALOG # undef wxUSE_TAB_DIALOG diff --git a/include/wx/filefn.h b/include/wx/filefn.h index 567a8d050d..c34371d988 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -143,6 +143,9 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; #if wxUSE_UNICODE # define wxNEED_WX_UNISTD_H +#if defined(__MWERKS__) && defined(macintosh) + #include +#endif WXDLLEXPORT int wxStat( const wxChar *file_name, wxStructStat *buf ); WXDLLEXPORT int wxAccess( const wxChar *pathname, int mode ); WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode ); diff --git a/include/wx/mac/bmpbuttn.h b/include/wx/mac/bmpbuttn.h index 43f61a6b57..a9da719241 100644 --- a/include/wx/mac/bmpbuttn.h +++ b/include/wx/mac/bmpbuttn.h @@ -18,7 +18,7 @@ #include "wx/button.h" -WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr; #define wxDEFAULT_BUTTON_MARGIN 4 diff --git a/include/wx/mac/button.h b/include/wx/mac/button.h index f400b6da20..f2cebe9e94 100644 --- a/include/wx/mac/button.h +++ b/include/wx/mac/button.h @@ -19,7 +19,7 @@ #include "wx/control.h" #include "wx/gdicmn.h" -WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxButtonNameStr; // Pushbutton class WXDLLEXPORT wxButton: public wxButtonBase diff --git a/include/wx/mac/choice.h b/include/wx/mac/choice.h index 2d526e0d56..86419c148b 100644 --- a/include/wx/mac/choice.h +++ b/include/wx/mac/choice.h @@ -20,7 +20,7 @@ #include "wx/dynarray.h" -WXDLLEXPORT_DATA(extern const char*) wxChoiceNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxChoiceNameStr; WX_DEFINE_ARRAY( char * , wxChoiceDataArray ) ; diff --git a/include/wx/mac/colour.h b/include/wx/mac/colour.h index d538f5f6a4..08c8fed907 100644 --- a/include/wx/mac/colour.h +++ b/include/wx/mac/colour.h @@ -36,7 +36,7 @@ public: wxColour( const wxString &colourName ) : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) { InitFromName(colourName); } - wxColour( const char *colourName ) + wxColour( const wxChar *colourName ) : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) { InitFromName(colourName); } diff --git a/include/wx/mac/combobox.h b/include/wx/mac/combobox.h index c4f07f114b..a70341e7f6 100644 --- a/include/wx/mac/combobox.h +++ b/include/wx/mac/combobox.h @@ -19,8 +19,8 @@ #include "wx/textctrl.h" #include "wx/choice.h" -WXDLLEXPORT_DATA(extern const char*) wxComboBoxNameStr; -WXDLLEXPORT_DATA(extern const char*) wxEmptyString; +WXDLLEXPORT_DATA(extern const wxChar*) wxComboBoxNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; // Combobox item class WXDLLEXPORT wxComboBox: public wxChoice diff --git a/include/wx/mac/dialog.h b/include/wx/mac/dialog.h index 10c9a879a5..11652bd281 100644 --- a/include/wx/mac/dialog.h +++ b/include/wx/mac/dialog.h @@ -18,7 +18,7 @@ #include "wx/panel.h" -WXDLLEXPORT_DATA(extern const char*) wxDialogNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr; WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr; diff --git a/include/wx/mac/filedlg.h b/include/wx/mac/filedlg.h index 16265f9eca..1bc0428fdb 100644 --- a/include/wx/mac/filedlg.h +++ b/include/wx/mac/filedlg.h @@ -22,8 +22,8 @@ * File selector */ -WXDLLEXPORT_DATA(extern const char*) wxFileSelectorPromptStr; -WXDLLEXPORT_DATA(extern const char*) wxFileSelectorDefaultWildcardStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorPromptStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxFileSelectorDefaultWildcardStr; class WXDLLEXPORT wxFileDialog: public wxDialog { @@ -41,7 +41,7 @@ protected: int m_filterIndex; public: 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); inline void SetMessage(const wxString& message) { m_message = message; } @@ -78,22 +78,22 @@ public: #define wxFILE_MUST_EXIST 0x0010 // File selector - backward compatibility -WXDLLEXPORT wxString wxFileSelector(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL, - const char *default_filename = NULL, const char *default_extension = NULL, - const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, +WXDLLEXPORT wxString wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, const wxChar *default_path = NULL, + const wxChar *default_filename = NULL, const wxChar *default_extension = NULL, + const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, wxWindow *parent = NULL, int x = -1, int y = -1); // An extended version of wxFileSelector -WXDLLEXPORT wxString wxFileSelectorEx(const char *message = wxFileSelectorPromptStr, const char *default_path = NULL, - const char *default_filename = NULL, int *indexDefaultExtension = NULL, - const char *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, +WXDLLEXPORT wxString wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, const wxChar *default_path = NULL, + const wxChar *default_filename = NULL, int *indexDefaultExtension = NULL, + const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, int flags = 0, wxWindow *parent = NULL, int x = -1, int y = -1); // 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 -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 // _WX_FILEDLG_H_ diff --git a/include/wx/mac/font.h b/include/wx/mac/font.h index 008957bd69..a49236c636 100644 --- a/include/wx/mac/font.h +++ b/include/wx/mac/font.h @@ -27,7 +27,7 @@ public: , m_style(wxNORMAL) , m_weight(wxNORMAL) , m_underlined(FALSE) - , m_faceName("Geneva") + , m_faceName(wxT("Geneva")) , m_encoding(wxFONTENCODING_DEFAULT) , m_macFontNum(0) , m_macFontSize(0) @@ -35,7 +35,7 @@ public: , m_macATSUFontID() { Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, - "Geneva", wxFONTENCODING_DEFAULT); + wxT("Geneva"), wxFONTENCODING_DEFAULT); } wxFontRefData(const wxFontRefData& data) diff --git a/include/wx/mac/frame.h b/include/wx/mac/frame.h index 5e2a0be580..44038e6ddd 100644 --- a/include/wx/mac/frame.h +++ b/include/wx/mac/frame.h @@ -21,8 +21,8 @@ #include "wx/accel.h" #include "wx/icon.h" -WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; -WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxStatusBar; diff --git a/include/wx/mac/gauge.h b/include/wx/mac/gauge.h index 29a8b71a53..1a72c563bc 100644 --- a/include/wx/mac/gauge.h +++ b/include/wx/mac/gauge.h @@ -18,7 +18,7 @@ #include "wx/control.h" -WXDLLEXPORT_DATA(extern const char*) wxGaugeNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxGaugeNameStr; // Group box class WXDLLEXPORT wxGauge: public wxGaugeBase diff --git a/include/wx/mac/glcanvas.h b/include/wx/mac/glcanvas.h index 1f7281a7ea..a94814f6a6 100644 --- a/include/wx/mac/glcanvas.h +++ b/include/wx/mac/glcanvas.h @@ -69,7 +69,7 @@ public: void SetCurrent(); 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(); @@ -88,15 +88,15 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow public: wxGLCanvas(wxWindow *parent, wxWindowID id = -1, 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( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, 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 ); wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, wxWindowID id = -1, 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(); @@ -105,7 +105,7 @@ class WXDLLEXPORT wxGLCanvas: public wxWindow int *attribList, const wxPalette& palette); void SetCurrent(); - void SetColour(const char *colour); + void SetColour(const wxChar *colour); void SwapBuffers(); void UpdateContext(); void SetViewport(); diff --git a/include/wx/mac/icon.h b/include/wx/mac/icon.h index aa5db567ab..0993fa4305 100644 --- a/include/wx/mac/icon.h +++ b/include/wx/mac/icon.h @@ -76,8 +76,8 @@ class WXDLLEXPORT wxICONResourceHandler: public wxBitmapHandler public: inline wxICONResourceHandler() { - m_name = "ICON resource"; - m_extension = ""; + m_name = wxT("ICON resource"); + m_extension = wxEmptyString; m_type = wxBITMAP_TYPE_ICON_RESOURCE; }; diff --git a/include/wx/mac/listbox.h b/include/wx/mac/listbox.h index 0d8f38b53e..ed538622dd 100644 --- a/include/wx/mac/listbox.h +++ b/include/wx/mac/listbox.h @@ -123,9 +123,9 @@ public: protected: void MacDestroy() ; void MacDelete( int n ) ; - void MacInsert( int n , const char * text) ; - void MacAppend( const char * text) ; - void MacSet( int n , const char *text ) ; + void MacInsert( int n , const wxString& item) ; + void MacAppend( const wxString& item) ; + void MacSet( int n , const wxString& item ) ; void MacClear() ; void MacSetSelection( int n , bool select ) ; int MacGetSelection() const ; diff --git a/include/wx/mac/mdi.h b/include/wx/mac/mdi.h index a9be83cc8a..df6eb3b412 100644 --- a/include/wx/mac/mdi.h +++ b/include/wx/mac/mdi.h @@ -20,8 +20,8 @@ #include "wx/frame.h" -WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr; -WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxStatusLineNameStr; class WXDLLEXPORT wxMDIClientWindow; class WXDLLEXPORT wxMDIChildFrame; diff --git a/include/wx/mac/metafile.h b/include/wx/mac/metafile.h index 7184a9c79b..bbf8e54117 100644 --- a/include/wx/mac/metafile.h +++ b/include/wx/mac/metafile.h @@ -55,7 +55,7 @@ class WXDLLEXPORT wxMetafile: public wxGDIObject : wxGDIObject() { Ref(metafile); } - wxMetafile(const wxString& file = ""); + wxMetafile(const wxString& file = wxEmptyString); ~wxMetafile(void); // After this is called, the metafile cannot be used for anything @@ -84,7 +84,7 @@ class WXDLLEXPORT wxMetafileDC: public wxDC public: // Don't supply origin and extent // Supply them to wxMakeMetaFilePlaceable instead. - wxMetafileDC(const wxString& file = ""); + wxMetafileDC(const wxString& file = wxEmptyString); // Supply origin and extent (recommended). // Then don't need to supply them to wxMakeMetaFilePlaceable. diff --git a/include/wx/mac/msgdlg.h b/include/wx/mac/msgdlg.h index 1acd4b3ad6..63bce5cd2e 100644 --- a/include/wx/mac/msgdlg.h +++ b/include/wx/mac/msgdlg.h @@ -24,7 +24,7 @@ * Message box dialog */ -WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxMessageBoxCaptionStr; class WXDLLEXPORT wxMessageDialog: public wxDialog { diff --git a/include/wx/mac/notebook.h b/include/wx/mac/notebook.h index 316cb94f1b..332dba4918 100644 --- a/include/wx/mac/notebook.h +++ b/include/wx/mac/notebook.h @@ -48,14 +48,14 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxString& name = "notebook"); + const wxString& name = wxT("notebook")); // Create() function bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxString& name = "notebook"); + const wxString& name = wxT("notebook")); // dtor ~wxNotebook(); diff --git a/include/wx/mac/pnghand.h b/include/wx/mac/pnghand.h index 7aedd44a6d..e75688c75e 100644 --- a/include/wx/mac/pnghand.h +++ b/include/wx/mac/pnghand.h @@ -22,8 +22,8 @@ class WXDLLEXPORT wxPNGFileHandler: public wxBitmapHandler public: inline wxPNGFileHandler(void) { - m_name = "PNG bitmap file"; - m_extension = "bmp"; + m_name = wxT("PNG bitmap file"); + m_extension = wxT("bmp"); m_type = wxBITMAP_TYPE_PNG; }; diff --git a/include/wx/mac/private.h b/include/wx/mac/private.h index b69f507586..2f2c4c6345 100644 --- a/include/wx/mac/private.h +++ b/include/wx/mac/private.h @@ -110,6 +110,7 @@ bool wxMacConvertEventToRecord( EventRef event , EventRecord *rec) ; // filefn.h WXDLLEXPORT wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) ; WXDLLEXPORT void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) ; +WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) ; # ifndef __DARWIN__ // Mac file names are POSIX (Unix style) under Darwin, so these are not needed WXDLLEXPORT wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) ; @@ -146,15 +147,106 @@ void wxMacCreateBitmapButton( ControlButtonContentInfo*info , const wxBitmap& bi // 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 wxMacConvertFromPC( 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 wxMacMakePCStringFromMac( const char * p ) ; - // converts this c string into a wxString with optional mac 2 pc encoding wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) ; @@ -162,6 +254,8 @@ wxString wxMacMakeStringFromMacString( const char* from , bool mac2pcEncoding ) inline wxString wxMacMakeStringFromMacString( const char* from ) { return wxMacMakeStringFromMacString( from , wxApp::s_macDefaultEncodingIsPC ) ; } +#endif + // converts this c string into a wxString with pc 2 mac encoding if s_macDefaultEncodingIsPC inline wxString wxMacMakeStringFromMacString( const wxString& from ) { 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 -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 -inline void wxMacStringToPascal( const char * from , StringPtr to ) +inline void wxMacStringToPascal( const wxChar * from , StringPtr to ) { wxMacStringToPascal( from , to , wxApp::s_macDefaultEncodingIsPC ) ; } // converts this string into a pascal with optional mac 2 pc encoding @@ -191,14 +285,15 @@ inline wxString wxMacMakeStringFromPascal( ConstStringPtr from ) #if TARGET_CARBON // 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 -inline CFStringRef wxMacCreateCFString( const wxString &str ) - { return wxMacCreateCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; } +inline CFStringRef wxMacStringToCFString( const wxString &str ) + { return wxMacStringToCFString( str , wxApp::s_macDefaultEncodingIsPC ) ; } #endif //TARGET_CARBON +#endif #endif // _WX_PRIVATE_H_ diff --git a/include/wx/mac/scrolbar.h b/include/wx/mac/scrolbar.h index 0709b7e6c0..13c8383c8e 100644 --- a/include/wx/mac/scrolbar.h +++ b/include/wx/mac/scrolbar.h @@ -18,7 +18,7 @@ #include "wx/control.h" -WXDLLEXPORT_DATA(extern const char*) wxScrollBarNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxScrollBarNameStr; // Scrollbar item class WXDLLEXPORT wxScrollBar: public wxControl diff --git a/include/wx/mac/slider.h b/include/wx/mac/slider.h index caf89d1842..d599d32c0f 100644 --- a/include/wx/mac/slider.h +++ b/include/wx/mac/slider.h @@ -20,7 +20,7 @@ #include "wx/slider.h" #include "wx/stattext.h" -WXDLLEXPORT_DATA(extern const char*) wxSliderNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxSliderNameStr; // Slider class WXDLLEXPORT wxSlider: public wxControl diff --git a/include/wx/mac/spinbutt.h b/include/wx/mac/spinbutt.h index fb0bc70b3c..b29866c5e5 100644 --- a/include/wx/mac/spinbutt.h +++ b/include/wx/mac/spinbutt.h @@ -40,7 +40,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_VERTICAL | wxSP_ARROW_KEYS, - const wxString& name = "wxSpinButton") + const wxString& name = wxT("wxSpinButton")) { Create(parent, id, pos, size, style, name); } @@ -52,7 +52,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSP_VERTICAL | wxSP_ARROW_KEYS, - const wxString& name = "wxSpinButton"); + const wxString& name = wxT("wxSpinButton")); // accessors diff --git a/include/wx/mac/statbox.h b/include/wx/mac/statbox.h index f3a68c5fcd..8f4bb1400a 100644 --- a/include/wx/mac/statbox.h +++ b/include/wx/mac/statbox.h @@ -18,7 +18,7 @@ #include "wx/control.h" -WXDLLEXPORT_DATA(extern const char*) wxStaticBoxNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBoxNameStr; // Group box class WXDLLEXPORT wxStaticBox: public wxControl diff --git a/include/wx/mac/tabctrl.h b/include/wx/mac/tabctrl.h index 7def1aa183..a05d73e83f 100644 --- a/include/wx/mac/tabctrl.h +++ b/include/wx/mac/tabctrl.h @@ -38,7 +38,7 @@ class WXDLLEXPORT wxTabCtrl: public wxControl wxTabCtrl(); 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); } @@ -97,7 +97,7 @@ class WXDLLEXPORT wxTabCtrl: public wxControl // Operations 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 bool DeleteAllItems(); diff --git a/include/wx/mac/taskbar.h b/include/wx/mac/taskbar.h index d896d3dfa2..27b38b6b73 100644 --- a/include/wx/mac/taskbar.h +++ b/include/wx/mac/taskbar.h @@ -29,7 +29,7 @@ public: // Accessors // Operations - bool SetIcon(const wxIcon& icon, const wxString& tooltip = ""); + bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString); bool RemoveIcon(); // Overridables diff --git a/include/wx/mac/textctrl.h b/include/wx/mac/textctrl.h index df241fbdcf..9db4464db2 100644 --- a/include/wx/mac/textctrl.h +++ b/include/wx/mac/textctrl.h @@ -18,8 +18,8 @@ #include "wx/control.h" -WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr; -WXDLLEXPORT_DATA(extern const char*) wxEmptyString; +WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString; // Single-line text item class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase diff --git a/include/wx/mac/toolbar.h b/include/wx/mac/toolbar.h index fd64e322f5..c5a26d024f 100644 --- a/include/wx/mac/toolbar.h +++ b/include/wx/mac/toolbar.h @@ -21,7 +21,7 @@ #include "wx/tbarbase.h" #include "wx/dynarray.h" -WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr; +WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr; class WXDLLEXPORT wxToolBar: public wxToolBarBase { diff --git a/include/wx/mac/uma.h b/include/wx/mac/uma.h index f96f5d42a5..c59d42cd41 100644 --- a/include/wx/mac/uma.h +++ b/include/wx/mac/uma.h @@ -56,7 +56,7 @@ OSStatus UMAPrClose(void *macPrintSession) ; GrafPtr UMAGetWindowPort( 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 UMADrawGrowIcon( WindowRef inWindowRef ) ; @@ -75,6 +75,7 @@ void UMAShowControl (ControlHandle theControl void UMAHideControl (ControlHandle theControl); void UMAActivateControl (ControlHandle inControl); void UMADeactivateControl (ControlHandle inControl); +void UMASetControlTitle( ControlHandle inControl , const wxString& title ) ; void UMAMoveControl( ControlHandle inControl , short x , short y ) ; void UMASizeControl( ControlHandle inControl , short x , short y ) ; diff --git a/include/wx/strconv.h b/include/wx/strconv.h index 5fda1a1b8d..50802dc6f9 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -146,7 +146,7 @@ WXDLLEXPORT_DATA(extern wxMBConv *) wxConvCurrent; // ---------------------------------------------------------------------------- // 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 #else #define wxMBFILES 0 diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index 28b9c1dc16..384f083b09 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -434,7 +434,70 @@ #define wxNEED_WX_STDIO_H #define wxNEED_WX_STDLIB_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 + + 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" #endif #else // ASCII @@ -813,6 +876,9 @@ WXDLLEXPORT int wxSystem(const wxChar *psz); // time.h functions #ifdef wxNEED_WX_TIME_H +#if defined(__MWERKS__) && defined(macintosh) + #include +#endif WXDLLEXPORT size_t wxStrftime(wxChar *s, size_t max, const wxChar *fmt, const struct tm *tm); #endif // wxNEED_WX_TIME_H diff --git a/src/common/dynlib.cpp b/src/common/dynlib.cpp index abf8d206a8..f55c803348 100644 --- a/src/common/dynlib.cpp +++ b/src/common/dynlib.cpp @@ -310,12 +310,8 @@ void *wxDllLoader::GetSymbol(wxDllType dllHandle, const wxString &name, bool *su CFragSymbolClass symClass; Str255 symName; -#if TARGET_CARBON - c2pstrcpy( (StringPtr) symName, name ); -#else - strcpy( (char *) symName, name ); - c2pstr( (char *) symName ); -#endif + wxMacStringToPascal( name.c_str() , symName ) ; + if( FindSymbol( ((CFragConnectionID)dllHandle), symName, &symAddress, &symClass ) == noErr ) symbol = (void *)symAddress; diff --git a/src/common/file.cpp b/src/common/file.cpp index 504bdbceea..372c692461 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -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, // 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 // int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access); int fd = creat( szFileName , accessMode); diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 0ff30e5381..44a683f407 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -331,7 +331,7 @@ wxString wxFileConfig::GetGlobalFileName(const wxChar *szFile) if ( wxStrchr(szFile, wxT('.')) == NULL ) #if defined( __WXMAC__ ) - str << " Preferences"; + str << wxT(" Preferences") ; #elif defined( __UNIX__ ) str << wxT(".conf"); #else // Windows @@ -364,7 +364,7 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) #endif #ifdef __WXMAC__ - str << " Preferences"; + str << wxT(" Preferences") ; #endif return str; diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 5543a2e3ec..7f54e8896d 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -63,6 +63,7 @@ #include #include #include + #include #endif #ifdef __UNIX__ @@ -935,7 +936,7 @@ wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) (*myPath)[length-1] = 0 ; // create path string for return value - wxString result( (char*) *myPath ) ; + wxString result = wxMacMakeStringFromCString( *myPath ) ; // free allocated handle ::HUnlock( myPath ) ; @@ -948,7 +949,8 @@ wxString wxMacFSSpec2MacFilename( const FSSpec *spec ) // Mac file names are POSIX (Unix style) under Darwin // therefore the conversion functions below are not needed -static char sMacFileNameConversion[ 1000 ] ; +static wxChar sMacFileNameConversion[ 1000 ] ; +static char scMacFileNameConversion[ 1000 ] ; #endif void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) @@ -965,10 +967,10 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) if ( strchr( path , ':' ) == NULL ) { // try whether it is a volume / or a mounted volume - strncpy( sMacFileNameConversion , path , 1000 ) ; - sMacFileNameConversion[998] = 0 ; - strcat( sMacFileNameConversion , ":" ) ; - err = FSpLocationFromFullPath( strlen(sMacFileNameConversion) , sMacFileNameConversion , spec ) ; + strncpy( scMacFileNameConversion , path , 1000 ) ; + scMacFileNameConversion[998] = 0 ; + strcat( scMacFileNameConversion , ":" ) ; + err = FSpLocationFromFullPath( strlen(scMacFileNameConversion) , scMacFileNameConversion , spec ) ; } else { @@ -977,15 +979,22 @@ void wxMacFilename2FSSpec( const char *path , FSSpec *spec ) #endif } +#if wxUSE_UNICODE +WXDLLEXPORT void wxMacFilename2FSSpec( const wxChar *path , FSSpec *spec ) +{ + return wxMacFilename2FSSpec( wxMacStringToCString( wxString( path ) ) , spec ) ; +} +#endif + #ifndef __DARWIN__ -wxString wxMac2UnixFilename (const char *str) +wxString wxMac2UnixFilename (const wxChar *str) { - char *s = sMacFileNameConversion ; - strcpy( s , str ) ; + wxChar *s = sMacFileNameConversion ; + wxStrcpy( s , str ) ; if (s) { - memmove( s+1 , s ,strlen( s ) + 1) ; + memmove( s+1 , s ,wxStrlen( s ) + 1 * sizeof(wxChar)) ; if ( *s == ':' ) *s = '.' ; else @@ -1003,25 +1012,25 @@ wxString wxMac2UnixFilename (const char *str) return wxString(sMacFileNameConversion) ; } -wxString wxUnix2MacFilename (const char *str) +wxString wxUnix2MacFilename (const wxChar *str) { - char *s = sMacFileNameConversion ; - strcpy( s , str ) ; + wxChar *s = sMacFileNameConversion ; + wxStrcpy( s , str ) ; if (s) { if ( *s == '.' ) { // 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 == '/' ) { // 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 { - wxASSERT_MSG( 1 , "unkown path beginning" ) ; + wxASSERT_MSG( 1 , wxT("unkown path beginning") ) ; } while (*s) { @@ -1031,7 +1040,7 @@ wxString wxUnix2MacFilename (const char *str) if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) ) { *s = ':'; - memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ; + memmove( s+1 , s+3 ,(wxStrlen( s+3 ) + 1)*sizeof(wxChar) ) ; } else *s = ':'; @@ -1039,7 +1048,7 @@ wxString wxUnix2MacFilename (const char *str) s++ ; } } - return wxString (sMacFileNameConversion) ; + return wxString(sMacFileNameConversion) ; } wxString wxMacFSSpec2UnixFilename( const FSSpec *spec ) @@ -1255,6 +1264,8 @@ bool wxRemoveFile(const wxString& file) || defined(__WATCOMC__) \ || defined(__GNUWIN32__) int res = wxRemove(file); +#elif defined(__WXMAC__) + int res = unlink(wxFNCONV(file)); #else int res = unlink(OS_FILENAME(file)); #endif @@ -1265,7 +1276,7 @@ bool wxRemoveFile(const wxString& file) bool wxMkdir(const wxString& dir, int perm) { #if defined(__WXMAC__) && !defined(__UNIX__) - return (mkdir( dir , 0 ) == 0); + return (mkdir( wxFNCONV(dir) , 0 ) == 0); #else // !Mac const wxChar *dirname = dir.c_str(); @@ -1497,10 +1508,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) cwdSpec.parID = pb.ioFCBParID; cwdSpec.name[0] = 0 ; wxString res = wxMacFSSpec2MacFilename( &cwdSpec ) ; - - strcpy( cbuf , res ) ; - cbuf[res.length()]=0 ; - + wxStrcpy( buf , res ) ; ok = TRUE; } else @@ -1518,7 +1526,7 @@ wxChar *wxGetWorkingDirectory(wxChar *buf, int sz) ok = getcwd(cbuf, sz) != NULL; #endif // platform - #if wxUSE_UNICODE + #if wxUSE_UNICODE && !defined(__WXMAC__) // finally convert the result to Unicode if needed wxConvFile.MB2WC(buf, cbuf, sz); #endif // wxUSE_UNICODE -- 2.45.2