2013-11-28 10:29:01 +00:00
|
|
|
namespace phoenix {
|
|
|
|
|
|
|
|
void pTabFrame::append(string text, const image& image) {
|
|
|
|
unsigned selection = tabFrame.state.text.size() - 1;
|
2013-11-28 10:32:53 +00:00
|
|
|
qtTabFrame->addTab(new QWidget, QString::fromUtf8(text));
|
2013-11-28 10:29:01 +00:00
|
|
|
if(!image.empty()) setImage(selection, image);
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:32:53 +00:00
|
|
|
QWidget* pTabFrame::container(Widget& widget) {
|
|
|
|
Layout* widgetLayout = GetParentWidgetLayout(&widget);
|
|
|
|
unsigned selection = 0;
|
|
|
|
for(auto& layout : tabFrame.state.layout) {
|
|
|
|
if(layout == widgetLayout) return qtTabFrame->widget(selection);
|
|
|
|
selection++;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
Position pTabFrame::displacement() {
|
|
|
|
return {5, 33};
|
|
|
|
}
|
|
|
|
|
2013-11-28 10:29:01 +00:00
|
|
|
void pTabFrame::remove(unsigned selection) {
|
|
|
|
qtTabFrame->removeTab(selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::setEnabled(bool enabled) {
|
|
|
|
for(auto& layout : tabFrame.state.layout) {
|
|
|
|
if(layout) layout->setEnabled(layout->enabled());
|
|
|
|
}
|
|
|
|
pWidget::setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::setGeometry(Geometry geometry) {
|
|
|
|
pWidget::setGeometry(geometry);
|
2013-11-28 10:32:53 +00:00
|
|
|
geometry.x += 0, geometry.width -= 5;
|
|
|
|
geometry.y += 29, geometry.height -= 33;
|
2013-11-28 10:29:01 +00:00
|
|
|
for(auto& layout : tabFrame.state.layout) {
|
2013-11-28 10:32:53 +00:00
|
|
|
if(layout) layout->setGeometry(geometry);
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
synchronizeLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::setImage(unsigned selection, const image& image) {
|
|
|
|
qtTabFrame->setTabIcon(selection, CreateIcon(image));
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::setSelection(unsigned selection) {
|
2013-12-03 10:01:59 +00:00
|
|
|
locked = true;
|
2013-11-28 10:29:01 +00:00
|
|
|
qtTabFrame->setCurrentIndex(selection);
|
|
|
|
synchronizeLayout();
|
2013-12-03 10:01:59 +00:00
|
|
|
locked = false;
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::setText(unsigned selection, string text) {
|
|
|
|
qtTabFrame->setTabText(selection, QString::fromUtf8(text));
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::setVisible(bool visible) {
|
|
|
|
for(auto& layout : tabFrame.state.layout) {
|
|
|
|
if(layout) layout->setVisible(layout->visible());
|
|
|
|
}
|
|
|
|
pWidget::setVisible(visible);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::constructor() {
|
|
|
|
qtWidget = qtTabFrame = new QTabWidget;
|
|
|
|
connect(qtTabFrame, SIGNAL(currentChanged(int)), SLOT(onChange(int)));
|
|
|
|
|
|
|
|
setSelection(tabFrame.state.selection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::destructor() {
|
|
|
|
delete qtTabFrame;
|
|
|
|
qtWidget = qtTabFrame = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::orphan() {
|
|
|
|
destructor();
|
|
|
|
constructor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::synchronizeLayout() {
|
|
|
|
unsigned selection = 0;
|
|
|
|
for(auto& layout : tabFrame.state.layout) {
|
|
|
|
if(layout) layout->setVisible(selection == tabFrame.state.selection);
|
|
|
|
selection++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void pTabFrame::onChange(int selection) {
|
|
|
|
tabFrame.state.selection = selection;
|
|
|
|
synchronizeLayout();
|
2013-12-03 10:01:59 +00:00
|
|
|
if(!locked && tabFrame.onChange) tabFrame.onChange();
|
2013-11-28 10:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|