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

📄 tab_control.hpp

📁 ncbi源码
💻 HPP
字号:
/* * =========================================================================== * PRODUCTION $Log: tab_control.hpp,v $ * PRODUCTION Revision 1000.1  2004/06/01 19:52:30  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * PRODUCTION * =========================================================================== */#ifndef __GUI_WIDGETS_FL___TAB_CONTROL__HPP#define __GUI_WIDGETS_FL___TAB_CONTROL__HPP/*  $Id: tab_control.hpp,v 1000.1 2004/06/01 19:52:30 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Andrey Yazhuk * * File Description: * */#include <corelib/ncbistl.hpp>#include <corelib/ncbistd.hpp>#include <gui/utils/fltk_utils.hpp>#include <gui/widgets/fl/utils.hpp>#include <gui/widgets/fl/tooltip.hpp>#include <FL/Fl_Group.H>#include <FL/Fl_Scrollbar.H>#include <algorithm>/** @addtogroup GUI_FltkWidgets * * @{ */BEGIN_NCBI_SCOPE////////////////////////////////////////////////////////////////////////////////// CTabControl class NCBI_GUIWIDGETS_FL_EXPORT CTabControl : public Fl_Group,                                              public ITooltipClient{public:    enum    ETabPosition    {        eBottom    };    enum    EResizePolicy   {        fShrink   = 0x1,   /// Truncate labels if there is not enough space        fMultiRow   = 0x2, /// place Tabs on multiple rows if there is not enough space        fExpand     = 0x4, /// expand tabs to occupy all available space in a row            };    CTabControl();    CTabControl(int x, int y, int w, int h, const char* label = 0);    virtual ~CTabControl();    /// takes a cobination of EResizePolicy flags    virtual void    SetResizePolicies(int policies);    virtual bool    AddTab(Fl_Widget* pane, const char* label);    virtual bool    InsertTab(Fl_Widget* pane, int pos, const char* label);    virtual bool    RemoveTab(Fl_Widget* pane);    virtual bool    RemoveTab(int index);    virtual void    RemoveAllTabs();        virtual int     GetTabsCount()  const;    virtual Fl_Widget*  GetTab(int index);        virtual string  GetTabLabel(int index)  const;    virtual string  GetTabTooltip(int index)  const;    virtual void    SetTabLabel(int index, const char* label);    virtual void    SetTabTooltip(int index, const char* label);    virtual int     GetSelectedTab() const;    virtual void    SelectTab(int index);    /// @name Fl_Group functions    /// @{    /* void add(Fl_Widget *w);        void add(Fl_Widget&  w);        void remove(Fl_Widget &w);*/    virtual void    draw();    virtual void    resize(int new_x, int new_y, int new_w, int new_h);    virtual int     handle(int);    /// @}    /// @name ITooltipClient implementation    /// @{    virtual bool    TC_NeedTooltip(int x, int y);      virtual string  TC_GetTooltip(int& x, int& y, int& w, int& h);    /// @}protected:    void    x_Init();    struct STabDescr        {        Fl_Widget*  m_pPane;        string      m_Label;        string      m_Tooltip;        int m_x, m_y, m_w, m_h; // local coords    };    bool    x_InsertTab(Fl_Widget* pane, int index, const char* label,                         const char* tooltip);    bool    x_RemoveTab(int index);    void    x_RemoveAllTabs();    int     x_GetTabsCount()    const   {   return m_vDescrs.size();    }    Fl_Widget*  x_GetPane(int index);    STabDescr*  x_GetTab(int index);     int     x_GetTabIndex(Fl_Widget* pane)  const;    void    x_SelectTab(int index);    STabDescr*   x_GetSelectedTab();    Fl_Widget*   x_GetSelectedPane();    void    x_DrawTab(int index);    void    x_Layout();    void    x_LayoutTabs();    int     x_GetTabAreaH() const;     int     x_GetTabRowH()  const;    int     x_MeasureTabWidth(int index);    void    x_GetClientRect(int& cl_x, int& cl_y, int& cl_w, int& cl_h);    bool    x_IsIndexValid(int index) const;    //static void x_OnScrollX(Fl_Widget* pW, void* pData);    enum    EHitResult  {        eClient,        eTab,         eEmptySpace,        eNothing    };    EHitResult  x_HitTest(int pos_x, int pos_y, int& i_tab);    int     x_HandleKeyEvent();    int     x_HandleMouseMove();    int     x_HandleMousePush();    int     x_HandleMouseDrag();    int     x_HandleMouseRelease();    virtual void    x_OnShowPopupMenu();    protected:       typedef vector<STabDescr*>  TDescrVector;    typedef vector<int>     TRowIndexes; // holds indexes of the tabs in a row    TDescrVector    m_vDescrs;    int     m_Selected;    vector<TRowIndexes> m_vRows;        // tooltip support    CTooltip    m_Tooltip;    int         m_iHitTab; /// index of the tab hit by tooltip hit test    int   m_ResizePolicies;    int   m_TabAreaH;        CGUIEvent   m_Event;    //bool        m_bSelfHandled; // "true" if event was handled by component itself, not by its children    Fl_Color    m_BorderColor;    Fl_Color    m_ActiveBorderColor;    Fl_Color    m_BackColor;    Fl_Color    m_ActiveBackColor;    Fl_Color    m_TextColor;    Fl_Color    m_ActiveTextColor;        //Fl_Scrollbar*   m_pScrollbar;};END_NCBI_SCOPE/* @} *//* * =========================================================================== * $Log: tab_control.hpp,v $ * Revision 1000.1  2004/06/01 19:52:30  gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.4 * * Revision 1.4  2004/05/13 17:19:58  yazhuk * Moved fl_draw_text() functions to utils.hpp * * Revision 1.3  2004/05/11 18:55:14  dicuccio * Added doxygen modules info * * Revision 1.2  2004/02/04 20:26:31  ucko * Fix capitalization of fl_draw.H. * * Revision 1.1  2004/02/04 20:03:15  yazhuk * Initial revision * * =========================================================================== */#endif  // __GUI_WIDGETS_FL___TAB_CONTROL__HPP

⌨️ 快捷键说明

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