]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Program: wxTest | |
3 | * | |
4 | * Author: Robert Roebling | |
5 | * | |
6 | * Copyright: (C) 1997, GNU (Robert Roebling) | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 2 of the License, or | |
11 | * (at your option) any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | */ | |
22 | ||
23 | #ifdef __GNUG__ | |
24 | #pragma implementation "wxTest.h" | |
25 | #endif | |
26 | ||
27 | #include "wxTest.h" | |
28 | ||
29 | #include "folder.xpm" | |
30 | #include "list.xpm" | |
31 | #include "test.xpm" | |
32 | ||
33 | //----------------------------------------------------------------------------- | |
34 | // main program | |
35 | //----------------------------------------------------------------------------- | |
36 | ||
37 | IMPLEMENT_APP(MyApp) | |
38 | ||
39 | //----------------------------------------------------------------------------- | |
40 | // MyDialog | |
41 | //----------------------------------------------------------------------------- | |
42 | ||
43 | const int ID_RETURN = 100; | |
44 | const int ID_HELLO = 101; | |
45 | ||
46 | const int ID_CHECKBOX = 110; | |
47 | const int ID_CHECKBOX_CHECK = 110; | |
48 | const int ID_CHECKBOX_UNCHECK = 112; | |
49 | ||
50 | const int ID_TEXTCTRL = 115; | |
51 | const int ID_TEXTCTRL_SET = 116; | |
52 | const int ID_TEXTCTRL_DEL = 117; | |
53 | ||
54 | const int ID_CHOICE = 120; | |
55 | const int ID_CHOICE_SEL_NUM = 121; | |
56 | const int ID_CHOICE_SEL_STR = 122; | |
57 | const int ID_CHOICE_CLEAR = 123; | |
58 | const int ID_CHOICE_APPEND = 124; | |
59 | ||
60 | const int ID_LISTBOX = 130; | |
61 | const int ID_LISTBOX_SEL_NUM = 131; | |
62 | const int ID_LISTBOX_SEL_STR = 132; | |
63 | const int ID_LISTBOX_CLEAR = 133; | |
64 | const int ID_LISTBOX_APPEND = 134; | |
65 | ||
66 | const int ID_RADIOBOX = 130; | |
67 | const int ID_RADIOBOX_SEL_NUM = 131; | |
68 | const int ID_RADIOBOX_SEL_STR = 132; | |
69 | ||
70 | BEGIN_EVENT_TABLE(MyDialog,wxDialog) | |
71 | EVT_BUTTON (ID_RETURN, MyDialog::OnReturnButton) | |
72 | EVT_BUTTON (ID_HELLO, MyDialog::OnHelloButton) | |
73 | EVT_CHECKBOX (ID_CHECKBOX, MyDialog::OnCheckBox) | |
74 | EVT_BUTTON (ID_CHECKBOX_CHECK, MyDialog::OnCheckBoxButtons) | |
75 | EVT_BUTTON (ID_CHECKBOX_UNCHECK, MyDialog::OnCheckBoxButtons) | |
76 | EVT_TEXT (ID_TEXTCTRL, MyDialog::OnTextCtrl) | |
77 | EVT_BUTTON (ID_TEXTCTRL_SET, MyDialog::OnTextCtrlButtons) | |
78 | EVT_BUTTON (ID_TEXTCTRL_DEL, MyDialog::OnTextCtrlButtons) | |
79 | EVT_CHOICE (ID_CHOICE, MyDialog::OnChoice) | |
80 | EVT_BUTTON (ID_CHOICE_SEL_NUM, MyDialog::OnChoiceButtons) | |
81 | EVT_BUTTON (ID_CHOICE_SEL_STR, MyDialog::OnChoiceButtons) | |
82 | EVT_BUTTON (ID_CHOICE_CLEAR, MyDialog::OnChoiceButtons) | |
83 | EVT_BUTTON (ID_CHOICE_APPEND, MyDialog::OnChoiceButtons) | |
84 | EVT_LISTBOX (ID_LISTBOX, MyDialog::OnListBox) | |
85 | EVT_BUTTON (ID_LISTBOX_SEL_NUM, MyDialog::OnListBoxButtons) | |
86 | EVT_BUTTON (ID_LISTBOX_SEL_STR, MyDialog::OnListBoxButtons) | |
87 | EVT_BUTTON (ID_LISTBOX_CLEAR, MyDialog::OnListBoxButtons) | |
88 | EVT_BUTTON (ID_LISTBOX_APPEND, MyDialog::OnListBoxButtons) | |
89 | EVT_RADIOBOX (ID_RADIOBOX, MyDialog::OnRadioBox) | |
90 | EVT_BUTTON (ID_RADIOBOX_SEL_NUM, MyDialog::OnRadioBoxButtons) | |
91 | EVT_BUTTON (ID_RADIOBOX_SEL_STR, MyDialog::OnRadioBoxButtons) | |
92 | END_EVENT_TABLE() | |
93 | ||
94 | //----------------------------------------------------------------------------- | |
95 | ||
96 | IMPLEMENT_DYNAMIC_CLASS(MyDialog, wxDialog) | |
97 | ||
98 | MyDialog::MyDialog( wxWindow *parent ) : | |
99 | wxDialog( parent, -1, "TestDialog", wxPoint(20,100), wxSize(700,400), wxDIALOG_MODAL ) | |
100 | { | |
101 | m_text1 = (wxStaticText *) NULL; | |
102 | m_text2 = (wxStaticText *) NULL; | |
103 | ||
104 | (void)new wxStaticBox( this, -1, "CheckBox group", wxPoint(20,10), wxSize(140,180) ); | |
105 | m_checkbox = new wxCheckBox( this, ID_CHECKBOX, "CheckBox", wxPoint(40,35), wxSize(100,30) ); | |
106 | (void)new wxButton( this, ID_CHECKBOX_CHECK, "Check", wxPoint(40,85), wxSize(100,30) ); | |
107 | (void)new wxButton( this, ID_CHECKBOX_UNCHECK, "Uncheck", wxPoint(40,135), wxSize(100,30) ); | |
108 | ||
109 | (void)new wxStaticBox( this, -1, "TextCtrl group", wxPoint(20,200), wxSize(140,180) ); | |
110 | m_textctrl = new wxTextCtrl( this, ID_TEXTCTRL, "TextCtrl", wxPoint(40,35+190), wxSize(100,30) ); | |
111 | (void)new wxButton( this, ID_TEXTCTRL_SET, "Set 'Hi!'", wxPoint(40,85+190), wxSize(100,30) ); | |
112 | (void)new wxButton( this, ID_TEXTCTRL_DEL, "Delete", wxPoint(40,135+190), wxSize(100,30) ); | |
113 | ||
114 | wxString choices[4] = | |
115 | { | |
116 | "This", | |
117 | "is", | |
118 | "a", | |
119 | "wonderfull example." | |
120 | }; | |
121 | ||
122 | (void)new wxStaticBox( this, -1, "Choice group", wxPoint(180,10), wxSize(140,330) ); | |
123 | m_choice = new wxChoice( this, ID_CHOICE, wxPoint(200,35), wxSize(100,30), 4, choices ); | |
124 | (void)new wxButton( this, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(200,130), wxSize(100,30) ); | |
125 | (void)new wxButton( this, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(200,180), wxSize(100,30) ); | |
126 | (void)new wxButton( this, ID_CHOICE_CLEAR, "Clear", wxPoint(200,230), wxSize(100,30) ); | |
127 | (void)new wxButton( this, ID_CHOICE_APPEND, "Append 'Hi!'", wxPoint(200,280), wxSize(100,30) ); | |
128 | ||
129 | (void)new wxStaticBox( this, 100, "ListBox group", wxPoint(340,10), wxSize(140,330) ); | |
130 | m_listbox = new wxListBox( this, ID_LISTBOX, wxPoint(360,35), wxSize(100,70), 4, choices ); | |
131 | (void)new wxButton( this, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(360,130), wxSize(100,30) ); | |
132 | (void)new wxButton( this, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(360,180), wxSize(100,30) ); | |
133 | (void)new wxButton( this, ID_LISTBOX_CLEAR, "Clear", wxPoint(360,230), wxSize(100,30) ); | |
134 | (void)new wxButton( this, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(360,280), wxSize(100,30) ); | |
135 | ||
136 | (void)new wxStaticBox( this, -1, "RadioBox group", wxPoint(500,10), wxSize(180,230) ); | |
137 | m_radiobox = new wxRadioBox( this, ID_RADIOBOX, "Test", wxPoint(520,35), wxSize(-1,-1), 4, choices, | |
138 | 1, wxRA_VERTICAL ); | |
139 | ||
140 | (void)new wxButton( this, ID_HELLO, "wxScreenDC", wxPoint(540,280), wxSize(120,40) ); | |
141 | (void)new wxButton( this, ID_RETURN, "Return", wxPoint(540,340), wxSize(120,40) ); | |
142 | ||
143 | m_text1 = new wxStaticText( this, -1, "No event.", wxPoint(170,350), wxSize(300,-1) ); | |
144 | m_text2 = new wxStaticText( this, -1, "No information.", wxPoint(170,370), wxSize(300,-1) ); | |
145 | ||
146 | InitDialog(); | |
147 | }; | |
148 | ||
149 | void MyDialog::OnTextCtrl( wxCommandEvent &WXUNUSED(event) ) | |
150 | { | |
151 | }; | |
152 | ||
153 | void MyDialog::OnTextCtrlButtons( wxCommandEvent &event ) | |
154 | { | |
155 | switch (event.GetId()) | |
156 | { | |
157 | case ID_TEXTCTRL_SET: | |
158 | { | |
159 | m_textctrl->SetValue( "Hi!" ); | |
160 | break; | |
161 | }; | |
162 | case ID_TEXTCTRL_DEL: | |
163 | { | |
164 | m_textctrl->Clear(); | |
165 | break; | |
166 | }; | |
167 | }; | |
168 | }; | |
169 | ||
170 | void MyDialog::OnRadioBox( wxCommandEvent &event ) | |
171 | { | |
172 | if (!m_text1) return; | |
173 | m_text1->SetLabel( "RadioBox Event:"); | |
174 | wxString tmp = "RadioBox selection string is: "; | |
175 | tmp += event.GetString(); | |
176 | m_text2->SetLabel( tmp ); | |
177 | }; | |
178 | ||
179 | void MyDialog::OnRadioBoxButtons( wxCommandEvent &WXUNUSED(event) ) | |
180 | { | |
181 | }; | |
182 | ||
183 | void MyDialog::OnListBox( wxCommandEvent &event ) | |
184 | { | |
185 | if (!m_text1) return; | |
186 | m_text1->SetLabel( "ListBox Event:"); | |
187 | wxString tmp = "ListBox selection string is: "; | |
188 | tmp += event.GetString(); | |
189 | m_text2->SetLabel( tmp ); | |
190 | }; | |
191 | ||
192 | void MyDialog::OnListBoxButtons( wxCommandEvent &event ) | |
193 | { | |
194 | switch (event.GetId()) | |
195 | { | |
196 | case ID_LISTBOX_SEL_NUM: | |
197 | { | |
198 | m_listbox->SetSelection( 2 ); | |
199 | break; | |
200 | }; | |
201 | case ID_LISTBOX_SEL_STR: | |
202 | { | |
203 | m_listbox->SetStringSelection( "This" ); | |
204 | break; | |
205 | }; | |
206 | case ID_LISTBOX_CLEAR: | |
207 | { | |
208 | m_listbox->Clear(); | |
209 | break; | |
210 | }; | |
211 | case ID_LISTBOX_APPEND: | |
212 | { | |
213 | m_listbox->Append( "Hi!" ); | |
214 | break; | |
215 | }; | |
216 | }; | |
217 | }; | |
218 | ||
219 | void MyDialog::OnCheckBox( wxCommandEvent &event ) | |
220 | { | |
221 | if (!m_text1) return; | |
222 | m_text1->SetLabel( "CheckBox Event:"); | |
223 | wxString tmp = "Checkbox is "; | |
224 | if (event.Checked()) | |
225 | tmp += "checked."; | |
226 | else | |
227 | tmp += "unchecked."; | |
228 | m_text2->SetLabel( tmp ); | |
229 | }; | |
230 | ||
231 | void MyDialog::OnCheckBoxButtons( wxCommandEvent &event ) | |
232 | { | |
233 | switch (event.GetId()) | |
234 | { | |
235 | case ID_CHECKBOX_CHECK: | |
236 | { | |
237 | m_checkbox->SetValue( TRUE ); | |
238 | break; | |
239 | }; | |
240 | case ID_CHECKBOX_UNCHECK: | |
241 | { | |
242 | m_checkbox->SetValue( FALSE ); | |
243 | break; | |
244 | }; | |
245 | }; | |
246 | }; | |
247 | ||
248 | void MyDialog::OnChoice( wxCommandEvent &event ) | |
249 | { | |
250 | if (!m_text1) return; | |
251 | m_text1->SetLabel( "Choice Event:"); | |
252 | wxString tmp = "Choice selection string is: "; | |
253 | tmp += event.GetString(); | |
254 | m_text2->SetLabel( tmp ); | |
255 | }; | |
256 | ||
257 | void MyDialog::OnChoiceButtons( wxCommandEvent &event ) | |
258 | { | |
259 | switch (event.GetId()) | |
260 | { | |
261 | case ID_CHOICE_SEL_NUM: | |
262 | { | |
263 | m_choice->SetSelection( 2 ); | |
264 | break; | |
265 | }; | |
266 | case ID_CHOICE_SEL_STR: | |
267 | { | |
268 | m_choice->SetStringSelection( "This" ); | |
269 | break; | |
270 | }; | |
271 | case ID_CHOICE_CLEAR: | |
272 | { | |
273 | m_choice->Clear(); | |
274 | break; | |
275 | }; | |
276 | case ID_CHOICE_APPEND: | |
277 | { | |
278 | m_choice->Append( "Hi!" ); | |
279 | break; | |
280 | }; | |
281 | }; | |
282 | }; | |
283 | ||
284 | void MyDialog::OnReturnButton( wxCommandEvent &WXUNUSED(event) ) | |
285 | { | |
286 | EndModal( 1 ); | |
287 | }; | |
288 | ||
289 | void MyDialog::OnHelloButton( wxCommandEvent &WXUNUSED(event) ) | |
290 | { | |
291 | wxMessageDialog *dialog; | |
292 | dialog = new wxMessageDialog( this, "Now, I will paint on Screen.", "wxGTK" ); | |
293 | dialog->ShowModal(); | |
294 | delete dialog; | |
295 | ||
296 | wxScreenDC dc; | |
297 | dc.StartDrawingOnTop(); | |
298 | ||
299 | int w = wxSystemSettings::GetSystemMetric( wxSYS_SCREEN_X ); | |
300 | int h = wxSystemSettings::GetSystemMetric( wxSYS_SCREEN_Y ); | |
301 | ||
302 | dc.SetPen( *wxWHITE_PEN ); | |
303 | dc.SetBrush( *wxTRANSPARENT_BRUSH ); | |
304 | for (int i = 0; i < h; i += 3) dc.DrawLine( 0, i, w, i ); | |
305 | ||
306 | dialog = new wxMessageDialog( this, "Now, the stripes will disappear.", "wxGTK" ); | |
307 | dialog->ShowModal(); | |
308 | delete dialog; | |
309 | ||
310 | dc.EndDrawingOnTop(); | |
311 | }; | |
312 | ||
313 | //----------------------------------------------------------------------------- | |
314 | // MyCanvas | |
315 | //----------------------------------------------------------------------------- | |
316 | ||
317 | IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow) | |
318 | ||
319 | BEGIN_EVENT_TABLE(MyCanvas,wxScrolledWindow) | |
320 | EVT_BUTTON (100, MyDialog::OnReturnButton) | |
321 | EVT_PAINT (MyCanvas::OnPaint) | |
322 | END_EVENT_TABLE() | |
323 | ||
324 | MyCanvas::MyCanvas( wxWindow *parent, const wxWindowID id, const wxPoint &pos, const wxSize &size ) | |
325 | : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ) | |
326 | { | |
327 | my_bitmap = new wxBitmap( folder_xpm ); | |
328 | my_horse = new wxBitmap( test_xpm); | |
329 | my_backstore = new wxBitmap( 150, 150 ); | |
330 | my_font = new wxFont( 20, wxROMAN, wxNORMAL, wxNORMAL ); | |
331 | m_isCreated = FALSE; | |
332 | ||
333 | SetBackgroundColour( wxColour("Wheat") ); | |
334 | }; | |
335 | ||
336 | MyCanvas::~MyCanvas(void) | |
337 | { | |
338 | delete my_bitmap; | |
339 | delete my_backstore; | |
340 | delete my_horse; | |
341 | delete my_font; | |
342 | }; | |
343 | ||
344 | void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) | |
345 | { | |
346 | wxPaintDC dc( this ); | |
347 | PrepareDC( dc ); | |
348 | ||
349 | wxMemoryDC memDC; | |
350 | memDC.SelectObject( *my_backstore ); | |
351 | memDC.Clear(); | |
352 | memDC.SetBrush( *wxBLACK_BRUSH ); | |
353 | memDC.SetPen( *wxWHITE_PEN ); | |
354 | memDC.DrawRectangle( 0, 0, 150, 150 ); | |
355 | memDC.SetTextForeground( *wxWHITE ); | |
356 | memDC.DrawText( "This is a memory dc.", 10, 10 ); | |
357 | ||
358 | int vx = 0; | |
359 | int vy = 0; | |
360 | GetVirtualSize( &vx, &vy ); | |
361 | dc.DrawLine( 5, 5, vx-10, vy-10 ); | |
362 | dc.DrawLine( 10, 20, 100, 10 ); | |
363 | dc.DrawLine( 10, 20, 100, 50 ); | |
364 | dc.DrawLine( 10, 20, 100, 100 ); | |
365 | ||
366 | dc.SetPen( *wxWHITE_PEN ); | |
367 | dc.DrawLine( 80, 50, 180, 50 ); | |
368 | ||
369 | dc.SetFont( *my_font ); | |
370 | ||
371 | long x = 0; | |
372 | long y = 0; | |
373 | dc.GetTextExtent( "Hej, ho, hej, ho.", &x, &y ); | |
374 | ||
375 | dc.SetBrush( *wxTRANSPARENT_BRUSH ); | |
376 | dc.DrawRectangle( 80, 40, x, y ); | |
377 | ||
378 | dc.SetTextForeground( *wxGREEN ); | |
379 | dc.DrawText( "Hej, ho, hej, ho.", 80, 40 ); | |
380 | ||
381 | dc.SetTextForeground( *wxBLACK ); | |
382 | dc.SetFont( *wxNORMAL_FONT ); | |
383 | dc.DrawText( "Hej, ho, hej, ho. (NormalFont)", 80, 60 ); | |
384 | dc.SetFont( *wxSMALL_FONT ); | |
385 | dc.DrawText( "Hej, ho, hej, ho. (SmallFont)", 80, 80 ); | |
386 | dc.SetFont( *wxITALIC_FONT ); | |
387 | dc.DrawText( "Hej, ho, hej, ho. (ItalicFont)", 80, 100 ); | |
388 | ||
389 | dc.DrawBitmap( *my_bitmap, 30, 80, TRUE ); | |
390 | dc.DrawBitmap( *my_horse, 30, 120 ); | |
391 | ||
392 | dc.Blit( 200, 200, 150, 150, &memDC, 0, 0, 0 ); | |
393 | ||
394 | memDC.SelectObject( wxNullBitmap ); | |
395 | ||
396 | /* | |
397 | dc.SetBrush( *wxBLACK_BRUSH ); | |
398 | dc.DrawRectangle( 50, 50, 50, 50 ); | |
399 | dc.SetPen( *wxWHITE_PEN ); | |
400 | dc.DrawRectangle( 101, 50, 50, 50 ); | |
401 | dc.DrawRectangle( 50, 101, 50, 50 ); | |
402 | ||
403 | dc.SetBrush( *wxWHITE_BRUSH ); | |
404 | ||
405 | dc.SetPen( *wxWHITE_PEN ); | |
406 | dc.DrawRectangle( 70, 70, 2, 2 ); | |
407 | ||
408 | dc.SetPen( *wxRED_PEN ); | |
409 | dc.DrawRectangle( 72, 70, 2, 2 ); | |
410 | dc.DrawRectangle( 70, 72, 2, 2 ); | |
411 | ||
412 | ||
413 | dc.SetPen( *wxRED_PEN ); | |
414 | dc.DrawRectangle( 82, 80, 2, 2 ); | |
415 | dc.DrawRectangle( 80, 82, 2, 2 ); | |
416 | ||
417 | dc.SetPen( *wxWHITE_PEN ); | |
418 | dc.DrawRectangle( 80, 80, 2, 2 ); | |
419 | */ | |
420 | }; | |
421 | ||
422 | //----------------------------------------------------------------------------- | |
423 | // MyFrame | |
424 | //----------------------------------------------------------------------------- | |
425 | ||
426 | const ID_OPEN = 101; | |
427 | const ID_SAVE = 102; | |
428 | const ID_MSG = 103; | |
429 | const ID_FONT = 104; | |
430 | const ID_DLG = 105; | |
431 | const ID_QUIT = 108; | |
432 | const ID_ABOUT = 109; | |
433 | ||
434 | IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame ) | |
435 | ||
436 | BEGIN_EVENT_TABLE(MyFrame,wxFrame) | |
437 | EVT_MENU (ID_OPEN, MyFrame::OnOpenDialog) | |
438 | EVT_MENU (ID_FONT, MyFrame::OnFontDialog) | |
439 | EVT_MENU (ID_MSG, MyFrame::OnMsg) | |
440 | EVT_MENU (ID_DLG, MyFrame::OnDialog) | |
441 | EVT_MENU (ID_ABOUT, MyFrame::OnAbout) | |
442 | EVT_MENU (ID_QUIT, MyFrame::OnQuit) | |
443 | END_EVENT_TABLE() | |
444 | ||
445 | MyFrame::MyFrame(void) : | |
446 | wxFrame( (wxFrame *) NULL, -1, (char *) "Robert's Test application", wxPoint(20,20), wxSize(470,360) ) | |
447 | { | |
448 | /* | |
449 | wxMenu *file_menu = new wxMenu( "Test" ); | |
450 | file_menu->Append( ID_OPEN, "Open.."); | |
451 | file_menu->Append( ID_MSG, "MessageBox.."); | |
452 | file_menu->Append( ID_FONT, "FontDialog.."); | |
453 | file_menu->AppendSeparator(); | |
454 | file_menu->Append( ID_DLG, "TestDialog.."); | |
455 | file_menu->AppendSeparator(); | |
456 | file_menu->Append( ID_ABOUT, "About.."); | |
457 | file_menu->Append( ID_QUIT, "Exit"); | |
458 | ||
459 | wxMenuBar *menu_bar = new wxMenuBar(); | |
460 | menu_bar->Append(file_menu, "File"); | |
461 | menu_bar->Show( TRUE ); | |
462 | ||
463 | SetMenuBar( menu_bar ); | |
464 | */ | |
465 | ||
466 | CreateStatusBar( 2 ); | |
467 | ||
468 | SetStatusText( "wxGTK v0.12", 0 ); | |
469 | SetStatusText( "Copyright 1998 Robert Roebling.", 1 ); | |
470 | ||
471 | m_canvas = new MyCanvas( this, -1, wxPoint(2,62), wxSize(300-4,120-4) ); | |
472 | m_canvas->SetScrollbars( 10, 10, 50, 50 ); | |
473 | ||
474 | m_tb = CreateToolBar(); | |
475 | m_tb->AddTool( 0, wxBitmap( list_xpm ), wxNullBitmap, FALSE, -1, -1, (wxObject *) NULL, "This is a button" ); | |
476 | m_tb->AddTool( 0, wxBitmap( folder_xpm ), wxNullBitmap, TRUE, -1, -1, (wxObject *) NULL, "This is a toggle" ); | |
477 | m_tb->Realize(); | |
478 | ||
479 | // m_timer.Start( 1000, TRUE ); | |
480 | }; | |
481 | ||
482 | void MyFrame::OnDialog( wxCommandEvent &WXUNUSED(event) ) | |
483 | { | |
484 | MyDialog *dialog = new MyDialog( this ); | |
485 | dialog->ShowModal(); | |
486 | dialog->Close( TRUE ); | |
487 | }; | |
488 | ||
489 | void MyFrame::OnFontDialog( wxCommandEvent &WXUNUSED(event) ) | |
490 | { | |
491 | wxFontData data; | |
492 | data.SetInitialFont( wxSMALL_FONT ); | |
493 | data.SetColour( wxRED ); | |
494 | wxGenericFontDialog dialog( this, &data ); | |
495 | if (dialog.ShowModal() == wxID_OK) | |
496 | { | |
497 | wxFontData retData = dialog.GetFontData(); | |
498 | // do something | |
499 | }; | |
500 | }; | |
501 | ||
502 | void MyFrame::OnOpenDialog( wxCommandEvent &WXUNUSED(event) ) | |
503 | { | |
504 | wxFileDialog dialog(this, "Testing open file dialog", "", "", "*.txt", 0); | |
505 | if (dialog.ShowModal() == wxID_OK) | |
506 | { | |
507 | wxMessageDialog dialog2(this, dialog.GetPath(), "Selected path"); | |
508 | dialog2.ShowModal(); | |
509 | }; | |
510 | }; | |
511 | ||
512 | void MyFrame::OnMsg( wxCommandEvent &WXUNUSED(event) ) | |
513 | { | |
514 | wxMessageBox( "There once was a lady from Riga.", "TestBox.", wxYES_NO ); | |
515 | }; | |
516 | ||
517 | void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) ) | |
518 | { | |
519 | Close( TRUE ); | |
520 | }; | |
521 | ||
522 | void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) ) | |
523 | { | |
524 | wxDialog dialog( this, -1, "About wxGTK", wxPoint(100,100), wxSize(540,350), wxDIALOG_MODAL ); | |
525 | ||
526 | int w = 0; | |
527 | int h = 0; | |
528 | dialog.GetSize( &w, &h ); | |
529 | ||
530 | int x = 30; | |
531 | int y = 20; | |
532 | int step = 20; | |
533 | ||
534 | (void)new wxStaticBox( &dialog, -1, (const char*)NULL, wxPoint(10,10), wxSize(w-20,h-80) ); | |
535 | ||
536 | (void)new wxStaticText( &dialog, -1, "wxGTK v0.12", wxPoint(240,y) ); | |
537 | y += 2*step-10; | |
538 | ||
539 | (void)new wxStaticText( &dialog, -1, "Written by Robert Roebling, 1998. More information at:", wxPoint(x,y) ); | |
540 | y += step; | |
541 | (void)new wxStaticText( &dialog, -1, "http://www.freiburg.linux.de/~wxxt", wxPoint(x+50,y) ); | |
542 | y += 2*step; | |
543 | ||
544 | (void)new wxStaticText( &dialog, -1, | |
545 | "wxGTK is based on the wxWindows GUI-library written mainly by Julian Smart. See:", wxPoint(x,y) ); | |
546 | y += step; | |
547 | (void)new wxStaticText( &dialog, -1, "http://web.ukonline.co.uk/julian.smart/wxwin", wxPoint(x+50,y) ); | |
548 | y += 2*step; | |
549 | ||
550 | (void)new wxStaticText( &dialog, -1, "wxWindows Copyright: Less restrictive version of LGPL.", wxPoint(x,y) ); | |
551 | y += 2*step; | |
552 | (void)new wxStaticText( &dialog, -1, "For questions concerning wxGTK, you may mail to:", wxPoint(x,y) ); | |
553 | y += step; | |
554 | (void)new wxStaticText( &dialog, -1, "roebling@ruf.uni-freiburg.de", wxPoint(x+50,y) ); | |
555 | ||
556 | (void) new wxButton( &dialog, wxID_OK, "Return", wxPoint(w/2-40,h-50), wxSize(80,30) ); | |
557 | ||
558 | dialog.ShowModal(); | |
559 | }; | |
560 | ||
561 | //----------------------------------------------------------------------------- | |
562 | // MyApp | |
563 | //----------------------------------------------------------------------------- | |
564 | ||
565 | MyApp::MyApp(void) : | |
566 | wxApp( ) | |
567 | { | |
568 | }; | |
569 | ||
570 | bool MyApp::OnInit(void) | |
571 | { | |
572 | wxFrame *frame = new MyFrame(); | |
573 | frame->Show( TRUE ); | |
574 | ||
575 | return TRUE; | |
576 | }; | |
577 | ||
578 | ||
579 | ||
580 | ||
581 |