+// ----------------------------------------------------------------------------
+// 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 WXDLLIMPEXP_CORE wxSplitterEvent : public wxNotifyEvent
+{
+public:
+ wxSplitterEvent(wxEventType type = wxEVT_NULL,
+ wxSplitterWindow *splitter = NULL)
+ : wxNotifyEvent(type)
+ {
+ SetEventObject(splitter);
+ if (splitter) m_id = splitter->GetId();
+ }
+ wxSplitterEvent(const wxSplitterEvent& event)
+ : wxNotifyEvent(event), m_data(event.m_data) { }
+
+ // 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_SPLITTER_SASH_POS_CHANGED
+ || GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGING);
+
+ m_data.pos = pos;
+ }
+
+ int GetSashPosition() const
+ {
+ wxASSERT( GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGED
+ || GetEventType() == wxEVT_SPLITTER_SASH_POS_CHANGING);
+
+ return m_data.pos;
+ }
+
+ // UNSPLIT event methods
+ wxWindow *GetWindowBeingRemoved() const
+ {
+ wxASSERT( GetEventType() == wxEVT_SPLITTER_UNSPLIT );
+
+ return m_data.win;
+ }
+
+ // DCLICK event methods
+ int GetX() const
+ {
+ wxASSERT( GetEventType() == wxEVT_SPLITTER_DOUBLECLICKED );
+
+ return m_data.pt.x;
+ }
+
+ int GetY() const
+ {
+ wxASSERT( GetEventType() == wxEVT_SPLITTER_DOUBLECLICKED );
+
+ return m_data.pt.y;
+ }
+
+ virtual wxEvent *Clone() const { return new wxSplitterEvent(*this); }
+
+private:
+ friend class WXDLLIMPEXP_FWD_CORE 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_NO_ASSIGN(wxSplitterEvent)
+};
+
+typedef void (wxEvtHandler::*wxSplitterEventFunction)(wxSplitterEvent&);
+
+#define wxSplitterEventHandler(func) \
+ wxEVENT_HANDLER_CAST(wxSplitterEventFunction, func)
+
+#define wx__DECLARE_SPLITTEREVT(evt, id, fn) \
+ wx__DECLARE_EVT1(wxEVT_SPLITTER_ ## evt, id, wxSplitterEventHandler(fn))
+
+#define EVT_SPLITTER_SASH_POS_CHANGED(id, fn) \
+ wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGED, id, fn)
+
+#define EVT_SPLITTER_SASH_POS_CHANGING(id, fn) \
+ wx__DECLARE_SPLITTEREVT(SASH_POS_CHANGING, id, fn)
+
+#define EVT_SPLITTER_DCLICK(id, fn) \
+ wx__DECLARE_SPLITTEREVT(DOUBLECLICKED, id, fn)
+
+#define EVT_SPLITTER_UNSPLIT(id, fn) \
+ wx__DECLARE_SPLITTEREVT(UNSPLIT, id, fn)
+
+
+// old wxEVT_COMMAND_* constants
+#define wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED wxEVT_SPLITTER_SASH_POS_CHANGED
+#define wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING wxEVT_SPLITTER_SASH_POS_CHANGING
+#define wxEVT_COMMAND_SPLITTER_DOUBLECLICKED wxEVT_SPLITTER_DOUBLECLICKED
+#define wxEVT_COMMAND_SPLITTER_UNSPLIT wxEVT_SPLITTER_UNSPLIT
+
+#endif // _WX_GENERIC_SPLITTER_H_