]> git.saurik.com Git - wxWidgets.git/blame - samples/splitter/splitter.cpp
Minor changes, just trim trailing spaces in webview code.
[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:
2f294a9c
VZ
114 wxScrolledWindow *m_left, *m_right;
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);
a63e17c1 279 m_left->SetScrollbars(20, 20, 5, 5);
2f294a9c
VZ
280 m_left->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
281
a63e17c1 282 m_right = new MyCanvas(m_splitter, false);
2f294a9c 283 m_right->SetBackgroundColour(*wxCYAN);
a63e17c1 284 m_right->SetScrollbars(20, 20, 5, 5);
6b55490a 285#else // for testing kbd navigation inside the splitter
9a83f860
VZ
286 m_left = new wxTextCtrl(m_splitter, wxID_ANY, wxT("first text"));
287 m_right = new wxTextCtrl(m_splitter, wxID_ANY, wxT("second text"));
6b55490a 288#endif
c801d85f 289
2f294a9c 290 // you can also do this to start with a single window
4a0b46a7 291#if 0
8ad18dc3 292 m_right->Show(false);
2f294a9c 293 m_splitter->Initialize(m_left);
4a0b46a7 294#else
74c57d1f 295 // you can also try -100
2f294a9c 296 m_splitter->SplitVertically(m_left, m_right, 100);
4a0b46a7
VZ
297#endif
298
8520f137 299#if wxUSE_STATUSBAR
9a83f860 300 SetStatusText(wxT("Min pane size = 0"), 1);
8520f137 301#endif // wxUSE_STATUSBAR
8adaf733 302
52ada3cd 303 m_replacewindow = NULL;
8adaf733
JS
304}
305
306MyFrame::~MyFrame()
307{
308 if (m_replacewindow) {
309 m_replacewindow->Destroy();
8adaf733 310 }
c801d85f
KB
311}
312
2f294a9c
VZ
313// menu command handlers
314
430bdeb5 315void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
c801d85f 316{
8ad18dc3 317 Close(true);
c801d85f
KB
318}
319
430bdeb5 320void MyFrame::OnSplitHorizontal(wxCommandEvent& WXUNUSED(event) )
c801d85f 321{
2f294a9c
VZ
322 if ( m_splitter->IsSplit() )
323 m_splitter->Unsplit();
8ad18dc3
JS
324 m_left->Show(true);
325 m_right->Show(true);
2f294a9c 326 m_splitter->SplitHorizontally( m_left, m_right );
52ada3cd 327 m_replacewindow = NULL;
74c57d1f 328
8520f137 329#if wxUSE_STATUSBAR
9a83f860 330 SetStatusText(wxT("Splitter split horizontally"), 1);
8520f137 331#endif // wxUSE_STATUSBAR
c801d85f
KB
332}
333
430bdeb5 334void MyFrame::OnSplitVertical(wxCommandEvent& WXUNUSED(event) )
c801d85f 335{
2f294a9c
VZ
336 if ( m_splitter->IsSplit() )
337 m_splitter->Unsplit();
8ad18dc3
JS
338 m_left->Show(true);
339 m_right->Show(true);
2f294a9c 340 m_splitter->SplitVertically( m_left, m_right );
52ada3cd 341 m_replacewindow = NULL;
74c57d1f 342
8520f137 343#if wxUSE_STATUSBAR
9a83f860 344 SetStatusText(wxT("Splitter split vertically"), 1);
8520f137 345#endif // wxUSE_STATUSBAR
c801d85f
KB
346}
347
430bdeb5 348void MyFrame::OnUnsplit(wxCommandEvent& WXUNUSED(event) )
c801d85f 349{
2f294a9c
VZ
350 if ( m_splitter->IsSplit() )
351 m_splitter->Unsplit();
8520f137 352#if wxUSE_STATUSBAR
9a83f860 353 SetStatusText(wxT("No splitter"));
8520f137 354#endif // wxUSE_STATUSBAR
0d559d69
VZ
355}
356
9b8d8755 357void MyFrame::ToggleFlag(int flag, bool enable)
b795f9ca
VZ
358{
359 long style = m_splitter->GetWindowStyleFlag();
9b8d8755
VZ
360 if ( enable )
361 style |= flag;
b795f9ca 362 else
9b8d8755 363 style &= ~flag;
b795f9ca
VZ
364
365 m_splitter->SetWindowStyleFlag(style);
9b8d8755
VZ
366
367 // we need to move sash to redraw it
368 int pos = m_splitter->GetSashPosition();
369 m_splitter->SetSashPosition(pos + 1);
370 m_splitter->SetSashPosition(pos);
b795f9ca
VZ
371}
372
430bdeb5 373void MyFrame::OnSetPosition(wxCommandEvent& WXUNUSED(event) )
6faed57d
VZ
374{
375 wxString str;
376 str.Printf( wxT("%d"), m_splitter->GetSashPosition());
9b8d8755 377#if wxUSE_TEXTDLG
9a83f860 378 str = wxGetTextFromUser(wxT("Enter splitter position:"), wxT(""), str, this);
9b8d8755 379#endif
6faed57d
VZ
380 if ( str.empty() )
381 return;
382
383 long pos;
384 if ( !str.ToLong(&pos) )
385 {
9a83f860 386 wxLogError(wxT("The splitter position should be an integer."));
6faed57d
VZ
387 return;
388 }
389
390 m_splitter->SetSashPosition(pos);
391
9a83f860 392 wxLogStatus(this, wxT("Splitter position set to %ld"), pos);
6faed57d
VZ
393}
394
430bdeb5 395void MyFrame::OnSetMinSize(wxCommandEvent& WXUNUSED(event) )
0d559d69 396{
2f294a9c 397 wxString str;
f565a6c2 398 str.Printf( wxT("%d"), m_splitter->GetMinimumPaneSize());
9b8d8755 399#if wxUSE_TEXTDLG
9a83f860 400 str = wxGetTextFromUser(wxT("Enter minimal size for panes:"), wxT(""), str, this);
9b8d8755 401#endif
6faed57d 402 if ( str.empty() )
2f294a9c
VZ
403 return;
404
405 int minsize = wxStrtol( str, (wxChar**)NULL, 10 );
406 m_splitter->SetMinimumPaneSize(minsize);
8520f137 407#if wxUSE_STATUSBAR
f565a6c2 408 str.Printf( wxT("Min pane size = %d"), minsize);
2f294a9c 409 SetStatusText(str, 1);
8520f137 410#endif // wxUSE_STATUSBAR
c801d85f 411}
430bdeb5
FM
412
413void MyFrame::OnSetGravity(wxCommandEvent& WXUNUSED(event) )
14b4c0ff
VZ
414{
415 wxString str;
416 str.Printf( wxT("%g"), m_splitter->GetSashGravity());
9b8d8755 417#if wxUSE_TEXTDLG
9a83f860 418 str = wxGetTextFromUser(wxT("Enter sash gravity (0,1):"), wxT(""), str, this);
9b8d8755 419#endif
14b4c0ff
VZ
420 if ( str.empty() )
421 return;
422
423 double gravity = wxStrtod( str, (wxChar**)NULL);
424 m_splitter->SetSashGravity(gravity);
425#if wxUSE_STATUSBAR
426 str.Printf( wxT("Gravity = %g"), gravity);
427 SetStatusText(str, 1);
428#endif // wxUSE_STATUSBAR
429}
c801d85f 430
430bdeb5 431void MyFrame::OnReplace(wxCommandEvent& WXUNUSED(event) )
8adaf733 432{
52ada3cd 433 if (m_replacewindow == NULL) {
8adaf733
JS
434 m_replacewindow = m_splitter->GetWindow2();
435 m_splitter->ReplaceWindow(m_replacewindow, new wxPanel(m_splitter, wxID_ANY));
436 m_replacewindow->Hide();
437 } else {
438 wxWindow *empty = m_splitter->GetWindow2();
52ada3cd 439 wxASSERT(empty != m_replacewindow);
8adaf733
JS
440 m_splitter->ReplaceWindow(empty, m_replacewindow);
441 m_replacewindow->Show();
52ada3cd 442 m_replacewindow = NULL;
8adaf733
JS
443 empty->Destroy();
444 }
445}
446
c0430d96
VZ
447void MyFrame::OnToggleInvisible(wxCommandEvent& WXUNUSED(event) )
448{
449 m_splitter->SetSashInvisible(!m_splitter->IsSashInvisible());
450 m_splitter->SizeWindows();
451}
452
2f294a9c
VZ
453// Update UI handlers
454
430bdeb5 455void MyFrame::OnUpdateUIHorizontal(wxUpdateUIEvent& event)
c801d85f 456{
2f294a9c 457 event.Enable( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_HORIZONTAL) );
c801d85f
KB
458}
459
430bdeb5 460void MyFrame::OnUpdateUIVertical(wxUpdateUIEvent& event)
c801d85f 461{
2f294a9c 462 event.Enable( ( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_VERTICAL) ) );
c801d85f
KB
463}
464
430bdeb5 465void MyFrame::OnUpdateUIUnsplit(wxUpdateUIEvent& event)
c801d85f 466{
2f294a9c 467 event.Enable( m_splitter->IsSplit() );
c801d85f
KB
468}
469
c0430d96
VZ
470void MyFrame::OnUpdateUIInvisible(wxUpdateUIEvent& event)
471{
472 event.Check( m_splitter->IsSashInvisible() );
473}
474
2f294a9c
VZ
475// ----------------------------------------------------------------------------
476// MySplitterWindow
477// ----------------------------------------------------------------------------
478
479BEGIN_EVENT_TABLE(MySplitterWindow, wxSplitterWindow)
8ad18dc3
JS
480 EVT_SPLITTER_SASH_POS_CHANGED(wxID_ANY, MySplitterWindow::OnPositionChanged)
481 EVT_SPLITTER_SASH_POS_CHANGING(wxID_ANY, MySplitterWindow::OnPositionChanging)
2f294a9c 482
8ad18dc3 483 EVT_SPLITTER_DCLICK(wxID_ANY, MySplitterWindow::OnDClick)
2f294a9c 484
8ad18dc3 485 EVT_SPLITTER_UNSPLIT(wxID_ANY, MySplitterWindow::OnUnsplitEvent)
2f294a9c
VZ
486END_EVENT_TABLE()
487
488MySplitterWindow::MySplitterWindow(wxFrame *parent)
8ad18dc3 489 : wxSplitterWindow(parent, wxID_ANY,
2f294a9c 490 wxDefaultPosition, wxDefaultSize,
3c2544bb
JS
491 wxSP_3D | wxSP_LIVE_UPDATE |
492 wxCLIP_CHILDREN /* | wxSP_NO_XP_THEME */ )
c801d85f 493{
2f294a9c 494 m_frame = parent;
c801d85f
KB
495}
496
2f294a9c
VZ
497void MySplitterWindow::OnPositionChanged(wxSplitterEvent& event)
498{
9a83f860 499 wxLogStatus(m_frame, wxT("Position has changed, now = %d (or %d)"),
2f294a9c
VZ
500 event.GetSashPosition(), GetSashPosition());
501
502 event.Skip();
503}
504
505void MySplitterWindow::OnPositionChanging(wxSplitterEvent& event)
506{
9a83f860 507 wxLogStatus(m_frame, wxT("Position is changing, now = %d (or %d)"),
2f294a9c
VZ
508 event.GetSashPosition(), GetSashPosition());
509
510 event.Skip();
511}
512
513void MySplitterWindow::OnDClick(wxSplitterEvent& event)
514{
8520f137 515#if wxUSE_STATUSBAR
9a83f860 516 m_frame->SetStatusText(wxT("Splitter double clicked"), 1);
8520f137 517#endif // wxUSE_STATUSBAR
2f294a9c
VZ
518
519 event.Skip();
520}
521
8ad18dc3 522void MySplitterWindow::OnUnsplitEvent(wxSplitterEvent& event)
2f294a9c 523{
8520f137 524#if wxUSE_STATUSBAR
9a83f860 525 m_frame->SetStatusText(wxT("Splitter unsplit"), 1);
8520f137 526#endif // wxUSE_STATUSBAR
2f294a9c
VZ
527
528 event.Skip();
529}
530
531// ----------------------------------------------------------------------------
532// MyCanvas
533// ----------------------------------------------------------------------------
534
a63e17c1 535MyCanvas::MyCanvas(wxWindow* parent, bool mirror)
8ad18dc3 536 : wxScrolledWindow(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
a63e17c1 537 wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE)
c801d85f 538{
a63e17c1 539 m_mirror = mirror;
c801d85f
KB
540}
541
a63e17c1 542void MyCanvas::OnDraw(wxDC& dcOrig)
c801d85f 543{
a63e17c1
VZ
544 wxMirrorDC dc(dcOrig, m_mirror);
545
2f294a9c 546 dc.SetPen(*wxBLACK_PEN);
a63e17c1 547 dc.DrawLine(0, 0, 100, 200);
c801d85f 548
9b8d8755 549 dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
9a83f860 550 dc.DrawText(wxT("Testing"), 50, 50);
b7346a70 551
2f294a9c
VZ
552 dc.SetPen(*wxRED_PEN);
553 dc.SetBrush(*wxGREEN_BRUSH);
554 dc.DrawRectangle(120, 120, 100, 80);
c801d85f 555}
2f294a9c 556