File: frame.cpp

package info (click to toggle)
higan 098-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 11,904 kB
  • ctags: 13,286
  • sloc: cpp: 108,285; ansic: 778; makefile: 32; sh: 18
file content (60 lines) | stat: -rw-r--r-- 1,457 bytes parent folder | download
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#if defined(Hiro_Frame)

namespace hiro {

auto pFrame::construct() -> void {
  hwnd = CreateWindow(L"BUTTON", L"",
    WS_CHILD | BS_GROUPBOX,
    0, 0, 0, 0, _parentHandle(), nullptr, GetModuleHandle(0), 0);
  SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)&reference);
  pWidget::_setState();
  setText(state().text);
}

auto pFrame::destruct() -> void {
  DestroyWindow(hwnd);
}

auto pFrame::append(sLayout layout) -> void {
}

auto pFrame::remove(sLayout layout) -> void {
}

auto pFrame::setEnabled(bool enabled) -> void {
  if(auto layout = state().layout) layout->setEnabled(layout->enabled());
  pWidget::setEnabled(enabled);
}

auto pFrame::setGeometry(Geometry geometry) -> void {
  bool empty = !state().text;
  auto size = pFont::size(hfont, state().text);
  pWidget::setGeometry({
    geometry.x(),
    geometry.y() - (empty ? size.height() >> 1 : 0),
    geometry.width(),
    geometry.height() + (empty ? size.height() >> 1 : 0)
  });
  if(auto layout = state().layout) {
    if(empty) size.setHeight(1);
    layout->setGeometry({
      geometry.x() + 1,
      geometry.y() + size.height(),
      geometry.width() - 2,
      geometry.height() - (size.height() + 2)
    });
  }
}

auto pFrame::setText(const string& text) -> void {
  SetWindowText(hwnd, utf16_t(text));
}

auto pFrame::setVisible(bool visible) -> void {
  if(auto layout = state().layout) layout->setVisible(layout->visible());
  pWidget::setVisible(visible);
}

}

#endif