// 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) \
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); \
}
DECLARE_DYNAMIC_CLASS(wxContextMenuEvent)
};
-#endif // wxUSE_GUI
-
// Idle event
/*
wxEVT_IDLE
bool m_requestMore;
};
+#endif // wxUSE_GUI
+
/* TODO
wxEVT_POWER,
wxEVT_MOUSE_CAPTURE_CHANGED,
#include "wx/window.h"
#include "wx/containr.h"
-class WXDLLEXPORT wxButton;
class WXDLLEXPORT wxControlContainer;
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)
int x, int y, int width, int height,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
+ : m_container(this)
{
Init();
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL | wxNO_BORDER,
const wxString& name = wxPanelNameStr)
+ : m_container(this)
{
Init();
// 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()
wxSPLIT_DRAG_LEFT_DOWN
};
+class WXDLLEXPORT wxControlContainer;
+
// ---------------------------------------------------------------------------
// wxSplitterWindow maintains one or two panes, with
// an optional vertical or horizontal split which
// Public API
// Default constructor
- wxSplitterWindow()
+ wxSplitterWindow() : m_container(this)
{
Init();
}
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,
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
wxPen* m_facePen;
private:
+ WX_DECLARE_CONTROL_CONTAINER();
+
DECLARE_DYNAMIC_CLASS(wxSplitterWindow)
DECLARE_EVENT_TABLE()
};
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
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");
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
-
- 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);
+#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_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);
{
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();
}
{
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();
}
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)
// implementation
// ============================================================================
-WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel, m_container)
+WX_DELEGATE_TO_CONTROL_CONTAINER(wxPanel)
// ----------------------------------------------------------------------------
// wxPanel creation
void wxPanel::Init()
{
- m_container = new wxControlContainer(this);
}
bool wxPanel::Create(wxWindow *parent, wxWindowID id,
wxPanel::~wxPanel()
{
- delete m_container;
}
// ----------------------------------------------------------------------------
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;