/** * @file XTPStatusBarPaneSwitch.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(__XTPSTATUSBARPANESWITCH_H__) # define __XTPSTATUSBARPANESWITCH_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPStatusBarSwitchPane is a CXTPStatusBarPane derived class. * CXTPStatusBarSwitchPane works with CXTStatusBar and allows * you to create switches in your status bar area. */ class _XTP_EXT_CLASS CXTPStatusBarSwitchPane : public CXTPStatusBarPane { /** @cond */ DECLARE_DYNAMIC(CXTPStatusBarSwitchPane) /** @endcond */ public: /** * @brief * Holds status bar pane switch properties. */ struct SWITCH { CString strToolTip; /**< Tooltip of the switch. */ UINT nID; /**< Id of the switch. */ int nWidth; /**< Width of the switch. */ BOOL bChecked; /**< TRUE to "check" the switch. */ BOOL bHighlighted; /**< TRUE if the switch is highlighted. */ BOOL bPressed; /**< TRUE if the switch is pressed. */ BOOL bEnabled; /**< TRUE if enabled */ }; public: /** * @brief * Constructs a CXTPStatusBarSwitchPane object. */ CXTPStatusBarSwitchPane(); /** * @brief * Destroys a CXTPStatusBarSwitchPane object, handles cleanup and * deallocation. */ ~CXTPStatusBarSwitchPane(); public: /** * @brief * Call this method to set switches. * @param lpIDArray Pointer to an array with identifiers. * @param nIDCount Count of elements in the array. * @return * TRUE if successful, otherwise FALSE. */ BOOL SetSwitches(const UINT* lpIDArray, int nIDCount); /** * @brief * Adds a switch to the Switch Pane. * @param nID ID of the switch. * @return * Reference to a SWITCH object. */ SWITCH* AddSwitch(UINT nID); /** * @brief * Adds a switch to the Switch Pane. * @param nID ID of the switch. * @param lpszToolTip Tooltip of the switch. * @return * Reference to a SWITCH object. */ SWITCH* AddSwitch(UINT nID, LPCTSTR lpszToolTip); /** * @brief * Retrieves a switch by its index/identifier. * Returns a switch by its position. * @param nIndex Index of the switch to retrieve. * @return * Pointer to the SWITCH. */ SWITCH* GetSwitch(int nIndex) const; /** * @brief * Retrieves a switch by its index/identifier. * Returns a switch by its position. * @param nID Identifier of the switch to retrieve. * @return * Pointer to the SWITCH. */ SWITCH* FindSwitch(UINT nID) const; /** * @brief * Gets the total number of switches in the switch pane. * @return * Total number of switches in the switch pane. */ int GetSwitchCount() const; /** * @brief * Removes all switches from the switch pane. */ void RemoveAll(); /** * @brief * Removes a switch from the switch pane. * @param nID ID of the switch to remove. */ void RemoveSwitch(UINT nID); /** * @brief * Specifies whether the switch pane is enabled. * @param nID ID of the switch to enable/disable. * @param bEnabled TRUE to enable the switch pane, FALSE to disable the swith pane. */ void EnableSwitch(UINT nID, BOOL bEnabled); /** * @brief * Sets the ID of the switch that is currently checked. * @param nID ID of the switch to be checked. * @details * Checked is used to get/set the currently selected/checked * switch in the switch pane. */ void SetChecked(UINT nID); /** * @brief * Gets the width of the switch pane. * @return * Width of the switch pane. */ virtual int GetWidth(); public: /** * @brief * Call this method to determine which pane, if any, is at the * specified screen position. * @param point Point to test. * @param rcItem Retrieves the bounding rectangle of the item. * @return * A SWITCH object containing the data of the pane at the specified point. */ SWITCH* HitTest(CPoint point, CRect& rcItem) const; protected: /** * @brief * This member function is used to process left mouse button events. * @param point A CPoint that specifies the x- and y- coordinates of * the cursor. These coordinates are always relative to * the upper-left corner of the window. */ virtual void OnLButtonDown(CPoint point); /** * @brief * This method is called to draw a pane switch item. Override it to * draw a custom switch. * @param pDC Pointer to a valid device context. * @param rcItem Item rectangle. */ virtual void OnDraw(CDC* pDC, CRect rcItem); /** * @brief * This member is called when the mouse cursor moves. * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnMouseMove(CPoint point); /** * @brief * The framework calls this member function to determine whether * a point is in the bounding rectangle of the specified tool. * @param point Specifies the x- and y- coordinates of the cursor. These * coordinates are always relative to the upper-left * corner of the window. * @param pTI A pointer to a TOOLINFO structure. * @return * If the tooltip control was found, then the window control ID is returned. * If the tooltip control was not found, then a value of -1 is returned. */ virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPStatusBarSwitchPane); void OleAddSwitch(UINT nID, LPCTSTR lpszToolTip); void OleRemoveSwitch(UINT nID); int OleGetChecked(); BSTR OleGetSwitchTooltip(int nID); void OleSetSwitchTooltip(int nID, LPCTSTR lpszTooltip); /** @endcond */ # endif protected: CArray m_arrSwitches; /**< Collection of switces in the switch pane. */ SWITCH* m_pHighlighted; /**< TRUE if the switch is currently highlighted. */ }; /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTPSTATUSBARPANESWITCH_H__) /** @endcond */