⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wxflatnotebook.h

📁 robocup rcssserver 运行防真机器人足球比赛所用的服务器端
💻 H
📖 第 1 页 / 共 2 页
字号:
///////////////////////////////////////////////////////////////////////////////// Name:		wxFlatNotebook.cpp // Purpose:     generic implementation of flat style notebook class.// Author:      Eran Ifrah <eranif@bezeqint.net>// Modified by: Priyank Bolia <soft@priyank.in>// Created:     30/12/2005// Modified:    01/01/2006// Copyright:   Eran Ifrah (c)// Licence:     wxWindows license <http://www.wxwidgets.org/licence3.txt>///////////////////////////////////////////////////////////////////////////////#ifndef WXFLATNOTEBOOK_H#define WXFLATNOTEBOOK_H#include <wx/wx.h>#include <wx/frame.h>#include <wx/dynarray.h>#ifdef __WXMSW__#ifdef _DEBUG//#include <crtdbg.h>#define DEBUG_NEW new(_NORMAL_BLOCK ,__FILE__, __LINE__)#else#define DEBUG_NEW new#endif#endif // __WXMSW__#ifdef WXMAKINGDLL_FNB#    define WXDLLIMPEXP_FNB WXEXPORT#elif defined(WXUSINGDLL_FNB)#    define WXDLLIMPEXP_FNB WXIMPORT#else /* not making nor using FNB as DLL */#    define WXDLLIMPEXP_FNB#endif // WXMAKINGDLL_FNB#include <wx/dcbuffer.h>#include <wx/dataobj.h>#include <wx/dnd.h>#include <wx/wxflatnotebook/wxfnbdroptarget.h>class wxPageContainer;#ifndef M_PI#define M_PI 3.14159265358979#endif#ifndef wxFNB_HEIGHT_SPACER#define wxFNB_HEIGHT_SPACER 10#endif// forward declerationsclass wxFNBRenderer;class wxFNBRendererDefault;class wxFNBRendererVC71;class wxFNBRendererVC8;class wxTabNavigatorWindow;class wxMenu;// Since some compiler complains about std::min, we define our own macro#define FNB_MIN(a, b) ((a > b) ? b : a)WX_DECLARE_USER_EXPORTED_OBJARRAY(wxBitmap, wxFlatNotebookImageList, WXDLLIMPEXP_FNB);WX_DECLARE_USER_EXPORTED_OBJARRAY(wxWindow*, wxWindowPtrArray, WXDLLIMPEXP_FNB);///  wxFlatNotebook styles#define wxFNB_DEFAULT_STYLE				wxFNB_MOUSE_MIDDLE_CLOSES_TABS#define wxFNB_VC71						0x00000001#define wxFNB_FANCY_TABS				0x00000002#define wxFNB_TABS_BORDER_SIMPLE		0x00000004#define wxFNB_NO_X_BUTTON				0x00000008#define wxFNB_NO_NAV_BUTTONS			0x00000010#define wxFNB_MOUSE_MIDDLE_CLOSES_TABS	0x00000020#define wxFNB_BOTTOM					0x00000040#define wxFNB_NODRAG					0x00000080#define wxFNB_VC8						0x00000100#define wxFNB_X_ON_TAB					0x00000200#define wxFNB_BACKGROUND_GRADIENT		0x00000400#define wxFNB_COLORFUL_TABS				0x00000800#define wxFNB_DCLICK_CLOSES_TABS		0x00001000#define wxFNB_SMART_TABS				0x00002000#define wxFNB_DROPDOWN_TABS_LIST		0x00004000#define wxFNB_ALLOW_FOREIGN_DND			0x00008000/// General macros#define VERTICAL_BORDER_PADDING			4#define BUTTON_SPACE					16#define VC8_SHAPE_LEN					16#define MASK_COLOR wxColor(0, 128, 128)/*** \brief Nice cross-platform flat notebook with X-button, navigation arrows and much more*/class WXDLLIMPEXP_FNB wxFlatNotebook : public wxPanel{private:	friend class wxPageContainer;public:	///Default constructor	wxFlatNotebook() : m_popupWin(NULL) {}	/// Parametrized constructor	/**	\param parent - parent window	\param id - window ID	\param pos - window position	\param size - window size	\param style - window style	\param name - window class name	*/	wxFlatNotebook(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("Flat Notebook"));	/// Destructor	virtual ~wxFlatNotebook(void);	/// Advances the selection	/**	\param bForward - if set to true then selection should be advanced forward otherwise - backward	*/	void AdvanceSelection(bool bForward);	/// Apends new notebook page	/**	\param windows - window to be appended	\param caption - tab caption	\param selected - determines if new page should be selected automatically	\param imgindex - page image index	*/	bool AddPage(wxWindow* windows, const wxString& caption, const bool selected = false, const int imgindex = -1);	/// Inserts new notebook page	/**	\param index - page index	\param page - window to be appended	\param text - tab caption	\param select - determines if new page should be selected automatically	\param imgindex - page image index	*/	bool InsertPage(size_t index, wxWindow* page, const wxString& text, bool select = false, const int imgindex = -1);	/// Changes the selection from currently visible/selected page to the page given by index.	/**	\param page - index of page to be selected	*/	void SetSelection(size_t page);	/// Removes the window from the notebook, and destroys the window associated with that notebook page.	/**	 * \param page - index of page to be deleted	 * \param notify - by default wxFlatNotebook fires two events:	 * - wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED 	 * - wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING 	 * to disable this functionality set notify to false	 */	void DeletePage(size_t page, bool notify = true);	/// Deletes all notebook pages and destroys all windows associated with pages	bool DeleteAllPages();	/// Returns the total number of pages in the notebook.	int  GetPageCount() const;	/// Returns the window object associated with selected notebook page.	wxWindow * GetCurrentPage() const;	/// Returns the window object associated with a notebook page.	/**	\param page - page index	*/	wxWindow * GetPage(size_t page) const;	/// Returns the page index of the window object.	/**	\param win - window object	*/	int GetPageIndex(wxWindow* win) const;	/// Returns the currently visible/selected notebook page 0 based index.	int GetSelection() const;	/**	* Return the previous selection, useful when implementing smart tabulation	* \return previous selection, or wxNOT_FOUND 	*/	int GetPreviousSelection() const;	/// Returns tab header inclination angle of specified page	/**	\param page_index - page index	\param result - pointer to the variable that receives the result	*/	bool GetPageShapeAngle(int page_index, unsigned int * result);	/// Sets tab header inclination angle of specified page	/**	\param page_index - page index	\param angle - new value of tab header inclination angle	*/	void SetPageShapeAngle(int page_index, unsigned int angle);	/// Sets tab header inclination angle for all pages	/**	\param angle - new value of tab header inclination angle	*/	void SetAllPagesShapeAngle(unsigned int angle);	/// Returns the best size for a page	wxSize GetPageBestSize();	/// Sets the caption/text of the notebook page	/**	\param page - page index	\param text - new value of tab caption	*/	bool SetPageText(size_t page, const wxString& text);	/**	 * Removes the window from the notebook, and destroys the window associated with that notebook page.	 * \param page - index of page to be deleted	 * \param notify - by default wxFlatNotebook fires two events:	 * - wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED 	 * - wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING 	 * to disable this functionality set notify to false	 */	bool RemovePage(size_t page, bool notify = true);	/// Sets the amount of space around each page's icon and label, in pixels.	/**	NB: The vertical padding cannot be changed in for wxFlatNotebook.	\param padding - new amount of space around each page's icon and label	*/	void SetPadding(const wxSize& padding);	/// Alters the notebook style	/**	\param style - new value of notebook style	*/	virtual void SetWindowStyleFlag(long style);	/// Sets a right click menu to the notebook	/**	\param menu - right click menu object	*/	void SetRightClickMenu(wxMenu* menu);	/// Returns the page text	/**	\param page - page index	*/	wxString GetPageText(size_t page);	/// Sets an image index of specified page	/**	\param page - page index	\param imgindex - new image index	*/	void SetPageImageIndex(size_t page, int imgindex);	/// Returns an image index of specified page	/**	\param page - page index	*/	int GetPageImageIndex(size_t page);	/// Sets gradient colors (only applicable when using the wxFNB_FANCY_TABS)	/**	\param from - first gradient colour	\param to - second gradient colour	\param border - page border colour	*/	void SetGradientColors(const wxColour& from, const wxColour& to, const wxColour& border);	/// Sets first gradient colour	/**	\param from - new value of first gradient colour	*/	void SetGradientColorFrom(const wxColour& from);	/// Sets second gradient colour	/**	\param to - new value of second gradient colour	*/	void SetGradientColorTo(const wxColour& to);	/// Sets the colour of page border	/**	\param border - new value of the colour of page border	*/	void SetGradientColorBorder(const wxColour& border);	/// Sets an image list associated with notebook pages	/**	\param imglist - image list object.	Image list assigned with this method will not be deleted by wxFlatNotebook's destructor, you must delete it yourself.	*/	void SetImageList(wxFlatNotebookImageList * imglist);	/// Returns an image list object associated with wxFlatNotebook	wxFlatNotebookImageList * GetImageList();	/**	* \brief Drop event handler, to be passed as function pointer to CTextDropTarget class.	* \param x X coordinate where the drop take place	* \param y Y coordinate where the drop take place	* \param nTabPage page index	* \param wnd_oldContainer pointer to wxPageContainer object that contained dragged page	* \return Drag operation identifier	*/	wxDragResult OnDropTarget(wxCoord x, wxCoord y, int nTabPage, wxWindow * wnd_oldContainer);	/// Enable / Disable page	/**	\param page - page to enable/diable	\param enabled - set to true to enable the tab, false otherwise	*/	void Enable(size_t page, bool enabled);	/// Return Returns true if if the page is enabled	/**	\param page - page index	*/	bool GetEnabled(size_t page);	/// Set the active tab text	/**	\param textColour - the active tab text colour	*/	void SetActiveTabTextColour(const wxColour& textColour);	/// Gets first gradient colour	const wxColour& GetGradientColorFrom();	/// Gets second gradient colour	const wxColour& GetGradientColorTo();	/// Gets the tab border colour	const wxColour& SetGradientColorBorder();	/// Get the active tab text	const wxColour& GetActiveTabTextColour();	/// Get the non-active tab text color	const wxColour& GetNonActiveTabTextColour();	/// Set the non-active tab text color	void SetNonActiveTabTextColour(const wxColour& color);	/// Return the tab area panel	wxPanel* GetTabArea() { return (wxPanel*)m_pages; }	/// Get the tab area background colour	const wxColour& GetTabAreaColour();	/// Set the tab area background colour	void SetTabAreaColour(const wxColour& color);	/// Get the active tab color	const wxColour& GetActiveTabColour();	/// Set the active tab color	void SetActiveTabColour(const wxColour& color);	/**	* Return the padding used between the text and icons, text and borders, etc.	* \return padding in pixels	*/	int GetPadding() { return m_nPadding; }protected:	/// Initialization function, called internally	virtual void Init();	wxPageContainer *m_pages;private:	/// Internal flag to force selection of page,	/// even if this page is disabled.	/// used incase such that the book itself need to update its selection.	/// e.g. after DeletePage()	bool m_bForceSelection;	wxBoxSizer* m_mainSizer;	/// vector of all the windows associated with the notebook pages.	wxWindowPtrArray m_windows;	wxFNBDropTarget<wxFlatNotebook> *m_pDropTarget;	int m_nFrom;	int m_nPadding;	wxTabNavigatorWindow *m_popupWin;	bool m_sendPageChangeEvent; ///< Ugly but needed to allow SetSelection to send / dont send event	DECLARE_DYNAMIC_CLASS(wxFlatNotebook)	DECLARE_EVENT_TABLE()	void OnNavigationKey(wxNavigationKeyEvent& event);};/*** \brief Contains parameters of notebook page*/class WXDLLIMPEXP_FNB wxPageInfo{private:	// Members	/// Page caption	wxString m_strCaption;	/// Page position	wxPoint m_pos;	/// Page size	wxSize  m_size;	/// Page region	wxRegion m_region;	/// Angle for painting tab	unsigned int m_TabAngle;	/// Page image index	int m_ImageIndex;	/// Page enable/disabled flag	bool m_bEnabled;	/// Tab 'x' button rectangle	wxRect m_xRect;	/// Tab color	wxColor m_color;public:	/// Default constructor	wxPageInfo(): m_strCaption(wxEmptyString), m_TabAngle(0), m_ImageIndex(-1), m_bEnabled(true){};	/// Parametrized constructor	/**	\param caption - page caption	\param imgindex - image index	*/	wxPageInfo(const wxString& caption, int imgindex) :	m_strCaption(caption), m_pos(-1, -1), m_size(-1, -1), m_TabAngle(0), m_ImageIndex(imgindex), m_bEnabled(true){}	/// Destructor	~wxPageInfo(){};	/// Sets page caption	/**	\param value - new page caption	*/	void SetCaption(wxString value) {m_strCaption = value;}	///Returns page caption	wxString GetCaption() {return m_strCaption;}	/// Sets page position	/**	\param value - new page position

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -