/** * @file XTPScrollBase.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(__XTPSCROLLBASE_H__) # define __XTPSCROLLBASE_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPWinThemeWrapper; # define XTP_HTSCROLLUP 60 /**< Scroll up hit test. @see CXTPScrollBase::HitTestScrollBar */ # define XTP_HTSCROLLDOWN \ 61 /**< Scroll down hit test. @see CXTPScrollBase::HitTestScrollBar \ \ \ \ */ # define XTP_HTSCROLLLEFT \ 60 /**< Scroll left hit test. @see CXTPScrollBase::HitTestScrollBar \ \ \ \ */ # define XTP_HTSCROLLRIGHT \ 61 /**< Scroll right hit test. @see CXTPScrollBase::HitTestScrollBar */ # define XTP_HTSCROLLUPPAGE \ 62 /**< Scroll up page hit test. @see CXTPScrollBase::HitTestScrollBar */ # define XTP_HTSCROLLDOWNPAGE \ 63 /**< Scroll down page hit test. @see CXTPScrollBase::HitTestScrollBar */ # define XTP_HTSCROLLTHUMB \ 64 /**< Scroll thumb hit test. @see CXTPScrollBase::HitTestScrollBar */ # define XTP_HTSCROLLPOPUP \ 65 /**< Scroll popup hit test. @see CXTPScrollBase::HitTestScrollBar */ # define IDSYS_SCROLL 23345 # define IDSYS_ANIMATE 23346 /** * @brief * Scrollbar style * @see * CXTPScrollBase::SetScrollBarStyle */ enum XTPScrollBarStyle { xtpScrollStyleDefault, /**< Default style */ xtpScrollStyleStandard, /**< standard window theme */ xtpScrollStyleFlat, /**< Flat scrollbar style */ xtpScrollStyleSystem, /**< WinXP themed style */ xtpScrollStyleOffice, /**< Office scrollbar style */ xtpScrollStyleOffice2007Light, /**< Office 2007 light style */ xtpScrollStyleOffice2007Dark, /**< Office 2007 dark style */ xtpScrollStyleSlider, /**< Makes the scrollbar look like a slider control. */ xtpScrollStyleVisualStudio2012Light, /**< Visual Studio 2012 Light */ xtpScrollStyleVisualStudio2012Dark, /**< Visual Studio 2012 Dark */ xtpScrollStyleVisualStudio2015, /**< Visual Studio 2015 */ xtpScrollStyleNativeWindows10, /**< Native Windows 10 */ xtpScrollStyleVisualStudio2017, /**< Visual Studio 2017 */ xtpScrollStyleVisualStudio2019, /**< Visual Studio 2019 */ xtpScrollStyleVisualStudio2022, /**< Visual Studio 2022 */ xtpScrollStyleNativeWindows11, /**< Native Windows 11 */ }; /** * @brief * Scrollbar theme identifier enum. */ enum XTPScrollBarTheme { xtpScrollBarThemeWindowsClassic, /**< Windows classic style theme */ xtpScrollBarThemeWindowsDefault, /**< Windows default style theme */ xtpScrollBarThemeFlat, /**< Flat appearance style theme */ xtpScrollBarThemeUltraFlat, /**< Ultra flat appearance style theme */ xtpScrollBarThemeResource, /**< Resource defined theme */ xtpScrollBarThemeOffice2000, /**< Office 2000 theme */ xtpScrollBarThemeOfficeXP, /**< Office XP theme */ xtpScrollBarThemeOffice2003, /**< Office 2003 theme */ xtpScrollBarThemeOffice2007Light, /**< Office 2007 light theme */ xtpScrollBarThemeOffice2007Dark, /**< Office 2007 dark theme */ xtpScrollBarThemeOffice2010, /**< Office 2010 theme */ xtpScrollBarThemeOffice2013, /**< Office 2013 theme */ xtpScrollBarThemeOffice2016 = xtpScrollBarThemeOffice2013, /**< Office 2016 theme */ xtpScrollBarThemeVisualStudio2012Light, /**< Visual Studio 2012 light theme */ xtpScrollBarThemeVisualStudio2012Dark, /**< Visual Studio 2012 dark theme */ xtpScrollBarThemeVisualStudio2015, /**< Visual Studio 2015 theme */ xtpScrollBarThemeVisualStudio2017, /**< Visual Studio 2017 theme */ xtpScrollBarThemeVisualStudio2019, /**< Visual Studio 2019 theme */ xtpScrollBarThemeVisualStudio2022, /**< Visual Studio 2022 theme */ xtpScrollBarThemeNativeWindows10, /**< Native Windows 10 theme */ xtpScrollBarThemeNativeWindows11, /**< Native Windows 11 theme */ xtpScrollBarThemeVisualStudio6 = xtpScrollBarThemeWindowsClassic, /**< Visual Studio 6 theme */ xtpScrollBarThemeVisualStudio2002 = xtpScrollBarThemeWindowsDefault, /**< Visual Studio 2002 theme */ xtpScrollBarThemeVisualStudio2003 = xtpScrollBarThemeWindowsDefault, /**< Visual Studio 2003 theme */ xtpScrollBarThemeVisualStudio2005 = xtpScrollBarThemeWindowsDefault, /**< Visual Studio 2005 theme */ xtpScrollBarThemeVisualStudio2008 = xtpScrollBarThemeWindowsDefault, /**< Visual Studio 2008 theme */ xtpScrollBarThemeVisualStudio2010 = xtpScrollBarThemeWindowsDefault, /**< Visual Studio 2010 theme */ }; class CXTPScrollBarPaintManager; const UINT XTP_SBN_SCROLL = 0x1007; /** * @brief * The NMXTPSCROLL structure contains information about the scroll bar. */ struct NMXTPSCROLL { NMHDR hdr; /**< NMHDR structure that contains additional information about this notification. */ CObject* pSender; /**< Pointer to the object that sent the message. */ int nSBCode; /**< Scroll bar request codes, such as SB_LINEUP, SB_LINEDOWN, etc. */ int nPos; /**< Position of the scroll bar thumb. */ }; /** * @brief * The XTP_SCROLLBAR_POSINFO structure contains scroll bar information. */ struct _XTP_EXT_CLASS XTP_SCROLLBAR_POSINFO { int posMin; /**< Minimum position */ int posMax; /**< Maximum position */ int page; /**< Page size */ int pos; /**< Position of thumb */ int pxTop; /**< Top bounding rectangle */ int pxBottom; /**< Bottom bounding rectangle */ int pxLeft; /**< Left bounding rectangle */ int pxRight; /**< Right bounding rectangle */ int cpxThumb; /**< Size of thumb button */ int pxUpArrow; /**< Position of Up arrow */ int pxDownArrow; /**< Position of Down arrow */ int pxStart; /**< Previous position of thumb button */ int pxThumbBottom; /**< Thumb bottom bounding rectangle */ int pxThumbTop; /**< Thumb top bounding rectangle */ int pxPopup; /**< In-place scroll position */ int cpx; /**< position in pixels */ int pxMin; /**< Minimum position in pixels */ RECT rc; /**< Bounding rectangle */ int ht; /**< Hit test */ BOOL fVert; /**< TRUE if vertical */ BOOL fSizebox; /**< TRUE if is of size-box type, fVert is ignored. */ }; /** * @brief * The XTP_SCROLLBAR_TRACKINFO structure contains tracking information. */ struct _XTP_EXT_CLASS XTP_SCROLLBAR_TRACKINFO { BOOL fHitOld; /**< Previous hittest */ RECT rcTrack; /**< Bounding rectangle of available thumb position */ UINT cmdSB; /**< Scroll command */ UINT_PTR hTimerSB; /**< Timer identifier */ int dpxThumb; /**< Delta of thumb button */ int pxOld; /**< Previous position in pixels */ int posOld; /**< Previous position */ int posNew; /**< new position */ HWND hWndTrack; /**< Parent tracking window */ BOOL bTrackThumb; /**< TRUE if thumb is tracking */ XTP_SCROLLBAR_POSINFO* pSBInfo; /**< SCROLLBARPOSINFO pointer */ }; /** * @brief * The XTP_SLIDERTICKS structure contains slider ticks. */ struct _XTP_EXT_CLASS XTP_SLIDERTICKS { /** * @brief * Constructs an XTP_SLIDERTICKS object. * @param pTicks Point to double array * @param nCount Count of double values */ XTP_SLIDERTICKS(double* pTicks, int nCount); /** * @brief * Destroys an XTP_SLIDERTICKS object, handles cleanup and deallocation. */ ~XTP_SLIDERTICKS(); double* pTicks; /**< Ticks array */ int nCount; /**< Count of ticks */ }; _XTP_EXT_CLASS int AFX_CDECL SBPosFromPx(XTP_SCROLLBAR_POSINFO* pSBInfo, int px); _XTP_EXT_CLASS CRect AFX_CDECL OffsetSourceRect(CRect rc, int nState); /** * @brief * CXTPScrollBase is the base class for all scrollable objects. */ class _XTP_EXT_CLASS CXTPScrollBase { public: /** * @brief * Constructs a CXTPScrollBase object. */ CXTPScrollBase(); /** * @brief * Destroys a CXTPScrollBase object, handles cleanup and deallocation. */ virtual ~CXTPScrollBase(); public: /** * @brief * Call this method to set the style of the scrollbar * @param scrollStyle Style to be set; must be one of the values * defined by the XTPScrollBarStyle enumeration. * @see * GetScrollBarStyle */ void SetScrollBarStyle(XTPScrollBarStyle scrollStyle); /** * @brief * Call this method to get the style of the scrollbar * @return * Style of the scrollbar; one of the values * defined by the XTPScrollBarStyle enumeration. * @see * SetScrollBarStyle */ XTPScrollBarStyle GetScrollBarStyle() const; public: /** * @brief * Call this method to get XTP_SCROLLBAR_TRACKINFO information * @return * A pointer to XTP_SCROLLBAR_TRACKINFO information * @see * GetScrollBarPosInfo */ XTP_SCROLLBAR_TRACKINFO* GetScrollBarTrackInfo() const; /** * @brief * Call this method to get XTP_SCROLLBAR_POSINFO information * @return * A pointer to XTP_SCROLLBAR_POSINFO information * @see * GetScrollBarTrackInfo */ XTP_SCROLLBAR_POSINFO* GetScrollBarPosInfo(); /** * @brief * Retrieves parent window of scrollbar * @return * Pointer to parent window */ virtual CWnd* GetParentWindow() const = 0; /** * @brief * Call this method to check ScrollBar part under pointer. * @param pt Mouse pointer to test * @return Hit test code that is on of: *
* HTNOWHERE - No hit * XTP_HTSCROLLUP - Up arrow hit * XTP_HTSCROLLPOPUP - Popup hit * XTP_HTSCROLLDOWN - Down arrow hit * XTP_HTSCROLLUPPAGE - Scroll up page hit * XTP_HTSCROLLDOWNPAGE - Scroll down page hit * XTP_HTSCROLLTHUMB - Scroll thumb hit **/ int HitTestScrollBar(POINT pt) const; /** * @brief * Gets the bounding rectangle of a specified part of the scrollbar. * @param nPart Part of the scrollbar to get bounding rectangle of. * @return * The bounding rectangle of the specified part of the scroll bar. */ CRect GetScrollBarPartRect(int nPart) const; /** * @brief * Call this method to start scrollbar tracking * @param hWnd Parent Window handle * @param point Starting cursor position * @param pSBInfo Scrollbar information * @param bDirect TRUE to scroll to specified position */ void PerformTrackInit(HWND hWnd, CPoint point, XTP_SCROLLBAR_POSINFO* pSBInfo, BOOL bDirect); /** * @brief * Gets the ticks in the slider. * @return * An XTP_SLIDERTICKS object. */ XTP_SLIDERTICKS* GetTicks() const; /** * @brief * Call this method to set ticks for the slider. * @param pTicks Pointer to double array of ticks. * @param nCount Count of elements in array. */ void SetTicks(double* pTicks, int nCount); /** * @brief * Call this method to get the scroll bar control color. * @param pDC Pointer to device context. * @return * An RGB value representing the scroll bar control color. */ HBRUSH GetCltColor(CDC* pDC) const; public: /** * @brief * Call this member function to determine if the scrollbar is a slider control * @return * TRUE if the scrollbar is a slider control */ BOOL IsSlider() const; /** * @brief * Determines if the scrollbar is enabled. * @return * TRUE if the scrollbar is enabled. */ virtual BOOL IsScrollBarEnabled() const = 0; /** * @brief * Obtains a pointer to the associated scrollbar paint manager. * @return * A pointer to the associated scrollbar paint manager. */ virtual CXTPScrollBarPaintManager* GetScrollBarPaintManager() const = 0; /** * @brief * Obtains the rectangle occupied by the scrollbar in client coordinates. * @return * The rectangle occupied by the scrollbar in client coordinates. */ virtual CRect GetScrollBarRect() = 0; /** * @brief * The GetScrollInfo function retrieves the parameters of a scroll bar, * including the minimum and maximum scrolling positions, the page size, * and the position of the scroll box(thumb) * @param psi Pointer to a SCROLLINFO structure. Before calling GetScrollInfo, * set the cbSize member to sizeof(SCROLLINFO), and set the fMask * member to specify the scroll bar parameters to retrieve. Before returning, * the function copies the specified parameters to the appropriate members * of the structure. Refer to MSDN documentation for more details on SCROLLINFO * fields. */ virtual void GetScrollInfo(SCROLLINFO* psi) = 0; /** * @brief * Forces the scrollbar to redraw itself. */ virtual void RedrawScrollBar() = 0; /** @cond */ void EndScroll(BOOL fCancel); void MoveThumb(int px); void TrackThumb(UINT message, CPoint pt); void TrackBox(UINT message, CPoint point); void ContScroll(); virtual void DoAnimate(); /** @endcond */ protected: /** @cond */ void SetupScrollInfo(); virtual void DoScroll(int cmd, int pos) = 0; virtual void CalcScrollBarInfo(LPRECT lprc, XTP_SCROLLBAR_POSINFO* pSBInfo, SCROLLINFO* pSI); void CalcTrackDragRect(XTP_SCROLLBAR_TRACKINFO* pSBTrack) const; /** @endcond */ XTP_SCROLLBAR_POSINFO m_spi; /**< ScrollBar position. */ XTP_SCROLLBAR_TRACKINFO* m_pSBTrack; /**< ScrollBar tracking */ XTP_SLIDERTICKS* m_pTicks; /**< Slider Ticks */ XTPScrollBarStyle m_scrollBarStyle; /**< ScrollBar style */ BOOL m_bAnimation; /**< TRUE if animation enabled. */ int m_nTimerElapse; /**< Scroll delay. */ }; /** @cond */ AFX_INLINE XTP_SCROLLBAR_TRACKINFO* CXTPScrollBase::GetScrollBarTrackInfo() const { return m_pSBTrack; } AFX_INLINE XTP_SLIDERTICKS* CXTPScrollBase::GetTicks() const { return m_pTicks; } AFX_INLINE XTP_SCROLLBAR_POSINFO* CXTPScrollBase::GetScrollBarPosInfo() { return &m_spi; } AFX_INLINE void CXTPScrollBase::SetScrollBarStyle(XTPScrollBarStyle scrollStyle) { m_scrollBarStyle = scrollStyle; } AFX_INLINE BOOL CXTPScrollBase::IsSlider() const { return (m_scrollBarStyle == xtpScrollStyleSlider); } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif //#if !defined(__XTPSCROLLBASE_H__) /** @endcond */