File: addremovectrl.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 (109 lines) | stat: -rw-r--r-- 3,372 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/addremovectrl.h
// Purpose:     wxAddRemoveCtrl declaration.
// Author:      Vadim Zeitlin
// Created:     2015-01-29
// Copyright:   (c) 2015 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_ADDREMOVECTRL_H_
#define _WX_ADDREMOVECTRL_H_

#include "wx/panel.h"

#if wxUSE_ADDREMOVECTRL

extern WXDLLIMPEXP_DATA_CORE(const char) wxAddRemoveCtrlNameStr[];

// ----------------------------------------------------------------------------
// wxAddRemoveAdaptor: used by wxAddRemoveCtrl to work with the list control
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxAddRemoveAdaptor
{
public:
    // Default ctor and trivial but virtual dtor.
    wxAddRemoveAdaptor() { }
    virtual ~wxAddRemoveAdaptor() { }

    // Override to return the associated control.
    virtual wxWindow* GetItemsCtrl() const = 0;

    // Override to return whether a new item can be added to the control.
    virtual bool CanAdd() const = 0;

    // Override to return whether the currently selected item (if any) can be
    // removed from the control.
    virtual bool CanRemove() const = 0;

    // Called when an item should be added, can only be called if CanAdd()
    // currently returns true.
    virtual void OnAdd() = 0;

    // Called when the current item should be removed, can only be called if
    // CanRemove() currently returns true.
    virtual void OnRemove() = 0;

private:
    wxDECLARE_NO_COPY_CLASS(wxAddRemoveAdaptor);
};

// ----------------------------------------------------------------------------
// wxAddRemoveCtrl: a list-like control combined with add/remove buttons
// ----------------------------------------------------------------------------

class WXDLLIMPEXP_CORE wxAddRemoveCtrl : public wxPanel
{
public:
    wxAddRemoveCtrl()
    {
        Init();
    }

    wxAddRemoveCtrl(wxWindow* parent,
                    wxWindowID winid = wxID_ANY,
                    const wxPoint& pos = wxDefaultPosition,
                    const wxSize& size = wxDefaultSize,
                    long style = 0,
                    const wxString& name = wxASCII_STR(wxAddRemoveCtrlNameStr))
    {
        Init();

        Create(parent, winid, pos, size, style, name);
    }

    bool Create(wxWindow* parent,
                wxWindowID winid = wxID_ANY,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                long style = 0,
                const wxString& name = wxASCII_STR(wxAddRemoveCtrlNameStr));

    virtual ~wxAddRemoveCtrl();

    // Must be called for the control to be usable, takes ownership of the
    // pointer.
    void SetAdaptor(wxAddRemoveAdaptor* adaptor);

    // Set tooltips to use for the add and remove buttons.
    void SetButtonsToolTips(const wxString& addtip, const wxString& removetip);

protected:
    virtual wxSize DoGetBestClientSize() const wxOVERRIDE;

private:
    // Common part of all ctors.
    void Init()
    {
        m_impl = NULL;
    }

    class wxAddRemoveImpl* m_impl;

    wxDECLARE_NO_COPY_CLASS(wxAddRemoveCtrl);
};

#endif // wxUSE_ADDREMOVECTRL

#endif // _WX_ADDREMOVECTRL_H_