/** * @file XTPCalendarWeekView.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(_XTPCALENDARWEEKVIEW_H__) # define _XTPCALENDARWEEKVIEW_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCalendarWeekView; class CXTPCalendarWeekViewDay; class CXTPCalendarControl; /** * @brief * This class implements a specific view portion of the Calendar * control - called Week view. * * @details * The Week view can be shown as one week, consisting of * 7 days, as a normal week contains. * Weekend days of the week are drawn compressed, which means * that 2 weekend days will be drawn in a rectangle of a usual day. * Each day is represented by a CXTPCalendarWeekViewDay class. * * @see CXTPCalendarView * @see CXTPCalendarDayView * @see CXTPCalendarMonthView * @see CXTPCalendarWeekViewDay * @see CXTPCalendarWeekViewEvent */ class _XTP_EXT_CLASS CXTPCalendarWeekView : public CXTPCalendarViewT { /** @cond */ DECLARE_DYNAMIC(CXTPCalendarWeekView) friend class CXTPCalendarWeekViewEvent; friend class CXTPCalendarTheme; /** @endcond */ public: /** * @brief * Base class type definition. */ typedef CXTPCalendarViewT TBase; /** * @brief * Default object constructor. * * @param pCalendarControl Pointer to CXTPCalendarControl object. * * @see ~CXTPCalendarEvent() */ CXTPCalendarWeekView(CXTPCalendarControl* pCalendarControl); /** * @brief * Default class destructor. * * @details * Handles member items deallocation. */ virtual ~CXTPCalendarWeekView(); /** * @brief * This member function is used to populate the view with data * for all items contained in the view. */ virtual void Populate(); /** * @brief * This member function is used to show the specified day in the * calendar view. * * @param date A COleDateTime object that contains the date to show. * @param bSelect TRUE to select the specified day after showing, * FALSE otherwise. TRUE is the default value. * * @details * Call this member function to show only the specified day in the * calendar view. */ virtual void ShowDay(const COleDateTime& date, BOOL bSelect = TRUE); /** * @brief * This member function is used to adjust the view's layout depending * on the window's client size and also calls AdjustLayout() for * all sub-items. * * @param pDC A pointer to a valid device context. * @param rcView A CRect that contains the rectangle * coordinates used to draw the view. * @param bCallPostAdjustLayout A BOOL. Flag used to call additional adjustments. * * @details * Call Populate() prior calling adjust AdjustLayout(). * AdjustLayout2 is called by calendar control instead of AdjustLayout * when theme is set. */ virtual void AdjustLayout(CDC* pDC, const CRect& rcView, BOOL bCallPostAdjustLayout = TRUE); /** * @brief * This member function is used to adjust the view's layout depending * on the window's client size and also calls AdjustLayout() for * all sub-items. * * @param pDC A pointer to a valid device context. * @param rcView A CRect that contains the rectangle * coordinates used to draw the view. * @param bCallPostAdjustLayout A BOOL. Flag used to call additional adjustments. * * @details * Call Populate() prior calling adjust AdjustLayout(). * AdjustLayout2 is called by calendar control instead of AdjustLayout * when theme is set. */ virtual void AdjustLayout2(CDC* pDC, const CRect& rcView, BOOL bCallPostAdjustLayout = TRUE); /** * @brief * This member function is used to retrieve information about a * scroll bar state. * * @param pSI A pointer to a scrollbar information structure. * * @return A BOOL. This function should return TRUE to indicate success. * FALSE otherwise. */ virtual BOOL GetScrollBarInfoV(SCROLLINFO* pSI) const; /** * @brief * This member function is used to scroll the contents of a view. * * @param nPos An int that contains the position value. * @param nPos_raw An int that contains the raw position value. * * @details * ScrollV internally uses Populate() to fill the new view data. * * @see Populate(). */ virtual void ScrollV(int nPos, int nPos_raw); /** * @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(). * Draw2 is called by calendar control instead of Draw when theme * is set. * * @see AdjustLayout(). */ virtual void Draw(CDC* pDC); /** * @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(). * Draw2 is called by calendar control instead of Draw when theme * is set. * * @see AdjustLayout(). */ virtual void Draw2(CDC* pDC); /** * @brief * This member function is used to process keyboard on-key-down events. * * @param nChar A UINT that contains the virtual key code of the given key. * @param nRepCnt A UINT that contains the number of times the keystroke is * repeated as a result of the user holding down the key. * @param nFlags A UINT that contains the scan code, key-transition code, * previous key state, and the context code. * * @details * This method is called by the CalendarControl when the user * presses keys on the keyboard. */ virtual void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); /** * @brief * Call this member function to obtain the date of a day view by * the day's index. * * @param nIndex An int that contains the day view index in the view * collection. * * @details * Index number starts with 0 and cannot be negative. * * @return A COleDateTime object that contains the day view date and time. * * @see GetViewDayCount() */ virtual COleDateTime GetViewDayDate(int nIndex) const; /** * @brief * This member function is used to obtain the header height of a * day. * * @return An int that contains the height of a row required to display * a single event. */ int GetDayHeaderHeight() const; /** * @brief * This member function is used to set the date of a week's Monday. * * @param dtNewBeginDate A COleDateTime object that contains the date of Monday. * * @details * Call this member function to set the date of a week to the Monday of * the current week. * * @see GetBeginDate() */ void SetBeginDate(COleDateTime dtNewBeginDate); /** * @brief * This member function is used to obtain the date of the current * week's Monday. * * @return A COleDateTime object that contains the current week's Monday date. * * @see SetBeginDate() */ COleDateTime GetBeginDate() const; /** * @brief * This member function is used to obtain the width of a weeks * day rectangle. * * @return An int that contains the width of a day rectangle. */ int GetDayWidth() const; /** * @brief * This member function is used to obtain the height of a weeks * day rectangle. * * @return An int that contains the height of a day rectangle. */ int GetDayHeight() const; /** @cond */ _XTP_DEPRECATED_IN_FAVOR(GetDayHeight) int GetDayHeidht() const; /** @endcond */ protected: // member function /** * @brief * Call this member function to adjust the first day of the week. * * @details * The first day of the week depends on region. */ virtual void AdjustFirstDayOfWeek(); private: COleDateTime ShiftDateToCell_00(COleDateTime dtDate) const; public: int GetFirstDayOfWeek() const; protected: XTP_WEEK_VIEW_LAYOUT& GetLayout(); protected: /**< data members */ XTP_WEEK_VIEW_LAYOUT m_LayoutX; /**< Layout data. */ int m_nCurrPos; /**< Current scrollbar position.*/ COleDateTime m_dtBeginDate; /**< First date of week (Monday's date).*/ int m_nFirstDayOfWeekIndex; /**< Index for first weekday. */ # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPCalendarWeekView); # endif }; AFX_INLINE int CXTPCalendarWeekView::GetFirstDayOfWeek() const { return m_nFirstDayOfWeekIndex; } AFX_INLINE XTP_WEEK_VIEW_LAYOUT& CXTPCalendarWeekView::GetLayout() { return m_LayoutX; } AFX_INLINE int CXTPCalendarWeekView::GetDayHeaderHeight() const { return m_LayoutX.m_nDayHeaderHeight; } AFX_INLINE COleDateTime CXTPCalendarWeekView::GetBeginDate() const { return m_dtBeginDate; } AFX_INLINE int CXTPCalendarWeekView::GetDayWidth() const { return m_LayoutX.m_nDayWidth; } AFX_INLINE int CXTPCalendarWeekView::GetDayHeight() const { return m_LayoutX.m_nDayHeight; } /** @cond */ AFX_INLINE int CXTPCalendarWeekView::GetDayHeidht() const { return GetDayHeight(); } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(_XTPCALENDARWEEKVIEW_H__)