]> git.saurik.com Git - wxWidgets.git/blame - samples/toolbar/toolbar.cpp
Added wxDbTable::SetOrderByColNums() function
[wxWidgets.git] / samples / toolbar / toolbar.cpp
CommitLineData
14d1ccd8 1/////////////////////////////////////////////////////////////////////////////
fc6bbc6d 2// Name: toolbar.cpp
14d1ccd8
JS
3// Purpose: wxToolBar sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
ad9bb75f 9// Licence: wxWindows licence
14d1ccd8
JS
10/////////////////////////////////////////////////////////////////////////////
11
ad9bb75f
VZ
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
14d1ccd8 20// For compilers that support precompilation, includes "wx/wx.h".
ad9bb75f 21#include <wx/wxprec.h>
14d1ccd8
JS
22
23#ifdef __BORLANDC__
ad9bb75f 24 #pragma hdrstop
14d1ccd8
JS
25#endif
26
27#ifndef WX_PRECOMP
ad9bb75f 28 #include <wx/wx.h>
14d1ccd8
JS
29#endif
30
ad9bb75f 31#include <wx/toolbar.h>
8bbe427f 32#include <wx/log.h>
40515a21 33#include <wx/image.h>
8bbe427f 34
ad4ae6ed 35// define this to 1 to use wxToolBarSimple instead of the native one
9fb35cf1 36#define USE_GENERIC_TBAR 0
ad4ae6ed 37
f6bcfd97
BP
38// define this to use XPMs everywhere (by default, BMPs are used under Win)
39#ifdef __WXMSW__
40 #define USE_XPM_BITMAPS 0
41#else
42 #define USE_XPM_BITMAPS 1
43#endif
44
ad4ae6ed
VZ
45#if USE_GENERIC_TBAR
46 #if !wxUSE_TOOLBAR_SIMPLE
9fb35cf1
VZ
47 #error wxToolBarSimple is not compiled in, set wxUSE_TOOLBAR_SIMPLE \
48 to 1 in setup.h and recompile the library.
ad4ae6ed
VZ
49 #else
50 #include <wx/tbarsmpl.h>
51 #endif
52#endif // USE_GENERIC_TBAR
53
f6bcfd97
BP
54#if USE_XPM_BITMAPS && defined(__WXMSW__) && !wxUSE_XPM_IN_MSW
55 #error You need to enable XPM support to use XPM bitmaps with toolbar!
56#endif // USE_XPM_BITMAPS
57
ad9bb75f
VZ
58// ----------------------------------------------------------------------------
59// resources
60// ----------------------------------------------------------------------------
14d1ccd8 61
f6bcfd97 62#if USE_XPM_BITMAPS
ad9bb75f
VZ
63 #include "mondrian.xpm"
64 #include "bitmaps/new.xpm"
65 #include "bitmaps/open.xpm"
66 #include "bitmaps/save.xpm"
67 #include "bitmaps/copy.xpm"
68 #include "bitmaps/cut.xpm"
5ef2e633 69 #include "bitmaps/preview.xpm" // paste XPM
ad9bb75f 70 #include "bitmaps/print.xpm"
ad9bb75f 71 #include "bitmaps/help.xpm"
f6bcfd97 72#endif // USE_XPM_BITMAPS
ad9bb75f
VZ
73
74// ----------------------------------------------------------------------------
75// classes
76// ----------------------------------------------------------------------------
77
78// Define a new application
5ef2e633 79class MyApp : public wxApp
ad9bb75f
VZ
80{
81public:
82 bool OnInit();
ad9bb75f 83};
47908e25 84
ad9bb75f
VZ
85// Define a new frame
86class MyFrame: public wxFrame
87{
88public:
89 MyFrame(wxFrame *parent,
90 wxWindowID id = -1,
91 const wxString& title = "wxToolBar Sample",
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 long style = wxDEFAULT_FRAME_STYLE);
14d1ccd8 95
5ef2e633
VZ
96 void RecreateToolbar();
97
ad9bb75f
VZ
98 void OnQuit(wxCommandEvent& event);
99 void OnAbout(wxCommandEvent& event);
100
f6bcfd97
BP
101 void OnSize(wxSizeEvent& event);
102
103 void OnToggleAnotherToolbar(wxCommandEvent& event);
104
5ef2e633
VZ
105 void OnToggleToolbarSize(wxCommandEvent& event);
106 void OnToggleToolbarOrient(wxCommandEvent& event);
98066234 107 void OnToggleToolbarRows(wxCommandEvent& event);
5ef2e633 108
ad4ae6ed
VZ
109 void OnEnablePrint(wxCommandEvent& WXUNUSED(event)) { DoEnablePrint(); }
110 void OnDeletePrint(wxCommandEvent& WXUNUSED(event)) { DoDeletePrint(); }
bdc72a22 111 void OnInsertPrint(wxCommandEvent& event);
ad4ae6ed 112 void OnToggleHelp(wxCommandEvent& WXUNUSED(event)) { DoToggleHelp(); }
ad9bb75f 113
ad9bb75f
VZ
114 void OnToolLeftClick(wxCommandEvent& event);
115 void OnToolEnter(wxCommandEvent& event);
116
1c383dba
VZ
117 void OnCombo(wxCommandEvent& event);
118
5ef2e633
VZ
119 void OnUpdateCopyAndCut(wxUpdateUIEvent& event);
120
b487a08f
JS
121 void OnToggleFullScreen(wxCommandEvent& event);
122
ad4ae6ed
VZ
123#if USE_GENERIC_TBAR
124 virtual wxToolBar *OnCreateToolBar(long style,
125 wxWindowID id,
126 const wxString& name );
127#endif // USE_GENERIC_TBAR
128
ad9bb75f
VZ
129private:
130 void DoEnablePrint();
97d7bfb8 131 void DoDeletePrint();
ad9bb75f
VZ
132 void DoToggleHelp();
133
f6bcfd97
BP
134 void LayoutChildren();
135
5ef2e633
VZ
136 bool m_smallToolbar,
137 m_horzToolbar;
98066234
VZ
138 size_t m_rows; // 1 or 2 only
139
f6bcfd97
BP
140 wxTextCtrl *m_textWindow;
141
142 wxToolBar *m_tbar;
ad9bb75f 143
ad9bb75f
VZ
144 DECLARE_EVENT_TABLE()
145};
146
147// ----------------------------------------------------------------------------
148// constants
149// ----------------------------------------------------------------------------
150
151const int ID_TOOLBAR = 500;
152
153enum
14d1ccd8 154{
5ef2e633
VZ
155 IDM_TOOLBAR_TOGGLETOOLBARSIZE = 200,
156 IDM_TOOLBAR_TOGGLETOOLBARORIENT,
98066234 157 IDM_TOOLBAR_TOGGLETOOLBARROWS,
ad9bb75f 158 IDM_TOOLBAR_ENABLEPRINT,
97d7bfb8 159 IDM_TOOLBAR_DELETEPRINT,
bdc72a22 160 IDM_TOOLBAR_INSERTPRINT,
1c383dba 161 IDM_TOOLBAR_TOGGLEHELP,
b487a08f 162 IDM_TOOLBAR_TOGGLEFULLSCREEN,
f6bcfd97 163 IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR,
1c383dba
VZ
164
165 ID_COMBO = 1000
ad9bb75f 166};
14d1ccd8 167
ad9bb75f
VZ
168// ----------------------------------------------------------------------------
169// event tables
170// ----------------------------------------------------------------------------
14d1ccd8 171
ad9bb75f
VZ
172// Notice that wxID_HELP will be processed for the 'About' menu and the toolbar
173// help button.
14d1ccd8 174
ad9bb75f 175BEGIN_EVENT_TABLE(MyFrame, wxFrame)
f6bcfd97
BP
176 EVT_SIZE(MyFrame::OnSize)
177
ad9bb75f
VZ
178 EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
179 EVT_MENU(wxID_HELP, MyFrame::OnAbout)
14d1ccd8 180
f6bcfd97
BP
181 EVT_MENU(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR, MyFrame::OnToggleAnotherToolbar)
182
5ef2e633
VZ
183 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARSIZE, MyFrame::OnToggleToolbarSize)
184 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARORIENT, MyFrame::OnToggleToolbarOrient)
98066234 185 EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBARROWS, MyFrame::OnToggleToolbarRows)
5ef2e633 186
ad9bb75f 187 EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
97d7bfb8 188 EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint)
bdc72a22 189 EVT_MENU(IDM_TOOLBAR_INSERTPRINT, MyFrame::OnInsertPrint)
ad9bb75f 190 EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp)
b487a08f 191 EVT_MENU(IDM_TOOLBAR_TOGGLEFULLSCREEN, MyFrame::OnToggleFullScreen)
14d1ccd8 192
ad9bb75f 193 EVT_MENU(-1, MyFrame::OnToolLeftClick)
14d1ccd8 194
1c383dba
VZ
195 EVT_COMBOBOX(ID_COMBO, MyFrame::OnCombo)
196
ad9bb75f 197 EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter)
5ef2e633
VZ
198
199 EVT_UPDATE_UI(wxID_COPY, MyFrame::OnUpdateCopyAndCut)
200 EVT_UPDATE_UI(wxID_CUT, MyFrame::OnUpdateCopyAndCut)
ad9bb75f 201END_EVENT_TABLE()
14d1ccd8 202
ad9bb75f
VZ
203// ============================================================================
204// implementation
205// ============================================================================
14d1ccd8 206
ad9bb75f
VZ
207// ----------------------------------------------------------------------------
208// MyApp
209// ----------------------------------------------------------------------------
14d1ccd8 210
ad9bb75f 211IMPLEMENT_APP(MyApp)
14d1ccd8 212
ad9bb75f
VZ
213// The `main program' equivalent, creating the windows and returning the
214// main frame
215bool MyApp::OnInit()
216{
217 // Create the main frame window
218 MyFrame* frame = new MyFrame((wxFrame *) NULL, -1,
219 "wxToolBar Sample",
220 wxPoint(100, 100), wxSize(450, 300));
14d1ccd8 221
7fb23305
VZ
222 frame->Show(TRUE);
223
224 frame->SetStatusText("Hello, wxWindows");
225
226 SetTopWindow(frame);
227
228 return TRUE;
14d1ccd8
JS
229}
230
5ef2e633 231void MyFrame::RecreateToolbar()
14d1ccd8 232{
5ef2e633 233 // delete and recreate the toolbar
ad4ae6ed 234 wxToolBarBase *toolBar = GetToolBar();
5ef2e633 235 delete toolBar;
14d1ccd8 236
5ef2e633
VZ
237 SetToolBar(NULL);
238
239 long style = wxNO_BORDER | wxTB_FLAT | wxTB_DOCKABLE;
240 style |= m_horzToolbar ? wxTB_HORIZONTAL : wxTB_VERTICAL;
241
242 toolBar = CreateToolBar(style, ID_TOOLBAR);
243 toolBar->SetMargins( 4, 4 );
244
245 // Set up toolbar
246 wxBitmap toolBarBitmaps[8];
247
f6bcfd97
BP
248#if USE_XPM_BITMAPS
249 toolBarBitmaps[0] = wxBitmap(new_xpm);
250 toolBarBitmaps[1] = wxBitmap(open_xpm);
251 toolBarBitmaps[2] = wxBitmap(save_xpm);
252 toolBarBitmaps[3] = wxBitmap(copy_xpm);
253 toolBarBitmaps[4] = wxBitmap(cut_xpm);
254 toolBarBitmaps[5] = wxBitmap(paste_xpm);
255 toolBarBitmaps[6] = wxBitmap(print_xpm);
256 toolBarBitmaps[7] = wxBitmap(help_xpm);
257#else // !USE_XPM_BITMAPS
5ef2e633
VZ
258 toolBarBitmaps[0] = wxBITMAP(new);
259 toolBarBitmaps[1] = wxBITMAP(open);
40515a21
VZ
260 toolBarBitmaps[2] = wxBITMAP(save);
261 toolBarBitmaps[3] = wxBITMAP(copy);
262 toolBarBitmaps[4] = wxBITMAP(cut);
263 toolBarBitmaps[5] = wxBITMAP(paste);
264 toolBarBitmaps[6] = wxBITMAP(print);
265 toolBarBitmaps[7] = wxBITMAP(help);
f6bcfd97 266#endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
40515a21 267
5ef2e633
VZ
268 if ( !m_smallToolbar )
269 {
40515a21
VZ
270 int w = 2*toolBarBitmaps[0].GetWidth(),
271 h = 2*toolBarBitmaps[0].GetHeight();
272 for ( size_t n = 0; n < WXSIZEOF(toolBarBitmaps); n++ )
273 {
274 toolBarBitmaps[n] =
275 wxImage(toolBarBitmaps[n]).Scale(w, h).ConvertToBitmap();
276 }
277
278 toolBar->SetToolBitmapSize(wxSize(w, h));
5ef2e633 279 }
14d1ccd8
JS
280
281#ifdef __WXMSW__
5ef2e633 282 int width = 24;
14d1ccd8 283#else
5ef2e633 284 int width = 16;
14d1ccd8 285#endif
c8f1f088 286
5ef2e633 287 int currentX = 5;
7fb23305 288
5ef2e633
VZ
289 toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "New file");
290 currentX += width + 5;
291 toolBar->AddTool(wxID_OPEN, toolBarBitmaps[1], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Open file");
14d1ccd8 292
ad4ae6ed
VZ
293 // neither the generic nor Motif native toolbars really support this
294#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__)
5ef2e633
VZ
295 // adding a combo to a vertical toolbar is not very smart
296 if ( m_horzToolbar )
297 {
298 wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO);
299 combo->Append("This");
300 combo->Append("is a");
301 combo->Append("combobox");
302 combo->Append("in a");
303 combo->Append("toolbar");
304 toolBar->AddControl(combo);
305 }
ad4ae6ed 306#endif // toolbars which don't support controls
14d1ccd8 307
40515a21
VZ
308 currentX += width + 5;
309 toolBar->AddTool(wxID_SAVE, toolBarBitmaps[2], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1");
310 currentX += width + 5;
311 toolBar->AddTool(wxID_COPY, toolBarBitmaps[3], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 2");
312 currentX += width + 5;
313 toolBar->AddTool(wxID_CUT, toolBarBitmaps[4], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Toggle/Untoggle help button");
314 currentX += width + 5;
315 toolBar->AddTool(wxID_PASTE, toolBarBitmaps[5], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste");
316 currentX += width + 5;
317 toolBar->AddTool(wxID_PRINT, toolBarBitmaps[6], wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Delete this tool");
318 currentX += width + 5;
319 toolBar->AddSeparator();
320 toolBar->AddTool(wxID_HELP, toolBarBitmaps[7], wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help button");
13437238 321
5ef2e633
VZ
322 // after adding the buttons to the toolbar, must call Realize() to reflect
323 // the changes
324 toolBar->Realize();
98066234
VZ
325
326 toolBar->SetRows(m_horzToolbar ? m_rows : 10 / m_rows);
14d1ccd8
JS
327}
328
ad9bb75f
VZ
329// ----------------------------------------------------------------------------
330// MyFrame
331// ----------------------------------------------------------------------------
13437238
JS
332
333// Define my frame constructor
7fb23305
VZ
334MyFrame::MyFrame(wxFrame* parent,
335 wxWindowID id,
336 const wxString& title,
337 const wxPoint& pos,
338 const wxSize& size,
339 long style)
340 : wxFrame(parent, id, title, pos, size, style)
14d1ccd8 341{
f6bcfd97 342 m_tbar = NULL;
e179bd65 343 m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
98066234 344
40515a21 345 m_smallToolbar = TRUE;
98066234
VZ
346 m_horzToolbar = TRUE;
347 m_rows = 1;
ad9bb75f
VZ
348
349 // Give it a status line
350 CreateStatusBar();
351
352 // Give it an icon
353 SetIcon(wxICON(mondrian));
354
355 // Make a menubar
356 wxMenu *tbarMenu = new wxMenu;
f6bcfd97
BP
357 tbarMenu->Append(IDM_TOOLBAR_TOGGLE_ANOTHER_TOOLBAR,
358 "Toggle &another toolbar\tCtrl-A",
359 "Show/hide another test toolbar",
360 TRUE);
361
5ef2e633
VZ
362 tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBARSIZE,
363 "&Toggle toolbar size\tCtrl-S",
364 "Toggle between big/small toolbar",
365 TRUE);
366 tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBARORIENT,
367 "Toggle toolbar &orientation\tCtrl-O",
368 "Toggle toolbar orientation",
369 TRUE);
98066234
VZ
370 tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBARROWS,
371 "Toggle number of &rows\tCtrl-R",
372 "Toggle number of toolbar rows between 1 and 2",
373 TRUE);
5ef2e633
VZ
374
375 tbarMenu->AppendSeparator();
376
fc6bbc6d
VZ
377 tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, "&Enable print button\tCtrl-E", "");
378 tbarMenu->Append(IDM_TOOLBAR_DELETEPRINT, "&Delete print button\tCtrl-D", "");
379 tbarMenu->Append(IDM_TOOLBAR_INSERTPRINT, "&Insert print button\tCtrl-I", "");
380 tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button\tCtrl-T", "");
ad9bb75f 381
b487a08f
JS
382#ifdef __WXMSW__
383 tbarMenu->AppendSeparator();
384 tbarMenu->Append(IDM_TOOLBAR_TOGGLEFULLSCREEN, "Toggle &full screen mode\tCtrl-F", "");
385#endif
386
ad9bb75f
VZ
387 wxMenu *fileMenu = new wxMenu;
388 fileMenu->Append(wxID_EXIT, "E&xit", "Quit toolbar sample" );
389
ad9bb75f
VZ
390 wxMenu *helpMenu = new wxMenu;
391 helpMenu->Append(wxID_HELP, "&About", "About toolbar sample");
392
393 wxMenuBar* menuBar = new wxMenuBar( wxMB_DOCKABLE );
394
395 menuBar->Append(fileMenu, "&File");
396 menuBar->Append(tbarMenu, "&Toolbar");
ad9bb75f
VZ
397 menuBar->Append(helpMenu, "&Help");
398
399 // Associate the menu bar with the frame
400 SetMenuBar(menuBar);
401
402 // Create the toolbar
5ef2e633
VZ
403 RecreateToolbar();
404}
ad9bb75f 405
ad4ae6ed
VZ
406#if USE_GENERIC_TBAR
407
408wxToolBar* MyFrame::OnCreateToolBar(long style,
409 wxWindowID id,
410 const wxString& name)
411{
412 return (wxToolBar *)new wxToolBarSimple(this, id,
413 wxDefaultPosition, wxDefaultSize,
414 style, name);
415}
416
417#endif // USE_GENERIC_TBAR
418
f6bcfd97
BP
419void MyFrame::LayoutChildren()
420{
421 wxSize size = GetClientSize();
422
423 int offset;
424 if ( m_tbar )
425 {
426 m_tbar->SetSize(-1, size.y);
427 m_tbar->Move(0, 0);
428
429 offset = m_tbar->GetSize().x;
430 }
431 else
432 {
433 offset = 0;
434 }
435
436 m_textWindow->SetSize(offset, 0, size.x - offset, size.y);
437}
438
439void MyFrame::OnSize(wxSizeEvent& event)
440{
441 if ( m_tbar )
442 {
443 LayoutChildren();
444 }
445 else
446 {
447 event.Skip();
448 }
449}
450
451void MyFrame::OnToggleAnotherToolbar(wxCommandEvent& WXUNUSED(event))
452{
453 if ( m_tbar )
454 {
455 delete m_tbar;
456 m_tbar = NULL;
457 }
458 else
459 {
460 m_tbar = new wxToolBar(this, -1,
461 wxDefaultPosition, wxDefaultSize,
462 wxTB_VERTICAL);
463 m_tbar->AddTool(wxID_HELP, wxBITMAP(help),
464 wxNullBitmap, FALSE,
465 NULL,
466 "This is the help button",
467 "This is the long help for the help button");
468 m_tbar->Realize();
469 }
470
471 LayoutChildren();
472}
473
5ef2e633
VZ
474void MyFrame::OnToggleToolbarSize(wxCommandEvent& WXUNUSED(event))
475{
476 m_smallToolbar = !m_smallToolbar;
ad9bb75f 477
5ef2e633 478 RecreateToolbar();
7fb23305
VZ
479}
480
98066234
VZ
481void MyFrame::OnToggleToolbarRows(wxCommandEvent& WXUNUSED(event))
482{
483 // m_rows may be only 1 or 2
484 m_rows = 3 - m_rows;
485
486 GetToolBar()->SetRows(m_horzToolbar ? m_rows : 10 / m_rows);
487
9fb35cf1 488 //RecreateToolbar(); -- this is unneeded
98066234
VZ
489}
490
5ef2e633 491void MyFrame::OnToggleToolbarOrient(wxCommandEvent& WXUNUSED(event))
7fb23305 492{
5ef2e633 493 m_horzToolbar = !m_horzToolbar;
7fb23305 494
5ef2e633 495 RecreateToolbar();
14d1ccd8
JS
496}
497
47908e25 498void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
14d1ccd8 499{
13437238 500 Close(TRUE);
14d1ccd8
JS
501}
502
47908e25 503void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
14d1ccd8 504{
1d5b7a0b 505 (void)wxMessageBox("wxWindows toolbar sample", "About wxToolBar");
13437238 506}
14d1ccd8 507
13437238
JS
508void MyFrame::OnToolLeftClick(wxCommandEvent& event)
509{
e179bd65
RR
510 wxString str;
511 str.Printf( _T("Clicked on tool %d\n"), event.GetId());
512 m_textWindow->WriteText( str );
ad9bb75f 513
e179bd65
RR
514 if (event.GetId() == wxID_HELP)
515 {
ad9bb75f 516 if ( event.GetExtraLong() != 0 )
e179bd65
RR
517 m_textWindow->WriteText( _T("Help button down now.\n") );
518 else
519 m_textWindow->WriteText( _T("Help button up now.\n") );
520 }
ad9bb75f 521
e179bd65
RR
522 if (event.GetId() == wxID_COPY)
523 {
7fb23305 524 DoEnablePrint();
e179bd65 525 }
ad9bb75f 526
e179bd65
RR
527 if (event.GetId() == wxID_CUT)
528 {
7fb23305 529 DoToggleHelp();
e179bd65 530 }
1c4f8f8d 531
97d7bfb8
RR
532 if (event.GetId() == wxID_PRINT)
533 {
534 DoDeletePrint();
535 }
14d1ccd8
JS
536}
537
1c383dba
VZ
538void MyFrame::OnCombo(wxCommandEvent& event)
539{
540 wxLogStatus(_T("Combobox string '%s' selected"), event.GetString().c_str());
541}
542
7fb23305
VZ
543void MyFrame::DoEnablePrint()
544{
ad4ae6ed 545 wxToolBarBase *tb = GetToolBar();
7fb23305
VZ
546 if (tb->GetToolEnabled(wxID_PRINT))
547 tb->EnableTool( wxID_PRINT, FALSE );
548 else
549 tb->EnableTool( wxID_PRINT, TRUE );
550}
551
97d7bfb8
RR
552void MyFrame::DoDeletePrint()
553{
ad4ae6ed 554 wxToolBarBase *tb = GetToolBar();
1c4f8f8d 555
97d7bfb8
RR
556 tb->DeleteTool( wxID_PRINT );
557}
558
7fb23305
VZ
559void MyFrame::DoToggleHelp()
560{
ad4ae6ed 561 wxToolBarBase *tb = GetToolBar();
7fb23305
VZ
562 tb->ToggleTool( wxID_HELP, !tb->GetToolState( wxID_HELP ) );
563}
564
5ef2e633
VZ
565void MyFrame::OnUpdateCopyAndCut(wxUpdateUIEvent& event)
566{
567 event.Enable( m_textWindow->CanCopy() );
568}
569
bdc72a22
VZ
570void MyFrame::OnInsertPrint(wxCommandEvent& WXUNUSED(event))
571{
5ef2e633 572 wxBitmap bmp = wxBITMAP(print);
bdc72a22 573
fc6bbc6d 574 GetToolBar()->InsertTool(0, wxID_PRINT, bmp, wxNullBitmap,
5ef2e633
VZ
575 FALSE, (wxObject *) NULL,
576 "Delete this tool",
577 "This button was inserted into the toolbar");
bdc72a22
VZ
578
579 GetToolBar()->Realize();
580}
581
13437238
JS
582void MyFrame::OnToolEnter(wxCommandEvent& event)
583{
ad4ae6ed
VZ
584 if (event.GetSelection() > -1)
585 {
586 wxString str;
587 str.Printf(_T("This is tool number %d"), event.GetSelection());
588 SetStatusText(str);
589 }
590 else
591 SetStatusText("");
13437238 592}
14d1ccd8 593
b487a08f
JS
594void MyFrame::OnToggleFullScreen(wxCommandEvent& event)
595{
596#ifdef __WXMSW__
597 ShowFullScreen(!IsFullScreen());
598#endif
599}
600