Debian Codegraph @

phoenix/qt/widget/vertical-scroller.cpp

raw
1 namespace phoenix {
2
3 Size pVerticalScroller::minimumSize() {
4 return {15, 0};
5 }
6
7 void pVerticalScroller::setLength(unsigned length) {
8 length += length == 0;
9 qtScroller->setRange(0, length - 1);
10 qtScroller->setPageStep(length >> 3);
11 }
12
13 void pVerticalScroller::setPosition(unsigned position) {
14 qtScroller->setValue(position);
15 }
16
17 void pVerticalScroller::constructor() {
18 qtWidget = qtScroller = new QScrollBar(Qt::Vertical);
19 qtScroller->setRange(0, 100);
20 qtScroller->setPageStep(101 >> 3);
21 connect(qtScroller, SIGNAL(valueChanged(int)), SLOT(onChange()));
22
23 pWidget::synchronizeState();
24 setLength(verticalScroller.state.length);
25 setPosition(verticalScroller.state.position);
26 }
27
28 void pVerticalScroller::destructor() {
29 delete qtScroller;
30 qtWidget = qtScroller = nullptr;
31 }
32
33 void pVerticalScroller::orphan() {
34 destructor();
35 constructor();
36 }
37
38 void pVerticalScroller::onChange() {
39 verticalScroller.state.position = qtScroller->value();
40 if(verticalScroller.onChange) verticalScroller.onChange();
41 }
42
43 }