From: Vadim Zeitlin Date: Wed, 27 Mar 2002 18:45:20 +0000 (+0000) Subject: Unicode compilation fixes (patch from Dimitri) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f565a6c2f4c6961c96dd330a98d0fa78f20ca8c0?ds=inline Unicode compilation fixes (patch from Dimitri) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14822 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/dialup/nettest.cpp b/samples/dialup/nettest.cpp index 7e31dad045..bcf1d57aa1 100644 --- a/samples/dialup/nettest.cpp +++ b/samples/dialup/nettest.cpp @@ -256,10 +256,10 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { wxString msg; - msg.Printf(_T("This is the network functions test sample.\n" - "© 1999 Vadim Zeitlin")); + msg.Printf( wxT("This is the network functions test sample.\n") + wxT("© 1999 Vadim Zeitlin") ); - wxMessageBox(msg, _T("About NetTest"), wxOK | wxICON_INFORMATION, this); + wxMessageBox(msg, wxT("About NetTest"), wxOK | wxICON_INFORMATION, this); } void MyFrame::OnHangUp(wxCommandEvent& WXUNUSED(event)) diff --git a/samples/event/event.cpp b/samples/event/event.cpp index 1f63f7efd1..380cdd17bd 100644 --- a/samples/event/event.cpp +++ b/samples/event/event.cpp @@ -293,9 +293,9 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(_T("Event sample shows different ways of using events\n" - "© 2001 Vadim Zeitlin"), - _T("About Event Sample"), wxOK | wxICON_INFORMATION, this); + wxMessageBox( wxT("Event sample shows different ways of using events\n") + wxT("© 2001 Vadim Zeitlin"), + wxT("About Event Sample"), wxOK | wxICON_INFORMATION, this ); } // ---------------------------------------------------------------------------- @@ -304,9 +304,12 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnDynamic(wxCommandEvent& WXUNUSED(event)) { - wxMessageBox(_T("This is a dynamic event handler which can be connected " - "and disconnected during run-time."), - _T("Dynamic Event Handler"), wxOK | wxICON_INFORMATION, this); + wxMessageBox + ( + wxT("This is a dynamic event handler which can be connected ") + wxT("and disconnected at run-time."), + wxT("Dynamic Event Handler"), wxOK | wxICON_INFORMATION, this + ); } void MyFrame::OnConnect(wxCommandEvent& event) diff --git a/samples/resource/resource.cpp b/samples/resource/resource.cpp index 807c387fa1..e29236c867 100644 --- a/samples/resource/resource.cpp +++ b/samples/resource/resource.cpp @@ -24,6 +24,10 @@ #include "wx/wx.h" #endif +#if wxUSE_UNICODE + #error "This sample can't be compiled in Unicode mode." +#endif // wxUSE_UNICODE + #include "wx/resource.h" #include @@ -52,8 +56,8 @@ // Under Windows, some compilers can't include // a whole .wxr file. So we use a .rc user-defined resource // instead. dialog1 will point to the whole .wxr 'file'. -static char *dialog1 = NULL; -static char *menu1 = NULL; +static wxChar *dialog1 = NULL; +static wxChar *menu1 = NULL; #else // Other platforms should have sensible compilers that // cope with long strings. @@ -76,39 +80,42 @@ MyApp::MyApp() bool MyApp::OnInit(void) { #if defined(__WXMSW__) - // Load the .wxr 'file' from a .rc resource, under Windows. - dialog1 = wxLoadUserResource("dialog1", "WXRDATA"); - menu1 = wxLoadUserResource("menu1", "WXRDATA"); - // All resources in the file (only one in this case) get parsed - // by this call. - wxResourceParseString(dialog1); - wxResourceParseString(menu1); + // Load the .wxr 'file' from a .rc resource, under Windows. + dialog1 = wxLoadUserResource(wxT("dialog1"), wxT("WXRDATA")); + menu1 = wxLoadUserResource(wxT("menu1"), wxT("WXRDATA")); + // All resources in the file (only one in this case) get parsed + // by this call. + wxResourceParseString(dialog1); + wxResourceParseString(menu1); #else - // Simply parse the data pointed to by the variable dialog1. - // If there were several resources, there would be several - // variables, and this would need to be called several times. - wxResourceParseData(dialog1); - wxResourceParseData(menu1); + // Simply parse the data pointed to by the variable dialog1. + // If there were several resources, there would be several + // variables, and this would need to be called several times. + wxResourceParseData(dialog1); + wxResourceParseData(menu1); #endif - // Create the main frame window - frame = new MyFrame((wxFrame *) NULL, -1, (char *) "wxWindows Resource Sample", wxPoint(-1, -1), wxSize(300, 250)); + // Create the main frame window + frame = new MyFrame( (wxFrame *) NULL, -1, + (char *) "wxWindows Resource Sample", + wxPoint(-1, -1), wxSize(300, 250) ); + + // Give it a status line + frame->CreateStatusBar(2); - // Give it a status line - frame->CreateStatusBar(2); + wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1"); - wxMenuBar *menu_bar = wxResourceCreateMenuBar("menu1"); - - // Associate the menu bar with the frame - frame->SetMenuBar(menu_bar); + // Associate the menu bar with the frame + frame->SetMenuBar(menu_bar); - // Make a panel - frame->panel = new MyPanel(frame, -1, wxPoint(0, 0), wxSize(400, 400), 0, "MyMainFrame"); - frame->Show(TRUE); + // Make a panel + frame->panel = new MyPanel( frame, -1, wxPoint(0, 0), wxSize(400, 400), + 0, "MyMainFrame" ); + frame->Show(TRUE); - SetTopWindow(frame); + SetTopWindow(frame); - return TRUE; + return TRUE; } MyApp::~MyApp() @@ -123,17 +130,20 @@ BEGIN_EVENT_TABLE(MyPanel, wxPanel) EVT_LEFT_DOWN( MyPanel::OnClick) END_EVENT_TABLE() -MyPanel::MyPanel( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, - int style, const wxString &name ) : - wxPanel( parent, id, pos, size, style, name ) +MyPanel::MyPanel +( + wxWindow *parent, wxWindowID id, const wxPoint& pos, + const wxSize& size, + int style, const wxString &name +) : wxPanel( parent, id, pos, size, style, name ) { } void MyPanel::OnClick( wxMouseEvent &WXUNUSED(event2) ) { - MyFrame *frame = (MyFrame*)(wxTheApp->GetTopWindow()); - wxCommandEvent event; - frame->OnTestDialog( event ); + MyFrame *frame = (MyFrame*)(wxTheApp->GetTopWindow()); + wxCommandEvent event; + frame->OnTestDialog( event ); } @@ -144,10 +154,13 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) END_EVENT_TABLE() // Define my frame constructor -MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size): - wxFrame(parent, id, title, pos, size) +MyFrame::MyFrame +( + wxWindow *parent, const wxWindowID id, + const wxString& title, const wxPoint& pos, const wxSize& size +) : wxFrame(parent, id, title, pos, size) { - panel = (wxWindow *) NULL; + panel = (wxWindow *) NULL; } void MyFrame::OnAbout( wxCommandEvent& WXUNUSED(event) ) @@ -164,15 +177,20 @@ void MyFrame::OnQuit( wxCommandEvent& WXUNUSED(event) ) void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event) ) { - MyDialog *dialog = new MyDialog; - if (dialog->LoadFromResource(this, "dialog1")) - { + MyDialog *dialog = new MyDialog; + + if (dialog->LoadFromResource(this, "dialog1")) + { wxTextCtrl *text = (wxTextCtrl *)wxFindWindowByName("multitext3", dialog); if (text) - text->SetValue("wxWindows resource demo"); + { + text->SetValue("wxWindows resource demo"); + } + dialog->ShowModal(); - } - dialog->Close(TRUE); + } + + dialog->Close(TRUE); } BEGIN_EVENT_TABLE(MyDialog, wxDialog) @@ -183,12 +201,12 @@ END_EVENT_TABLE() void MyDialog::OnOk(wxCommandEvent& WXUNUSED(event) ) { - // EndModal(RESOURCE_OK); + // EndModal(RESOURCE_OK); } void MyDialog::OnCancel(wxCommandEvent& WXUNUSED(event) ) { - EndModal(ID_BUTTON109); + EndModal(ID_BUTTON109); } diff --git a/samples/richedit/wxLayout.cpp b/samples/richedit/wxLayout.cpp index 89fe57e094..796dd2a310 100644 --- a/samples/richedit/wxLayout.cpp +++ b/samples/richedit/wxLayout.cpp @@ -263,128 +263,145 @@ MyFrame::Clear(void) void MyFrame::OnCommand( wxCommandEvent &event ) { - switch (event.GetId()) - { - case ID_QUIT: - Close( TRUE ); - break; - case ID_PRINT: - { - wxPrinter printer; - wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout")); - if (! printer.Print(this, &printout, TRUE)) - wxMessageBox( - _("There was a problem with printing the message:\n" - "perhaps your current printer is not set up correctly?"), - _("Printing"), wxOK); - } - break; - case ID_NOWRAP: - case ID_WRAP: - m_lwin->SetWrapMargin(event.GetId() == ID_NOWRAP ? 0 : 40); - break; - case ID_ADD_SAMPLE: - AddSampleText(m_lwin->GetLayoutList()); - break; - case ID_CLEAR: - Clear(); - break; + switch (event.GetId()) + { + case ID_QUIT: + Close( TRUE ); + break; + case ID_PRINT: + { + wxPrinter printer; + wxLayoutPrintout printout(m_lwin->GetLayoutList(),_("M: Printout")); + if (! printer.Print(this, &printout, TRUE)) + { + // Had to remove the split up strings that used to be below, and + // put them into one long strong. Otherwise MSVC would give an + // error "C2308: concatenating mismatched wide strings" when + // building a Unicode version. + wxMessageBox + ( + _("There was a problem with printing the message:\nperhaps your current printer is not set up correctly?"), + _("Printing"), wxOK + ); + } + break; + } + + case ID_NOWRAP: + case ID_WRAP: + m_lwin->SetWrapMargin(event.GetId() == ID_NOWRAP ? 0 : 40); + break; + case ID_ADD_SAMPLE: + AddSampleText(m_lwin->GetLayoutList()); + break; + case ID_CLEAR: + Clear(); + break; case ID_CLICK: - cerr << "Received click event." << endl; - break; + cerr << "Received click event." << endl; + break; case ID_PASTE: - m_lwin->Paste(TRUE); - m_lwin->Refresh(FALSE); - break; + m_lwin->Paste(TRUE); + m_lwin->Refresh(FALSE); + break; #ifdef __WXGTK__ - case ID_PASTE_PRIMARY: - // text only from primary: - m_lwin->Paste(FALSE, TRUE); - m_lwin->Refresh(FALSE); - break; - case ID_COPY_PRIMARY: - // copy text-only to primary selection: - m_lwin->Copy(FALSE,FALSE,TRUE); - m_lwin->Refresh(FALSE); - break; + case ID_PASTE_PRIMARY: + // text only from primary: + m_lwin->Paste(FALSE, TRUE); + m_lwin->Refresh(FALSE); + break; + case ID_COPY_PRIMARY: + // copy text-only to primary selection: + m_lwin->Copy(FALSE,FALSE,TRUE); + m_lwin->Refresh(FALSE); + break; #endif - case ID_COPY: - m_lwin->Copy(TRUE,TRUE,FALSE); - m_lwin->Refresh(FALSE); - break; - case ID_CUT: - m_lwin->Cut(); - m_lwin->Refresh(FALSE); - break; + case ID_COPY: + m_lwin->Copy(TRUE,TRUE,FALSE); + m_lwin->Refresh(FALSE); + break; + case ID_CUT: + m_lwin->Cut(); + m_lwin->Refresh(FALSE); + break; #ifdef M_BASEDIR - case ID_FIND: - m_lwin->Find("void"); - m_lwin->Refresh(FALSE); - break; + case ID_FIND: + m_lwin->Find("void"); + m_lwin->Refresh(FALSE); + break; #endif - case ID_HTML: - { - wxLayoutExportObject *export0; - wxLayoutExportStatus status(m_lwin->GetLayoutList()); - - cout << "" << endl; - while((export0 = wxLayoutExport( &status, - WXLO_EXPORT_AS_HTML)) != NULL) - { - if(export0->type == WXLO_EXPORT_HTML) - cout << *(export0->content.text); - else - ; // ignore itcout << "