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:
Vadim Zeitlin 2000-01-21 02:31:49 +00:00
parent f1df09276c
commit d93c719ac0
7 changed files with 234 additions and 24 deletions

View File

@ -32,12 +32,13 @@
//#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
@ -160,6 +161,34 @@ static void TestDirEnum()
#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
// ----------------------------------------------------------------------------
@ -1851,6 +1880,10 @@ int main(int argc, char **argv)
TestDirEnum();
#endif // TEST_DIR
#ifdef TEST_EXECUTE
TestExecute();
#endif // TEST_EXECUTE
#ifdef TEST_LOG
wxString s;
for ( size_t n = 0; n < 8000; n++ )

View File

@ -75,6 +75,7 @@ bool MyApp::OnInit(void)
#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");
@ -96,7 +97,7 @@ bool MyApp::OnInit(void)
myCanvas->SetBackgroundColour(*wxWHITE);
frame->Centre(wxBOTH);
// Show the frame
frame->Show(TRUE);
@ -119,7 +120,7 @@ void MyFrame::ChooseColour(wxCommandEvent& WXUNUSED(event) )
wxColour colour(i*16, i*16, i*16);
data.SetCustomColour(i, colour);
}
wxColourDialog *dialog = new wxColourDialog(this, &data);
if (dialog->ShowModal() == wxID_OK)
{
@ -138,7 +139,7 @@ void MyFrame::ChooseFont(wxCommandEvent& WXUNUSED(event) )
wxFontData data;
data.SetInitialFont(wxGetApp().m_canvasFont);
data.SetColour(wxGetApp().m_canvasTextColour);
wxFontDialog *dialog = new wxFontDialog(this, &data);
if (dialog->ShowModal() == wxID_OK)
{
@ -160,7 +161,7 @@ void MyFrame::ChooseColourGeneric(wxCommandEvent& WXUNUSED(event))
wxColour colour(i*16, i*16, i*16);
data.SetCustomColour(i, colour);
}
wxGenericColourDialog *dialog = new wxGenericColourDialog(this, &data);
if (dialog->ShowModal() == wxID_OK)
{
@ -190,7 +191,16 @@ void MyFrame::ChooseFontGeneric(wxCommandEvent& WXUNUSED(event) )
}
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) )
{
@ -204,7 +214,7 @@ void MyFrame::NumericEntry(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;
@ -215,8 +225,8 @@ void MyFrame::NumericEntry(wxCommandEvent& WXUNUSED(event) )
icon = wxICON_HAND;
}
else
{
msg.Printf(_T("You've entered %lu"), res );
{
msg.Printf(_T("You've entered %lu"), res );
icon = wxICON_INFORMATION;
}
@ -378,6 +388,7 @@ END_EVENT_TABLE()
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)

View File

@ -31,6 +31,7 @@ public:
void ChooseColour(wxCommandEvent& event);
void ChooseFont(wxCommandEvent& event);
void LogDialog(wxCommandEvent& event);
void MessageBox(wxCommandEvent& event);
void SingleChoice(wxCommandEvent& event);
void TextEntry(wxCommandEvent& event);
@ -76,6 +77,7 @@ public:
#define DIALOGS_DIR_CHOOSE 11
#define DIALOGS_TIP 12
#define DIALOGS_NUM_ENTRY 13
#define DIALOGS_LOG_DIALOG 14
#endif

View File

@ -42,6 +42,10 @@
#include "wx/process.h"
#ifdef __WINDOWS__
#include "wx/dde.h"
#endif // __WINDOWS__
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
@ -72,6 +76,7 @@ public:
void OnSyncExec(wxCommandEvent& event);
void OnAsyncExec(wxCommandEvent& event);
void OnShell(wxCommandEvent& event);
void OnDDEExec(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
@ -114,9 +119,12 @@ enum
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
// ----------------------------------------------------------------------------
@ -130,6 +138,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
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()
@ -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"),
_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"));
@ -232,7 +246,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
_T("Exec sample"),
DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
@ -247,7 +261,7 @@ void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
_T("Exec sample"),
DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
@ -269,7 +283,7 @@ void MyFrame::OnAsyncExec(wxCommandEvent& WXUNUSED(event))
void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
{
wxString cmd = wxGetTextFromUser(_T("Enter the command: "),
_T("Exec sample"),
DIALOG_TITLE,
m_cmdLast);
if ( !cmd )
@ -281,6 +295,48 @@ void MyFrame::OnShell(wxCommandEvent& WXUNUSED(event))
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
// ----------------------------------------------------------------------------

View File

@ -275,7 +275,9 @@ void MyFrame::Draw(wxDC& dc, bool WXUNUSED(draw_bitmaps) )
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);

View File

@ -99,7 +99,8 @@ void MyApp::InitTabView(wxNotebook* notebook, wxPanel* window)
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);

View File

@ -41,6 +41,30 @@
#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
// ----------------------------------------------------------------------------
@ -53,7 +77,22 @@ public:
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
@ -63,11 +102,15 @@ IMPLEMENT_APP(MyApp)
// 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");
}
@ -185,11 +228,25 @@ private:
// 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
// ----------------------------------------------------------------------------
@ -197,15 +254,62 @@ END_EVENT_TABLE()
// `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");
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"
"© 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);
@ -237,8 +341,9 @@ bool MyApp::OnInit()
}
wizard->Destroy();
// we're done
return FALSE;
}
void MyFrame::OnWizardCancel(wxWizardEvent& WXUNUSED(event))
{
wxLogStatus(this, "The wizard was cancelled.");
}