-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathNumberEntryDialog.cpp
More file actions
31 lines (27 loc) · 1.01 KB
/
NumberEntryDialog.cpp
File metadata and controls
31 lines (27 loc) · 1.01 KB
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
#include <wx/app.h>
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/numdlg.h>
#include <wx/panel.h>
#include <wx/stattext.h>
namespace NumberEntryDialogExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "NumberEntryDialog example"} {
button->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
label->SetLabel("Number = ");
auto dialog = wxNumberEntryDialog {this, "Message text", "Prompt text", "Caption text", 50, 10, 100};
if (dialog.ShowModal() == wxID_OK)
label->SetLabel(wxString::Format("Number = %ld", dialog.GetValue()));
});
}
private:
wxPanel* panel = new wxPanel {this};
wxButton* button = new wxButton {panel, wxID_ANY, "Number...", {10, 10}};
wxStaticText* label = new wxStaticText {panel, wxID_ANY, "Number = ", {10, 50}};
};
class Application : public wxApp {
auto OnInit() -> bool override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(NumberEntryDialogExample::Application);