/** * @file XTPDatePickerItemMonth.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ #if !defined(_XTPDATEPICKERITEMMONTH_H__) # define _XTPDATEPICKERITEMMONTH_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** Maximum amount of weeks shown in one month area.*/ const UINT XTP_MAX_WEEKS = (UINT)6; /** Number of days in the week.*/ const UINT XTP_WEEK_DAYS = (UINT)7; class CXTPDatePickerControl; class CXTPDatePickerItemDay; /** * @brief * Class CXTPDatePickerItemMonth represents one month inside the * date picker month grid. * * @details Call the constructor to create the object and provide a pointer * to the DatePicker control. The date value corresponds to the first * day of the month and the grid coordinates. It is not necessary to * add day items to the month item after creation. The month item * constructor calls the day item constructor and fills the day items. * * @see CXTPDatePickerItemDay */ class _XTP_EXT_CLASS CXTPDatePickerItemMonth : public CXTPCmdTarget { friend class CXTPDatePickerControl; friend class CXTPDatePickerPaintManager; public: /** * @brief * Default CXTPDatePickerItemMonth object constructor. * * @param pControl A CXTPDatePickerControl pointer to the parent DatePicker * control. * @param dtMonth A COleDateTime object date of the first day of the month. * @param nRow An int that contains the vertical coordinate of the month * in the control's months grid. * @param nCol An int that contains the horizontal coordinate of the month * in the control's months grid. * * @details Handles initial initialization, populates the month item with the * corresponding day items. * * @see PopulateDays() * @see CXTPDatePickerItemDay */ CXTPDatePickerItemMonth(CXTPDatePickerControl* pControl, COleDateTime dtMonth, int nRow, int nCol); /** * @brief * Default collection destructor. * * @details Handles member items deallocation. * * @see ClearDays() */ virtual ~CXTPDatePickerItemMonth(); /** * @brief * Call this member function to adjust the layout of all sub-items. * * @param rcClient A CRect object that contains the coordinates of the control. * @param bIsAuto A BOOL that determines the method that is used to adjust the * layout: If TRUE - The layout is adjusted depending on the * given control client area rectangle. If FALSE - The layout * calculations depend on the current display settings of all * included items (day items, header items) and the current * device context. * * @details Adjusts the layout of all sub-items in two different ways * depending on the bIsAuto parameter. If bIsAuto = TRUE, then the * layout is adjusted depending on the given control's client area * rectangle. In this case the given count of month items is adjusted * to fit the client area. If bIsAuto = FALSE, then the layout * calculation depends on the current display settings of all * included items (day items, header items) and the current device * context. In this case the size of one month item is calculated * first, this then determines the count of the month items that fit * into the control's client rectangle. Note: The second method is * the default mode. */ void AdjustLayout(CRect rcClient, BOOL bIsAuto = FALSE); /** * @brief * Call this member function to perform drawing logic. * * @param pDC Pointer to a valid device context. * * @details This function performs all drawing logic. * This member function is used to display the month item. It does not * perform any adjustments or size corrections. You must call * AdjustLayout(CRect rcClient, BOOL bIsAuto = FALSE) first to * handle all adjustments. * * @see AdjustLayout(CRect rcClient, BOOL bIsAuto = FALSE) */ virtual void Draw(CDC* pDC); /** * @brief * Call this member function to obtain the month date. * * @details Use this member function to identify the month by date. Use the * date that corresponds to the first day of the month. * * @return A ColeDateTime object that contains the month date for which this * item represents. */ COleDateTime GetMonth() const; /** * @brief * Call this member function to determine if the days before a given * month are displayed. * * @details This option allows changing the behavior of the control in the * following way: If the first day of the month is Wednesday you may * wish to leave places for Monday and Tuesday items empty to display * the last days from previous month item. * * @return Boolean value that determines if the days before this month are * visible. TRUE if the days before this month are visible. Otherwise * FALSE. * * @see SetShowDaysBefore(BOOL bShow) * @see SetShowDaysAfter(BOOL bShow) * @see GetShowDaysAfter() */ BOOL GetShowDaysBefore() const; /** * @brief * Call this member function to determine whether to show the days * after this month. * * @details This option allows changing the behavior of the control in the * following way: If the last day of the month is Wednesday you may * wish to leave places for the remaining day items empty or display * the beginning days from the next month item. * * @return Boolean value determines whether to show the days after this * month. TRUE - If the days after this month are visible. FALSE - If * the days after this month are not visible. * * @see GetShowDaysBefore() */ BOOL GetShowDaysAfter() const; /** * @brief * Call this member function to set whether days before this month * are shown. * * @param bShow Boolean value that determines if the days before this month are * displayed. TRUE if the days before this month are shown. FALSE * if the days before this month are not shown. * * @details This option allows changing the behavior of the control in the * following way: If the first day of the month is Wednesday you may * leave places for Monday and Tuesday items empty or display the * last days from the previous month item. * * @see GetShowDaysBefore() */ void SetShowDaysBefore(BOOL bShow); /** * @brief * Call this member function to set whether days after this month are * shown. * * @param bShow Boolean value that determines if the days after this month are * displayed. TRUE if the days after this month are visible. FALSE * if the days after this month are not visible. * * @details This option allows changing the behavior of the control in the * following way: If the last day of month is Wednesday you may wish * to leave places for remaining day items empty or display the * beginning days from next month item. * * @see GetShowDaysAfter() */ void SetShowDaysAfter(BOOL bShow); /** * @brief * Call this member function to determine if the left scroll * triangle is visible. * * @details This option allows using scrolling facilities to find and work * with month items that currently are not shown in the control. * ScrollV to desired month item using the scroll triangle * icon. * * @return Boolean value determines if the left scroll triangle is visible. * TRUE - If the left scroll triangle is visible. * FALSE - If the left scroll triangle is not visible. * * @see GetShowRightScroll * @see SetShowScrolling */ BOOL GetShowLeftScroll() const; /** * @brief * Call this member function to determine if the right scroll * triangle is visible. * * @details This option allows scrolling facilities to find and work with * month items that currently are not shown in the control. ScrollV to * desired month item using the scroll triangle icon. * * @return Boolean value that determines if the right scroll triangle is * visible. * TRUE - If the right scroll triangle is visible. * FALSE - If the right scroll triangle is not visible. * * @see GetShowLeftScroll * @see SetShowScrolling */ BOOL GetShowRightScroll() const; /** * @brief * Call this member function to add the left and the right scrolling * triangles. * * @param bLeftScroll Boolean value determines if the left scroll triangle is * visible. TRUE Left scrolling triangle is visible. Right * scrolling triangle is visible. FALSE Left scrolling * triangle is not visible. Right scrolling triangle is not * visible. * @param bRightScroll Boolean value determines if the right scroll triangle is * visible. * * @details This option allows scrolling facilities to find and work with * month items that currently aren't shown in the control. ScrollV to * the desired month item using the scroll triangle icon. In some * cases scrolling is not needed, and you can hide one or both * scrolling triangles. * * @see GetShowLeftScroll * @see GetShowRightScroll */ void SetShowScrolling(BOOL bLeftScroll, BOOL bRightScroll); /** * @brief * Call this member function to obtain the day item by its index in * the day collection of the month. * * @param nIndex An int that contains the zero\-based index value. * * @return If the index value is less than 0 and greater then the value * returned by GetDayCount() the function returns NULL. * * Example: *
* // Enumerate the month array.
* CPoint point (100, 100);
* int nDayCount = GetDayCount();
* for (int nDay = 0; nDay \< nDayCount; nDay++)
* {
* CXTPDatePickerItemDay* pDay = GetDay(nDay);
* if (pDay && pDay-\>GetRect().PtInRect(point) && pDay-\>IsVisible())
* return pDay;
* }
*
*
* @return A pointer to a CXTPDatePickerItemDay object or NULL if the index
* is invalid.
*
* @see GetDayCount()
*/
CXTPDatePickerItemDay* GetDay(int nIndex) const;
/**
* @brief
* Call this member function to obtain the number of day items in the
* month collection.
*
* @return An int that contains the number of items stored in the collection.
*
* @see GetDay(int nIndex)
*/
int GetDayCount() const;
/**
* @brief
* Call this function to return the day where the mouse cursor was
* located when the left mouse button was clicked.
*
* @param point A CPoint object that specifies the x\- and y\- coordinates
* of the cursor.
* @param bCheckVisible TRUE when check visibility flag of the day item.
* If this parameter is FALSE, the method would return pointer
* to the corresponding day item even if this day is hidden
* (for example days from previous month).
* It is TRUE by default.
*
* @details This member function is heavily used by all event handlers to
* determine the item that was disturbed by the mouse pointer. If
* item was found, then the function returns a pointer to item,
* otherwise NULL is returned.
*
* @return Returns a pointer to the affected day item. Returns NULL if the
* left mouse button was clicked outside any day area.
*/
CXTPDatePickerItemDay* HitTest(CPoint point, BOOL bCheckVisible = TRUE) const;
protected:
/**
* @brief
* Call this member function to cleanup the days array.
*
* @details Handles cleanup of days collection, including each day item.
*/
void ClearDays();
/**
* @brief
* Call this member function to populate the day objects.
*
* @details Creates days objects based on the current settings.
*/
void PopulateDays();
/**
* @brief
* This member function is called to process left button down mouse
* messages.
*
* @param nFlags A UINT that is used to indicate whether various virtual
* keys are down.
* @param point A CPoint object that specifies the x\- and y\- coordinates
* of the cursor.
*
* @details This function is called from control event handlers.
*/
void OnLButtonDown(UINT nFlags, CPoint point);
/**
* @brief
* This member function is called to process left button up mouse
* messages.
*
* @param nFlags A UINT that indicates whether various virtual keys are
* down.
* @param point A CPoint object that specifies the x\- and y\- coordinates
* of the cursor.
*
* @details This function is called from control event handlers.
*/
void OnLButtonUp(UINT nFlags, CPoint point);
/**
* @brief
* This function is called to process mouse move messages.
*
* @param nFlags A UINT that indicates whether various virtual keys are
* down.
* @param point A CPoint object that specifies the x\- and y\- coordinates
* of the cursor.
*
* @details This function is called from control event handlers.
*/
void OnMouseMove(UINT nFlags, CPoint point);
/**
* @brief
* This member function is called to process changing cursor message.
*
* @param point A CPoint object that specifies the x\- and y\- coordinates
* of the cursor.
*
* @details This function is called from control event handlers.
* @return Nonzero to halt further processing, or 0 to continue.
*/
BOOL OnSetCursor(CPoint point);
/**
* @brief
* Call this member function to calculate sizes and counts by font
* metrics.
*
* @param rcClient A CRect object that contains the coordinates of the control and
* the location where the control is drawn.
*
* @details This member function implements one of the branches of
* AdjustLayout(). If FALSE - The calculated layout depends on
* correct display settings of all included items (day items, header
* items) and current device context. In this case, the size of one
* month item is calculated first, then it determines the count of
* month items that fit into the control client rectangle.
*
* @see AdjustLayout()
*/
void ByFontAdjustLayout(CRect rcClient);
/**
* @brief
* This member function is used to calculate the size of the header,
* days of week, week numbers, and the scrolling triangles bounding
* rectangles.
*
* @param rcClient A CRect object that contains the coordinates that specifies
* where the control is drawn.
*
* @details This member function implements one of the branches of
* AdjustLayout(). If TRUE, then the layout is adjusted depending on
* the given control client area rectangle. In this case, the given
* count of month items is adjusted to fit the client area.
*
* @see AdjustLayout()
*/
void AutoAdjustLayout(CRect rcClient);
// Attributes
public:
/**
* This member variable is a CXTPDatePickerControl object pointer to
* the parent control
*/
CXTPDatePickerControl* m_pControl;
/**
* This member variable is an int that is used for the row month
* index.
*/
int m_nRow;
/**
* This member variable is an int that is used for the column month
* index.
*/
int m_nColumn;
/**
* This member variable is COleDateTime object that is used as the
* date with the month definition for the month item.
*/
COleDateTime m_dtMonth;
/**
* This member variable is a BOOL that is used to determine if the
* "days before this month" are visible. The valid values are TRUE if
* the "days before this month" are visible, otherwise false.
*/
BOOL m_bShowDaysBefore;
/**
* This member variable is a BOOL that is used to indicate if the
* "days after this month" are visible. The valid values are TRUE if
* the "days after this month" are visible, otherwise FALSE.
*/
BOOL m_bShowDaysAfter;
/**
* This member variable is a BOOL that is used to determine if the
* "left scroll triangle" is visible. The valid values are TRUE if
* the "left scroll triangle" is visible, otherwise false.
*/
BOOL m_bShowLeftScroll;
/**
* This member variable is a BOOL that is used to determine if the
* "right scroll triangle" is visible. The valid values are TRUE if
* the "right scroll triangle" is visible, otherwise false.
*/
BOOL m_bShowRightScroll;
/**
* This member variable is a CRect object that contains the
* coordinates of the total month's area.
*/
CRect m_rcMonth;
/**
* This member variable is a CRect object that contains the
* coordinates of the month's header area.
*/
CRect m_rcHeader;
/**
* This member variable is a CRect object that contains the
* coordinates of the month's "week days" area.
*/
CRect m_rcDaysOfWeek;
/**
* This member variable is a CRect object that contains the
* coordinates of the month's week numbers area.
*/
CRect m_rcWeekNumbers;
/**
* This member variable is a CRect object that contains the
* coordinates of the month's "all days" area.
*/
CRect m_rcDaysArea;
/**
* This member variable is a CRect object that contains the
* coordinates of the left scroll triangle area.
*/
CRect m_rcLeftScroll;
/**
* This member variable is a CRect object that contains the
* coordinates of the right scroll triangle area.
*/
CRect m_rcRightScroll;
protected:
/**
* This member variable is a CArray\