| 1 |
#pragma once |
| 2 |
|
| 3 |
#include "ClassEditor.h" |
| 4 |
#include "wxutil/XmlResourceBasedWidget.h" |
| 5 |
#include "wxutil/menu/PopupMenu.h" |
| 6 |
#include <memory> |
| 7 |
|
| 8 |
class wxCheckBox; |
| 9 |
class wxStaticText; |
| 10 |
class wxSpinCtrl; |
| 11 |
class wxSpinCtrlDouble; |
| 12 |
class wxMenu; |
| 13 |
|
| 14 |
namespace ui |
| 15 |
{ |
| 16 |
|
| 17 |
class StimEditor : |
| 18 |
public ClassEditor, |
| 19 |
private wxutil::XmlResourceBasedWidget |
| 20 |
{ |
| 21 |
private: |
| 22 |
struct PropertyWidgets |
| 23 |
{ |
| 24 |
wxCheckBox* active; |
| 25 |
wxCheckBox* useBounds; |
| 26 |
wxCheckBox* radiusToggle; |
| 27 |
wxSpinCtrl* radiusEntry; |
| 28 |
wxCheckBox* finalRadiusToggle; |
| 29 |
wxSpinCtrl* finalRadiusEntry; |
| 30 |
wxCheckBox* timeIntToggle; |
| 31 |
wxSpinCtrl* timeIntEntry; |
| 32 |
wxStaticText* timeUnitLabel; |
| 33 |
|
| 34 |
struct TimerWidgets |
| 35 |
{ |
| 36 |
wxCheckBox* toggle; |
| 37 |
wxPanel* entryHBox; |
| 38 |
wxSpinCtrl* hour; |
| 39 |
wxSpinCtrl* minute; |
| 40 |
wxSpinCtrl* second; |
| 41 |
wxSpinCtrl* millisecond; |
| 42 |
|
| 43 |
wxCheckBox* typeToggle; |
| 44 |
|
| 45 |
wxCheckBox* reloadToggle; |
| 46 |
wxSpinCtrl* reloadEntry; |
| 47 |
wxStaticText* reloadLabel; |
| 48 |
wxPanel* reloadHBox; |
| 49 |
|
| 50 |
wxCheckBox* waitToggle; |
| 51 |
} timer; |
| 52 |
|
| 53 |
wxCheckBox* durationToggle; |
| 54 |
wxSpinCtrl* durationEntry; |
| 55 |
wxStaticText* durationUnitLabel; |
| 56 |
wxCheckBox* maxFireCountToggle; |
| 57 |
wxSpinCtrl* maxFireCountEntry; |
| 58 |
wxCheckBox* magnToggle; |
| 59 |
wxSpinCtrl* magnEntry; |
| 60 |
wxCheckBox* falloffToggle; |
| 61 |
wxSpinCtrlDouble* falloffEntry; |
| 62 |
wxCheckBox* chanceToggle; |
| 63 |
wxSpinCtrlDouble* chanceEntry; |
| 64 |
wxCheckBox* velocityToggle; |
| 65 |
wxTextCtrl* velocityEntry; |
| 66 |
|
| 67 |
struct BoundsWidgets |
| 68 |
{ |
| 69 |
wxCheckBox* toggle; |
| 70 |
wxPanel* panel; |
| 71 |
wxStaticText* minLabel; |
| 72 |
wxTextCtrl* minEntry; |
| 73 |
wxStaticText* maxLabel; |
| 74 |
wxTextCtrl* maxEntry; |
| 75 |
} bounds; |
| 76 |
} _propertyWidgets; |
| 77 |
|
| 78 |
struct ListContextMenu |
| 79 |
{ |
| 80 |
std::unique_ptr<wxMenu> menu; |
| 81 |
wxMenuItem* remove; |
| 82 |
wxMenuItem* add; |
| 83 |
wxMenuItem* enable; |
| 84 |
wxMenuItem* disable; |
| 85 |
wxMenuItem* duplicate; |
| 86 |
} _contextMenu; |
| 87 |
|
| 88 |
wxWindow* _mainPanel; |
| 89 |
|
| 90 |
public: |
| 91 |
// Constructor is setting up the stim editing panel |
| 92 |
StimEditor(wxWindow* mainPanel, StimTypes& stimTypes); |
| 93 |
|
| 94 |
/** greebo: Sets the new entity (is called by the StimResponseEditor class) |
| 95 |
*/ |
| 96 |
virtual void setEntity(const SREntityPtr& entity) override; |
| 97 |
|
| 98 |
/** greebo: Updates the widgets (e.g. after a selection change) |
| 99 |
*/ |
| 100 |
void update() override; |
| 101 |
|
| 102 |
void reloadStimTypes(); |
| 103 |
|
| 104 |
private: |
| 105 |
/** greebo: Retrieves the formatted timer string h:m:s:ms |
| 106 |
*/ |
| 107 |
std::string getTimerString(); |
| 108 |
|
| 109 |
/** greebo: Adds a new stim to the list |
| 110 |
*/ |
| 111 |
void addSR() override; |
| 112 |
|
| 113 |
/** greebo: Gets called when a spinbutton changes, overrides the |
| 114 |
* method from the base class. |
| 115 |
*/ |
| 116 |
void spinButtonChanged(wxSpinCtrl* ctrl) override; |
| 117 |
|
| 118 |
/** greebo: Updates the associated text fields when a check box |
| 119 |
* is toggled. |
| 120 |
*/ |
| 121 |
void checkBoxToggled(wxCheckBox* toggleButton) override; |
| 122 |
|
| 123 |
/** greebo: As the name states, this creates the context menu widgets. |
| 124 |
*/ |
| 125 |
void createContextMenu(); |
| 126 |
|
| 127 |
/** greebo: Gets called when the stim selection gets changed |
| 128 |
*/ |
| 129 |
virtual void selectionChanged() override; |
| 130 |
|
| 131 |
void openSRListContextMenu() override; |
| 132 |
|
| 133 |
void setupPage(); |
| 134 |
void setupEditPanel(); |
| 135 |
|
| 136 |
// Context menu callbacks |
| 137 |
void onContextMenuAdd(wxCommandEvent& ev); |
| 138 |
void onContextMenuDelete(wxCommandEvent& ev); |
| 139 |
}; |
| 140 |
|
| 141 |
} // namespace ui |