| 1 |
#if defined(Hiro_Frame) |
| 2 |
|
| 3 |
namespace hiro { |
| 4 |
|
| 5 |
auto pFrame::construct() -> void { |
| 6 |
qtWidget = qtFrame = new QGroupBox; |
| 7 |
if(QApplication::style()->objectName() == "gtk+") { |
| 8 |
//QGtkStyle (gtk+) theme disrespects font weight and omits the border, even if native GTK+ theme does not |
| 9 |
//bold Label controls already exist; so this style sheet forces QGtkStyle to look like a Frame instead |
| 10 |
qtFrame->setStyleSheet( |
| 11 |
"QGroupBox { border: 1px solid #aaa; border-radius: 5px; margin-top: 0.5em; }\n" |
| 12 |
"QGroupBox::title { left: 5px; subcontrol-origin: margin; }\n" |
| 13 |
); |
| 14 |
} |
| 15 |
|
| 16 |
pWidget::construct(); |
| 17 |
_setState(); |
| 18 |
} |
| 19 |
|
| 20 |
auto pFrame::destruct() -> void { |
| 21 |
delete qtFrame; |
| 22 |
qtWidget = qtFrame = nullptr; |
| 23 |
} |
| 24 |
|
| 25 |
auto pFrame::append(sSizable sizable) -> void { |
| 26 |
} |
| 27 |
|
| 28 |
auto pFrame::remove(sSizable sizable) -> void { |
| 29 |
} |
| 30 |
|
| 31 |
auto pFrame::setEnabled(bool enabled) -> void { |
| 32 |
if(auto& sizable = state().sizable) sizable->setEnabled(sizable->enabled()); |
| 33 |
pWidget::setEnabled(enabled); |
| 34 |
} |
| 35 |
|
| 36 |
auto pFrame::setGeometry(Geometry geometry) -> void { |
| 37 |
pWidget::setGeometry(geometry); |
| 38 |
if(auto& sizable = state().sizable) { |
| 39 |
auto size = pFont::size(qtFrame->font(), state().text); |
| 40 |
if(!state().text) size.setHeight(8); |
| 41 |
sizable->setGeometry({ |
| 42 |
4, size.height(), |
| 43 |
geometry.width() - 8, |
| 44 |
geometry.height() - size.height() - 4 |
| 45 |
}); |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
auto pFrame::setText(const string& text) -> void { |
| 50 |
_setState(); |
| 51 |
} |
| 52 |
|
| 53 |
auto pFrame::setVisible(bool visible) -> void { |
| 54 |
if(auto& sizable = state().sizable) sizable->setVisible(sizable->visible()); |
| 55 |
pWidget::setVisible(visible); |
| 56 |
} |
| 57 |
|
| 58 |
auto pFrame::_setState() -> void { |
| 59 |
qtFrame->setTitle(QString::fromUtf8(state().text)); |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
|
| 64 |
#endif |