File: combobox.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 (77 lines) | stat: -rw-r--r-- 2,690 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
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/persist/combobox.h
// Purpose:     Interface of wxPersistentComboBox
// Author:      Vadim Zeitlin
// Created:     2020-11-19
// Copyright:   (c) 2020 Vadim Zeitlin <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

/**
    Persistence adapter for wxComboBox.

    This adapter saves and restores the items of wxComboBox. A persistent
    combobox can be used to preserve history of user entries.

    Example of using it:
    @code
    // Suppose you need to ask the user to select their favourite Linux
    // distribution, for some reason:
    wxComboBox* combo = new wxComboBox(this, wxID_ANY);
    if ( !wxPersistentRegisterAndRestore(combo, "distribution") )
    {
        // Seed it with some default contents.
        combo->Append("Debian");
        combo->Append("Fedora");
        combo->Append("Ubuntu");
    }

    // Optionally, you might want to restore the last used entry:
    combo->SetSelection(0);

    @endcode

    @since 3.1.5
 */
class wxPersistentComboBox : public wxPersistentWindow<wxComboBox>
{
public:
    /**
        Constructor.

        @param combobox
            The associated combobox.
     */
    explicit wxPersistentComboBox(wxComboBox *combobox);

    /**
        Save the current items and value.

        The current control value is saved as the first item, so that calling
        @c SetSelection(0) when the control is created the next time will
        restore the value which was last used. If the current value is the same
        as one of the existing items, this item is moved to the front of the
        list, instead of being added again.

        If the current value is empty, it is not saved at all.

        At most 10 items are saved, if the combobox has more than 10 items, or
        exactly 10 items and the current value is different from all of them,
        the items beyond the tenth one are discarded.
     */
    virtual void Save() const;

    /**
        Restore the combobox items.

        This function doesn't change the current combobox value, you need to
        call @c SetSelection(0) explicitly, after verifying that the combobox
        is not empty using its IsListEmpty() method, if you want to restore the
        last used value automatically. Otherwise the user can always do it by
        opening the combobox and selecting it manually.
     */
    virtual bool Restore();
};

/// Overload allowing persistence adapter creation for wxComboBox objects.
wxPersistentObject *wxCreatePersistentObject(wxComboBox *combobox);