X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5315ebfaed37b056b5a3d1dc990c0014ee02db26..9513c5b609740c15322f2284e5e8b9609eeaa069:/samples/dialogs/dialogs.cpp?ds=sidebyside diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 026cfb9739..2441a60904 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -5,11 +5,11 @@ // Modified by: // Created: 04/01/98 // RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem +// Copyright: (c) Julian Smart // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(__APPLE__) #pragma implementation #pragma interface #endif @@ -25,6 +25,10 @@ #include "wx/wx.h" #endif +#ifdef __WXWINCE__ +#include "wx/msw/wince/time.h" +#endif + #include "wx/colordlg.h" #include "wx/filedlg.h" #include "wx/dirdlg.h" @@ -34,6 +38,7 @@ #include "wx/progdlg.h" #include "wx/fdrepdlg.h" #include "wx/busyinfo.h" +#include "wx/image.h" #define wxTEST_GENERIC_DIALOGS_IN_MSW 0 @@ -44,7 +49,7 @@ #define wxUSE_DIRDLGG 0 -#if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG +#if !(defined(__WXMSW__) || defined(__WXMAC__)) || wxUSE_DIRDLGG #include "wx/generic/dirdlgg.h" #endif @@ -119,6 +124,10 @@ MyCanvas *myCanvas = (MyCanvas *) NULL; // `Main program' equivalent, creating windows and returning main app frame bool MyApp::OnInit() { +#if wxUSE_IMAGE + wxInitAllImageHandlers(); +#endif + #if defined(__WXGTK__) && defined(wxUSE_UNICODE) wxConvCurrent = &wxConvLibc; #endif @@ -131,7 +140,7 @@ bool MyApp::OnInit() // Make a menubar wxMenu *file_menu = new wxMenu; - + file_menu->Append(DIALOGS_CHOOSE_COLOUR, _T("&Choose colour")); #if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW @@ -238,7 +247,7 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) wxColourData retData = dialog.GetColourData(); col = retData.GetColour(); myCanvas->SetBackgroundColour(col); - myCanvas->Clear(); + myCanvas->ClearBackground(); myCanvas->Refresh(); } } @@ -284,7 +293,7 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) wxColour col = retData.GetColour(); // wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID); myCanvas->SetBackgroundColour(col); - myCanvas->Clear(); + myCanvas->ClearBackground(); myCanvas->Refresh(); } dialog->Destroy(); @@ -308,7 +317,7 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) } #endif // wxTEST_GENERIC_DIALOGS_IN_MSW -void MyFrame::LogDialog(wxCommandEvent& event) +void MyFrame::LogDialog(wxCommandEvent& WXUNUSED(event)) { // calling wxYield() (as ~wxBusyCursor does) shouldn't result in messages // being flushed -- test it @@ -444,10 +453,11 @@ void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) ) if ( count ) { wxString msg; - msg.Printf(wxT("You selected %u items:\n"), count); + msg.Printf(wxT("You selected %u items:\n"), (unsigned)count); for ( size_t n = 0; n < count; n++ ) { - msg += wxString::Format(wxT("\t%u: %u (%s)\n"), n, selections[n], + msg += wxString::Format(wxT("\t%u: %u (%s)\n"), + (unsigned)n, (unsigned)selections[n], choices[selections[n]].c_str()); } wxLogMessage(msg); @@ -513,8 +523,14 @@ void MyFrame::FileOpen2(wxCommandEvent& WXUNUSED(event) ) void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) ) { + wxString wildcards = +#ifdef __WXMOTIF__ + _T("C++ files (*.cpp)|*.cpp"); +#else + _T("All files (*.*)|*.*|C++ files (*.h;*.cpp)|*.h;*.cpp"); +#endif wxFileDialog dialog(this, _T("Testing open multiple file dialog"), - _T(""), _T(""), wxFileSelectorDefaultWildcardStr, + _T(""), _T(""), wildcards, wxMULTIPLE); if (dialog.ShowModal() == wxID_OK) @@ -529,10 +545,12 @@ void MyFrame::FilesOpen(wxCommandEvent& WXUNUSED(event) ) for ( size_t n = 0; n < count; n++ ) { s.Printf(_T("File %d: %s (%s)\n"), - n, paths[n].c_str(), filenames[n].c_str()); + (int)n, paths[n].c_str(), filenames[n].c_str()); msg += s; } + s.Printf(_T("Filter index: %d"), dialog.GetFilterIndex()); + msg += s; wxMessageDialog dialog2(this, msg, _T("Selected files")); dialog2.ShowModal(); @@ -578,14 +596,14 @@ void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) ) { - DoDirChoose(wxDD_NEW_DIR_BUTTON); + DoDirChoose(wxDD_DEFAULT_STYLE | wxDD_NEW_DIR_BUTTON); } #if defined(__WXMSW__) || defined(__WXMAC__) void MyFrame::GenericDirChoose(wxCommandEvent& WXUNUSED(event) ) { -#if !defined(__WXMSW__) || defined(wxUSE_DIRDLGG) && wxUSE_DIRDLGG +#if !(defined(__WXMSW__) || defined(__WXMAC__)) || wxUSE_DIRDLGG // pass some initial dir to wxDirDialog wxString dirHome; wxGetHomeDir(&dirHome); @@ -630,7 +648,7 @@ void MyFrame::ModelessDlg(wxCommandEvent& event) } } -void MyFrame::ShowTip(wxCommandEvent& event) +void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event)) { #if wxUSE_STARTUP_TIPS static size_t s_index = (size_t)-1;