| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "SpecifierPanel.h" |
| 4 |
#include "SpecifierPanelFactory.h" |
| 5 |
#include <wx/event.h> |
| 6 |
|
| 7 |
class wxTextCtrl; |
| 8 |
|
| 9 |
namespace objectives |
| 10 |
{ |
| 11 |
|
| 12 |
class Component; |
| 13 |
|
| 14 |
namespace ce |
| 15 |
{ |
| 16 |
|
| 17 |
/** |
| 18 |
* SpecifierPanel intermediate class for all SpecifierPanels which wish to |
| 19 |
* provide a simple text entry box for editing their value. |
| 20 |
* |
| 21 |
* This class does not register itself directly in the SpecifierPanelFactory, |
| 22 |
* but should be used as a parent class for individual type-based |
| 23 |
* SpecifierPanels which register themselves correctly for a given SPEC_* type. |
| 24 |
*/ |
| 25 |
class TextSpecifierPanel : |
| 26 |
public wxEvtHandler, |
| 27 |
public SpecifierPanel |
| 28 |
{ |
| 29 |
protected: |
| 30 |
wxTextCtrl* _entry; |
| 31 |
|
| 32 |
// The change callback, invoked when the text changes |
| 33 |
std::function<void()> _valueChanged; |
| 34 |
|
| 35 |
TextSpecifierPanel(); |
| 36 |
|
| 37 |
public: |
| 38 |
TextSpecifierPanel(wxWindow* parent); |
| 39 |
|
| 40 |
virtual ~TextSpecifierPanel(); |
| 41 |
|
| 42 |
/* SpecifierPanel implementation */ |
| 43 |
virtual SpecifierPanelPtr create(wxWindow* parent) const |
| 44 |
{ |
| 45 |
return SpecifierPanelPtr(new TextSpecifierPanel(parent)); |
| 46 |
} |
| 47 |
|
| 48 |
void setChangedCallback(const std::function<void()>& callback) |
| 49 |
{ |
| 50 |
_valueChanged = callback; |
| 51 |
} |
| 52 |
|
| 53 |
virtual wxWindow* getWidget(); |
| 54 |
void setValue(const std::string& value); |
| 55 |
std::string getValue() const; |
| 56 |
|
| 57 |
private: |
| 58 |
void onEntryChanged(wxCommandEvent& ev); |
| 59 |
}; |
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
} |