From 35c9aadc34f52e29a8157fd44dfceeac6c4d49d4 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 23 Nov 2002 00:00:21 +0000 Subject: [PATCH] wxTabEvent and tab styles now in keeping with wxNotebook, for future reference. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17950 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 6 +++++- include/wx/msw/tabctrl.h | 26 ++++++++++++++++++++++---- src/msw/tabctrl.cpp | 11 ++--------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 86ec8bcd1b..5482b48848 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1173,8 +1173,12 @@ enum wxBorder */ #define wxTC_RIGHTJUSTIFY 0x0010 #define wxTC_FIXEDWIDTH 0x0020 -#define wxTC_OWNERDRAW 0x0040 +#define wxTC_TOP 0x0000 // default +#define wxTC_LEFT 0x0020 +#define wxTC_RIGHT 0x0040 +#define wxTC_BOTTOM 0x0080 #define wxTC_MULTILINE wxNB_MULTILINE +#define wxTC_OWNERDRAW 0x0200 // wxToolBar style flags #define wxTB_HORIZONTAL wxHORIZONTAL // == 0x0004 diff --git a/include/wx/msw/tabctrl.h b/include/wx/msw/tabctrl.h index e97a957a28..014ea3167b 100644 --- a/include/wx/msw/tabctrl.h +++ b/include/wx/msw/tabctrl.h @@ -126,12 +126,30 @@ protected: DECLARE_EVENT_TABLE() }; -class WXDLLEXPORT wxTabEvent: public wxNotifyEvent +class WXDLLEXPORT wxTabEvent : public wxNotifyEvent { - DECLARE_DYNAMIC_CLASS(wxTabEvent) +public: + wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0, + int nSel = -1, int nOldSel = -1) + : wxNotifyEvent(commandType, id) + { + m_nSel = nSel; + m_nOldSel = nOldSel; + } - public: - wxTabEvent(wxEventType commandType = wxEVT_NULL, int id = 0); + // accessors + // the currently selected page (-1 if none) + int GetSelection() const { return m_nSel; } + void SetSelection(int nSel) { m_nSel = nSel; } + // the page that was selected before the change (-1 if none) + int GetOldSelection() const { return m_nOldSel; } + void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; } + +private: + int m_nSel, // currently selected page + m_nOldSel; // previously selected page + + DECLARE_DYNAMIC_CLASS(wxTabEvent) }; typedef void (wxEvtHandler::*wxTabEventFunction)(wxTabEvent&); diff --git a/src/msw/tabctrl.cpp b/src/msw/tabctrl.cpp index d5fc8ed130..c2553f2f2f 100644 --- a/src/msw/tabctrl.cpp +++ b/src/msw/tabctrl.cpp @@ -45,6 +45,7 @@ #include "wx/msw/imaglist.h" IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxNotifyEvent) DEFINE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGING) @@ -158,6 +159,7 @@ bool wxTabCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) event.SetEventObject( this ); event.SetEventType(eventType); event.SetInt(idCtrl) ; + event.SetSelection(idCtrl); return ProcessEvent(event); } @@ -439,14 +441,5 @@ void wxMapBitmap(HBITMAP hBitmap, int width, int height) } #endif -// Tab event -IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxNotifyEvent) - -wxTabEvent::wxTabEvent(wxEventType commandType, int id): - wxNotifyEvent(commandType, id) -{ -} - - #endif // __WIN95__