SavvyUI C++ UI Library
Loading...
Searching...
No Matches
Calendar.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4
5class DayInfo
6{
7public:
8
9 DayInfo(int dayNo, Bounds rect)
10 {
11 _dayNumber = dayNo;
12 _rect.left = rect.left;
13 _rect.top = rect.top;
14 _rect.right = rect.right;
15 _rect.bottom = rect.bottom;
16 }
19};
20
28class Calendar : public Component
29{
33 BOOL _isPopup;
34
38 wstring _orientation;
39
43 Bounds _monthRects[12];
44
48 vector<DayInfo> _dayRects;
49
53 Bounds _yearRect;
54
58 Bounds _incYearRect;
59
63 Bounds _decYearRect;
64
68 Bounds _todayRect;
69
73 Bounds _yearNumberRect;
74
78 BOOL _isEditingYear;
79
83 int _curYear, _curMonth;
84
88 int _selectedYear, _selectedMonth, _selectedDay;
89
93 void dateChanged();
94
98 void syncCurrentFromSelected();
99
100protected:
101
111 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
112
117
118public:
119
124
128 virtual ~Calendar();
129
135 void setAsPopup(BOOL isPopup);
136
140 BOOL isPopup();
141
147 void setOrientation(const wstring& orientation);
148
154 void setSelectedDate(const wstring& dateYYYYMMDD);
155
163 void setSelectedDate(int year, int month, int day);
164
171
180 wstring getSelectedDate(int& year, int& month, int& day);
181
182public: // Overridables
183
190
195
200
205
212 void onKeyBackSpace(BOOL shiftPressed, BOOL ctrlPressed);
213
221 void onKeyTyped(wchar_t ch, BOOL shiftPressed, BOOL ctrlPressed);
222
233 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
234
244 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
245
252};
HWND WinHandle
Definition Common.h:16
Definition Common.h:20
long left
Definition Common.h:111
long top
Definition Common.h:111
long right
Definition Common.h:111
long bottom
Definition Common.h:111
wstring getSelectedDate(int &year, int &month, int &day)
Gets the selected date components.
wstring getSelectedDate()
Gets the selected date as a string formatted as YYYYMMDD.
BOOL isPopup()
Return TRUE if this component is displayed as a popup (e.g. DateTimePicker).
void onFocusGained()
Called when the calendar gains focus.
virtual ~Calendar()
Destroys the Calendar component.
void onKeyTyped(wchar_t ch, BOOL shiftPressed, BOOL ctrlPressed)
Handles typed character input.
Calendar()
Constructs a Calendar component.
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta)
Handles mouse wheel events.
void onWindowResized()
Called when the window has been resized.
void addSelectionChangedListener(SelectionChangeListener *l)
Adds a listener for selection change events.
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Handles mouse press events.
void onFocusLost()
Called when the calendar loses focus.
void setOrientation(const wstring &orientation)
Sets the orientation of the calendar.
void onKeyBackSpace(BOOL shiftPressed, BOOL ctrlPressed)
Handles Backspace key input.
void setSelectedDate(int year, int month, int day)
Sets the selected date using year, month, and day integers.
void setSelectedDate(const wstring &dateYYYYMMDD)
Sets the selected date using a string formatted as YYYYMMDD.
void onPaint(Graphics *g)
Paints the calendar to the provided device context.
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Retrieves options needed to create the calendar window.
void windowCreated()
Called after the window has been successfully created.
void setAsPopup(BOOL isPopup)
Sets whether the calendar is used in a popup context.
Component()
Constructs a new Component instance.
DayInfo(int dayNo, Bounds rect)
Definition Calendar.h:9
int _dayNumber
Definition Calendar.h:17
Bounds _rect
Definition Calendar.h:18
Definition Graphics.h:161
Definition EventListeners.h:31