]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/generic/splitter.h
Updated the erase/paint event logic.
[wxWidgets.git] / include / wx / generic / splitter.h
index ff65670f54c3922b866707d2bfa059e8e915f2be..94e371330020e0849723950caf4a7dc0b92f46bd 100644 (file)
@@ -17,6 +17,7 @@
 #endif
 
 #include "wx/window.h"                      // base class declaration
+#include "wx/containr.h"                    // wxControlContainer
 
 class WXDLLEXPORT wxSplitterEvent;
 
@@ -24,7 +25,7 @@ class WXDLLEXPORT wxSplitterEvent;
 // splitter constants
 // ---------------------------------------------------------------------------
 
-enum
+enum wxSplitMode
 {
     wxSPLIT_HORIZONTAL = 1,
     wxSPLIT_VERTICAL
@@ -69,19 +70,19 @@ public:
     wxSplitterWindow(wxWindow *parent, wxWindowID id = -1,
                      const wxPoint& pos = wxDefaultPosition,
                      const wxSize& size = wxDefaultSize,
-                     long style = wxSP_3D|wxCLIP_CHILDREN,
+                     long style = wxSP_3D,
                      const wxString& name = "splitter")
     {
         Init();
         Create(parent, id, pos, size, style, name);
     }
 
-    ~wxSplitterWindow();
+    virtual ~wxSplitterWindow();
 
     bool Create(wxWindow *parent, wxWindowID id = -1,
                      const wxPoint& pos = wxDefaultPosition,
                      const wxSize& size = wxDefaultSize,
-                     long style = wxSP_3D|wxCLIP_CHILDREN,
+                     long style = wxSP_3D,
                      const wxString& name = "splitter");
 
     // Gets the only or left/top pane
@@ -91,10 +92,16 @@ public:
     wxWindow *GetWindow2() const { return m_windowTwo; }
 
     // Sets the split mode
-    void SetSplitMode(int mode) { m_splitMode = mode; }
+    void SetSplitMode(int mode)
+    {
+        wxASSERT_MSG( mode == wxSPLIT_VERTICAL || mode == wxSPLIT_HORIZONTAL,
+                      _T("invalid split mode") );
+
+        m_splitMode = (wxSplitMode)mode;
+    }
 
     // Gets the split mode
-    int GetSplitMode() const { return m_splitMode; };
+    wxSplitMode GetSplitMode() const { return m_splitMode; };
 
     // Initialize with one window
     void Initialize(wxWindow *window);
@@ -107,10 +114,12 @@ public:
     // absolute value rather than the size of left/upper pane.
     virtual bool SplitVertically(wxWindow *window1,
                                  wxWindow *window2,
-                                 int sashPosition = 0);
+                                 int sashPosition = 0)
+        { return DoSplit(wxSPLIT_VERTICAL, window1, window2, sashPosition); }
     virtual bool SplitHorizontally(wxWindow *window1,
                                    wxWindow *window2,
-                                   int sashPosition = 0);
+                                   int sashPosition = 0)
+        { return DoSplit(wxSPLIT_HORIZONTAL, window1, window2, sashPosition); }
 
     // Removes the specified (or second) window from the view
     // Doesn't actually delete the window.
@@ -209,10 +218,21 @@ protected:
     void SendUnsplitEvent(wxWindow *winRemoved);
 
 protected:
+    // common part of all ctors
     void Init();
 
+    // common part of SplitVertically() and SplitHorizontally()
+    bool DoSplit(wxSplitMode mode,
+                 wxWindow *window1, wxWindow *window2,
+                 int sashPosition);
 
-    int         m_splitMode;
+    // adjusts sash position with respect to min. pane and window sizes
+    int AdjustSashPosition(int sashPos) const;
+
+    // get either width or height depending on the split mode
+    int GetWindowSize() const;
+
+    wxSplitMode m_splitMode;
     bool        m_permitUnsplitAlways;
     bool        m_needUpdating; // when in live mode, set this to TRUE to resize children in idle
     wxWindow*   m_windowOne;
@@ -237,6 +257,8 @@ protected:
     wxPen*      m_facePen;
 
 private:
+    WX_DECLARE_CONTROL_CONTAINER();
+
     DECLARE_DYNAMIC_CLASS(wxSplitterWindow)
     DECLARE_EVENT_TABLE()
 };