oops, restored accidentally checked in testing code
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43064 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c4b4f847e2
commit
1c07cf50cb
@ -1,233 +1,207 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
Index: samples/minimal/minimal.cpp
|
||||||
// Name: minimal.cpp
|
===================================================================
|
||||||
// Purpose: Minimal wxWidgets sample
|
RCS file: /pack/cvsroots/wxwidgets/wxWidgets/samples/minimal/minimal.cpp,v
|
||||||
// Author: Julian Smart
|
retrieving revision 1.71
|
||||||
// Modified by:
|
diff -B -b -u -2 -p -r1.71 minimal.cpp
|
||||||
// Created: 04/01/98
|
--- samples/minimal/minimal.cpp 2006/06/29 13:47:45 1.71
|
||||||
// RCS-ID: $Id$
|
+++ samples/minimal/minimal.cpp 2006/11/04 20:50:29
|
||||||
// Copyright: (c) Julian Smart
|
@@ -1,199 +0,0 @@
|
||||||
// Licence: wxWindows licence
|
-/////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
-// Name: minimal.cpp
|
||||||
|
-// Purpose: Minimal wxWidgets sample
|
||||||
// ============================================================================
|
-// Author: Julian Smart
|
||||||
// declarations
|
-// Modified by:
|
||||||
// ============================================================================
|
-// Created: 04/01/98
|
||||||
|
-// RCS-ID: $Id$
|
||||||
// ----------------------------------------------------------------------------
|
-// Copyright: (c) Julian Smart
|
||||||
// headers
|
-// Licence: wxWindows licence
|
||||||
// ----------------------------------------------------------------------------
|
-/////////////////////////////////////////////////////////////////////////////
|
||||||
|
-
|
||||||
// For compilers that support precompilation, includes "wx/wx.h".
|
-// ============================================================================
|
||||||
#include "wx/wxprec.h"
|
-// declarations
|
||||||
|
-// ============================================================================
|
||||||
#ifdef __BORLANDC__
|
-
|
||||||
#pragma hdrstop
|
-// ----------------------------------------------------------------------------
|
||||||
#endif
|
-// headers
|
||||||
|
-// ----------------------------------------------------------------------------
|
||||||
// for all others, include the necessary headers (this file is usually all you
|
-
|
||||||
// need because it includes almost all "standard" wxWidgets headers)
|
-// For compilers that support precompilation, includes "wx/wx.h".
|
||||||
#ifndef WX_PRECOMP
|
-#include "wx/wxprec.h"
|
||||||
#include "wx/wx.h"
|
-
|
||||||
#endif
|
-#ifdef __BORLANDC__
|
||||||
|
- #pragma hdrstop
|
||||||
// ----------------------------------------------------------------------------
|
-#endif
|
||||||
// resources
|
-
|
||||||
// ----------------------------------------------------------------------------
|
-// for all others, include the necessary headers (this file is usually all you
|
||||||
|
-// need because it includes almost all "standard" wxWidgets headers)
|
||||||
// the application icon (under Windows and OS/2 it is in resources and even
|
-#ifndef WX_PRECOMP
|
||||||
// though we could still include the XPM here it would be unused)
|
- #include "wx/wx.h"
|
||||||
#if !defined(__WXMSW__) && !defined(__WXPM__)
|
-#endif
|
||||||
#include "../sample.xpm"
|
-
|
||||||
#endif
|
-// ----------------------------------------------------------------------------
|
||||||
|
-// resources
|
||||||
// ----------------------------------------------------------------------------
|
-// ----------------------------------------------------------------------------
|
||||||
// private classes
|
-
|
||||||
// ----------------------------------------------------------------------------
|
-// the application icon (under Windows and OS/2 it is in resources and even
|
||||||
|
-// though we could still include the XPM here it would be unused)
|
||||||
// Define a new application type, each program should derive a class from wxApp
|
-#if !defined(__WXMSW__) && !defined(__WXPM__)
|
||||||
class MyApp : public wxApp
|
- #include "../sample.xpm"
|
||||||
{
|
-#endif
|
||||||
public:
|
-
|
||||||
// override base class virtuals
|
-// ----------------------------------------------------------------------------
|
||||||
// ----------------------------
|
-// private classes
|
||||||
|
-// ----------------------------------------------------------------------------
|
||||||
// this one is called on application startup and is a good place for the app
|
-
|
||||||
// initialization (doing it here and not in the ctor allows to have an error
|
-// Define a new application type, each program should derive a class from wxApp
|
||||||
// return: if OnInit() returns false, the application terminates)
|
-class MyApp : public wxApp
|
||||||
virtual bool OnInit();
|
-{
|
||||||
};
|
-public:
|
||||||
|
- // override base class virtuals
|
||||||
// Define a new frame type: this is going to be our main frame
|
- // ----------------------------
|
||||||
class MyFrame : public wxFrame
|
-
|
||||||
{
|
- // this one is called on application startup and is a good place for the app
|
||||||
public:
|
- // initialization (doing it here and not in the ctor allows to have an error
|
||||||
// ctor(s)
|
- // return: if OnInit() returns false, the application terminates)
|
||||||
MyFrame(const wxString& title);
|
- virtual bool OnInit();
|
||||||
|
-};
|
||||||
// event handlers (these functions should _not_ be virtual)
|
-
|
||||||
void OnQuit(wxCommandEvent& event);
|
-// Define a new frame type: this is going to be our main frame
|
||||||
void OnAbout(wxCommandEvent& event);
|
-class MyFrame : public wxFrame
|
||||||
|
-{
|
||||||
void OnPaint(wxPaintEvent&)
|
-public:
|
||||||
{
|
- // ctor(s)
|
||||||
wxPaintDC dc(this);
|
- MyFrame(const wxString& title);
|
||||||
|
-
|
||||||
wxBitmap bmp(100, 100, 1);
|
- // event handlers (these functions should _not_ be virtual)
|
||||||
{
|
- void OnQuit(wxCommandEvent& event);
|
||||||
wxMemoryDC memdc(bmp);
|
- void OnAbout(wxCommandEvent& event);
|
||||||
memdc.SetBackground(*wxWHITE);
|
-
|
||||||
memdc.SetTextForeground(*wxBLACK);
|
-private:
|
||||||
memdc.Clear();
|
- // any class wishing to process wxWidgets events must use this macro
|
||||||
memdc.DrawText(_T("Hello wx!"), 10, 10);
|
- DECLARE_EVENT_TABLE()
|
||||||
}
|
-};
|
||||||
|
-
|
||||||
wxBitmap bmp2 = bmp;
|
-// ----------------------------------------------------------------------------
|
||||||
{
|
-// constants
|
||||||
wxMemoryDC memdc(bmp2);
|
-// ----------------------------------------------------------------------------
|
||||||
memdc.SetBackground(*wxWHITE);
|
-
|
||||||
memdc.SetTextForeground(*wxRED);
|
-// IDs for the controls and the menu commands
|
||||||
memdc.Clear();
|
-enum
|
||||||
memdc.DrawText(_T("Goodbye!"), 10, 10);
|
-{
|
||||||
}
|
- // menu items
|
||||||
|
- Minimal_Quit = wxID_EXIT,
|
||||||
dc.DrawBitmap(bmp, 10, 10);
|
-
|
||||||
dc.DrawBitmap(bmp2, 120, 10);
|
- // it is important for the id corresponding to the "About" command to have
|
||||||
}
|
- // this standard value as otherwise it won't be handled properly under Mac
|
||||||
|
- // (where it is special and put into the "Apple" menu)
|
||||||
private:
|
- Minimal_About = wxID_ABOUT
|
||||||
// any class wishing to process wxWidgets events must use this macro
|
-};
|
||||||
DECLARE_EVENT_TABLE()
|
-
|
||||||
};
|
-// ----------------------------------------------------------------------------
|
||||||
|
-// event tables and other macros for wxWidgets
|
||||||
// ----------------------------------------------------------------------------
|
-// ----------------------------------------------------------------------------
|
||||||
// constants
|
-
|
||||||
// ----------------------------------------------------------------------------
|
-// the event tables connect the wxWidgets events with the functions (event
|
||||||
|
-// handlers) which process them. It can be also done at run-time, but for the
|
||||||
// IDs for the controls and the menu commands
|
-// simple menu events like this the static method is much simpler.
|
||||||
enum
|
-BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
{
|
- EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
// menu items
|
- EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
Minimal_Quit = wxID_EXIT,
|
-END_EVENT_TABLE()
|
||||||
|
-
|
||||||
// it is important for the id corresponding to the "About" command to have
|
-// Create a new application object: this macro will allow wxWidgets to create
|
||||||
// this standard value as otherwise it won't be handled properly under Mac
|
-// the application object during program execution (it's better than using a
|
||||||
// (where it is special and put into the "Apple" menu)
|
-// static object for many reasons) and also implements the accessor function
|
||||||
Minimal_About = wxID_ABOUT
|
-// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
||||||
};
|
-// not wxApp)
|
||||||
|
-IMPLEMENT_APP(MyApp)
|
||||||
// ----------------------------------------------------------------------------
|
-
|
||||||
// event tables and other macros for wxWidgets
|
-// ============================================================================
|
||||||
// ----------------------------------------------------------------------------
|
-// implementation
|
||||||
|
-// ============================================================================
|
||||||
// the event tables connect the wxWidgets events with the functions (event
|
-
|
||||||
// handlers) which process them. It can be also done at run-time, but for the
|
-// ----------------------------------------------------------------------------
|
||||||
// simple menu events like this the static method is much simpler.
|
-// the application class
|
||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
-// ----------------------------------------------------------------------------
|
||||||
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
-
|
||||||
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
-// 'Main program' equivalent: the program execution "starts" here
|
||||||
END_EVENT_TABLE()
|
-bool MyApp::OnInit()
|
||||||
|
-{
|
||||||
// Create a new application object: this macro will allow wxWidgets to create
|
- // call the base class initialization method, currently it only parses a
|
||||||
// the application object during program execution (it's better than using a
|
- // few common command-line options but it could be do more in the future
|
||||||
// static object for many reasons) and also implements the accessor function
|
- if ( !wxApp::OnInit() )
|
||||||
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
- return false;
|
||||||
// not wxApp)
|
-
|
||||||
IMPLEMENT_APP(MyApp)
|
- // create the main application window
|
||||||
|
- MyFrame *frame = new MyFrame(_T("Minimal wxWidgets App"));
|
||||||
// ============================================================================
|
-
|
||||||
// implementation
|
- // and show it (the frames, unlike simple controls, are not shown when
|
||||||
// ============================================================================
|
- // created initially)
|
||||||
|
- frame->Show(true);
|
||||||
// ----------------------------------------------------------------------------
|
-
|
||||||
// the application class
|
- // success: wxApp::OnRun() will be called which will enter the main message
|
||||||
// ----------------------------------------------------------------------------
|
- // loop and the application will run. If we returned false here, the
|
||||||
|
- // application would exit immediately.
|
||||||
// 'Main program' equivalent: the program execution "starts" here
|
- return true;
|
||||||
bool MyApp::OnInit()
|
-}
|
||||||
{
|
-
|
||||||
// call the base class initialization method, currently it only parses a
|
-// ----------------------------------------------------------------------------
|
||||||
// few common command-line options but it could be do more in the future
|
-// main frame
|
||||||
if ( !wxApp::OnInit() )
|
-// ----------------------------------------------------------------------------
|
||||||
return false;
|
-
|
||||||
|
-// frame constructor
|
||||||
// create the main application window
|
-MyFrame::MyFrame(const wxString& title)
|
||||||
MyFrame *frame = new MyFrame(_T("Minimal wxWidgets App"));
|
- : wxFrame(NULL, wxID_ANY, title)
|
||||||
|
-{
|
||||||
// and show it (the frames, unlike simple controls, are not shown when
|
- // set the frame icon
|
||||||
// created initially)
|
- SetIcon(wxICON(sample));
|
||||||
frame->Show(true);
|
-
|
||||||
|
-#if wxUSE_MENUS
|
||||||
// success: wxApp::OnRun() will be called which will enter the main message
|
- // create a menu bar
|
||||||
// loop and the application will run. If we returned false here, the
|
- wxMenu *fileMenu = new wxMenu;
|
||||||
// application would exit immediately.
|
-
|
||||||
return true;
|
- // the "About" item should be in the help menu
|
||||||
}
|
- wxMenu *helpMenu = new wxMenu;
|
||||||
|
- helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));
|
||||||
// ----------------------------------------------------------------------------
|
-
|
||||||
// main frame
|
- fileMenu->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
||||||
// ----------------------------------------------------------------------------
|
-
|
||||||
|
- // now append the freshly created menu to the menu bar...
|
||||||
// frame constructor
|
- wxMenuBar *menuBar = new wxMenuBar();
|
||||||
MyFrame::MyFrame(const wxString& title)
|
- menuBar->Append(fileMenu, _T("&File"));
|
||||||
: wxFrame(NULL, wxID_ANY, title)
|
- menuBar->Append(helpMenu, _T("&Help"));
|
||||||
{
|
-
|
||||||
Connect(wxEVT_PAINT, wxPaintEventHandler(MyFrame::OnPaint));
|
- // ... and attach this menu bar to the frame
|
||||||
// set the frame icon
|
- SetMenuBar(menuBar);
|
||||||
SetIcon(wxICON(sample));
|
-#endif // wxUSE_MENUS
|
||||||
|
-
|
||||||
#if wxUSE_MENUS
|
-#if wxUSE_STATUSBAR
|
||||||
// create a menu bar
|
- // create a status bar just for fun (by default with 1 pane only)
|
||||||
wxMenu *fileMenu = new wxMenu;
|
- CreateStatusBar(2);
|
||||||
|
- SetStatusText(_T("Welcome to wxWidgets!"));
|
||||||
// the "About" item should be in the help menu
|
-#endif // wxUSE_STATUSBAR
|
||||||
wxMenu *helpMenu = new wxMenu;
|
-}
|
||||||
helpMenu->Append(Minimal_About, _T("&About...\tF1"), _T("Show about dialog"));
|
-
|
||||||
|
-
|
||||||
fileMenu->Append(Minimal_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
-// event handlers
|
||||||
|
-
|
||||||
// now append the freshly created menu to the menu bar...
|
-void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
||||||
wxMenuBar *menuBar = new wxMenuBar();
|
-{
|
||||||
menuBar->Append(fileMenu, _T("&File"));
|
- // true is to force the frame to close
|
||||||
menuBar->Append(helpMenu, _T("&Help"));
|
- Close(true);
|
||||||
|
-}
|
||||||
// ... and attach this menu bar to the frame
|
-
|
||||||
SetMenuBar(menuBar);
|
-void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||||
#endif // wxUSE_MENUS
|
-{
|
||||||
|
- wxMessageBox(wxString::Format(
|
||||||
wxTextCtrl *m_textctrl = new wxTextCtrl(this, -1, _T(""), wxPoint(100,
|
- _T("Welcome to %s!\n")
|
||||||
100), wxSize(100, 100), wxTE_MULTILINE);
|
- _T("\n")
|
||||||
wxTextAttr t_style ( *wxRED );
|
- _T("This is the minimal wxWidgets sample\n")
|
||||||
m_textctrl->SetDefaultStyle(t_style);
|
- _T("running under %s."),
|
||||||
m_textctrl->Clear();
|
- wxVERSION_STRING,
|
||||||
m_textctrl->WriteText(_T("Must be red"));
|
- wxGetOsDescription().c_str()
|
||||||
|
- ),
|
||||||
#if wxUSE_STATUSBAR
|
- _T("About wxWidgets minimal sample"),
|
||||||
// create a status bar just for fun (by default with 1 pane only)
|
- wxOK | wxICON_INFORMATION,
|
||||||
CreateStatusBar(2);
|
- this);
|
||||||
SetStatusText(_T("Welcome to wxWidgets!"));
|
-}
|
||||||
#endif // wxUSE_STATUSBAR
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// event handlers
|
|
||||||
|
|
||||||
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
// true is to force the frame to close
|
|
||||||
Close(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
wxMessageBox(wxString::Format(
|
|
||||||
_T("Welcome to %s!\n")
|
|
||||||
_T("\n")
|
|
||||||
_T("This is the minimal wxWidgets sample\n")
|
|
||||||
_T("running under %s."),
|
|
||||||
wxVERSION_STRING,
|
|
||||||
wxGetOsDescription().c_str()
|
|
||||||
),
|
|
||||||
_T("About wxWidgets minimal sample"),
|
|
||||||
wxOK | wxICON_INFORMATION,
|
|
||||||
this);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user