File: frame.cpp

package info (click to toggle)
ares 126-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 32,600 kB
  • sloc: cpp: 356,508; ansic: 20,394; makefile: 16; sh: 2
file content (64 lines) | stat: -rw-r--r-- 1,676 bytes parent folder | download | duplicates (4)
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
61
62
63
64
#if defined(Hiro_Frame)

namespace hiro {

auto pFrame::construct() -> void {
  qtWidget = qtFrame = new QGroupBox;
  if(QApplication::style()->objectName() == "gtk+") {
    //QGtkStyle (gtk+) theme disrespects font weight and omits the border, even if native GTK+ theme does not
    //bold Label controls already exist; so this style sheet forces QGtkStyle to look like a Frame instead
    qtFrame->setStyleSheet(
      "QGroupBox { border: 1px solid #aaa; border-radius: 5px; margin-top: 0.5em; }\n"
      "QGroupBox::title { left: 5px; subcontrol-origin: margin; }\n"
    );
  }

  pWidget::construct();
  _setState();
}

auto pFrame::destruct() -> void {
  delete qtFrame;
  qtWidget = qtFrame = nullptr;
}

auto pFrame::append(sSizable sizable) -> void {
}

auto pFrame::remove(sSizable sizable) -> void {
}

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

auto pFrame::setGeometry(Geometry geometry) -> void {
  pWidget::setGeometry(geometry);
  if(auto& sizable = state().sizable) {
    auto size = pFont::size(qtFrame->font(), state().text);
    if(!state().text) size.setHeight(8);
    sizable->setGeometry({
      4, size.height(),
      geometry.width() - 8,
      geometry.height() - size.height() - 4
    });
  }
}

auto pFrame::setText(const string& text) -> void {
  _setState();
}

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

auto pFrame::_setState() -> void {
  qtFrame->setTitle(QString::fromUtf8(state().text));
}

}

#endif