// 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
#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"
#include "wx/progdlg.h"
#include "wx/fdrepdlg.h"
#include "wx/busyinfo.h"
+#include "wx/image.h"
#define wxTEST_GENERIC_DIALOGS_IN_MSW 0
#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
EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
EVT_MENU(DIALOGS_FILE_SAVE, MyFrame::FileSave)
EVT_MENU(DIALOGS_DIR_CHOOSE, MyFrame::DirChoose)
+ EVT_MENU(DIALOGS_DIRNEW_CHOOSE, MyFrame::DirChooseNew)
#if defined(__WXMSW__) || defined(__WXMAC__)
EVT_MENU(DIALOGS_GENERIC_DIR_CHOOSE, MyFrame::GenericDirChoose)
#endif // wxMSW || wxMAC
// `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
// 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
#if defined(__WXMSW__) && wxTEST_GENERIC_DIALOGS_IN_MSW
file_menu->Append(DIALOGS_CHOOSE_FONT_GENERIC, _T("Choose f&ont (generic)"));
-
#endif
+
file_menu->AppendSeparator();
file_menu->Append(DIALOGS_LOG_DIALOG, _T("&Log dialog\tCtrl-L"));
file_menu->Append(DIALOGS_MESSAGE_BOX, _T("&Message box\tCtrl-M"));
file_menu->Append(DIALOGS_FILES_OPEN, _T("Open &files\tCtrl-Q"));
file_menu->Append(DIALOGS_FILE_SAVE, _T("Sa&ve file\tCtrl-S"));
file_menu->Append(DIALOGS_DIR_CHOOSE, _T("&Choose a directory\tCtrl-D"));
+ file_menu->Append(DIALOGS_DIRNEW_CHOOSE, _T("Choose a directory (with \"Ne&w\" button)\tShift-Ctrl-D"));
#if defined(__WXMSW__) || defined(__WXMAC__)
file_menu->Append(DIALOGS_GENERIC_DIR_CHOOSE, _T("&Choose a directory (generic implementation)"));
#endif // wxMSW || wxMAC
+ file_menu->AppendSeparator();
+
#if wxUSE_PROGRESSDLG
file_menu->Append(DIALOGS_PROGRESS, _T("Pro&gress dialog\tCtrl-G"));
#endif // wxUSE_PROGRESSDLG
file_menu->Append(DIALOGS_REPLACE, _T("Find and &replace dialog\tShift-Ctrl-F"), _T(""), TRUE);
#endif // wxUSE_FINDREPLDLG
file_menu->AppendSeparator();
+
file_menu->Append(DIALOGS_MODAL, _T("Mo&dal dialog\tCtrl-W"));
file_menu->Append(DIALOGS_MODELESS, _T("Modeless &dialog\tCtrl-Z"), _T(""), TRUE);
file_menu->AppendSeparator();
+
file_menu->Append(wxID_EXIT, _T("E&xit\tAlt-X"));
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _T("&File"));
wxColourData retData = dialog.GetColourData();
col = retData.GetColour();
myCanvas->SetBackgroundColour(col);
- myCanvas->Clear();
+ myCanvas->ClearBackground();
myCanvas->Refresh();
}
}
wxColour col = retData.GetColour();
// wxBrush *brush = wxTheBrushList->FindOrCreateBrush(&col, wxSOLID);
myCanvas->SetBackgroundColour(col);
- myCanvas->Clear();
+ myCanvas->ClearBackground();
myCanvas->Refresh();
}
dialog->Destroy();
}
#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
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);
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)
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();
}
}
-void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
+void MyFrame::DoDirChoose(int style)
{
// pass some initial dir to wxDirDialog
wxString dirHome;
wxGetHomeDir(&dirHome);
- wxDirDialog dialog(this, _T("Testing directory picker"), dirHome);
+ wxDirDialog dialog(this, _T("Testing directory picker"), dirHome, style);
if (dialog.ShowModal() == wxID_OK)
{
}
}
+void MyFrame::DirChoose(wxCommandEvent& WXUNUSED(event) )
+{
+ DoDirChoose(wxDD_DEFAULT_STYLE & ~wxDD_NEW_DIR_BUTTON);
+}
+
+void MyFrame::DirChooseNew(wxCommandEvent& WXUNUSED(event) )
+{
+ 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);
}
}
-void MyFrame::ShowTip(wxCommandEvent& event)
+void MyFrame::ShowTip(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_STARTUP_TIPS
static size_t s_index = (size_t)-1;
{
wxBoxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
- m_btnFocused = new wxButton(this, -1, _T("Default button"));
+ m_btnModal = new wxButton(this, -1, _T("&Modal dialog..."));
+ m_btnModeless = new wxButton(this, -1, _T("Mode&less dialog"));
m_btnDelete = new wxButton(this, -1, _T("&Delete button"));
+
wxButton *btnOk = new wxButton(this, wxID_CANCEL, _T("&Close"));
- sizerTop->Add(m_btnFocused, 0, wxALIGN_CENTER | wxALL, 5);
+ sizerTop->Add(m_btnModal, 0, wxALIGN_CENTER | wxALL, 5);
+ sizerTop->Add(m_btnModeless, 0, wxALIGN_CENTER | wxALL, 5);
sizerTop->Add(m_btnDelete, 0, wxALIGN_CENTER | wxALL, 5);
sizerTop->Add(btnOk, 0, wxALIGN_CENTER | wxALL, 5);
sizerTop->SetSizeHints(this);
sizerTop->Fit(this);
- m_btnFocused->SetFocus();
- m_btnFocused->SetDefault();
+ m_btnModal->SetFocus();
+ m_btnModal->SetDefault();
}
void MyModalDialog::OnButton(wxCommandEvent& event)
{
if ( event.GetEventObject() == m_btnDelete )
{
- delete m_btnFocused;
- m_btnFocused = NULL;
+ delete m_btnModal;
+ m_btnModal = NULL;
m_btnDelete->Disable();
}
- else if ( event.GetEventObject() == m_btnFocused )
+ else if ( event.GetEventObject() == m_btnModal )
{
wxGetTextFromUser(_T("Dummy prompt"),
_T("Modal dialog called from dialog"),
_T(""), this);
}
+ else if ( event.GetEventObject() == m_btnModeless )
+ {
+ (new MyModelessDialog(this))->Show();
+ }
else
{
event.Skip();