+// ----------------------------------------------------------------------------
+// event class and macros
+// ----------------------------------------------------------------------------
+
+// we reuse the same class for all splitter event types because this is the
+// usual wxWin convention, but the three event types have different kind of
+// data associated with them, so the accessors can be only used if the real
+// event type matches with the one for which the accessors make sense
+class WXDLLEXPORT wxSplitterEvent : public wxCommandEvent
+{
+public:
+ wxSplitterEvent(wxEventType type = wxEVT_NULL,
+ wxSplitterWindow *splitter = (wxSplitterWindow *)NULL)
+ : wxCommandEvent(type)
+ {
+ SetEventObject(splitter);
+ if (splitter) m_id = splitter->GetId();
+ }
+
+ // SASH_POS_CHANGED methods
+
+ // setting the sash position to -1 prevents the change from taking place at
+ // all
+ void SetSashPosition(int pos)
+ {
+ 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
+ || GetEventType() == wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING);
+
+ return m_data.pos;
+ }
+
+ // UNSPLIT event methods
+ wxWindow *GetWindowBeingRemoved() const
+ {
+ wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_UNSPLIT );
+
+ return m_data.win;
+ }
+
+ // DCLICK event methods
+ int GetX() const
+ {
+ wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_DOUBLECLICKED );
+
+ return m_data.pt.x;
+ }
+
+ int GetY() const
+ {
+ wxASSERT( GetEventType() == wxEVT_COMMAND_SPLITTER_DOUBLECLICKED );
+
+ return m_data.pt.y;
+ }
+
+private:
+ friend class WXDLLEXPORT wxSplitterWindow;
+
+ // data for the different types of event
+ union
+ {
+ int pos; // position for SASH_POS_CHANGED event
+ wxWindow *win; // window being removed for UNSPLIT event
+ struct
+ {
+ int x, y;
+ } pt; // position of double click for DCLICK event
+ } m_data;
+
+ DECLARE_DYNAMIC_CLASS(wxSplitterEvent)
+};
+
+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) \
+ 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 \
+ ),
+