/** * @file XTPCalendarDayViewDay.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(_XTPCALENDARDAYVIEWDAY_H__) # define _XTPCALENDARDAYVIEWDAY_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCalendarDayView; class CXTPCalendarViewPart; class CXTPCalendarDayViewDay; class CXTPCalendarDayViewEvent; struct XTP_CALENDAR_HITTESTINFO; /** * @brief * This class represents a single resource view portion of the Calendar * Day View. * * @details * It represents a specific view of the CalendarView's associated events * data grouped by one day and one resource and provides basic * functionality on this data using user input through keyboard and mouse. * * @see CXTPCalendarDayViewDay */ class _XTP_EXT_CLASS CXTPCalendarDayViewGroup : public CXTPCalendarViewGroupT { friend class CXTPCalendarDayViewEvent; friend class CXTPCalendarTheme; /** @cond */ DECLARE_DYNAMIC(CXTPCalendarDayViewGroup) /** @endcond */ public: /** * @brief * Base class type definition. */ typedef CXTPCalendarViewGroupT TBase; typedef CXTPCalendarPtrCollectionT TViewEventsCollection; /** * @brief * Default object constructor. * Construct CXTPCalendarDayViewGroup object. * * @param pViewDay Pointer to CXTPCalendarDayViewDay object. * * @see ~CXTPCalendarDayViewGroup() */ CXTPCalendarDayViewGroup(CXTPCalendarDayViewDay* pViewDay); /** * @brief * Default class destructor. * * @details * Handles member items deallocation. */ virtual ~CXTPCalendarDayViewGroup(); /** * @brief * This member function is used to adjust the view's layout depending * on the provided bounding rectangle and calls AdjustLayout() for * all sub items. * * @param pDC Pointer to a valid device context. * @param rcGroup A CRect object containing the dimensions of the bounding * rectangle for the DayViewGroup area. * * @details * 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 bounding rectangle and calls AdjustLayout() for * all sub items. * * @param pDC Pointer to a valid device context. * @param rcGroup A CRect object containing the dimensions of the bounding * rectangle for the DayViewGroup area. * * @details * 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 content utilizing * the specified device context. * * @param pDC Pointer to a valid device context. * * @details * Call AdjustLayout() before Draw() * * @see AdjustLayout */ virtual void Draw(CDC* pDC); virtual void DrawEvents(CDC* pDC); void DrawAllDayAreaScrollIcons(CDC* pDC); /** * @brief * This member function is used to fill the * XTP_CALENDAR_HITTESTINFO structure. * * @param pt A CPoint object that contains the point to test. * @param pHitTest Pointer to an XTP_CALENDAR_HITTESTINFO struct. * * @return TRUE if the test is succesful, FALSE else. * * @details * Call this member function to gather hit test information from * the day view. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTestEx(CPoint pt, XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function is used to obtain the busy status for the * specified time. * * @param dtTime A COleDateTime object that contains the time value for * which to check the busy status. * * @return XTPCalendarEventBusyStatus value. */ virtual int GetBusyStatus(COleDateTime dtTime) const; /** * @brief * This member function is used to obtain the drawing area of all day * events. * * @return A CRect object containing the coordinates of the all day events * drawing area. */ virtual CRect GetAllDayEventsRect() const; /** * @brief * Adjusts layout of day events items. * * @param pDC Pointer to a valid device context. */ virtual void AdjustDayEvents(CDC* pDC); /** * @brief * This member function is used to obtain the height of a single cell. * * @return An int that contains the height, in pixels, of a single cell. */ int GetRowHeight() const; /** * @brief * This member function is used to obtain the number of rows * visible in the view. * * @return An int that contains the number of rows visible in the view. */ int GetVisibleRowCount() const; /** * @brief * This member function is used to obtain the number of the top * visible row in the view. * * @return An int that contains the number of the top visible row in the view. */ int GetTopRow() const; /** * @brief * This member function is used to obtain the total number of * rows in the view. * * @return An int that contains the total number of rows in the view. */ int GetRowCount() const; /** * @brief * This member function is used to obtain the beginning time value * for the specified cell. * * @param nCell An int that contains the cell index. * * @return A COleDateTime object that contains the beginning time value * for the specified cell. */ COleDateTime GetCellDateTime(int nCell) const; /** * @brief * This member function is used to calculate the cell number for * the specified time value. * * @param dtTime A COleDateTime object that contains the time value to * search for. * @param bForEndTime A BOOL object that determines if a split line * between cells is needed. The split line is used to * indicate if the date to search for belongs to the * end of the previous cell or to the beginning of the * next cell. * * @return Call this member function to retrieve the cell that contains * the specified time value. */ int GetDateTimeCell(const COleDateTime& dtTime, BOOL bForEndTime) const; /** * @brief * This member function is used to obtain the rect for the specified * cell. * * @param nCell An int that contains the cell index. * * @return A CRect object that contains the cell rect. */ CRect GetCellRect(int nCell) const; /** * @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 CPoint& of mouse position. * @param hitInfo XTP_CALENDAR_HITTESTINFO. * * @return A CRect object with relative coordinates of the tooltip. * * @details * This member function returns a rectangle calculated as a single * cell rect which user currently holds a mouse on. */ virtual CRect GetTooltipRect(const CPoint& ptHit, const XTP_CALENDAR_HITTESTINFO& hitInfo) const; /** * @brief * This member function is used to check if the specified date time * is work or non-work. * * @param dtDateTime A COleDateTime object that contains the date time * value to check. * * @return TRUE if the specified date time is work, FALSE otherwise. */ BOOL IsWorkDateTime(const COleDateTime& dtDateTime) const; /** * @brief * This member function is used to determine if the group header * is visible or not. * * @return TRUE if the group header is visible, FALSE otherwise. */ BOOL IsGroupHeaderVisible() const; /** * @brief * Call this member function to set the ExpandUp sign visible. * * @details * Can be useful to implement visualization themes. */ void SetExpandUp(); /** * @brief * Call this member function to set the ExpandDown sign visible. * * @details * Can be useful to implement visualization themes. */ void SetExpandDown(); /** * @brief * Call this member function to determine if the ExpandUp sign is visible. * * @details * Can be useful to implement visualization themes. * * @return TRUE if the ExpandUp sign is visible, FALSE otherwise. */ BOOL IsExpandUp() const; /** * @brief * Call this member function to determine if the ExpandDown sign is visible. * * @details * Can be useful to implement visualization themes. * * @return TRUE if the ExpandDown sign is visible, FALSE otherwise. */ BOOL IsExpandDown() const; /** * @brief * Calculates the rectangle to fill with a scroll button icon for day view * when there are too many alldayevents to show without scrolling. * * @details * Can be useful to implement visualization themes. * * @param nButton xtpHotAllDayEventsScrollUp or xtpHotAllDayEventsScrollDown buttons ids. * * @return CRect for scroll icon to show. */ CRect GetAllDayEventsScrollButtonRect(XTP_DAY_VIEW_GROUP_LAYOUT::XTPEnumHotItem nButton) const; /** * @brief * Call this member function to determine if all day events scroll icons * will be shown in day view. * * @return TRUE if all day events scroll icons will be shown in day view. */ BOOL NeedScrollAllDayEvents() const; /** * @brief * Call this member function to determine if the up scroll button for the * alldayevents area will be shown. * * @return TRUE if the up scroll button for the alldayevents area will be shown. */ BOOL IsShowAllDayEventsUpScrollButton() const; /** * @brief * Call this member function to determine if the down scroll button for the * alldayevents area will be shown. * * @return TRUE if the down scroll button for the alldayevents area will be shown. */ BOOL IsShowAllDayEventsDownScrollButton() const; /** * @brief * Call this member function to set the visibility for the up scroll button in * the all day events area. * @param bShow TRUE to turn on visibility for up scroll button, FALSE to hide */ void SetShowAllDayEventsUpScrollButton(BOOL bShow); /** * @brief * Call this member function to set the visibility for the down scroll button in * the all day events area. * @param bShow TRUE to turn on visibility for up scroll button, FALSE to hide */ void SetShowAllDayEventsDownScrollButton(BOOL bShow); /** * @brief * Call this member function to determine the index of the first visible all day * event in group view. * * @return Index of the view event object. */ int GetFirstVisibleAllDayEvent() const; /** * @brief * Call this member function to determine the index of the last visible all day * event in group view. * * @return Index of the view event object. */ int GetLastVisibleAllDayEvent() const; /** * @brief * Call this member function to determine if the up scroll icon in the * all day events area is visible-highlighted. * * @return TRUE if visible, FALSE otherwise. */ BOOL IsUpAllDayEventsScrollButtonVisible() const; /** * @brief * Call this member function to determine if the down scroll icon in the * all day events area is visible-highlighted. * * @return TRUE if visible, FALSE otherwise. */ BOOL IsDownAllDayEventsScrollButtonVisible() const; /** * @brief * Call this member function to find the top and bottom events in a group. * * @param rpMin [out] Reference to store pointer to a top event. * @param rpMax [out] Reference to store pointer to a bottom event. */ void FindMinMaxGroupDayEvents(CXTPCalendarDayViewEvent*& rpMin, CXTPCalendarDayViewEvent*& rpMax) const; /** * @brief * This member function is used to process the user action * xtpCalendarUserAction_OnScrollDay. * * @param eButton - [in] a button from which this action comes. * * @details * Implementation sends an XTP_NC_CALENDAR_USERACTION notification. * * @return TRUE if the action was handled by the user and default processing must be * skipped, FALSE otherwise. * * @see XTP_NC_CALENDAR_USERACTION */ BOOL UserAction_OnScrollDay(XTPCalendarScrollDayButton eButton); /** * @brief * This member function is used to process the user actions * xtpCalendarUserAction_OnScrollAllDayEvensUp and * xtpCalendarUserAction_OnScrollAllDayEvensDown. * * @param eHotBtn - [in] a button from which this action comes. * * @details * Implementation sends an XTP_NC_CALENDAR_USERACTION notification. * * @return TRUE if action was handled by user and default processing must be * skipped, FALSE otherwise. * * @see XTP_NC_CALENDAR_USERACTION */ BOOL UserAction_OnScrollAllDayEvents(XTP_DAY_VIEW_GROUP_LAYOUT::XTPEnumHotItem eHotBtn); /** * @brief * This member function processes click on up scroll icon in the all day events area. * * @return TRUE if the action was handled by default, * FALSE if the user canceled default handler. * * @see XTP_NC_CALENDAR_USERACTION */ BOOL ScrollIcon_ScrollAllDayEventsUp(); /** * @brief * This member function processes click on down scroll icon in the all day events area. * * @return TRUE if the action was handled by default, * FALSE if the user canceled default handler. * * @see XTP_NC_CALENDAR_USERACTION */ BOOL ScrollIcon_ScrollAllDayEventsDown(); /** * @brief * This member function returns events count in the all day area of the group. * @return The number of events in all data area. */ int GetEventsCountInAllDayArea() const; BOOL m_bHide; COLORREF m_GroupColor; protected: /** * @brief * This member function is used to process left mouse button events. * * @param nFlags A UINT that is used to indicate whether various virtual * keys are down. * @param point A CPoint that specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * * @return TRUE if the operation is successful, FALSE otherwise. * * @details * This method is called by the CalendarControl when the user * presses the left mouse button. */ virtual BOOL OnLButtonDown(UINT nFlags, CPoint point); /** * @brief * This member function is used to process left mouse button events. * * @param nFlags A UINT that is used to indicate whether various virtual * keys are down. * @param point A CPoint that specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * * @return TRUE if the operation is successful, FALSE otherwise. * * @details * This method is called by the CalendarControl when the user * presses the left mouse button. */ virtual BOOL OnLButtonDblClk(UINT nFlags, CPoint point); /** * @brief * This member function is used by OnLButtonDblClk() and OnLButtonDown() to filter scroll * icons presses in the all days events area. * * @param nFlags A UINT that is used to indicate whether various virtual * keys are down. * @param point A CPoint that specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * * @return TRUE if the operation is successful, FALSE otherwise. */ BOOL OnAllDaysAreaClick(UINT nFlags, CPoint point); /** * @brief * This member function is used to process mouse movement events. * * @param nFlags A UINT that is used to indicate whether various virtual * keys are down. * @param point A CPoint that specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * * @details * This method is called by the CalendarControl when the user * moves the mouse cursor or stylus. */ virtual void OnMouseMove(UINT nFlags, CPoint point); /** * @brief * This member function is used to obtain the view part of the * specified cell. * * @param dtDateTime A COleDateTime object that contains the cell's * date to return the view part for. * * @return A pointer to a CXTPCalendarViewPart object. * The CXTPCalendarViewPart object contains the Day View * Working Cell part if dtDateTime is the same as the Work Date * Time. * Otherwise the CXTPCalendarViewPart object contains the * Non-Work Cell part. * * @see CXTPCalendarViewPart overview */ virtual CXTPCalendarViewPart* GetCellViewPart(const COleDateTime& dtDateTime) const; /** * @brief * This member function is used to obtain the events collection * which belongs to the specified cell. * * @param nCell An int that contains the cell number for the events * collection. * @param pViewEvents Pointer to an event views collection. This pointer * is used populate the views collection with data. * @param rdtMinEventTime A COleDateTime object used to contain the minimum * time for events in the returned collection. * @param rdtMaxEventTime A COleDateTime object used to contain the maximum * time for events in the returned collection. * * @see TViewEventsCollection */ virtual void GetCellEvents(int nCell, TViewEventsCollection* pViewEvents, COleDateTime& rdtMinEventTime, COleDateTime& rdtMaxEventTime); /** * @brief * This member function is used to fill an * XTP_CALENDAR_HITTESTINFO structure. * * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * Call this member function to gather hit test information from * the day view. * It uses pHitTest->pt point for gathering information. * * @return A BOOL. * TRUE if pHitTest->pt point is on a valid part of the Day View. * FALSE otherwise. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTestDateTime(XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function is used to fill an * XTP_CALENDAR_HITTESTINFO structure. * * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * Call this member function to gather hit test information from the * day view. * * @see XTP_CALENDAR_HITTESTINFO */ virtual void FillHitTestEx(XTP_CALENDAR_HITTESTINFO* pHitTest) const; public: const XTP_DAY_VIEW_GROUP_LAYOUT& GetLayout() const; /** * @brief * This member function is used to fill an * XTP_CALENDAR_HITTESTINFO structure. * * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO structure. * @param pt A CPoint object that contains the point to test. * * @details * Call this member function to gather hit test information from * the day view. * It uses pHitTest->pt point for gathering information. * * @return A BOOL. * TRUE if pHitTest->pt point is on a valid part of the Day View. * FALSE otherwise. * * @see XTP_CALENDAR_HITTESTINFO */ virtual BOOL HitTestAllDayEventsScrollIcons(CPoint pt, XTP_CALENDAR_HITTESTINFO* pHitTest) const; protected: XTP_DAY_VIEW_GROUP_LAYOUT& GetLayout(); protected: XTP_DAY_VIEW_GROUP_LAYOUT m_LayoutX; /**< Store group view layout.*/ BOOL m_bExpandUP; /**< Store is ExpandUP sign visible.*/ BOOL m_bExpandDOWN; /**< Store is ExpandDOWN sign visible.*/ BOOL m_bIsShowAllDayEventsUpScrollButton; BOOL m_bIsShowAllDayEventsDownScrollButton; private: TViewEventsCollection m_arRegionViewEvents; void _AddInRegion_IfNeed(CXTPCalendarDayViewEvent* pViewEvent); void _OnRegionEnded(CDC* pDC, int nRegionMaxSize); virtual CXTPCalendarDayViewGroup* GetPThis(); }; AFX_INLINE CXTPCalendarDayViewGroup* CXTPCalendarDayViewGroup::GetPThis() { return this; } /** * @brief * This class represents a day view portion of the Calendar Day View. * * @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 keyboard and mouse. * * CXTPCalendarDayViewDay is based on the CXTPCalendarViewDayT template * class. It inherits basic behavior from the CXTPCalendarViewDayT template * class. Furthermore, CXTPCalendarDayViewDay overlaps and adds some * new functionality to get its own behavior and appearance. * * @see CXTPCalendarViewDay * @see CXTPCalendarViewDayT */ class _XTP_EXT_CLASS CXTPCalendarDayViewDay : public CXTPCalendarViewDayT { friend class CXTPCalendarDayView; friend class CXTPCalendarDayViewGroup; friend class CXTPCalendarDayViewEvent; /** @cond */ DECLARE_DYNAMIC(CXTPCalendarDayViewDay) /** @endcond */ public: /** * @brief * Base class type definition. */ typedef CXTPCalendarViewDayT TBase; /** * @brief * Default object constructor. * * @param pDayView Pointer to parent CXTPCalendarDayView object. * @param dtDate A date for which the day view is created. * * @details * Constructs a CXTPCalendarDayViewDay object. * * @see ~CXTPCalendarDayViewDay() */ CXTPCalendarDayViewDay(CXTPCalendarDayView* pDayView, COleDateTime dtDate); /** * @brief * Default class destructor. * * @details * Handles member items deallocation. */ virtual ~CXTPCalendarDayViewDay(); /** * @brief * This member function is used to draw the view content utilizing * the specified device context. * * @param pDC Pointer to a valid device context. * * @details * Call AdjustLayout() before Draw(). * * @see AdjustLayout(CRect rcDay) */ virtual void Draw(CDC* pDC); /** * @brief * This member function is used to draw the view content utilizing * the specified device context. * * @param pDC Pointer to a valid device context. * * @details * Call AdjustLayout() before Draw(). * * @see AdjustLayout(CRect rcDay) */ virtual void DrawEvents(CDC* pDC); /** * @brief * This member function is used to draw the view content utilizing * the specified device context. * * @param pDC Pointer to a valid device context. * * @details * Call AdjustLayout() before Draw(). * * @see AdjustLayout(CRect rcDay) */ virtual void DrawTopmostLayer(CDC* pDC); /** * @brief * This member function is used to adjust the view's layout depending * on the provided bounding rectangle and calls AdjustLayout() for * all sub items. * * @param pDC Pointer to a valid device context. * @param rcDay A CRect object containing the dimensions of the bounding * rectangle for the control. * * @details * AdjustLayout2 is called by calendar control instead of AdjustLayout * when theme is set. */ virtual void AdjustLayout(CDC* pDC, const CRect& rcDay); /** * @brief * This member function is used to adjust the view's layout depending * on the provided bounding rectangle and calls AdjustLayout() for * all sub items. * * @param pDC Pointer to a valid device context. * @param rcDay A CRect object containing the dimensions of the bounding * rectangle for the control. * * @details * AdjustLayout2 is called by calendar control instead of AdjustLayout * when theme is set. */ virtual void AdjustLayout2(CDC* pDC, const CRect& rcDay); /** * @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. */ virtual void Populate(COleDateTime dtDayDate); /** * @brief * This member function is used to obtain a single day's view caption. * * @return A CString object that contains the day's view caption. */ virtual CString GetCaption() const; /** * @brief * This member function is used to fill an * XTP_CALENDAR_HITTESTINFO structure. * * @param pInfo A pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @details * Call this member function to gather hit test information from the * day view. * * @see XTP_CALENDAR_HITTESTINFO */ virtual void FillHitTestEx(XTP_CALENDAR_HITTESTINFO* pInfo) const; protected: /** * @brief * This member function is used to processes mouse movement events. * * @param nFlags A UINT that is used to indicate whether various virtual * keys are down. * @param point A CPoint that specifies the x- and y- coordinates of the cursor. * These coordinates are always relative to the * upper-left corner of the window. * * @details * This method is called by the CalendarControl when the user * moves the mouse cursor or stylus. */ virtual void OnMouseMove(UINT nFlags, CPoint point); private: virtual CXTPCalendarDayViewDay* GetPThis(); }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE CRect CXTPCalendarDayViewGroup::GetAllDayEventsRect() const { return m_LayoutX.m_rcAllDayEvents; } AFX_INLINE BOOL CXTPCalendarDayViewGroup::IsGroupHeaderVisible() const { return m_LayoutX.m_bShowHeader; } AFX_INLINE XTP_DAY_VIEW_GROUP_LAYOUT& CXTPCalendarDayViewGroup::GetLayout() { return m_LayoutX; } AFX_INLINE const XTP_DAY_VIEW_GROUP_LAYOUT& CXTPCalendarDayViewGroup::GetLayout() const { return m_LayoutX; } AFX_INLINE CXTPCalendarDayViewDay* CXTPCalendarDayViewDay::GetPThis() { return this; } AFX_INLINE void CXTPCalendarDayViewGroup::SetExpandUp() { m_bExpandUP = TRUE; } AFX_INLINE void CXTPCalendarDayViewGroup::SetExpandDown() { m_bExpandDOWN = TRUE; } AFX_INLINE BOOL CXTPCalendarDayViewGroup::IsExpandUp() const { return m_bExpandUP; } AFX_INLINE BOOL CXTPCalendarDayViewGroup::IsExpandDown() const { return m_bExpandDOWN; } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(AFX_XTPCALENDARDAYVIEWDAY_H__7E299FBF_C671_4648_8919_8ACAFDF38A99__INCLUDED_)