]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/calctrl.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / include / wx / msw / calctrl.h
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
9 #ifndef _WX_MSW_CALCTRL_H_
10 #define _WX_MSW_CALCTRL_H_
11
12 class WXDLLIMPEXP_ADV wxCalendarCtrl : public wxCalendarCtrlBase
13 {
14 public:
15 wxCalendarCtrl() { Init(); }
16 wxCalendarCtrl(wxWindow *parent,
17 wxWindowID id,
18 const wxDateTime& date = wxDefaultDateTime,
19 const wxPoint& pos = wxDefaultPosition,
20 const wxSize& size = wxDefaultSize,
21 long style = wxCAL_SHOW_HOLIDAYS,
22 const wxString& name = wxCalendarNameStr)
23 {
24 Init();
25
26 Create(parent, id, date, pos, size, style, name);
27 }
28
29 bool Create(wxWindow *parent,
30 wxWindowID id,
31 const wxDateTime& date = wxDefaultDateTime,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 long style = wxCAL_SHOW_HOLIDAYS,
35 const wxString& name = wxCalendarNameStr);
36
37 virtual bool SetDate(const wxDateTime& date);
38 virtual wxDateTime GetDate() const;
39
40 virtual bool SetDateRange(const wxDateTime& lowerdate = wxDefaultDateTime,
41 const wxDateTime& upperdate = wxDefaultDateTime);
42 virtual bool GetDateRange(wxDateTime *lowerdate, wxDateTime *upperdate) const;
43
44 virtual bool EnableMonthChange(bool enable = true);
45
46 virtual void Mark(size_t day, bool mark);
47 virtual void SetHoliday(size_t day);
48
49 virtual wxCalendarHitTestResult HitTest(const wxPoint& pos,
50 wxDateTime *date = NULL,
51 wxDateTime::WeekDay *wd = NULL);
52
53 virtual void SetWindowStyleFlag(long style);
54
55 protected:
56 virtual wxSize DoGetBestSize() const;
57
58 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
59
60 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
61
62 void MSWOnClick(wxMouseEvent& event);
63 void MSWOnDoubleClick(wxMouseEvent& event);
64
65 private:
66 void Init();
67
68 // bring the control in sync with m_marks
69 void UpdateMarks();
70
71 // set first day of week in the control to correspond to our
72 // wxCAL_MONDAY_FIRST flag
73 void UpdateFirstDayOfWeek();
74
75 // reset holiday information
76 virtual void ResetHolidayAttrs() { m_holidays = 0; }
77
78 // redisplay holidays
79 virtual void RefreshHolidays() { UpdateMarks(); }
80
81
82 // current date, we need to store it instead of simply retrieving it from
83 // the control as needed in order to be able to generate the correct events
84 // from MSWOnNotify()
85 wxDateTime m_date;
86
87 // bit field containing the state (marked or not) of all days in the month
88 wxUint32 m_marks;
89
90 // the same but indicating whether a day is a holiday or not
91 wxUint32 m_holidays;
92
93
94 DECLARE_DYNAMIC_CLASS(wxCalendarCtrl)
95 wxDECLARE_NO_COPY_CLASS(wxCalendarCtrl);
96 };
97
98 #endif // _WX_MSW_CALCTRL_H_