/** * @file XTPScrollBarContainer.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(__XTPSCROLLBARCONTAINER_H__) # define __XTPSCROLLBARCONTAINER_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPScrollBarCtrl; /** @cond */ class _XTP_EXT_CLASS CXTPScrollBarContainerImpl { public: CXTPScrollBarContainerImpl(); ~CXTPScrollBarContainerImpl(); void SetContainer(CWnd* pContainer); BOOL CreateScrollBarCtrl(DWORD dwStyle, UINT nID); void DestroyScrollBarCtrl(UINT nID); void SetScrollBarClass(CRuntimeClass* pClass = NULL); CScrollBar* GetScrollBarCtrl(int nBar); void SetScrollBarTheme(XTPScrollBarTheme theme); void ShowScrollBar(UINT nBar, BOOL bShow); BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH); void RefreshMetrics(); void OnWindowProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& lResult); void OptimizeChildrenClipping(); private: struct STDSCROLLBAR { STDSCROLLBAR(); ~STDSCROLLBAR(); CXTPScrollBarCtrl* operator->() throw(); const CXTPScrollBarCtrl* operator->() const throw(); CXTPScrollBarCtrl* pCtrl; BOOL bVisible; }; enum StdScrollBarId { SbInvalid = -1, SbHorz = 0, SbVert = 1, SbGripper = 2 }; void OnCreate(LPCREATESTRUCT lpCreateStruct); void OnWindowPosChange(WINDOWPOS* lpWndPos); void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS* lpncsp); void OnStyleChanged(LONG nType, LPSTYLESTRUCT pStyleStruct); BOOL HasStdBar(StdScrollBarId nBar) const; CScrollBar* CreateStdScrollBar(StdScrollBarId nBar); void DestroyStdScrollBar(StdScrollBarId nBar); void RepositionStdScrollBars(const RECT* lpRect = NULL); static StdScrollBarId AFX_CDECL SBtoSBId(int nBar); static UINT AFX_CDECL SBIdToSBWs(StdScrollBarId nBar); static int AFX_CDECL SBIdToSB(StdScrollBarId nBar); void ShowScrollBarInternal(StdScrollBarId nBar, BOOL bShow); void SyncStdScrollBarStates(); CSize GetContainerBorder(); BOOL m_bCreated; STDSCROLLBAR m_StdScrollBar[3]; CWnd* m_pContainer; XTPScrollBarTheme m_nTheme; CList m_ScrollBars; BOOL m_bRightFrameAdjusted; BOOL m_bBottomFrameAdjusted; CRuntimeClass* m_pScrollBarClass; }; /** @endcond */ /** * @brief * CXTPScrollBarContainer class adds XTP scroll bars to a class * derived from CWnd. */ template class CXTPScrollBarContainer : public Parent { protected: /** * @brief * Constructs a CXTPScrollBarContainer object. * Forces the class to be inherited only, not instantiated. */ CXTPScrollBarContainer() { m_Impl.SetContainer(this); } public: //{{AFX_VIRTUAL(CXTPScrollBarContainer) virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { LRESULT lResult = Parent::WindowProc(message, wParam, lParam); m_Impl.OnWindowProc(message, wParam, lParam, lResult); return lResult; } //}}AFX_VIRTUAL /** * @brief * Sets scroll bar theme. * @param theme scroll bar theme identifier. */ void SetScrollBarTheme(XTPScrollBarTheme theme) { m_Impl.SetScrollBarTheme(theme); RefreshScrollBarMetrics(); } /** * @brief * Creates a scroll bar control with ID and style specied. * @param dwStyle scroll bar style. * @param nID scroll bar control ID. * @return * TRUE if succeeded. */ BOOL CreateScrollBarCtrl(DWORD dwStyle, UINT nID) { return m_Impl.CreateScrollBarCtrl(dwStyle, nID); } /** * @brief * Call this member function to obtain a pointer to the specified * sibling scroll bar or splitter window. * @param nBar Specifies the type of scroll bar. * @return Returns a pointer to the specified sibling */ virtual CScrollBar* GetScrollBarCtrl(int nBar) const { return const_cast(m_Impl).GetScrollBarCtrl(nBar); } /** * @brief * Shows or hides a scroll bar. * @param nBar Specifies the type of scroll bar. * @param bShow Specifies whether Windows shows or hides the scroll bar. */ void ShowScrollBar(UINT nBar, BOOL bShow = TRUE) { m_Impl.ShowScrollBar(nBar, bShow); } /** * @brief * Enables or disables one or both arrows of a scroll bar. * @param nSBFlags Specifies the scroll-bar type. * @param nArrowFlags Specifies whether the scroll-bar arrows are enabled * or disabled and which arrows are enabled or disabled. * @return True = enable, False = disable */ BOOL EnableScrollBar(int nSBFlags, UINT nArrowFlags = ESB_ENABLE_BOTH) { return m_Impl.EnableScrollBar(nSBFlags, nArrowFlags); } /** * @brief * Triggers update of color and size information for themed * scroll bars. */ void RefreshScrollBarMetrics() { m_Impl.RefreshMetrics(); } /** * @brief * Applies WS_CLIPCHILDREN and WS_CLIPSIBLINGS styles the the container * owner and all its immediate children windows in order prevent * possible overlapping of children controls with scroll bars. */ void OptimizeChildrenClipping() { m_Impl.OptimizeChildrenClipping(); } /** * @brief Sets a scroll bar class to be used for creating scroll bars. * @param pClass A scroll bar class pointer. The class must be derived * from CXTPScrollBarCtrl. NULL indicates CXTPScrollBarCtrl * to be used by default. */ void SetScrollBarClass(CRuntimeClass* pClass = NULL) { m_Impl.SetScrollBarClass(pClass); } private: CXTPScrollBarContainerImpl m_Impl; }; /** * @brief * CXTPDialogScrollBarContainer class adds XTP scroll bars to a class * derived from CDialog. The parent class must have CDialog constructors. */ template class CXTPDialogScrollBarContainer : public CXTPScrollBarContainer { protected: /** * @brief * Constructs a CXTPDialogScrollBarContainer object. */ CXTPDialogScrollBarContainer() { } /** * @brief * Constructs a CXTPDialogScrollBarContainer object. * @param lpszTemplateName Contains a null-terminated string that is the * name of a dialog-box template resource. * @param pParentWnd Contains the ID number of a dialog-box template * resource. */ explicit CXTPDialogScrollBarContainer(LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL) { new (static_cast(this)) Parent(lpszTemplateName, pParentWnd); } /** * @brief * Constructs a CXTPDialogScrollBarContainer object. * @param nIDTemplate Resource ID for the string that is the * name of a dialog-box template resource. * @param pParentWnd Points to the parent or owner window object * (of type CWnd) to which the dialog object belongs. * If it is NULL, the dialog object's parent window is set * to the main application window. */ explicit CXTPDialogScrollBarContainer(UINT nIDTemplate, CWnd* pParentWnd = NULL) { new (static_cast(this)) Parent(nIDTemplate, pParentWnd); } }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSCROLLBARCONTAINER_H__ /** @endcond */