]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/generic/splitter.h
Headers to support 'Y' positioning fixes for OS/2 controls
[wxWidgets.git] / include / wx / generic / splitter.h
index 55c78919087516c794021bfa08dfc5a23ccec9af..8528e2265bcb0ed052509e5aea944551125bbab3 100644 (file)
@@ -17,6 +17,7 @@
 #endif
 
 #include "wx/window.h"                      // base class declaration
+#include "wx/containr.h"                    // wxControlContainer
 
 class WXDLLEXPORT wxSplitterEvent;
 
@@ -60,15 +61,29 @@ public:
 // Public API
 
     // Default constructor
-    wxSplitterWindow();
+    wxSplitterWindow()
+    {
+        Init();
+    }
 
     // Normal constructor
     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);
+    }
+
+    virtual ~wxSplitterWindow();
+
+    bool Create(wxWindow *parent, wxWindowID id = -1,
+                     const wxPoint& pos = wxDefaultPosition,
+                     const wxSize& size = wxDefaultSize,
+                     long style = wxSP_3D,
                      const wxString& name = "splitter");
-    ~wxSplitterWindow();
 
     // Gets the only or left/top pane
     wxWindow *GetWindow1() const { return m_windowOne; }
@@ -160,33 +175,47 @@ public:
     // Adjusts the panes
     void OnSize(wxSizeEvent& event);
 
+    // In live mode, resize child windows in idle time
+    void OnIdle(wxIdleEvent& event);
+
     // Draws borders
-    void DrawBorders(wxDC& dc);
+    virtual void DrawBorders(wxDC& dc);
 
     // Draws the sash
-    void DrawSash(wxDC& dc);
+    virtual void DrawSash(wxDC& dc);
 
     // Draws the sash tracker (for whilst moving the sash)
-    void DrawSashTracker(int x, int y);
+    virtual void DrawSashTracker(int x, int y);
 
     // Tests for x, y over sash
-    bool SashHitTest(int x, int y, int tolerance = 2);
+    virtual bool SashHitTest(int x, int y, int tolerance = 2);
 
     // Resizes subwindows
-    void SizeWindows();
+    virtual void SizeWindows();
 
     // Initialize colours
     void InitColours();
 
+    void SetNeedUpdating(bool needUpdating) { m_needUpdating = needUpdating; }
+    bool GetNeedUpdating() const { return m_needUpdating ; }
+
 protected:
     // our event handlers
     void OnSashPosChanged(wxSplitterEvent& event);
+    void OnSashPosChanging(wxSplitterEvent& event);
     void OnDoubleClick(wxSplitterEvent& event);
     void OnUnsplitEvent(wxSplitterEvent& event);
+    void OnSetCursor(wxSetCursorEvent& event);
 
     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
     wxWindow*   m_windowOne;
     wxWindow*   m_windowTwo;
     int         m_dragMode;
@@ -209,6 +238,8 @@ protected:
     wxPen*      m_facePen;
 
 private:
+    WX_DECLARE_CONTROL_CONTAINER();
+
     DECLARE_DYNAMIC_CLASS(wxSplitterWindow)
     DECLARE_EVENT_TABLE()
 };
@@ -229,6 +260,7 @@ public:
         : wxCommandEvent(type)
     {
         SetEventObject(splitter);
+        if (splitter) m_id = splitter->GetId();
     }
 
     // SASH_POS_CHANGED methods
@@ -237,14 +269,16 @@ public:
     // all
     void SetSashPosition(int pos)
     {
-        wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED );
+        wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
+                || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING);
 
         m_data.pos = pos;
     }
 
     int GetSashPosition() const
     {
-        wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED );
+        wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED
+                || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING);
 
         return m_data.pos;
     }
@@ -273,7 +307,7 @@ public:
     }
 
 private:
-    friend wxSplitterWindow;
+    friend class WXDLLEXPORT wxSplitterWindow;
 
     // data for the different types of event
     union
@@ -292,30 +326,39 @@ private:
 typedef void (wxEvtHandler::*wxSplitterEventFunction)(wxSplitterEvent&);
 
 #define EVT_SPLITTER_SASH_POS_CHANGED(id, fn)                               \
-  {                                                                         \
+  DECLARE_EVENT_TABLE_ENTRY(                                                \
     wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED,                                \
     id,                                                                     \
     -1,                                                                     \
     (wxObjectEventFunction)(wxEventFunction)(wxSplitterEventFunction) &fn,  \
     NULL                                                                    \
-  },
+  ),
+
+#define EVT_SPLITTER_SASH_POS_CHANGING(id, fn)                              \
+  DECLARE_EVENT_TABLE_ENTRY(                                                \
+    wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING,                               \
+    id,                                                                     \
+    -1,                                                                     \
+    (wxObjectEventFunction)(wxEventFunction)(wxSplitterEventFunction) &fn,  \
+    NULL                                                                    \
+  ),
 
-#define EVT_SPLITTER_DCLICK(id, fn)                                   \
-  {                                                                         \
-    wxEVT_COMMAND_SPLITTER_DOUBLECLICKED,                                    \
+#define EVT_SPLITTER_DCLICK(id, fn)                                         \
+  DECLARE_EVENT_TABLE_ENTRY(                                                \
+    wxEVT_COMMAND_SPLITTER_DOUBLECLICKED,                                   \
     id,                                                                     \
     -1,                                                                     \
     (wxObjectEventFunction)(wxEventFunction)(wxSplitterEventFunction) &fn,  \
     NULL                                                                    \
-  },
+  ),
 
 #define EVT_SPLITTER_UNSPLIT(id, fn)                                        \
-  {                                                                         \
+  DECLARE_EVENT_TABLE_ENTRY(                                                \
     wxEVT_COMMAND_SPLITTER_UNSPLIT,                                         \
     id,                                                                     \
     -1,                                                                     \
     (wxObjectEventFunction)(wxEventFunction)(wxSplitterEventFunction) &fn,  \
     NULL                                                                    \
-  },
+  ),
 
 #endif // __SPLITTERH_G__