X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/457814b5aa2ee5c83abc65a6aee2a3ebcb1af34f..c67d86184d21b37d32c621bd45318d5818c3f864:/samples/dialogs/dialogs.cpp?ds=sidebyside diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 90b03d2131..7477d7de43 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -31,7 +31,9 @@ #include #include -#if !defined(__WINDOWS__) || USE_GENERIC_DIALOGS_IN_MSW +#define wxTEST_GENERIC_DIALOGS_IN_MSW 0 + +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW #include #include #endif @@ -40,7 +42,7 @@ IMPLEMENT_APP(MyApp) -MyCanvas *myCanvas = NULL; +MyCanvas *myCanvas = (MyCanvas *) NULL; // A macro needed for some compilers (AIX) that need 'main' to be defined // in the application itself. @@ -53,21 +55,21 @@ bool MyApp::OnInit(void) m_canvasFont = *wxNORMAL_FONT; // Create the main frame window - MyFrame *frame = new MyFrame(NULL, "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300)); + MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300)); // Make a menubar wxMenu *file_menu = new wxMenu; file_menu->Append(DIALOGS_CHOOSE_COLOUR, "&Choose colour"); -#if !defined(__WINDOWS__) || 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(__WINDOWS__) || 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,7 +80,11 @@ 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; @@ -103,7 +109,7 @@ MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos, co wxFrame(parent, -1, title, pos, size) {} -void MyFrame::ChooseColour(wxCommandEvent& event) +void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) ) { wxColourData data; data.SetChooseFull(TRUE); @@ -126,7 +132,7 @@ void MyFrame::ChooseColour(wxCommandEvent& event) dialog->Close(); } -void MyFrame::ChooseFont(wxCommandEvent& event) +void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) ) { wxFontData data; data.SetInitialFont(wxGetApp().m_canvasFont); @@ -143,8 +149,8 @@ void MyFrame::ChooseFont(wxCommandEvent& event) dialog->Close(); } -#if !defined(__WINDOWS__) || USE_GENERIC_DIALOGS_IN_MSW -void MyFrame::ChooseColourGeneric(wxCommandEvent& event) +#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW +void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event)) { wxColourData data; data.SetChooseFull(TRUE); @@ -167,7 +173,7 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& event) dialog->Close(); } -void MyFrame::ChooseFontGeneric(wxCommandEvent& event) +void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) ) { wxFontData data; data.SetInitialFont(wxGetApp().m_canvasFont); @@ -185,7 +191,7 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& event) } #endif -void MyFrame::MessageBox(wxCommandEvent& event) +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", "Message box text", wxYES_NO|wxCANCEL); @@ -193,7 +199,7 @@ void MyFrame::MessageBox(wxCommandEvent& event) dialog.ShowModal(); } -void MyFrame::TextEntry(wxCommandEvent& event) +void MyFrame::TextEntry(wxCommandEvent& WXUNUSED(event) ) { wxTextEntryDialog dialog(this, "This is a small sample\nA long, long string to test out the text entrybox", "Please enter a string", "Default value", wxOK|wxCANCEL); @@ -205,22 +211,24 @@ void MyFrame::TextEntry(wxCommandEvent& event) } } -void MyFrame::SingleChoice(wxCommandEvent& event) +void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) ) { - const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ; - int n = 5; + const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ; + int n = 5; - wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog", - "Please select a value", n, (const wxString *)choices); + wxSingleChoiceDialog dialog(this, "This is a small sample\nA single-choice convenience dialog", + "Please select a value", n, (const wxString *)choices); - if (dialog.ShowModal() == wxID_OK) - { - wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string"); - dialog2.ShowModal(); - } + dialog.SetSelection(2); + + if (dialog.ShowModal() == wxID_OK) + { + wxMessageDialog dialog2(this, dialog.GetStringSelection(), "Got string"); + dialog2.ShowModal(); + } } -void MyFrame::FileOpen(wxCommandEvent& event) +void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) ) { wxFileDialog dialog(this, "Testing open file dialog", "", "", "*.txt", 0); @@ -231,7 +239,7 @@ void MyFrame::FileOpen(wxCommandEvent& event) } } -void MyFrame::FileSave(wxCommandEvent& event) +void MyFrame::FileSave(wxCommandEvent& WXUNUSED(event) ) { wxFileDialog dialog(this, "Testing save file dialog", "", "", "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc", @@ -246,8 +254,9 @@ void MyFrame::FileSave(wxCommandEvent& event) } } -void MyFrame::DirChoose(wxCommandEvent& event) +void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) ) { +#ifndef __WXGTK__ wxDirDialog dialog(this, "Testing directory picker", ""); if (dialog.ShowModal() == wxID_OK) @@ -255,14 +264,15 @@ void MyFrame::DirChoose(wxCommandEvent& event) wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path"); dialog2.ShowModal(); } +#endif } -void MyFrame::OnExit(wxCommandEvent& event) +void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event) ) { Close(TRUE); } -void MyCanvas::OnPaint(wxPaintEvent& event) +void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event) ) { wxPaintDC dc(this); dc.SetFont(wxGetApp().m_canvasFont); @@ -284,7 +294,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(__WINDOWS__) || 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