]> git.saurik.com Git - wxWidgets.git/blame - samples/splitter/splitter.cpp
fixing reentrancy which happened in tests, bringing client coordinates origins in...
[wxWidgets.git] / samples / splitter / splitter.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
6718d773 2// Name: splitter.cpp
c801d85f
KB
3// Purpose: wxSplitterWindow sample
4// Author: Julian Smart
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id$
6aa89a22 8// Copyright: (c) Julian Smart
526954c5 9// Licence: wxWindows licence
c801d85f
KB
10/////////////////////////////////////////////////////////////////////////////
11
2f294a9c
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__
2f294a9c 24 #pragma hdrstop
c801d85f
KB
25#endif
26
27#ifndef WX_PRECOMP
6faed57d
VZ
28 #include "wx/log.h"
29
30 #include "wx/app.h"
31 #include "wx/frame.h"
32
33 #include "wx/scrolwin.h"
34 #include "wx/menu.h"
35
36 #include "wx/textdlg.h" // for wxGetTextFromUser
c801d85f
KB
37#endif
38
39#include "wx/splitter.h"
a63e17c1 40#include "wx/dcmirror.h"
c801d85f 41
e7092398 42#ifndef wxHAS_IMAGES_IN_RESOURCES
41f02b9a
FM
43 #include "../sample.xpm"
44#endif
45
2f294a9c
VZ
46// ----------------------------------------------------------------------------
47// constants
48// ----------------------------------------------------------------------------
49
50// ID for the menu commands
51enum
52{
77e0a6d8 53 SPLIT_QUIT = 1,
2f294a9c
VZ
54 SPLIT_HORIZONTAL,
55 SPLIT_VERTICAL,
56 SPLIT_UNSPLIT,
b795f9ca 57 SPLIT_LIVE,
9b8d8755
VZ
58 SPLIT_BORDER,
59 SPLIT_3DSASH,
6faed57d 60 SPLIT_SETPOSITION,
14b4c0ff 61 SPLIT_SETMINSIZE,
8adaf733 62 SPLIT_SETGRAVITY,
c0430d96
VZ
63 SPLIT_REPLACE,
64 SPLIT_INVISIBLE
2f294a9c
VZ
65};
66
67// ----------------------------------------------------------------------------
68// our classes
69// ----------------------------------------------------------------------------
c801d85f
KB
70
71class MyApp: public wxApp
72{
73public:
a63e17c1
VZ
74 MyApp() { }
75
76 virtual bool OnInit();
77
c0c133e1 78 wxDECLARE_NO_COPY_CLASS(MyApp);
c801d85f
KB
79};
80
2f294a9c 81class MyFrame: public wxFrame
c801d85f
KB
82{
83public:
2f294a9c 84 MyFrame();
8adaf733 85 virtual ~MyFrame();
0d559d69 86
9b8d8755 87 void ToggleFlag(int flag, bool enable);
430bdeb5
FM
88
89 // Menu commands
90 void OnSplitHorizontal(wxCommandEvent& event);
91 void OnSplitVertical(wxCommandEvent& event);
92 void OnUnsplit(wxCommandEvent& event);
93 void OnToggleLive(wxCommandEvent& event)
9b8d8755 94 { ToggleFlag(wxSP_LIVE_UPDATE, event.IsChecked()); }
430bdeb5 95 void OnToggleBorder(wxCommandEvent& event)
9b8d8755 96 { ToggleFlag(wxSP_BORDER, event.IsChecked()); }
430bdeb5 97 void OnToggle3DSash(wxCommandEvent& event)
9b8d8755 98 { ToggleFlag(wxSP_3DSASH, event.IsChecked()); }
430bdeb5
FM
99 void OnSetPosition(wxCommandEvent& event);
100 void OnSetMinSize(wxCommandEvent& event);
101 void OnSetGravity(wxCommandEvent& event);
102 void OnReplace(wxCommandEvent &event);
c0430d96 103 void OnToggleInvisible(wxCommandEvent &event);
b795f9ca 104
430bdeb5 105 void OnQuit(wxCommandEvent& event);
4a0b46a7 106
2f294a9c 107 // Menu command update functions
430bdeb5
FM
108 void OnUpdateUIHorizontal(wxUpdateUIEvent& event);
109 void OnUpdateUIVertical(wxUpdateUIEvent& event);
110 void OnUpdateUIUnsplit(wxUpdateUIEvent& event);
c0430d96 111 void OnUpdateUIInvisible(wxUpdateUIEvent& event);
4a0b46a7 112
0d559d69 113private:
5c299305 114 wxWindow *m_left, *m_right;
2f294a9c
VZ
115
116 wxSplitterWindow* m_splitter;
8adaf733 117 wxWindow *m_replacewindow;
2f294a9c
VZ
118
119 DECLARE_EVENT_TABLE()
c0c133e1 120 wxDECLARE_NO_COPY_CLASS(MyFrame);
0d559d69 121};
c801d85f 122
2f294a9c 123class MySplitterWindow : public wxSplitterWindow
0d559d69
VZ
124{
125public:
2f294a9c 126 MySplitterWindow(wxFrame *parent);
c801d85f 127
2f294a9c
VZ
128 // event handlers
129 void OnPositionChanged(wxSplitterEvent& event);
130 void OnPositionChanging(wxSplitterEvent& event);
131 void OnDClick(wxSplitterEvent& event);
8ad18dc3 132 void OnUnsplitEvent(wxSplitterEvent& event);
c801d85f
KB
133
134private:
2f294a9c 135 wxFrame *m_frame;
0d559d69 136
2f294a9c 137 DECLARE_EVENT_TABLE()
c0c133e1 138 wxDECLARE_NO_COPY_CLASS(MySplitterWindow);
c801d85f
KB
139};
140
141class MyCanvas: public wxScrolledWindow
142{
143public:
a63e17c1 144 MyCanvas(wxWindow* parent, bool mirror);
925e9792 145 virtual ~MyCanvas(){};
c801d85f 146
2f294a9c 147 virtual void OnDraw(wxDC& dc);
a63e17c1
VZ
148
149private:
150 bool m_mirror;
151
c0c133e1 152 wxDECLARE_NO_COPY_CLASS(MyCanvas);
c801d85f
KB
153};
154
2f294a9c
VZ
155// ============================================================================
156// implementation
157// ============================================================================
c801d85f 158
2f294a9c
VZ
159// ----------------------------------------------------------------------------
160// MyApp
161// ----------------------------------------------------------------------------
0d57be45 162
c801d85f
KB
163IMPLEMENT_APP(MyApp)
164
2f294a9c 165bool MyApp::OnInit()
c801d85f 166{
45e6e6f8
VZ
167 if ( !wxApp::OnInit() )
168 return false;
169
2f294a9c
VZ
170 // create and show the main frame
171 MyFrame* frame = new MyFrame;
4a0b46a7 172
8ad18dc3 173 frame->Show(true);
c801d85f 174
8ad18dc3 175 return true;
c801d85f
KB
176}
177
2f294a9c
VZ
178// ----------------------------------------------------------------------------
179// MyFrame
180// ----------------------------------------------------------------------------
181
c801d85f 182BEGIN_EVENT_TABLE(MyFrame, wxFrame)
430bdeb5
FM
183 EVT_MENU(SPLIT_VERTICAL, MyFrame::OnSplitVertical)
184 EVT_MENU(SPLIT_HORIZONTAL, MyFrame::OnSplitHorizontal)
185 EVT_MENU(SPLIT_UNSPLIT, MyFrame::OnUnsplit)
186 EVT_MENU(SPLIT_LIVE, MyFrame::OnToggleLive)
187 EVT_MENU(SPLIT_BORDER, MyFrame::OnToggleBorder)
188 EVT_MENU(SPLIT_3DSASH, MyFrame::OnToggle3DSash)
189 EVT_MENU(SPLIT_SETPOSITION, MyFrame::OnSetPosition)
190 EVT_MENU(SPLIT_SETMINSIZE, MyFrame::OnSetMinSize)
191 EVT_MENU(SPLIT_SETGRAVITY, MyFrame::OnSetGravity)
192 EVT_MENU(SPLIT_REPLACE, MyFrame::OnReplace)
c0430d96 193 EVT_MENU(SPLIT_INVISIBLE, MyFrame::OnToggleInvisible)
430bdeb5
FM
194
195 EVT_MENU(SPLIT_QUIT, MyFrame::OnQuit)
196
197 EVT_UPDATE_UI(SPLIT_VERTICAL, MyFrame::OnUpdateUIVertical)
198 EVT_UPDATE_UI(SPLIT_HORIZONTAL, MyFrame::OnUpdateUIHorizontal)
199 EVT_UPDATE_UI(SPLIT_UNSPLIT, MyFrame::OnUpdateUIUnsplit)
c0430d96 200 EVT_UPDATE_UI(SPLIT_INVISIBLE, MyFrame::OnUpdateUIInvisible)
c801d85f
KB
201END_EVENT_TABLE()
202
203// My frame constructor
2f294a9c 204MyFrame::MyFrame()
9a83f860 205 : wxFrame(NULL, wxID_ANY, wxT("wxSplitterWindow sample"),
2f294a9c 206 wxDefaultPosition, wxSize(420, 300),
fe31f91c 207 wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
c801d85f 208{
41f02b9a
FM
209 SetIcon(wxICON(sample));
210
8520f137 211#if wxUSE_STATUSBAR
2f294a9c 212 CreateStatusBar(2);
8520f137 213#endif // wxUSE_STATUSBAR
b7346a70 214
2f294a9c 215 // Make a menubar
6faed57d
VZ
216 wxMenu *splitMenu = new wxMenu;
217 splitMenu->Append(SPLIT_VERTICAL,
9a83f860
VZ
218 wxT("Split &Vertically\tCtrl-V"),
219 wxT("Split vertically"));
6faed57d 220 splitMenu->Append(SPLIT_HORIZONTAL,
9a83f860
VZ
221 wxT("Split &Horizontally\tCtrl-H"),
222 wxT("Split horizontally"));
6faed57d 223 splitMenu->Append(SPLIT_UNSPLIT,
9a83f860
VZ
224 wxT("&Unsplit\tCtrl-U"),
225 wxT("Unsplit"));
c0430d96
VZ
226 splitMenu->AppendCheckItem(SPLIT_INVISIBLE,
227 wxT("Toggle sash &invisibility\tCtrl-I"),
228 wxT("Toggle sash invisibility"));
6faed57d
VZ
229 splitMenu->AppendSeparator();
230
231 splitMenu->AppendCheckItem(SPLIT_LIVE,
9a83f860
VZ
232 wxT("&Live update\tCtrl-L"),
233 wxT("Toggle live update mode"));
9b8d8755 234 splitMenu->AppendCheckItem(SPLIT_BORDER,
9a83f860
VZ
235 wxT("3D &Border"),
236 wxT("Toggle wxSP_BORDER flag"));
9b8d8755
VZ
237 splitMenu->Check(SPLIT_BORDER, true);
238 splitMenu->AppendCheckItem(SPLIT_3DSASH,
9a83f860
VZ
239 wxT("&3D Sash"),
240 wxT("Toggle wxSP_3DSASH flag"));
9b8d8755 241 splitMenu->Check(SPLIT_3DSASH, true);
6faed57d 242 splitMenu->Append(SPLIT_SETPOSITION,
9a83f860
VZ
243 wxT("Set splitter &position\tCtrl-P"),
244 wxT("Set the splitter position"));
6faed57d 245 splitMenu->Append(SPLIT_SETMINSIZE,
9a83f860
VZ
246 wxT("Set &min size\tCtrl-M"),
247 wxT("Set minimum pane size"));
14b4c0ff 248 splitMenu->Append(SPLIT_SETGRAVITY,
9a83f860
VZ
249 wxT("Set &gravity\tCtrl-G"),
250 wxT("Set gravity of sash"));
6faed57d
VZ
251 splitMenu->AppendSeparator();
252
8adaf733 253 splitMenu->Append(SPLIT_REPLACE,
9a83f860
VZ
254 wxT("&Replace right window"),
255 wxT("Replace right window"));
8adaf733
JS
256 splitMenu->AppendSeparator();
257
9a83f860 258 splitMenu->Append(SPLIT_QUIT, wxT("E&xit\tAlt-X"), wxT("Exit"));
c801d85f 259
2f294a9c 260 wxMenuBar *menuBar = new wxMenuBar;
9a83f860 261 menuBar->Append(splitMenu, wxT("&Splitter"));
c801d85f 262
2f294a9c 263 SetMenuBar(menuBar);
c801d85f 264
8ad18dc3 265 menuBar->Check(SPLIT_LIVE, true);
2f294a9c 266 m_splitter = new MySplitterWindow(this);
430bdeb5 267
853f4764
VZ
268 // If you use non-zero gravity you must initialize the splitter with its
269 // correct initial size, otherwise it will change the sash position by a
270 // huge amount when it's resized from its initial default size to its real
271 // size when the frame lays it out. This wouldn't be necessary if default
272 // zero gravity were used (although it would do no harm neither).
273 m_splitter->SetSize(GetClientSize());
14b4c0ff 274 m_splitter->SetSashGravity(1.0);
4a0b46a7 275
6b55490a 276#if 1
a63e17c1 277 m_left = new MyCanvas(m_splitter, true);
2f294a9c 278 m_left->SetBackgroundColour(*wxRED);
2f294a9c
VZ
279 m_left->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
280
a63e17c1 281 m_right = new MyCanvas(m_splitter, false);
2f294a9c 282 m_right->SetBackgroundColour(*wxCYAN);
6b55490a 283#else // for testing kbd navigation inside the splitter
9a83f860
VZ
284 m_left = new wxTextCtrl(m_splitter, wxID_ANY, wxT("first text"));
285 m_right = new wxTextCtrl(m_splitter, wxID_ANY, wxT("second text"));
6b55490a 286#endif
c801d85f 287
2f294a9c 288 // you can also do this to start with a single window
4a0b46a7 289#if 0
8ad18dc3 290 m_right->Show(false);
2f294a9c 291 m_splitter->Initialize(m_left);
4a0b46a7 292#else
74c57d1f 293 // you can also try -100
2f294a9c 294 m_splitter->SplitVertically(m_left, m_right, 100);
4a0b46a7
VZ
295#endif
296
8520f137 297#if wxUSE_STATUSBAR
9a83f860 298 SetStatusText(wxT("Min pane size = 0"), 1);
8520f137 299#endif // wxUSE_STATUSBAR
8adaf733 300
52ada3cd 301 m_replacewindow = NULL;
8adaf733
JS
302}
303
304MyFrame::~MyFrame()
305{
306 if (m_replacewindow) {
307 m_replacewindow->Destroy();
8adaf733 308 }
c801d85f
KB
309}
310
2f294a9c
VZ
311// menu command handlers
312
430bdeb5 313void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
c801d85f 314{
8ad18dc3 315 Close(true);
c801d85f
KB
316}
317
430bdeb5 318void MyFrame::OnSplitHorizontal(wxCommandEvent& WXUNUSED(event) )
c801d85f 319{
2f294a9c
VZ
320 if ( m_splitter->IsSplit() )
321 m_splitter->Unsplit();
8ad18dc3
JS
322 m_left->Show(true);
323 m_right->Show(true);
2f294a9c 324 m_splitter->SplitHorizontally( m_left, m_right );
52ada3cd 325 m_replacewindow = NULL;
74c57d1f 326
8520f137 327#if wxUSE_STATUSBAR
9a83f860 328 SetStatusText(wxT("Splitter split horizontally"), 1);
8520f137 329#endif // wxUSE_STATUSBAR
c801d85f
KB
330}
331
430bdeb5 332void MyFrame::OnSplitVertical(wxCommandEvent& WXUNUSED(event) )
c801d85f 333{
2f294a9c
VZ
334 if ( m_splitter->IsSplit() )
335 m_splitter->Unsplit();
8ad18dc3
JS
336 m_left->Show(true);
337 m_right->Show(true);
2f294a9c 338 m_splitter->SplitVertically( m_left, m_right );
52ada3cd 339 m_replacewindow = NULL;
74c57d1f 340
8520f137 341#if wxUSE_STATUSBAR
9a83f860 342 SetStatusText(wxT("Splitter split vertically"), 1);
8520f137 343#endif // wxUSE_STATUSBAR
c801d85f
KB
344}
345
430bdeb5 346void MyFrame::OnUnsplit(wxCommandEvent& WXUNUSED(event) )
c801d85f 347{
2f294a9c
VZ
348 if ( m_splitter->IsSplit() )
349 m_splitter->Unsplit();
8520f137 350#if wxUSE_STATUSBAR
9a83f860 351 SetStatusText(wxT("No splitter"));
8520f137 352#endif // wxUSE_STATUSBAR
0d559d69
VZ
353}
354
9b8d8755 355void MyFrame::ToggleFlag(int flag, bool enable)
b795f9ca
VZ
356{
357 long style = m_splitter->GetWindowStyleFlag();
9b8d8755
VZ
358 if ( enable )
359 style |= flag;
b795f9ca 360 else
9b8d8755 361 style &= ~flag;
b795f9ca
VZ
362
363 m_splitter->SetWindowStyleFlag(style);
9b8d8755
VZ
364
365 // we need to move sash to redraw it
366 int pos = m_splitter->GetSashPosition();
367 m_splitter->SetSashPosition(pos + 1);
368 m_splitter->SetSashPosition(pos);
b795f9ca
VZ
369}
370
430bdeb5 371void MyFrame::OnSetPosition(wxCommandEvent& WXUNUSED(event) )
6faed57d
VZ
372{
373 wxString str;
374 str.Printf( wxT("%d"), m_splitter->GetSashPosition());
9b8d8755 375#if wxUSE_TEXTDLG
9a83f860 376 str = wxGetTextFromUser(wxT("Enter splitter position:"), wxT(""), str, this);
9b8d8755 377#endif
6faed57d
VZ
378 if ( str.empty() )
379 return;
380
381 long pos;
382 if ( !str.ToLong(&pos) )
383 {
9a83f860 384 wxLogError(wxT("The splitter position should be an integer."));
6faed57d
VZ
385 return;
386 }
387
388 m_splitter->SetSashPosition(pos);
389
9a83f860 390 wxLogStatus(this, wxT("Splitter position set to %ld"), pos);
6faed57d
VZ
391}
392
430bdeb5 393void MyFrame::OnSetMinSize(wxCommandEvent& WXUNUSED(event) )
0d559d69 394{
2f294a9c 395 wxString str;
f565a6c2 396 str.Printf( wxT("%d"), m_splitter->GetMinimumPaneSize());
9b8d8755 397#if wxUSE_TEXTDLG
9a83f860 398 str = wxGetTextFromUser(wxT("Enter minimal size for panes:"), wxT(""), str, this);
9b8d8755 399#endif
6faed57d 400 if ( str.empty() )
2f294a9c
VZ
401 return;
402
403 int minsize = wxStrtol( str, (wxChar**)NULL, 10 );
404 m_splitter->SetMinimumPaneSize(minsize);
8520f137 405#if wxUSE_STATUSBAR
f565a6c2 406 str.Printf( wxT("Min pane size = %d"), minsize);
2f294a9c 407 SetStatusText(str, 1);
8520f137 408#endif // wxUSE_STATUSBAR
c801d85f 409}
430bdeb5
FM
410
411void MyFrame::OnSetGravity(wxCommandEvent& WXUNUSED(event) )
14b4c0ff
VZ
412{
413 wxString str;
414 str.Printf( wxT("%g"), m_splitter->GetSashGravity());
9b8d8755 415#if wxUSE_TEXTDLG
9a83f860 416 str = wxGetTextFromUser(wxT("Enter sash gravity (0,1):"), wxT(""), str, this);
9b8d8755 417#endif
14b4c0ff
VZ
418 if ( str.empty() )
419 return;
420
421 double gravity = wxStrtod( str, (wxChar**)NULL);
422 m_splitter->SetSashGravity(gravity);
423#if wxUSE_STATUSBAR
424 str.Printf( wxT("Gravity = %g"), gravity);
425 SetStatusText(str, 1);
426#endif // wxUSE_STATUSBAR
427}
c801d85f 428
430bdeb5 429void MyFrame::OnReplace(wxCommandEvent& WXUNUSED(event) )
8adaf733 430{
52ada3cd 431 if (m_replacewindow == NULL) {
8adaf733
JS
432 m_replacewindow = m_splitter->GetWindow2();
433 m_splitter->ReplaceWindow(m_replacewindow, new wxPanel(m_splitter, wxID_ANY));
434 m_replacewindow->Hide();
435 } else {
436 wxWindow *empty = m_splitter->GetWindow2();
52ada3cd 437 wxASSERT(empty != m_replacewindow);
8adaf733
JS
438 m_splitter->ReplaceWindow(empty, m_replacewindow);
439 m_replacewindow->Show();
52ada3cd 440 m_replacewindow = NULL;
8adaf733
JS
441 empty->Destroy();
442 }
443}
444
c0430d96
VZ
445void MyFrame::OnToggleInvisible(wxCommandEvent& WXUNUSED(event) )
446{
447 m_splitter->SetSashInvisible(!m_splitter->IsSashInvisible());
448 m_splitter->SizeWindows();
449}
450
2f294a9c
VZ
451// Update UI handlers
452
430bdeb5 453void MyFrame::OnUpdateUIHorizontal(wxUpdateUIEvent& event)
c801d85f 454{
2f294a9c 455 event.Enable( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_HORIZONTAL) );
c801d85f
KB
456}
457
430bdeb5 458void MyFrame::OnUpdateUIVertical(wxUpdateUIEvent& event)
c801d85f 459{
2f294a9c 460 event.Enable( ( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_VERTICAL) ) );
c801d85f
KB
461}
462
430bdeb5 463void MyFrame::OnUpdateUIUnsplit(wxUpdateUIEvent& event)
c801d85f 464{
2f294a9c 465 event.Enable( m_splitter->IsSplit() );
c801d85f
KB
466}
467
c0430d96
VZ
468void MyFrame::OnUpdateUIInvisible(wxUpdateUIEvent& event)
469{
470 event.Check( m_splitter->IsSashInvisible() );
471}
472
2f294a9c
VZ
473// ----------------------------------------------------------------------------
474// MySplitterWindow
475// ----------------------------------------------------------------------------
476
477BEGIN_EVENT_TABLE(MySplitterWindow, wxSplitterWindow)
8ad18dc3
JS
478 EVT_SPLITTER_SASH_POS_CHANGED(wxID_ANY, MySplitterWindow::OnPositionChanged)
479 EVT_SPLITTER_SASH_POS_CHANGING(wxID_ANY, MySplitterWindow::OnPositionChanging)
2f294a9c 480
8ad18dc3 481 EVT_SPLITTER_DCLICK(wxID_ANY, MySplitterWindow::OnDClick)
2f294a9c 482
8ad18dc3 483 EVT_SPLITTER_UNSPLIT(wxID_ANY, MySplitterWindow::OnUnsplitEvent)
2f294a9c
VZ
484END_EVENT_TABLE()
485
486MySplitterWindow::MySplitterWindow(wxFrame *parent)
8ad18dc3 487 : wxSplitterWindow(parent, wxID_ANY,
2f294a9c 488 wxDefaultPosition, wxDefaultSize,
3c2544bb
JS
489 wxSP_3D | wxSP_LIVE_UPDATE |
490 wxCLIP_CHILDREN /* | wxSP_NO_XP_THEME */ )
c801d85f 491{
2f294a9c 492 m_frame = parent;
c801d85f
KB
493}
494
2f294a9c
VZ
495void MySplitterWindow::OnPositionChanged(wxSplitterEvent& event)
496{
9a83f860 497 wxLogStatus(m_frame, wxT("Position has changed, now = %d (or %d)"),
2f294a9c
VZ
498 event.GetSashPosition(), GetSashPosition());
499
500 event.Skip();
501}
502
503void MySplitterWindow::OnPositionChanging(wxSplitterEvent& event)
504{
9a83f860 505 wxLogStatus(m_frame, wxT("Position is changing, now = %d (or %d)"),
2f294a9c
VZ
506 event.GetSashPosition(), GetSashPosition());
507
508 event.Skip();
509}
510
511void MySplitterWindow::OnDClick(wxSplitterEvent& event)
512{
8520f137 513#if wxUSE_STATUSBAR
9a83f860 514 m_frame->SetStatusText(wxT("Splitter double clicked"), 1);
8520f137 515#endif // wxUSE_STATUSBAR
2f294a9c
VZ
516
517 event.Skip();
518}
519
8ad18dc3 520void MySplitterWindow::OnUnsplitEvent(wxSplitterEvent& event)
2f294a9c 521{
8520f137 522#if wxUSE_STATUSBAR
9a83f860 523 m_frame->SetStatusText(wxT("Splitter unsplit"), 1);
8520f137 524#endif // wxUSE_STATUSBAR
2f294a9c
VZ
525
526 event.Skip();
527}
528
529// ----------------------------------------------------------------------------
530// MyCanvas
531// ----------------------------------------------------------------------------
532
a63e17c1 533MyCanvas::MyCanvas(wxWindow* parent, bool mirror)
8ad18dc3 534 : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
a63e17c1 535 wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE)
c801d85f 536{
a63e17c1 537 m_mirror = mirror;
5c299305 538 SetScrollbars(20, 20, 5, 5);
c801d85f
KB
539}
540
a63e17c1 541void MyCanvas::OnDraw(wxDC& dcOrig)
c801d85f 542{
a63e17c1
VZ
543 wxMirrorDC dc(dcOrig, m_mirror);
544
2f294a9c 545 dc.SetPen(*wxBLACK_PEN);
a63e17c1 546 dc.DrawLine(0, 0, 100, 200);
c801d85f 547
9b8d8755 548 dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
9a83f860 549 dc.DrawText(wxT("Testing"), 50, 50);
b7346a70 550
2f294a9c
VZ
551 dc.SetPen(*wxRED_PEN);
552 dc.SetBrush(*wxGREEN_BRUSH);
553 dc.DrawRectangle(120, 120, 100, 80);
c801d85f 554}
2f294a9c 555