]> git.saurik.com Git - wxWidgets.git/blame - samples/mdi/mdi.cpp
fix the length passed to wxMB2WC (replaces patch 1554431); don't use (and especially...
[wxWidgets.git] / samples / mdi / mdi.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: mdi.cpp
3// Purpose: MDI sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6aa89a22 8// Copyright: (c) Julian Smart
c52d95b4 9// Licence: wxWindows license
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
c52d95b4
VZ
12// ===========================================================================
13// declarations
14// ===========================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
c801d85f
KB
20// For compilers that support precompilation, includes "wx/wx.h".
21#include "wx/wxprec.h"
22
23#ifdef __BORLANDC__
c52d95b4 24 #pragma hdrstop
c801d85f
KB
25#endif
26
27#ifndef WX_PRECOMP
c52d95b4
VZ
28 #include "wx/wx.h"
29 #include "wx/mdi.h"
c801d85f
KB
30#endif
31
012f2cb2 32#include "wx/toolbar.h"
c801d85f 33
9fa453ec 34#if !defined(__WXMSW__)
c52d95b4 35 #include "mondrian.xpm"
716b7364
RR
36#endif
37
d04d32c4
CE
38#include "bitmaps/new.xpm"
39#include "bitmaps/open.xpm"
40#include "bitmaps/save.xpm"
41#include "bitmaps/copy.xpm"
42#include "bitmaps/cut.xpm"
43#include "bitmaps/paste.xpm"
44#include "bitmaps/print.xpm"
45#include "bitmaps/help.xpm"
46
47
c801d85f
KB
48#include "mdi.h"
49
c52d95b4
VZ
50IMPLEMENT_APP(MyApp)
51
52// ---------------------------------------------------------------------------
53// global variables
54// ---------------------------------------------------------------------------
55
c67daf87 56MyFrame *frame = (MyFrame *) NULL;
c801d85f
KB
57wxList my_children;
58
c801d85f 59// For drawing lines in a canvas
c52d95b4
VZ
60static long xpos = -1;
61static long ypos = -1;
62
63static int gs_nFrames = 0;
64
65// ---------------------------------------------------------------------------
66// event tables
67// ---------------------------------------------------------------------------
68
69BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
70 EVT_MENU(MDI_ABOUT, MyFrame::OnAbout)
71 EVT_MENU(MDI_NEW_WINDOW, MyFrame::OnNewWindow)
72 EVT_MENU(MDI_QUIT, MyFrame::OnQuit)
73
74 EVT_CLOSE(MyFrame::OnClose)
c52d95b4
VZ
75 EVT_SIZE(MyFrame::OnSize)
76END_EVENT_TABLE()
77
78// Note that MDI_NEW_WINDOW and MDI_ABOUT commands get passed
79// to the parent window for processing, so no need to
80// duplicate event handlers here.
81BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
82 EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
83 EVT_MENU(MDI_REFRESH, MyChild::OnRefresh)
f6bcfd97 84 EVT_MENU(MDI_CHANGE_TITLE, MyChild::OnChangeTitle)
3d8dea7e
VZ
85 EVT_MENU(MDI_CHANGE_POSITION, MyChild::OnChangePosition)
86 EVT_MENU(MDI_CHANGE_SIZE, MyChild::OnChangeSize)
87
c9f856af
VZ
88#if wxUSE_CLIPBOARD
89 EVT_MENU(wxID_PASTE, MyChild::OnPaste)
90 EVT_UPDATE_UI(wxID_PASTE, MyChild::OnUpdatePaste)
91#endif // wxUSE_CLIPBOARD
92
3d8dea7e
VZ
93 EVT_SIZE(MyChild::OnSize)
94 EVT_MOVE(MyChild::OnMove)
c52d95b4
VZ
95
96 EVT_CLOSE(MyChild::OnClose)
97END_EVENT_TABLE()
98
99BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
100 EVT_MOUSE_EVENTS(MyCanvas::OnEvent)
101END_EVENT_TABLE()
102
103// ===========================================================================
104// implementation
105// ===========================================================================
c801d85f 106
c52d95b4
VZ
107// ---------------------------------------------------------------------------
108// MyApp
109// ---------------------------------------------------------------------------
c801d85f
KB
110
111// Initialise this in OnInit, not statically
c52d95b4 112bool MyApp::OnInit()
c801d85f 113{
c52d95b4 114 // Create the main frame window
c801d85f 115
eb839c84
WS
116 frame = new MyFrame((wxFrame *)NULL, wxID_ANY, _T("MDI Demo"),
117 wxDefaultPosition, wxSize(500, 400),
c52d95b4 118 wxDEFAULT_FRAME_STYLE | wxHSCROLL | wxVSCROLL);
df61c009
JS
119#ifdef __WXMSW__
120#if 0
121 // Experimental: change the window menu
122 wxMenu* windowMenu = new wxMenu;
42ed7532 123 windowMenu->Append(5000, _T("My menu item!"));
df61c009
JS
124 frame->SetWindowMenu(windowMenu);
125#endif
126#endif
c801d85f 127
c52d95b4 128 // Give it an icon
2049ba38 129#ifdef __WXMSW__
42ed7532 130 frame->SetIcon(wxIcon(_T("mdi_icn")));
52cbfcf0 131#else
c52d95b4 132 frame->SetIcon(wxIcon( mondrian_xpm ));
c801d85f 133#endif
c801d85f 134
c52d95b4
VZ
135 // Make a menubar
136 wxMenu *file_menu = new wxMenu;
c801d85f 137
42ed7532
MB
138 file_menu->Append(MDI_NEW_WINDOW, _T("&New window\tCtrl-N"), _T("Create a new child window"));
139 file_menu->Append(MDI_QUIT, _T("&Exit\tAlt-X"), _T("Quit the program"));
c801d85f 140
c52d95b4 141 wxMenu *help_menu = new wxMenu;
42ed7532 142 help_menu->Append(MDI_ABOUT, _T("&About\tF1"));
c801d85f 143
c52d95b4 144 wxMenuBar *menu_bar = new wxMenuBar;
c801d85f 145
42ed7532
MB
146 menu_bar->Append(file_menu, _T("&File"));
147 menu_bar->Append(help_menu, _T("&Help"));
c801d85f 148
c52d95b4
VZ
149 // Associate the menu bar with the frame
150 frame->SetMenuBar(menu_bar);
c801d85f 151
8520f137 152#if wxUSE_STATUSBAR
c52d95b4 153 frame->CreateStatusBar();
8520f137 154#endif // wxUSE_STATUSBAR
c801d85f 155
eb839c84 156 frame->Show(true);
c801d85f 157
c52d95b4 158 SetTopWindow(frame);
c801d85f 159
eb839c84 160 return true;
c801d85f
KB
161}
162
c52d95b4
VZ
163// ---------------------------------------------------------------------------
164// MyFrame
165// ---------------------------------------------------------------------------
c801d85f
KB
166
167// Define my frame constructor
c52d95b4
VZ
168MyFrame::MyFrame(wxWindow *parent,
169 const wxWindowID id,
170 const wxString& title,
171 const wxPoint& pos,
172 const wxSize& size,
173 const long style)
3ebcfb76
VZ
174 : wxMDIParentFrame(parent, id, title, pos, size,
175 style | wxNO_FULL_REPAINT_ON_RESIZE)
c801d85f 176{
eb839c84 177 textWindow = new wxTextCtrl(this, wxID_ANY, _T("A help window"),
c52d95b4
VZ
178 wxDefaultPosition, wxDefaultSize,
179 wxTE_MULTILINE | wxSUNKEN_BORDER);
c801d85f 180
6ceba174 181#if wxUSE_TOOLBAR
fa762db4 182 CreateToolBar(wxNO_BORDER | wxTB_FLAT | wxTB_HORIZONTAL);
81d66cf3 183 InitToolBar(GetToolBar());
6ceba174 184#endif // wxUSE_TOOLBAR
57a7b7c1 185
4219b5e7 186#if wxUSE_ACCEL
57a7b7c1
JS
187 // Accelerators
188 wxAcceleratorEntry entries[3];
189 entries[0].Set(wxACCEL_CTRL, (int) 'N', MDI_NEW_WINDOW);
190 entries[1].Set(wxACCEL_CTRL, (int) 'X', MDI_QUIT);
191 entries[2].Set(wxACCEL_CTRL, (int) 'A', MDI_ABOUT);
192 wxAcceleratorTable accel(3, entries);
193 SetAcceleratorTable(accel);
4219b5e7 194#endif // wxUSE_ACCEL
c801d85f
KB
195}
196
c52d95b4
VZ
197void MyFrame::OnClose(wxCloseEvent& event)
198{
199 if ( event.CanVeto() && (gs_nFrames > 0) )
200 {
201 wxString msg;
ddb6bc71 202 msg.Printf(_T("%d windows still open, close anyhow?"), gs_nFrames);
42ed7532 203 if ( wxMessageBox(msg, _T("Please confirm"),
c52d95b4
VZ
204 wxICON_QUESTION | wxYES_NO) != wxYES )
205 {
206 event.Veto();
207
208 return;
209 }
210 }
211
212 event.Skip();
213}
214
215void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
c801d85f 216{
c52d95b4 217 Close();
c801d85f
KB
218}
219
e3e65dac 220void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
c801d85f 221{
be5a51fb 222 (void)wxMessageBox(_T("wxWidgets 2.0 MDI Demo\n")
42ed7532
MB
223 _T("Author: Julian Smart (c) 1997\n")
224 _T("Usage: mdi.exe"), _T("About MDI Demo"));
c801d85f
KB
225}
226
e3e65dac 227void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
c801d85f 228{
c52d95b4 229 // Make another frame, containing a canvas
eb839c84 230 MyChild *subframe = new MyChild(frame, _T("Canvas Frame"));
c801d85f 231
c52d95b4 232 wxString title;
ddb6bc71 233 title.Printf(_T("Canvas Frame %d"), ++gs_nFrames);
c801d85f 234
c52d95b4
VZ
235 subframe->SetTitle(title);
236
237 // Give it an icon
2049ba38 238#ifdef __WXMSW__
42ed7532 239 subframe->SetIcon(wxIcon(_T("chrt_icn")));
8704bf74 240#else
c52d95b4 241 subframe->SetIcon(wxIcon( mondrian_xpm ));
c801d85f
KB
242#endif
243
290c74fb 244#if wxUSE_MENUS
c52d95b4
VZ
245 // Make a menubar
246 wxMenu *file_menu = new wxMenu;
247
42ed7532
MB
248 file_menu->Append(MDI_NEW_WINDOW, _T("&New window"));
249 file_menu->Append(MDI_CHILD_QUIT, _T("&Close child"), _T("Close this window"));
250 file_menu->Append(MDI_QUIT, _T("&Exit"));
c801d85f 251
c52d95b4 252 wxMenu *option_menu = new wxMenu;
c801d85f 253
42ed7532
MB
254 option_menu->Append(MDI_REFRESH, _T("&Refresh picture"));
255 option_menu->Append(MDI_CHANGE_TITLE, _T("Change &title...\tCtrl-T"));
fa762db4 256 option_menu->AppendSeparator();
42ed7532
MB
257 option_menu->Append(MDI_CHANGE_POSITION, _T("Move frame\tCtrl-M"));
258 option_menu->Append(MDI_CHANGE_SIZE, _T("Resize frame\tCtrl-S"));
c9f856af
VZ
259#if wxUSE_CLIPBOARD
260 option_menu->AppendSeparator();
261 option_menu->Append(wxID_PASTE, _T("Copy text from clipboard\tCtrl-V"));
262#endif // wxUSE_CLIPBOARD
c801d85f 263
c52d95b4 264 wxMenu *help_menu = new wxMenu;
42ed7532 265 help_menu->Append(MDI_ABOUT, _T("&About"));
c801d85f 266
c52d95b4 267 wxMenuBar *menu_bar = new wxMenuBar;
c801d85f 268
42ed7532
MB
269 menu_bar->Append(file_menu, _T("&File"));
270 menu_bar->Append(option_menu, _T("&Child"));
271 menu_bar->Append(help_menu, _T("&Help"));
c801d85f 272
c52d95b4
VZ
273 // Associate the menu bar with the frame
274 subframe->SetMenuBar(menu_bar);
290c74fb 275#endif // wxUSE_MENUS
c801d85f 276
8520f137 277#if wxUSE_STATUSBAR
c41ea66a
VZ
278 subframe->CreateStatusBar();
279 subframe->SetStatusText(title);
8520f137 280#endif // wxUSE_STATUSBAR
c41ea66a 281
c52d95b4
VZ
282 int width, height;
283 subframe->GetClientSize(&width, &height);
284 MyCanvas *canvas = new MyCanvas(subframe, wxPoint(0, 0), wxSize(width, height));
285 canvas->SetCursor(wxCursor(wxCURSOR_PENCIL));
286 subframe->canvas = canvas;
c801d85f 287
c52d95b4
VZ
288 // Give it scrollbars
289 canvas->SetScrollbars(20, 20, 50, 50);
c801d85f 290
eb839c84 291 subframe->Show(true);
c801d85f
KB
292}
293
4219b5e7 294void MyFrame::OnSize(wxSizeEvent&
5f58391f
JS
295 #ifdef __WXUNIVERSAL__
296 event
297 #else
298 WXUNUSED(event)
299 #endif
300 )
c52d95b4
VZ
301{
302 int w, h;
303 GetClientSize(&w, &h);
304
305 textWindow->SetSize(0, 0, 200, h);
306 GetClientWindow()->SetSize(200, 0, w - 200, h);
a9c824e9
JS
307
308 // FIXME: On wxX11, we need the MDI frame to process this
309 // event, but on other platforms this should not
310 // be done.
4219b5e7 311#ifdef __WXUNIVERSAL__
b9f933ab 312 event.Skip();
a9c824e9 313#endif
c52d95b4
VZ
314}
315
6ceba174 316#if wxUSE_TOOLBAR
c52d95b4
VZ
317void MyFrame::InitToolBar(wxToolBar* toolBar)
318{
319 wxBitmap* bitmaps[8];
320
c52d95b4
VZ
321 bitmaps[0] = new wxBitmap( new_xpm );
322 bitmaps[1] = new wxBitmap( open_xpm );
323 bitmaps[2] = new wxBitmap( save_xpm );
324 bitmaps[3] = new wxBitmap( copy_xpm );
325 bitmaps[4] = new wxBitmap( cut_xpm );
326 bitmaps[5] = new wxBitmap( paste_xpm );
327 bitmaps[6] = new wxBitmap( print_xpm );
328 bitmaps[7] = new wxBitmap( help_xpm );
c52d95b4 329
c52d95b4 330 int width = 24;
c52d95b4
VZ
331 int currentX = 5;
332
422d0ff0 333 toolBar->AddTool( MDI_NEW_WINDOW, *(bitmaps[0]), wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("New file"));
c52d95b4 334 currentX += width + 5;
422d0ff0 335 toolBar->AddTool(1, *bitmaps[1], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Open file"));
c52d95b4 336 currentX += width + 5;
422d0ff0 337 toolBar->AddTool(2, *bitmaps[2], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Save file"));
c52d95b4
VZ
338 currentX += width + 5;
339 toolBar->AddSeparator();
422d0ff0 340 toolBar->AddTool(3, *bitmaps[3], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Copy"));
c52d95b4 341 currentX += width + 5;
422d0ff0 342 toolBar->AddTool(4, *bitmaps[4], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Cut"));
c52d95b4 343 currentX += width + 5;
422d0ff0 344 toolBar->AddTool(5, *bitmaps[5], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Paste"));
c52d95b4
VZ
345 currentX += width + 5;
346 toolBar->AddSeparator();
422d0ff0 347 toolBar->AddTool(6, *bitmaps[6], wxNullBitmap, false, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Print"));
c52d95b4
VZ
348 currentX += width + 5;
349 toolBar->AddSeparator();
422d0ff0 350 toolBar->AddTool( MDI_ABOUT, *bitmaps[7], wxNullBitmap, true, currentX, wxDefaultCoord, (wxObject *) NULL, _T("Help"));
c52d95b4
VZ
351
352 toolBar->Realize();
353
354 int i;
355 for (i = 0; i < 8; i++)
356 delete bitmaps[i];
357}
6ceba174 358#endif // wxUSE_TOOLBAR
c52d95b4
VZ
359
360// ---------------------------------------------------------------------------
361// MyCanvas
362// ---------------------------------------------------------------------------
c801d85f
KB
363
364// Define a constructor for my canvas
c52d95b4 365MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size)
eb839c84 366 : wxScrolledWindow(parent, wxID_ANY, pos, size,
3ebcfb76
VZ
367 wxSUNKEN_BORDER |
368 wxNO_FULL_REPAINT_ON_RESIZE |
369 wxVSCROLL | wxHSCROLL)
c801d85f 370{
42ed7532 371 SetBackgroundColour(wxColour(_T("WHITE")));
c52d95b4 372
eb839c84 373 m_dirty = false;
c801d85f
KB
374}
375
376// Define the repainting behaviour
377void MyCanvas::OnDraw(wxDC& dc)
378{
c9f856af
VZ
379 if ( !m_text.empty() )
380 dc.DrawText(m_text, 10, 10);
381
c52d95b4
VZ
382 dc.SetFont(*wxSWISS_FONT);
383 dc.SetPen(*wxGREEN_PEN);
384 dc.DrawLine(0, 0, 200, 200);
385 dc.DrawLine(200, 0, 0, 200);
386
387 dc.SetBrush(*wxCYAN_BRUSH);
388 dc.SetPen(*wxRED_PEN);
389 dc.DrawRectangle(100, 100, 100, 50);
390 dc.DrawRoundedRectangle(150, 150, 100, 50, 20);
391
392 dc.DrawEllipse(250, 250, 100, 50);
c41ea66a 393#if wxUSE_SPLINES
c52d95b4 394 dc.DrawSpline(50, 200, 50, 100, 200, 10);
c41ea66a 395#endif // wxUSE_SPLINES
c52d95b4 396 dc.DrawLine(50, 230, 200, 230);
42ed7532 397 dc.DrawText(_T("This is a test string"), 50, 230);
c52d95b4
VZ
398
399 wxPoint points[3];
400 points[0].x = 200; points[0].y = 300;
401 points[1].x = 100; points[1].y = 400;
402 points[2].x = 300; points[2].y = 400;
403
404 dc.DrawPolygon(3, points);
c801d85f
KB
405}
406
c52d95b4
VZ
407// This implements a tiny doodling program! Drag the mouse using the left
408// button.
c801d85f
KB
409void MyCanvas::OnEvent(wxMouseEvent& event)
410{
c52d95b4
VZ
411 wxClientDC dc(this);
412 PrepareDC(dc);
c801d85f 413
c52d95b4 414 wxPoint pt(event.GetLogicalPosition(dc));
c801d85f 415
c52d95b4
VZ
416 if (xpos > -1 && ypos > -1 && event.Dragging())
417 {
418 dc.SetPen(*wxBLACK_PEN);
419 dc.DrawLine(xpos, ypos, pt.x, pt.y);
c801d85f 420
eb839c84 421 m_dirty = true;
c52d95b4 422 }
c801d85f 423
c52d95b4
VZ
424 xpos = pt.x;
425 ypos = pt.y;
426}
427
428// ---------------------------------------------------------------------------
429// MyChild
430// ---------------------------------------------------------------------------
431
eb839c84
WS
432MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title)
433 : wxMDIChildFrame(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize,
434 wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
c801d85f 435{
c52d95b4
VZ
436 canvas = (MyCanvas *) NULL;
437 my_children.Append(this);
3ebcfb76
VZ
438
439 // this should work for MDI frames as well as for normal ones
440 SetSizeHints(100, 100);
c801d85f
KB
441}
442
c52d95b4 443MyChild::~MyChild()
c801d85f 444{
c52d95b4 445 my_children.DeleteObject(this);
c801d85f
KB
446}
447
33d0b396 448void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
c801d85f 449{
eb839c84 450 Close(true);
c52d95b4
VZ
451}
452
f6bcfd97
BP
453void MyChild::OnRefresh(wxCommandEvent& WXUNUSED(event))
454{
455 if ( canvas )
456 canvas->Refresh();
457}
458
fa762db4
VZ
459void MyChild::OnChangePosition(wxCommandEvent& WXUNUSED(event))
460{
461 Move(10, 10);
462}
463
464void MyChild::OnChangeSize(wxCommandEvent& WXUNUSED(event))
465{
466 SetClientSize(100, 100);
467}
468
f6bcfd97 469void MyChild::OnChangeTitle(wxCommandEvent& WXUNUSED(event))
c52d95b4 470{
2b5f62a0 471//#if wxUSE_TEXTDLG
f6bcfd97
BP
472 static wxString s_title = _T("Canvas Frame");
473
474 wxString title = wxGetTextFromUser(_T("Enter the new title for MDI child"),
475 _T("MDI sample question"),
476 s_title,
fa762db4 477 GetParent()->GetParent());
f6bcfd97
BP
478 if ( !title )
479 return;
480
481 s_title = title;
482 SetTitle(s_title);
2b5f62a0 483//#endif
c801d85f
KB
484}
485
486void MyChild::OnActivate(wxActivateEvent& event)
487{
c52d95b4
VZ
488 if ( event.GetActive() && canvas )
489 canvas->SetFocus();
c801d85f
KB
490}
491
fa762db4
VZ
492void MyChild::OnMove(wxMoveEvent& event)
493{
494 // VZ: here everything is totally wrong under MSW, the positions are
495 // different and both wrong (pos2 is off by 2 pixels for me which seems
496 // to be the width of the MDI canvas border)
497 wxPoint pos1 = event.GetPosition(),
498 pos2 = GetPosition();
4693b20c 499 wxLogStatus(wxT("position from event: (%d, %d), from frame (%d, %d)"),
fa762db4
VZ
500 pos1.x, pos1.y, pos2.x, pos2.y);
501
502 event.Skip();
503}
504
505void MyChild::OnSize(wxSizeEvent& event)
506{
507 // VZ: under MSW the size event carries the client size (quite
508 // unexpectedly) *except* for the very first one which has the full
509 // size... what should it really be? TODO: check under wxGTK
510 wxSize size1 = event.GetSize(),
511 size2 = GetSize(),
512 size3 = GetClientSize();
4693b20c 513 wxLogStatus(wxT("size from event: %dx%d, from frame %dx%d, client %dx%d"),
fa762db4
VZ
514 size1.x, size1.y, size2.x, size2.y, size3.x, size3.y);
515
516 event.Skip();
517}
518
c52d95b4 519void MyChild::OnClose(wxCloseEvent& event)
c801d85f 520{
c52d95b4
VZ
521 if ( canvas && canvas->IsDirty() )
522 {
42ed7532 523 if ( wxMessageBox(_T("Really close?"), _T("Please confirm"),
c52d95b4
VZ
524 wxICON_QUESTION | wxYES_NO) != wxYES )
525 {
526 event.Veto();
c801d85f 527
c52d95b4
VZ
528 return;
529 }
530 }
c801d85f 531
c52d95b4
VZ
532 gs_nFrames--;
533
534 event.Skip();
c801d85f 535}
c9f856af
VZ
536
537#if wxUSE_CLIPBOARD
538
539#include "wx/clipbrd.h"
540
541void MyChild::OnPaste(wxCommandEvent& WXUNUSED(event))
542{
543 wxClipboardLocker lock;
544 wxTextDataObject data;
37f66b04 545 canvas->SetText(wxTheClipboard->GetData(data) ? data.GetText().c_str()
c9f856af
VZ
546 : _T("No text on clipboard"));
547}
548
549void MyChild::OnUpdatePaste(wxUpdateUIEvent& event)
550{
551 wxClipboardLocker lock;
552 event.Enable( wxTheClipboard->IsSupported(wxDF_TEXT) );
553}
554
555#endif // wxUSE_CLIPBOARD