dateevt.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/dateevt.h
  3. // Purpose: declares wxDateEvent class
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 2005-01-10
  7. // Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwindows.org>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_DATEEVT_H_
  11. #define _WX_DATEEVT_H_
  12. #include "wx/event.h"
  13. #include "wx/datetime.h"
  14. #include "wx/window.h"
  15. // ----------------------------------------------------------------------------
  16. // wxDateEvent: used by wxCalendarCtrl, wxDatePickerCtrl and wxTimePickerCtrl.
  17. // ----------------------------------------------------------------------------
  18. class WXDLLIMPEXP_ADV wxDateEvent : public wxCommandEvent
  19. {
  20. public:
  21. wxDateEvent() { }
  22. wxDateEvent(wxWindow *win, const wxDateTime& dt, wxEventType type)
  23. : wxCommandEvent(type, win->GetId()),
  24. m_date(dt)
  25. {
  26. SetEventObject(win);
  27. }
  28. const wxDateTime& GetDate() const { return m_date; }
  29. void SetDate(const wxDateTime &date) { m_date = date; }
  30. // default copy ctor, assignment operator and dtor are ok
  31. virtual wxEvent *Clone() const { return new wxDateEvent(*this); }
  32. private:
  33. wxDateTime m_date;
  34. DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxDateEvent)
  35. };
  36. // ----------------------------------------------------------------------------
  37. // event types and macros for handling them
  38. // ----------------------------------------------------------------------------
  39. wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_ADV, wxEVT_DATE_CHANGED, wxDateEvent);
  40. wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_ADV, wxEVT_TIME_CHANGED, wxDateEvent);
  41. typedef void (wxEvtHandler::*wxDateEventFunction)(wxDateEvent&);
  42. #define wxDateEventHandler(func) \
  43. wxEVENT_HANDLER_CAST(wxDateEventFunction, func)
  44. #define EVT_DATE_CHANGED(id, fn) \
  45. wx__DECLARE_EVT1(wxEVT_DATE_CHANGED, id, wxDateEventHandler(fn))
  46. #define EVT_TIME_CHANGED(id, fn) \
  47. wx__DECLARE_EVT1(wxEVT_TIME_CHANGED, id, wxDateEventHandler(fn))
  48. #endif // _WX_DATEEVT_H_