File: vertical-scroller.cpp

package info (click to toggle)
libretro-bsnes-mercury 094%2Bgit20160126-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 9,636 kB
  • sloc: cpp: 109,056; ansic: 3,097; makefile: 638; xml: 11; sh: 1
file content (45 lines) | stat: -rw-r--r-- 1,168 bytes parent folder | download | duplicates (5)
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
namespace phoenix {

Size pVerticalScroller::minimumSize() {
  return {18, 0};
}

void pVerticalScroller::setLength(unsigned length) {
  length += (length == 0);
  SetScrollRange(hwnd, SB_CTL, 0, length - 1, TRUE);
  verticalScroller.setPosition(0);
}

void pVerticalScroller::setPosition(unsigned position) {
  SetScrollPos(hwnd, SB_CTL, position, TRUE);
}

void pVerticalScroller::constructor() {
  hwnd = CreateWindow(
    L"SCROLLBAR", L"", WS_CHILD | SBS_VERT,
    0, 0, 0, 0, parentHwnd, (HMENU)id, GetModuleHandle(0), 0
  );
  SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&verticalScroller);
  unsigned position = verticalScroller.state.position;
  setLength(verticalScroller.state.length);
  verticalScroller.setPosition(position);
  synchronize();
}

void pVerticalScroller::destructor() {
  DestroyWindow(hwnd);
}

void pVerticalScroller::orphan() {
  destructor();
  constructor();
}

void pVerticalScroller::onChange(WPARAM wparam) {
  unsigned position = ScrollEvent(hwnd, wparam);
  if(position == verticalScroller.state.position) return;
  verticalScroller.state.position = position;
  if(verticalScroller.onChange) verticalScroller.onChange();
}

}