forked from xLightsSequencer/xLights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSustainDialog.cpp
142 lines (126 loc) · 6.47 KB
/
SustainDialog.cpp
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/***************************************************************
* This source files comes from the xLights project
* https://www.xlights.org
* https://github.com/smeighan/xLights
* See the github commit history for a record of contributing
* developers.
* Copyright claimed based on commit dates recorded in Github
* License: https://github.com/smeighan/xLights/blob/master/License.txt
**************************************************************/
#include "SustainDialog.h"
#include "xScheduleMain.h"
#include "ScheduleManager.h"
#include "../xLights/outputs/OutputManager.h"
//(*InternalHeaders(SustainDialog)
#include <wx/intl.h>
#include <wx/string.h>
//*)
//(*IdInit(SustainDialog)
const long SustainDialog::ID_STATICTEXT1 = wxNewId();
const long SustainDialog::ID_TEXTCTRL2 = wxNewId();
const long SustainDialog::ID_STATICTEXT5 = wxNewId();
const long SustainDialog::ID_STATICTEXT2 = wxNewId();
const long SustainDialog::ID_SPINCTRL2 = wxNewId();
const long SustainDialog::ID_STATICTEXT4 = wxNewId();
const long SustainDialog::ID_TEXTCTRL1 = wxNewId();
const long SustainDialog::ID_CHECKBOX1 = wxNewId();
const long SustainDialog::ID_BUTTON1 = wxNewId();
const long SustainDialog::ID_BUTTON2 = wxNewId();
//*)
BEGIN_EVENT_TABLE(SustainDialog,wxDialog)
//(*EventTable(SustainDialog)
//*)
END_EVENT_TABLE()
SustainDialog::SustainDialog(wxWindow* parent, OutputManager* outputManager, std::string& startChannel, size_t& channels, std::string& description, bool& enabled, wxWindowID id, const wxPoint& pos, const wxSize& size) : _startChannel(startChannel), _channels(channels), _description(description), _enabled(enabled)
{
_outputManager = outputManager;
//(*Initialize(SustainDialog)
wxBoxSizer* BoxSizer1;
wxFlexGridSizer* FlexGridSizer1;
wxFlexGridSizer* FlexGridSizer2;
Create(parent, id, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
SetClientSize(wxDefaultSize);
Move(wxDefaultPosition);
FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer1->AddGrowableCol(1);
StaticText1 = new wxStaticText(this, ID_STATICTEXT1, _("Start Channel:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT1"));
FlexGridSizer1->Add(StaticText1, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer2 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer2->AddGrowableCol(0);
TextCtrl_StartChannel = new wxTextCtrl(this, ID_TEXTCTRL2, _("1"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL2"));
FlexGridSizer2->Add(TextCtrl_StartChannel, 1, wxALL|wxEXPAND, 5);
StaticText_StartChannel = new wxStaticText(this, ID_STATICTEXT5, _("1"), wxDefaultPosition, wxSize(60,-1), 0, _T("ID_STATICTEXT5"));
FlexGridSizer2->Add(StaticText_StartChannel, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer1->Add(FlexGridSizer2, 1, wxALL|wxEXPAND, 5);
StaticText2 = new wxStaticText(this, ID_STATICTEXT2, _("Channels:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Channels = new wxSpinCtrl(this, ID_SPINCTRL2, _T("1"), wxDefaultPosition, wxDefaultSize, 0, 1, 100, 1, _T("ID_SPINCTRL2"));
SpinCtrl_Channels->SetValue(_T("1"));
FlexGridSizer1->Add(SpinCtrl_Channels, 1, wxALL|wxEXPAND, 5);
StaticText4 = new wxStaticText(this, ID_STATICTEXT4, _("Description:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT4"));
FlexGridSizer1->Add(StaticText4, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
TextCtrl_Description = new wxTextCtrl(this, ID_TEXTCTRL1, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_TEXTCTRL1"));
FlexGridSizer1->Add(TextCtrl_Description, 1, wxALL|wxEXPAND, 5);
FlexGridSizer1->Add(0,0,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
CheckBox_Enabled = new wxCheckBox(this, ID_CHECKBOX1, _("Enabled"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_CHECKBOX1"));
CheckBox_Enabled->SetValue(false);
FlexGridSizer1->Add(CheckBox_Enabled, 1, wxALL|wxEXPAND, 5);
FlexGridSizer1->Add(0,0,1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
BoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
Button_Ok = new wxButton(this, ID_BUTTON1, _("Ok"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));
Button_Ok->SetDefault();
BoxSizer1->Add(Button_Ok, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
Button_Cancel = new wxButton(this, ID_BUTTON2, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON2"));
BoxSizer1->Add(Button_Cancel, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
FlexGridSizer1->Add(BoxSizer1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
SetSizer(FlexGridSizer1);
FlexGridSizer1->Fit(this);
FlexGridSizer1->SetSizeHints(this);
Connect(ID_TEXTCTRL2,wxEVT_COMMAND_TEXT_UPDATED,(wxObjectEventFunction)&SustainDialog::OnTextCtrl_StartChannelText);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SustainDialog::OnButton_OkClick);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&SustainDialog::OnButton_CancelClick);
//*)
long chs = xScheduleFrame::GetScheduleManager()->GetTotalChannels();
SpinCtrl_Channels->SetRange(1, chs);
TextCtrl_StartChannel->SetValue(_startChannel);
SpinCtrl_Channels->SetValue(_channels);
TextCtrl_Description->SetValue(_description);
CheckBox_Enabled->SetValue(_enabled);
SetEscapeId(Button_Cancel->GetId());
SetAffirmativeId(Button_Ok->GetId());
ValidateWindow();
}
SustainDialog::~SustainDialog()
{
//(*Destroy(SustainDialog)
//*)
}
void SustainDialog::ValidateWindow()
{
long sc = _outputManager->DecodeStartChannel(TextCtrl_StartChannel->GetValue().ToStdString());
StaticText_StartChannel->SetLabel(wxString::Format("%ld", (long)sc));
if (sc == 0 || sc > xScheduleFrame::GetScheduleManager()->GetTotalChannels())
{
Button_Ok->Enable(false);
}
else
{
Button_Ok->Enable(true);
}
}
void SustainDialog::OnTextCtrl_StartChannelText(wxCommandEvent& event)
{
ValidateWindow();
}
void SustainDialog::OnButton_OkClick(wxCommandEvent& event)
{
_startChannel = TextCtrl_StartChannel->GetValue();
_channels = SpinCtrl_Channels->GetValue();
_description = TextCtrl_Description->GetValue().ToStdString();
_enabled = CheckBox_Enabled->IsChecked();
EndDialog(wxID_OK);
}
void SustainDialog::OnButton_CancelClick(wxCommandEvent& event)
{
EndDialog(wxID_CANCEL);
}