-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathButton.cpp
35 lines (30 loc) · 1.24 KB
/
Button.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
#include <wx/app.h>
#include <wx/button.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/stattext.h>
namespace ButtonExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "Button example"} {
button1->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
staticText1->SetLabel(wxString::Format("button1 clicked %d times", ++button1Clicked));
});
button2->Bind(wxEVT_BUTTON, [&](wxCommandEvent& event) {
staticText2->SetLabel(wxString::Format("button2 clicked %d times", ++button2Clicked));
});
}
private:
wxPanel* panel = new wxPanel {this};
wxButton* button1 = new wxButton {panel, wxID_ANY, "button1", {50, 10}};
wxButton* button2 = new wxButton {panel, wxID_ANY, "button2", {50, 60}, {200, 75}, wxBORDER_SIMPLE};
wxStaticText* staticText1 = new wxStaticText {panel, wxID_ANY, "button1 clicked 0 times", {50, 150}, {200, 20}};
wxStaticText* staticText2 = new wxStaticText {panel, wxID_ANY, "button2 clicked 0 times", {50, 180}, {200, 20}};
int button1Clicked = 0;
int button2Clicked = 0;
};
class Application : public wxApp {
bool OnInit() override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(ButtonExample::Application);