calctrl.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/calctrl.h
  3. // Purpose: wxCalendarCtrl control implementation for MSW
  4. // Author: Vadim Zeitlin
  5. // Copyright: (C) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_MSW_CALCTRL_H_
  9. #define _WX_MSW_CALCTRL_H_
  10. class WXDLLIMPEXP_ADV wxCalendarCtrl : public wxCalendarCtrlBase
  11. {
  12. public:
  13. wxCalendarCtrl() { Init(); }
  14. wxCalendarCtrl(wxWindow *parent,
  15. wxWindowID id,
  16. const wxDateTime& date = wxDefaultDateTime,
  17. const wxPoint& pos = wxDefaultPosition,
  18. const wxSize& size = wxDefaultSize,
  19. long style = wxCAL_SHOW_HOLIDAYS,
  20. const wxString& name = wxCalendarNameStr)
  21. {
  22. Init();
  23. Create(parent, id, date, pos, size, style, name);
  24. }
  25. bool Create(wxWindow *parent,
  26. wxWindowID id,
  27. const wxDateTime& date = wxDefaultDateTime,
  28. const wxPoint& pos = wxDefaultPosition,
  29. const wxSize& size = wxDefaultSize,
  30. long style = wxCAL_SHOW_HOLIDAYS,
  31. const wxString& name = wxCalendarNameStr);
  32. virtual bool SetDate(const wxDateTime& date);
  33. virtual wxDateTime GetDate() const;
  34. virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
  35. const wxDateTime& upperdate = wxDefaultDateTime);
  36. virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const;
  37. virtual bool EnableMonthChange(bool enable = true);
  38. virtual void Mark(size_t day, bool mark);
  39. virtual void SetHoliday(size_t day);
  40. virtual wxCalendarHitTestResult HitTest(const wxPoint& pos,
  41. wxDateTime *date = NULL,
  42. wxDateTime::WeekDay *wd = NULL);
  43. virtual void SetWindowStyleFlag(long style);
  44. protected:
  45. virtual wxSize DoGetBestSize() const;
  46. virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
  47. virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
  48. void MSWOnClick(wxMouseEvent& event);
  49. void MSWOnDoubleClick(wxMouseEvent& event);
  50. private:
  51. void Init();
  52. // bring the control in sync with m_marks
  53. void UpdateMarks();
  54. // set first day of week in the control to correspond to our
  55. // wxCAL_MONDAY_FIRST flag
  56. void UpdateFirstDayOfWeek();
  57. // reset holiday information
  58. virtual void ResetHolidayAttrs() { m_holidays = 0; }
  59. // redisplay holidays
  60. virtual void RefreshHolidays() { UpdateMarks(); }
  61. // current date, we need to store it instead of simply retrieving it from
  62. // the control as needed in order to be able to generate the correct events
  63. // from MSWOnNotify()
  64. wxDateTime m_date;
  65. // bit field containing the state (marked or not) of all days in the month
  66. wxUint32 m_marks;
  67. // the same but indicating whether a day is a holiday or not
  68. wxUint32 m_holidays;
  69. DECLARE_DYNAMIC_CLASS(wxCalendarCtrl)
  70. wxDECLARE_NO_COPY_CLASS(wxCalendarCtrl);
  71. };
  72. #endif // _WX_MSW_CALCTRL_H_