]> git.saurik.com Git - wxWidgets.git/commitdiff
1. slightly changed how wxControlContainer is used
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 6 Aug 2001 12:55:04 +0000 (12:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 6 Aug 2001 12:55:04 +0000 (12:55 +0000)
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

include/wx/containr.h
include/wx/event.h
include/wx/generic/panelg.h
include/wx/generic/splitter.h
samples/splitter/splitter.cpp
src/common/event.cpp
src/generic/panelg.cpp
src/generic/splitter.cpp

index 11a3dddf98cabd9fa6e14701c4b480e2e5d0f00e..3e84da9384f1298e39b02b0ed9da4dd76a30bce4 100644 (file)
@@ -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); \
 }
 
 
index 16332530aad7c88032c27bd88036bf3cda725766..d3daa5b71e3d272733f82c3cde306c88c27b82b3 100644 (file)
@@ -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,
index a66dd5b7aa252bb140c586a991ac122a90cdf0d3..85f91ee81a39e7bbb0c581ac8e63ca3da5cf0fb9 100644 (file)
@@ -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()
index 09fa572b011ccf7245ed24b24a6f57859d05c2ca..853e75e5a1a499abc08fc853866275c483cda8ec 100644 (file)
@@ -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()
 };
index 4bde92e99ac75f159dd7672811397068a104d498..c7789cc0f8e71b9c3d4398baf689b89b27c2c0e8 100644 (file)
@@ -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
-
-  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);
@@ -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();
 }
 
index 3856f917365f60e3175ba15307ddc53228c75449..e9a76b3fd2355631b84d26ded1a09a3708ca9f2d 100644 (file)
@@ -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)
index f42365f225e6c3e30a1cbcfbca6db8a44bf9cfc7..c36c49c46d2bb3397d4eb1ef64a85582b3c63488 100644 (file)
@@ -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;
 }
 
 // ----------------------------------------------------------------------------
index 6ff6aa9b6297adc25afebb322f4102c937c7c1ed..7b0a84b401e66e64c102641e49b16658dbe5af10 100644 (file)
@@ -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;