bool ClickableWidget::setProperty(std::string property, const std::string& value) { property = toLower(property); if (property == "callback") { Widget::setProperty(property, value); std::vector<sf::String> callbacks; decodeList(value, callbacks); for (auto it = callbacks.begin(); it != callbacks.end(); ++it) { if ((*it == "LeftMousePressed") || (*it == "leftmousepressed")) bindCallback(LeftMousePressed); else if ((*it == "LeftMouseReleased") || (*it == "leftmousereleased")) bindCallback(LeftMouseReleased); else if ((*it == "LeftMouseClicked") || (*it == "leftmouseclicked")) bindCallback(LeftMouseClicked); } } else // The property didn't match return Widget::setProperty(property, value); // You pass here when one of the properties matched return true; }
void Sum::initialize() { QStringList items = decodeList(toAdd, this); int n = items.size(); values.clear(); for (int i = 0; i < n; ++i) { VariableBase *var = seekOne<Model*,VariableBase*>(items[i]); values << var; } }
bool AnimatedPicture::setProperty(std::string property, const std::string& value) { property = toLower(property); if (property == "playing") { if ((value == "true") || (value == "True")) m_Playing = true; else if ((value == "false") || (value == "False")) m_Playing = false; else TGUI_OUTPUT("TGUI error: Failed to parse 'Playing' property."); } else if (property == "looping") { if ((value == "true") || (value == "True")) m_Looping = true; else if ((value == "false") || (value == "False")) m_Looping = false; else TGUI_OUTPUT("TGUI error: Failed to parse 'Looping' property."); } else if (property == "callback") { ClickableWidget::setProperty(property, value); std::vector<sf::String> callbacks; decodeList(value, callbacks); for (auto it = callbacks.begin(); it != callbacks.end(); ++it) { if ((*it == "AnimationFinished") || (*it == "animationfinished")) bindCallback(AnimationFinished); } } else // The property didn't match return ClickableWidget::setProperty(property, value); // You pass here when one of the properties matched return true; }
bool Widget::setProperty(std::string property, const std::string& value) { property = toLower(property); if (property == "left") { setPosition(static_cast<float>(atof(value.c_str())), getPosition().y); } else if (property == "top") { setPosition(getPosition().x, static_cast<float>(atof(value.c_str()))); } else if (property == "width") { setSize(static_cast<float>(atof(value.c_str())), getSize().y); } else if (property == "height") { setSize(getSize().x, static_cast<float>(atof(value.c_str()))); } else if (property == "visible") { if ((value == "true") || (value == "True")) m_Visible = true; else if ((value == "false") || (value == "False")) m_Visible = false; else TGUI_OUTPUT("TGUI error: Failed to parse 'Visible' property."); } else if (property == "enabled") { if ((value == "true") || (value == "True")) m_Enabled = true; else if ((value == "false") || (value == "False")) m_Enabled = false; else TGUI_OUTPUT("TGUI error: Failed to parse 'Enabled' property."); } else if (property == "transparency") { setTransparency(static_cast<char>(atoi(value.c_str()))); } else if (property == "callbackid") { m_Callback.id = static_cast<unsigned int>(std::atoi(value.c_str())); } else if (property == "callback") { std::vector<sf::String> callbacks; decodeList(value, callbacks); for (auto it = callbacks.begin(); it != callbacks.end(); ++it) { if ((*it == "Focused") || (*it == "focused")) bindCallback(Focused); else if ((*it == "Unfocused") || (*it == "unfocused")) bindCallback(Unfocused); else if ((*it == "MouseEntered") || (*it == "mouseentered")) bindCallback(MouseEntered); else if ((*it == "MouseLeft") || (*it == "mouseleft")) bindCallback(MouseLeft); } } else // The property didn't match return false; // You pass here when one of the properties matched return true; }
void DecodeManager::decodeItem(QPostItem* item) { items.append(item); decodeList(); }
bool Checkbox::setProperty(std::string property, const std::string& value) { property = toLower(property); if (property == "configfile") { load(value); } else if (property == "checked") { if ((value == "true") || (value == "True")) check(); else if ((value == "false") || (value == "False")) uncheck(); else TGUI_OUTPUT("TGUI error: Failed to parse 'Checked' property."); } else if (property == "text") { setText(value); } else if (property == "textcolor") { setTextColor(extractColor(value)); } else if (property == "textsize") { setTextSize(atoi(value.c_str())); } else if (property == "allowtextclick") { if ((value == "true") || (value == "True")) allowTextClick(true); else if ((value == "false") || (value == "False")) allowTextClick(false); else TGUI_OUTPUT("TGUI error: Failed to parse 'AllowTextClick' property."); } else if (property == "callback") { ClickableWidget::setProperty(property, value); std::vector<sf::String> callbacks; decodeList(value, callbacks); for (auto it = callbacks.begin(); it != callbacks.end(); ++it) { if ((*it == "Checked") || (*it == "checked")) bindCallback(Checked); else if ((*it == "Unchecked") || (*it == "unchecked")) bindCallback(Unchecked); else if ((*it == "SpaceKeyPressed") || (*it == "spacekeypressed")) bindCallback(SpaceKeyPressed); else if ((*it == "ReturnKeyPressed") || (*it == "returnkeypressed")) bindCallback(ReturnKeyPressed); } } else // The property didn't match return ClickableWidget::setProperty(property, value); // You pass here when one of the properties matched return true; }