-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputdialog.cc
60 lines (51 loc) · 1.73 KB
/
inputdialog.cc
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
#include "inputdialog.h"
wxBEGIN_EVENT_TABLE(reInputDialog, wxDialog)
EVT_BUTTON(wxID_APPLY, reInputDialog::OnApply)
wxEND_EVENT_TABLE()
void reInputDialog::CreateControls()
{
wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
wxIntegerValidator<int> first_val(&first_);
wxIntegerValidator<int> second_val(&second_);
first_val.SetMin(-128);
first_val.SetMax(255);
second_val.SetMin(-128);
second_val.SetMax(255);
first_input_ = new wxTextCtrl(this, wxID_ANY, std::to_string(first_),
wxDefaultPosition, wxDefaultSize, 0L,
first_val, "0x80");
second_input_ = new wxTextCtrl(this, wxID_ANY, std::to_string(second_),
wxDefaultPosition, wxDefaultSize, 0L,
second_val, "0x81");
int input_height;
first_input_->GetSize(nullptr, &input_height);
first_input_->SetMinSize(wxSize(250, input_height));
second_input_->SetMinSize(wxSize(250, input_height));
sizer->AddSpacer(15);
sizer->Add(new wxStaticText(this, wxID_ANY, "0x80"), 0, wxLEFT, 15);
sizer->AddSpacer(5);
sizer->Add(first_input_, 0, wxLEFT | wxRIGHT, 15);
sizer->AddSpacer(15);
sizer->Add(new wxStaticText(this, wxID_ANY, "0x81"), 0, wxLEFT, 15);
sizer->AddSpacer(5);
sizer->Add(second_input_, 0, wxLEFT | wxRIGHT, 15);
sizer->AddSpacer(15);
sizer->Add(CreateButtonSizer(wxAPPLY),
wxSizerFlags().Align(wxALIGN_CENTER_HORIZONTAL));
sizer->AddSpacer(15);
SetSizerAndFit(sizer);
SetMaxSize(GetSize());
}
void reInputDialog::OnApply(wxCommandEvent& event)
{
if (Validate() && TransferDataFromWindow())
{
EndModal(wxID_APPLY);
}
else
{
SetReturnCode(wxID_CANCEL);
Show(false);
}
event.Skip();
}