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

📄 captionbar.h

📁 wxWidgets 2.8.9 Downloads
💻 H
📖 第 1 页 / 共 2 页
字号:
/** \class wxCaptionBar    This class is a graphical caption component that consists of a caption and a clickable arrow.    The wxCaptionBar fires an event EVT_CAPTIONBAR which is a wxCaptionBarEvent. This event can be caught    and the parent window can act upon the collapsed or expanded state of the bar (which is actually just    the icon which changed). The parent panel can reduce size or expand again.*/#include <wx/imaglist.h>/** Defines an empty captionbar style */#define wxEmptyCaptionBarStyle wxCaptionBarStyle()class WXDLLIMPEXP_FOLDBAR wxCaptionBar: public wxWindow{private:    wxString m_caption;    wxImageList *m_foldIcons;    wxSize m_oldSize;    //wxFont m_captionFont;    int m_rightIndent;    int m_iconWidth, m_iconHeight;    //int m_captionStyle;    //wxColour m_firstColour, m_secondColour, m_textColour;    /** True when the caption is in collapsed state (means at the bottom of the wxFoldPanel */    bool m_collapsed;    wxCaptionBarStyle m_captionStyle;    /** Fills the background of the caption with either a gradient, or a solid color */    void FillCaptionBackground(wxPaintDC &dc);    /* Draw methods */    void DrawHorizontalGradient(wxDC &dc, const wxRect &rect );    void DrawVerticalGradient(wxDC &dc, const wxRect &rect );    void DrawSingleColour(wxDC &dc, const wxRect &rect );    void DrawSingleRectangle(wxDC &dc, const wxRect &rect );    void RedrawIconBitmap();    void ApplyCaptionStyle(const wxCaptionBarStyle &cbstyle, bool applyDefault);public:    /** Constructor of wxCaptionBar. To create a wxCaptionBar with the arrow images, simply pass an image list        which contains at least two bitmaps. The bitmaps contain the expanded and collapsed icons needed to        represent it's state. If you don't want images, simply pass a null pointer and the bitmap is disabled. */    wxCaptionBar(wxWindow* parent, const wxString &caption, wxImageList *images,                 wxWindowID id = wxID_ANY, const wxCaptionBarStyle &cbstyle = wxEmptyCaptionBarStyle,                 const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);    ~wxCaptionBar();    /** Set wxCaptionBar styles with wxCapionBarSyle class. All styles that are actually set, are applied. If you        set applyDefault to true, all other (not defined) styles will be set to default. If it is false,        the styles which are not set in the wxCaptionBarStyle will be ignored */    void SetCaptionStyle(bool applyDefault, wxCaptionBarStyle style = wxEmptyCaptionBarStyle) {        ApplyCaptionStyle(style, applyDefault);        Refresh();    };    /** Returns the current style of the captionbar in a wxCaptionBarStyle class. This can be used to change and set back the        changes. */    wxCaptionBarStyle GetCaptionStyle() {        return m_captionStyle;    };    bool IsVertical() const;#if 0    /** Sets a pointer to an image list resource (a non owned pointer) to the collapsed and expand icon bitmap.        The reason why it will be assigned a pointer is that it is very likely that multiple caption bars will        be used and if they all have their own bitmap resources it will eat up more memory then needed. It will        also ease the use of shared icon change, when there is any need to.        If no wxImageList is assigned, there will be no fold icons and only the doubleclick on the panel        will work to collapse / expand.        The image list must contain 2 bitmaps. Index 0 will be the expanded state, and index 1 will be the        collapsed state of the bitmap. The size of the bitmap is taken in account when the minimal height and        widht is calculated.        The bitmaps must be the second thing to be done before using it (SetRightIndent should be the first thing),        make sure if the icons are larger than the font, that the parent of this window gets a Fit call to resize        all the windows accordingly */    void SetFoldIcons(wxImageList *images) {        m_foldIcons = images;        m_iconWidth = m_iconHeight = 0;        if(m_foldIcons)            m_foldIcons->GetSize(0, m_iconWidth, m_iconHeight);        Refresh();    };#endif    /** Returns wether the status of the bar is expanded or collapsed */    bool IsCollapsed() const {        return m_collapsed;    };    /** Sets the amount of pixels on the right from which the bitmap is trailing. If this is 0, it will be        drawn all the way to the right, default is equal to wxFPB_BMP_RIGHTSPACE. Assign this before        assigning an image list to prevent a redraw */    void SetRightIndent(int pixels) {        wxCHECK2(pixels >= 0, return);        m_rightIndent = pixels;        // issue a refresh (if we have a bmp)        if(m_foldIcons)            Refresh();    };    /** Return the best size for this panel, based upon the font assigned to this window, and the        caption string */    wxSize DoGetBestSize() const;    /** This sets the internal state / representation to collapsed. This does not trigger a wxCaptionBarEvent        to be sent to the parent */    void Collapse() {        m_collapsed = true;        RedrawIconBitmap();    };    /** This sets the internal state / representation to expanded. This does not trigger a wxCaptionBarEvent        to be sent to the parent */    void Expand() {        m_collapsed = false;        RedrawIconBitmap();    };    void SetBoldFont() {        GetFont().SetWeight(wxBOLD);    };    void SetNormalFont() {        GetFont().SetWeight(wxNORMAL);    };private:    /** The paint event for flat or gradient fill */    void OnPaint(wxPaintEvent& event);    /** For clicking the icon, the mouse event must be intercepted */    void OnMouseEvent(wxMouseEvent& event);    /** Maybe when focus (don't know how yet) a cursor left or backspace will collapse or expand */    void OnChar(wxKeyEvent& event);    void OnSize(wxSizeEvent &event);protected:    DECLARE_NO_COPY_CLASS(wxCaptionBar)    DECLARE_EVENT_TABLE()};/***********************************************************************************************************//** \class wxCaptionBarEvent    This event will be sent when a EVT_CAPTIONBAR is mapped in the parent. It is to notify the parent    that the bar is now in collapsed or expanded state. The parent should re-arrange the associated    windows accordingly */class WXDLLIMPEXP_FOLDBAR wxCaptionBarEvent : public wxCommandEvent{private:    bool m_collapsed;    wxCaptionBar *m_captionBar;    void *m_tag;public:    wxCaptionBarEvent(wxEventType commandType = wxEVT_NULL, int id = 0)        : wxCommandEvent(commandType, id)        , m_collapsed(false)        , m_captionBar(NULL)        , m_tag(0)    { }    /** Constructor for clone copy */    wxCaptionBarEvent(const wxCaptionBarEvent &event);    /** Clone function */    virtual wxEvent *Clone() const {        return new wxCaptionBarEvent(*this);    };    /** Returns wether the bar is expanded or collapsed. True means expanded */    bool GetFoldStatus() const {        wxCHECK(m_captionBar, false);        return !m_captionBar->IsCollapsed();    };    /** Returns the bar associated with this event */    wxCaptionBar *GetCaptionBar() const {        return m_captionBar;    };    void SetTag(void *tag) {        m_tag = tag;    };    void *GetTag() const {        return m_tag;    };    /** Sets the bar associated with this event, should not used        by any other then the originator of the event */    void SetCaptionBar(wxCaptionBar *bar) {        m_captionBar = bar;    };    DECLARE_DYNAMIC_CLASS(wxCaptionBarEvent)};BEGIN_DECLARE_EVENT_TYPES()    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_FOLDBAR, wxEVT_CAPTIONBAR, 7777)END_DECLARE_EVENT_TYPES()typedef void (wxEvtHandler::*wxCaptionBarEventFunction)(wxCaptionBarEvent&);#define EVT_CAPTIONBAR(id, fn) \    DECLARE_EVENT_TABLE_ENTRY( \        wxEVT_CAPTIONBAR, id, wxID_ANY, \        (wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxCaptionBarEventFunction, & fn), \        (wxObject *) NULL \    ),#endif // _NO_CAPTIONBAR_#endif

⌨️ 快捷键说明

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