]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: arttest.cpp | |
3 | // Purpose: wxArtProvider sample | |
4 | // Author: Vaclav Slavik | |
5 | // Modified by: | |
6 | // Created: 2002/03/25 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Vaclav Slavik | |
9 | // Licence: wxWindows license | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // For compilers that support precompilation, includes "wx/wx.h". | |
13 | #include "wx/wxprec.h" | |
14 | ||
15 | #ifdef __BORLANDC__ | |
16 | #pragma hdrstop | |
17 | #endif | |
18 | ||
19 | #ifndef WX_PRECOMP | |
20 | #include "wx/wx.h" | |
21 | #endif | |
22 | ||
23 | #ifndef __WXMSW__ | |
24 | #include "mondrian.xpm" | |
25 | #endif | |
26 | ||
27 | #include "wx/artprov.h" | |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
30 | // private classes | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
33 | class MyApp : public wxApp | |
34 | { | |
35 | public: | |
36 | virtual bool OnInit(); | |
37 | }; | |
38 | ||
39 | class MyFrame : public wxFrame | |
40 | { | |
41 | public: | |
42 | MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, | |
43 | long style = wxDEFAULT_FRAME_STYLE); | |
44 | ||
45 | private: | |
46 | // event handlers (these functions should _not_ be virtual) | |
47 | void OnQuit(wxCommandEvent& event); | |
48 | void OnAbout(wxCommandEvent& event); | |
49 | void OnLogs(wxCommandEvent& event); | |
50 | ||
51 | DECLARE_EVENT_TABLE() | |
52 | }; | |
53 | ||
54 | // ---------------------------------------------------------------------------- | |
55 | // constants | |
56 | // ---------------------------------------------------------------------------- | |
57 | ||
58 | // IDs for the controls and the menu commands | |
59 | enum | |
60 | { | |
61 | ID_Quit = wxID_HIGHEST, | |
62 | ID_Logs | |
63 | }; | |
64 | ||
65 | // ---------------------------------------------------------------------------- | |
66 | // event tables and other macros for wxWindows | |
67 | // ---------------------------------------------------------------------------- | |
68 | ||
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) | |
73 | END_EVENT_TABLE() | |
74 | ||
75 | IMPLEMENT_APP(MyApp) | |
76 | ||
77 | // ============================================================================ | |
78 | // implementation | |
79 | // ============================================================================ | |
80 | ||
81 | // ---------------------------------------------------------------------------- | |
82 | // the application class | |
83 | // ---------------------------------------------------------------------------- | |
84 | ||
85 | // 'Main program' equivalent: the program execution "starts" here | |
86 | bool MyApp::OnInit() | |
87 | { | |
88 | // create the main application window | |
89 | MyFrame *frame = new MyFrame(_T("wxArtProvider sample"), | |
90 | wxPoint(50, 50), wxSize(450, 340)); | |
91 | frame->Show(TRUE); | |
92 | return TRUE; | |
93 | } | |
94 | ||
95 | // ---------------------------------------------------------------------------- | |
96 | // main frame | |
97 | // ---------------------------------------------------------------------------- | |
98 | ||
99 | // frame constructor | |
100 | MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style) | |
101 | : wxFrame(NULL, -1, title, pos, size, style) | |
102 | { | |
103 | SetIcon(wxICON(mondrian)); | |
104 | ||
105 | // create a menu bar | |
106 | wxMenu *menuFile = new wxMenu; | |
107 | ||
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")); | |
111 | ||
112 | menuFile->Append(ID_Logs, _T("&Logging test"), _T("Show some logging output")); | |
113 | menuFile->AppendSeparator(); | |
114 | ||
115 | menuFile->Append(ID_Quit, _T("E&xit\tAlt-X"), _T("Quit this program")); | |
116 | ||
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")); | |
121 | ||
122 | // ... and attach this menu bar to the frame | |
123 | SetMenuBar(menuBar); | |
124 | } | |
125 | ||
126 | ||
127 | // event handlers | |
128 | ||
129 | void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event)) | |
130 | { | |
131 | // TRUE is to force the frame to close | |
132 | Close(TRUE); | |
133 | } | |
134 | ||
135 | void MyFrame::OnLogs(wxCommandEvent& WXUNUSED(event)) | |
136 | { | |
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.")); | |
143 | } | |
144 | ||
145 | void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event)) | |
146 | { | |
147 | wxString msg; | |
148 | msg.Printf( _T("This is the about dialog of wxArtProvider sample.\n") | |
149 | _T("Welcome to %s"), wxVERSION_STRING); | |
150 | ||
151 | wxMessageBox(msg, _T("About Minimal"), wxOK | wxICON_INFORMATION, this); | |
152 | } |