/** * @file XTPDatePickerDaysCollection.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(_XTPDATEPICKERDAYSCOLLECTION_H__) # define _XTPDATEPICKERDAYSCOLLECTION_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 // XTPDatePickerDaysCollection.h : header file /// # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPDatePickerControl; class CXTPDatePickerItemDay; /** * @details Class CXTPDatePickerDaysCollection provides facilities to build various * collection of days, for using in groups. For example, the selected days * collection. To create an object of this class, simply call the constructor * and provide a pointer to the DatePicker controller. */ class _XTP_EXT_CLASS CXTPDatePickerDaysCollection : public CXTPCmdTarget { friend class CXTPDatePickerControl; public: /** * @brief * Selected block structure. * Each member is represented by an integer part of a corresponding * COleDateTime value. * * Example: * You can create COleDateTime in a following manner: *
	 * COleDateTime dtValue;
	 * dtValue = (DATE)(double)block.nDateBegin;
	 * 
*/ struct SELECTED_BLOCK { long nDateBegin; /**< Begin date.*/ long nDateEnd; /**< End date.*/ }; public: /** * @brief * Default collection constructor. * * @param pControl Pointer to the DatePicker control object. * * @details Handles initial initialization.h */ CXTPDatePickerDaysCollection(CXTPDatePickerControl* pControl); /** * @brief * Default collection destructor. * * @details Handles member item deallocation. * * @see Clear() */ virtual ~CXTPDatePickerDaysCollection(); /** * @brief * Call this member function to clear the day collection. */ void Clear(); /** * @brief * Call this member function to add a day to the collection. * * @param dtDay Date of a day, the key of the new element. * * @details The primary means to insert an element into a map. First, search * for the key. If the key is found, then the corresponding value is * changed. Otherwise, a new key-value pair is created an added to * the map. * * @see Remove */ void Add(const COleDateTime& dtDay); /** * @brief * Call this member function to select a day * * @param dtDay Date of a day, the key of the new element. * * @see Add * @see SelectRange */ void Select(const COleDateTime& dtDay); /** * @brief * Call this member function to select days. * * @param dtDayBegin First Date of a day. * @param dtDayEnd Last Date of a day. * * @see Select */ void SelectRange(const COleDateTime& dtDayBegin, const COleDateTime& dtDayEnd); /** * @brief * Call this member function to remove a day from the collection. * * @param dtDay A COleDateTime reference that contains the date of a day. The * key for the element to be removed. * @details Searches the map for the entry corresponding to the supplied key. * If the key is found, then the entry is removed. * * @see Add */ void Remove(const COleDateTime& dtDay); /** * @brief * Call this member function to determine if a day is contained in * the collection. * * @param dtDay Date of a day. The key that identifies the element to * search for. * * @details This function uses a hash algorithm to quickly find the map * element using a key that exactly matches the given key. * * @return Nonzero if the element was found. Otherwise 0. */ BOOL Contains(const COleDateTime& dtDay) const; /** * @brief * Call this member function to count the number of days in the * collection. * * @return An integer value representing the number of day items in * the collection. */ int GetSelectedDaysCount() const; /** * @brief * Call this member function to count the number of selected blocks. * * @return An integer value representing the number of selected blocks. */ int GetSelectedBlocksCount() const; /** * @brief * Call this member function to get the selected block by its index. * * @param nIndex Selected block to retrieve. * * @return An enumerated value specifying the selected block. */ SELECTED_BLOCK GetSelectedBlock(int nIndex) const; /** * @brief * Call this member function to determine the minimum and the maximum * day in the collection. * * @param refMinRange A COleDateTime reference to the minimum date storage * variable. * @param refMaxRange A COleDateTime reference to maximum date storage * variable. * * @return A boolean value. TRUE if successful. Otherwise FALSE. */ BOOL GetMinMaxRange(COleDateTime& refMinRange, COleDateTime& refMaxRange) const; private: void _InsertBlock(int nIndexInsert, long nDateBegin, long nDateEnd); void AddBlock(long nBegin, long nEnd); // Attributes protected: CXTPDatePickerControl* m_pControl; /**< This member variable is a pointer to the parent control.*/ CArray m_arrSelectedBlocks; /**< Contains an array of the selected dates blocks.*/ # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPDatePickerDaysCollection); DECLARE_ENUM_VARIANT(CXTPDatePickerDaysCollection); int OleGetItemCount(); LPDISPATCH OleGetItem(long nIndex); BOOL OleGetAllowNoncontinuousSelection(); void OleSetAllowNoncontinuousSelection(BOOL bSet); # endif }; AFX_INLINE int CXTPDatePickerDaysCollection::GetSelectedBlocksCount() const { return (int)m_arrSelectedBlocks.GetSize(); } AFX_INLINE CXTPDatePickerDaysCollection::SELECTED_BLOCK CXTPDatePickerDaysCollection::GetSelectedBlock(int nIndex) const { _ASSERTE(nIndex >= 0 && nIndex < (int)m_arrSelectedBlocks.GetSize()); return m_arrSelectedBlocks[nIndex]; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(_XTPDATEPICKERDAYSCOLLECTION_H__)