12fd305bcd
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14785 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
153 lines
4.4 KiB
C++
153 lines
4.4 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: arttest.cpp
|
|
// Purpose: wxArtProvider sample
|
|
// Author: Vaclav Slavik
|
|
// Modified by:
|
|
// Created: 2002/03/25
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) Vaclav Slavik
|
|
// Licence: wxWindows license
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#ifndef WX_PRECOMP
|
|
#include "wx/wx.h"
|
|
#endif
|
|
|
|
#ifndef __WXMSW__
|
|
#include "mondrian.xpm"
|
|
#endif
|
|
|
|
#include "wx/artprov.h"
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// private classes
|
|
// ----------------------------------------------------------------------------
|
|
|
|
class MyApp : public wxApp
|
|
{
|
|
public:
|
|
virtual bool OnInit();
|
|
};
|
|
|
|
class MyFrame : public wxFrame
|
|
{
|
|
public:
|
|
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
|
|
long style = wxDEFAULT_FRAME_STYLE);
|
|
|
|
private:
|
|
// event handlers (these functions should _not_ be virtual)
|
|
void OnQuit(wxCommandEvent& event);
|
|
void OnAbout(wxCommandEvent& event);
|
|
void OnLogs(wxCommandEvent& event);
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// constants
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// IDs for the controls and the menu commands
|
|
enum
|
|
{
|
|
ID_Quit = wxID_HIGHEST,
|
|
ID_Logs
|
|
};
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// event tables and other macros for wxWindows
|
|
// ----------------------------------------------------------------------------
|
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|
EVT_MENU(ID_Quit, MyFrame::OnQuit)
|
|
EVT_MENU(ID_Logs, MyFrame::OnLogs)
|
|
EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
|
|
END_EVENT_TABLE()
|
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
// ============================================================================
|
|
// implementation
|
|
// ============================================================================
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// the application class
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 'Main program' equivalent: the program execution "starts" here
|
|
bool MyApp::OnInit()
|
|
{
|
|
// create the main application window
|
|
MyFrame *frame = new MyFrame(_T("wxArtProvider sample"),
|
|
wxPoint(50, 50), wxSize(450, 340));
|
|
frame->Show(TRUE);
|
|
return TRUE;
|
|
}
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// main frame
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// frame constructor
|
|
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
|
|
: wxFrame(NULL, -1, title, pos, size, style)
|
|
{
|
|
SetIcon(wxICON(mondrian));
|
|
|
|
// create a menu bar
|
|
wxMenu *menuFile = new wxMenu;
|
|
|
|
// the "About" item should be in the help menu
|
|
wxMenu *helpMenu = new wxMenu;
|
|
helpMenu->Append(wxID_ABOUT, _T("&About...\tF1"), _T("Show about dialog"));
|
|
|
|
menuFile->Append(ID_Logs, _T("&Logging test"), _T("Show some logging output"));
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append(ID_Quit, _T("E&xit\tAlt-X"), _T("Quit this program"));
|
|
|
|
// now append the freshly created menu to the menu bar...
|
|
wxMenuBar *menuBar = new wxMenuBar();
|
|
menuBar->Append(menuFile, _T("&File"));
|
|
menuBar->Append(helpMenu, _T("&Help"));
|
|
|
|
// ... and attach this menu bar to the frame
|
|
SetMenuBar(menuBar);
|
|
}
|
|
|
|
|
|
// event handlers
|
|
|
|
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
{
|
|
// TRUE is to force the frame to close
|
|
Close(TRUE);
|
|
}
|
|
|
|
void MyFrame::OnLogs(wxCommandEvent& WXUNUSED(event))
|
|
{
|
|
wxLogMessage(_T("Some information."));
|
|
wxLogError(_T("This is an error."));
|
|
wxLogWarning(_T("A warning."));
|
|
wxLogError(_T("Yet another error."));
|
|
wxLog::GetActiveTarget()->Flush();
|
|
wxLogMessage(_T("Check/uncheck 'File/Plug-in provider' and try again."));
|
|
}
|
|
|
|
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
{
|
|
wxString msg;
|
|
msg.Printf( _T("This is the about dialog of wxArtProvider sample.\n")
|
|
_T("Welcome to %s"), wxVERSION_STRING);
|
|
|
|
wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this);
|
|
}
|