forked from xLightsSequencer/xLights
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDimWhiteDialog.cpp
152 lines (134 loc) · 7.1 KB
/
DimWhiteDialog.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
143
144
145
146
147
148
149
150
151
152
/***************************************************************
* 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 "DimWhiteDialog.h"
#include "xScheduleMain.h"
#include "ScheduleManager.h"
#include "../xLights/outputs/OutputManager.h"
//(*InternalHeaders(DimWhiteDialog)
#include <wx/intl.h>
#include <wx/string.h>
//*)
//(*IdInit(DimWhiteDialog)
const long DimWhiteDialog::ID_STATICTEXT1 = wxNewId();
const long DimWhiteDialog::ID_TEXTCTRL2 = wxNewId();
const long DimWhiteDialog::ID_STATICTEXT5 = wxNewId();
const long DimWhiteDialog::ID_STATICTEXT2 = wxNewId();
const long DimWhiteDialog::ID_SPINCTRL2 = wxNewId();
const long DimWhiteDialog::ID_STATICTEXT3 = wxNewId();
const long DimWhiteDialog::ID_SPINCTRL3 = wxNewId();
const long DimWhiteDialog::ID_STATICTEXT4 = wxNewId();
const long DimWhiteDialog::ID_TEXTCTRL1 = wxNewId();
const long DimWhiteDialog::ID_CHECKBOX1 = wxNewId();
const long DimWhiteDialog::ID_BUTTON1 = wxNewId();
const long DimWhiteDialog::ID_BUTTON2 = wxNewId();
//*)
BEGIN_EVENT_TABLE(DimWhiteDialog,wxDialog)
//(*EventTable(DimWhiteDialog)
//*)
END_EVENT_TABLE()
DimWhiteDialog::DimWhiteDialog(wxWindow* parent, OutputManager* outputManager, std::string& startChannel, size_t& channels, size_t& dim, std::string& description, bool& enabled, wxWindowID id,const wxPoint& pos,const wxSize& size) : _startChannel(startChannel), _nodes(channels), _dim(dim), _description(description), _enabled(enabled)
{
_outputManager = outputManager;
//(*Initialize(DimWhiteDialog)
wxFlexGridSizer* FlexGridSizer2;
wxBoxSizer* BoxSizer1;
wxFlexGridSizer* FlexGridSizer1;
Create(parent, id, _("Dim White"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, _T("id"));
SetClientSize(wxDefaultSize);
Move(wxDefaultPosition);
FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
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, _("Nodes:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT2"));
FlexGridSizer1->Add(StaticText2, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Nodes = new wxSpinCtrl(this, ID_SPINCTRL2, _T("1"), wxDefaultPosition, wxDefaultSize, 0, 1, 100, 1, _T("ID_SPINCTRL2"));
SpinCtrl_Nodes->SetValue(_T("1"));
FlexGridSizer1->Add(SpinCtrl_Nodes, 1, wxALL|wxEXPAND, 5);
StaticText3 = new wxStaticText(this, ID_STATICTEXT3, _("Brightness:"), wxDefaultPosition, wxDefaultSize, 0, _T("ID_STATICTEXT3"));
FlexGridSizer1->Add(StaticText3, 1, wxALL|wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL, 5);
SpinCtrl_Brightness = new wxSpinCtrl(this, ID_SPINCTRL3, _T("100"), wxDefaultPosition, wxDefaultSize, 0, 0, 100, 100, _T("ID_SPINCTRL3"));
SpinCtrl_Brightness->SetValue(_T("100"));
FlexGridSizer1->Add(SpinCtrl_Brightness, 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(-1,-1,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(-1,-1,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)&DimWhiteDialog::OnTextCtrl_StartChannelText);
Connect(ID_BUTTON1,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&DimWhiteDialog::OnButton_OkClick);
Connect(ID_BUTTON2,wxEVT_COMMAND_BUTTON_CLICKED,(wxObjectEventFunction)&DimWhiteDialog::OnButton_CancelClick);
//*)
long chs = xScheduleFrame::GetScheduleManager()->GetTotalChannels();
SpinCtrl_Nodes->SetRange(1, chs / 3);
TextCtrl_StartChannel->SetValue(_startChannel);
SpinCtrl_Nodes->SetValue(_nodes);
SpinCtrl_Brightness->SetValue(_dim);
TextCtrl_Description->SetValue(_description);
CheckBox_Enabled->SetValue(_enabled);
SetEscapeId(Button_Cancel->GetId());
SetAffirmativeId(Button_Ok->GetId());
ValidateWindow();
}
void DimWhiteDialog::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);
}
}
DimWhiteDialog::~DimWhiteDialog()
{
//(*Destroy(DimWhiteDialog)
//*)
}
void DimWhiteDialog::OnButton_OkClick(wxCommandEvent& event)
{
_startChannel = TextCtrl_StartChannel->GetValue();
_nodes = SpinCtrl_Nodes->GetValue();
_dim = SpinCtrl_Brightness->GetValue();
_description = TextCtrl_Description->GetValue().ToStdString();
_enabled = CheckBox_Enabled->IsChecked();
EndDialog(wxID_OK);
}
void DimWhiteDialog::OnButton_CancelClick(wxCommandEvent& event)
{
EndDialog(wxID_CANCEL);
}
void DimWhiteDialog::OnTextCtrl_StartChannelText(wxCommandEvent& event)
{
ValidateWindow();
}