-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathScrollBar.cpp
More file actions
39 lines (31 loc) · 1.38 KB
/
ScrollBar.cpp
File metadata and controls
39 lines (31 loc) · 1.38 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
32
33
34
35
36
37
38
39
#include <wx/app.h>
#include <wx/frame.h>
#include <wx/panel.h>
#include <wx/scrolbar.h>
namespace ScrollBarExample {
class Frame : public wxFrame {
public:
Frame() : wxFrame {nullptr, wxID_ANY, "ScrollBar example"} {
SetClientSize(300, 300);
scrollBar1->SetScrollbar(10, 1, 20, 1);
scrollBar1->SetSize(220, scrollBar1->GetSize().GetHeight());
scrollBar1->Bind(wxEVT_SCROLLBAR, [&](wxCommandEvent& e){
wxMessageOutputDebug().Printf("wxEVT_SCROLL_TOP {position %d}", scrollBar1->GetThumbPosition());
});
scrollBar2->SetScrollbar(0, 1, 100, 1);
scrollBar3->SetScrollbar(10, 1, 20, 1);
scrollBar3->SetSize(scrollBar3->GetSize().GetWidth(), 220);
scrollBar4->SetScrollbar(0, 1, 100, 1);
}
private:
wxPanel* panel = new wxPanel {this};
wxScrollBar* scrollBar1 = new wxScrollBar {panel, wxID_ANY, {10, 10}, wxDefaultSize, wxSB_HORIZONTAL};
wxScrollBar* scrollBar2 = new wxScrollBar {panel, wxID_ANY, {10, 40}, wxDefaultSize, wxSB_HORIZONTAL};
wxScrollBar* scrollBar3 = new wxScrollBar {panel, wxID_ANY, {270, 70}, wxDefaultSize, wxSB_VERTICAL};
wxScrollBar* scrollBar4 = new wxScrollBar {panel, wxID_ANY, {240, 190}, wxDefaultSize, wxSB_VERTICAL};
};
class Application : public wxApp {
auto OnInit() -> bool override {return (new Frame)->Show();}
};
}
wxIMPLEMENT_APP(ScrollBarExample::Application);