1. slightly changed how wxControlContainer is used
2. use it now for wxSplitterWindow too 3. don't compile wxIdleEvent in !wxUSE_GUI mode (why was it done?) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -80,13 +80,17 @@ extern bool wxSetFocusToChild(wxWindow *win, wxWindow **child);
|
||||
|
||||
// declare the methods to be forwarded
|
||||
#define WX_DECLARE_CONTROL_CONTAINER() \
|
||||
public: \
|
||||
void OnNavigationKey(wxNavigationKeyEvent& event); \
|
||||
void OnFocus(wxFocusEvent& event); \
|
||||
virtual void OnChildFocus(wxChildFocusEvent& event); \
|
||||
virtual void SetFocus(); \
|
||||
virtual void RemoveChild(wxWindowBase *child); \
|
||||
virtual wxWindow *GetDefaultItem() const; \
|
||||
virtual wxWindow *SetDefaultItem(wxWindow *child) \
|
||||
virtual wxWindow *SetDefaultItem(wxWindow *child); \
|
||||
\
|
||||
protected: \
|
||||
wxControlContainer m_container
|
||||
|
||||
// implement the event table entries for wxControlContainer
|
||||
#define WX_EVENT_TABLE_CONTROL_CONTAINER(classname) \
|
||||
@@ -95,43 +99,43 @@ extern bool wxSetFocusToChild(wxWindow *win, wxWindow **child);
|
||||
EVT_NAVIGATION_KEY(classname::OnNavigationKey)
|
||||
|
||||
// implement the methods forwarding to the wxControlContainer
|
||||
#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname, container) \
|
||||
#define WX_DELEGATE_TO_CONTROL_CONTAINER(classname) \
|
||||
wxWindow *classname::SetDefaultItem(wxWindow *child) \
|
||||
{ \
|
||||
return container->SetDefaultItem(child); \
|
||||
return m_container.SetDefaultItem(child); \
|
||||
} \
|
||||
\
|
||||
wxWindow *classname::GetDefaultItem() const \
|
||||
{ \
|
||||
return container->GetDefaultItem(); \
|
||||
return m_container.GetDefaultItem(); \
|
||||
} \
|
||||
\
|
||||
void classname::OnNavigationKey( wxNavigationKeyEvent& event ) \
|
||||
{ \
|
||||
container->HandleOnNavigationKey(event); \
|
||||
m_container.HandleOnNavigationKey(event); \
|
||||
} \
|
||||
\
|
||||
void classname::RemoveChild(wxWindowBase *child) \
|
||||
{ \
|
||||
container->HandleOnWindowDestroy(child); \
|
||||
m_container.HandleOnWindowDestroy(child); \
|
||||
\
|
||||
wxWindow::RemoveChild(child); \
|
||||
} \
|
||||
\
|
||||
void classname::SetFocus() \
|
||||
{ \
|
||||
if ( !container->DoSetFocus() ) \
|
||||
if ( !m_container.DoSetFocus() ) \
|
||||
wxWindow::SetFocus(); \
|
||||
} \
|
||||
\
|
||||
void classname::OnChildFocus(wxChildFocusEvent& event) \
|
||||
{ \
|
||||
container->SetLastFocus(event.GetWindow()); \
|
||||
m_container.SetLastFocus(event.GetWindow()); \
|
||||
} \
|
||||
\
|
||||
void classname::OnFocus(wxFocusEvent& event) \
|
||||
{ \
|
||||
container->HandleOnFocus(event); \
|
||||
m_container.HandleOnFocus(event); \
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1512,8 +1512,6 @@ private:
|
||||
DECLARE_DYNAMIC_CLASS(wxContextMenuEvent)
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
// Idle event
|
||||
/*
|
||||
wxEVT_IDLE
|
||||
@@ -1536,6 +1534,8 @@ protected:
|
||||
bool m_requestMore;
|
||||
};
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
/* TODO
|
||||
wxEVT_POWER,
|
||||
wxEVT_MOUSE_CAPTURE_CHANGED,
|
||||
|
@@ -23,7 +23,6 @@
|
||||
#include "wx/window.h"
|
||||
#include "wx/containr.h"
|
||||
|
||||
class WXDLLEXPORT wxButton;
|
||||
class WXDLLEXPORT wxControlContainer;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
|
||||
@@ -35,7 +34,7 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
|
||||
class WXDLLEXPORT wxPanel : public wxWindow
|
||||
{
|
||||
public:
|
||||
wxPanel() { Init(); }
|
||||
wxPanel() : m_container(this) { Init(); }
|
||||
|
||||
// Old-style constructor (no default values for coordinates to avoid
|
||||
// ambiguity with the new one)
|
||||
@@ -43,6 +42,7 @@ public:
|
||||
int x, int y, int width, int height,
|
||||
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
|
||||
const wxString& name = wxPanelNameStr)
|
||||
: m_container(this)
|
||||
{
|
||||
Init();
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
|
||||
const wxString& name = wxPanelNameStr)
|
||||
: m_container(this)
|
||||
{
|
||||
Init();
|
||||
|
||||
@@ -90,9 +91,6 @@ protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// the object which implements the TAB traversal logic
|
||||
wxControlContainer *m_container;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxPanel)
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
@@ -37,6 +37,8 @@ enum
|
||||
wxSPLIT_DRAG_LEFT_DOWN
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxControlContainer;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxSplitterWindow maintains one or two panes, with
|
||||
// an optional vertical or horizontal split which
|
||||
@@ -60,7 +62,7 @@ public:
|
||||
// Public API
|
||||
|
||||
// Default constructor
|
||||
wxSplitterWindow()
|
||||
wxSplitterWindow() : m_container(this)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
@@ -71,12 +73,13 @@ public:
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxSP_3D,
|
||||
const wxString& name = "splitter")
|
||||
: m_container(this)
|
||||
{
|
||||
Init();
|
||||
Create(parent, id, pos, size, style, name);
|
||||
}
|
||||
|
||||
~wxSplitterWindow();
|
||||
virtual ~wxSplitterWindow();
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
@@ -209,9 +212,9 @@ protected:
|
||||
void SendUnsplitEvent(wxWindow *winRemoved);
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
|
||||
int m_splitMode;
|
||||
bool m_permitUnsplitAlways;
|
||||
bool m_needUpdating; // when in live mode, set this to TRUE to resize children in idle
|
||||
@@ -237,6 +240,8 @@ protected:
|
||||
wxPen* m_facePen;
|
||||
|
||||
private:
|
||||
WX_DECLARE_CONTROL_CONTAINER();
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxSplitterWindow)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
@@ -79,13 +79,12 @@ public:
|
||||
private:
|
||||
void UpdatePosition();
|
||||
|
||||
wxMenu* fileMenu;
|
||||
wxMenuBar* menuBar;
|
||||
MyCanvas* m_leftCanvas;
|
||||
MyCanvas* m_rightCanvas;
|
||||
wxWindow *m_left,
|
||||
*m_right;
|
||||
|
||||
MySplitterWindow* m_splitter;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
class MyCanvas: public wxScrolledWindow
|
||||
@@ -154,7 +153,7 @@ MyFrame::MyFrame(wxFrame* frame, const wxString& title,
|
||||
CreateStatusBar(2);
|
||||
|
||||
// Make a menubar
|
||||
fileMenu = new wxMenu;
|
||||
wxMenu *fileMenu = new wxMenu;
|
||||
fileMenu->Append(SPLIT_VERTICAL, "Split &Vertically\tCtrl-V", "Split vertically");
|
||||
fileMenu->Append(SPLIT_HORIZONTAL, "Split &Horizontally\tCtrl-H", "Split horizontally");
|
||||
fileMenu->Append(SPLIT_UNSPLIT, "&Unsplit\tCtrl-U", "Unsplit");
|
||||
@@ -163,33 +162,33 @@ MyFrame::MyFrame(wxFrame* frame, const wxString& title,
|
||||
fileMenu->AppendSeparator();
|
||||
fileMenu->Append(SPLIT_QUIT, "E&xit\tAlt-X", "Exit");
|
||||
|
||||
menuBar = new wxMenuBar;
|
||||
wxMenuBar *menuBar = new wxMenuBar;
|
||||
menuBar->Append(fileMenu, "&File");
|
||||
|
||||
SetMenuBar(menuBar);
|
||||
|
||||
m_splitter = new MySplitterWindow(this, SPLITTER_WINDOW);
|
||||
|
||||
#if 0
|
||||
wxSize sz( m_splitter->GetSize() );
|
||||
wxLogMessage( "Initial splitter size: %d %d\n", (int)sz.x, (int)sz.y );
|
||||
#endif // 0
|
||||
#if 1
|
||||
m_left = new MyCanvas(m_splitter, CANVAS1, wxPoint(0, 0), wxSize(400, 400), "Test1" );
|
||||
m_left->SetBackgroundColour(*wxRED);
|
||||
m_left->SetScrollbars(20, 20, 50, 50);
|
||||
m_left->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
|
||||
|
||||
m_leftCanvas = new MyCanvas(m_splitter, CANVAS1, wxPoint(0, 0), wxSize(400, 400), "Test1" );
|
||||
m_leftCanvas->SetBackgroundColour(*wxRED);
|
||||
m_leftCanvas->SetScrollbars(20, 20, 50, 50);
|
||||
m_leftCanvas->SetCursor(wxCursor(wxCURSOR_MAGNIFIER));
|
||||
|
||||
m_rightCanvas = new MyCanvas(m_splitter, CANVAS2, wxPoint(0, 0), wxSize(400, 400), "Test2" );
|
||||
m_rightCanvas->SetBackgroundColour(*wxCYAN);
|
||||
m_rightCanvas->SetScrollbars(20, 20, 50, 50);
|
||||
m_right = new MyCanvas(m_splitter, CANVAS2, wxPoint(0, 0), wxSize(400, 400), "Test2" );
|
||||
m_right->SetBackgroundColour(*wxCYAN);
|
||||
m_right->SetScrollbars(20, 20, 50, 50);
|
||||
#else // for testing kbd navigation inside the splitter
|
||||
m_left = new wxTextCtrl(m_splitter, -1, "first text");
|
||||
m_right = new wxTextCtrl(m_splitter, -1, "second text");
|
||||
#endif
|
||||
|
||||
// you can also do this to start with a single window
|
||||
#if 0
|
||||
m_rightCanvas->Show(FALSE);
|
||||
m_splitter->Initialize(m_leftCanvas);
|
||||
m_right->Show(FALSE);
|
||||
m_splitter->Initialize(m_left);
|
||||
#else
|
||||
m_splitter->SplitVertically(m_leftCanvas, m_rightCanvas, 100);
|
||||
m_splitter->SplitVertically(m_left, m_right, 100);
|
||||
#endif
|
||||
|
||||
SetStatusText("Min pane size = 0", 1);
|
||||
@@ -208,9 +207,9 @@ void MyFrame::SplitHorizontal(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
if ( m_splitter->IsSplit() )
|
||||
m_splitter->Unsplit();
|
||||
m_leftCanvas->Show(TRUE);
|
||||
m_rightCanvas->Show(TRUE);
|
||||
m_splitter->SplitHorizontally( m_leftCanvas, m_rightCanvas );
|
||||
m_left->Show(TRUE);
|
||||
m_right->Show(TRUE);
|
||||
m_splitter->SplitHorizontally( m_left, m_right );
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
@@ -218,9 +217,9 @@ void MyFrame::SplitVertical(wxCommandEvent& WXUNUSED(event) )
|
||||
{
|
||||
if ( m_splitter->IsSplit() )
|
||||
m_splitter->Unsplit();
|
||||
m_leftCanvas->Show(TRUE);
|
||||
m_rightCanvas->Show(TRUE);
|
||||
m_splitter->SplitVertically( m_leftCanvas, m_rightCanvas );
|
||||
m_left->Show(TRUE);
|
||||
m_right->Show(TRUE);
|
||||
m_splitter->SplitVertically( m_left, m_right );
|
||||
UpdatePosition();
|
||||
}
|
||||
|
||||
|
@@ -52,9 +52,9 @@
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject)
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
|
||||
|
||||
#if wxUSE_GUI
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent)
|
||||
|
@@ -57,7 +57,7 @@ END_EVENT_TABLE()
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, m_container)
|
||||
WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxPanel creation
|
||||
@@ -65,7 +65,6 @@ WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, m_container)
|
||||
|
||||
void wxPanel::Init()
|
||||
{
|
||||
m_container = new wxControlContainer(this);
|
||||
}
|
||||
|
||||
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
|
||||
@@ -79,7 +78,6 @@ bool wxPanel::Create(wxWindow *parent, wxWindowID id,
|
||||
|
||||
wxPanel::~wxPanel()
|
||||
{
|
||||
delete m_container;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -56,14 +56,21 @@ BEGIN_EVENT_TABLE(wxSplitterWindow, wxWindow)
|
||||
EVT_SPLITTER_SASH_POS_CHANGING(-1, wxSplitterWindow::OnSashPosChanged)
|
||||
EVT_SPLITTER_DCLICK(-1, wxSplitterWindow::OnDoubleClick)
|
||||
EVT_SPLITTER_UNSPLIT(-1, wxSplitterWindow::OnUnsplitEvent)
|
||||
|
||||
WX_EVENT_TABLE_CONTROL_CONTAINER(wxSplitterWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
WX_DELEGATE_TO_CONTROL_CONTAINER(wxSplitterWindow);
|
||||
|
||||
bool wxSplitterWindow::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
// allow TABbing from one window to the other
|
||||
style |= wxTAB_TRAVERSAL;
|
||||
|
||||
if (!wxWindow::Create(parent, id, pos, size, style, name))
|
||||
return FALSE;
|
||||
|
||||
|
Reference in New Issue
Block a user