]>
git.saurik.com Git - wxWidgets.git/blob - samples/artprov/arttest.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxArtProvider sample
4 // Author: Vaclav Slavik
8 // Copyright: (c) Vaclav Slavik
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx/wx.h".
13 #include "wx/wxprec.h"
24 #include "mondrian.xpm"
27 #include "wx/artprov.h"
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 class MyApp
: public wxApp
36 virtual bool OnInit();
39 class MyFrame
: public wxFrame
42 MyFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
,
43 long style
= wxDEFAULT_FRAME_STYLE
);
46 // event handlers (these functions should _not_ be virtual)
47 void OnQuit(wxCommandEvent
& event
);
48 void OnAbout(wxCommandEvent
& event
);
49 void OnLogs(wxCommandEvent
& event
);
54 // ----------------------------------------------------------------------------
56 // ----------------------------------------------------------------------------
58 // IDs for the controls and the menu commands
61 ID_Quit
= wxID_HIGHEST
,
65 // ----------------------------------------------------------------------------
66 // event tables and other macros for wxWindows
67 // ----------------------------------------------------------------------------
69 BEGIN_EVENT_TABLE(MyFrame
, wxFrame
)
70 EVT_MENU(ID_Quit
, MyFrame::OnQuit
)
71 EVT_MENU(ID_Logs
, MyFrame::OnLogs
)
72 EVT_MENU(wxID_ABOUT
, MyFrame::OnAbout
)
77 // ============================================================================
79 // ============================================================================
81 // ----------------------------------------------------------------------------
82 // the application class
83 // ----------------------------------------------------------------------------
85 // 'Main program' equivalent: the program execution "starts" here
88 // create the main application window
89 MyFrame
*frame
= new MyFrame(_T("wxArtProvider sample"),
90 wxPoint(50, 50), wxSize(450, 340));
95 // ----------------------------------------------------------------------------
97 // ----------------------------------------------------------------------------
100 MyFrame::MyFrame(const wxString
& title
, const wxPoint
& pos
, const wxSize
& size
, long style
)
101 : wxFrame(NULL
, -1, title
, pos
, size
, style
)
103 SetIcon(wxICON(mondrian
));
106 wxMenu
*menuFile
= new wxMenu
;
108 // the "About" item should be in the help menu
109 wxMenu
*helpMenu
= new wxMenu
;
110 helpMenu
->Append(wxID_ABOUT
, _T("&About...\tF1"), _T("Show about dialog"));
112 menuFile
->Append(ID_Logs
, _T("&Logging test"), _T("Show some logging output"));
113 menuFile
->AppendSeparator();
115 menuFile
->Append(ID_Quit
, _T("E&xit\tAlt-X"), _T("Quit this program"));
117 // now append the freshly created menu to the menu bar...
118 wxMenuBar
*menuBar
= new wxMenuBar();
119 menuBar
->Append(menuFile
, _T("&File"));
120 menuBar
->Append(helpMenu
, _T("&Help"));
122 // ... and attach this menu bar to the frame
129 void MyFrame::OnQuit(wxCommandEvent
& WXUNUSED(event
))
131 // TRUE is to force the frame to close
135 void MyFrame::OnLogs(wxCommandEvent
& WXUNUSED(event
))
137 wxLogMessage(_T("Some information."));
138 wxLogError(_T("This is an error."));
139 wxLogWarning(_T("A warning."));
140 wxLogError(_T("Yet another error."));
141 wxLog::GetActiveTarget()->Flush();
142 wxLogMessage(_T("Check/uncheck 'File/Plug-in provider' and try again."));
145 void MyFrame::OnAbout(wxCommandEvent
& WXUNUSED(event
))
148 msg
.Printf( _T("This is the about dialog of wxArtProvider sample.\n")
149 _T("Welcome to %s"), wxVERSION_STRING
);
151 wxMessageBox(msg
, _T("About Minimal"), wxOK
| wxICON_INFORMATION
, this);