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