📄 wg_toolbar.h
字号:
// wg_toolbar.h//// CToolBar class interface////// Copyright (c) 2002 Rob Wiskow// rob-dev@boxedchaos.com//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//#ifndef _WG_TOOLBAR_H_#define _WG_TOOLBAR_H_#include "wg_window.h"#include "wg_button.h"#include <vector>namespace wGui{//! A Toolbar control that groups and organizes buttons//! Toolbars support CButton derived controlsclass CToolBar : public CWindow{public: //! Constructs a new ToolBar //! \param WindowRect A CRect that defines the outer limits of the control //! \param pParent A pointer to the parent window CToolBar(const CRect& WindowRect, CWindow* pParent); //! Standard destructor virtual ~CToolBar(void); //! Add a button to the toolbar //! The toolbar will become the button's parent //! The toolbar will catch all CTRL_LCLICK messages from the buttons and will post a CTRL_LCLICK message from the toolbar with the iButtonID value as the iNewValue //! \param pButton A pointer to the button to be inserted, inserts a spacer if this is NULL //! \param iButtonID An identifier that the toolbar will return when a button is clicked on, defaults to 0 //! \param iPosition The position to insert the button at (defaults to adding to the end of the toolbar) void InsertButton(CButton* pButton, long int iButtonID = 0, int iPosition = -1); //! Remove a button from the toolbar //! This will automatically delete the button //! \param iPosition The position of the button to remove void RemoveButton(int iPosition); //! \return The number of buttons in the toolbar int ButtonCount(void) { return static_cast<int>(m_vpButtons.size()); } //! \param iPosition The position of the button to get the ID for //! \return The ButtonID of the button at the given position (spacers always return 0) long int GetButtonID(int iPosition) { return m_vpButtons.at(iPosition).second; } //! \param iButtonID The ID of the button to get the position for //! \return The position of the button, or -1 if it can't find the ButtonID int GetButtonPosition(long int iButtonID); //! CWindow overrides //! Giving a control a new WindowRect will move and resize the control //! \param WindowRect A CRect that defines the outer limits of the control virtual void SetWindowRect(const CRect& WindowRect); // CMessageClient overrides //! CToolBars handle CTRL_LCLICK messages //! \param pMessage A pointer to the message virtual bool HandleMessage(CMessage* pMessage);protected: //! Reposition all the buttons in the toolbar void RepositionButtons(void); typedef std::pair<CButton*, long int> t_ButtonIDPair; typedef std::vector<t_ButtonIDPair> t_ButtonVector; t_ButtonVector m_vpButtons; //!< A vector of pointers to the buttons and their IDs in the toolbarprivate: void operator=(CToolBar) { } //!< The assignment operator is not allowed for CWindow derived objects};}#endif // _WG_TOOLBAR_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -