X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c67daf87774c71ae9f73af9969008af220e52a11..4dc2c3bbc5bc04b6239e14a7ec4e3ddc400a00bc:/samples/dialogs/dialogs.cpp diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 1c624e29bb..5b38a4085d 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -31,7 +31,9 @@ #include #include -#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW +#define wxTEST_GENERIC_DIALOGS_IN_MSW 0 + +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW #include #include #endif @@ -42,13 +44,13 @@ IMPLEMENT_APP(MyApp) MyCanvas *myCanvas = (MyCanvas *) NULL; -// A macro needed for some compilers (AIX) that need 'main' to be defined -// in the application itself. -IMPLEMENT_WXWIN_MAIN - // `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit(void) { +#if defined(__WXGTK__) && defined(wxUSE_UNICODE) + wxConvCurrent = &wxConvLocal; +#endif + m_canvasTextColour = wxColour("BLACK"); m_canvasFont = *wxNORMAL_FONT; @@ -60,14 +62,14 @@ bool MyApp::OnInit(void) file_menu->Append(DIALOGS_CHOOSE_COLOUR, "&Choose colour"); -#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW file_menu->Append(DIALOGS_CHOOSE_COLOUR_GENERIC, "Choose colour (&generic)"); #endif file_menu->AppendSeparator(); file_menu->Append(DIALOGS_CHOOSE_FONT, "Choose &font"); -#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW file_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, "Choose f&ont (generic)"); #endif @@ -78,11 +80,7 @@ bool MyApp::OnInit(void) file_menu->AppendSeparator(); file_menu->Append(DIALOGS_FILE_OPEN, "&Open file"); file_menu->Append(DIALOGS_FILE_SAVE, "Sa&ve file"); -#ifndef __WXGTK__ - // don't add a menu entry for something that isn't in wxGTK. It only - // confuses the user file_menu->Append(DIALOGS_DIR_CHOOSE, "&Choose a directory"); -#endif file_menu->AppendSeparator(); file_menu->Append(wxID_EXIT, "E&xit"); wxMenuBar *menu_bar = new wxMenuBar; @@ -127,7 +125,7 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) myCanvas->Clear(); myCanvas->Refresh(); } - dialog->Close(); + dialog->Destroy(); } void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) @@ -144,10 +142,10 @@ void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) wxGetApp().m_canvasTextColour = retData.GetColour(); myCanvas->Refresh(); } - dialog->Close(); + dialog->Destroy(); } -#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) { wxColourData data; @@ -168,7 +166,7 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) myCanvas->Clear(); myCanvas->Refresh(); } - dialog->Close(); + dialog->Destroy(); } void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) @@ -185,16 +183,19 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) wxGetApp().m_canvasTextColour = retData.GetColour(); myCanvas->Refresh(); } - dialog->Close(); + dialog->Destroy(); } #endif void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) ) { - wxMessageDialog dialog(this, "This is a message box\nA long, long string to test out the message box properly", + wxMessageDialog dialog(NULL, "This is a message box\nA long, long string to test out the message box properly", "Message box text", wxYES_NO|wxCANCEL); dialog.ShowModal(); + + ::wxMessageBox("MsgBox with a really long long string", + "this is the text", wxYES_NO|wxICON_EXCLAMATION); } void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event) ) @@ -232,7 +233,14 @@ void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) if (dialog.ShowModal() == wxID_OK) { - wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path"); + wxString info; + info.Printf(_T("Full file name: %s\n") + _T("Path: %s\n") + _T("Name: %s"), + dialog.GetPath().c_str(), + dialog.GetDirectory().c_str(), + dialog.GetFilename().c_str()); + wxMessageDialog dialog2(this, info, "Selected file"); dialog2.ShowModal(); } } @@ -245,8 +253,8 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) if (dialog.ShowModal() == wxID_OK) { - char buf[400]; - sprintf(buf, "%s, filter %d", (const char *)dialog.GetPath(), dialog.GetFilterIndex()); + wxChar buf[400]; + wxSprintf(buf, _T("%s, filter %d"), (const wxChar*)dialog.GetPath(), dialog.GetFilterIndex()); wxMessageDialog dialog2(this, wxString(buf), "Selected path"); dialog2.ShowModal(); } @@ -254,7 +262,6 @@ void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) { -#ifndef __WXGTK__ wxDirDialog dialog(this, "Testing directory picker", ""); if (dialog.ShowModal() == wxID_OK) @@ -262,7 +269,6 @@ void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path"); dialog2.ShowModal(); } -#endif } void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) ) @@ -292,7 +298,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen) EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave) EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose) -#if !defined(__WXMSW__) || USE_GENERIC_DIALOGS_IN_MSW +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW EVT_MENU(DIALOGS_CHOOSE_COLOUR_GENERIC, MyFrame::ChooseColourGeneric) EVT_MENU(DIALOGS_CHOOSE_FONT_GENERIC, MyFrame::ChooseFontGeneric) #endif