From 404aba09e585de231b85eb2422bdd3bdc6318535 Mon Sep 17 00:00:00 2001
From: Stefan Neis <Stefan.Neis@t-online.de>
Date: Sat, 7 Apr 2007 12:21:15 +0000
Subject: [PATCH] Replaced incorrect or inefficient usage of char_str() by
 wx_str().

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/os2/choice.cpp   |  6 +++---
 src/os2/dc.cpp       |  6 ++----
 src/os2/dcprint.cpp  |  4 ++--
 src/os2/listbox.cpp  |  8 ++++----
 src/os2/menu.cpp     | 12 ++++++------
 src/os2/menuitem.cpp |  2 +-
 src/os2/ownerdrw.cpp |  4 ++--
 src/os2/textctrl.cpp |  5 +++--
 src/os2/utils.cpp    |  2 +-
 src/os2/window.cpp   |  5 +----
 10 files changed, 25 insertions(+), 29 deletions(-)

diff --git a/src/os2/choice.cpp b/src/os2/choice.cpp
index 0b769aceb8..59e63f9275 100644
--- a/src/os2/choice.cpp
+++ b/src/os2/choice.cpp
@@ -134,7 +134,7 @@ int wxChoice::DoAppend(
     nIndex = (int)::WinSendMsg( GetHwnd()
                                ,LM_INSERTITEM
                                ,(MPARAM)nIndexType
-                               ,(MPARAM)rsItem.char_str()
+                               ,(MPARAM)rsItem.wx_str()
                               );
     return nIndex;
 } // end of wxChoice::DoAppend
@@ -157,7 +157,7 @@ int wxChoice::DoInsert( const wxString& rsItem, unsigned int pos )
     nIndex = (int)::WinSendMsg( GetHwnd()
                                ,LM_INSERTITEM
                                ,(MPARAM)nIndexType
-                               ,(MPARAM)rsItem.char_str()
+                               ,(MPARAM)rsItem.wx_str()
                               );
     return nIndex;
 } // end of wxChoice::DoInsert
@@ -232,7 +232,7 @@ void wxChoice::SetString(unsigned int n, const wxString& rsStr)
     ::WinSendMsg( GetHwnd()
                  ,LM_INSERTITEM
                  ,(MPARAM)nIndexType
-                 ,(MPARAM)rsStr.char_str()
+                 ,(MPARAM)rsStr.wx_str()
                 );
 
     if (pData)
diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp
index 1a65b1804c..11d9169319 100644
--- a/src/os2/dc.cpp
+++ b/src/os2/dc.cpp
@@ -1753,12 +1753,10 @@ void wxDC::DrawAnyText( const wxString& rsText,
             vPtlStart.y = vY;
     }
 
-    PCH pzStr = rsText.char_str();
-
     ::GpiMove(m_hPS, &vPtlStart);
     lHits = ::GpiCharString( m_hPS
                             ,rsText.length()
-                            ,pzStr
+                            ,rsText.wx_str()
                            );
     if (lHits != GPI_OK)
     {
@@ -2178,7 +2176,7 @@ void wxDC::DoGetTextExtent(
     //
     bRc = ::GpiQueryTextBox( m_hPS
                             ,l
-                            ,rsString.char_str()
+                            ,(char *)rsString.wx_str()
                             ,TXTBOX_COUNT // return maximum information
                             ,avPoint      // array of coordinates points
                            );
diff --git a/src/os2/dcprint.cpp b/src/os2/dcprint.cpp
index 807340d397..1c4a11c248 100644
--- a/src/os2/dcprint.cpp
+++ b/src/os2/dcprint.cpp
@@ -41,8 +41,8 @@ wxPrinterDC::wxPrinterDC( const wxString& rsDriverName,
                           bool bInteractive,
                           int nOrientation )
 {
-    DEVOPENSTRUC    vDevOpen = { rsDeviceName.char_str()
-                                ,rsDriverName.char_str()
+    DEVOPENSTRUC    vDevOpen = { (char*)rsDeviceName.wx_str()
+                                ,(char*)rsDriverName.wx_str()
                                 ,NULL
                                 ,NULL
                                 ,NULL
diff --git a/src/os2/listbox.cpp b/src/os2/listbox.cpp
index b799035407..aaca7eabcb 100644
--- a/src/os2/listbox.cpp
+++ b/src/os2/listbox.cpp
@@ -281,7 +281,7 @@ int wxListBox::DoAppend(const wxString& rsItem)
     else
         lIndexType = LIT_END;
 
-    lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.char_str());
+    lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.wx_str());
     m_nNumItems++;
 
 #if wxUSE_OWNER_DRAWN
@@ -318,7 +318,7 @@ void wxListBox::DoSetItems( const wxArrayString& raChoices,
             lIndexType = LIT_SORTASCENDING;
         else
             lIndexType = LIT_END;
-        ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)raChoices[i].char_str());
+        ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)raChoices[i].wx_str());
 
         if (ppClientData)
         {
@@ -563,7 +563,7 @@ void wxListBox::DoInsertItems(const wxArrayString& asItems, unsigned int nPos)
         int nIndex = (int)::WinSendMsg( GetHwnd(),
                                         LM_INSERTITEM,
                                         MPFROMLONG((LONG)(i + nPos)),
-                                        (MPARAM)asItems[i].char_str() );
+                                        (MPARAM)asItems[i].wx_str() );
 
         wxOwnerDrawn* pNewItem = CreateItem(nIndex);
 
@@ -613,7 +613,7 @@ void wxListBox::SetString(unsigned int n, const wxString& rsString)
     ::WinSendMsg( GetHwnd()
                  ,LM_INSERTITEM
                  ,(MPARAM)nNewN
-                 ,(MPARAM)rsString.char_str()
+                 ,(MPARAM)rsString.wx_str()
                 );
 
     //
diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp
index bd013d35bf..7f693d4d2d 100644
--- a/src/os2/menu.cpp
+++ b/src/os2/menu.cpp
@@ -323,7 +323,7 @@ bool wxMenu::DoInsertOrAppend( wxMenuItem* pItem,
             //
             rItem.afStyle |= MIS_TEXT;
         }
-        pData = pItem->GetText().char_str();
+        pData = (char*) pItem->GetText().wx_str();
     }
 
     if (nPos == (size_t)-1)
@@ -804,7 +804,7 @@ WXHMENU wxMenuBar::Create()
 
             (*it)->m_vMenuData.iPosition = (SHORT)i;
 
-            rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&(*it)->m_vMenuData, (MPARAM)m_titles[i].char_str());
+            rc = (APIRET)::WinSendMsg(m_hMenu, MM_INSERTITEM, (MPARAM)&(*it)->m_vMenuData, (MPARAM)m_titles[i].wx_str());
             if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
             {
                 vError = ::WinGetLastError(vHabmain);
@@ -879,7 +879,7 @@ void wxMenuBar::SetLabelTop(
     }
     nId = vItem.id;
 
-    if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT, MPFROMSHORT(nId), (MPARAM)rLabel.char_str()));
+    if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT, MPFROMSHORT(nId), (MPARAM)rLabel.wx_str()));
     {
         wxLogLastError(wxT("ModifyMenu"));
     }
@@ -925,7 +925,7 @@ wxMenu* wxMenuBar::Replace(
     if (IsAttached())
     {
         ::WinSendMsg((HWND)m_hMenu, MM_REMOVEITEM, MPFROM2SHORT(nId, TRUE), (MPARAM)0);
-        ::WinSendMsg((HWND)m_hMenu, MM_INSERTITEM, (MPARAM)&pMenu->m_vMenuData, (MPARAM)sTitle.char_str());
+        ::WinSendMsg((HWND)m_hMenu, MM_INSERTITEM, (MPARAM)&pMenu->m_vMenuData, (MPARAM)sTitle.wx_str());
 
 #if wxUSE_ACCEL
         if (pMenuOld->HasAccels() || pMenu->HasAccels())
@@ -958,7 +958,7 @@ bool wxMenuBar::Insert( size_t          nPos,
         ::WinSendMsg( (HWND)m_hMenu
                      ,MM_INSERTITEM
                      ,(MPARAM)&pMenu->m_vMenuData
-                     ,(MPARAM)sTitle.char_str()
+                     ,(MPARAM)sTitle.wx_str()
                     );
 #if wxUSE_ACCEL
         if (pMenu->HasAccels())
@@ -990,7 +990,7 @@ bool wxMenuBar::Append( wxMenu* pMenu,
     if ( IsAttached() )
     {
         pMenu->m_vMenuData.iPosition = MIT_END;
-        ::WinSendMsg((HWND)m_hMenu, MM_INSERTITEM, (MPARAM)&pMenu->m_vMenuData, (MPARAM)sTitle.char_str());
+        ::WinSendMsg((HWND)m_hMenu, MM_INSERTITEM, (MPARAM)&pMenu->m_vMenuData, (MPARAM)sTitle.wx_str());
 #if wxUSE_ACCEL
         if (pMenu->HasAccels())
         {
diff --git a/src/os2/menuitem.cpp b/src/os2/menuitem.cpp
index f0b69b5f79..921cfd2cbe 100644
--- a/src/os2/menuitem.cpp
+++ b/src/os2/menuitem.cpp
@@ -427,7 +427,7 @@ void wxMenuItem::SetText( const wxString& rText )
 #endif  //owner drawn
         {
             uFlagsOld |= MIS_TEXT;
-            pData = m_text.char_str();
+            pData = (char*) m_text.wx_str();
         }
 
         //
diff --git a/src/os2/ownerdrw.cpp b/src/os2/ownerdrw.cpp
index 12790b51ce..d5d0db57c3 100644
--- a/src/os2/ownerdrw.cpp
+++ b/src/os2/ownerdrw.cpp
@@ -351,7 +351,7 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC,
     ::GpiCharStringAt( rDC.GetHPS()
                       ,&vPntStart
                       ,sFullString.length()
-                      ,sFullString.char_str()
+                      ,sFullString.wx_str()
                      );
     if (bFoundMnemonic)
     {
@@ -389,7 +389,7 @@ bool wxOwnerDrawn::OnDrawItem( wxDC& rDC,
         ::GpiCharStringAt( rDC.GetHPS()
                           ,&vPntStart
                           ,sAccel.length()
-                          ,sAccel.char_str()
+                          ,sAccel.wx_str()
                          );
     }
 
diff --git a/src/os2/textctrl.cpp b/src/os2/textctrl.cpp
index 24dca77ce6..1c7014d733 100644
--- a/src/os2/textctrl.cpp
+++ b/src/os2/textctrl.cpp
@@ -329,7 +329,8 @@ void wxTextCtrl::SetupColours()
 wxString wxTextCtrl::GetValue() const
 {
     wxString                        sStr = wxGetWindowText(GetHWND());
-    char*                           zStr = sStr.char_str();
+    wxCharBuffer                    buf(sStr.char_str());
+    char*                           zStr = buf.data();
 
     for ( ; *zStr; zStr++ )
     {
@@ -370,7 +371,7 @@ void wxTextCtrl::WriteText(
 )
 {
     if (m_bIsMLE)
-        ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM(rsValue.char_str()), MPARAM(0));
+        ::WinSendMsg(GetHwnd(), MLM_INSERT, MPARAM(rsValue.wx_str()), MPARAM(0));
     else
         ::WinSetWindowText(GetHwnd(), rsValue.c_str());
     AdjustSpaceLimit();
diff --git a/src/os2/utils.cpp b/src/os2/utils.cpp
index 7fb53b78a3..5576bc9b82 100644
--- a/src/os2/utils.cpp
+++ b/src/os2/utils.cpp
@@ -157,7 +157,7 @@ bool wxShell( const wxString& rCommand )
     SData.PgmName  = (char*)zShell;
 
     sInputs = _T("/C ") + rCommand;
-    SData.PgmInputs     = (BYTE*)sInputs.char_str();
+    SData.PgmInputs     = (BYTE*)sInputs.wx_str();
     SData.TermQ         = 0;
     SData.Environment   = 0;
     SData.InheritOpt    = SSF_INHERTOPT_SHELL;
diff --git a/src/os2/window.cpp b/src/os2/window.cpp
index 31fda2d2e4..44fdde685b 100644
--- a/src/os2/window.cpp
+++ b/src/os2/window.cpp
@@ -1673,7 +1673,6 @@ void wxWindowOS2::GetTextExtent( const wxString& rString,
     int         l;
     FONTMETRICS vFM; // metrics structure
     BOOL        bRc = FALSE;
-    char*       pStr;
     HPS         hPS;
 
     hPS = ::WinGetPS(GetHwnd());
@@ -1681,14 +1680,12 @@ void wxWindowOS2::GetTextExtent( const wxString& rString,
     l = rString.length();
     if (l > 0L)
     {
-        pStr = rString.char_str();
-
         //
         // In world coordinates.
         //
         bRc = ::GpiQueryTextBox( hPS,
                                  l,
-                                 pStr,
+                                 (char*) rString.wx_str(),
                                  TXTBOX_COUNT,// return maximum information
                                  avPoint      // array of coordinates points
                                 );
-- 
2.47.2