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