11#ifndef __SCALENDAR__H__
12#define __SCALENDAR__H__
33 static BOOL
IsLeapYear(WORD wYear, BOOL &bLeapYear);
45 static BOOL
GetDaysNumInYear(WORD wYear, WORD wMonth, WORD wDay, WORD &wDays);
57 static BOOL
GetDateFromDays(WORD wYear, WORD wDays, WORD &wMonth, WORD &wDay);
68 static short GetDayOfWeek(WORD wYear, WORD wMonth, WORD wDay);
89 static BOOL
DateCheck(WORD wYear, WORD wMonth, WORD wDay);
119#define HIT_YEAR_1 -13
120#define HIT_YEAR_2 -14
121#define HIT_YEAR_3 -15
125#define SHOW_MONTH -101
126#define SHOW_YEAR -102
127#define SHOW_YEAR_DECADE -103
128#define SHOW_YEAR_CENTURY -104
136 DEF_SOBJECT(
SWindow, L
"calendar")
145 SCalendar(WORD iYear, WORD iMonth, WORD iDay);
181 void GetDate(WORD &iYear, WORD &iMonth, WORD &iDay);
192 BOOL
SetDate(WORD iYear, WORD iMonth, WORD iDay,
int nBtnType =
HIT_NULL,
bool bNotify =
false);
246 BOOL
OnMouseWheel(UINT nFlags,
short zDelta, CPoint pt);
260 ATTR_I18NSTRT(L
"textSunday",
m_strWeek[0], TRUE)
261 ATTR_I18NSTRT(L
"textMonday",
m_strWeek[1], TRUE)
262 ATTR_I18NSTRT(L
"textTuesday",
m_strWeek[2], TRUE)
263 ATTR_I18NSTRT(L
"textWednesday",
m_strWeek[3], TRUE)
264 ATTR_I18NSTRT(L
"textThursday",
m_strWeek[4], TRUE)
265 ATTR_I18NSTRT(L
"textFriday",
m_strWeek[5], TRUE)
266 ATTR_I18NSTRT(L
"textSaturday",
m_strWeek[6], TRUE)
Smart pointer class for managing COM-style reference-counted objects.
static BOOL DateCheck(WORD wYear, WORD wMonth, WORD wDay)
Validates the year, month, and day.
static WORD GetDaysOfMonth(WORD wYear, WORD wMonth)
Returns the number of days in a specified month.
static BOOL GetDaysNumInYear(WORD wYear, WORD wMonth, WORD wDay, WORD &wDays)
Calculates the day number within the year (starting from 0, where 0 is January 1st).
static short GetDayOfWeek(WORD wYear, WORD wMonth, WORD wDay)
Returns the day of the week.
static SStringT FormatYear(WORD iYear)
Formats the year display.
static BOOL GetDateFromDays(WORD wYear, WORD wDays, WORD &wMonth, WORD &wDay)
Calculates the month and day from the day number within the year.
static SStringT FormatDay(WORD iDay)
Formats the day display.
static SStringT FormatMonth(WORD iMonth)
Formats the month display.
static BOOL IsLeapYear(WORD wYear, BOOL &bLeapYear)
Determines if a year is a leap year.
COLORREF m_crSelDayBack
Background color of the selected day.
void DrawToday(IRenderTarget *pRT, CRect &rcDay)
Draws the "Today" button.
void SetShowType(int showType)
Sets the calendar display type.
SAutoRefPtr< ISkinObj > m_pSkinNext
Skin for the next button.
void SetYearDecadeCentury()
Sets the year, decade, and century views.
int m_showTypeLbdown
Calendar display state when mouse button is down.
int m_nSelItem
Selected item.
SLayoutSize m_nFooterHeight
Height of the "Today" button.
SAutoRefPtr< ISkinObj > m_pSkinDay
Skin for the day.
void SetNextYearCentury()
Sets the next century.
SYSTEMTIME m_Today
Current date.
void SetNextYearDecade()
Sets the next decade.
void SetYearMonth(int iYear, int iMonth)
Sets the year and month.
int m_nHoverItem
Hover item.
SAutoRefPtr< ISkinObj > m_pSkinPrev
Skin for the previous button.
WORD m_iYear
Current year.
void Init()
Initializes the control.
CRect m_rcToday
"Today" button area.
int HitTest(const CPoint &pt)
Tests the mouse click position.
void SetNextYear()
Sets the next year.
void OnPaint(IRenderTarget *pRT)
Paints the control.
void DrawWeek(IRenderTarget *pRT, const CRect &rect)
Draws the week days.
void SetLastYear()
Sets the previous year.
void DrawYearMonth(IRenderTarget *pRT, const CRect &rect)
Draws the calendar header (year and month).
virtual HRESULT OnLanguageChanged()
Called when the language changes.
COLORREF m_crHoverText
Color of the hover text.
void OnPaintMonth(IRenderTarget *pRT)
Paints the month view.
BOOL SetDate(WORD iYear, WORD iMonth, WORD iDay, int nBtnType=-1, bool bNotify=false)
Sets the date.
void SetLastYearCentury()
Sets the previous century.
void OnPaintYearDecadeCentury(IRenderTarget *pRT)
Paints the year, decade, and century views.
void GetDate(WORD &iYear, WORD &iMonth, WORD &iDay)
Gets the current date.
int m_showType
Calendar display state.
void OnMouseMove(UINT nFlags, CPoint pt)
Handles mouse move event.
STrText m_strWeek[7]
Header text.
void SetLastMonth()
Sets the previous month.
SLayoutSize m_nYearMonthHeight
Height of the year and month.
void OnMouseLeave()
Handles mouse leave event.
void OnLButtonUp(UINT nFlags, CPoint point)
Handles left mouse button up event.
void OnLButtonDown(UINT nFlags, CPoint point)
Handles left mouse button down event.
void SetLastYearDecade()
Sets the previous decade.
wDayInfo m_arrDays[42]
Date information array.
COLORREF m_crSelText
Selected text color.
void SetNextMonth()
Sets the next month.
COLORREF m_crOtherDayText
Color of other days' text.
wMonthOrYearInfo m_arrMonthOrYear[12]
Month or year information array.
WORD GetMonth()
Gets the current month.
SCalendar(WORD iYear, WORD iMonth, WORD iDay)
Constructor.
void GetItemRect(int nItem, CRect &rcItem)
Gets the item drawing area.
WORD m_iMonth
Current month.
SLayoutSize m_nWeekHeight
Height of the week.
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
Handles mouse wheel event.
WORD GetDay()
Gets the current day.
SAutoRefPtr< ISkinObj > m_pSkinWeek
Skin for the week.
WORD GetYear()
Gets the current year.
void DrawYearDecadeCentury(IRenderTarget *pRT, const CRect &rect, int nItem)
Draws the year, decade, and century items.
void DrawDay(IRenderTarget *pRT, CRect &rcDay, int nItem)
Draws the day.
int OnCreate(LPVOID lp)
Called when the control is created.
Class for handling text with translation support.
Interface for rendering target objects.
Date information structure.
Month or year information structure.