/** * @file XTPStatusBarPane.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(__XTPSTATUSBARPANE_H__) # define __XTPSTATUSBARPANE_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPStatusBarPane is a CXTPCmdTarget derived class. * It represents a single pane of a status bar. */ class _XTP_EXT_CLASS CXTPStatusBarPane : public CXTPCmdTarget { private: /** @cond */ DECLARE_DYNAMIC(CXTPStatusBarPane) /** @endcond */ public: /** * @brief * Constructs a CXTPStatusBarPane object. */ CXTPStatusBarPane(); /** * @brief * Destroys a CXTPStatusBarPane object, handles cleanup and deallocation. */ virtual ~CXTPStatusBarPane(); public: /** * @brief * Call this member to set the text caption that is displayed * in this pane. * @param lpszText Text caption of the pane. * @see * GetText */ void SetText(LPCTSTR lpszText); /** * @brief * Sets the text that is displayed for the pane in the status * bar customization window. * @param lpszCaption The caption is the text that is displayed for * the pane in the status bar customization window. */ void SetCaption(LPCTSTR lpszCaption); /** * @brief * Gets the text that is displayed for the pane in the status * bar customization window. * @return * Text caption. */ CString GetCaption() const; /** * @brief * Sets the value of the pane. This is displayed in the status * bar customization window. * @param lpszValue The value of the pane can be any string value and * can be used to store extra data if customization * is disabled. If customization is enabled, then the * Value is the text that is displayed for the pane * in the status bar customization window. */ void SetValue(LPCTSTR lpszValue); /** * @brief * Gets the value of the pane. This is displayed in the status * bar customization window. * @return * The value of the status bar pane. */ CString GetValue() const; /** * @brief * Call this member to get the text caption of the pane. * @return * Text caption of pane. This is the text displayed in the pane. * @see * SetText */ CString GetText() const; /** * @brief * Call this member to set the width of this pane. * @param nWidth new width to be set. * @see * GetWidth */ void SetWidth(int nWidth); /** * @brief * Call this member to get the width of the pane. * @return * Current width of the pane. * @see * SetWidth */ virtual int GetWidth(); /** * @brief * Call this member function to set the style of a status bar's pane. * A pane's style determines how the pane appears. * @param nStyle Style of the pane whose style is to be set. */ void SetStyle(UINT nStyle); /** * @brief * Call this member function to get the style of a status bar's pane. * @return * Style of the indicator pane. */ UINT GetStyle() const; /** * @brief * Call this member function to get the ID of a status bar's pane. * @return * ID of the indicator pane. */ UINT GetID() const; /** * @brief * Call this member function to get the index of a status bar's pane. * @return * Index of the indicator pane. */ int GetIndex() const; /** * @brief * Call this member function to remove the pane. */ void Remove(); /** * @brief * Call this member to determine if the pane is visible. * @return * TRUE if the tab is visible, FALSE otherwise. * @see * SetVisible */ BOOL IsVisible() const; /** * @brief * Call this member to set the visibility of the pane. * @param bVisible TRUE to show the tab, FALSE to hide the tab. * @param bRecalcLayout TRUE to recalculate layout after. * @see * IsVisible */ void SetVisible(BOOL bVisible, BOOL bRecalcLayout = TRUE); /** * @brief * Call this member function to set the color of an item text. * @param clrText COLORREF object that represents the color of an item * text. */ void SetTextColor(COLORREF clrText); /** * @brief * Call this member function to set the disabled color of an item text. * @param clrText COLORREF object that represents the disabled color of an item * text. */ void SetTextGrayColor(COLORREF clrText); /** * @brief * Call this member function to get the color of an item text. * @return * A COLORREF object that represents the color of an item text. */ COLORREF GetTextColor() const; /** * @brief * Call this member function to get the disabled color of an item text. * @return * A COLORREF object that represents the disabled color of an item text. */ COLORREF GetTextGrayColor() const; /** * @brief * Call this member function to set the color of an item background. * @param clrBackground COLORREF object that represents the background color of an item * text. */ void SetBackgroundColor(COLORREF clrBackground); /** * @brief * Call this member to get the background color of an item. * @return * The background color of an item. */ COLORREF GetBackgroundColor() const; /** * @brief * Call this member function to set the font of an item text. * @param pFntText pointer to a CFont object. */ void SetTextFont(CFont* pFntText); /** * @brief * Call this member function to set the font of an item text. * @param pLogfText pointer to a LOGFONT structure. */ void SetTextFont(PLOGFONT pLogfText); /** * @brief * Call this member function to set the font of an item text. * @return * Pointer to CFont object. */ virtual CFont* GetTextFont(); /** * @brief * Retrieves icon index. * @return * Icon index. * @see * SetIconIndex */ int GetIconIndex() const; /** * @brief * Call this method to set the icon index of an item. * @param nIconIndex Icon index to be set. * @see * GetIconIndex */ void SetIconIndex(int nIconIndex); /** * @brief * Call this member function to set the alignment of an item text. * @param nAlign The alignment style of an item text. */ void SetTextAlignment(int nAlign); /** * @brief * Call this member function to get the alignment of an item text. * @return * The alignment style of an item text. */ int GetTextAlignment() const; /** * @brief * Call this member to set the tooltip for this pane. This is the * text that will be displayed when the mouse pointer is positioned * over the pane. * @param lpszTooltip Tooltip to set for this tab. * @see * GetTooltip */ void SetTooltip(LPCTSTR lpszTooltip); /** * @brief * Call this member to get the tooltip displayed when the mouse * pointer is positioned over the pane. * @return * The tooltip displayed when the mouse if over the pane. * @see * SetTooltip */ CString GetTooltip() const; /** * @brief * Fits the width of the pane to its text width. */ void BestFit(); /** * @brief * Gets the best fit width which fits the width of the pane to * the its text width. * @return * Best fit width. */ int GetBestFit(); /** * @brief * Call this method to add a separator before the pane. * @param bBeginGroup TRUE to start a new group. */ void SetBeginGroup(BOOL bBeginGroup = TRUE); /** * @brief * Gets a boolean value indicating whether the pane has a separator * placed before it and thus begins a new group. * @return * TRUE if the pane begins a group, FALSE otherwise. */ BOOL GetBeginGroup() const; /** * @brief * Call this member function to get the parent status bar object. * @return * Pointer to the parent status bar object. */ CXTPStatusBar* GetStatusBar() const; /** * @brief * This method is called to get an image of the pane. * @return * CXTPImageManagerIcon pointer to be drawn. */ virtual CXTPImageManagerIcon* GetImage() const; /** * @return * Returns margins for pane entry * @see * SetMargins */ CRect GetMargins() const; /** * @brief * Gets the padding placed around the Text of a pane. * @return * Padding placed around the Text of a pane. */ CRect GetPadding() const; /** * @brief * Call this method to set margins for the pane. * @param nLeft Left margin. * @param nTop Top margin. * @param nRight Right margin. * @param nBottom Bottom margin. * @see * GetMargins */ void SetMargins(int nLeft, int nTop, int nRight, int nBottom); /** * @brief * Sets the padding placed around the text of a pane in pixels. * @param nLeft Padding placed on the left side of the text of a pane. * @param nTop Padding placed on the top of the text of a pane. * @param nRight Padding placed on the right side of the text of a pane. * @param nBottom Padding placed on the bottom of the text of a pane. */ void SetPadding(int nLeft, int nTop, int nRight, int nBottom); /** * @brief * Specifies whether the pane will also act as a button. * @param bButton TRUE if the pane will act as a button. * @details * Button panes will look and act like a button on mouse over * and when clicked. On mouse over, the button pane will become * "hot" giving a visual que that it is a button and can be * clicked. When clicked, the button pane will change to a * "pressed" state. */ void SetButton(BOOL bButton = TRUE); /** * @brief * Specifies whether the pane will also act as a button. * @return * TRUE if the pane acts as a button, FALSE otherwise. */ BOOL IsButton() const; /** * @brief * Gets a boolean value indicating whether the switch pane is enabled. * @return * TRUE if enabled, FALSE if disabled. */ BOOL IsEnabled() const; /** * @brief * Specifies whether the switch pane is enabled or disabled. * @param bEnabled TRUE to enable the pane, FALSE to disable the pane. */ void SetEnabled(BOOL bEnabled); /** * @brief * This member is called to determine if the pane button is * currently highlighted. This occurs when the mouse cursor is * positioned over the pane button. * @return * TRUE if the pane button is currently highlighted. */ BOOL IsHighlighted() const; /** * @brief * Call this method to determine if the pane button is pressed. * @return * TRUE if the pane button is pressed, otherwise FALSE. */ BOOL IsPressed() const; /** * @brief * Enables or disables status bar customization. * @param bVisible TRUE to enable customization, FALSE to disable customization. * @details * SetCustomizationVisible will enable a status bar customization * window to appear when the status bar is right-clicked on. The * customization window allows all the panes in the statusbar to * be hidden or displayed (if already hidden). All panes will be * displayed in the window with the exception of the pane with an * ID equal to 0. The items displayed in the window are the * caption of the pane and the value of the pane. Also indicated * is the visibility of the pane. */ void SetCustomizationVisible(BOOL bVisible); /** * @brief * Gets whether customization is enabled. * @return * TRUE if customization is enabled, FALSE otherwise. */ BOOL GetCustomizationVisible() const; /** * @brief * Call this member function to determine if the pane button state is * checked. * @return * TRUE if the pane button is checked, otherwise FALSE. */ BOOL IsChecked() const; /** * @brief * Call this member to set the checked state of a pane. * @param bChecked TRUE to set the pane to checked, FALSE to set the pane to unchecked. */ void SetChecked(BOOL bChecked); /** * @brief * Call this member function to determine if the pane has borders * enabled. * @return * TRUE if the pane has borders enabled, otherwise FALSE. * @details * If the pane is a button, the return value is always FALSE * since buttons will handle drawing their own borders. * @see * IsButton */ BOOL HasBorders() const; /** * @brief * Call this member function to show the pane borders. * @param bShowBorders TRUE to show the pane borders, FALSE to hide them. * @details * If the pane is a button, then this has no effect. */ void ShowBorders(BOOL bShowBorders); /** * @brief * Call this member function to redraw the pane. */ void Redraw() const; /** * @brief * Call this member to get the bounding rectangle for the pane. * @return * A CRect object. */ CRect GetRect() const; /** * @brief * This member function is used to get the stored CXTPMarkupUIElement object. * @return * A pointer to the CXTPMarkupUIElement object. */ CXTPMarkupUIElement* GetMarkupUIElement() const; /** * @brief * Some themes may display status bar panes as dark. * This method turns this effect on/off. * @param bDark Sets status bar panes as dark. True by default, set false to turn off */ void SetDark(BOOL bDark = TRUE); /** * @brief * Determines if a pane is to be drawn as dark in some themes. * @return * TRUE if the pane is dark, otherwise FALSE. */ BOOL IsDark() const; protected: /** * @brief * This method is called to draw a pane item. Override it to draw a custom pane. * @param pDC Pointer to a valid device context. * @param rcItem Item rectangle. */ virtual void OnDraw(CDC* pDC, CRect rcItem); /** * @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 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 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; protected: UINT m_nID; /**< IDC of indicator: 0 => normal text area. */ int m_cxText; /**< Width of the string area in pixels. On both sides there is a 3 pixel gap and a 1 pixel border, making a pane 6 pixels wider. */ UINT m_nStyle; /**< Style flags (SBPS_*). */ CString m_strText; /**< Text in the pane. */ DWORD m_dwHideFlags; /**< TRUE if pane is visible */ COLORREF m_clrText; /**< Text color */ COLORREF m_clrTextGray; /**< Disabled text color */ COLORREF m_clrBackground; /**< Background color */ CString m_strToolTip; /**< Tooltip text for the item */ CRect m_rcPane; /**< Bounding rectangle for the pane */ HWND m_hWndPane; /**< Child handle */ BOOL m_bAutoDeleteWnd; /**< TRUE to auto delete child. */ int m_nAlignment; /**< Alignment of the item. */ CXTPStatusBar* m_pStatusBar; /**< Parent StatusBar object */ int m_nIndex; /**< Index of the item */ CXTPFont m_xtpFontText; /**< Font of an item text */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fntText, m_xtpFontText, GetTextFontHandle); int m_nIconIndex; /**< Icon index of the pane */ CRect m_rcPadding; /**< Margins of the pane */ CRect m_rcMargins; /**< Margins of the pane */ BOOL m_bButton; /**< TRUE if pane is clickable button */ BOOL m_bPressed; /**< TRUE if button was pressed */ CXTPMarkupUIElement* m_pMarkupUIElement; /**< Markup Context */ BOOL m_bBeginGroup; /**< TRUE if the pane begins a group */ CString m_strCaption; /**< The text that is displayed for the pane in the status bar customization window */ CString m_strValue; /**< The value of the pane. This is displayed in the status bar customization window */ int m_nBestFit; /**< Width for the pane to have the best fit */ BOOL m_bCustomizable; /**< True to enable customization, False to disable customization */ BOOL m_bIsDark; /**< True if a pane should be dark in some themes. */ # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() DECLARE_OLETYPELIB_EX(CXTPStatusBarPane); afx_msg BSTR OleGetText(); afx_msg LPFONTDISP OleGetFont(); afx_msg void OleSetFont(LPFONTDISP pFontDisp); afx_msg HWND OleGetHandle(); afx_msg void OleSetHandle(HWND hWnd); afx_msg int OleGetHideFlags(); afx_msg void OleSetHideFlags(int dwHideFlags); afx_msg void OleSetVisible(BOOL bVisible); afx_msg void OleRedrawPane(); afx_msg void OleGetRect(long* pLeft, long* pTop, long* pRight, long* pBottom); afx_msg BOOL OleGetDark(); afx_msg void OleSetDark(BOOL fDark); /** @endcond */ # endif friend class CXTPStatusBar; }; ////////////////////////////////////////////////////////////////////// AFX_INLINE void CXTPStatusBarPane::SetCaption(LPCTSTR lpszCaption) { m_strCaption = lpszCaption; } AFX_INLINE CString CXTPStatusBarPane::GetCaption() const { return m_strCaption; } AFX_INLINE void CXTPStatusBarPane::SetValue(LPCTSTR lpszValue) { m_strValue = lpszValue; } AFX_INLINE CString CXTPStatusBarPane::GetValue() const { return m_strValue; } AFX_INLINE BOOL CXTPStatusBarPane::IsHighlighted() const { return m_pStatusBar->m_pHighlightedPane == this; } AFX_INLINE BOOL CXTPStatusBarPane::IsPressed() const { return m_bPressed; } AFX_INLINE void CXTPStatusBarPane::SetBeginGroup(BOOL bBeginGroup) { m_bBeginGroup = bBeginGroup; } AFX_INLINE BOOL CXTPStatusBarPane::GetBeginGroup() const { return m_bBeginGroup; } AFX_INLINE BOOL CXTPStatusBarPane::HasBorders() const { return ((m_nStyle & SBPS_NOBORDERS) == 0); } AFX_INLINE void CXTPStatusBarPane::ShowBorders(BOOL bShowBorders) { SetStyle(bShowBorders ? m_nStyle & ~SBPS_NOBORDERS : m_nStyle | SBPS_NOBORDERS); } AFX_INLINE CXTPMarkupUIElement* CXTPStatusBarPane::GetMarkupUIElement() const { return m_pMarkupUIElement; } AFX_INLINE void CXTPStatusBarPane::SetDark(BOOL bDark /*= TRUE*/) { m_bIsDark = bDark; } AFX_INLINE BOOL CXTPStatusBarPane::IsDark() const { return m_bIsDark; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // !defined(__XTPSTATUSBARPANE_H__) /** @endcond */