File: xh_bookctrlbase.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (82 lines) | stat: -rw-r--r-- 2,818 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/xrc/xh_bookctrlbase.h
// Purpose:     Base class for wxBookCtrl-derived classes XRC handlers
// Author:      Vadim Zeitlin
// Created:     2022-02-23
// Copyright:   (c) 2022 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_XRC_XH_BOOKCTRLBASE_H_
#define _WX_XRC_XH_BOOKCTRLBASE_H_

#include "wx/xrc/xmlres.h"

#if wxUSE_XRC && wxUSE_BOOKCTRL

class WXDLLIMPEXP_FWD_CORE wxBookCtrlBase;

// ----------------------------------------------------------------------------
// wxBookCtrlXmlHandlerBase: base class of handlers for wxBookCtrl subclasses
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_XRC wxBookCtrlXmlHandlerBase : public wxXmlResourceHandler
{
protected:
    wxBookCtrlXmlHandlerBase();
    virtual ~wxBookCtrlXmlHandlerBase();

    // Create all pages under the current node and add them to the book control.
    //
    // This should be called instead of calling CreateChildren() directly by
    // the derived class to deal with the contents of the book control node.
    void DoCreatePages(wxBookCtrlBase* book);

    // Create a new page using the contents of the current node.
    //
    // This should be called to handle the book control page node.
    wxObject* DoCreatePage(wxBookCtrlBase* book);

    // Return true if we're parsing the book control node itself.
    bool IsInside() const { return m_isInside; }

    // This struct contains the actual page, created by DoCreatePage(), and all
    // its attributes read from wxXmlNode.
    struct PageWithAttrs
    {
        PageWithAttrs();

        // Returns bmpId if it's valid or imgId (which can still be invalid)
        // otherwise.
        int GetImageId() const;

        wxWindow* wnd;
        wxString label;
        bool selected;
        int imgId; // index in the image list
        int bmpId; // index in m_bookImages vector
    };

private:
    // This function is implemented by just calling AddPage() in the base
    // class, but can be overridden if something else is needed, as is e.g. the
    // case for wxTreebookXmlHandler.
    virtual void
    DoAddPage(wxBookCtrlBase* book, size_t n, const PageWithAttrs& page);


    // And this vector contains all the pages created so far.
    wxVector<PageWithAttrs> m_bookPages;

    // All bitmaps defined for the pages, may be empty.
    wxVector<wxBitmapBundle> m_bookImages;

    // True if we're used for parsing the contents of the book control node.
    bool m_isInside;

    wxDECLARE_NO_COPY_CLASS(wxBookCtrlXmlHandlerBase);
};

#endif // wxUSE_XRC && wxUSE_BOOKCTRL

#endif // _WX_XRC_XH_BOOKCTRLBASE_H_