//#define TEST_ARRAYS
//#define TEST_CMDLINE
//#define TEST_DIR
+#define TEST_EXECUTE
//#define TEST_LOG
//#define TEST_LONGLONG
//#define TEST_MIME
//#define TEST_STRINGS
//#define TEST_THREADS
-#define TEST_TIME
+//#define TEST_TIME
// ============================================================================
// implementation
#endif // TEST_DIR
+// ----------------------------------------------------------------------------
+// wxExecute
+// ----------------------------------------------------------------------------
+
+#ifdef TEST_EXECUTE
+
+#include <wx/utils.h>
+
+static void TestExecute()
+{
+ puts("*** testing wxExecute ***");
+
+#ifdef __UNIX__
+ #define COMMAND "echo hi"
+#elif defined(__WXMSW__)
+ #define COMMAND "command.com -c 'echo hi'"
+#else
+ #error "no command to exec"
+#endif // OS
+
+ if ( wxExecute(COMMAND) == 0 )
+ puts("\nOk.");
+ else
+ puts("\nError.");
+}
+
+#endif // TEST_EXECUTE
+
// ----------------------------------------------------------------------------
// MIME types
// ----------------------------------------------------------------------------
TestDirEnum();
#endif // TEST_DIR
+#ifdef TEST_EXECUTE
+ TestExecute();
+#endif // TEST_EXECUTE
+
#ifdef TEST_LOG
wxString s;
for ( size_t n = 0; n < 8000; n++ )
#endif
file_menu->AppendSeparator();
+ file_menu->Append(DIALOGS_LOG_DIALOG, "&Log dialog\tCtrl-L");
file_menu->Append(DIALOGS_MESSAGE_BOX, "&Message box\tCtrl-M");
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E");
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
myCanvas->SetBackgroundColour(*wxWHITE);
frame->Centre(wxBOTH);
-
+
// Show the frame
frame->Show(TRUE);
wxColour colour(i*16, i*16, i*16);
data.SetCustomColour(i, colour);
}
-
+
wxColourDialog *dialog = new wxColourDialog(this, &data);
if (dialog->ShowModal() == wxID_OK)
{
wxFontData data;
data.SetInitialFont(wxGetApp().m_canvasFont);
data.SetColour(wxGetApp().m_canvasTextColour);
-
+
wxFontDialog *dialog = new wxFontDialog(this, &data);
if (dialog->ShowModal() == wxID_OK)
{
wxColour colour(i*16, i*16, i*16);
data.SetCustomColour(i, colour);
}
-
+
wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &data);
if (dialog->ShowModal() == wxID_OK)
{
}
dialog->Destroy();
}
-#endif
+#endif // wxTEST_GENERIC_DIALOGS_IN_MSW
+
+void MyFrame::LogDialog(wxCommandEvent& event)
+{
+ wxLogMessage("This is some message - everything is ok so far.");
+ wxLogMessage("Another message...");
+ wxLogWarning("And then something went wrong!");
+ wxLogError("Intermediary error handler decided to abort.");
+ wxLogError("The top level caller detected an error.");
+}
void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
{
{
long res = wxGetNumberFromUser( "This is some text, actually a lot of text.\n"
"Even two rows of text.",
- "Enter a number:", "Numeric input test",
+ "Enter a number:", "Numeric input test",
50, 0, 100, this );
wxString msg;
icon = wxICON_HAND;
}
else
- {
- msg.Printf(_T("You've entered %lu"), res );
+ {
+ msg.Printf(_T("You've entered %lu"), res );
icon = wxICON_INFORMATION;
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
+ EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
void ChooseColour(wxCommandEvent& event);
void ChooseFont(wxCommandEvent& event);
+ void LogDialog(wxCommandEvent& event);
void MessageBox(wxCommandEvent& event);
void SingleChoice(wxCommandEvent& event);
void TextEntry(wxCommandEvent& event);
#define DIALOGS_DIR_CHOOSE 11
#define DIALOGS_TIP 12
#define DIALOGS_NUM_ENTRY 13
+#define DIALOGS_LOG_DIALOG 14
#endif
#include "wx/process.h"
+#ifdef __WINDOWS__
+ #include "wx/dde.h"
+#endif // __WINDOWS__
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
void OnSyncExec(wxCommandEvent& event);
void OnAsyncExec(wxCommandEvent& event);
void OnShell(wxCommandEvent& event);
+ void OnDDEExec(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
Exec_SyncExec = 200,
Exec_AsyncExec,
Exec_Shell,
+ Exec_DDEExec,
Exec_About = 300
};
+static const wxChar *DIALOG_TITLE = _T("Exec sample");
+
// ----------------------------------------------------------------------------
// event tables and other macros for wxWindows
// ----------------------------------------------------------------------------
EVT_MENU(Exec_SyncExec, MyFrame::OnSyncExec)
EVT_MENU(Exec_AsyncExec, MyFrame::OnAsyncExec)
EVT_MENU(Exec_Shell, MyFrame::OnShell)
+ EVT_MENU(Exec_DDEExec, MyFrame::OnDDEExec)
EVT_MENU(Exec_About, MyFrame::OnAbout)
END_EVENT_TABLE()
execMenu->Append(Exec_Shell, _T("Execute &shell command...\tCtrl-S"),
_T("Launch a shell and execute a command in it"));
+#ifdef __WINDOWS__
+ execMenu->AppendSeparator();
+ execMenu->Append(Exec_DDEExec, _T("Execute command via &DDE...\tCtrl-D"));
+#endif
+
wxMenu *helpMenu = new wxMenu(_T(""), wxMENU_TEAROFF);
helpMenu->Append(Exec_About, _T("&About...\tF1"), _T("Show about dialog"));
void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
- _T("Exec sample"),
+ DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
- _T("Exec sample"),
+ DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
- _T("Exec sample"),
+ DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
m_cmdLast = cmd;
}
+void MyFrame::OnDDEExec(wxCommandEvent& WXUNUSED(event))
+{
+#ifdef __WINDOWS__
+ wxString server = wxGetTextFromUser(_T("Server to connect to:"),
+ DIALOG_TITLE, _T("IExplore"));
+ if ( !server )
+ return;
+
+ wxString topic = wxGetTextFromUser(_T("DDE topic:"),
+ DIALOG_TITLE, _T("WWW_OpenURL"));
+ if ( !topic )
+ return;
+
+ wxString cmd = wxGetTextFromUser(_T("DDE command:"),
+ DIALOG_TITLE,
+ _T("\"file:F:\\wxWindows\\samples\\"
+ "image\\horse.gif\",,-1,,,,,"));
+ if ( !cmd )
+ return;
+
+ wxDDEClient client;
+ wxConnectionBase *conn = client.MakeConnection("", server, topic);
+ if ( !conn )
+ {
+ wxLogError(_T("Failed to connect to the DDE server '%s'."),
+ server.c_str());
+ }
+ else
+ {
+ if ( !conn->Execute(cmd) )
+ {
+ wxLogError(_T("Failed to execute command '%s' via DDE."),
+ cmd.c_str());
+ }
+ else
+ {
+ wxLogStatus(_T("Successfully executed DDE command"));
+ }
+ }
+#endif // __WINDOWS__
+}
+
// ----------------------------------------------------------------------------
// MyProcess
// ----------------------------------------------------------------------------
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
dc.DrawEllipse(250, 250, 100, 50);
+#if wxUSE_SPLINES
dc.DrawSpline(50, 200, 50, 100, 200, 10);
+#endif // wxUSE_SPLINES
dc.DrawLine(50, 230, 200, 230);
dc.SetPen(* wxBLACK_PEN);
wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" };
wxRadioBox *radiobox = new wxRadioBox(panel2, -1, "Choose one",
- wxDefaultPosition, wxDefaultSize, 5, animals);
+ wxDefaultPosition, wxDefaultSize, 5, animals,
+ 2, wxRA_SPECIFY_ROWS);
c = new wxLayoutConstraints;
c->left.SameAs(panel2, wxLeft, 4);
#include "wiztest.xpm"
#endif
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// ids for menu items
+enum
+{
+ Wizard_Quit = 100,
+ Wizard_Run,
+ Wizard_About = 1000
+};
+
+// ----------------------------------------------------------------------------
+// ressources
+// ----------------------------------------------------------------------------
+
+#ifdef __WXMSW__
+ #define BMP_WIZARD_1 wxBitmap("wiztest.bmp", wxBITMAP_TYPE_BMP)
+ #define BMP_WIZARD_2 wxBitmap("wiztest2.bmp", wxBITMAP_TYPE_BMP)
+#else
+ #define BMP_WIZARD_1 wxBitmap(wizimage)
+ #define BMP_WIZARD_2 wxBitmap(wizimage)
+#endif
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
virtual bool OnInit();
};
-IMPLEMENT_APP(MyApp)
+class MyFrame : public wxFrame
+{
+public:
+ // ctor(s)
+ MyFrame(const wxString& title);
+
+ // event handlers (these functions should _not_ be virtual)
+ void OnQuit(wxCommandEvent& event);
+ void OnAbout(wxCommandEvent& event);
+ void OnRunWizard(wxCommandEvent& event);
+ void OnWizardCancel(wxWizardEvent& event);
+
+private:
+ // any class wishing to process wxWindows events must use this macro
+ DECLARE_EVENT_TABLE()
+};
// ----------------------------------------------------------------------------
// some pages for our wizard
// overriding TransferDataFromWindow() - of course, in a real program, the
// check wouldn't be so trivial and the data will be probably saved somewhere
// too
+//
+// it also shows how to use a different bitmap for one of the pages
class wxValidationPage : public wxWizardPageSimple
{
public:
wxValidationPage(wxWizard *parent) : wxWizardPageSimple(parent)
{
+ m_bitmap = BMP_WIZARD_2;
+
m_checkbox = new wxCheckBox(this, -1, "&Check me");
}
// implementation
// ============================================================================
+// ----------------------------------------------------------------------------
+// event tables and such
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ EVT_MENU(Wizard_Quit, MyFrame::OnQuit)
+ EVT_MENU(Wizard_About, MyFrame::OnAbout)
+ EVT_MENU(Wizard_Run, MyFrame::OnRunWizard)
+
+ EVT_WIZARD_CANCEL(-1, MyFrame::OnWizardCancel)
+END_EVENT_TABLE()
+
BEGIN_EVENT_TABLE(wxRadioboxPage, wxWizardPageSimple)
EVT_WIZARD_PAGE_CHANGING(-1, wxRadioboxPage::OnWizardPageChanging)
EVT_WIZARD_CANCEL(-1, wxRadioboxPage::OnWizardCancel)
END_EVENT_TABLE()
+IMPLEMENT_APP(MyApp)
+
// ----------------------------------------------------------------------------
// the application class
// ----------------------------------------------------------------------------
// `Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
-#ifdef __WXMSW__
- wxBitmap bmpWizard("wiztest.bmp", wxBITMAP_TYPE_BMP);
-#else
- wxBitmap bmpWizard(wizimage);
-#endif
+ MyFrame *frame = new MyFrame("wxWizard Sample");
+
+ // and show it (the frames, unlike simple controls, are not shown when
+ // created initially)
+ frame->Show(TRUE);
+
+ // we're done
+ return TRUE;
+}
+
+// ----------------------------------------------------------------------------
+// MyFrame
+// ----------------------------------------------------------------------------
+
+MyFrame::MyFrame(const wxString& title)
+ : wxFrame((wxFrame *)NULL, -1, title,
+ wxDefaultPosition, wxSize(250, 150)) // small frame
+{
+ wxMenu *menuFile = new wxMenu;
+ menuFile->Append(Wizard_Run, "&Run wizard...\tCtrl-R");
+ menuFile->AppendSeparator();
+ menuFile->Append(Wizard_Quit, "E&xit\tAlt-X", "Quit this program");
+
+ wxMenu *helpMenu = new wxMenu;
+ helpMenu->Append(Wizard_About, "&About...\tF1", "Show about dialog");
+
+ // now append the freshly created menu to the menu bar...
+ wxMenuBar *menuBar = new wxMenuBar();
+ menuBar->Append(menuFile, "&File");
+ menuBar->Append(helpMenu, "&Help");
- wxWizard *wizard = wxWizard::Create(NULL, -1,
+ // ... and attach this menu bar to the frame
+ SetMenuBar(menuBar);
+
+ // also create status bar which we use in OnWizardCancel
+ CreateStatusBar();
+}
+
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
+{
+ // TRUE is to force the frame to close
+ Close(TRUE);
+}
+
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+ wxMessageBox("Demo of wxWizard class\n"
+ "© 1999, 2000 Vadim Zeitlin",
+ "About wxWizard sample", wxOK | wxICON_INFORMATION, this);
+}
+
+void MyFrame::OnRunWizard(wxCommandEvent& WXUNUSED(event))
+{
+ wxWizard *wizard = wxWizard::Create(this, -1,
"Absolutely Useless Wizard",
- bmpWizard);
+ BMP_WIZARD_1);
// a wizard page may be either an object of predefined class
wxWizardPageSimple *page1 = new wxWizardPageSimple(wizard);
}
wizard->Destroy();
-
- // we're done
- return FALSE;
}
+void MyFrame::OnWizardCancel(wxWizardEvent& WXUNUSED(event))
+{
+ wxLogStatus(this, "The wizard was cancelled.");
+}