From e0a050e347b1ece07ad5f165ba1b1d16edbeae77 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 20 Jun 2007 07:44:45 +0000 Subject: [PATCH] more changes to make wx compile without implicit wxString->char* conversion (for STL build) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46553 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/fontmap.h | 2 +- include/wx/msw/dde.h | 5 ++++- include/wx/msw/mimetype.h | 2 +- include/wx/msw/private.h | 2 +- src/common/appbase.cpp | 4 ++-- src/common/filefn.cpp | 12 ++++++------ src/common/filename.cpp | 17 +++++++++-------- src/common/log.cpp | 2 +- src/common/msgout.cpp | 5 +++-- src/generic/datectlg.cpp | 2 +- src/generic/gridctrl.cpp | 2 +- src/generic/logg.cpp | 2 +- src/gtk/combobox.cpp | 1 + src/gtk/control.cpp | 18 +++++++++--------- src/gtk/gnome/gprint.cpp | 37 +++++++++++-------------------------- src/gtk/menu.cpp | 26 +++++++++++++++----------- src/msw/accel.cpp | 2 +- src/msw/button.cpp | 7 ++++--- src/msw/checkbox.cpp | 4 ++-- src/msw/colordlg.cpp | 2 +- src/msw/combobox.cpp | 4 ++-- src/msw/control.cpp | 2 +- src/msw/cursor.cpp | 4 ++-- src/msw/dc.cpp | 2 +- src/msw/dcprint.cpp | 11 +++++++---- src/msw/dib.cpp | 2 +- src/msw/dir.cpp | 2 +- src/msw/display.cpp | 8 ++++---- src/msw/dlmsw.cpp | 8 ++++++-- src/msw/enhmeta.cpp | 6 +++--- src/msw/fdrepdlg.cpp | 2 +- src/msw/filedlg.cpp | 8 ++++---- src/msw/gdiimage.cpp | 12 ++++++------ src/msw/helpchm.cpp | 21 +++++++++++++-------- src/msw/helpwin.cpp | 8 ++++---- src/msw/listbox.cpp | 10 +++++----- src/msw/listctrl.cpp | 2 +- src/msw/mdi.cpp | 8 ++++---- src/msw/menu.cpp | 14 +++++++------- src/msw/mimetype.cpp | 2 +- src/msw/msgdlg.cpp | 2 +- src/msw/ole/dataobj.cpp | 6 +++--- src/msw/radiobox.cpp | 2 +- src/msw/slider95.cpp | 8 +++++--- src/msw/snglinst.cpp | 2 +- src/msw/spinctrl.cpp | 3 ++- src/msw/statbox.cpp | 4 ++-- src/msw/statbr95.cpp | 4 ++-- src/msw/textctrl.cpp | 2 +- src/msw/tooltip.cpp | 2 +- src/msw/toplevel.cpp | 4 ++-- src/msw/treectrl.cpp | 2 +- src/msw/utils.cpp | 9 +++++---- src/msw/utilsgui.cpp | 4 +++- src/msw/window.cpp | 6 +++--- 55 files changed, 182 insertions(+), 168 deletions(-) diff --git a/include/wx/fontmap.h b/include/wx/fontmap.h index d057c16bd6..c8b5822ac7 100644 --- a/include/wx/fontmap.h +++ b/include/wx/fontmap.h @@ -50,7 +50,7 @@ class WXDLLIMPEXP_CORE wxFontMapper; class WXDLLIMPEXP_BASE wxFontMapperBase { public: - // constructtor and such + // constructor and such // --------------------- // default ctor diff --git a/include/wx/msw/dde.h b/include/wx/msw/dde.h index 51eeb91262..d8b0fabebe 100644 --- a/include/wx/msw/dde.h +++ b/include/wx/msw/dde.h @@ -51,7 +51,10 @@ public: // Calls that CLIENT can make virtual bool Execute(const wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); - virtual bool Execute(const wxString& str) { return Execute(str, -1, wxIPC_TEXT); } + // FIXME-UTF8: change Execute() to DoExecute() to avoid having to do this; + // don't use c_str() below after removing ANSI build + virtual bool Execute(const wxString& str) + { return Execute(str.c_str(), -1, wxIPC_TEXT); } virtual wxChar *Request(const wxString& item, int *size = NULL, wxIPCFormat format = wxIPC_TEXT); virtual bool Poke(const wxString& item, wxChar *data, int size = -1, wxIPCFormat format = wxIPC_TEXT); virtual bool StartAdvise(const wxString& item); diff --git a/include/wx/msw/mimetype.h b/include/wx/msw/mimetype.h index eb79564204..4dcff92796 100644 --- a/include/wx/msw/mimetype.h +++ b/include/wx/msw/mimetype.h @@ -66,7 +66,7 @@ public: private: // helper function: reads the command corresponding to the specified verb // from the registry (returns an empty string if not found) - wxString GetCommand(const wxChar *verb) const; + wxString GetCommand(const wxString& verb) const; // get the registry path for the given verb wxString GetVerbPath(const wxString& verb) const; diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 52c924ae09..22049abda7 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -692,7 +692,7 @@ public: { if ( IsRegistered() ) { - if ( !::UnregisterClass(m_clsname, wxhInstance) ) + if ( !::UnregisterClass(m_clsname.wx_str(), wxhInstance) ) { wxLogLastError(_T("UnregisterClass")); } diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index a24fee5965..119622bb8b 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -959,7 +959,7 @@ bool DoShowAssertDialog(const wxString& msg) wxT("You can also choose [Cancel] to suppress ") wxT("further warnings."); - switch ( ::MessageBox(NULL, msgDlg, _T("wxWidgets Debug Alert"), + switch ( ::MessageBox(NULL, msgDlg.wx_str(), _T("wxWidgets Debug Alert"), MB_YESNOCANCEL | MB_ICONSTOP ) ) { case IDYES: @@ -1027,7 +1027,7 @@ void ShowAssertDialog(const wxString& szFile, #if defined(__WXMSW__) && !defined(__WXMICROWIN__) msg << wxT("\r\n"); - OutputDebugString(msg ); + OutputDebugString(msg.wx_str()); #else // send to stderr wxFprintf(stderr, wxT("%s\n"), msg.c_str()); diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index e4d3f4d5dd..7e806a16cc 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -317,7 +317,7 @@ wxFileExists (const wxString& filename) #elif defined(__WIN32__) && !defined(__WXMICROWIN__) // we must use GetFileAttributes() instead of the ANSI C functions because // it can cope with network (UNC) paths unlike them - DWORD ret = ::GetFileAttributes(filename); + DWORD ret = ::GetFileAttributes(filename.fn_str()); return (ret != (DWORD)-1) && !(ret & FILE_ATTRIBUTE_DIRECTORY); #else // !__WIN32__ @@ -1125,7 +1125,7 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite) // instead of our code if available // // NB: 3rd parameter is bFailIfExists i.e. the inverse of overwrite - if ( !::CopyFile(file1, file2, !overwrite) ) + if ( !::CopyFile(file1.fn_str(), file2.fn_str(), !overwrite) ) { wxLogSysError(_("Failed to copy the file '%s' to '%s'"), file1.c_str(), file2.c_str()); @@ -1272,7 +1272,7 @@ bool wxRemoveFile(const wxString& file) || (defined(__MWERKS__) && defined(__MSL__)) int res = wxRemove(file); #elif defined(__WXMAC__) - int res = unlink(wxFNCONV(file)); + int res = unlink(file.fn_str()); #elif defined(__WXPALMOS__) int res = 1; // TODO with VFSFileDelete() @@ -1288,7 +1288,7 @@ bool wxMkdir(const wxString& dir, int perm) #if defined(__WXPALMOS__) return false; #elif defined(__WXMAC__) && !defined(__UNIX__) - return (mkdir( wxFNCONV(dir) , 0 ) == 0); + return (mkdir(dir.fn_str() , 0 ) == 0); #else // !Mac const wxChar *dirname = dir.c_str(); @@ -1376,7 +1376,7 @@ bool wxDirExists(const wxString& pathName) return false; #elif defined(__WIN32__) && !defined(__WXMICROWIN__) // stat() can't cope with network paths - DWORD ret = ::GetFileAttributes(strPath); + DWORD ret = ::GetFileAttributes(strPath.fn_str()); return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY); #elif defined(__OS2__) @@ -1662,7 +1662,7 @@ bool wxSetWorkingDirectory(const wxString& d) wxUnusedVar(d); return false; #else - return (bool)(SetCurrentDirectory(d) != 0); + return (bool)(SetCurrentDirectory(d.fn_str()) != 0); #endif #else // Must change drive, too. diff --git a/src/common/filename.cpp b/src/common/filename.cpp index ac911cb0a9..295725c32f 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -163,7 +163,7 @@ public: { m_hFile = ::CreateFile ( - filename, // name + filename.fn_str(), // name mode == Read ? GENERIC_READ // access mask : GENERIC_WRITE, FILE_SHARE_READ | // sharing mode @@ -650,7 +650,7 @@ static int wxOpenWithDeleteOnClose(const wxString& filename) DWORD attributes = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE; - HANDLE h = ::CreateFile(filename, access, 0, NULL, + HANDLE h = ::CreateFile(filename.fn_str(), access, 0, NULL, disposition, attributes, NULL); return wxOpenOSFHandle(h, wxO_BINARY); @@ -745,7 +745,8 @@ static wxString wxCreateTempImpl( } #elif defined(__WINDOWS__) && !defined(__WXMICROWIN__) - if ( !::GetTempFileName(dir, name, 0, wxStringBuffer(path, MAX_PATH + 1)) ) + if ( !::GetTempFileName(dir.fn_str(), name.fn_str(), 0, + wxStringBuffer(path, MAX_PATH + 1)) ) { wxLogLastError(_T("GetTempFileName")); @@ -1802,13 +1803,13 @@ wxString wxFileName::GetShortPath() const wxString path(GetFullPath()); #if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__) - DWORD sz = ::GetShortPathName(path, NULL, 0); + DWORD sz = ::GetShortPathName(path.fn_str(), NULL, 0); if ( sz != 0 ) { wxString pathOut; if ( ::GetShortPathName ( - path, + path.fn_str(), wxStringBuffer(pathOut, sz), sz ) != 0 ) @@ -1866,12 +1867,12 @@ wxString wxFileName::GetLongPath() const if ( s_pfnGetLongPathName ) { - DWORD dwSize = (*s_pfnGetLongPathName)(path, NULL, 0); + DWORD dwSize = (*s_pfnGetLongPathName)(path.fn_str(), NULL, 0); if ( dwSize > 0 ) { if ( (*s_pfnGetLongPathName) ( - path, + path.fn_str(), wxStringBuffer(pathOut, dwSize), dwSize ) != 0 ) @@ -1921,7 +1922,7 @@ wxString wxFileName::GetLongPath() const continue; } - hFind = ::FindFirstFile(tmpPath, &findFileData); + hFind = ::FindFirstFile(tmpPath.fn_str(), &findFileData); if (hFind == INVALID_HANDLE_VALUE) { // Error: most likely reason is that path doesn't exist, so diff --git a/src/common/log.cpp b/src/common/log.cpp index 1919342e23..e0bc967110 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -157,7 +157,7 @@ IMPLEMENT_LOG_FUNCTION(Status) void wxSafeShowMessage(const wxString& title, const wxString& text) { #ifdef __WINDOWS__ - ::MessageBox(NULL, text, title, MB_OK | MB_ICONSTOP); + ::MessageBox(NULL, text.wx_str(), title.wx_str(), MB_OK | MB_ICONSTOP); #else wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str()); fflush(stderr); diff --git a/src/common/msgout.cpp b/src/common/msgout.cpp index 5060844865..618ace720e 100755 --- a/src/common/msgout.cpp +++ b/src/common/msgout.cpp @@ -128,7 +128,8 @@ void wxMessageOutputBest::Output(const wxString& str) #ifdef __WINDOWS__ if ( !IsInConsole() ) { - ::MessageBox(NULL, str, _T("wxWidgets"), MB_ICONINFORMATION | MB_OK); + ::MessageBox(NULL, str.wx_str(), _T("wxWidgets"), + MB_ICONINFORMATION | MB_OK); } else #endif // __WINDOWS__/!__WINDOWS__ @@ -167,7 +168,7 @@ void wxMessageOutputDebug::Output(const wxString& str) #if defined(__WXMSW__) && !defined(__WXMICROWIN__) out.Replace(wxT("\t"), wxT(" ")); out.Replace(wxT("\n"), wxT("\r\n")); - ::OutputDebugString(out); + ::OutputDebugString(out.wx_str()); #elif defined(__WXMAC__) && !defined(__DARWIN__) if ( wxIsDebuggerRunning() ) { diff --git a/src/generic/datectlg.cpp b/src/generic/datectlg.cpp index 3c5d6933b8..cac86b2505 100644 --- a/src/generic/datectlg.cpp +++ b/src/generic/datectlg.cpp @@ -181,7 +181,7 @@ public: if ( !s.empty() ) { - pDt->ParseFormat(s, m_format); + pDt->ParseFormat(s.c_str(), m_format); if ( !pDt->IsValid() ) return false; } diff --git a/src/generic/gridctrl.cpp b/src/generic/gridctrl.cpp index 1dd5e68813..e8da62f564 100644 --- a/src/generic/gridctrl.cpp +++ b/src/generic/gridctrl.cpp @@ -76,7 +76,7 @@ wxString wxGridCellDateTimeRenderer::GetString(const wxGrid& grid, int row, int if (!hasDatetime ) { text = table->GetValue(row, col); - hasDatetime = (val.ParseFormat( text, m_iformat, m_dateDef ) != (wxChar *)NULL) ; + hasDatetime = (val.ParseFormat(text.c_str(), m_iformat, m_dateDef) != (wxChar *)NULL) ; } if ( hasDatetime ) diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index ab86120d63..04656f2d6f 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -407,7 +407,7 @@ void wxLogGui::DoLog(wxLogLevel level, const wxString& szString, time_t t) // don't prepend debug/trace here: it goes to the // debug window anyhow str += wxT("\r\n"); - OutputDebugString(str); + OutputDebugString(str.wx_str()); #else // send them to stderr wxFprintf(stderr, wxT("[%s] %s\n"), diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index bd57409bc7..b1bed06a01 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -1117,6 +1117,7 @@ void wxComboBox::Replace( long from, long to, const wxString& value ) if (value.IsNull()) return; gint pos = (gint)to; + // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer #if wxUSE_UNICODE_UTF8 const char *utf8 = value.utf8_str(); #else diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index f839ce7e45..7369e8cd9e 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -158,19 +158,18 @@ enum MnemonicsFlag MNEMONICS_CONVERT_MARKUP }; -static wxString GTKProcessMnemonics(const wxChar* label, MnemonicsFlag flag) +static wxString GTKProcessMnemonics(const wxString& label, MnemonicsFlag flag) { - const size_t len = wxStrlen(label); wxString labelGTK; - labelGTK.reserve(len); - for ( size_t i = 0; i < len; i++ ) + labelGTK.reserve(label.length()); + for ( wxString::const_iterator i = label.begin(); i != label.end(); ++i ) { - wxChar ch = label[i]; + wxChar ch = *i; switch ( ch ) { case wxT('&'): - if ( i == len - 1 ) + if ( i + 1 == label.end() ) { // "&" at the end of string is an error wxLogDebug(wxT("Invalid label \"%s\"."), label); @@ -180,6 +179,7 @@ static wxString GTKProcessMnemonics(const wxChar* label, MnemonicsFlag flag) if ( flag == MNEMONICS_CONVERT_MARKUP ) { bool isMnemonic = true; + size_t distanceFromEnd = label.end() - i; // is this ampersand introducing a mnemonic or rather an entity? for (size_t j=0; j < wxMARKUP_ENTITY_MAX; j++) @@ -187,8 +187,8 @@ static wxString GTKProcessMnemonics(const wxChar* label, MnemonicsFlag flag) const wxChar *entity = wxMarkupEntities[wxMARKUP_ELEMENT_NAME][j]; size_t entityLen = wxStrlen(entity); - if (len - i >= entityLen && - wxStrncmp(entity, &label[i], entityLen) == 0) + if (distanceFromEnd >= entityLen && + wxString(i, i + entityLen) == entity) { labelGTK << entity; i += entityLen - 1; // the -1 is because main for() @@ -203,7 +203,7 @@ static wxString GTKProcessMnemonics(const wxChar* label, MnemonicsFlag flag) continue; } - ch = label[++i]; // skip '&' itself + ch = *(++i); // skip '&' itself switch ( ch ) { case wxT('&'): diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index e6736d09d6..80827bd60d 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -1512,17 +1512,15 @@ void wxGnomePrintDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord bool underlined = m_font.Ok() && m_font.GetUnderlined(); -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); + // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer +#if wxUSE_UNICODE_UTF8 + const char *data = text.utf8_str(); #else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - if ( !wdata ) - return; - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); + const wxCharBuffer data = text.utf8_str(); #endif - size_t datalen = strlen((const char*)data); - pango_layout_set_text( m_layout, (const char*) data, datalen); + size_t datalen = strlen(data); + pango_layout_set_text( m_layout, data, datalen); if (underlined) { @@ -1850,27 +1848,14 @@ void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxC pango_layout_set_font_description( m_layout, theFont->GetNativeFontInfo()->description ); // Set layout's text -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - const char *dataUTF8 = (const char *)data; + + // FIXME-UTF8: wouldn't be needed if utf8_str() always returned a buffer +#if wxUSE_UNICODE_UTF8 + const char *dataUTF8 = string.utf8_str(); #else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - if ( !wdata ) - { - if (width) (*width) = 0; - if (height) (*height) = 0; - return; - } - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - const char *dataUTF8 = (const char *)data; + const wxCharBuffer dataUTF8 = string.utf8_str(); #endif - if ( !dataUTF8 ) - { - // hardly ideal, but what else can we do if conversion failed? - return; - } - pango_layout_set_text( m_layout, dataUTF8, strlen(dataUTF8) ); int w,h; diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 9f80040246..cdac20572c 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -868,18 +868,22 @@ wxString wxMenuItem::GTKProcessMenuItemLabel(const wxString& str, wxString *hotK wxString text; // '\t' is the deliminator indicating a hot key - const wxChar *pc = str; - while ( (*pc != wxT('\0')) && (*pc != wxT('\t')) ) + wxString::const_iterator pc = str.begin(); + while ( pc != str.end() && *pc != wxT('\t') ) { - if ((*pc == wxT('&')) && (*(pc+1) == wxT('&'))) + if (*pc == wxT('&')) { - // "&" is doubled to indicate "&" instead of accelerator - ++pc; - text << wxT('&'); - } - else if (*pc == wxT('&')) - { - text << wxT('_'); + wxString::const_iterator next = pc + 1; + if (next != str.end() && *next == wxT('&')) + { + // "&" is doubled to indicate "&" instead of accelerator + ++pc; + text << wxT('&'); + } + else + { + text << wxT('_'); + } } else if ( *pc == wxT('_') ) // escape underscores { @@ -898,7 +902,7 @@ wxString wxMenuItem::GTKProcessMenuItemLabel(const wxString& str, wxString *hotK if(*pc == wxT('\t')) { pc++; - *hotKey = pc; + hotKey->assign(pc, str.end()); } } diff --git a/src/msw/accel.cpp b/src/msw/accel.cpp index 3b8355d057..5a13ad0fa4 100644 --- a/src/msw/accel.cpp +++ b/src/msw/accel.cpp @@ -90,7 +90,7 @@ wxAcceleratorTable::wxAcceleratorTable(const wxString& resource) { m_refData = new wxAcceleratorRefData; - HACCEL hAccel = ::LoadAccelerators(wxGetInstance(), resource); + HACCEL hAccel = ::LoadAccelerators(wxGetInstance(), resource.wx_str()); M_ACCELDATA->m_hAccel = hAccel; M_ACCELDATA->m_ok = hAccel != 0; } diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 1c99e39ef9..95f1ba1fa6 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -572,7 +572,8 @@ static void DrawButtonText(HDC hdc, // first we need to compute its bounding rect RECT rc; ::CopyRect(&rc, pRect); - ::DrawText(hdc, text, text.length(), &rc, DT_CENTER | DT_CALCRECT); + ::DrawText(hdc, text.wx_str(), text.length(), &rc, + DT_CENTER | DT_CALCRECT); // now center this rect inside the entire button area const LONG w = rc.right - rc.left; @@ -582,12 +583,12 @@ static void DrawButtonText(HDC hdc, rc.top = (pRect->bottom - pRect->top)/2 - h/2; rc.bottom = rc.top+h; - ::DrawText(hdc, text, text.length(), &rc, DT_CENTER); + ::DrawText(hdc, text.wx_str(), text.length(), &rc, DT_CENTER); } else // single line label { // Note: we must have DT_SINGLELINE for DT_VCENTER to work. - ::DrawText(hdc, text, text.length(), pRect, + ::DrawText(hdc, text.wx_str(), text.length(), pRect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); } diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp index 281861d855..1b47fbe0a4 100644 --- a/src/msw/checkbox.cpp +++ b/src/msw/checkbox.cpp @@ -494,7 +494,7 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) // around it if ( isFocused ) { - if ( !::DrawText(hdc, label, label.length(), &rectLabel, + if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel, fmt | DT_CALCRECT) ) { wxLogLastError(_T("DrawText(DT_CALCRECT)")); @@ -506,7 +506,7 @@ bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT)); } - if ( !::DrawText(hdc, label, label.length(), &rectLabel, fmt) ) + if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel, fmt) ) { wxLogLastError(_T("DrawText()")); } diff --git a/src/msw/colordlg.cpp b/src/msw/colordlg.cpp index 66a70b0eb5..75a63ecef6 100644 --- a/src/msw/colordlg.cpp +++ b/src/msw/colordlg.cpp @@ -69,7 +69,7 @@ wxColourDialogHookProc(HWND hwnd, CHOOSECOLOR *pCC = (CHOOSECOLOR *)lParam; wxColourDialog *dialog = (wxColourDialog *)pCC->lCustData; - ::SetWindowText(hwnd, dialog->GetTitle()); + ::SetWindowText(hwnd, dialog->GetTitle().wx_str()); wxPoint pos = dialog->GetPosition(); if ( pos != wxDefaultPosition ) diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index e6e3af1bd4..9a3f40c653 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -326,7 +326,7 @@ bool wxComboBox::MSWCommand(WXUINT param, WXWORD id) // this string is going to become the new combobox value soon but // we need it to be done right now, otherwise the event handler // could get a wrong value when it calls our GetValue() - ::SetWindowText(GetHwnd(), value); + ::SetWindowText(GetHwnd(), value.wx_str()); { wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, GetId()); @@ -680,7 +680,7 @@ void wxComboBox::Replace(long from, long to, const wxString& value) Remove(from, to); // Now replace with 'value', by pasting. - wxSetClipboardData(wxDF_TEXT, (wxObject *)(const wxChar *)value, 0, 0); + wxSetClipboardData(wxDF_TEXT, (wxObject *)value.wx_str(), 0, 0); // Paste into edit control SendMessage(GetHwnd(), WM_PASTE, (WPARAM)0, (LPARAM)0L); diff --git a/src/msw/control.cpp b/src/msw/control.cpp index 54fd80129e..030a55f704 100644 --- a/src/msw/control.cpp +++ b/src/msw/control.cpp @@ -140,7 +140,7 @@ bool wxControl::MSWCreateControl(const wxChar *classname, ( exstyle, // extended style classname, // the kind of control to create - label, // the window name + label.wx_str(), // the window name style, // the window style x, y, w, h, // the window position and size GetHwndOf(GetParent()), // parent diff --git a/src/msw/cursor.cpp b/src/msw/cursor.cpp index 5093518a98..3e10e77865 100644 --- a/src/msw/cursor.cpp +++ b/src/msw/cursor.cpp @@ -254,12 +254,12 @@ wxCursor::wxCursor(const wxString& filename, switch ( kind ) { case wxBITMAP_TYPE_CUR_RESOURCE: - hcursor = ::LoadCursor(wxGetInstance(), filename); + hcursor = ::LoadCursor(wxGetInstance(), filename.fn_str()); break; #ifndef __WXWINCE__ case wxBITMAP_TYPE_CUR: - hcursor = ::LoadCursorFromFile(filename); + hcursor = ::LoadCursorFromFile(filename.fn_str()); break; #endif diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 2a205d5f01..6e0ea3100b 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -1748,7 +1748,7 @@ void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, SIZE sizeRect; const size_t len = string.length(); - if ( !::GetTextExtentPoint32(GetHdc(), string, len, &sizeRect) ) + if ( !::GetTextExtentPoint32(GetHdc(), string.wx_str(), len, &sizeRect) ) { wxLogLastError(_T("GetTextExtentPoint32()")); } diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 4b514b9e32..92425e9cf7 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -116,7 +116,10 @@ wxPrinterDC::wxPrinterDC(const wxString& driver_name, { if ( !driver_name.empty() && !device_name.empty() && !file.empty() ) { - m_hDC = (WXHDC) CreateDC(driver_name, device_name, file, NULL); + m_hDC = (WXHDC) CreateDC(driver_name.wx_str(), + device_name.wx_str(), + file.fn_str(), + NULL); } else // we don't have all parameters, ask the user { @@ -178,14 +181,14 @@ bool wxPrinterDC::StartDoc(const wxString& message) { DOCINFO docinfo; docinfo.cbSize = sizeof(DOCINFO); - docinfo.lpszDocName = (const wxChar*)message; + docinfo.lpszDocName = message.wx_str(); wxString filename(m_printData.GetFilename()); if (filename.empty()) docinfo.lpszOutput = NULL; else - docinfo.lpszOutput = (const wxChar *) filename; + docinfo.lpszOutput = filename.wx_str(); docinfo.lpszDatatype = NULL; docinfo.fwType = 0; @@ -323,7 +326,7 @@ WXHDC WXDLLEXPORT wxGetPrinterDC(const wxPrintData& printDataConst) DEVMODE *lpDevMode = hDevMode ? (DEVMODE *)::GlobalLock(hDevMode) : NULL; - HDC hDC = ::CreateDC(NULL, deviceName, NULL, lpDevMode); + HDC hDC = ::CreateDC(NULL, deviceName.wx_str(), NULL, lpDevMode); if ( !hDC ) wxLogLastError(_T("CreateDC(printer)")); diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 0c89e7e5ad..2abcde95b7 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -286,7 +286,7 @@ bool wxDIB::Load(const wxString& filename) m_handle = (HBITMAP)::LoadImage ( wxGetInstance(), - filename, + filename.fn_str(), IMAGE_BITMAP, 0, 0, // don't specify the size LR_CREATEDIBSECTION | LR_LOADFROMFILE diff --git a/src/msw/dir.cpp b/src/msw/dir.cpp index bfca51b322..5525d72a61 100644 --- a/src/msw/dir.cpp +++ b/src/msw/dir.cpp @@ -62,7 +62,7 @@ static inline void FreeFindData(FIND_DATA fd) static inline FIND_DATA FindFirst(const wxString& spec, FIND_STRUCT *finddata) { - return ::FindFirstFile(spec, finddata); + return ::FindFirstFile(spec.fn_str(), finddata); } static inline bool FindNext(FIND_DATA fd, FIND_STRUCT *finddata) diff --git a/src/msw/display.cpp b/src/msw/display.cpp index 1855c0c6a7..f5e9e84d51 100644 --- a/src/msw/display.cpp +++ b/src/msw/display.cpp @@ -768,11 +768,11 @@ bool wxDisplayImplMultimon::ChangeMode(const wxVideoMode& mode) // do change the mode switch ( pfnChangeDisplaySettingsEx ( - GetName(), // display name - pDevMode, // dev mode or NULL to reset - NULL, // reserved + GetName().wx_str(), // display name + pDevMode, // dev mode or NULL to reset + NULL, // reserved flags, - NULL // pointer to video parameters (not used) + NULL // pointer to video parameters (not used) ) ) { case DISP_CHANGE_SUCCESSFUL: diff --git a/src/msw/dlmsw.cpp b/src/msw/dlmsw.cpp index 7faff796a5..18a819d796 100644 --- a/src/msw/dlmsw.cpp +++ b/src/msw/dlmsw.cpp @@ -141,7 +141,11 @@ HMODULE wxGetModuleHandle(const char *name, void *addr) // Windows CE only has Unicode API, so even we have an ANSI string here, we // still need to use GetModuleHandleW() there and so do it everywhere to // avoid #ifdefs -- this code is not performance-critical anyhow... - return ::GetModuleHandle(wxString::FromAscii((char *)name)); +#ifdef __WINCE__ + return ::GetModuleHandleW(wxConvLibc.cMB2WC(name).data()); +#else + return ::GetModuleHandleA((char *)name); +#endif } // ============================================================================ @@ -278,7 +282,7 @@ wxDllType wxDynamicLibrary::GetProgramHandle() wxDllType wxDynamicLibrary::RawLoad(const wxString& libname, int WXUNUSED(flags)) { - return ::LoadLibrary(libname); + return ::LoadLibrary(libname.wx_str()); } /* static */ diff --git a/src/msw/enhmeta.cpp b/src/msw/enhmeta.cpp index 098c482469..aaf3f59857 100644 --- a/src/msw/enhmeta.cpp +++ b/src/msw/enhmeta.cpp @@ -57,7 +57,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxEnhMetaFileDC, wxDC) // we must pass NULL if the string is empty to metafile functions static inline const wxChar *GetMetaFileName(const wxString& fn) - { return !fn ? (const wxChar *)NULL : (const wxChar*)fn.c_str(); } + { return !fn ? (const wxChar *)NULL : (const wxChar*)fn.wx_str(); } // ============================================================================ // implementation @@ -75,7 +75,7 @@ void wxEnhMetaFile::Init() } else // have valid file name, load metafile from it { - m_hMF = (WXHANDLE)::GetEnhMetaFile(m_filename); + m_hMF = (WXHANDLE)::GetEnhMetaFile(m_filename.fn_str()); if ( !m_hMF ) wxLogSysError(_("Failed to load metafile from file \"%s\"."), m_filename.c_str()); @@ -219,7 +219,7 @@ wxEnhMetaFileDC::wxEnhMetaFileDC(const wxString& filename, ScreenHDC hdcRef; m_hDC = (WXHDC)::CreateEnhMetaFile(hdcRef, GetMetaFileName(filename), - pRect, description); + pRect, description.wx_str()); if ( !m_hDC ) { wxLogLastError(_T("CreateEnhMetaFile")); diff --git a/src/msw/fdrepdlg.cpp b/src/msw/fdrepdlg.cpp index 8cb9af619b..61441c2782 100644 --- a/src/msw/fdrepdlg.cpp +++ b/src/msw/fdrepdlg.cpp @@ -310,7 +310,7 @@ wxFindReplaceDialogHookProc(HWND hwnd, FINDREPLACE *pFR = (FINDREPLACE *)lParam; wxFindReplaceDialog *dialog = (wxFindReplaceDialog *)pFR->lCustData; - ::SetWindowText(hwnd, dialog->GetTitle()); + ::SetWindowText(hwnd, dialog->GetTitle().wx_str()); // don't return FALSE from here or the dialog won't be shown return TRUE; diff --git a/src/msw/filedlg.cpp b/src/msw/filedlg.cpp index e1c40bf3a5..175b241358 100644 --- a/src/msw/filedlg.cpp +++ b/src/msw/filedlg.cpp @@ -320,7 +320,7 @@ int wxFileDialog::ShowModal() of.lStructSize = gs_ofStructSize; of.hwndOwner = hWnd; - of.lpstrTitle = WXSTRINGCAST m_message; + of.lpstrTitle = m_message.wx_str(); of.lpstrFileTitle = titleBuffer; of.nMaxFileTitle = wxMAXFILE + 1 + wxMAXEXT; @@ -396,7 +396,7 @@ int wxFileDialog::ShowModal() //=== Setting defaultFileName >>========================================= - wxStrncpy( fileNameBuffer, (const wxChar *)m_fileName, wxMAXPATH-1 ); + wxStrncpy(fileNameBuffer, m_fileName, wxMAXPATH-1); fileNameBuffer[ wxMAXPATH-1 ] = wxT('\0'); of.lpstrFile = fileNameBuffer; // holds returned filename @@ -409,7 +409,7 @@ int wxFileDialog::ShowModal() wxString defextBuffer; // we need it to be alive until GetSaveFileName()! if (HasFdFlag(wxFD_SAVE)) { - const wxChar* extension = filterBuffer; + const wxChar* extension = filterBuffer.wx_str(); int maxFilter = (int)(of.nFilterIndex*2L) - 1; for( int i = 0; i < maxFilter; i++ ) // get extension @@ -511,7 +511,7 @@ int wxFileDialog::ShowModal() (of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) ) { // User has typed a filename without an extension: - const wxChar* extension = filterBuffer; + const wxChar* extension = filterBuffer.wx_str(); int maxFilter = (int)(of.nFilterIndex*2L) - 1; for( int i = 0; i < maxFilter; i++ ) // get extension diff --git a/src/msw/gdiimage.cpp b/src/msw/gdiimage.cpp index 6988f3d0c4..ff89f0755b 100644 --- a/src/msw/gdiimage.cpp +++ b/src/msw/gdiimage.cpp @@ -323,7 +323,7 @@ bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap, int WXUNUSED(desiredHeight)) { // TODO: load colourmap. - bitmap->SetHBITMAP((WXHBITMAP)::LoadBitmap(wxGetInstance(), name)); + bitmap->SetHBITMAP((WXHBITMAP)::LoadBitmap(wxGetInstance(), name.wx_str())); if ( !bitmap->Ok() ) { @@ -438,7 +438,7 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon, desiredHeight == ::GetSystemMetrics(SM_CYICON) ) { // get the specified large icon from file - if ( !::ExtractIconEx(nameReal, iconIndex, &hicon, NULL, 1) ) + if ( !::ExtractIconEx(nameReal.wx_str(), iconIndex, &hicon, NULL, 1) ) { // it is not an error, but it might still be useful to be informed // about it optionally @@ -451,7 +451,7 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon, desiredHeight == ::GetSystemMetrics(SM_CYSMICON) ) { // get the specified small icon from file - if ( !::ExtractIconEx(nameReal, iconIndex, NULL, &hicon, 1) ) + if ( !::ExtractIconEx(nameReal.wx_str(), iconIndex, NULL, &hicon, 1) ) { wxLogTrace(_T("iconload"), _T("No small icons found in the file '%s'."), @@ -464,7 +464,7 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon, if ( !hicon ) { // take any size icon from the file by index - hicon = ::ExtractIcon(wxGetInstance(), nameReal, iconIndex); + hicon = ::ExtractIcon(wxGetInstance(), nameReal.wx_str(), iconIndex); } #endif @@ -518,13 +518,13 @@ bool wxICOResourceHandler::LoadIcon(wxIcon *icon, // some icon rescaling internally which results in very ugly 16x16 icons if ( hasSize ) { - hicon = (HICON)::LoadImage(wxGetInstance(), name, IMAGE_ICON, + hicon = (HICON)::LoadImage(wxGetInstance(), name.wx_str(), IMAGE_ICON, desiredWidth, desiredHeight, LR_DEFAULTCOLOR); } else { - hicon = ::LoadIcon(wxGetInstance(), name); + hicon = ::LoadIcon(wxGetInstance(), name.wx_str()); } // next check if it's not a standard icon diff --git a/src/msw/helpchm.cpp b/src/msw/helpchm.cpp index 411d495980..1114decbd0 100644 --- a/src/msw/helpchm.cpp +++ b/src/msw/helpchm.cpp @@ -88,7 +88,8 @@ CallHtmlHelpFunction(wxWindow *win, const wxChar *str, UINT uint, DWORD dword) { HTMLHELP htmlHelp = GetHtmlHelpFunction(); - return htmlHelp && htmlHelp(GetSuitableHWND(win), str, uint, dword); + return htmlHelp && + htmlHelp(GetSuitableHWND(win), str, uint, dword); } IMPLEMENT_DYNAMIC_CLASS(wxCHMHelpController, wxHelpControllerBase) @@ -116,7 +117,8 @@ bool wxCHMHelpController::DisplayContents() wxString str = GetValidFilename(m_helpFile); - return CallHtmlHelpFunction(GetParentWindow(), str, HH_DISPLAY_TOPIC, 0L); + return CallHtmlHelpFunction(GetParentWindow(), + str.wx_str(), HH_DISPLAY_TOPIC, 0L); } // Use topic or HTML filename @@ -131,7 +133,8 @@ bool wxCHMHelpController::DisplaySection(const wxString& section) if ( section.Find(wxT(".htm")) != wxNOT_FOUND ) { // interpret as a file name - return CallHtmlHelpFunction(GetParentWindow(), str, HH_DISPLAY_TOPIC, + return CallHtmlHelpFunction(GetParentWindow(), + str.wx_str(), HH_DISPLAY_TOPIC, wxPtrToUInt(section.c_str())); } @@ -146,8 +149,8 @@ bool wxCHMHelpController::DisplaySection(int section) wxString str = GetValidFilename(m_helpFile); - return CallHtmlHelpFunction(GetParentWindow(), str, HH_HELP_CONTEXT, - (DWORD)section); + return CallHtmlHelpFunction(GetParentWindow(), + str.wx_str(), HH_HELP_CONTEXT, (DWORD)section); } bool wxCHMHelpController::DisplayContextPopup(int contextId) @@ -171,7 +174,8 @@ bool wxCHMHelpController::DisplayContextPopup(int contextId) popup.pszFont = NULL; popup.pszText = NULL; - return CallHtmlHelpFunction(GetParentWindow(), str, HH_DISPLAY_TEXT_POPUP, + return CallHtmlHelpFunction(GetParentWindow(), + str.wx_str(), HH_DISPLAY_TEXT_POPUP, wxPtrToUInt(&popup)); } @@ -195,7 +199,7 @@ bool wxCHMHelpController::ShowContextHelpPopup(const wxString& text, popup.clrBackground = (COLORREF)-1; popup.rcMargins.top = popup.rcMargins.left = popup.rcMargins.right = popup.rcMargins.bottom = -1; popup.pszFont = NULL; - popup.pszText = (const wxChar*) text; + popup.pszText = text.wx_str(); return CallHtmlHelpFunction(window, NULL, HH_DISPLAY_TEXT_POPUP, wxPtrToUInt(&popup)); @@ -224,7 +228,8 @@ bool wxCHMHelpController::KeywordSearch(const wxString& k, link.pszWindow = NULL ; link.fIndexOnFail = TRUE ; - return CallHtmlHelpFunction(GetParentWindow(), str, HH_KEYWORD_LOOKUP, + return CallHtmlHelpFunction(GetParentWindow(), + str.wx_str(), HH_KEYWORD_LOOKUP, wxPtrToUInt(&link)); } diff --git a/src/msw/helpwin.cpp b/src/msw/helpwin.cpp index 3b9ec5549d..edb293ca0f 100644 --- a/src/msw/helpwin.cpp +++ b/src/msw/helpwin.cpp @@ -63,7 +63,7 @@ bool wxWinHelpController::DisplayContents(void) wxString str = GetValidFilename(m_helpFile); - return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_FINDER, 0L) != 0); + return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_FINDER, 0L) != 0); } bool wxWinHelpController::DisplaySection(int section) @@ -73,7 +73,7 @@ bool wxWinHelpController::DisplaySection(int section) wxString str = GetValidFilename(m_helpFile); - return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXT, (DWORD)section) != 0); + return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_CONTEXT, (DWORD)section) != 0); } bool wxWinHelpController::DisplayContextPopup(int contextId) @@ -82,7 +82,7 @@ bool wxWinHelpController::DisplayContextPopup(int contextId) wxString str = GetValidFilename(m_helpFile); - return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_CONTEXTPOPUP, (DWORD) contextId) != 0); + return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_CONTEXTPOPUP, (DWORD) contextId) != 0); } bool wxWinHelpController::DisplayBlock(long block) @@ -98,7 +98,7 @@ bool wxWinHelpController::KeywordSearch(const wxString& k, wxString str = GetValidFilename(m_helpFile); - return (WinHelp(GetSuitableHWND(this), (const wxChar*) str, HELP_PARTIALKEY, (DWORD)(const wxChar*) k) != 0); + return (WinHelp(GetSuitableHWND(this), str.wx_str(), HELP_PARTIALKEY, (DWORD)k.wx_str()) != 0); } // Can't close the help window explicitly in WinHelp diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index f85cec4b55..698d03d610 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -279,7 +279,7 @@ void wxListBox::Delete(unsigned int n) int wxListBox::DoAppend(const wxString& item) { - int index = ListBox_AddString(GetHwnd(), item); + int index = ListBox_AddString(GetHwnd(), item.wx_str()); m_noItems++; #if wxUSE_OWNER_DRAWN @@ -312,7 +312,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) unsigned int i; for (i = 0; i < m_noItems; i++) { - ListBox_AddString(GetHwnd(), choices[i]); + ListBox_AddString(GetHwnd(), choices[i].wx_str()); if ( clientData ) { SetClientData(i, clientData[i]); @@ -349,7 +349,7 @@ int wxListBox::FindString(const wxString& s, bool bCase) const if (bCase) return wxItemContainerImmutable::FindString( s, bCase ); - int pos = ListBox_FindStringExact(GetHwnd(), -1, s); + int pos = ListBox_FindStringExact(GetHwnd(), -1, s.wx_str()); if (pos == LB_ERR) return wxNOT_FOUND; else @@ -520,7 +520,7 @@ wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos) unsigned int nItems = items.GetCount(); for ( unsigned int i = 0; i < nItems; i++ ) { - int idx = ListBox_InsertString(GetHwnd(), i + pos, items[i]); + int idx = ListBox_InsertString(GetHwnd(), i + pos, items[i].wx_str()); #if wxUSE_OWNER_DRAWN if ( m_windowStyle & wxLB_OWNERDRAW ) @@ -574,7 +574,7 @@ void wxListBox::SetString(unsigned int n, const wxString& s) if ( n == (m_noItems - 1) ) newN = -1; - ListBox_InsertString(GetHwnd(), newN, s); + ListBox_InsertString(GetHwnd(), newN, s.wx_str()); // restore the client data if ( oldData ) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index f61b3fd9ca..65fb65b7d0 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1424,7 +1424,7 @@ long wxListCtrl::FindItem(long start, const wxString& str, bool partial) findInfo.flags = LVFI_STRING; if ( partial ) findInfo.flags |= LVFI_PARTIAL; - findInfo.psz = str; + findInfo.psz = str.wx_str(); // ListView_FindItem() excludes the first item from search and to look // through all the items you need to start from -1 which is unnatural and diff --git a/src/msw/mdi.cpp b/src/msw/mdi.cpp index 881f48fce9..7114765e93 100644 --- a/src/msw/mdi.cpp +++ b/src/msw/mdi.cpp @@ -199,7 +199,7 @@ bool wxMDIParentFrame::Create(wxWindow *parent, msflags &= ~WS_HSCROLL; if ( !wxWindow::MSWCreate(wxMDIFrameClassName, - title, + title.wx_str(), pos, size, msflags, exflags) ) @@ -711,7 +711,7 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, mcs.szClass = style & wxFULL_REPAINT_ON_RESIZE ? wxMDIChildFrameClassName : wxMDIChildFrameClassNameNoRedraw; - mcs.szTitle = title; + mcs.szTitle = title.wx_str(); mcs.hOwner = wxGetInstance(); if (x != wxDefaultCoord) mcs.x = x; @@ -1430,14 +1430,14 @@ static void InsertWindowMenu(wxWindow *win, WXHMENU menu, HMENU subMenu) { success = true; ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING, - (UINT)subMenu, _("&Window")); + (UINT)subMenu, _("&Window").wx_str()); break; } } if ( !success ) { - ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, _("&Window")); + ::AppendMenu(hmenu, MF_POPUP, (UINT)subMenu, _("&Window").wx_str()); } } diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 5e24fd40b9..ad2f91eac1 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -731,7 +731,7 @@ void wxMenu::SetTitle(const wxString& label) if ( !label.empty() ) { if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, - (unsigned)idMenuTitle, m_title) || + (unsigned)idMenuTitle, m_title.wx_str()) || !::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { wxLogLastError(wxT("InsertMenu")); @@ -767,7 +767,7 @@ void wxMenu::SetTitle(const wxString& label) #else if ( !ModifyMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, - (unsigned)idMenuTitle, m_title) ) + (unsigned)idMenuTitle, m_title.wx_str()) ) { wxLogLastError(wxT("ModifyMenu")); } @@ -979,7 +979,7 @@ WXHMENU wxMenuBar::Create() { if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING, (UINT)(*it)->GetHMenu(), - m_titles[i]) ) + m_titles[i].wx_str()) ) { wxLogLastError(wxT("AppendMenu")); } @@ -1085,7 +1085,7 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) #else if ( ::ModifyMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_STRING | flagsOld, - id, label) == (int)0xFFFFFFFF ) + id, label.wx_str()) == (int)0xFFFFFFFF ) { wxLogLastError(wxT("ModifyMenu")); } @@ -1130,7 +1130,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) if ( !::InsertMenu(GetHmenu(), (UINT)mswpos, MF_BYPOSITION | MF_POPUP | MF_STRING, - (UINT)GetHmenuOf(menu), title) ) + (UINT)GetHmenuOf(menu), title.wx_str()) ) { wxLogLastError(wxT("InsertMenu")); } @@ -1197,7 +1197,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) #else if ( !::InsertMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_POPUP | MF_STRING, - (UINT)GetHmenuOf(menu), title) ) + (UINT)GetHmenuOf(menu), title.wx_str()) ) { wxLogLastError(wxT("InsertMenu")); } @@ -1256,7 +1256,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) } #else if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, - (UINT)submenu, title) ) + (UINT)submenu, title.wx_str()) ) { wxLogLastError(wxT("AppendMenu")); } diff --git a/src/msw/mimetype.cpp b/src/msw/mimetype.cpp index be3b448067..91cb4036c2 100644 --- a/src/msw/mimetype.cpp +++ b/src/msw/mimetype.cpp @@ -200,7 +200,7 @@ bool wxFileTypeImpl::EnsureExtKeyExists() // get the command to use // ---------------------------------------------------------------------------- -wxString wxFileTypeImpl::GetCommand(const wxChar *verb) const +wxString wxFileTypeImpl::GetCommand(const wxString& verb) const { // suppress possible error messages wxLogNull nolog; diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index 83b2d98d22..76eda81fc9 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -109,7 +109,7 @@ int wxMessageDialog::ShowModal() #endif // wxUSE_UNICODE // do show the dialog - int msAns = MessageBox(hWnd, message, m_caption, msStyle); + int msAns = MessageBox(hWnd, message.wx_str(), m_caption.wx_str(), msStyle); int ans; switch (msAns) { diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 6452e4b2fd..3831f98b1a 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -139,7 +139,7 @@ private: void wxDataFormat::SetId(const wxString& format) { - m_format = (wxDataFormat::NativeFormat)::RegisterClipboardFormat(format); + m_format = (wxDataFormat::NativeFormat)::RegisterClipboardFormat(format.wx_str()); if ( !m_format ) { wxLogError(_("Couldn't register clipboard format '%s'."), format); @@ -1082,7 +1082,7 @@ size_t wxFileDataObject::GetDataSize() const size_t len; #if wxUSE_UNICODE_MSLU if ( sizeOfChar == sizeof(char) ) - len = strlen(wxConvFileName->cWC2MB(m_filenames[i])); + len = strlen(m_filenames[i].mb_str(*wxConvFileName)); else #endif // wxUSE_UNICODE_MSLU len = m_filenames[i].length(); @@ -1131,7 +1131,7 @@ bool wxFileDataObject::GetDataHere(void *WXUNUSED_IN_WINCE(pData)) const #if wxUSE_UNICODE_MSLU if ( sizeOfChar == sizeof(char) ) { - wxCharBuffer buf(wxConvFileName->cWC2MB(m_filenames[i])); + wxCharBuffer buf(m_filenames[i].mb_str(*wxConvFileName)); len = strlen(buf); memcpy(pbuf, buf, len*sizeOfChar); } diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 45424eb27e..408c5d8b65 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -170,7 +170,7 @@ bool wxRadioBox::Create(wxWindow *parent, long newId = NewControlId(); HWND hwndBtn = ::CreateWindow(_T("BUTTON"), - choices[i], + choices[i].wx_str(), styleBtn, 0, 0, 0, 0, // will be set in SetSize() GetHwndOf(parent), diff --git a/src/msw/slider95.cpp b/src/msw/slider95.cpp index ef18937374..8bef10518a 100644 --- a/src/msw/slider95.cpp +++ b/src/msw/slider95.cpp @@ -573,7 +573,7 @@ void wxSlider::SetValue(int value) if ( m_labels ) { - ::SetWindowText((*m_labels)[SliderLabel_Value], Format(value)); + ::SetWindowText((*m_labels)[SliderLabel_Value], Format(value).wx_str()); } } @@ -587,8 +587,10 @@ void wxSlider::SetRange(int minValue, int maxValue) if ( m_labels ) { - ::SetWindowText((*m_labels)[SliderLabel_Min], Format(ValueInvertOrNot(m_rangeMin))); - ::SetWindowText((*m_labels)[SliderLabel_Max], Format(ValueInvertOrNot(m_rangeMax))); + ::SetWindowText((*m_labels)[SliderLabel_Min], + Format(ValueInvertOrNot(m_rangeMin)).wx_str()); + ::SetWindowText((*m_labels)[SliderLabel_Max], + Format(ValueInvertOrNot(m_rangeMax)).wx_str()); } } diff --git a/src/msw/snglinst.cpp b/src/msw/snglinst.cpp index 3e9e23a1be..83f66d46a0 100644 --- a/src/msw/snglinst.cpp +++ b/src/msw/snglinst.cpp @@ -52,7 +52,7 @@ public: bool Create(const wxString& name) { - m_hMutex = ::CreateMutex(NULL, FALSE, name); + m_hMutex = ::CreateMutex(NULL, FALSE, name.wx_str()); if ( !m_hMutex ) { wxLogLastError(_T("CreateMutex")); diff --git a/src/msw/spinctrl.cpp b/src/msw/spinctrl.cpp index a3c6e43a0e..39e32fbf70 100644 --- a/src/msw/spinctrl.cpp +++ b/src/msw/spinctrl.cpp @@ -462,7 +462,8 @@ void wxSpinCtrl::SetValue(int val) // text control is currently empty, the spin button seems to be happy // to leave it like this, while we really want to always show the // current value in the control, so do it manually - ::SetWindowText(GetBuddyHwnd(), wxString::Format(_T("%d"), val)); + ::SetWindowText(GetBuddyHwnd(), + wxString::Format(_T("%d"), val).wx_str()); } m_oldValue = GetValue(); diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 692e8a10ca..0d4df55d13 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -500,13 +500,13 @@ void wxStaticBox::PaintForeground(wxDC& dc, const RECT& rc) if ( !rtl ) { RECT rc2 = { x, 0, x + width, y }; - ::DrawText(hdc, label, label.length(), &rc2, + ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER); } else // RTL { RECT rc2 = { x, 0, x - width, y }; - ::DrawText(hdc, label, label.length(), &rc2, + ::DrawText(hdc, label.wx_str(), label.length(), &rc2, DT_SINGLELINE | DT_VCENTER | DT_RTLREADING); } } diff --git a/src/msw/statbr95.cpp b/src/msw/statbr95.cpp index 2fd1936449..9b310fcf23 100644 --- a/src/msw/statbr95.cpp +++ b/src/msw/statbr95.cpp @@ -218,7 +218,7 @@ void wxStatusBar95::SetStatusText(const wxString& strText, int nField) // Pass both field number and style. MSDN library doesn't mention // that nField and style have to be 'ORed' - if ( !StatusBar_SetText(GetHwnd(), nField | style, strText) ) + if ( !StatusBar_SetText(GetHwnd(), nField | style, strText.wx_str()) ) { wxLogLastError(wxT("StatusBar_SetText")); } @@ -404,7 +404,7 @@ void wxStatusBar95::SetStatusStyles(int n, const int styles[]) // the fields' styles. MSDN library doesn't mention // that nField and style have to be 'ORed' wxString text = GetStatusText(i); - if (!StatusBar_SetText(GetHwnd(), style | i, text)) + if (!StatusBar_SetText(GetHwnd(), style | i, text.wx_str())) { wxLogLastError(wxT("StatusBar_SetText")); } diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index 04cc73d26a..4ae10bb7e6 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -446,7 +446,7 @@ bool wxTextCtrl::MSWCreateText(const wxString& value, valueWin = value; } - if ( !MSWCreateControl(windowClass, msStyle, pos, size, valueWin) ) + if ( !MSWCreateControl(windowClass.wx_str(), msStyle, pos, size, valueWin) ) return false; #if wxUSE_RICHEDIT diff --git a/src/msw/tooltip.cpp b/src/msw/tooltip.cpp index 0c875c0650..0e41099317 100644 --- a/src/msw/tooltip.cpp +++ b/src/msw/tooltip.cpp @@ -339,7 +339,7 @@ void wxToolTip::Add(WXHWND hWnd) while (token.length()) { SIZE sz; - if ( !::GetTextExtentPoint32(hdc, token, token.length(), &sz) ) + if ( !::GetTextExtentPoint32(hdc, token.wx_str(), token.length(), &sz) ) { wxLogLastError(wxT("GetTextExtentPoint32")); } diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index 1d50568724..272d3c15bf 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -479,7 +479,7 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, if ( !title.empty() ) { - ::SetWindowText(GetHwnd(), title); + ::SetWindowText(GetHwnd(), title.wx_str()); } SubclassWin(m_hWnd); @@ -507,7 +507,7 @@ bool wxTopLevelWindowMSW::CreateFrame(const wxString& title, exflags |= WS_EX_LAYOUTRTL; #endif - return MSWCreate(wxCanvasClassName, title, pos, sz, flags, exflags); + return MSWCreate(wxCanvasClassName, title.wx_str(), pos, sz, flags, exflags); } bool wxTopLevelWindowMSW::Create(wxWindow *parent, diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index f3733657d9..fac8ddbaee 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -934,7 +934,7 @@ void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) { if ( item == m_idEdited ) { - ::SetWindowText(hwndEdit, text); + ::SetWindowText(hwndEdit, text.wx_str()); } } } diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index df8a474ea7..c0efa166b7 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -514,7 +514,7 @@ bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path), ULARGE_INTEGER bytesFree, bytesTotal; // may pass the path as is, GetDiskFreeSpaceEx() is smart enough - if ( !pGetDiskFreeSpaceEx(path, + if ( !pGetDiskFreeSpaceEx(path.fn_str(), &bytesFree, &bytesTotal, NULL) ) @@ -564,7 +564,7 @@ bool wxGetDiskSpace(const wxString& WXUNUSED_IN_WINCE(path), // FIXME: this is wrong, we should extract the root drive from path // instead, but this is the job for wxFileName... - if ( !::GetDiskFreeSpace(path, + if ( !::GetDiskFreeSpace(path.fn_str(), &lSectorsPerCluster, &lBytesPerSector, &lNumberOfFreeClusters, @@ -608,7 +608,7 @@ bool wxGetEnv(const wxString& WXUNUSED_IN_WINCE(var), return false; #else // Win32 // first get the size of the buffer - DWORD dwRet = ::GetEnvironmentVariable(var, NULL, 0); + DWORD dwRet = ::GetEnvironmentVariable(var.wx_str(), NULL, 0); if ( !dwRet ) { // this means that there is no such variable @@ -617,7 +617,8 @@ bool wxGetEnv(const wxString& WXUNUSED_IN_WINCE(var), if ( value ) { - (void)::GetEnvironmentVariable(var, wxStringBuffer(*value, dwRet), + (void)::GetEnvironmentVariable(var.wx_str(), + wxStringBuffer(*value, dwRet), dwRet); } diff --git a/src/msw/utilsgui.cpp b/src/msw/utilsgui.cpp index 9883a635a3..f01babae85 100644 --- a/src/msw/utilsgui.cpp +++ b/src/msw/utilsgui.cpp @@ -107,7 +107,9 @@ bool wxCheckForInterrupt(wxWindow *wnd) #ifndef __WXMICROWIN__ wxChar *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType) { - HRSRC hResource = ::FindResource(wxGetInstance(), resourceName, resourceType); + HRSRC hResource = ::FindResource(wxGetInstance(), + resourceName.wx_str(), + resourceType.wx_str()); if ( hResource == 0 ) return NULL; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 26f261059f..d5e877f3f9 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1979,7 +1979,7 @@ void wxWindowMSW::GetTextExtent(const wxString& string, SIZE sizeRect; TEXTMETRIC tm; - ::GetTextExtentPoint32(hdc, string, string.length(), &sizeRect); + ::GetTextExtentPoint32(hdc, string.wx_str(), string.length(), &sizeRect); GetTextMetrics(hdc, &tm); if ( x ) @@ -3369,8 +3369,8 @@ bool wxWindowMSW::MSWCreate(const wxChar *wclass, m_hWnd = (WXHWND)::CreateWindowEx ( extendedStyle, - className, - title ? title : (const wxChar*)m_windowName.c_str(), + className.wx_str(), + title ? title : m_windowName.wx_str(), style, x, y, w, h, (HWND)MSWGetParent(), -- 2.45.2