1. some DDE tests in exec
2. per-page images test in wizard 3. wxLog dialog test in dialogs git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5559 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -32,12 +32,13 @@
|
|||||||
//#define TEST_ARRAYS
|
//#define TEST_ARRAYS
|
||||||
//#define TEST_CMDLINE
|
//#define TEST_CMDLINE
|
||||||
//#define TEST_DIR
|
//#define TEST_DIR
|
||||||
|
#define TEST_EXECUTE
|
||||||
//#define TEST_LOG
|
//#define TEST_LOG
|
||||||
//#define TEST_LONGLONG
|
//#define TEST_LONGLONG
|
||||||
//#define TEST_MIME
|
//#define TEST_MIME
|
||||||
//#define TEST_STRINGS
|
//#define TEST_STRINGS
|
||||||
//#define TEST_THREADS
|
//#define TEST_THREADS
|
||||||
#define TEST_TIME
|
//#define TEST_TIME
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
@@ -160,6 +161,34 @@ static void TestDirEnum()
|
|||||||
|
|
||||||
#endif // TEST_DIR
|
#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
|
// MIME types
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1851,6 +1880,10 @@ int main(int argc, char **argv)
|
|||||||
TestDirEnum();
|
TestDirEnum();
|
||||||
#endif // TEST_DIR
|
#endif // TEST_DIR
|
||||||
|
|
||||||
|
#ifdef TEST_EXECUTE
|
||||||
|
TestExecute();
|
||||||
|
#endif // TEST_EXECUTE
|
||||||
|
|
||||||
#ifdef TEST_LOG
|
#ifdef TEST_LOG
|
||||||
wxString s;
|
wxString s;
|
||||||
for ( size_t n = 0; n < 8000; n++ )
|
for ( size_t n = 0; n < 8000; n++ )
|
||||||
|
@@ -75,6 +75,7 @@ bool MyApp::OnInit(void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
file_menu->AppendSeparator();
|
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_MESSAGE_BOX, "&Message box\tCtrl-M");
|
||||||
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E");
|
file_menu->Append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E");
|
||||||
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
|
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
|
||||||
@@ -96,7 +97,7 @@ bool MyApp::OnInit(void)
|
|||||||
myCanvas->SetBackgroundColour(*wxWHITE);
|
myCanvas->SetBackgroundColour(*wxWHITE);
|
||||||
|
|
||||||
frame->Centre(wxBOTH);
|
frame->Centre(wxBOTH);
|
||||||
|
|
||||||
// Show the frame
|
// Show the frame
|
||||||
frame->Show(TRUE);
|
frame->Show(TRUE);
|
||||||
|
|
||||||
@@ -119,7 +120,7 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
|
|||||||
wxColour colour(i*16, i*16, i*16);
|
wxColour colour(i*16, i*16, i*16);
|
||||||
data.SetCustomColour(i, colour);
|
data.SetCustomColour(i, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxColourDialog *dialog = new wxColourDialog(this, &data);
|
wxColourDialog *dialog = new wxColourDialog(this, &data);
|
||||||
if (dialog->ShowModal() == wxID_OK)
|
if (dialog->ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
@@ -138,7 +139,7 @@ void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
|
|||||||
wxFontData data;
|
wxFontData data;
|
||||||
data.SetInitialFont(wxGetApp().m_canvasFont);
|
data.SetInitialFont(wxGetApp().m_canvasFont);
|
||||||
data.SetColour(wxGetApp().m_canvasTextColour);
|
data.SetColour(wxGetApp().m_canvasTextColour);
|
||||||
|
|
||||||
wxFontDialog *dialog = new wxFontDialog(this, &data);
|
wxFontDialog *dialog = new wxFontDialog(this, &data);
|
||||||
if (dialog->ShowModal() == wxID_OK)
|
if (dialog->ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
@@ -160,7 +161,7 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
|
|||||||
wxColour colour(i*16, i*16, i*16);
|
wxColour colour(i*16, i*16, i*16);
|
||||||
data.SetCustomColour(i, colour);
|
data.SetCustomColour(i, colour);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &data);
|
wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &data);
|
||||||
if (dialog->ShowModal() == wxID_OK)
|
if (dialog->ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
@@ -190,7 +191,16 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
|
|||||||
}
|
}
|
||||||
dialog->Destroy();
|
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) )
|
void MyFrame::MessageBox(wxCommandEvent& WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
@@ -204,7 +214,7 @@ void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) )
|
|||||||
{
|
{
|
||||||
long res = wxGetNumberFromUser( "This is some text, actually a lot of text.\n"
|
long res = wxGetNumberFromUser( "This is some text, actually a lot of text.\n"
|
||||||
"Even two rows of text.",
|
"Even two rows of text.",
|
||||||
"Enter a number:", "Numeric input test",
|
"Enter a number:", "Numeric input test",
|
||||||
50, 0, 100, this );
|
50, 0, 100, this );
|
||||||
|
|
||||||
wxString msg;
|
wxString msg;
|
||||||
@@ -215,8 +225,8 @@ void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) )
|
|||||||
icon = wxICON_HAND;
|
icon = wxICON_HAND;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg.Printf(_T("You've entered %lu"), res );
|
msg.Printf(_T("You've entered %lu"), res );
|
||||||
icon = wxICON_INFORMATION;
|
icon = wxICON_INFORMATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,6 +388,7 @@ END_EVENT_TABLE()
|
|||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
|
EVT_MENU(DIALOGS_CHOOSE_COLOUR, MyFrame::ChooseColour)
|
||||||
EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
|
EVT_MENU(DIALOGS_CHOOSE_FONT, MyFrame::ChooseFont)
|
||||||
|
EVT_MENU(DIALOGS_LOG_DIALOG, MyFrame::LogDialog)
|
||||||
EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
|
EVT_MENU(DIALOGS_MESSAGE_BOX, MyFrame::MessageBox)
|
||||||
EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
|
EVT_MENU(DIALOGS_TEXT_ENTRY, MyFrame::TextEntry)
|
||||||
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
|
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
|
||||||
|
@@ -31,6 +31,7 @@ public:
|
|||||||
|
|
||||||
void ChooseColour(wxCommandEvent& event);
|
void ChooseColour(wxCommandEvent& event);
|
||||||
void ChooseFont(wxCommandEvent& event);
|
void ChooseFont(wxCommandEvent& event);
|
||||||
|
void LogDialog(wxCommandEvent& event);
|
||||||
void MessageBox(wxCommandEvent& event);
|
void MessageBox(wxCommandEvent& event);
|
||||||
void SingleChoice(wxCommandEvent& event);
|
void SingleChoice(wxCommandEvent& event);
|
||||||
void TextEntry(wxCommandEvent& event);
|
void TextEntry(wxCommandEvent& event);
|
||||||
@@ -76,6 +77,7 @@ public:
|
|||||||
#define DIALOGS_DIR_CHOOSE 11
|
#define DIALOGS_DIR_CHOOSE 11
|
||||||
#define DIALOGS_TIP 12
|
#define DIALOGS_TIP 12
|
||||||
#define DIALOGS_NUM_ENTRY 13
|
#define DIALOGS_NUM_ENTRY 13
|
||||||
|
#define DIALOGS_LOG_DIALOG 14
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -42,6 +42,10 @@
|
|||||||
|
|
||||||
#include "wx/process.h"
|
#include "wx/process.h"
|
||||||
|
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
#include "wx/dde.h"
|
||||||
|
#endif // __WINDOWS__
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// private classes
|
// private classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -72,6 +76,7 @@ public:
|
|||||||
void OnSyncExec(wxCommandEvent& event);
|
void OnSyncExec(wxCommandEvent& event);
|
||||||
void OnAsyncExec(wxCommandEvent& event);
|
void OnAsyncExec(wxCommandEvent& event);
|
||||||
void OnShell(wxCommandEvent& event);
|
void OnShell(wxCommandEvent& event);
|
||||||
|
void OnDDEExec(wxCommandEvent& event);
|
||||||
|
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
|
|
||||||
@@ -114,9 +119,12 @@ enum
|
|||||||
Exec_SyncExec = 200,
|
Exec_SyncExec = 200,
|
||||||
Exec_AsyncExec,
|
Exec_AsyncExec,
|
||||||
Exec_Shell,
|
Exec_Shell,
|
||||||
|
Exec_DDEExec,
|
||||||
Exec_About = 300
|
Exec_About = 300
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const wxChar *DIALOG_TITLE = _T("Exec sample");
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// event tables and other macros for wxWindows
|
// event tables and other macros for wxWindows
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -130,6 +138,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(Exec_SyncExec, MyFrame::OnSyncExec)
|
EVT_MENU(Exec_SyncExec, MyFrame::OnSyncExec)
|
||||||
EVT_MENU(Exec_AsyncExec, MyFrame::OnAsyncExec)
|
EVT_MENU(Exec_AsyncExec, MyFrame::OnAsyncExec)
|
||||||
EVT_MENU(Exec_Shell, MyFrame::OnShell)
|
EVT_MENU(Exec_Shell, MyFrame::OnShell)
|
||||||
|
EVT_MENU(Exec_DDEExec, MyFrame::OnDDEExec)
|
||||||
|
|
||||||
EVT_MENU(Exec_About, MyFrame::OnAbout)
|
EVT_MENU(Exec_About, MyFrame::OnAbout)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
@@ -195,6 +204,11 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
execMenu->Append(Exec_Shell, _T("Execute &shell command...\tCtrl-S"),
|
execMenu->Append(Exec_Shell, _T("Execute &shell command...\tCtrl-S"),
|
||||||
_T("Launch a shell and execute a command in it"));
|
_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);
|
wxMenu *helpMenu = new wxMenu(_T(""), wxMENU_TEAROFF);
|
||||||
helpMenu->Append(Exec_About, _T("&About...\tF1"), _T("Show about dialog"));
|
helpMenu->Append(Exec_About, _T("&About...\tF1"), _T("Show about dialog"));
|
||||||
|
|
||||||
@@ -232,7 +246,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|||||||
void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
|
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
|
||||||
_T("Exec sample"),
|
DIALOG_TITLE,
|
||||||
m_cmdLast);
|
m_cmdLast);
|
||||||
|
|
||||||
if ( !cmd )
|
if ( !cmd )
|
||||||
@@ -247,7 +261,7 @@ void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
|
|||||||
void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
|
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
|
||||||
_T("Exec sample"),
|
DIALOG_TITLE,
|
||||||
m_cmdLast);
|
m_cmdLast);
|
||||||
|
|
||||||
if ( !cmd )
|
if ( !cmd )
|
||||||
@@ -269,7 +283,7 @@ void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
|
|||||||
void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
|
void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
|
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
|
||||||
_T("Exec sample"),
|
DIALOG_TITLE,
|
||||||
m_cmdLast);
|
m_cmdLast);
|
||||||
|
|
||||||
if ( !cmd )
|
if ( !cmd )
|
||||||
@@ -281,6 +295,48 @@ void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
|
|||||||
m_cmdLast = 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
|
// MyProcess
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -275,7 +275,9 @@ void MyFrame::Draw(wxDC& dc, bool WXUNUSED(draw_bitmaps) )
|
|||||||
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
|
dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
|
||||||
|
|
||||||
dc.DrawEllipse(250, 250, 100, 50);
|
dc.DrawEllipse(250, 250, 100, 50);
|
||||||
|
#if wxUSE_SPLINES
|
||||||
dc.DrawSpline(50, 200, 50, 100, 200, 10);
|
dc.DrawSpline(50, 200, 50, 100, 200, 10);
|
||||||
|
#endif // wxUSE_SPLINES
|
||||||
dc.DrawLine(50, 230, 200, 230);
|
dc.DrawLine(50, 230, 200, 230);
|
||||||
|
|
||||||
dc.SetPen(* wxBLACK_PEN);
|
dc.SetPen(* wxBLACK_PEN);
|
||||||
|
@@ -99,7 +99,8 @@ void MyApp::InitTabView(wxNotebook* notebook, wxPanel* window)
|
|||||||
|
|
||||||
wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" };
|
wxString animals[] = { "Fox", "Hare", "Rabbit", "Sabre-toothed tiger", "T Rex" };
|
||||||
wxRadioBox *radiobox = new wxRadioBox(panel2, -1, "Choose one",
|
wxRadioBox *radiobox = new wxRadioBox(panel2, -1, "Choose one",
|
||||||
wxDefaultPosition, wxDefaultSize, 5, animals);
|
wxDefaultPosition, wxDefaultSize, 5, animals,
|
||||||
|
2, wxRA_SPECIFY_ROWS);
|
||||||
|
|
||||||
c = new wxLayoutConstraints;
|
c = new wxLayoutConstraints;
|
||||||
c->left.SameAs(panel2, wxLeft, 4);
|
c->left.SameAs(panel2, wxLeft, 4);
|
||||||
|
@@ -41,6 +41,30 @@
|
|||||||
#include "wiztest.xpm"
|
#include "wiztest.xpm"
|
||||||
#endif
|
#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
|
// private classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -53,7 +77,22 @@ public:
|
|||||||
virtual bool OnInit();
|
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
|
// some pages for our wizard
|
||||||
@@ -63,11 +102,15 @@ IMPLEMENT_APP(MyApp)
|
|||||||
// overriding TransferDataFromWindow() - of course, in a real program, the
|
// overriding TransferDataFromWindow() - of course, in a real program, the
|
||||||
// check wouldn't be so trivial and the data will be probably saved somewhere
|
// check wouldn't be so trivial and the data will be probably saved somewhere
|
||||||
// too
|
// too
|
||||||
|
//
|
||||||
|
// it also shows how to use a different bitmap for one of the pages
|
||||||
class wxValidationPage : public wxWizardPageSimple
|
class wxValidationPage : public wxWizardPageSimple
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxValidationPage(wxWizard *parent) : wxWizardPageSimple(parent)
|
wxValidationPage(wxWizard *parent) : wxWizardPageSimple(parent)
|
||||||
{
|
{
|
||||||
|
m_bitmap = BMP_WIZARD_2;
|
||||||
|
|
||||||
m_checkbox = new wxCheckBox(this, -1, "&Check me");
|
m_checkbox = new wxCheckBox(this, -1, "&Check me");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,11 +228,25 @@ private:
|
|||||||
// implementation
|
// 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)
|
BEGIN_EVENT_TABLE(wxRadioboxPage, wxWizardPageSimple)
|
||||||
EVT_WIZARD_PAGE_CHANGING(-1, wxRadioboxPage::OnWizardPageChanging)
|
EVT_WIZARD_PAGE_CHANGING(-1, wxRadioboxPage::OnWizardPageChanging)
|
||||||
EVT_WIZARD_CANCEL(-1, wxRadioboxPage::OnWizardCancel)
|
EVT_WIZARD_CANCEL(-1, wxRadioboxPage::OnWizardCancel)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
IMPLEMENT_APP(MyApp)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// the application class
|
// the application class
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -197,15 +254,62 @@ END_EVENT_TABLE()
|
|||||||
// `Main program' equivalent: the program execution "starts" here
|
// `Main program' equivalent: the program execution "starts" here
|
||||||
bool MyApp::OnInit()
|
bool MyApp::OnInit()
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
MyFrame *frame = new MyFrame("wxWizard Sample");
|
||||||
wxBitmap bmpWizard("wiztest.bmp", wxBITMAP_TYPE_BMP);
|
|
||||||
#else
|
|
||||||
wxBitmap bmpWizard(wizimage);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxWizard *wizard = wxWizard::Create(NULL, -1,
|
// 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");
|
||||||
|
|
||||||
|
// ... 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"
|
||||||
|
"<EFBFBD> 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",
|
"Absolutely Useless Wizard",
|
||||||
bmpWizard);
|
BMP_WIZARD_1);
|
||||||
|
|
||||||
// a wizard page may be either an object of predefined class
|
// a wizard page may be either an object of predefined class
|
||||||
wxWizardPageSimple *page1 = new wxWizardPageSimple(wizard);
|
wxWizardPageSimple *page1 = new wxWizardPageSimple(wizard);
|
||||||
@@ -237,8 +341,9 @@ bool MyApp::OnInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
wizard->Destroy();
|
wizard->Destroy();
|
||||||
|
|
||||||
// we're done
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MyFrame::OnWizardCancel(wxWizardEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxLogStatus(this, "The wizard was cancelled.");
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user