From b0c0a393c4027a46b83187ea1328949ca75971d0 Mon Sep 17 00:00:00 2001 From: David Elliott Date: Thu, 22 Jan 2004 07:29:54 +0000 Subject: [PATCH] Unicode build fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/notebook.h | 4 ++-- src/cocoa/app.mm | 4 ++-- src/cocoa/button.mm | 2 +- src/cocoa/choice.mm | 2 +- src/cocoa/dc.mm | 5 +++-- src/cocoa/font.cpp | 2 +- src/cocoa/menu.mm | 9 +++++---- src/cocoa/menuitem.mm | 3 ++- src/cocoa/stattext.mm | 3 ++- src/cocoa/textctrl.mm | 5 +++-- src/generic/notebook.cpp | 2 +- 11 files changed, 23 insertions(+), 18 deletions(-) diff --git a/include/wx/generic/notebook.h b/include/wx/generic/notebook.h index 467a27e58b..f55b0db48f 100644 --- a/include/wx/generic/notebook.h +++ b/include/wx/generic/notebook.h @@ -47,14 +47,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/src/cocoa/app.mm b/src/cocoa/app.mm index a499a3a0e6..2fe3e1874a 100644 --- a/src/cocoa/app.mm +++ b/src/cocoa/app.mm @@ -191,11 +191,11 @@ bool wxApp::Initialize(int& argc, wxChar **argv) if ( argc > 1 ) { static const wxChar *ARG_PSN = _T("-psn_"); - if ( wxStrncmp(argv[1], ARG_PSN, strlen(ARG_PSN)) == 0 ) + if ( wxStrncmp(argv[1], ARG_PSN, wxStrlen(ARG_PSN)) == 0 ) { // remove this argument --argc; - memmove(argv + 1, argv + 2, argc * sizeof(char *)); + memmove(argv + 1, argv + 2, argc * sizeof(wxChar *)); } } diff --git a/src/cocoa/button.mm b/src/cocoa/button.mm index c68e9596ed..f9d006b3a7 100644 --- a/src/cocoa/button.mm +++ b/src/cocoa/button.mm @@ -68,7 +68,7 @@ void wxButton::Cocoa_wxNSButtonAction(void) wxString wxButton::GetLabel() const { - return wxString([[GetNSButton() title] lossyCString]); + return wxStringWithNSString([GetNSButton() title]); } void wxButton::SetLabel(const wxString& label) diff --git a/src/cocoa/choice.mm b/src/cocoa/choice.mm index 3127f87a8c..3840e0994b 100644 --- a/src/cocoa/choice.mm +++ b/src/cocoa/choice.mm @@ -145,7 +145,7 @@ int wxChoice::GetCount() const wxString wxChoice::GetString(int n) const { - return wxString([[(NSPopUpButton*)m_cocoaNSView itemTitleAtIndex:n] lossyCString]); + return wxStringWithNSString([(NSPopUpButton*)m_cocoaNSView itemTitleAtIndex:n]); } void wxChoice::SetString(int n, const wxString& title) diff --git a/src/cocoa/dc.mm b/src/cocoa/dc.mm index 55be845f80..660658dadc 100644 --- a/src/cocoa/dc.mm +++ b/src/cocoa/dc.mm @@ -16,6 +16,7 @@ #endif //WX_PRECOMP #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" #import #import @@ -207,7 +208,7 @@ void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord // FIXME: Cache this so it can be used for DoDrawText wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!")); NSAttributedString *attributedString = [[NSAttributedString alloc] - initWithString:[NSString stringWithCString:text.c_str()]]; + initWithString:wxNSStringWithWxString(text.c_str())]; [sm_cocoaNSTextStorage setAttributedString:attributedString]; [attributedString release]; @@ -228,7 +229,7 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) if(!CocoaTakeFocus()) return; wxASSERT_MSG(sm_cocoaNSTextStorage && sm_cocoaNSLayoutManager && sm_cocoaNSTextContainer, wxT("Text system has not been initialized. BAD PROGRAMMER!")); NSAttributedString *attributedString = [[NSAttributedString alloc] - initWithString:[NSString stringWithCString:text.c_str()]]; + initWithString:wxNSStringWithWxString(text.c_str())]; [sm_cocoaNSTextStorage setAttributedString:attributedString]; [attributedString release]; diff --git a/src/cocoa/font.cpp b/src/cocoa/font.cpp index 6a14f5022f..7133060f8f 100644 --- a/src/cocoa/font.cpp +++ b/src/cocoa/font.cpp @@ -189,7 +189,7 @@ void wxFont::SetUnderlined(bool underlined) /* New font system */ wxString wxFont::GetFaceName() const { - wxString str(""); + wxString str; if (M_FONTDATA) str = M_FONTDATA->m_faceName ; return str; diff --git a/src/cocoa/menu.mm b/src/cocoa/menu.mm index 666001f5ce..ae88841c86 100644 --- a/src/cocoa/menu.mm +++ b/src/cocoa/menu.mm @@ -24,6 +24,7 @@ #endif // WX_PRECOMP #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" #import #import @@ -43,7 +44,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler) bool wxMenu::Create(const wxString& title, long style) { wxAutoNSAutoreleasePool pool; - m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: [NSString stringWithCString: title.c_str()]]; + m_cocoaNSMenu = [[NSMenu alloc] initWithTitle: wxNSStringWithWxString(title)]; return true; } @@ -110,7 +111,7 @@ bool wxMenuBar::Append( wxMenu *menu, const wxString &title ) return false; wxASSERT(menu); wxASSERT(menu->GetNSMenu()); - NSString *menuTitle = [[NSString alloc] initWithCString: wxStripMenuCodes(title).c_str()]; + NSString *menuTitle = wxInitNSStringWithWxString([NSString alloc], wxStripMenuCodes(title)); NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:NULL keyEquivalent:@""]; [menu->GetNSMenu() setTitle:menuTitle]; [newItem setSubmenu:menu->GetNSMenu()]; @@ -132,7 +133,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) return false; wxASSERT(menu); wxASSERT(menu->GetNSMenu()); - NSString *menuTitle = [[NSString alloc] initWithCString: title.c_str()]; + NSString *menuTitle = wxInitNSStringWithWxString([NSString alloc], title); NSMenuItem *newItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:NULL keyEquivalent:@""]; [menu->GetNSMenu() setTitle:menuTitle]; [newItem setSubmenu:menu->GetNSMenu()]; @@ -180,7 +181,7 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const wxMenu *menu = GetMenu(pos); int itemindex = [m_cocoaNSMenu indexOfItemWithSubmenu:menu->GetNSMenu()]; wxASSERT(itemindex>=0); - return wxString([[[m_cocoaNSMenu itemAtIndex:itemindex] title] lossyCString]); + return wxStringWithNSString([[m_cocoaNSMenu itemAtIndex:itemindex] title]); } void wxMenuBar::Attach(wxFrame *frame) diff --git a/src/cocoa/menuitem.mm b/src/cocoa/menuitem.mm index eb2c412503..a8795fe053 100644 --- a/src/cocoa/menuitem.mm +++ b/src/cocoa/menuitem.mm @@ -28,6 +28,7 @@ #include "wx/cocoa/ObjcPose.h" #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" #import #import @@ -134,7 +135,7 @@ wxMenuItemCocoa::wxMenuItemCocoa(wxMenu *pParentMenu, : wxMenuItemBase(pParentMenu, itemid, strName, strHelp, kind, pSubMenu) { wxAutoNSAutoreleasePool pool; - NSString *menuTitle = [[NSString alloc] initWithCString: wxStripMenuCodes(strName).c_str()]; + NSString *menuTitle = wxInitNSStringWithWxString([NSString alloc],wxStripMenuCodes(strName)); m_cocoaNSMenuItem = [[NSMenuItem alloc] initWithTitle:menuTitle action:@selector(wxMenuItemAction:) keyEquivalent:@""]; sm_cocoaHash.insert(wxMenuItemCocoaHash::value_type(m_cocoaNSMenuItem,this)); [m_cocoaNSMenuItem setTarget:sm_cocoaTarget]; diff --git a/src/cocoa/stattext.mm b/src/cocoa/stattext.mm index 20ccf8ce47..ff04f5899a 100644 --- a/src/cocoa/stattext.mm +++ b/src/cocoa/stattext.mm @@ -16,6 +16,7 @@ #endif //WX_PRECOMP #include "wx/cocoa/autorelease.h" +#include "wx/cocoa/string.h" #import #import @@ -39,7 +40,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID winid, m_cocoaNSView = NULL; SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); [m_cocoaNSView release]; - [GetNSTextField() setStringValue:[NSString stringWithCString:label.c_str()]]; + [GetNSTextField() setStringValue:wxNSStringWithWxString(label)]; // [GetNSTextField() setBordered: NO]; [GetNSTextField() setBezeled: NO]; [GetNSTextField() setEditable: NO]; diff --git a/src/cocoa/textctrl.mm b/src/cocoa/textctrl.mm index 1d858a32b0..6ead7fdd43 100644 --- a/src/cocoa/textctrl.mm +++ b/src/cocoa/textctrl.mm @@ -41,7 +41,8 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID winid, m_cocoaNSView = NULL; SetNSTextField([[NSTextField alloc] initWithFrame:MakeDefaultNSRect(size)]); [m_cocoaNSView release]; - [GetNSTextField() setStringValue:[NSString stringWithCString:value.c_str()]]; + [GetNSTextField() setStringValue:wxNSStringWithWxString(value)]; + [GetNSControl() sizeToFit]; NSRect currentFrame = [m_cocoaNSView frame]; if(currentFrame.size.width < 70) @@ -200,6 +201,6 @@ bool wxTextCtrl::CanUndo() const wxString wxTextCtrl::GetValue() const { wxAutoNSAutoreleasePool pool; - return wxString([[GetNSTextField() stringValue] lossyCString]); + return wxStringWithNSString([GetNSTextField() stringValue]); } diff --git a/src/generic/notebook.cpp b/src/generic/notebook.cpp index f6462ae8a4..756369436e 100644 --- a/src/generic/notebook.cpp +++ b/src/generic/notebook.cpp @@ -600,7 +600,7 @@ bool wxNotebook::DoPhase(int /* nPhase */) void wxNotebook::Command(wxCommandEvent& WXUNUSED(event)) { - wxFAIL_MSG("wxNotebook::Command not implemented"); + wxFAIL_MSG(wxT("wxNotebook::Command not implemented")); } // ---------------------------------------------------------------------------- -- 2.45.2