/** * @file XTPGridView.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 * */ /** @cond */ #if !defined(__XTPGRIDVIEW_H__) # define __XTPGRIDVIEW_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPGridViewPrintOptions; class CXTPGridControl; class CXTPGridPaintManager; /** * @brief * Identifier for a Grid control child window of CXTPGridView. * * Example: *
* int CXTPGridView::OnCreate(LPCREATESTRUCT lpCreateStruct)
* {
* if (CView::OnCreate(lpCreateStruct) == -1)
* return -1;
*
* if (!m_wndGrid.Create(WS_CHILD | WS_TABSTOP | WS_VISIBLE | WM_VSCROLL,
* CRect(0, 0, 0, 0), this, XTP_ID_GRID_CONTROL))
* {
* TRACE(_T("Failed to create tab control window\n"));
* return -1;
* }
* return 0;
* }
*
* @see
* XTP_NM_GRID_CHECKED, XTP_NM_GRID_COLUMNORDERCHANGED, XTP_NM_GRID_HEADER_RCLICK,
* XTP_NM_GRID_HYPERLINK, XTP_NM_GRID_INPLACEBUTTONDOWN, XTP_NM_GRID_SELCHANGED
* XTP_NM_GRID_SORTORDERCHANGED, XTP_NM_GRID_VALUECHANGED
* CXTPGridView, CXTPGridControl, CXTPGridHeader
*/
const UINT XTP_ID_GRID_CONTROL = 100;
/**
* @brief
* The CXTPGridView class provides an implementation of the Grid control as a
* view class. Use the GetGridCtrl method to access methods of CXTPGridControl.
* @see
* CXTPGridControl
*/
class _XTP_EXT_CLASS CXTPGridView : public CView
{
/** @cond */
DECLARE_DYNCREATE(CXTPGridView)
/** @endcond */
protected:
/**
* @brief
* Protected constructor used by dynamic creation.
*/
CXTPGridView();
BOOL m_bSwitchMode; /**< Tells whether to switch between modes (icon and grid). */
BOOL m_bShowRowNumber; /**< TRUE to show the row number, FALSE otherwise. */
public:
/**
* @brief
* Sets the Grid control theme.
* @param paintTheme Grid control theme; must be one of the values
* listed in the Remarks section.
* @param bEnableMetrics TRUE to allow the theme to override control metrics.
* @details
* paintTheme can be one of the following values:
* xtpGridThemeDefault: Enables default theme.
* xtpGridThemeOfficeXP: Enables Office XP style theme.
* xtpGridThemeOffice2003: Enables Office 2003 style theme.
* xtpGridThemeOffice2007: Enables Office 2007 style theme.
* xtpGridThemeOffice2010: Enables Office 2010 style theme.
* xtpGridThemeOffice2013: Enables Office 2013 style theme.
* xtpGridThemeVisualStudio2005: Enables Visual Studio 2005 style theme.
* xtpGridThemeVisualStudio2010: Enables Visual Studio 2010 style theme.
* xtpGridThemeVisualStudio2012Light: Enables VS 2012 Light style
* Property Grid theme.
* xtpGridThemeVisualStudio2012Dark: Enables VS 2012 Dark style
* Property Grid theme.
* xtpGridThemeResource: Enables visual style theme.
*/
void SetTheme(XTPGridPaintTheme paintTheme, BOOL bEnableMetrics = FALSE);
/**
* @brief
* Gets the Grid control.
* @return
* A reference to the Grid control object.
*/
virtual CXTPGridControl& GetGridCtrl() const;
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(GetGridCtrl)
virtual CXTPGridControl& GetReportCtrl() const;
/** @endcond */
/**
* @brief
* Sets the Grid control.
* @param pGrid Pointer to the Grid control object to be set.
*/
void SetGridCtrl(CXTPGridControl* pGrid);
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(SetGridCtrl)
void SetReportCtrl(CXTPGridControl* pGrid);
/** @endcond */
/**
* @brief
* Gets the paint manager of the Grid control.
* @return
* A pointer to the paint manager of the Grid control.
*/
CXTPGridPaintManager* GetPaintManager() const;
/**
* @brief
* Gets the print options of this view.
* @return
* A pointer to a CXTPGridViewPrintOptions object describing
* the print options of this view.
*/
CXTPGridViewPrintOptions* GetPrintOptions() const;
protected:
/**
* @brief
* Destroys a CXTPGridView object, handles cleanup and deallocation.
*/
virtual ~CXTPGridView();
protected:
/**
* @brief
* Prints a single page of the Grid control.
* @param pDC Pointer to a device context for page output.
* @param pInfo Pointer to a CPrintInfo structure that describes the
* current print job.
* @param rcPage Page bounding rectangle.
* @param nRowFrom First row to print.
* @param nColumnFrom First column to print.
* @param nColumnTo Next column after the last column to print.
* @details
* This method prints the page header, page footer, and calls
* the PrintGrid method.
* @return
* The index of the last printed row.
*/
virtual int PrintPage(CDC* pDC, CPrintInfo* pInfo, CRect rcPage, int nRowFrom, int nColumnFrom,
int nColumnTo);
/**
* @brief
* Prints the Grid control (columns, header, and rows) on the page.
* @param pDC Pointer to a device context for page output.
* @param pInfo Pointer to a CPrintInfo structure that describes the
* current print job.
* @param rcPage Page bounding rectangle.
* @param nRowFrom First row to print.
* @param nColumnFrom First column to print.
* @param nColumnTo Next column after the last column to print.
* @details
* This method calls the PrintHeader and PrintRows methods.
* @return
* The index of the last printed row.
*/
virtual int PrintGrid(CDC* pDC, CPrintInfo* pInfo, CRect rcPage, int nRowFrom, int nColumnFrom,
int nColumnTo);
/**
* @brief
* Prints the header of each page.
* @param pDC Pointer to a device context for page output.
* @param rcHeader Header bounding rectangle.
*/
virtual void PrintHeader(CDC* pDC, CRect rcHeader);
/**
* @brief
* Prints the footer of each page.
* @param pDC Pointer to a device context for page output.
* @param rcFooter Footer bounding rectangle.
*/
virtual void PrintFooter(CDC* pDC, CRect rcFooter);
/**
* @brief
* Prints the page header of the Grid control.
* @param pDC Pointer to a device context for page output.
* @param pInfo Pointer to a CPrintInfo structure that
* describes the current print job.
* @param rcPage Page print area.
* @param bOnlyCalculate TRUE to only calculate,
* FALSE to calculate and print.
* @param nPageNumber The printed page number.
* @param nNumberOfPages The total number of printed pages.
* @param nHorizontalPageNumber The printed horizontal page number.
* @param nNumberOfHorizontalPages The total number of printed horizontal pages.
* @return
* The header height in device units.
*/
virtual int PrintPageHeader(CDC* pDC, CPrintInfo* pInfo, CRect rcPage, BOOL bOnlyCalculate,
int nPageNumber, int nNumberOfPages, int nHorizontalPageNumber,
int nNumberOfHorizontalPages);
/**
* @brief
* Prints the page footer of the Grid control.
* @param pDC Pointer to a device context for page output.
* @param pInfo Pointer to a CPrintInfo structure that
* describes the current print job.
* @param rcPage Page print area.
* @param bOnlyCalculate TRUE to only calculate,
* FALSE to calculate and print.
* @param nPageNumber The printed page number.
* @param nNumberOfPages The total number of printed pages.
* @param nHorizontalPageNumber The printed horizontal page number.
* @param nNumberOfHorizontalPages The total number of printed horizontal pages.
* @return
* The footer height in device units.
*/
virtual int PrintPageFooter(CDC* pDC, CPrintInfo* pInfo, CRect rcPage, BOOL bOnlyCalculate,
int nPageNumber, int nNumberOfPages, int nHorizontalPageNumber,
int nNumberOfHorizontalPages);
/**
* @brief
* Sets the external scrollbar control.
* @param pScrollBar Pointer to a CScrollBar object.
* @param bHor Orientation flag; TRUE for a horizontal scrollbar,
* FALSE for a vertical scrollbar.
* @see
* CScrollBar
*/
void SetScrollBarCtrl(CScrollBar* pScrollBar, BOOL bHor = FALSE);
/**
* @brief
* Sets the external slider control.
* @param pSlider Pointer to a CSliderCtrl object.
*/
void SetSliderCtrl(CSliderCtrl* pSlider);
/**
* @brief
* Prints either the header or footer divider.
* @param pDC Pointer to a device context for page output.
* @param rc Reference to the bounding rectangle of the divider.
* @param bHeaderRows TRUE to print the header divider,
* FALSE to print the footer divider.
* @return
* The height of the printed divider.
*/
int PrintFixedRowsDivider(CDC* pDC, const CRect& rc, BOOL bHeaderRows);
/**
* @brief
* Prepares an array of columns for printing.
* @param pDC Pointer to a device context for page output.
* @param pInfo Printing information.
* @return
* The number of columns prepared for printing.
*/
int SetupStartCol(CDC* pDC, CPrintInfo* pInfo);
/**
* @brief
* Retrieves a specified scrollbar control.
* @param nBar Orientation flag; SB_HORZ to retrieve a horizontal scrollbar,
* SB_VERT to retrieve a vertical scrollbar.
* @return
* A pointer to a CScrollBar object.
*/
CScrollBar* GetScrollBarCtrl(int nBar) const;
public:
/**
* @brief
* Updates the visibility and positions of scrollbars.
*/
void UpdateScrollBars();
protected:
/** @cond */
# ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
# endif
protected:
DECLARE_MESSAGE_MAP()
//{{AFX_VIRTUAL(CXTPGridView)
virtual BOOL PaginateTo(CDC* pDC, CPrintInfo* pInfo);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo);
virtual void OnDraw(CDC* pDC);
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);
//}}AFX_VIRTUAL
//{{AFX_MSG(CXTPGridView)
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnPaint();
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
afx_msg void OnEditCut();
afx_msg void OnEditCopy();
afx_msg void OnEditPaste();
afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
afx_msg void OnFilePageSetup();
//}}AFX_MSG
/** @endcond */
protected:
CBitmap m_bmpGrayDC; /**< A temporary bitmap to convert a colored Grid control image to 'gray'
colors when printing in black and white mode. */
CXTPGridControl m_wndGrid; /**< Child Grid control window. */
CXTPGridControl* m_pGrid; /**< Child Grid control pointer. */
BOOL m_bPrintSelection; /**< TRUE if only printing the currently selected rows in the grid,
FALSE if printing the entire grid. */
CXTPGridViewPrintOptions* m_pPrintOptions; /**< Printing options. */
CXTPScrollBarCtrl m_wndVScrollBar;
CXTPScrollBarCtrl m_wndHScrollBar;
CScrollBar* m_pScrollBarVer; /**< Pointer to external vertical scrollbar control. */
CScrollBar* m_pScrollBarHor; /**< Pointer to external horizontal scrollbar control. */
/** @cond */
CSliderCtrl* m_pSlider;
friend class CGridControlCtrl;
int m_nColumnStart; /**< Starting index of the current printed range of columns. */
int m_nColumnEnd; /**< Ending (or next starting) index of the current range of columns. */
UINT m_nStartIndex; /**< Index of the current printed virtual page (in
CXTPGridPaintManager::m_arStartCol). */
CUIntArray m_aPageStart; /**< Array of indexes for the top rows of every printed page. */
BOOL m_bPaginated;
/** @endcond */
public:
BOOL m_bAllowCut; /**< If TRUE, then the cut operation is allowed. */
BOOL m_bAllowPaste; /**< If TRUE, then the paste operation is allowed. */
BOOL m_bPrintDirect; /**< If TRUE, then the print dialog is bypassed. FALSE by default. */
BOOL m_bResizeControlWithView; /**< If FALSE, then the attached Grid control will not be resized
with the view. TRUE by default. */
};
AFX_INLINE CXTPGridViewPrintOptions* CXTPGridView::GetPrintOptions() const
{
return m_pPrintOptions;
}
/** @cond */
AFX_INLINE void CXTPGridView::SetReportCtrl(CXTPGridControl* pGrid)
{
SetGridCtrl(pGrid);
}
AFX_INLINE CXTPGridControl& CXTPGridView::GetReportCtrl() const
{
return GetGridCtrl();
}
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
#endif // !defined(__XTPGRIDVIEW_H__)
/** @endcond */