1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-03-14 14:30:04 -05:00
|
|
|
// Name: splitter.cpp
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose: wxSplitterWindow sample
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
2003-03-17 06:55:54 -05:00
|
|
|
// Copyright: (c) Julian Smart
|
1998-10-23 09:15:15 -04:00
|
|
|
// Licence: wxWindows license
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
2002-01-07 13:33:30 -05:00
|
|
|
#pragma hdrstop
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
2002-07-12 09:23:53 -04:00
|
|
|
#include "wx/log.h"
|
|
|
|
|
|
|
|
#include "wx/app.h"
|
|
|
|
#include "wx/frame.h"
|
|
|
|
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
#include "wx/menu.h"
|
|
|
|
|
|
|
|
#include "wx/textdlg.h" // for wxGetTextFromUser
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/splitter.h"
|
2003-09-27 11:30:41 -04:00
|
|
|
#include "wx/dcmirror.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// ID for the menu commands
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
SPLIT_QUIT,
|
|
|
|
SPLIT_HORIZONTAL,
|
|
|
|
SPLIT_VERTICAL,
|
|
|
|
SPLIT_UNSPLIT,
|
2002-02-22 10:09:45 -05:00
|
|
|
SPLIT_LIVE,
|
2002-07-12 09:23:53 -04:00
|
|
|
SPLIT_SETPOSITION,
|
2002-01-07 13:33:30 -05:00
|
|
|
SPLIT_SETMINSIZE
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// our classes
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
class MyApp: public wxApp
|
|
|
|
{
|
|
|
|
public:
|
2003-09-27 11:30:41 -04:00
|
|
|
MyApp() { }
|
|
|
|
|
|
|
|
virtual bool OnInit();
|
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(MyApp)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
class MyFrame: public wxFrame
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
|
|
|
public:
|
2002-01-07 13:33:30 -05:00
|
|
|
MyFrame();
|
|
|
|
virtual ~MyFrame();
|
1998-10-23 09:15:15 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// Menu commands
|
|
|
|
void SplitHorizontal(wxCommandEvent& event);
|
|
|
|
void SplitVertical(wxCommandEvent& event);
|
|
|
|
void Unsplit(wxCommandEvent& event);
|
2002-02-22 10:09:45 -05:00
|
|
|
void ToggleLive(wxCommandEvent& event);
|
2002-07-12 09:23:53 -04:00
|
|
|
void SetPosition(wxCommandEvent& event);
|
2002-01-07 13:33:30 -05:00
|
|
|
void SetMinSize(wxCommandEvent& event);
|
2002-02-22 10:09:45 -05:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
void Quit(wxCommandEvent& event);
|
2001-06-14 13:44:24 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// Menu command update functions
|
|
|
|
void UpdateUIHorizontal(wxUpdateUIEvent& event);
|
|
|
|
void UpdateUIVertical(wxUpdateUIEvent& event);
|
|
|
|
void UpdateUIUnsplit(wxUpdateUIEvent& event);
|
2001-06-14 13:44:24 -04:00
|
|
|
|
1998-10-23 09:15:15 -04:00
|
|
|
private:
|
2002-01-07 13:33:30 -05:00
|
|
|
wxScrolledWindow *m_left, *m_right;
|
|
|
|
|
|
|
|
wxSplitterWindow* m_splitter;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2003-09-27 11:30:41 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(MyFrame)
|
1998-10-23 09:15:15 -04:00
|
|
|
};
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
class MySplitterWindow : public wxSplitterWindow
|
1998-10-23 09:15:15 -04:00
|
|
|
{
|
|
|
|
public:
|
2002-01-07 13:33:30 -05:00
|
|
|
MySplitterWindow(wxFrame *parent);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// event handlers
|
|
|
|
void OnPositionChanged(wxSplitterEvent& event);
|
|
|
|
void OnPositionChanging(wxSplitterEvent& event);
|
|
|
|
void OnDClick(wxSplitterEvent& event);
|
|
|
|
void OnUnsplit(wxSplitterEvent& event);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
private:
|
2002-01-07 13:33:30 -05:00
|
|
|
wxFrame *m_frame;
|
1998-10-23 09:15:15 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2003-09-27 11:30:41 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(MySplitterWindow)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class MyCanvas: public wxScrolledWindow
|
|
|
|
{
|
|
|
|
public:
|
2003-09-27 11:30:41 -04:00
|
|
|
MyCanvas(wxWindow* parent, bool mirror);
|
2001-06-11 16:03:00 -04:00
|
|
|
virtual ~MyCanvas();
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
virtual void OnDraw(wxDC& dc);
|
2003-09-27 11:30:41 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_mirror;
|
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(MyCanvas)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// MyApp
|
|
|
|
// ----------------------------------------------------------------------------
|
1998-10-21 17:43:20 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
IMPLEMENT_APP(MyApp)
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
bool MyApp::OnInit()
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
// create and show the main frame
|
|
|
|
MyFrame* frame = new MyFrame;
|
2001-06-14 13:44:24 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
frame->Show(TRUE);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
return TRUE;
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// MyFrame
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
2002-01-07 13:33:30 -05:00
|
|
|
EVT_MENU(SPLIT_VERTICAL, MyFrame::SplitVertical)
|
|
|
|
EVT_MENU(SPLIT_HORIZONTAL, MyFrame::SplitHorizontal)
|
|
|
|
EVT_MENU(SPLIT_UNSPLIT, MyFrame::Unsplit)
|
2002-02-22 10:09:45 -05:00
|
|
|
EVT_MENU(SPLIT_LIVE, MyFrame::ToggleLive)
|
2002-07-12 09:23:53 -04:00
|
|
|
EVT_MENU(SPLIT_SETPOSITION, MyFrame::SetPosition)
|
2002-01-07 13:33:30 -05:00
|
|
|
EVT_MENU(SPLIT_SETMINSIZE, MyFrame::SetMinSize)
|
|
|
|
|
2002-02-22 10:09:45 -05:00
|
|
|
EVT_MENU(SPLIT_QUIT, MyFrame::Quit)
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
EVT_UPDATE_UI(SPLIT_VERTICAL, MyFrame::UpdateUIVertical)
|
|
|
|
EVT_UPDATE_UI(SPLIT_HORIZONTAL, MyFrame::UpdateUIHorizontal)
|
|
|
|
EVT_UPDATE_UI(SPLIT_UNSPLIT, MyFrame::UpdateUIUnsplit)
|
1998-05-20 10:01:55 -04:00
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// My frame constructor
|
2002-01-07 13:33:30 -05:00
|
|
|
MyFrame::MyFrame()
|
|
|
|
: wxFrame(NULL, -1, _T("wxSplitterWindow sample"),
|
|
|
|
wxDefaultPosition, wxSize(420, 300),
|
2001-06-15 21:09:30 -04:00
|
|
|
wxDEFAULT_FRAME_STYLE | wxNO_FULL_REPAINT_ON_RESIZE)
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
CreateStatusBar(2);
|
1998-07-08 09:21:23 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// Make a menubar
|
2002-07-12 09:23:53 -04:00
|
|
|
wxMenu *splitMenu = new wxMenu;
|
|
|
|
splitMenu->Append(SPLIT_VERTICAL,
|
|
|
|
_T("Split &Vertically\tCtrl-V"),
|
|
|
|
_T("Split vertically"));
|
|
|
|
splitMenu->Append(SPLIT_HORIZONTAL,
|
|
|
|
_T("Split &Horizontally\tCtrl-H"),
|
|
|
|
_T("Split horizontally"));
|
|
|
|
splitMenu->Append(SPLIT_UNSPLIT,
|
|
|
|
_T("&Unsplit\tCtrl-U"),
|
|
|
|
_T("Unsplit"));
|
|
|
|
splitMenu->AppendSeparator();
|
|
|
|
|
|
|
|
splitMenu->AppendCheckItem(SPLIT_LIVE,
|
|
|
|
_T("&Live update\tCtrl-L"),
|
|
|
|
_T("Toggle live update mode"));
|
|
|
|
splitMenu->Append(SPLIT_SETPOSITION,
|
|
|
|
_T("Set splitter &position\tCtrl-P"),
|
|
|
|
_T("Set the splitter position"));
|
|
|
|
splitMenu->Append(SPLIT_SETMINSIZE,
|
|
|
|
_T("Set &min size\tCtrl-M"),
|
|
|
|
_T("Set minimum pane size"));
|
|
|
|
splitMenu->AppendSeparator();
|
|
|
|
|
|
|
|
splitMenu->Append(SPLIT_QUIT, _T("E&xit\tAlt-X"), _T("Exit"));
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
wxMenuBar *menuBar = new wxMenuBar;
|
2002-07-12 09:23:53 -04:00
|
|
|
menuBar->Append(splitMenu, _T("&Splitter"));
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
SetMenuBar(menuBar);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-02-22 10:09:45 -05:00
|
|
|
menuBar->Check(SPLIT_LIVE, TRUE);
|
2002-01-07 13:33:30 -05:00
|
|
|
m_splitter = new MySplitterWindow(this);
|
2001-06-14 13:44:24 -04:00
|
|
|
|
2001-08-06 08:55:04 -04:00
|
|
|
#if 1
|
2003-09-27 11:30:41 -04:00
|
|
|
m_left = new MyCanvas(m_splitter, true);
|
2002-01-07 13:33:30 -05:00
|
|
|
m_left->SetBackgroundColour(*wxRED);
|
2003-09-27 11:30:41 -04:00
|
|
|
m_left->SetScrollbars(20, 20, 5, 5);
|
2002-01-07 13:33:30 -05:00
|
|
|
m_left->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
|
|
|
|
|
2003-09-27 11:30:41 -04:00
|
|
|
m_right = new MyCanvas(m_splitter, false);
|
2002-01-07 13:33:30 -05:00
|
|
|
m_right->SetBackgroundColour(*wxCYAN);
|
2003-09-27 11:30:41 -04:00
|
|
|
m_right->SetScrollbars(20, 20, 5, 5);
|
2001-08-06 08:55:04 -04:00
|
|
|
#else // for testing kbd navigation inside the splitter
|
2002-01-07 13:33:30 -05:00
|
|
|
m_left = new wxTextCtrl(m_splitter, -1, _T("first text"));
|
|
|
|
m_right = new wxTextCtrl(m_splitter, -1, _T("second text"));
|
2001-08-06 08:55:04 -04:00
|
|
|
#endif
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// you can also do this to start with a single window
|
2001-06-14 13:44:24 -04:00
|
|
|
#if 0
|
2002-01-07 13:33:30 -05:00
|
|
|
m_right->Show(FALSE);
|
|
|
|
m_splitter->Initialize(m_left);
|
2001-06-14 13:44:24 -04:00
|
|
|
#else
|
2002-02-21 19:48:02 -05:00
|
|
|
// you can also try -100
|
2002-01-07 13:33:30 -05:00
|
|
|
m_splitter->SplitVertically(m_left, m_right, 100);
|
2001-06-14 13:44:24 -04:00
|
|
|
#endif
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
SetStatusText(_T("Min pane size = 0"), 1);
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MyFrame::~MyFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// menu command handlers
|
|
|
|
|
1998-07-27 16:50:48 -04:00
|
|
|
void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) )
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
Close(TRUE);
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
1998-07-27 16:50:48 -04:00
|
|
|
void MyFrame::SplitHorizontal(wxCommandEvent& WXUNUSED(event) )
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
if ( m_splitter->IsSplit() )
|
|
|
|
m_splitter->Unsplit();
|
|
|
|
m_left->Show(TRUE);
|
|
|
|
m_right->Show(TRUE);
|
|
|
|
m_splitter->SplitHorizontally( m_left, m_right );
|
2002-02-21 19:48:02 -05:00
|
|
|
|
|
|
|
SetStatusText(_T("Splitter split horizontally"), 1);
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
1998-07-27 16:50:48 -04:00
|
|
|
void MyFrame::SplitVertical(wxCommandEvent& WXUNUSED(event) )
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
if ( m_splitter->IsSplit() )
|
|
|
|
m_splitter->Unsplit();
|
|
|
|
m_left->Show(TRUE);
|
|
|
|
m_right->Show(TRUE);
|
|
|
|
m_splitter->SplitVertically( m_left, m_right );
|
2002-02-21 19:48:02 -05:00
|
|
|
|
|
|
|
SetStatusText(_T("Splitter split vertically"), 1);
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
1998-07-27 16:50:48 -04:00
|
|
|
void MyFrame::Unsplit(wxCommandEvent& WXUNUSED(event) )
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
if ( m_splitter->IsSplit() )
|
|
|
|
m_splitter->Unsplit();
|
|
|
|
SetStatusText(_T("No splitter"));
|
1998-10-23 09:15:15 -04:00
|
|
|
}
|
|
|
|
|
2002-02-22 10:09:45 -05:00
|
|
|
void MyFrame::ToggleLive(wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
long style = m_splitter->GetWindowStyleFlag();
|
|
|
|
if ( event.IsChecked() )
|
|
|
|
style |= wxSP_LIVE_UPDATE;
|
|
|
|
else
|
|
|
|
style &= ~wxSP_LIVE_UPDATE;
|
|
|
|
|
|
|
|
m_splitter->SetWindowStyleFlag(style);
|
|
|
|
}
|
|
|
|
|
2002-07-12 09:23:53 -04:00
|
|
|
void MyFrame::SetPosition(wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
|
|
|
wxString str;
|
|
|
|
str.Printf( wxT("%d"), m_splitter->GetSashPosition());
|
|
|
|
str = wxGetTextFromUser(_T("Enter splitter position:"), _T(""), str, this);
|
|
|
|
if ( str.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
long pos;
|
|
|
|
if ( !str.ToLong(&pos) )
|
|
|
|
{
|
|
|
|
wxLogError(_T("The splitter position should be an integer."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_splitter->SetSashPosition(pos);
|
|
|
|
|
|
|
|
wxLogStatus(this, _T("Splitter position set to %ld"), pos);
|
|
|
|
}
|
|
|
|
|
1998-10-23 09:15:15 -04:00
|
|
|
void MyFrame::SetMinSize(wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
wxString str;
|
2002-03-27 13:45:20 -05:00
|
|
|
str.Printf( wxT("%d"), m_splitter->GetMinimumPaneSize());
|
2002-01-07 13:33:30 -05:00
|
|
|
str = wxGetTextFromUser(_T("Enter minimal size for panes:"), _T(""), str, this);
|
2002-07-12 09:23:53 -04:00
|
|
|
if ( str.empty() )
|
2002-01-07 13:33:30 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
int minsize = wxStrtol( str, (wxChar**)NULL, 10 );
|
|
|
|
m_splitter->SetMinimumPaneSize(minsize);
|
2002-03-27 13:45:20 -05:00
|
|
|
str.Printf( wxT("Min pane size = %d"), minsize);
|
2002-01-07 13:33:30 -05:00
|
|
|
SetStatusText(str, 1);
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// Update UI handlers
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
void MyFrame::UpdateUIHorizontal(wxUpdateUIEvent& event)
|
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
event.Enable( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_HORIZONTAL) );
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::UpdateUIVertical(wxUpdateUIEvent& event)
|
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
event.Enable( ( (!m_splitter->IsSplit()) || (m_splitter->GetSplitMode() != wxSPLIT_VERTICAL) ) );
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::UpdateUIUnsplit(wxUpdateUIEvent& event)
|
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
event.Enable( m_splitter->IsSplit() );
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// MySplitterWindow
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MySplitterWindow, wxSplitterWindow)
|
|
|
|
EVT_SPLITTER_SASH_POS_CHANGED(-1, MySplitterWindow::OnPositionChanged)
|
|
|
|
EVT_SPLITTER_SASH_POS_CHANGING(-1, MySplitterWindow::OnPositionChanging)
|
|
|
|
|
|
|
|
EVT_SPLITTER_DCLICK(-1, MySplitterWindow::OnDClick)
|
|
|
|
|
|
|
|
EVT_SPLITTER_UNSPLIT(-1, MySplitterWindow::OnUnsplit)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
MySplitterWindow::MySplitterWindow(wxFrame *parent)
|
|
|
|
: wxSplitterWindow(parent, -1,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2004-03-03 15:44:37 -05:00
|
|
|
wxSP_3D | wxSP_LIVE_UPDATE |
|
|
|
|
wxCLIP_CHILDREN /* | wxSP_NO_XP_THEME */ )
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2002-01-07 13:33:30 -05:00
|
|
|
m_frame = parent;
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
void MySplitterWindow::OnPositionChanged(wxSplitterEvent& event)
|
|
|
|
{
|
|
|
|
wxLogStatus(m_frame, _T("Position has changed, now = %d (or %d)"),
|
|
|
|
event.GetSashPosition(), GetSashPosition());
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MySplitterWindow::OnPositionChanging(wxSplitterEvent& event)
|
|
|
|
{
|
|
|
|
wxLogStatus(m_frame, _T("Position is changing, now = %d (or %d)"),
|
|
|
|
event.GetSashPosition(), GetSashPosition());
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MySplitterWindow::OnDClick(wxSplitterEvent& event)
|
|
|
|
{
|
|
|
|
m_frame->SetStatusText(_T("Splitter double clicked"), 1);
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MySplitterWindow::OnUnsplit(wxSplitterEvent& event)
|
|
|
|
{
|
|
|
|
m_frame->SetStatusText(_T("Splitter unsplit"), 1);
|
|
|
|
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// MyCanvas
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2003-09-27 11:30:41 -04:00
|
|
|
MyCanvas::MyCanvas(wxWindow* parent, bool mirror)
|
|
|
|
: wxScrolledWindow(parent, -1, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxHSCROLL | wxVSCROLL | wxNO_FULL_REPAINT_ON_RESIZE)
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2003-09-27 11:30:41 -04:00
|
|
|
m_mirror = mirror;
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
MyCanvas::~MyCanvas()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-09-27 11:30:41 -04:00
|
|
|
void MyCanvas::OnDraw(wxDC& dcOrig)
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
2003-09-27 11:30:41 -04:00
|
|
|
wxMirrorDC dc(dcOrig, m_mirror);
|
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
dc.SetPen(*wxBLACK_PEN);
|
2003-09-27 11:30:41 -04:00
|
|
|
dc.DrawLine(0, 0, 100, 200);
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
dc.SetBackgroundMode(wxTRANSPARENT);
|
|
|
|
dc.DrawText(_T("Testing"), 50, 50);
|
1998-07-08 09:21:23 -04:00
|
|
|
|
2002-01-07 13:33:30 -05:00
|
|
|
dc.SetPen(*wxRED_PEN);
|
|
|
|
dc.SetBrush(*wxGREEN_BRUSH);
|
|
|
|
dc.DrawRectangle(120, 120, 100, 80);
|
1998-05-20 10:01:55 -04:00
|
|
|
}
|
2002-01-07 13:33:30 -05:00
|
|
|
|