OptionsParser::OptionsParser() { AddNewOption('c', "conf", "specify the configuration file, ./conf/webhttpd.conf default."); AddNewOption('h', "help", "print the help infomation."); }
DropdownWidget::DropdownWidget(const XMLNode& node) :BaseWidget2(node) , m_renderer(nullptr) , m_textRenderer(nullptr) , m_isExpend(false) { //m_currentStateProperty = m_forStates[1]; for (int i = 0; i < NUM_WIDGET_STATE_; i++) { m_forStates[i].fromCode.Set("BGColor", RGBA(0.0F, 0.0F, 0.0F, 1.0F)); m_forStates[i].fromCode.Set("edgeColor", RGBA(1.0F, 1.0F, 1.0F, 1.0F)); m_forStates[i].fromCode.Set("position", Vector2(200.0f, 500.0f)); //m_forStates[i].fromCode.Set("mins", Vector2(200.0f, 500.0f)); m_forStates[i].fromCode.Set("textColor", RGBA(1.0F, 1.0F, 1.0F, 1.0F)); m_forStates[i].fromCode.Set("textScale", 25.0f); m_forStates[i].fromCode.Set("edgeThickness", 3.0f); m_forStates[i].fromCode.Set("length", 100.0f); m_forStates[i].fromCode.Set("height", 40.0f); } int j = 0; XMLNode stateNode = node.getChildNode(j); while (!stateNode.isEmpty()) { SetColorFromXMLByNameInState("textColor", stateNode, PROPERTIES_FROM_BASE); ////////////////////////////////////////////////////////////////////////// const char* stateNum = stateNode.getAttribute("state"); int currentState; if (stateNum != NULL) currentState = atoi(stateNum); else continue; ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// const char* maxs = stateNode.getAttribute("position"); if(maxs != NULL) { std::string str = maxs; std::vector<std::string> maxsVec; float maxsChar[2]; maxsVec.push_back(Utility::CutString(str, ',').c_str()); maxsVec.push_back(Utility::CutString(str, ',').c_str()); for (unsigned int i = 0; i < maxsVec.size(); i++) { if (maxsVec[i] == "") maxsChar[i] = 0.0f; else maxsChar[i] = (float)atof(maxsVec[i].c_str()); } Vector2 currentMaxs = Vector2(maxsChar[0], maxsChar[1]); m_forStates[currentState].fromWidget.Set("position", currentMaxs); } ////////////////////////////////////////////////////////////////////////// SetColorFromXMLByNameInState("textColor", stateNode, PROPERTIES_FROM_BASE); ////////////////////////////////////////////////////////////////////////// const char* text = stateNode.getAttribute("text"); if (text != NULL) { std::string t = text; m_forStates[currentState].fromWidget.Set("text", t); } const char* textScale = stateNode.getAttribute("textScale"); if (textScale != NULL) { float textScalef = (float)atof(textScale); m_forStates[currentState].fromWidget.Set("textScale", textScalef); } ////////////////////////////////////////////////////////////////////////// const char* length = stateNode.getAttribute("length"); if (length != NULL) { float lengthf = (float)atof(length); m_forStates[currentState].fromWidget.Set("length", lengthf); } const char* height = stateNode.getAttribute("height"); if (height != NULL) { float heightf = (float)atof(height); m_forStates[currentState].fromWidget.Set("height", heightf); } ////////////////////////////////////////////////////////////////////////// const char* options = stateNode.getAttribute("options"); if (options != NULL) { m_currentStateProperty = m_forStates[1]; std::string t = options; //m_forStates[currentState].fromWidget.Set("text", t); std::string option = Utility::CutString(t, ','); while (option != "") { AddNewOption(option); if (m_options.size()==1) { AddNewOption(option); } option = Utility::CutString(t, ','); } } j++; stateNode = node.getChildNode(j); } m_currentStateProperty = m_forStates[1]; }