/** * @file XTPStatusBar.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(__XTPSTATUSBAR_H__) # define __XTPSTATUSBAR_H__ /** @endcond */ # if _MSC_VER >= 1000 # pragma once # endif // _MSC_VER >= 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPCommandBars; class CXTPPaintManager; class CXTPStatusBar; class CXTPStatusBarPane; class CXTPStatusBarPaintManager; class CXTPImageManagerIcon; class CXTPImageManager; class CXTPToolTipContext; class CXTPPopupBar; class CXTPPropExchange; class CXTPMarkupUIElement; class CXTPMarkupContext; /** * @brief * CXTPStatusBar is a CControlBar derived class. */ class _XTP_EXT_CLASS CXTPStatusBar : public CControlBar { /** @cond */ DECLARE_DYNAMIC(CXTPStatusBar) /** @endcond */ private: class CStatusCmdUI; class CControlCustomization; public: /** * @brief * Constructs a CXTPStatusBar object. */ CXTPStatusBar(); /** * @brief * Destroys a CXTPStatusBar object, handles cleanup and deallocation. */ virtual ~CXTPStatusBar(); public: /** * @brief * Creates a status bar (a child window) and associates it with the * CStatusBar object. Also sets the initial font and sets the * status bar's height to a default value. * @param pParentWnd Pointer to the CWnd object whose Windows window * is the parent of the status bar. * @param dwStyle The status bar window style's bits. * @param nID The toolbar's child-window ID. * @return * Nonzero if successful; otherwise 0. */ BOOL Create(CWnd* pParentWnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, UINT nID = AFX_IDW_STATUS_BAR); public: /** * @brief * Sets each indicator's ID to the value specified by the corresponding * element of the array lpIDArray, loads the string resource specified * by each ID, and sets the indicator's text to the string. * @param lpIDArray Pointer to an array of IDs. * @param nIDCount Number of elements in the array pointed to by lpIDArray. * @return * TRUE if successful; otherwise FALSE. */ BOOL SetIndicators(const UINT* lpIDArray, int nIDCount); CXTPCommandBars* GetCommandBars() const; /** * @brief * Call this member to set the command bar's object. * @param pCommandBars CXTPCommandBars to be set. */ void SetCommandBars(CXTPCommandBars* pCommandBars); /** * @brief * Retrieves the paint manager. * @return * A pointer to a CXTPPaintManager object. */ CXTPPaintManager* GetPaintManager() const; /** * @brief * Retrieves the status bar paint manager. * @return * A pointer to a CXTPStatusBarPaintManager object. */ CXTPStatusBarPaintManager* GetStatusBarPaintManager() const; public: BOOL IsAllCaps() const; void SetAllCaps(BOOL bAllCaps); /** * @brief * This member function is called by the status bar to reposition pane * item controls. */ void PositionControls(); /** * @brief * Call this member function to add a control to an indicator pane. * @param pWnd Pointer to a control window. * @param nID ID of the indicator pane. * @param bAutoDelete TRUE if the control is to be deleted when destroyed. * @return * TRUE if successful, otherwise FALSE. */ BOOL AddControl(CWnd* pWnd, UINT nID, BOOL bAutoDelete = TRUE); /** * @brief * Call this member function to set the width for an indicator pane. * @param nIndex Index of the indicator pane. * @param cxText New width for the indicator pane. */ void SetPaneWidth(int nIndex, int cxText); /** * @brief * Call this member function to add an indicator pane to the status bar. * @param nID ID of the indicator pane. * @param nIndex Index of the indicator pane. * @return * CXTPStatusBarPane pointer if successful, otherwise NULL. */ CXTPStatusBarPane* AddIndicator(UINT nID, int nIndex = -1); /** * @brief * Call this member function to add an indicator pane to the status bar. * @param nID ID of the indicator pane. * @param nIndex Index of the indicator pane. * @param pPane New CXTPStatusBarPane object. * @return * CXTPStatusBarPane pointer if successful, otherwise NULL. */ CXTPStatusBarPane* AddIndicator(CXTPStatusBarPane* pPane, UINT nID, int nIndex = -1); /** * @brief * Call this member function to remove an indicator pane from the status bar. * @param nID ID of the indicator pane. * @return * TRUE if successful, otherwise FALSE. */ BOOL RemoveIndicator(UINT nID); /** * @brief * Call this member function to return the number of panes that are created * for the status bar. * @return * An integer value that represents the number of panes for the status bar. */ int GetPaneCount() const; /** * @brief * Calculates the total number of visible panes. * @return * Total number of panes currently visible. */ int GetVisiblePaneCount() const; /** * @brief * Call this member function to get the pane information for the given index. * @param nIndex Index of the indicator pane. * @return * A pointer to a CXTPStatusBarPane class. */ CXTPStatusBarPane* GetPane(int nIndex) const; /** * @brief * Call this member function to find the pane for the given identifier. * @param nID Identifier of the indicator pane. * @return * A pointer to a CXTPStatusBarPane class. */ CXTPStatusBarPane* FindPane(UINT nID) const; /** * @brief * Call this member function to remove all indicators. */ void RemoveAll(); /** * @brief * Call this member function to remove an indicator pane from the status bar. * @param nIndex Index of the indicator pane. * @return * TRUE if successful, otherwise FALSE. */ BOOL RemoveAt(int nIndex); /** * @brief * Call this member to retrieve the image manager of the image manager. * @return * A pointer to a CXTPImageManager object */ CXTPImageManager* GetImageManager() const; /** * @brief * Determines which pane, if any, is at a specified screen position. * @param pt Point to be tested. * @param lpRect Pointer to a CRect object to receive the item at point pt. * @return * A pointer to the CXTPStatusBarPane object at the specified point, if any, * or NULL otherwise. */ CXTPStatusBarPane* HitTest(CPoint pt, CRect* lpRect = NULL) const; public: /** * @brief * Call this method to enable/disable customization of the status bar. * @param bEnable TRUE to enable customization, FALSE to disable customization. */ void EnableCustomization(BOOL bEnable = TRUE); /** * @brief * Retrieves state information from the registry or .INI file. * @param lpszProfileName Pointer to a NULL-terminated string that specifies the * name of a section in the initialization file or a key in * the Windows registry where state information is stored. */ void LoadState(LPCTSTR lpszProfileName); /** * @brief * Saves state information to the registry or .INI file. * @param lpszProfileName Pointer to a NULL-terminated string that specifies the * name of a section in the initialization file or a key in * the Windows registry where state information is stored. */ void SaveState(LPCTSTR lpszProfileName); /** * @brief * Reads this object from or writes this object to an archive. * @param pPX A CXTPPropExchange object to serialize to or from. */ virtual void DoPropExchange(CXTPPropExchange* pPX); public: /** * @brief * Call this member function to set the paint manager to draw disabled text. * @param bDraw TRUE to draw disabled text, otherwise FALSE. */ void SetDrawDisabledText(BOOL bDraw); /** * @brief * Call this member function to check if the paint manager will draw disabled text. * @return * TRUE if the paint manager will draw disabled text, otherwise FALSE. */ BOOL GetDrawDisabledText() const; /** * @brief * Call this method to get a pointer to the tooltip context. * @return * A pointer to the tooltip context. */ CXTPToolTipContext* GetToolTipContext() const; public: /** * @brief * This method is called to draw a single pane of the status bar. * @param pDC Pointer to a valid device context. * @param nIndex Index of the pane to draw. * @param rcItem Bounding rectangle of the pane. */ virtual void DrawPaneEntry(CDC* pDC, int nIndex, CRect rcItem); public: /** * @brief * Call this function to create a status bar. * @param pParentWnd Pointer to the CWnd object whose Windows window is the * parent of the status bar. * @param dwCtrlStyle Additional styles for the creation of the embedded * CStatusBarCtrl object. * @param dwStyle The status bar style. * @param nID The status bar's child-window ID. * @return * Nonzero if successful; otherwise 0. */ BOOL CreateEx(CWnd* pParentWnd, DWORD dwCtrlStyle = 0, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, UINT nID = AFX_IDW_STATUS_BAR); /** * @brief * Gets the indicator index for a given ID. The index of the first indicator is 0. * @param nIDFind String ID of the indicator whose index is to be retrieved. * @return * The index of the indicator if successful; -1 if not successful. * @see * GetItemID */ int CommandToIndex(UINT nIDFind) const; /** * @brief * Returns the ID of the indicator specified by nIndex. * @param nIndex Index of the indicator whose ID is to be retrieved. * @return * The ID of the indicator specified by nIndex. * @see * CommandToIndex */ UINT GetItemID(int nIndex) const; /** * @brief * Copies the coordinates of the indicator specified by nIndex into * the structure pointed to by lpRect. Coordinates are in pixels * relative to the upper-left corner of the status bar. * @param nIndex Index of the indicator whose rectangle coordinates are to be retrieved. * @param lpRect Pointer to a RECT structure or a CRect object that will receive * the coordinates of the indicator specified by nIndex. * @see * GetPaneInfo, CommandToIndex */ void GetItemRect(int nIndex, LPRECT lpRect) const; /** * @brief * Call this member function to retrieve the text that appears in a * status bar pane. The second form of this member function * fills a CString object with the string text. * @param nIndex Index of the pane whose text is to be retrieved. * @return Returns the text that appears in a status bar pane * @see * SetPaneText */ CString GetPaneText(int nIndex) const; /** * @brief * Call this member function to retrieve the text that appears in a * status bar pane. The second form of this member function * fills a CString object with the string text. * @param nIndex Index of the pane whose text is to be retrieved. * @param rString A reference to a CString object that contains the text to be retrieved. * @see * SetPaneText */ void GetPaneText(int nIndex, CString& rString) const; /** * @brief * Sets the pane text to the string pointed to by lpszNewText. * @param nIndex Index of the pane whose text is to be set. * @param lpszNewText Pointer to the new pane text. * @return * Nonzero if successful; otherwise 0. * @see * GetPaneText */ BOOL SetPaneText(int nIndex, LPCTSTR lpszNewText); /** * @brief * Sets nID, nStyle, and cxWidth to the ID, style, and width of the indicator * pane at the location specified by nIndex. * @param nIndex Index of the pane whose information is to be retrieved. * @param nID Reference to a UINT that is set to the ID of the pane. * @param nStyle Reference to a UINT that is set to the style of the pane. * @param cxWidth Reference to an integer that is set to the width of the pane. * @see * SetPaneInfo, GetItemRect */ void GetPaneInfo(int nIndex, UINT& nID, UINT& nStyle, int& cxWidth) const; /** * @brief * Sets the specified indicator pane to a new ID, style, and width. * @param nIndex Index of the indicator pane whose style is to be set. * @param nID New ID for the indicator pane. * @param nStyle New style for the indicator pane. * @param cxWidth New width for the indicator pane. * @see * GetPaneInfo */ void SetPaneInfo(int nIndex, UINT nID, UINT nStyle, int cxWidth); /** * @brief * Call this member function to retrieve the style of a status bar's pane. * A pane's style determines how the pane appears. * @param nIndex Index of the pane whose style is to be retrieved. * @return * The style of the status bar pane specified by nIndex. * @see * SetPaneStyle */ UINT GetPaneStyle(int nIndex) const; /** * @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 nIndex Index of the pane whose style is to be set. * @param nStyle Style of the pane whose style is to be set. * @see * GetPaneStyle */ void SetPaneStyle(int nIndex, UINT nStyle); /** * @brief * This member function allows direct access to the underlying common control. * @return * Contains a reference to a CStatusBarCtrl object. */ CStatusBarCtrl& GetStatusBarCtrl() const; /** * @brief * Call this method to set the font for the status bar. * @param pFont Font to set. * @param bRedraw TRUE to redraw status bar. */ void SetFont(CFont* pFont, BOOL bRedraw = TRUE); /** * @brief * Call this method to get the font for the status bar. * @return * Font used for the status bar. */ CFont* GetFont(); /** * @brief * Sets the position of the ribbon divider index. This specifies * the panes that get the second color for the ribbon theme. * @param nIndex Position of the ribbon bar divider. * @details * RibbonDividerIndex is a zero-based index and specifies the * panes that get the second color for the ribbon theme. All * panes with an index larger than the divider index will get * the second ribbon color applied. */ void SetRibbonDividerIndex(int nIndex); /** * @brief * Gets the position of the ribbon divider index. * @return * Position of the ribbon bar divider. */ int GetRibbonDividerIndex() const; /** * @brief * Allows the use of a XAML snippet to be used for the text of * panes in the status Bar. * @param bEnableMarkup TRUE to enable markup, FALSE to disable markup. */ void EnableMarkup(BOOL bEnableMarkup = TRUE); /** * @brief * Retrieves a pointer to the markup context. * @return * A pointer to a CXTPMarkupContext object. */ CXTPMarkupContext* GetMarkupContext() const; /** * @brief * Call this method to reposition all panes. */ virtual void RecalcLayout(); /** @cond */ // Obsolete void UpdateAllPanes(BOOL bUpdateRects, BOOL bUpdateText); # if _MSC_VER > 1100 void SetBorders(LPCRECT lpRect); void SetBorders(int cxLeft = 0, int cyTop = 0, int cxRight = 0, int cyBottom = 0); # endif /** @endcond */ protected: /** * @brief * Draws the stretch gripper of the status bar. * @param pDC Pointer to a valid device context. * @param rcClient Client rectangle. */ virtual void DrawStretch(CDC* pDC, CRect& rcClient); protected: /** @cond */ virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz); BOOL PreCreateWindow(CREATESTRUCT& cs); void CalcInsideRect(CRect& rect, BOOL bHorz) const; virtual void OnBarStyleChange(DWORD dwOldStyle, DWORD dwNewStyle); # ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; void EnableDocking(DWORD dwDockStyle); # endif public: virtual void OnPaneClick(CXTPStatusBarPane* pPane); virtual void OnSwitchPaneClick(CXTPStatusBarPane* pPane, long Id); virtual CXTPPopupBar* GetStatusBarPopup(); /** @endcond */ protected: /** @cond */ DECLARE_MESSAGE_MAP() virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const; virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); //{{AFX_MSG(CXTPStatusBar) public: afx_msg void OnPaint(); afx_msg void OnDraw(CDC* pDC); afx_msg LRESULT OnPrintClient(WPARAM wParam, LPARAM /*lParam*/); afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg int OnCreate(LPCREATESTRUCT lpcs); afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam); protected: afx_msg LRESULT OnNcHitTest(CPoint); afx_msg void OnNcCalcSize(BOOL, NCCALCSIZE_PARAMS*); afx_msg void OnNcPaint(); afx_msg void OnWindowPosChanging(LPWINDOWPOS); afx_msg LRESULT OnSetText(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnGetText(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnGetTextLength(WPARAM wParam, LPARAM lParam); afx_msg LRESULT OnSetMinHeight(WPARAM wParam, LPARAM lParam); afx_msg void OnWindowPosChanged(WINDOWPOS* lpwndpos); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void HandleMouseMove(CPoint point); afx_msg void OnMouseLeave(); afx_msg void OnLButtonDown(UINT nFlags, CPoint pt); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg void OnSysCommand(UINT nID, LPARAM lParam); afx_msg void OnUpdateKeyIndicator(CCmdUI* pCmdUI); //}}AFX_MSG /** @endcond */ private: BOOL IsWin4(); private: /** @cond */ DISABLE_WNDCREATE() DISABLE_WNDCREATEEX() /** @endcond */ # ifdef _XTP_COMMANDBARS_ACTIVEX /** @cond */ DECLARE_ENUM_VARIANT(CXTPStatusBar); long OleGetItemCount(); LPDISPATCH OleGetItem(int nItem); public: CString m_strIdleText; // Implementation protected: void OnFinalRelease(); DECLARE_DISPATCH_MAP() DECLARE_INTERFACE_MAP() XTP_DECLARE_CMDTARGETPROVIDER_INTERFACE() DECLARE_OLETYPELIB_EX(CXTPStatusBar); DECLARE_CONNECTION_EX(CXTPStatusBar) LPFONTDISP OleGetFont(); void OleSetFont(LPFONTDISP pFontDisp); afx_msg LPDISPATCH OleHitTest(OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y); afx_msg long OleGetMinHeight(); afx_msg void OleSetMinHeight(int nMinHeight); afx_msg BOOL OleGetVisible(); afx_msg void OleSetVisible(BOOL bNewValue); afx_msg void OleOnIdleTextChanged(); afx_msg LPDISPATCH OleAddPane(long nID); afx_msg LPDISPATCH OleAddSwitchPane(long nID); afx_msg LPDISPATCH OleAddProgressPane(long nID); afx_msg LPDISPATCH OleAddSliderPane(long nID); afx_msg LPDISPATCH OleGetToolTipContext(); afx_msg LPDISPATCH OleFindPane(long nID); afx_msg LPDISPATCH OleInsertPane(int nIndex, int nID); afx_msg void OleSetPaneText(long nIndex, LPCTSTR strText); afx_msg void OleSetPaneWidth(long nIndex, long nWidth); afx_msg void OleSetPaneStyle(long nIndex, long nStyle); afx_msg void OleSetShowSizeGripper(BOOL bGripper); afx_msg BOOL OleGetShowSizeGripper(); afx_msg void OleSetEnableMarkup(BOOL bEnableMarkup); afx_msg BOOL OleGetEnableMarkup(); afx_msg OLE_HANDLE OleGetHwnd(); afx_msg void OleSetAllCaps(BOOL bAllCaps); afx_msg BOOL OleIsAllCaps(); public: void FireMouseDown(short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y) { FireEvent(DISPID_MOUSEDOWN, EVENT_PARAM(VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS), nButton, nShiftState, x, y); } void FireMouseUp(short nButton, short nShiftState, OLE_XPOS_PIXELS x, OLE_YPOS_PIXELS y) { FireEvent(DISPID_MOUSEUP, EVENT_PARAM(VTS_I2 VTS_I2 VTS_XPOS_PIXELS VTS_YPOS_PIXELS), nButton, nShiftState, x, y); } void FirePaneDblClick(LPDISPATCH lpDispatch) { FireEvent(1, EVENT_PARAM(VTS_DISPATCH), lpDispatch); } void FirePaneClick(LPDISPATCH lpDispatch) { FireEvent(2, EVENT_PARAM(VTS_DISPATCH), lpDispatch); } void FireSwitchPaneClick(LPDISPATCH lpDispatch, long Id) { FireEvent(3, EVENT_PARAM(VTS_DISPATCH VTS_I4), lpDispatch, Id); } void FireSliderPaneClick(LPDISPATCH lpDispatch, long Command, long Pos) { FireEvent(4, EVENT_PARAM(VTS_DISPATCH VTS_I4 VTS_I4), lpDispatch, Command, Pos); } /** @endcond */ # endif protected: CArray m_arrPanes; /**< Array of panes */ int m_nMinHeight; /**< Minimum client height */ CXTPFont m_xtpFontStatus; /**< Font of status bar */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED(CFont, m_fontStatus, m_xtpFontStatus, GetStatusFontHandle); BOOL m_bShowSizeGripper; /**< TRUE to show size gripper */ BOOL m_bDrawDisabledText; /**< TRUE to draw disabled text */ BOOL m_bAllCaps; CXTPStatusBarPane* m_pHighlightedPane; /**< Pane currently highlighted */ int m_nRibbonDividerIndex; /**< Position of dark part for Ribbon Theme */ CXTPMarkupContext* m_pMarkupContext; /**< Markup Context */ int m_cxPaneSpacing; /**< Gap between panes */ int m_bCustomizable; /**< TRUE to allow customize status bar. */ private: CXTPCommandBars* m_pCommandBars; CXTPToolTipContext* m_pToolTipContext; /**< Tooltip Context. */ friend class CXTPStatusBarPane; }; AFX_INLINE BOOL CXTPStatusBar::IsAllCaps() const { return m_bAllCaps; } AFX_INLINE void CXTPStatusBar::SetAllCaps(BOOL bAllCaps) { m_bAllCaps = bAllCaps; } AFX_INLINE void CXTPStatusBar::SetRibbonDividerIndex(int nIndex) { m_nRibbonDividerIndex = nIndex; } AFX_INLINE int CXTPStatusBar::GetRibbonDividerIndex() const { return m_nRibbonDividerIndex; } AFX_INLINE CXTPCommandBars* CXTPStatusBar::GetCommandBars() const { return m_pCommandBars; } AFX_INLINE void CXTPStatusBar::SetCommandBars(CXTPCommandBars* pCommandBars) { m_pCommandBars = pCommandBars; } AFX_INLINE int CXTPStatusBar::GetPaneCount() const { return (int)m_arrPanes.GetSize(); } AFX_INLINE CStatusBarCtrl& CXTPStatusBar::GetStatusBarCtrl() const { return *(CStatusBarCtrl*)this; } # if _MSC_VER > 1100 AFX_INLINE void CXTPStatusBar::SetBorders(int cxLeft, int cyTop, int cxRight, int cyBottom) { _ASSERTE(cyTop >= 2); CControlBar::SetBorders(cxLeft, cyTop, cxRight, cyBottom); } AFX_INLINE void CXTPStatusBar::SetBorders(LPCRECT lpRect) { SetBorders(lpRect->left, lpRect->top, lpRect->right, lpRect->bottom); } # endif # ifdef _DEBUG // status bars do not support docking AFX_INLINE void CXTPStatusBar::EnableDocking(DWORD) { _ASSERTE(FALSE); } # endif AFX_INLINE void CXTPStatusBar::SetDrawDisabledText(BOOL bDraw) { m_bDrawDisabledText = bDraw; } AFX_INLINE BOOL CXTPStatusBar::GetDrawDisabledText() const { return m_bDrawDisabledText; } AFX_INLINE CXTPToolTipContext* CXTPStatusBar::GetToolTipContext() const { return m_pToolTipContext; } AFX_INLINE CXTPMarkupContext* CXTPStatusBar::GetMarkupContext() const { return m_pMarkupContext; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif //#if !defined(__XTPSTATUSBAR_H__) /** @endcond */