/** * @file XTPCalendarDayViewTimeScale.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(_XTPCALENDARDAYVIEWTIMESCALE_H__) # define _XTPCALENDARDAYVIEWTIMESCALE_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" struct XTP_CALENDAR_HITTESTINFO; class CXTPCalendarDayView; class CXTPCalendarTimeZones; /** * @brief * Time format structure. Time values for timescale will be formatted using this parameter. */ struct XTP_LC_TIMEFORMAT { XTP_LC_TIMEFORMAT(); virtual ~XTP_LC_TIMEFORMAT(); virtual void RefreshMetrics(); void LoadFromLocale(); void SetCustomFormat(BOOL bAmPm, BOOL bLeadingZero, const CString& separator, const CString& am, const CString& pm); void ResetToDefault(); BOOL bIsCustom; BOOL bAMPM_timeFormat; BOOL bLeadingZeroTime; CString strSeparator; CString strAM; CString strPM; }; /** * @brief * This class implements a specific view portion of the Calendar * Day view - called Time scale. * * @details * The Day view contains two time scales defining those intervals * at the left of the view, which is represented by the * CXTPCalendarDayViewTimeScale class. One time scale is the main and * is visible by default. The second time scale is the alternative * and could be enabled programmatically. Time scale interval could be * changed using the SetScaleInterval member function. * * @see CXTPCalendarDayViewDay */ class _XTP_EXT_CLASS CXTPCalendarDayViewTimeScale : public CXTPCmdTarget { DECLARE_DYNAMIC(CXTPCalendarDayViewTimeScale) friend class CXTPCalendarDayView; friend class CXTPCalendarTheme; public: /** * @brief * Default object constructor. * * @param pDayView Pointer to associated CXTPCalendarDayView object. * @param bVisible Specifies initial visibility mode for the time * scale. * @param bDrawNowLine If TRUE current time mark is drawn. * * @see ~CXTPCalendarDayViewTimeScale() */ CXTPCalendarDayViewTimeScale(CXTPCalendarDayView* pDayView, BOOL bVisible = TRUE, BOOL bDrawNowLine = TRUE); /** * @brief * Default class destructor. * * @details * Handles member items deallocation. * * @see CXTPCalendarDayViewTimeScale */ virtual ~CXTPCalendarDayViewTimeScale(); /** * @brief * This member function is used to obtain the time scale width in pixels. * * @param pDC Pointer to a valid device context. * * @return An int that contains the time scale width in pixels. */ int CalcWidth(CDC* pDC); /** * @brief * This member function is used to get the time scale width. * * @return An int that contains the time scale width in pixels. */ int GetWidth() const; /** * @brief * This member function is used to perform all drawing logic of * the time scale. * * @param pDC A pointer to a valid device context. */ void Draw(CDC* pDC); /** * @brief * This function is used to adjust the time scale layout. * * @param pDC Pointer to a valid device context. */ virtual void AdjustLayout(CDC* pDC); /** * @brief * This member function is used to format the time scale text. * * @param dtTime A COleDateTime object that contains the time to format to text. * @param bTopCell If TRUE and minutes value is 0 the minutes * value is replaced on am/pm value. This valid only for * AM/PM 12-hour time format. If this parameter is FALSE, the * minutes value 0 is replaced only if the hour value is 12. * @param pHour A pointer to the CString object to write the hour part of the value. * @param pMin A pointer to the CString object to write the minutes part of the value. * * @return A string containing formatted text. */ virtual CString Format(COleDateTime dtTime, BOOL bTopCell, CString* pHour = NULL, CString* pMin = NULL); /** * @brief * This member function is used to determine if the Current Time Mark * can be drawn for this time scale. * * @details * By default it returns TRUE for primary time scale and * FALSE for secondary. * * @return Returns TRUE if Current Time Mark may be drawn for this time scale, * FALSE otherwise. */ virtual BOOL IsDrawNowLine() const; /** * @brief * This member function obtains the time scale cell interval. * * @details * Use this member function to retrieve the current time scale * cell interval. * * @return A COleDateTimeSpan object that contains the cell interval for * the time scale. */ COleDateTimeSpan GetScaleInterval() const; /** * @brief * This member function is used to set the text caption for the * time scale. * * @param strCaption A CString object that contains the new text * caption for the time scale. * * @details * Use this function to set the current time scale caption. * * @see GetCaption */ void SetCaption(LPCTSTR strCaption); /** * @brief * This member function is used to obtain the text caption for * the time scale. * * @details * Use GetCaption() to get the current time scale caption. * * @return A CString object that contains the text caption for the time scale. * * @see SetCaption */ CString GetCaption() const; /** * @brief * This member function is used to set the new time shift in * hours for the time scale. * * @param nMinutes An int that contains the new time shift for the * time scale in minutes. * * @details * Use this member function to set the new time shift for * the time scale. * * @see GetTimeshift */ void SetTimeshift(int nMinutes); /** * @brief * This member function is used to obtain the time shift in * hours for the time scale. * * @details * Use this member function to retrieve the current time shift for * the time scale. * * @return An int that contains the time shift for the time scale in minutes. * * @see SetTimeshift */ int GetTimeshift() const; /** * @brief * This member function is used to set the time scale visibility * mode (TRUE - visible, FALSE - invisible). * * @param bVisible A BOOL that contains the new time scale visible state. * TRUE - Visible. * FALSE - Invisible. * * @see GetVisible() */ void SetVisible(BOOL bVisible); /** * @brief * This member function is used to obtain the current time scale * visibility mode. * * @return A BOOL that contains the time scale visibility scale value. * TRUE if the time scale is visible. * FALSE otherwise. * * @see SetVisible(BOOL) */ BOOL GetVisible() const; /** * @brief * This member function is used to fill an * XTP_CALENDAR_HITTESTINFO structure. * * @param pHitTest A pointer to an XTP_CALENDAR_HITTESTINFO structure. * * @return TRUE if the test is succesful, FALSE otherwise. * * @details * Call this member function to gather hit test information from * the day view. * It uses pHitTest->pt point for gathering hit test information. * * @see XTP_CALENDAR_HITTESTINFO */ BOOL HitTestDateTime(XTP_CALENDAR_HITTESTINFO* pHitTest) const; /** * @brief * This member function obtains the time scale owner view. * * @details * Use this member function to get the day view object which owns the time * scale. * * @return A pointer to CXTPCalendarDayView object. */ CXTPCalendarDayView* GetDayView() const; /** * @brief * This member function shifts the time scale object. * * @param nXPos Offset from base position. * * @details * Used by horizontal scrolling to place the timescale always visible * on the left border. */ void MoveTo(int nXPos); /** * @brief * Sets the custom time format for the day view timescale. * * @param bAmPm selects 24hrs or 12hrs time format * TRUE - 12hrs format * FALSE - 24 hrs format * @param bLeadingZero Set to TRUE to fill 1-digit time with leading zero * @param separator hours-mins separator * @param am string to fill for "am" * @param pm string to fill for "pm" * * @details * This function overrides the locale time format for calendar control. To reset the time * format back to locale, call ResetCustomTimeFormat() */ void SetCustomTimeFormat(BOOL bAmPm, BOOL bLeadingZero = TRUE, const CString& separator = _T(":"), const CString& am = _T("am"), const CString& pm = _T("pm")); /** * @brief * Resets the timescale time format to the current locale format. */ void ResetCustomTimeFormat(); public: void RefreshTimeFormat(); const XTP_LC_TIMEFORMAT& GetTimeFormat() const; private: void DrawLTR(CDC* pDC); void DrawRTL(CDC* pDC); public: BOOL m_bDrawNowLine; /**< Specifies whether we should draw the "Now" line on the time scale.*/ protected: XTP_TIMESCALE_LAYOUT& GetLayout(); protected: XTP_TIMESCALE_LAYOUT m_Layout; /**< Store time scale layout.*/ XTP_LC_TIMEFORMAT m_timeFormat; CXTPCalendarDayView* m_pDayView; /**< Pointer to the parent Calendar Day view object.*/ CString m_strCaption; /**< Caption under time scale.*/ int m_nTimeshift_min; /**< Time zone time shift in minutes.*/ BOOL m_bVisible; /**< Show this timescale or not.*/ private: int m_nWidth; /**< Calculated time scale width.*/ BOOL m_bDrawNowLineDyn; /**< DrawNowLine attribute dynamically calculated on AdjustLayout.*/ }; ///////////////////////////////////////////////////////////////////////////// // CXTPCalendarTimeScalePropertiesDlg dialog // // This dialog allows for the customization of the Calendar Time Scale part as // well as the setting of a proper time zone and its description. // // This dialog is a simplified version of a similar Outlook dialog. // ///////////////////////////////////////////////////////////////////////////// class _XTP_EXT_CLASS CXTPCalendarTimeScalePropertiesDlg : public CDialog { public: enum { IDD = XTP_IDD_CALENDAR_TIMESCALE_PROPERTIES }; /** * @brief * Dialog class constructor. * * @param pParent [in] Pointer to parent window. Can be NULL. * @param nIDTemplate [in] Contains the ID number of a dialog-box template resource. */ CXTPCalendarTimeScalePropertiesDlg(CWnd* pParent = NULL, UINT nIDTemplate = CXTPCalendarTimeScalePropertiesDlg::IDD); ~CXTPCalendarTimeScalePropertiesDlg(); public: CString m_strCaption1; /**< [in, out] Store Caption string for main timescale.*/ BOOL m_bShowAdditionalScale; /**< [in, out] Store is additional timescale used or not.*/ CString m_strCaption2; /**< [in, out] Store Caption string for additional timescale.*/ TIME_ZONE_INFORMATION m_tziScale2; /**< [in, out] Store additional timescale data.*/ protected: // Generated message map functions virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); virtual void OnOK(); afx_msg void OnSelchangeZones2(); afx_msg void OnBnClickedScale2(); /** @cond */ DECLARE_MESSAGE_MAP() /** @endcond */ protected: CEdit m_edtCaption1; /**< An edit control for the main time zone caption.*/ CComboBox m_cmbZones1; /**< A combobox to display the main time zone.*/ CButton m_btnAutoAdjustDayLight1; /**< A check box control to show the 'Auto Adjust Day Light' option for the main timezone.*/ CEdit m_edtCaption2; /**< An edit control for an additional time zone caption.*/ CComboBox m_cmbZones2; /**< A combobox to edit an additional time zone.*/ CButton m_btnAutoAdjustDayLight2; /**< A check box control to edit the 'Auto Adjust Day Light' option for an additional timezone.*/ BOOL m_bAutoAdjustDayLight2; /**< A BOOL member which is used to edit the 'Auto Adjust Day Light' option for an additional timezone.*/ CXTPCalendarTimeZones* m_pTimeZones; /**< A collection of timezones.*/ }; ///////////////////////////////////////////////////////////////////////////// AFX_INLINE void CXTPCalendarDayViewTimeScale::SetCaption(LPCTSTR strCaption) { m_strCaption = strCaption; } AFX_INLINE CString CXTPCalendarDayViewTimeScale::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPCalendarDayViewTimeScale::SetTimeshift(int nMinutes) { m_nTimeshift_min = nMinutes; } AFX_INLINE int CXTPCalendarDayViewTimeScale::GetTimeshift() const { return m_nTimeshift_min; } AFX_INLINE void CXTPCalendarDayViewTimeScale::SetVisible(BOOL bVisible) { m_bVisible = bVisible; } AFX_INLINE BOOL CXTPCalendarDayViewTimeScale::GetVisible() const { return m_bVisible; } AFX_INLINE CXTPCalendarDayView* CXTPCalendarDayViewTimeScale::GetDayView() const { return m_pDayView; } AFX_INLINE XTP_TIMESCALE_LAYOUT& CXTPCalendarDayViewTimeScale::GetLayout() { return m_Layout; } AFX_INLINE const XTP_LC_TIMEFORMAT& CXTPCalendarDayViewTimeScale::GetTimeFormat() const { return m_timeFormat; } AFX_INLINE BOOL CXTPCalendarDayViewTimeScale::IsDrawNowLine() const { return m_bDrawNowLine; } AFX_INLINE int CXTPCalendarDayViewTimeScale::GetWidth() const { return m_Layout.m_rcHeader.Width(); } # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(_XTPCALENDARDAYVIEWTIMESCALE_H__)