/** * @file XTPCalendarControlView.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(__XTPCALENDARCONTROLVIEW_H__) # define __XTPCALENDARCONTROLVIEW_H__ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableAdvancedWarnings.h" # include # include "Common/Base/Diagnostic/XTPEnableAdvancedWarnings.h" # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCalendarControlViewPrintOptions; class CXTPCalendarPageSetupDialog; class CXTPNotifySink; /** * @brief * Identifier of Calendar control child window of CXTPCalendarControlView. */ const UINT XTP_ID_CALENDAR_CONTROL = 100; const UINT XTP_ID_CALENDARCAPTIONBAR_CONTROL = 101; /** * @brief * Describes printing options for the Calendar Control. * * @details * Use this class when you want to programmatically customize printing * options for the Calendar control. * * See each property description to examine which customization options * are available. * * @see CXTPPrintOptions * @see CXTPCalendarPageSetupDialog overview */ class _XTP_EXT_CLASS CXTPCalendarControlViewPrintOptions : public CXTPPrintOptions { /** @cond */ DECLARE_DYNAMIC(CXTPCalendarControlViewPrintOptions) /** @endcond */ public: /** * @brief * Default constructor. */ CXTPCalendarControlViewPrintOptions(); COleDateTime m_dtPrintFrom; /**< Top bound of the printing area for a day view.*/ COleDateTime m_dtPrintTo; /**< Bottom bound of the printing area for a day view.*/ BOOL m_bPrintFromToExactly; /**< Defines whether to cut printing area by showing only area between m_dtPrintFrom and m_dtPrintTo*/ COleDateTime m_dtMonthViewPrintBeginDate; /**< Begin date to print for multi month print option*/ COleDateTime m_dtMonthViewPrintEndDate; /**< End date to print for multi month print option*/ BOOL m_bPrintDateHeader; /**< Defines whether to print a date header or not.*/ LOGFONT m_lfDateHeaderFont; /**< Font for day header caption (Day 1 - Day 2)*/ LOGFONT m_lfDateHeaderWeekDayFont; /**< Font for day header week day(Monday, ...)*/ LOGFONT m_lfDateHeaderCalendarFont; /**< Font for day header small calendar.*/ BOOL m_b3SmallCal; /**< Print 3 small calendars in header instead of 1.*/ // BOOL m_bNoBackGround; // BOOL m_bGrayBackGround; // BOOL m_bGrayEventBackGround; /** * @brief * Copies all print options from a specified PrintOptions object. * * @param pSrc - Pointer to the object to copy options from. */ void Set(const CXTPCalendarControlViewPrintOptions* pSrc); /** * @brief * Override this member function in a derived class to retrieve * the active locale ID. * * @return Locale ID. Base implementation returns LOCALE_USER_DEFAULT; */ virtual LCID GetActiveLCID(); protected: # ifdef _XTP_ACTIVEX DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPCalendarControlViewPrintOptions); afx_msg LPFONTDISP OleGetDateHeaderFont(); afx_msg void OleSetDateHeaderFont(LPFONTDISP pFontDisp); afx_msg LPFONTDISP OleGetDateHeaderWeekDayFont(); afx_msg void OleSetDateHeaderWeekDayFont(LPFONTDISP pFontDisp); afx_msg LPFONTDISP OleGetDateHeaderCalendarFont(); afx_msg void OleSetDateHeaderCalendarFont(LPFONTDISP pFontDisp); # endif }; /** * @brief * Customized Calendar control page setup dialog. * * @details * Use this class when you want to allow users to customize printing * options for the Calendar control. * * This class enhances standard MFC page setup dialog, which encapsulates * the services provided by the Windows common OLE Page Setup dialog box * with additional support for setting and modifying print margins. * This class is designed to take the place of the Print Setup dialog box. * * @see CXTPCalendarControlViewPrintOptions overview * @see CPageSetupDialog overview */ class _XTP_EXT_CLASS CXTPCalendarPageSetupDialog : public CPageSetupDialog { public: enum { IDD = XTP_IDD_CALENDAR_PRINT_PAGE_SETUP }; /** * @brief * Class constructor. * * @param pOptions A pointer to an associated CXTPCalendarControlViewPrintOptions * object for storing user's interaction results. * @param dwFlags One or more flags you can use to customize the settings * of the dialog box. The values can be combined using the * bitwise-OR operator. For more details see CPageSetupDialog::CPageSetupDialog. * @param pParentWnd Pointer to the dialog box's parent or owner. * * @details * Use the DoModal function to display the dialog box. * * @see CPageSetupDialog::CPageSetupDialog() */ CXTPCalendarPageSetupDialog(CXTPCalendarControlViewPrintOptions* pOptions, DWORD dwFlags = PSD_MARGINS | PSD_INWININIINTLMEASURE, CWnd* pParentWnd = NULL); /** * @brief * Default class constructor, handles members cleanup. */ virtual ~CXTPCalendarPageSetupDialog(); protected: CXTPCalendarControlViewPrintOptions* m_pOptions; /**< Pointer to associated print options object.*/ CComboBox m_ctrlPrintFromCmb; /**< A combo for choosing CXTPCalendarControlViewPrintOptions::m_dtPrintFrom value*/ CComboBox m_ctrlPrintToCmb; /**< A combo for choosing CXTPCalendarControlViewPrintOptions::m_dtPrintTo value*/ CButton m_ctrlPrintFromTo; /**< A check box for editing CXTPCalendarControlViewPrintOptions::m_bPrintFromToExactly value*/ CButton m_ctrlPrintDateHeader; /**< A check box for editing CXTPCalendarControlViewPrintOptions::m_bPrintDateHeader value*/ CStatic m_ctrlDateHeaderFontLabel; /**< A label for displaying CXTPCalendarControlViewPrintOptions::m_lfDateHeaderFont caption*/ CEdit m_ctrlDateHeaderFont; /**< A label for displaying CXTPCalendarControlViewPrintOptions::m_lfDateHeaderFont value*/ CButton m_ctrlDateHeaderFontButton; /**< A button for choosing CXTPCalendarControlViewPrintOptions::m_lfDateHeaderFont value*/ CButton m_ctrlBlackWhitePrinting; /**< A check box for editing CXTPCalendarControlViewPrintOptions::m_bBlackWhitePrinting value*/ CButton m_ctrl3SmallCal; /**< A check box for setting CXTPCalendarControlViewPrintOptions::m_b3SmallCal value*/ LOGFONT m_lfDateHeader; /**< a date time picker for begin date in month view printing*/ CDateTimeCtrl m_ctrlMonthViewPrintFrom; /**< a date time picker for end date in month view printing*/ CDateTimeCtrl m_ctrlMonthViewPrintTo; /**< a check box which swithes between use or not multimonth printing option*/ CButton m_ctrlMonthViewPrintRange; /**< Date header font temporary storage*/ CEdit m_ctrlHeaderFormat; /**< An edit for header format string*/ CEdit m_ctrlFooterFormat; /**< An edit for footer format string*/ CButton m_ctrlHeaderFormatBtn; /**< A button to show header specifiers menu*/ CButton m_ctrlFooterFormatBtn; /**< A button to show footer specifiers menu*/ /** * @brief * Converts a font name to a human readable string. * * @param lfFont A reference to a font. * * @return A string describing a provided font. */ CString FormatFontName(const LOGFONT& lfFont); /** * @brief * Dialog-box initialization. * * @return FALSE because it has explicitly set the input focus to one of the * controls in the dialog box. * * @see CPageSetupDialog::OnInitDialog() */ virtual BOOL OnInitDialog(); /** * @brief * Called when the user clicks the OK button (the button with an ID of IDOK). * * @details * Saves all values into m_pOptions structure. * * @see CPageSetupDialog::OnOK() */ virtual void OnOK(); /** * @brief * Called when the user clicks the Print Date Header check box. * * @details * Enables/disables all controls related to configuring a Date Header. */ afx_msg void OnBnClickedPrintDateHeader(); /** * @brief * Called when the user clicks the Date Header font button. * @details * Shows standard Font dialog in order to customize a Date Header font. */ afx_msg void OnBnClickedDateHeaderFont(); afx_msg void OnBnClickedHeaderFormat(); afx_msg void OnBnClickedFooterFormat(); afx_msg void OnBnClickedMonthViewPrintRange(); DECLARE_MESSAGE_MAP() void UpdateMonthViewDateControls(); }; /** * @brief * The CXTPCalendarControlView class provides an implementation of * the Calendar control as a view class. Use the GetCalendarCtrl() method * to access methods of CXTPCalendarControl. * * @see CXTPCalendarControl */ class _XTP_EXT_CLASS CXTPCalendarControlView : public CView { /** @cond */ DECLARE_DYNCREATE(CXTPCalendarControlView) /** @endcond */ protected: /** * @brief * Protected constructor used by dynamic creation. */ CXTPCalendarControlView(); public: /** * @brief * Call this method to access a Calendar control object. * * @return Reference to a child CXTPCalendarControl window. */ virtual CXTPCalendarControl& GetCalendarCtrl(); /** * @brief * Call this method to access a CaptionBar control object. * * @return Reference to a child GetCalendarCaptionBarCtrl window. */ virtual CXTPCalendarCaptionBarControl& GetCalendarCaptionBarCtrl(); /** * @brief * Call this method to set a custom Calendar control object. * * @param pCalendar Pointer to custom report object. * @param bReleaseWhenDestroy Set this parameter as TRUE to call InternalRelease * for pCalendar object on destroy of * CXTPCalendarControlView. */ virtual void SetCalendarCtrl(CXTPCalendarControl* pCalendar, BOOL bReleaseWhenDestroy = TRUE); /** * @brief * Call this method to access print options for this view. * * @return Pointer to an object describing print options of this view. */ CXTPCalendarControlViewPrintOptions* GetPrintOptions() const; /** * @brief * Use this member function to set external scroll bar control. * * @param pScrollBar Pointer to a scrollbar object. * @param nBar Specifies the bar orientation either SB_VERT or SB_HORZ. * * @see CScrollBar */ void SetScrollBarCtrl(CScrollBar* pScrollBar, int nBar = SB_VERT); /** * @brief * Call this method to retrieve a Caption Bar control's visible state. * * @return TRUE if the Caption Bar is visible, FALSE otherwise. * * @see ShowCaptionBar * @see CXTPCalendarCaptionBarControl */ virtual BOOL IsShowCaptionBar() const; /** * @brief * Call this method to show or hide a Caption Bar control. * * @param bShow Set this parameter as TRUE to show Caption Bar and as FALSE to hide it. * * @see IsShowCaptionBar * @see CXTPCalendarCaptionBarControl */ virtual void ShowCaptionBar(BOOL bShow); // move to public area virtual void _ResizeControls(); protected: /** * @brief * Destroys a CXTPCalendarControlView object, handles cleanup and deallocation. */ virtual ~CXTPCalendarControlView(); protected: /** * @brief * Draws main (central) date header area. * * @param bCalculate If TRUE, then only calculate rectangles and do not * performs drawing itself. * @param pDC Pointer to a valid device context. * @param rrcHeader [out] Drawn rectangle area. */ virtual void DrawDateHeader(BOOL bCalculate, CDC* pDC, CRect& rrcHeader); /** * @brief * Draws month calendar in the right part of the central date header * area. * * @param bCalculate If TRUE, then only calculate rectangles and do not * performs drawing itself. * @param pDC Pointer to a valid device context. * @param dtYearMonth Which month's calendar to draw. * @param rrcHeaderCalendar [out] Drawn rectangle area. */ virtual void _DrawDateHeaderCalendar(BOOL bCalculate, CDC* pDC, COleDateTime dtYearMonth, CRect& rrcHeaderCalendar); /** * @brief * Calculates a number of shown months and captions for them to be * drawn on the date header. * * @param dtYearMonth1 Bottom boundary of the date period. * @param dtYearMonth2 Top boundary of the date period. * @param strHeader1 [out] Bottom boundary caption. * @param strHeader2 [out] Top boundary caption. * @param strHeaderWeekDay [out] Week day name (for a single day view only). * * @return A number of months between the bottom and top boundaries, including them. */ virtual int _GetDateHeaderMonths(COleDateTime& dtYearMonth1, COleDateTime& dtYearMonth2, CString& strHeader1, CString& strHeader2, CString& strHeaderWeekDay); /** * @brief * Adjusts a calendar printing rectangle by adding space for a header, * footer and similar areas. * * @param pDC Pointer to a valid device context. * @param rcCalendar Calendar printing rectangle. * @param pInfo Pointer to calendar Print Options object. * * @return An adjusted calendar printing rectangle. */ virtual CRect AdjustCalendarForPrint(CDC* pDC, CRect rcCalendar, CPrintInfo* pInfo); /** * @brief * Converts a rectangle of HIMETRIC units into logical units. * * @param pDC Pointer to a valid device context. * @param rcHimetric A rectangle to convert in HIMETRIC units. * * @details * Use this function when you get HIMETRIC sizes from OLE and wish to * convert them to your application's natural mapping mode. * The conversion is accomplished by first converting the HIMETRIC * units into pixels and then converting these units into logical * units using the device context's current mapping units. Note that * the extents of the device's window and viewport will affect the result. * * @return A converted rectangle in logical units. * * @see CDC::HIMETRICtoLP() */ static CRect AFX_CDECL _HimetricToLP(CDC* pDC, const CRect rcHimetric); protected: COleDateTime m_dtPrintFrom; /**< Top bound of the printing area for a day view.*/ COleDateTime m_dtPrintTo; /**< Bottom bound of the printing area for a day view.*/ # ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; # endif DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPCalendarControlView) virtual void OnDraw(CDC* pDC); CScrollBar* GetScrollBarCtrl(int nBar) const; virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo); virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo); virtual void _OnPrint2(CDC* pDC, CPrintInfo* pInfo, CRect rcPrint); //}}AFX_VIRTUAL void DoPrintPage(CDC* pDC, CPrintInfo* pInfo); void SetupCurrentPrintPage(CDC* pDC, CPrintInfo* pInfo); void SetupCurrentDayViewPrintPage(CDC* pDC, CPrintInfo* pInfo); void SetupCurrentMonthViewPrintPage(CPrintInfo* pInfo); void SelectNextPrintPage(CPrintInfo* pInfo); void SelectNextDayViewPrintPage(CPrintInfo* pInfo); CRect ExcludeMarginsFromDrawRect(CDC* pDC, CPrintInfo* pInfo); UINT CalculateMonthViewPrintPagesCount(); //{{AFX_MSG(CXTPCalendarControlView) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnSetFocus(CWnd* pOldWnd); afx_msg void OnPaint(); afx_msg void OnUndo(); afx_msg void OnCut(); afx_msg void OnCopy(); afx_msg void OnPaste(); afx_msg void OnSelectAll(); afx_msg void OnUpdateCommand(CCmdUI* pCmdUI); afx_msg void OnFilePageSetup(); //}}AFX_MSG protected: class CPritAdjustContext { public: CPritAdjustContext() { Reset(); } void Reset() { m_bAdjust = TRUE; m_rcCalendar.SetRectEmpty(); m_rectDraw_prev.SetRectEmpty(); m_rcDateHeader.SetRectEmpty(); m_rcFooter.SetRectEmpty(); m_rcHeader.SetRectEmpty(); } BOOL m_bAdjust; CRect m_rcHeader; CRect m_rcDateHeader; CRect m_rcCalendar; CRect m_rcFooter; CRect m_rectDraw_prev; }; class CBeforePrintState { public: CBeforePrintState(); public: void ClearData(); void Save(CXTPCalendarControlView* pView); void Restore(CXTPCalendarControlView* pView); public: BOOL m_bDataValid; COleDateTimeSpan m_spScale_orig; int m_nTopRow; }; CBeforePrintState m_beforePrintState; CPritAdjustContext m_pritAdjustContext; CXTPCalendarControl::CUpdateContext* m_pUpdateContext; CBitmap m_bmpGrayDC; friend class CCalendarControlCtrl; friend class CBeforePrintState; protected: void CalendarDayView_ScrolV(int nTopRow); CXTPNotifySink* m_pSink; virtual void OnEvent_CalendarThemeChanged(XTP_NOTIFY_CODE Event, WPARAM wParam, LPARAM lParam); protected: CXTPCalendarControlViewPrintOptions* m_pPrintOptions; /**< Printing options.*/ BOOL m_bShowCaptionBar; /**< Store Office 2007 theme Calendar Caption Bar state.*/ private: CXTPCalendarCaptionBarControl m_wndCalendarCaptionBar; /**< Child Calendar Caption Bar window*/ CXTPCalendarControl* m_pCalendar; /**< Child Calendar control pointer (used to set external calendar control).*/ BOOL m_bReleaseCalendarWhenDestroy; CScrollBar* m_pVScrollBar; CScrollBar* m_pHScrollBar; BOOL m_bDayViewMode; /**