/** * @file XTPSpinButtonCtrl.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(__XTPSPINBUTTONCTRL_H__) # define __XTPSPINBUTTONCTRL_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPEdit; class CXTPWinThemeWrapper; /** * @brief * The CXTPSpinButtonCtrl class provides the functionality of a * themed Windows spin button control. */ class _XTP_EXT_CLASS CXTPSpinButtonCtrl : public CSpinButtonCtrl { /** @cond */ DECLARE_DYNAMIC(CXTPSpinButtonCtrl) /** @endcond */ public: /** * @brief * Constructs a CXTPSpinButtonCtrl object. */ CXTPSpinButtonCtrl(); /** * @brief * Destroys a CXTPSpinButtonCtrl object, handles cleanup and deallocation. */ ~CXTPSpinButtonCtrl(); /** * @brief * Call this member to switch the visual theme of the control. * @param nTheme New visual theme. Can be any of the values listed in the Remarks section. * @details * nStyle can be one of the following: * xtpControlThemeDefault: Standard appearance style. * xtpControlThemeFlat: Flat appearance style. * xtpControlThemeUltraFlat: Ultra flat appearance style. * xtpControlThemeOffice2000: Office 2000 appearance style. * xtpControlThemeOfficeXP: Office XP appearance style. * xtpControlThemeOffice2003: Office 2003 appearance style. * xtpControlThemeResource: Office 2007 appearance style. */ void SetTheme(XTPControlTheme nTheme); /** * @brief * Determines if the control is drawn using visual styles/SkinFramework, * if supported. * @details * This method enables Windows XP visual styles for the control. * This Control will draw using visual styles if both the control * and the operating system support it. * Visual styles and SkinFramework skins are specifications for * the appearance of controls. GetUseVisualStyle determines whether * to use the currently set Windows XP visual style. If using * SkinFramework, then it determines whether to use the currently set * style of the SkinFramework. * @return * TRUE if the currently set Windows XP visual style will be used to * theme the control. If using SkinFramework, then the currently set * style of the SkinFramework will be used to skin the control. * FALSE if the currently set appearance/style in the OS will be used. */ BOOL GetUseVisualStyle() const; /** * @brief * Enables Windows XP visual styles for the control. * @details * This method enables Windows XP visual styles for the control. * This Control will draw using visual styles if both the control * and the operating system support it. * Visual styles and SkinFramework skins are specifications for * the appearance of controls. GetUseVisualStyle determines whether * to use the currently set Windows XP visual style. If using * SkinFramework, then it determines whether to use the currently set * style of the SkinFramework. * @param bUseVisualStyle TRUE if the currently set Windows XP visual style * will be used to theme the control. If using * SkinFramework, then the currently set style of the * SkinFramework will be used to skin the control. * FALSE if the currently set appearance/style in the * OS will be used. */ void SetUseVisualStyle(BOOL bUseVisualStyle = TRUE); protected: /** * @brief * Determines which spin button, if any, is at a specified position. * @param pt Point to be tested. * @return * The ID of the spin button at the position specified by pt, can * be either UD_HITNOWHERE, UD_HITDOWN, or UD_HITUP. */ UINT HitTest(CPoint pt); /** * @brief * Called by the framework to render the spin button control. * @param pDC Pointer to a valid device context. */ void OnDraw(CDC* pDC); /** * @brief * This member is called to update color, text, and other * visual elements of the control. */ void RefreshMetrics(); /** * @brief * Called to determine if the border is shared with a buddy. * @return * TRUE if the borders are shared. */ BOOL HasSharedBorder() const; /** * @brief * Called to retrieve a pointer to the CXTPEdit buddy window. * @return * A pointer to a CXTPEdit object if a buddy is available, * otherwise NULL. */ CXTPEdit* GetEditBuddy() const; /** * @brief * Called by the framework to render Windows themes for the spin * button control. * @param pDC Pointer to a valid device context. */ void DrawVisualStyle(CDC* pDC); /** * @brief * Called by the framework to render resource driven themes. * @param pDC Pointer to a valid device context. */ void DrawOffice2007(CDC* pDC); /** * @brief * Called by the framework to render flat style spin button themes. * @param pDC Pointer to a valid device context. */ void DrawFlat(CDC* pDC); /** * @brief * Called by the framework to render the button portion of the * spin button control for flat style themes. * @param pDC Pointer to a valid device context. * @param nButton Button control ID. */ void DrawFlatButton(CDC* pDC, UINT nButton); /** * @brief * Called by the framework to render the up and down arrows for * the spin button control. * @param pDC Pointer to a valid device context. * @param rcArrow Size of the arrow to draw. * @param bHorz TRUE if the arrow is horizontal. * @param bUpArrow TRUE if the arrow is pointing up. * @param clrArrow An RGB value representing the color of the arrow to draw. */ void DrawArrowGlyph(CDC* pDC, CRect rcArrow, BOOL bHorz, BOOL bUpArrow, COLORREF clrArrow); /** * @brief * Draw spin button using native Windows theme. * @param pDC Pointer to a valid device context. */ void DrawStandard(CDC* pDC); /** * @brief * Called by the framework to determine if the spin button control * is vertically orientated. * @return * TRUE if the spin button control orientation is vertical. */ BOOL IsVertical() const; /** * @brief * Called by the spin button control to determine the size of the * spin button specified by nButton. * @param nButton ID of the button to retrieve the size information for, * can be either UD_HITUP or UD_HITDOWN. * @return * A CRect value representing the size for the specified button. */ CRect GetButtonRect(int nButton); /** * @brief * This member function is called from OnInitDialog or OnInitialUpdate * to initialize the control. */ void Init(); /** @cond */ virtual BOOL PreCreateWindow(CREATESTRUCT& cs); virtual void PreSubclassWindow(); virtual int OnCreate(LPCREATESTRUCT lpCreateStruct); //{{AFX_MSG(CXTPSpinButtonCtrl) afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg void OnMouseLeave(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg LRESULT OnSetTheme(WPARAM wParam, LPARAM lParam); DECLARE_MESSAGE_MAP() //}}AFX_MSG /** @endcond */ UINT m_nHotButton; /**< ID for the currently highlighted button, can be either UD_HITNOWHERE, UD_HITDOWN or UD_HITUP. */ UINT m_nPressedButton; /**< ID for the currently pressed button, can be either UD_HITNOWHERE, UD_HITDOWN or UD_HITUP. */ BOOL m_bUseVisualStyle; /**< TRUE to use Windows themes. */ BOOL m_bPreSubclassInit; /**< TRUE if the control has been subclassed. */ COLORREF m_crBack; /**< Spin button background color. */ COLORREF m_crBackHilite; /**< Spin button background highlight color. */ COLORREF m_crBackPushed; /**< Spin button background pushed color. */ COLORREF m_crBackDisabled; /**< Spin button disabled color. */ COLORREF m_crBorder; /**< Border color. */ COLORREF m_crBorderHilite; /**< Border highlight color. */ COLORREF m_crBorderPushed; /**< Border pushed color. */ COLORREF m_crBorderDisabled; /**< Border disabled color. */ COLORREF m_crArrowEnabled; /**< Spin button arrow color. */ COLORREF m_crArrowHilite; /**< Spin button arrow highlight color. */ COLORREF m_crArrowPushed; /**< Spin button arrow pushed color. */ COLORREF m_crArrowDisabled; /**< Spin button arrow disabled color. */ XTPControlTheme m_nTheme; /**< Currently active theme ID. */ CXTPWinThemeWrapper* m_themeSpin; /**< Windows theme API wrapper pointer. */ }; ///////////////////////////////////////////////////////////////////////////// /** @cond */ AFX_INLINE BOOL CXTPSpinButtonCtrl::GetUseVisualStyle() const { return m_bUseVisualStyle; } /** @endcond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // #if !defined(__XTPSPINBUTTONCTRL_H__) /** @endcond */