/** * @file XTPCalendarViewDay.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(_XTPCALENDARVIEWDAY_H__) # define _XTPCALENDARVIEWDAY_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" # pragma warning(disable : 4786) class CXTPCalendarView; class CXTPCalendarViewDay; class CXTPCalendarViewGroup; class CXTPCalendarViewEvent; class CXTPCalendarEvent; struct XTP_CALENDAR_HITTESTINFO; /** * * Regular schema: * - CalendarView consists of CalendarView(s)Day * - CalendarViewDay consists of CalendarView(s)Resource * - CalendarViewGroup contains CalendarView(s)Event * * ViewGroup draws a single resource depending on the type of parent * day view. * */ class _XTP_EXT_CLASS CXTPCalendarViewGroup : public CXTPCalendarWMHandler { friend class CXTPCalendarView; friend class CXTPCalendarViewDay; friend class CXTPCalendarViewEvent; friend class CXTPCalendarTheme; DECLARE_DYNAMIC(CXTPCalendarViewGroup) typedef CXTPCalendarWMHandler TBase; /**< Base class shortcut*/ public: /** * @brief * Default object constructor. Constructs a CXTPCalendarViewGroup object. * @param pViewDay An associated view day object pointer. * @see ~CXTPCalendarViewGroup() */ CXTPCalendarViewGroup(CXTPCalendarViewDay* pViewDay); /** * @brief * Default class destructor. * * @details * Handles member item deallocation. */ virtual ~CXTPCalendarViewGroup(); /** * @brief * Obtain a pointer to a collection of Calendar Resources. * * @details * Use this method to retrieve a pointer to the Calendar Resources * collection of this Group View. * * @return CXTPCalendarResources pointer. * * @see CXTPCalendarResources overview * @see SetResources * @see AddResource */ virtual CXTPCalendarResources* GetResources() const; /** * @brief * Returns data provider for this view group. * * @return A pointer to the data provider object if it was previously set; * otherwise, returns NULL. * * @see CXTPCalendarData overview */ virtual CXTPCalendarData* GetDataProvider() const; /** * @brief * Adds a new Resource object into the collection of resources for * this Group View. * * @param pResource Pointer to the added CXTPCalendarResource object. * @param bWithAddRef Set this value to TRUE to increment the reference * count of the inserted object, * FALSE to insert object without incrementing * reference count. * * @see CXTPCalendarResources::Add */ virtual void AddResource(CXTPCalendarResource* pResource, BOOL bWithAddRef); /** * @brief * Assigns a new Resources collection to this Group View. * * @param pResources Pointer to the new Resources collection to be copied * into internal collections of this Group View. * * @see GetResources * @see AddResource */ virtual void SetResources(CXTPCalendarResources* pResources); /** * @brief * Returns default Schedule ID - the first existing one. * * @return The first existing Schedule ID or * XTP_CALENDAR_UNKNOWN_SCHEDULE_ID if not found. */ virtual UINT GetScheduleID() const; /** * @brief * This member function is used to populate the view with data for * all items contained in the view. * * @param dtDayDate A COleDateTime object that contains the day's date. * * @details * This is a pure virtual function. This function must be defined * in the derived class. */ virtual void Populate(COleDateTime dtDayDate); /** * @brief * This member function is used to adjust the view's layout depending * on the provided rectangle and then calls AdjustLayout() for all * of the sub-items. * * @param pDC Pointer to a valid device context. * @param rcGroup A CRect object that contains the rectangle coordinates * that are used to draw the view. * * @details * Call Populate(COleDateTime dtDayDate) prior to calling AdjustLayout(). * AdjustLayout2 is called by calendar control instead of AdjustLayout * when theme is set. */ virtual void AdjustLayout(CDC* pDC, const CRect& rcGroup); /** * @brief * This member function is used to adjust the view's layout depending * on the provided rectangle and then calls AdjustLayout() for all * of the sub-items. * * @param pDC Pointer to a valid device context. * @param rcGroup A CRect object that contains the rectangle coordinates * that are used to draw the view. * * @details * Call Populate(COleDateTime dtDayDate) prior to calling AdjustLayout(). * AdjustLayout2 is called by calendar control instead of AdjustLayout * when theme is set. */ virtual void AdjustLayout2(CDC* pDC, const CRect& rcGroup); /** * @brief * This member function is used to draw the view contents using * the specified device context. * * @param pDC A pointer to a valid device context. * * @details * Call AdjustLayout() before calling Draw(). * * @see AdjustLayout(CRect rcGroup) */ virtual void Draw(CDC* pDC); /** * @brief * This member function is used to determine which view item, * if any, is at the specified position index, and returns additional * info in an XTP_CALENDAR_HITTESTINFO struct. * * @param pt A CPoint object that contains the coordinates of * the point to test. * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO struct that * contains information about the point to test. * * @details * This is a pure virtual function. This function must be defined * in the derived class. * * @return A BOOL. TRUE if the item is found. FALSE otherwise. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTest(CPoint pt, XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function is used to determine which view item, * if any, is at the specified position index, and returns additional * info in the XTP_CALENDAR_HITTESTINFO template object. * * @param pt A CPoint that contains the coordinates of the point test. * @param pHitTest A pointer to a XTP_CALENDAR_HITTESTINFO structure. * * @details * Implements standard functionality for the HitTestEx method. * * @return A BOOL. TRUE if the item is found. FALSE otherwise. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTestEx(CPoint pt, XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function is used to fill the pHitTest structure * members with the default values for the current day view object. * * @param pHitTest A Pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * This is a pure virtual function. This function must be defined * in the derived class. */ virtual void FillHitTestEx(XTP_CALENDAR_HITTESTINFO* pHitTest) const = 0; /** * @brief * Call this member function to obtain the group's rectangle area. * * @return A CRect that contains the rectangle coordinates of the group view * in client coordinates of the parent's CXTPDatePickerControl object. * * @see GetHeaderRect */ virtual CRect GetRect() const { return m_Layout.m_rcGroup; } /** * @brief * Call this member function to obtain the group's header rectangle * area. * * @return A CRect that contains the rectangle coordinates of the group view * header part in client coordinates of the parent's * CXTPDatePickerControl object. * * @see GetRect */ virtual CRect GetHeaderRect() const { return m_Layout.m_rcGroupHeader; } /** * @brief * Call this member function to obtain the bounding rectangle of * the tooltip space (currently this is only "click to add new appointment"). * Tooltip rectangle is calculated basing on the current mouse position * * @param ptHit A CPoint of mouse coordinates. * @param hitInfo An XTP_CALENDAR_HITTESTINFO object. * * @return A CRect object with relative coordinates of the tooltip. * * @details * This member function always returns an empty rectangle. * Actual tooltip rectangle is calculated by ViewGroups of specific * views (currently DayView and MonthView are supported). */ virtual CRect GetTooltipRect(const CPoint& ptHit, const XTP_CALENDAR_HITTESTINFO& hitInfo) const; /** * @brief * Call this member function to obtain the number of event views * in the day view collection. * * @details * This is a pure virtual function. This function must be defined * in the derived class. * * @return An int that contains the number of event views. */ int GetViewEventsCount() const; /** * @brief * Call this member function to obtain a pointer to a * CXTPCalendarViewEvent object associated with the event's index. * * @param nIndex An int that contains the event view index in the day * view collection. * * @details * Index number starts with 0 and cannot be negative. * This is a pure virtual function. This function must be defined * in the derived class. * * @return A pointer to a CXTPCalendarViewEvent object. * * @see GetViewEventsCount() */ CXTPCalendarViewEvent* GetViewEvent_(int nIndex) const; /** * @brief * Call this member function to obtain a pointer to the containing * CXTPCalendarViewDay object. * * @return A pointer to the CXTPCalendarViewDay object. */ CXTPCalendarViewDay* GetViewDay_() const; /** * @brief * This member function is used to obtain the index of the "this" * pointer Group View in the Calendar Day View. * * @return An int that contains the index of the "this" day in the Calendar * Day View. */ virtual int GetGroupIndex() const; /** * @brief * This member function is used to obtain a group's view caption. * * @return A CString object that contains the group's view caption. */ virtual CString GetCaption() const; /** * @brief * This member function is used to obtain the number of * event views elements in this Group View. * * @details * Call this method to retrieve the number of elements in the array * of event views inside this Group View. * Because indexes are zero-based, the size is 1 greater than * the largest index. * * @return A count of event views elements. * * @see GetChildHandlerAt */ virtual int GetChildHandlersCount() const; /** * @brief * Call this method to get an event view object at the * specified numeric index. * * @param nIndex An integer index that is greater than or equal to 0 * and less than the value returned by GetChildHandlersCount. * * @details * Returns the array element at the specified index. * * @return The pointer to the descendant of CXTPCalendarWMHandler element * currently at this index. * * @see GetChildHandlersCount */ virtual CXTPCalendarWMHandler* GetChildHandlerAt(int nIndex) const; /** * @brief * Call this member function to obtain a pointer to a CXTPCalendarViewEvent * object that is identified by the corresponding event object. * * @param pEvent Pointer to a CXTPCalendarEvent object. * * @return A pointer to a CXTPCalendarViewEvent object. * * @see CXTPCalendarEvent * @see CXTPCalendarViewEvent */ virtual CXTPCalendarViewEvent* GetViewEventByEvent_(CXTPCalendarEvent* pEvent) const; /** * @brief * Call this member function to obtain an event view object identified * by its event place number. * * @param nEventPlace An int that contains the ViewEvent place identifier. * * @return A pointer to a CXTPCalendarViewEvent object. * * @see CXTPCalendarEvent * @see CXTPCalendarViewEvent */ virtual CXTPCalendarViewEvent* GetViewEventByPlace_(int nEventPlace) const; /** * @brief * Call this member function to obtain a pointer to the calendar control * object. * * @return A pointer to a CXTPCalendarControl object. */ virtual CXTPCalendarControl* GetCalendarControl() const; /** * @brief * This member function is used to exchange event view positions. * * @param pViewEvent A pointer to a CXTPCalendarViewEvent object. * @param nNewPlace An int that contains the new event view position. * * @details * Each event view has a unique position number for the day. In the * simple case, this is the row number used to draw the event view. * This function is used to avoid duplicating position numbers. * * @see CXTPCalendarViewEvent::ChangeEventPlace * @see CXTPCalendarViewEvent::GetEventPlaceNumber * @see CXTPCalendarViewEvent::AddMultiDayEvent_Slave * @see CXTPCalendarViewEvent::AdjustLayout */ virtual void ExchangeEventPlace(CXTPCalendarViewEvent* pViewEvent, int nNewPlace); protected: /** * @brief * This member function is used to create a timer event. * * @param uTimeOut_ms A UINT that contains the duration of the timer in * milliseconds. * * @return A UINT that is the identifier of the timer. */ virtual UINT SetTimer(UINT uTimeOut_ms); /** * @brief * This member function is used to destroy a timer event. * * @param uTimerID A UINT that specifies the identifier of the timer. */ virtual void KillTimer(UINT uTimerID); /** * @brief * This member function is used to allow some customization before * show events. * * @param pEvents A pointer to events array to draw. * * @details * Default implementation sends an XTP_NC_CALENDAR_PREPOPULATE notification. * * @see XTP_NC_CALENDAR_PREPOPULATE */ virtual void OnPrePopulate(CXTPCalendarEvents* pEvents); public: virtual void AddViewEvent(CXTPCalendarEvent* pEvent); protected: virtual CXTPCalendarViewEvent* CreateViewEvent(CXTPCalendarEvent* pEvent) = 0; protected: XTP_VIEW_GROUP_LAYOUT& GetLayout_(); protected: XTP_VIEW_GROUP_LAYOUT m_Layout; /**< This group view client coordinates.*/ CXTPCalendarPtrCollectionT m_arEvents; /**< Storage for events views.*/ CXTPCalendarResources* m_pResources; /**< An associated resource object.*/ CXTPCalendarViewDay* m_pViewDay; /**< Parent day view*/ # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPCalendarViewGroup); LPDISPATCH OleGetViewDay(); LPDISPATCH OleGetViewEvents(); LPDISPATCH OleGetMultipleResources(); # endif }; /** * @brief * This class represents the day view portion of the CalendarView. * * @details * It represents a specific view of the CalendarView's associated events * data grouped by one day and provides basic functionality on this * data using user input through the keyboard and the mouse. * * These are the predefined view implementations available * for the Calendar control: * * * * Day and work week day views : Using the CXTPCalendarDayViewDay class. * * Week day view : Using the CXTPCalendarWeekViewDay class. * * Month day view : Using the CXTPCalendarMonthViewDay class. * * * Furthermore, any user-defined day view may also be implemented as * a descendant of the CXTPCalendarViewDay class. * * A typical day view model consists of a collection of ViewEvent's for * the particular day, each of them represents a view of an CXTPCalendarEvent * object. * * @see CXTPCalendarViewDayT * @see CXTPCalendarDayViewDay * @see CXTPCalendarWeekViewDay * @see CXTPCalendarMonthViewDay * @see CXTPCalendarView * @see CXTPCalendarViewEvent */ class _XTP_EXT_CLASS CXTPCalendarViewDay : public CXTPCalendarWMHandler { friend class CXTPCalendarView; friend class CXTPCalendarViewEvent; friend class CXTPCalendarTheme; DECLARE_DYNAMIC(CXTPCalendarViewDay) typedef CXTPCalendarWMHandler TBase; public: /** * @brief * Default object constructor. Construct CXTPCalendarViewDay object. * * @param pView Pointer to CXTPCalendarView object. * * @see ~CXTPCalendarViewDay() */ CXTPCalendarViewDay(const CXTPCalendarView* pView); /** * @brief * Default class destructor. * * @details * Handles member item deallocation. */ virtual ~CXTPCalendarViewDay(); /** * @brief * This member function is used to populate the view with data for * all items contained in the view. * * @param dtDayDate A COleDateTime object that contains the day's date. * * @details * This is a pure virtual function. This function must be defined * in the derived class. */ virtual void Populate(COleDateTime dtDayDate); /** * @brief * This member function is used to adjust the view's layout depending * on the provided rectangle and then calls AdjustLayout() for all * of the sub-items. * * @param pDC A pointer to a valid device context. * @param rcDay A CRect object that contains the rectangle coordinates * that are used to draw the view. * * @details * Call Populate(COleDateTime dtDayDate) prior to calling AdjustLayout(). */ virtual void AdjustLayout(CDC* pDC, const CRect& rcDay); /** * @brief * This member function is used to draw the view contents using * the specified device context. * * @param pDC A pointer to a valid device context. * * @details * Call AdjustLayout() before calling Draw(). * * @see AdjustLayout(CRect rcDay) */ virtual void Draw(CDC* pDC) { UNREFERENCED_PARAMETER(pDC); } /** * @brief * This member function is used to obtain the number of * resource group views elements in the collection. * * @details * Call this method to retrieve the number of elements in the array. * Because indexes are zero-based, the size is 1 greater than * the largest index. * * @return A count of resource group views elements. */ virtual int GetChildHandlersCount() const { return GetViewGroupsCount(); } /** * @brief * Call this method to get a resource group view object at the * specified numeric index. * * @param nIndex An integer index that is greater than or equal to 0 * and less than the value returned by GetChildHandlersCount. * * @details * Returns the array element at the specified index. * * @return The pointer to the CXTPCalendarWMHandler element currently at this * index. */ virtual CXTPCalendarWMHandler* GetChildHandlerAt(int nIndex) const { ASSERT_KINDOF(CXTPCalendarWMHandler, GetViewGroup_(nIndex)); return GetViewGroup_(nIndex); } /** * @brief * This member function is used to determine which view item, * if any, is at the specified position index, and returns additional * info in an XTP_CALENDAR_HITTESTINFO struct. * * @param pt A CPoint object that contains the coordinates of * the point to test. * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO struct that * contains information about the point to test. * * @details * This is a pure virtual function. This function must be defined * in the derived class. * * @return A BOOL. TRUE if the item is found. FALSE otherwise. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTest(CPoint pt, XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function is used to determine which view item, * if any, is at the specified position index, and returns additional * info in the XTP_CALENDAR_HITTESTINFO template object. * * @param pt A CPoint that contains the coordinates of the point test. * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * Implements standard functionality for the HitTestEx method. * * @return A BOOL. TRUE if the item is found. FALSE otherwise. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTestEx(CPoint pt, XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function is used to fill the pHitTest structure * members with the default values for the current day view object. * * @param pHitTest A Pointer to a XTP_CALENDAR_HITTESTINFO structure. * * @details * This is a pure virtual function. This function must be defined * in the derived class. */ virtual void FillHitTestEx(XTP_CALENDAR_HITTESTINFO* pHitTest) const = 0; /** * @brief * Call this member function to obtain a pointer to a * CXTPCalendarView object. * * @details * This is a pure virtual function. This function must be defined * in the derived class. * * @return A pointer to a CXTPCalendarView object. */ virtual CXTPCalendarView* GetView_() const; /** * @brief * Call this member function to obtain a pointer to a * CXTPCalendarControl object. * * @return A pointer to a CXTPCalendarControl object. */ virtual CXTPCalendarControl* GetCalendarControl() const; /** * @brief * Call this member function to obtain a pointer to the associated * Calendar Resources collection object. * * @return * A pointer to the CXTPCalendarResources collection object. * * @see CXTPCalendarResources overview * @see CXTPCalendarResource overview */ virtual CXTPCalendarResources* GetResources() const; /** * @brief * This member function sets the new Resources collection for the view day. * * @param pResources A pointer to the CXTPCalendarResources collection object. * * @details * Call this member function to programmatically set the new * Resources collection for the view day. */ virtual void SetResources(CXTPCalendarResources* pResources); /** * @brief * Call this member function to obtain the number of event views * in the day view collection. * * @details * This function is left for compatibility with previous versions * and only for singe resource group mode. * * @return An int that contains the number of event views. */ virtual int GetViewEventsCount() const; /** * @brief * Call this member function to obtain a pointer to a * CXTPCalendarViewEvent object associated with the event's index. * * @param nIndex An int that contains the event view index in the day * view collection. * * @details * Index number starts with 0 and cannot be negative. * This function is left for compatibility with previous versions * and only for singe resource group mode. * * @return A pointer to a CXTPCalendarViewEvent object. * * @see GetViewEventsCount() */ virtual CXTPCalendarViewEvent* GetViewEvent_(int nIndex) const; /** * @brief * Call this member function to obtain the number of resource group * views in the view day collection. * * @details * This is a pure virtual function. This function must be defined * in the derived class. * * @return An int that contains the number of event views. */ int GetViewGroupsCount() const; /** * @brief * Call this member function to obtain a pointer to a * CXTPCalendarViewGroup object associated with the group's index. * * @param nIndex An int that contains the group view index in the day * view collection. * * @details * Index number starts with 0 and cannot be negative. * This is a pure virtual function. This function must be defined * in the derived class. * * @return A pointer to a CXTPCalendarViewGroup object. * * @see GetViewGroupsCount() */ CXTPCalendarViewGroup* GetViewGroup_(int nIndex) const; /** * @brief * Call this member function to obtain a day date value. * * @return A COleDateTime object containing the day's date. * * @see SetDayDate(COleDateTime dtDayDate) */ virtual COleDateTime GetDayDate() const; /** * @brief * Call this member function to obtain the day date value. * * @param dtDayDate A COleDateTime object that contains the new day's * date value. * * @return A COleDateTime object that contains the previous day's date value. * * @see GetDayDate() */ virtual COleDateTime SetDayDate(COleDateTime dtDayDate); /** * @brief * Call this member function to determine if there are any invisible event views. * * @details * This function is used for determining if the expanding signs are * drawn. * * @return A BOOL. TRUE if there is at least one event that is completely * invisible. FALSE otherwise. */ virtual BOOL ContainsInvisibleEvents() const; /** @cond */ _XTP_DEPRECATED_IN_FAVOR(ContainsInvisibleEvents) virtual BOOL _NoAllEventsAreVisible() const { return ContainsInvisibleEvents(); } /** @endcond */ /** * @brief * Call this member function to determine if there are any invisible event views * and to calculate the rectangle for the ExpandSign. * * @return TRUE if there are invisible event views. FALSE otherwise. * * @see CXTPCalendarViewDay::ContainsInvisibleEvents */ virtual BOOL ContainsInvisibleEventsUpdate(); /** @cond */ _XTP_DEPRECATED_IN_FAVOR(ContainsInvisibleEventsUpdate) virtual BOOL NoAllEventsAreVisible() { return ContainsInvisibleEventsUpdate(); } /** @endcond */ /** * @brief * Call this member function to determine if the day view is selected. * * @return A BOOL. TRUE if the day view is selected. FALSE otherwise. * * @see SetSelected(bSet) */ virtual BOOL IsSelected() const; /** * @brief * This member function is used to set the day view as selected. * * @see IsSelected() */ virtual void SetSelected(); /** * @brief * Call this member function to obtain the day view rectangle coordinates. * * @return A CRect object containing the day view rectangle coordinates. * * @see SetDayRect(CRect rcDay) */ virtual CRect GetDayRect() const; /** * @brief * This member function is used to set the day view rectangle coordinates. * * @param rcDay A CRect object containing the new rectangle coordinates. * * @see GetDayRect() */ virtual void SetDayRect(CRect rcDay); /** * @brief * Call this member function to determine if there are invisible event * views because the boundaries of the day view are hidden and * if the day view should display the expand sign. * * @return A BOOL. TRUE if there are invisible event views. FALSE otherwise. */ virtual BOOL IsExpanded() const; /** * @brief * Call this member function to obtain the expand sign rectangle. * * @return A CRect object that contains the expand sign rectangle's coordinates. */ virtual CRect GetExpandSignRect() const; /** * @brief * This member function is used to create a timer event. * * @param uTimeOut_ms A UINT that contains the duration of the timer in * milliseconds. * * @return A UINT that is the identifier of the timer. */ virtual UINT SetTimer(UINT uTimeOut_ms); /** * @brief * This member function is used to destroy a timer event. * * @param uTimerID - A UINT that specifies the identifier of the timer. */ virtual void KillTimer(UINT uTimerID); /** * @brief * This member function is used to obtain the index of the "this" * pointer day in the Calendar Day View. * * @return An int that contains the index of the "this" day in the Calendar * Day View. */ virtual int GetDayIndex() const; /** * @brief * This member function is used to process the user action * xtpCalendarUserAction_OnExpandDay. * * @param eButton [in] a button from which this action comes. * * @details * Implementation sends an XTP_NC_CALENDAR_USERACTION notification. * * @return TRUE if action was handled by the user and default processing must be * skipped, FALSE otherwise. * * @see XTP_NC_CALENDAR_USERACTION */ virtual BOOL UserAction_OnExpandDay(XTPCalendarExpandDayButton eButton); protected: /** * @brief * This member function is used to allow some customization before * show events. * * @details * Default implementation sends an XTP_NC_CALENDAR_PREPOPULATE_DAY notification. * * @see XTP_NC_CALENDAR_PREPOPULATE */ virtual void OnPrePopulateDay(); /** * @brief * This member function is used to create a new instance of a group. * @return A newly created view group object pointer. */ virtual CXTPCalendarViewGroup* CreateGroup() = 0; public: const XTP_VIEW_DAY_LAYOUT& GetLayout_() const; protected: XTP_VIEW_DAY_LAYOUT& GetLayout_(); protected: XTP_VIEW_DAY_LAYOUT m_Layout; /**< Layout data.*/ COleDateTime m_dtDate; /**< Day date.*/ CXTPCalendarResources* m_pResources; /**< Resources array*/ CXTPCalendarPtrCollectionT m_arViewGroups; /**< Storage for views of groups.*/ CXTPCalendarView* m_pView; /**< Storage for a owner view.*/ protected: # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPCalendarViewDay); DATE OleGetDate(); LPDISPATCH OleGetView(); LPDISPATCH OleGetViewGroups(); LPDISPATCH OleGetItem(long nIndex); int OleGetItemCount(); LPDISPATCH OleGetMultipleResources(); void OleSetMultipleResources(LPDISPATCH pDispResources); DECLARE_ENUM_VARIANT(CXTPCalendarViewDay); # endif }; /** * @brief * This class template customizes, overrides and implements some * functionality for the CXTPCalendarViewDay base class. * * @details * It is used as a part of the calendar control framework to build the * ViewDay layer of View->DayView->ViewDay * typed objects hierarchy. * These are template parameters: * _TView - Type of owner View object. * _TViewGroup - Type of View Resource objects stored in View Day. * XTP_CALENDAR_HITTESTINFO - Type of HitTest struct, used as parameter in the * member functions. * _TPThis - The last derived class type in the class hierarchy. * * You must provide all of the above parameters. * * @see CXTPCalendarViewDay */ template class CXTPCalendarViewDayT : public CXTPCalendarViewDay { public: /** * @details * Owner view class type definition. */ typedef _TView TView; public: /** * @brief * Default object constructor. * * @param pView Pointer to owner view object. * * @see ~CXTPCalendarViewDayT() */ CXTPCalendarViewDayT(const _TView* pView) : CXTPCalendarViewDay((CXTPCalendarView*)pView) { } /** * @brief * Default class destructor. * * @details * Handles class members deallocation. */ virtual ~CXTPCalendarViewDayT(){}; /** * @brief * This member function is used to fill the pHitTest structure * members with the default values for the current day view object. * * @param pHitTest A Pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * This is a pure virtual function. This function must be defined * in the derived class. */ virtual void FillHitTestEx(XTP_CALENDAR_HITTESTINFO* pHitTest) const = 0; /** * @brief * This member function is used to obtain the owner view object. * * @return A _TView template pointer to the owner view object. * * @see GetView_ */ _TView* GetView() const { return (TView*)GetView_(); } /** * @brief * Call this member function to obtain a pointer to the _TViewGroup * object that corresponds to the resource's index. * * @param nIndex An int that contains the resource view index in the day * view collection. * * @return A pointer to a _TViewGroup template object. * * @details * Index number starts with 0 and cannot be negative. * * @see GetViewGroupsCount() * @see GetViewGroup_() */ virtual _TViewGroup* GetViewGroup(int nIndex) const { return (_TViewGroup*)GetViewGroup_(nIndex); } /** * @brief * This member function is used to create a new instance of a group. * @return A newly created view group object pointer. */ virtual CXTPCalendarViewGroup* CreateGroup() { return new _TViewGroup(GetPThis()); } /** * @brief * This member function is used to adjust the view's layout depending * on the provided rectangle and then calls AdjustLayout() for all * of the sub-items. * * @param pDC A pointer to a valid device context. * @param rcDay A CRect object that contains the rectangle coordinates * that are used to draw the view. * * @details * Call Populate(COleDateTime dtDayDate) prior to calling AdjustLayout(). */ virtual void AdjustLayout(CDC* pDC, const CRect& rcDay) { CXTPCalendarViewDay::AdjustLayout(pDC, rcDay); int nCount = GetViewGroupsCount(); for (int i = 0; i < nCount; i++) { CXTPCalendarViewGroup* pViewGroup = GetViewGroup_(i); _ASSERTE(pViewGroup); if (pViewGroup) { pViewGroup->AdjustLayout(pDC, rcDay); } } } protected: /** * @brief * Call this member function to obtain the typed pointer to the * last derived class in the class hierarchy. * * @details * _TPThis - The last derived class type in the class hierarchy. * This is a pure virtual function. This function must be defined * in the derived class. * * @return Pointer to this object as last derived class type. */ virtual _TPThis* GetPThis() = 0; private: }; //////////////////////////////////////////////////////////////////////////// AFX_INLINE COleDateTime CXTPCalendarViewDay::GetDayDate() const { return m_dtDate; } AFX_INLINE CRect CXTPCalendarViewDay::GetDayRect() const { return m_Layout.m_rcDay; } AFX_INLINE void CXTPCalendarViewDay::SetDayRect(CRect rcDay) { m_Layout.m_rcDay.CopyRect(rcDay); } AFX_INLINE BOOL CXTPCalendarViewDay::IsExpanded() const { return m_Layout.m_rcExpandSign.Width() > 0 ? TRUE : FALSE; } AFX_INLINE CRect CXTPCalendarViewDay::GetExpandSignRect() const { return m_Layout.m_rcExpandSign; } /** * @brief * This class template customizes, overrides and implements some * functionality for the CXTPCalendarViewGroup base class. * * @details * It is used as a part of the calendar control framework to build the * ViewGroup layer of View->DayView->ViewDay->ViewGroup * typed objects hierarchy. * These are template parameters: * _TView - Type of owner View object. * _TViewEvent - Type of View Event objects stored in Group View. * XTP_CALENDAR_HITTESTINFO - Type of HitTest struct, used as parameter in the * member functions. * _TPThis - The last derived class type in the class hierarchy. * * You must provide all of the above parameters. * * @see CXTPCalendarViewGroup */ template class CXTPCalendarViewGroupT : public CXTPCalendarViewGroup { public: /** * @details * Owner view class type definition. */ typedef _TViewDay TViewDay; public: /** * @brief * Default object constructor. * * @param pViewDay Pointer to owner view Day object. * * @see ~CXTPCalendarViewGroupT() */ CXTPCalendarViewGroupT(_TViewDay* pViewDay) : CXTPCalendarViewGroup(pViewDay) { } /** * @brief * Default class destructor. * * @details * Handles class members deallocation. */ virtual ~CXTPCalendarViewGroupT(){}; /** * @brief * This member function is used to fill the pHitTest structure * members with the default values for the current group view object. * * @param pHitTest A Pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * This is a pure virtual function. This function must be defined * in the derived class. */ virtual void FillHitTestEx(XTP_CALENDAR_HITTESTINFO* pHitTest) const = 0; /** * @brief * This member function is used to obtain the owner view object. * * @return A _TView template pointer to the owner view object. * * @see GetView_ */ _TViewDay* GetViewDay() const { return (_TViewDay*)GetViewDay_(); } /** * @brief * Call this member function to obtain a pointer to the _TViewEvent * object that corresponds to the event's index. * * @param nIndex An int that contains the event view index in the day * view collection. * * @return A pointer to a _TViewEvent template object. * * @details * Index number starts with 0 and cannot be negative. * * @see GetViewEventsCount() * @see GetViewEvent_() */ virtual _TViewEvent* GetViewEvent(int nIndex) const { return (_TViewEvent*)GetViewEvent_(nIndex); } CXTPCalendarViewEvent* CreateViewEvent(CXTPCalendarEvent* pEvent) { return new _TViewEvent(pEvent, GetPThis()); } protected: /** * @brief * Call this member function to obtain the typed pointer to the * last derived class in the class hierarchy. * * @details * _TPThis - The last derived class type in the class hierarchy. * This is a pure virtual function. This function must be defined * in the derived class. * * @return Pointer to this object as last derived class type. */ virtual _TPThis* GetPThis() = 0; private: }; //////////////////////////////////////////////////////////////////////////// AFX_INLINE XTP_VIEW_DAY_LAYOUT& CXTPCalendarViewDay::GetLayout_() { return m_Layout; } AFX_INLINE const XTP_VIEW_DAY_LAYOUT& CXTPCalendarViewDay::GetLayout_() const { return m_Layout; } AFX_INLINE CXTPCalendarResources* CXTPCalendarViewGroup::GetResources() const { return m_pResources; } AFX_INLINE int CXTPCalendarViewGroup::GetChildHandlersCount() const { return GetViewEventsCount(); } AFX_INLINE XTP_VIEW_GROUP_LAYOUT& CXTPCalendarViewGroup::GetLayout_() { return m_Layout; } AFX_INLINE CXTPCalendarControl* CXTPCalendarViewGroup::GetCalendarControl() const { if (GetViewDay_()) return GetViewDay_()->GetCalendarControl(); return NULL; } AFX_INLINE int CXTPCalendarViewGroup::GetViewEventsCount() const { return m_arEvents.GetCount(); } AFX_INLINE CXTPCalendarViewEvent* CXTPCalendarViewGroup::GetViewEvent_(int nIndex) const { _ASSERTE(this); if (!this) { return NULL; } int nCount = m_arEvents.GetCount(); _ASSERTE(nIndex >= 0 && nIndex < nCount); return (nIndex >= 0 && nIndex < nCount) ? m_arEvents.GetAt(nIndex) : NULL; } AFX_INLINE int CXTPCalendarViewDay::GetViewGroupsCount() const { return m_arViewGroups.GetCount(); } AFX_INLINE CXTPCalendarViewGroup* CXTPCalendarViewDay::GetViewGroup_(int nIndex) const { _ASSERTE(this); if (!this) { return NULL; } int nCount = m_arViewGroups.GetCount(); _ASSERTE(nIndex >= 0 && nIndex < nCount); return (nIndex >= 0 && nIndex < nCount) ? m_arViewGroups.GetAt(nIndex) : NULL; } AFX_INLINE CXTPCalendarViewDay* CXTPCalendarViewGroup::GetViewDay_() const { _ASSERTE(this); return this ? m_pViewDay : NULL; } AFX_INLINE CXTPCalendarView* CXTPCalendarViewDay::GetView_() const { _ASSERTE(this); return this ? m_pView : NULL; } //////////////////////////////////////////////////////////////////////////// # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(_XTPCALENDARVIEWDAY_H__)