📄 wxflatnotebook.h
字号:
*/ void SetPosition(wxPoint value) {m_pos = value;} ///Returns page position const wxPoint & GetPosition() {return m_pos;} /// Sets page size /** \param value - new page size */ void SetSize(wxSize value) {m_size = value;} ///Returns page size const wxSize & GetSize() {return m_size;} /// Sets the tab header inclination angle /** \param value - new tab header inclination angle */ void SetTabAngle(unsigned int value) {m_TabAngle = FNB_MIN((unsigned int)(45), (unsigned int)(value));} /// Returns an inclination of tab header borders unsigned int GetTabAngle() {return m_TabAngle;} /// Sets page image index /** \param value - new image index */ void SetImageIndex(int value) {m_ImageIndex = value;} /// Returns an image index int GetImageIndex() {return m_ImageIndex;} /// Return true if the page is enabled bool GetEnabled() { return m_bEnabled; } /// Set the page enable/disable flag /** \param enabled - new page enable status */ void Enable(bool enabled) { m_bEnabled = enabled; } /// Set the page region /** \param n - number of points \param points - array of points that construct the region */ void SetRegion(const size_t n, const wxPoint points[]) { m_region = wxRegion(n, points); } /// Get the page region wxRegion& GetRegion() { return m_region ; } /// Set the 'x' button rectangle area /** \param xrect - the 'x' button rectangle */ void SetXRect(const wxRect& xrect) { m_xRect = xrect; } /// Get the 'x' button rectangle wxRect& GetXRect() { return m_xRect; } /** * * \return The tab color */ wxColor GetColor() { return m_color; } /** * * \param color Tab face color */ void SetColor(wxColor& color) { m_color = color; }};WX_DECLARE_USER_EXPORTED_OBJARRAY(wxPageInfo, wxPageInfoArray, WXDLLIMPEXP_FNB);/// Button statusenum{ wxFNB_BTN_PRESSED, wxFNB_BTN_HOVER, wxFNB_BTN_NONE};/// Hit Test resultsenum{ wxFNB_TAB, ///< On a tab wxFNB_X, ///< On the X button wxFNB_TAB_X, ///< On the 'X' button (tab's X button) wxFNB_LEFT_ARROW, ///< On the rotate left arrow button wxFNB_RIGHT_ARROW, ///< On the rotate right arrow button wxFNB_DROP_DOWN_ARROW, ///< On the drop down arrow button wxFNB_NOWHERE ///< Anywhere else};/*** \brief Notebook page*/class WXDLLIMPEXP_FNB wxPageContainer : public wxPanel{protected: friend class wxFlatNotebook; friend class wxFNBRenderer; friend class wxFNBRendererDefault; friend class wxFNBRendererVC71; friend class wxFNBRendererVC8; wxFlatNotebookImageList * m_ImageList;public: /// Parametrized constructor /** \param parent - parent window \param id - window ID \param pos - window position \param size - window size \param style - window style */ wxPageContainer(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0); /// Destructor virtual ~wxPageContainer(void); /// 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. */ virtual void SetImageList(wxFlatNotebookImageList * imglist) {m_ImageList = imglist;} /// Returns an image list object associated with wxFlatNotebook virtual wxFlatNotebookImageList * GetImageList() {return m_ImageList;} /// Apends new notebook page /** \param caption - tab caption \param selected - determines if new page should be selected automatically \param imgindex - page image index */ virtual bool AddPage(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 */ virtual 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 */ virtual void SetSelection(size_t page); /// Returns the current selection page index virtual int GetSelection() { return m_iActivePage; } /// Advances the selection /** \param bForward - if set to true then selection should be advanced forward otherwise - backward */ virtual void AdvanceSelection(bool bForward); /// Return the number of pages virtual size_t GetPageCount() { return m_pagesInfoVec.size(); } /// Returns the page caption /** \param page - page index */ virtual wxString GetPageText(size_t page) { return m_pagesInfoVec[page].GetCaption(); } /// Set the caption of the page /** \param page - page index \param text - new page caption */ virtual bool SetPageText(size_t page, const wxString& text) { m_pagesInfoVec[page].SetCaption(text); return true; } /// Sets an image index of specified page /** \param page - page index \param imgindex - new image index */ virtual void SetPageImageIndex(size_t page, int imgindex); /// Returns an image index of specified page /** \param page - page index */ virtual int GetPageImageIndex(size_t page); /// Enable / Disable page /** \param page - page to enable/diable \param enabled - set to true to enable the tab, false otherwise */ virtual void Enable(size_t page, bool enabled); /// Return Returns true if if the page is enabled /** \param page - page index */ virtual bool GetEnabled(size_t page); /// Style helper methods bool HasFlag(int flag); /** * Return a vector containing the tabs informations (used by the redereres) * \return tabs info vector */ wxPageInfoArray& GetPageInfoVector() { return m_pagesInfoVec; } /** * Return the first graident colour ("from") * \return gradient colour 1 */ const wxColour& GetGradientColourFrom() const { return m_colorFrom; } /** * Return the second graident colour ("to") * \return gradient colour 2 */ const wxColour& GetGradientColourTo() const { return m_colorTo; } /** * Return tab's border colour * \return border colour */ const wxColour& GetBorderColour() const { return m_colorBorder; } /** * Return non active tab's text colour * \return non active tab's text colour */ const wxColour& GetNonoActiveTextColor() const { return m_nonActiveTextColor; } /** * Return the active tab colour * \return tab colour */ const wxColour& GetActiveTabColour() const { return m_activeTabColor; } /** * Get the previous selected tab, wxNOT_FOUND if none * \return index of previous selected tab */ int GetPreviousSelection() const { return m_iPreviousActivePage; } /** * Draw a tab preview */ void DrawDragHint(); DECLARE_EVENT_TABLE() // Event handlers virtual void OnPaint(wxPaintEvent& event); virtual void OnSize(wxSizeEvent& WXUNUSED(event)); virtual void OnMouseMove(wxMouseEvent& event); virtual void OnLeftDown(wxMouseEvent& event); virtual void OnLeftUp(wxMouseEvent& event); virtual void OnRightDown(wxMouseEvent& event); virtual void OnMiddleDown(wxMouseEvent& event); virtual void OnEraseBackground(wxEraseEvent& WXUNUSED(event)) { } virtual void OnMouseLeave(wxMouseEvent& event); virtual void OnMouseEnterWindow(wxMouseEvent& event); virtual void OnLeftDClick(wxMouseEvent &event); virtual void OnTabMenuSelection(wxCommandEvent &event);protected: /** * Popup a menu that contains all the tabs to be selected by user */ void PopupTabsMenu(); void ClearFlag(int flag); /// return true if tabIdx has image bool TabHasImage(int tabIdx); /// Check whether the style is set to default virtual bool IsDefaultTabs(); /// Return the color of the single line border virtual wxColor GetSingleLineBorderColor(); /// Return true if page is visible virtual bool IsTabVisible(size_t page); /// Return if pt is anywhere on a tab, button or anywhere else virtual int HitTest(const wxPoint& pt, wxPageInfo& pageInfo, int &tabIdx); /// Display tool tip when mouse is hovering a tab virtual void ShowTabTooltip(int tabIdx); /// A wrapper from calling the DoDeletePage() virtual void DeletePage(size_t page); /// Remove all pages from the container (it also deletes them) virtual void DeleteAllPages(); /// Perform the actual deletion of a tab from the container /// The window is also deleted using this function virtual void DoDeletePage(size_t page); /// Preform the actual page selection virtual void DoSetSelection(size_t page); /// Return the index of the last visible index virtual int GetLastVisibleTab(); /// Return the number of tabs that can be scrolled left /// starting from the first visible tab (i.e. m_nFrom) virtual int GetNumTabsCanScrollLeft(); /// Return the number of visible tabs virtual int GetNumOfVisibleTabs(); /** * \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 */ virtual wxDragResult OnDropTarget(wxCoord x, wxCoord y, int nTabPage, wxWindow * wnd_oldContainer); /** * \brief Moves the tab page from one location to another * \param nMove The index of the tab page to be moved. * \param nMoveTo The index for the tab page, where it has to be moved */ virtual void MoveTabPage(int nMove, int nMoveTo); /// Check whether page can fit to the current /// screen or a scrolling is required /** \param page - page index */ virtual bool CanFitToScreen(size_t page);protected: wxPageInfoArray m_pagesInfoVec; int m_iActivePage; int m_nFrom; /// Drop target for enabling drag'n'drop of tabs wxFNBDropTarget<wxPageContainer> *m_pDropTarget; /// Pointer to the parent window wxWindow *m_pParent; /// The right click menu wxMenu* m_pRightClickMenu; /// Gradient colors wxColour m_colorFrom, m_colorTo, m_colorBorder, m_activeTextColor, m_nonActiveTextColor, m_tabAreaColor, m_activeTabColor; /// X,>,< buttons status, can be one of /// - Pressed /// - Hover /// - None int m_nXButtonStatus, m_nLeftButtonStatus, m_nRightButtonStatus, m_nTabXButtonStatus; /// holds the button id in case a left click is done on one of them int m_nLeftClickZone; int m_iPreviousActivePage; int m_nArrowDownButtonStatus;};/*** \brief Holds information about events associated with wxFlatNotebook objects*/class WXDLLIMPEXP_FNB wxFlatNotebookEvent : public wxNotifyEvent{ DECLARE_DYNAMIC_CLASS(wxFlatNotebookEvent) size_t sel, oldsel;public: /// Constructor /** \param commandType - event type \param winid - window ID \param nSel - current selection \param nOldSel - old selection */ wxFlatNotebookEvent(wxEventType commandType = wxEVT_NULL, int winid = 0, int nSel = -1, int nOldSel = -1) : wxNotifyEvent(commandType, winid), sel(nSel), oldsel(nOldSel) {} /// Sets the value of current selection /** \param s - index of currently selected page */ void SetSelection(int s) { sel = s; } /// Sets the value of previous selection /** \param s - index of previously selected page */ void SetOldSelection(int s) { oldsel = s; } /// Returns the index of currently selected page int GetSelection() { return (int)sel; } /// Returns the index of previously selected page int GetOldSelection() { return (int)oldsel; }};BEGIN_DECLARE_EVENT_TYPES()DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_FNB, wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED, 50000)DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_FNB, wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING, 50001)DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_FNB, wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING, 50002)DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_FNB, wxEVT_COMMAND_FLATNOTEBOOK_CONTEXT_MENU, 50003)DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_FNB, wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED, 50004)END_DECLARE_EVENT_TYPES()typedef void (wxEvtHandler::*wxFlatNotebookEventFunction)(wxFlatNotebookEvent&);#define wxFlatNotebookEventHandler(func) \ (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFlatNotebookEventFunction, &func)#define EVT_FLATNOTEBOOK_PAGE_CHANGED(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGED, winid, wxFlatNotebookEventHandler(fn))#define EVT_FLATNOTEBOOK_PAGE_CHANGING(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CHANGING, winid, wxFlatNotebookEventHandler(fn))#define EVT_FLATNOTEBOOK_PAGE_CLOSING(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSING, winid, wxFlatNotebookEventHandler(fn))#define EVT_FLATNOTEBOOK_CONTEXT_MENU(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_FLATNOTEBOOK_CONTEXT_MENU, winid, wxFlatNotebookEventHandler(fn))#define EVT_FLATNOTEBOOK_PAGE_CLOSED(winid, fn) \ wx__DECLARE_EVT1(wxEVT_COMMAND_FLATNOTEBOOK_PAGE_CLOSED, winid, wxFlatNotebookEventHandler(fn))#endif // WXFLATNOTEBOOK_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -