TGUI_API Widget::Ptr loadClickableWidget(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { if (widget) return loadWidget(node, widget); else return loadWidget(node, std::make_shared<ClickableWidget>()); }
TGUI_API Widget::Ptr loadTab(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Tab::Ptr tab; if (widget) tab = std::static_pointer_cast<Tab>(widget); else tab = std::make_shared<Tab>(); loadWidget(node, tab); if (node->propertyValuePairs["tabs"]) { if (!node->propertyValuePairs["tabs"]->listNode) throw Exception{"Failed to parse 'Tabs' property, expected a list as value"}; for (auto& tabText : node->propertyValuePairs["tabs"]->valueList) tab->add(Deserializer::deserialize(ObjectConverter::Type::String, tabText).getString()); } if (node->propertyValuePairs["maximumtabwidth"]) tab->setMaximumTabWidth(tgui::stof(node->propertyValuePairs["maximumtabwidth"]->value)); if (node->propertyValuePairs["textsize"]) tab->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["tabheight"]) tab->setTabHeight(tgui::stof(node->propertyValuePairs["tabheight"]->value)); if (node->propertyValuePairs["selected"]) tab->select(tgui::stoi(node->propertyValuePairs["selected"]->value)); return tab; }
TGUI_API Widget::Ptr loadTextBox(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { TextBox::Ptr textBox; if (widget) textBox = std::static_pointer_cast<TextBox>(widget); else textBox = std::make_shared<TextBox>(); loadWidget(node, textBox); if (node->propertyValuePairs["text"]) textBox->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["textsize"]) textBox->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["maximumcharacters"]) textBox->setMaximumCharacters(tgui::stoi(node->propertyValuePairs["maximumcharacters"]->value)); if (node->propertyValuePairs["readonly"]) textBox->setReadOnly(parseBoolean(node->propertyValuePairs["readonly"]->value)); for (auto& childNode : node->children) { if (toLower(childNode->name) == "scrollbar") textBox->setScrollbar(std::static_pointer_cast<Scrollbar>(WidgetLoader::getLoadFunction("scrollbar")(childNode))); } REMOVE_CHILD("scrollbar"); return textBox; }
void WidgetLoader::load(Container::Ptr parent, std::stringstream& stream) { auto rootNode = DataIO::parse(stream); if (rootNode->propertyValuePairs.size() != 0) loadWidget(rootNode, parent); for (auto& node : rootNode->children) { auto nameSeparator = node->name.find('.'); auto widgetType = node->name.substr(0, nameSeparator); auto& loadFunction = m_loadFunctions[toLower(widgetType)]; if (loadFunction) { std::string className; if (nameSeparator != std::string::npos) { if ((node->name.size() >= nameSeparator + 2) && (node->name[nameSeparator+1] == '"') && (node->name.back() == '"')) className = Deserializer::deserialize(ObjectConverter::Type::String, node->name.substr(nameSeparator + 1)).getString(); else className = node->name.substr(nameSeparator + 1); } tgui::Widget::Ptr widget = loadFunction(node); parent->add(widget, className); } else throw Exception{"No load function exists for widget type '" + widgetType + "'."}; } }
void EmbeddedFilesDock::fillInfo() { if (!m_table) // use delayed initialization for faster startup if not all docks are visible loadWidget(); m_table->setHorizontalHeaderLabels( QStringList() << tr("Name") << tr("Description") << tr("Size") << tr("Creation date") << tr("Modification date") << tr("Checksum")); if (!document()->hasEmbeddedFiles()) { m_table->setItem(0, 0, new QTableWidgetItem(tr("No files"))); return; } const QList<Poppler::EmbeddedFile*> files = document()->embeddedFiles(); m_table->setRowCount(files.count()); int i = 0; Q_FOREACH(Poppler::EmbeddedFile *file, files) { m_table->setItem(i, 0, new QTableWidgetItem(file->name())); m_table->setItem(i, 1, new QTableWidgetItem(file->description())); m_table->setItem(i, 2, new QTableWidgetItem(QString::number(file->size()))); m_table->setItem(i, 3, new QTableWidgetItem(file->createDate().toString(Qt::SystemLocaleDate))); m_table->setItem(i, 4, new QTableWidgetItem(file->modDate().toString(Qt::SystemLocaleDate))); const QByteArray checksum = file->checksum(); const QString checksumString = !checksum.isEmpty() ? QString::fromAscii(checksum.toHex()) : QString::fromLatin1("n/a"); m_table->setItem(i, 5, new QTableWidgetItem(checksumString)); ++i; }
void GUI::loadWidget(const Aurora::GFFStruct &strct, Widget *parent, float width, float height) { WidgetContext ctx(strct, parent); createWidget(ctx); if (width <= 0.0) width = ctx.widget->getWidth(); if (height <= 0.0) height = ctx.widget->getHeight(); float wX, wY, wZ; ctx.widget->getPosition(wX, wY, wZ); wX = wX - (width / 2.0); wY = ((height - wY) - ctx.widget->getHeight()) - (height / 2.0); wZ = _widgetZ + wZ; ctx.widget->setPosition(wX, wY, wZ); _widgetZ -= 1.0; addWidget(ctx.widget); // Go down to the children if (ctx.strct->hasField("CONTROLS")) { const Aurora::GFFList &children = ctx.strct->getList("CONTROLS"); for (Aurora::GFFList::const_iterator c = children.begin(); c != children.end(); ++c) loadWidget(**c, ctx.widget, width, height); } }
TGUI_API Widget::Ptr loadContainer(std::shared_ptr<DataIO::Node> node, Container::Ptr container) { assert(container != nullptr); loadWidget(node, container); for (auto& childNode : node->children) { auto nameSeparator = childNode->name.find('.'); auto widgetType = childNode->name.substr(0, nameSeparator); auto& loadFunction = WidgetLoader::getLoadFunction(toLower(widgetType)); if (loadFunction) { std::string className; if (nameSeparator != std::string::npos) { if ((childNode->name.size() >= nameSeparator + 2) && (childNode->name[nameSeparator+1] == '"') && (childNode->name.back() == '"')) className = Deserializer::deserialize(ObjectConverter::Type::String, childNode->name.substr(nameSeparator + 1)).getString(); else className = childNode->name.substr(nameSeparator + 1); } tgui::Widget::Ptr childWidget = loadFunction(childNode); container->add(childWidget, className); } else throw Exception{"No load function exists for widget type '" + widgetType + "'."}; } return container; }
void GUI::loadWidget(const Aurora::GFF3Struct &strct, Widget *parent) { WidgetContext ctx(strct, parent); createWidget(ctx); if (_guiWidth <= 0.0f) _guiWidth = ctx.widget->getWidth(); if (_guiHeight <= 0.0f) _guiHeight = ctx.widget->getHeight(); float wX, wY, wZ; ctx.widget->getPosition(wX, wY, wZ); convertToXoreos(wX, wY, ctx.widget->getHeight()); wZ = _widgetZ + wZ; ctx.widget->setPosition(wX, wY, wZ); _widgetZ -= 1.0f; addWidget(ctx.widget); // Go down to the children if (ctx.strct->hasField("CONTROLS")) { const Aurora::GFF3List &children = ctx.strct->getList("CONTROLS"); for (Aurora::GFF3List::const_iterator c = children.begin(); c != children.end(); ++c) loadWidget(**c, ctx.widget); } }
void GUI::load(const Common::UString &resref) { _name = resref; try { Common::ScopedPtr<Aurora::GFF3File> gff(new Aurora::GFF3File(resref, Aurora::kFileTypeGUI, MKTAG('G', 'U', 'I', ' '), true)); loadWidget(gff->getTopLevel(), 0); } catch (Common::Exception &e) { e.add("Can't load GUI \"%s\"", resref.c_str()); throw; } }
void TocDock::fillInfo() { if (!m_tree) // use delayed initialization for faster startup if not all docks are visible loadWidget(); const QDomDocument *toc = document()->toc(); if (toc) { fillToc(document(), *toc, m_tree, 0); } else { QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(0, tr("No table of contents found.")); item->setFlags(item->flags() & ~Qt::ItemIsEnabled); m_tree->addTopLevelItem(item); } delete toc; }
TGUI_API Widget::Ptr loadButton(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Button::Ptr button; if (widget) button = std::static_pointer_cast<Button>(widget); else button = std::make_shared<Button>(); loadWidget(node, button); if (node->propertyValuePairs["text"]) button->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["textsize"]) button->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); return button; }
void GUI::load(const Common::UString &resref) { // This is only relevant to Jade Empire. // LTI prefixed GUI definitions for the Windows version of Jade Empire // with lti_ to support mouse and keyboard control. _name = ResMan.hasResource("lti_" + resref, Aurora::kFileTypeGUI) ? _name = "lti_" + resref : resref; try { _gff.reset(new Aurora::GFF3File(_name, Aurora::kFileTypeGUI, MKTAG('G', 'U', 'I', ' '))); loadWidget(_gff->getTopLevel(), 0); } catch (Common::Exception &e) { e.add("Can't load GUI \"%s\"", _name.c_str()); throw; } }
void Loader::load() { auto node = ResourceRegistry::get<XMLResource>( "data" )->doc().first_element_by_path( "/kriti/guis" ); if(!node) { Message3(GUI, Debug, "No GUIs specified in data file!"); return; } for(auto child : node) { std::string guiName = child.attribute("name").as_string(""); m_guis[guiName] = loadWidget(child.child("widget")); } }
TGUI_API Widget::Ptr loadPicture(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Picture::Ptr picture; if (widget) picture = std::static_pointer_cast<Picture>(widget); else picture = std::make_shared<Picture>(); if (node->propertyValuePairs["filename"]) picture = std::make_shared<Picture>(DESERIALIZE_STRING("filename")); loadWidget(node, picture); if (node->propertyValuePairs["smooth"]) picture->setSmooth(parseBoolean(node->propertyValuePairs["smooth"]->value)); return picture; }
void GUI::load(const Common::UString &resref) { _name = resref; Aurora::GFF3File *gff = 0; try { gff = new Aurora::GFF3File(resref, Aurora::kFileTypeGUI, MKTAG('G', 'U', 'I', ' ')); loadWidget(gff->getTopLevel(), 0); } catch (Common::Exception &e) { delete gff; e.add("Can't load GUI \"%s\"", resref.c_str()); throw; } delete gff; }
TGUI_API Widget::Ptr loadSlider(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Slider::Ptr slider; if (widget) slider = std::static_pointer_cast<Slider>(widget); else slider = std::make_shared<Slider>(); loadWidget(node, slider); if (node->propertyValuePairs["minimum"]) slider->setMinimum(tgui::stoi(node->propertyValuePairs["minimum"]->value)); if (node->propertyValuePairs["maximum"]) slider->setMaximum(tgui::stoi(node->propertyValuePairs["maximum"]->value)); if (node->propertyValuePairs["value"]) slider->setValue(tgui::stoi(node->propertyValuePairs["value"]->value)); return slider; }
void GUI::load(const Common::UString &resref, float width, float height) { _name = resref; Aurora::GFFFile *gff = 0; try { gff = new Aurora::GFFFile(resref, Aurora::kFileTypeGUI, MKID_BE('GUI ')); loadWidget(gff->getTopLevel(), 0, width, height); } catch (Common::Exception &e) { delete gff; e.add("Can't load GUI \"%s\"", resref.c_str()); throw; } delete gff; }
TGUI_API Widget::Ptr loadEditBox(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { EditBox::Ptr editBox; if (widget) editBox = std::static_pointer_cast<EditBox>(widget); else editBox = std::make_shared<EditBox>(); loadWidget(node, editBox); if (node->propertyValuePairs["text"]) editBox->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["defaulttext"]) editBox->setDefaultText(DESERIALIZE_STRING("defaulttext")); if (node->propertyValuePairs["textsize"]) editBox->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["maximumcharacters"]) editBox->setMaximumCharacters(tgui::stoi(node->propertyValuePairs["maximumcharacters"]->value)); if (node->propertyValuePairs["textwidthlimited"]) editBox->limitTextWidth(parseBoolean(node->propertyValuePairs["textwidthlimited"]->value)); if (node->propertyValuePairs["caretwidth"]) editBox->setCaretWidth(tgui::stof(node->propertyValuePairs["caretwidth"]->value)); if (node->propertyValuePairs["numbersonly"]) editBox->setNumbersOnly(parseBoolean(node->propertyValuePairs["numbersonly"]->value)); if (node->propertyValuePairs["passwordcharacter"]) { std::string pass = DESERIALIZE_STRING("passwordcharacter"); if (!pass.empty()) editBox->setPasswordCharacter(pass[0]); } if (node->propertyValuePairs["alignment"]) { if (toLower(node->propertyValuePairs["alignment"]->value) == "left") editBox->setAlignment(EditBox::Alignment::Left); else if (toLower(node->propertyValuePairs["alignment"]->value) == "center") editBox->setAlignment(EditBox::Alignment::Center); else if (toLower(node->propertyValuePairs["alignment"]->value) == "right") editBox->setAlignment(EditBox::Alignment::Right); else throw Exception{"Failed to parse Alignment property. Only the values Left, Center and Right are correct."}; } return editBox; }
TGUI_API Widget::Ptr loadLabel(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Label::Ptr label; if (widget) label = std::static_pointer_cast<Label>(widget); else label = std::make_shared<Label>(); loadWidget(node, label); if (node->propertyValuePairs["textstyle"]) { sf::Uint32 style = sf::Text::Regular; std::vector<std::string> styles = tgui::split(node->propertyValuePairs["textstyle"]->value, '|'); for (auto& elem : styles) { std::string requestedStyle = toLower(trim(elem)); if (requestedStyle == "bold") style |= sf::Text::Bold; else if (requestedStyle == "italic") style |= sf::Text::Italic; else if (requestedStyle == "underlined") style |= sf::Text::Underlined; else if (requestedStyle == "strikethrough") style |= sf::Text::StrikeThrough; else if (requestedStyle != "regular") throw Exception{"Failed to parse TextStyle property, found unknown style."}; } label->setTextStyle(style); } if (node->propertyValuePairs["text"]) label->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["textsize"]) label->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["maximumtextwidth"]) label->setMaximumTextWidth(tgui::stof(node->propertyValuePairs["maximumtextwidth"]->value)); if (node->propertyValuePairs["autosize"]) label->setAutoSize(parseBoolean(node->propertyValuePairs["autosize"]->value)); return label; }
TGUI_API Widget::Ptr loadSpinButton(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { SpinButton::Ptr spinButton; if (widget) spinButton = std::static_pointer_cast<SpinButton>(widget); else spinButton = std::make_shared<SpinButton>(); loadWidget(node, spinButton); if (node->propertyValuePairs["minimum"]) spinButton->setMinimum(tgui::stoi(node->propertyValuePairs["minimum"]->value)); if (node->propertyValuePairs["maximum"]) spinButton->setMaximum(tgui::stoi(node->propertyValuePairs["maximum"]->value)); if (node->propertyValuePairs["value"]) spinButton->setValue(tgui::stoi(node->propertyValuePairs["value"]->value)); if (node->propertyValuePairs["verticalscroll"]) spinButton->setVerticalScroll(parseBoolean(node->propertyValuePairs["verticalscroll"]->value)); return spinButton; }
TGUI_API Widget::Ptr loadCheckBox(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { CheckBox::Ptr checkbox; if (widget) checkbox = std::static_pointer_cast<CheckBox>(widget); else checkbox = std::make_shared<CheckBox>(); loadWidget(node, checkbox); if (node->propertyValuePairs["text"]) checkbox->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["textsize"]) checkbox->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["checked"]) { if (parseBoolean(node->propertyValuePairs["checked"]->value)) checkbox->check(); } return checkbox; }
TGUI_API Widget::Ptr loadRadioButton(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { RadioButton::Ptr radioButton; if (widget) radioButton = std::static_pointer_cast<RadioButton>(widget); else radioButton = std::make_shared<RadioButton>(); loadWidget(node, radioButton); if (node->propertyValuePairs["text"]) radioButton->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["textsize"]) radioButton->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["checked"]) { if (parseBoolean(node->propertyValuePairs["checked"]->value)) radioButton->check(); } return radioButton; }
TGUI_API Widget::Ptr loadScrollbar(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Scrollbar::Ptr scrollbar; if (widget) scrollbar = std::static_pointer_cast<Scrollbar>(widget); else scrollbar = std::make_shared<Scrollbar>(); loadWidget(node, scrollbar); if (node->propertyValuePairs["lowvalue"]) scrollbar->setLowValue(tgui::stoi(node->propertyValuePairs["lowvalue"]->value)); if (node->propertyValuePairs["maximum"]) scrollbar->setMaximum(tgui::stoi(node->propertyValuePairs["maximum"]->value)); if (node->propertyValuePairs["value"]) scrollbar->setValue(tgui::stoi(node->propertyValuePairs["value"]->value)); if (node->propertyValuePairs["arrowscrollamount"]) scrollbar->setArrowScrollAmount(tgui::stoi(node->propertyValuePairs["arrowscrollamount"]->value)); if (node->propertyValuePairs["autohide"]) scrollbar->setAutoHide(parseBoolean(node->propertyValuePairs["autohide"]->value)); return scrollbar; }
TGUI_API Widget::Ptr loadComboBox(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { ComboBox::Ptr comboBox; if (widget) comboBox = std::static_pointer_cast<ComboBox>(widget); else comboBox = std::make_shared<ComboBox>(); for (auto& childNode : node->children) { if (toLower(childNode->name) == "listbox") comboBox->setListBox(std::static_pointer_cast<ListBox>(WidgetLoader::getLoadFunction("listbox")(childNode))); } REMOVE_CHILD("listbox"); loadWidget(node, comboBox); if (node->propertyValuePairs["itemstodisplay"]) comboBox->setItemsToDisplay(tgui::stoi(node->propertyValuePairs["itemstodisplay"]->value)); return comboBox; }
TGUI_API Widget::Ptr loadProgressBar(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { ProgressBar::Ptr progressBar; if (widget) progressBar = std::static_pointer_cast<ProgressBar>(widget); else progressBar = std::make_shared<ProgressBar>(); loadWidget(node, progressBar); if (node->propertyValuePairs["minimum"]) progressBar->setMinimum(tgui::stoi(node->propertyValuePairs["minimum"]->value)); if (node->propertyValuePairs["maximum"]) progressBar->setMaximum(tgui::stoi(node->propertyValuePairs["maximum"]->value)); if (node->propertyValuePairs["value"]) progressBar->setValue(tgui::stoi(node->propertyValuePairs["value"]->value)); if (node->propertyValuePairs["text"]) progressBar->setText(DESERIALIZE_STRING("text")); if (node->propertyValuePairs["textsize"]) progressBar->setTextSize(tgui::stoi(node->propertyValuePairs["textsize"]->value)); if (node->propertyValuePairs["filldirection"]) { std::string requestedStyle = toLower(trim(node->propertyValuePairs["filldirection"]->value)); if (requestedStyle == "lefttoright") progressBar->setFillDirection(tgui::ProgressBar::FillDirection::LeftToRight); else if (requestedStyle == "righttoleft") progressBar->setFillDirection(tgui::ProgressBar::FillDirection::RightToLeft); else if (requestedStyle == "toptobottom") progressBar->setFillDirection(tgui::ProgressBar::FillDirection::TopToBottom); else if (requestedStyle == "toptobottom") progressBar->setFillDirection(tgui::ProgressBar::FillDirection::TopToBottom); else throw Exception{"Failed to parse FillDirection property, found unknown value."}; } return progressBar; }
TGUI_API Widget::Ptr loadKnob(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { Knob::Ptr knob; if (widget) knob = std::static_pointer_cast<Knob>(widget); else knob = std::make_shared<Knob>(); loadWidget(node, knob); if (node->propertyValuePairs["startrotation"]) knob->setStartRotation(tgui::stof(node->propertyValuePairs["startrotation"]->value)); if (node->propertyValuePairs["endrotation"]) knob->setEndRotation(tgui::stof(node->propertyValuePairs["endrotation"]->value)); if (node->propertyValuePairs["minimum"]) knob->setMinimum(tgui::stoi(node->propertyValuePairs["minimum"]->value)); if (node->propertyValuePairs["maximum"]) knob->setMaximum(tgui::stoi(node->propertyValuePairs["maximum"]->value)); if (node->propertyValuePairs["value"]) knob->setValue(tgui::stoi(node->propertyValuePairs["value"]->value)); if (node->propertyValuePairs["clockwiseturning"]) knob->setClockwiseTurning(parseBoolean(node->propertyValuePairs["clockwiseturning"]->value)); return knob; }
void GUI::loadWidget(const Aurora::GFF3Struct &strct, Widget *parent) { WidgetContext ctx(strct, parent); createWidget(ctx); addWidget(ctx.widget); if (ctx.parent) { if (ctx.strct->getString("Obj_Parent") != ctx.parent->getTag()) throw Common::Exception("Parent's tag != Obj_Parent"); parent->addChild(*ctx.widget); float pX, pY, pZ; parent->getPosition(pX, pY, pZ); float x = ctx.strct->getDouble("Obj_X") * 100.0 + pX; float y = ctx.strct->getDouble("Obj_Y") * 100.0 + pY; float z = pZ - ctx.strct->getDouble("Obj_Z") * 100.0; ctx.widget->setPosition(x, y, z); } else { // We'll ignore these for now, centering the GUI } initWidget(ctx); // Create a caption/label and move the label to its destined position WidgetLabel *label = createCaption(ctx); if (label && ctx.strct->hasField("Obj_Caption")) { const Aurora::GFF3Struct &caption = ctx.strct->getStruct("Obj_Caption"); float alignH = caption.getDouble("AurString_AlignH"); float alignV = caption.getDouble("AurString_AlignV"); float labelX = ctx.strct->getDouble("Obj_Label_X") * 100.0; float labelY = ctx.strct->getDouble("Obj_Label_Y") * 100.0; float labelZ = ctx.strct->getDouble("Obj_Label_Z") * 100.0; if (ctx.type != kWidgetTypeLabel) { if (label->getWidth() > ctx.widget->getWidth() || label->getHeight() > ctx.widget->getHeight()) label->setText(label->getText(), alignH, ctx.widget->getWidth(), ctx.widget->getHeight()); labelX += ctx.widget->getWidth () * alignV; labelY += ctx.widget->getHeight() * alignH; labelX -= label->getWidth () / 2; labelY -= label->getHeight() / 2; } else { float labelWidth = 0.0; if (ctx.strct->hasField("Obj_Label_Width")) labelWidth = ctx.strct->getDouble("Obj_Label_Width") * 100.0; float labelHeight = 0.0; if (ctx.strct->hasField("Obj_Label_Height")) labelHeight = ctx.strct->getDouble("Obj_Label_Height") * 100.0; if (alignV == 0.5) { bool multilines = false; if (label->getWidth() > labelWidth) multilines = true; label->setText(label->getText(), alignH, labelWidth, labelHeight); labelX += labelWidth * alignH; if (multilines) labelY += label->getHeight() * alignV; } labelX -= label->getWidth () * alignH; labelY -= label->getHeight(); labelY -= label->getHeight() * alignV; } label->movePosition(labelX, labelY, -labelZ); } // uint32 layer = strct.getUint("Obj_Layer"); // bool locked = strct.getUint("Obj_Locked") != 0; // Go down to the children if (ctx.strct->hasField("Obj_ChildList")) { const Aurora::GFF3List &children = ctx.strct->getList("Obj_ChildList"); for (Aurora::GFF3List::const_iterator c = children.begin(); c != children.end(); ++c) loadWidget(**c, ctx.widget); } }
bool CQUpdatesWidget::enterProtected() { loadWidget(); return true; }
void MainWindow::showUI() { infoloader->run(); // ui->webView->setHtml(html,QUrl("qrc:/")); QTextStream sout(stdout); sout << infoloader->resultAsText(); ui->progressBar->setVisible(false); bool qmlUI = false; // If QtDeclarative and Qt Quick Components are available, use QML UI QWidget* widget = NULL; if (infoloader->isLoaded("Qt5Quick") || infoloader->isLoaded("QtQuick")) { // go for fancy declarative UI instead of QWidgets sout << "QtQuick module present, contemplating QML UI"; qDebug() << "QtQuick module present, contemplating QML UI"; if (callBoolFunction("qt5declarativeui", "isQmlUiAvailable")) { sout << "loading QML5 UI"; qDebug() << "loading QML5 UI"; widget = loadWidget("qt5declarativeui", "declarativeUI"); sout << widget; qDebug() << widget; } } if (widget == NULL && (infoloader->isLoaded("QtDeclarative") || infoloader->isLoaded("Qt5Declarative"))) { // go for fancy declarative UI instead of QWidgets sout << "Declarative module present, contemplating QML UI"; if (widget == NULL && callBoolFunction("declarativeui", "isQmlUiAvailable")) { sout << "loading QML UI"; widget = loadWidget("declarativeui", "declarativeUI"); } } if (widget != NULL) { // we have a living breathing QtQuick widget! sout << "QML UI is a GO!"; qDebug() << "QML UI is a GO!"; qmlUI = true; widget->setParent(this); ui->textBrowser->setVisible(false); ui->widget->setEnabled(true); ui->widget->setVisible(true); widget->showFullScreen(); // Note that QML buttons should call the same methods as the auto-slot-connected buttons } else { // this->statusBar()->setVisible(true); ui->emailButton->setVisible(true); ui->jsbinButton->setVisible(true); ui->clipboardButton->setVisible(true); ui->saveButton->setVisible(true); #ifndef Q_WS_MAEMO_5 ui->closeButton->setVisible(true); // maemo5 has X provided by the window manager #endif } if (!qmlUI) { ui->textBrowser->setHtml(infoloader->resultAsHTML()); } else { delete ui->textBrowser; ui->textBrowser = 0; } }
TGUI_API Widget::Ptr loadListBox(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr) { ListBox::Ptr listBox; if (widget) listBox = std::static_pointer_cast<ListBox>(widget); else listBox = std::make_shared<ListBox>(); loadWidget(node, listBox); if (node->propertyValuePairs["items"]) { if (!node->propertyValuePairs["items"]->listNode) throw Exception{"Failed to parse 'Items' property, expected a list as value"}; if (node->propertyValuePairs["itemids"]) { if (!node->propertyValuePairs["itemids"]->listNode) throw Exception{"Failed to parse 'ItemIds' property, expected a list as value"}; if (node->propertyValuePairs["items"]->valueList.size() != node->propertyValuePairs["itemids"]->valueList.size()) throw Exception{"Amounts of values for 'Items' differs from the amount in 'ItemIds'"}; for (unsigned int i = 0; i < node->propertyValuePairs["items"]->valueList.size(); ++i) { listBox->addItem(Deserializer::deserialize(ObjectConverter::Type::String, node->propertyValuePairs["items"]->valueList[i]).getString(), Deserializer::deserialize(ObjectConverter::Type::String, node->propertyValuePairs["itemids"]->valueList[i]).getString()); } } else // There are no item ids { for (auto& item : node->propertyValuePairs["items"]->valueList) listBox->addItem(item); } } else // If there are no items, there should be no item ids { if (node->propertyValuePairs["itemids"]) { if (!node->propertyValuePairs["itemids"]->listNode) throw Exception{"Failed to parse 'ItemIds' property, expected a list as value"}; if (!node->propertyValuePairs["itemids"]->valueList.empty()) throw Exception{"Found 'ItemIds' property while there is no 'Items' property"}; } } if (node->propertyValuePairs["itemheight"]) listBox->setItemHeight(tgui::stoi(node->propertyValuePairs["itemheight"]->value)); if (node->propertyValuePairs["maximumitems"]) listBox->setMaximumItems(tgui::stoi(node->propertyValuePairs["maximumitems"]->value)); for (auto& childNode : node->children) { if (toLower(childNode->name) == "scrollbar") listBox->setScrollbar(std::static_pointer_cast<Scrollbar>(WidgetLoader::getLoadFunction("scrollbar")(childNode))); } REMOVE_CHILD("scrollbar"); return listBox; }