File: SpecifierEditCombo.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (91 lines) | stat: -rw-r--r-- 2,426 bytes parent folder | download | duplicates (6)
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
#pragma once

#include <wx/panel.h>
#include "../Specifier.h"
#include "specpanel/SpecifierPanel.h"

class wxChoice;

namespace objectives
{

namespace ce
{

/**
 * Compound widget for changing specifier types and editing their values.
 *
 * A SpecifierEditCombo is a horizontal box containing two main elements. On the
 * left is a ComboBox which contains the names of a number of different
 * SpecifierType types, and on the right is a SpecifierPanel which is switched
 * depending on the selected dropdown value. The SpecifierEditCombo therefore
 * provides a means for the user to choose both a SpecifierType and its
 * associated value.
 *
 * Since some Component types accept a different subset of the SpecifierType types,
 * the SpecifierEditCombo can accept a std::set of SpecifierType types to display
 * in its dropdown list. Alternatively the entire set of Specifiers can be
 * made available.
 */
class SpecifierEditCombo :
	public wxPanel
{
private:
	// Current SpecifierPanel
	SpecifierPanelPtr _specPanel;

    // Combo box containing Specifiers
	wxChoice* _specifierCombo;

	std::function<void()> _valueChanged;

private:

    // Get the selected SpecifierType string
    std::string getSpecName() const;

    // Create the SpecifierPanel for the given specifier type
    void createSpecifierPanel(const std::string& type);

	// callback
	void _onChange(wxCommandEvent& ev);

public:

	/**
	 * Construct a SpecifierEditCombo with a subset of SpecifierType types
	 * available.
	 *
	 * @param set
	 * A SpecifierSet containing the subset of Specifiers which should be
	 * displayed in this edit combo. The default is the complete set of
	 * specifiers.
	 *
	 * @param valueChanged:
	 * A callback to be invoked when the edit combo (either type or argument) changes.
	 */
	SpecifierEditCombo(wxWindow* parent, const std::function<void()>& valueChanged, 
					   const SpecifierTypeSet& set = SpecifierType::SET_ALL());

    /**
     * Return the current value of the Specifier (type and value).
     *
     * @return
     * A Specifier containing the type and value of the Specifier as currently
     * shown by the edit widgets.
     */
    SpecifierPtr getSpecifier() const;

    /**
     * Set the Specifier to display in the ComboBox.
     *
     * @param
     * A Specifier containing the type and value to be displayed in the edit
     * widgets.
     */
    void setSpecifier(SpecifierPtr spec);
};

}

}