X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_WidgetAPI.cpp;h=2fdad673519fcd7f1be6fc49cdbadad3062ffb67;hb=2b4f4bf278c841500eb29bb5d204690427b0d56b;hp=38b4476ade39806eec6eaf0f6213a177f73b9017;hpb=a002dc2fe33da6b7ab8e0faff3b6b591efaf17b0;p=modules%2Fshaper.git diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 38b4476ad..2fdad6735 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -6,15 +6,17 @@ */ #include +#include +#include -#include -#include +#include +#include Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml) { myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str()); - myCurrentNode = NULL; + myCurrentNode = xmlDocGetRootElement(myDoc); } @@ -23,22 +25,43 @@ Config_WidgetAPI::~Config_WidgetAPI() xmlFreeDoc(myDoc); } -void Config_WidgetAPI::reset() +bool Config_WidgetAPI::toNextWidget() { - xmlNodePtr aRoot = xmlDocGetRootElement(myDoc); - if(aRoot) { - myCurrentNode = aRoot->children; + //Skip all non-element node, stop if next node is null + xmlNodePtr aNextNode = myCurrentNode; + do { + aNextNode = aNextNode->next; + } while(aNextNode && !isElementNode(aNextNode)); + + if(!aNextNode) { + toParentWidget(); + return false; } + myCurrentNode = aNextNode; + return true; +} +bool Config_WidgetAPI::toChildWidget() +{ + if(myCurrentNode && hasChild(myCurrentNode)) { + myCurrentNode = myCurrentNode->children; + while(!isElementNode(myCurrentNode)) { + myCurrentNode = myCurrentNode->next; + } + return true; + } + return false; } -bool Config_WidgetAPI::nextWidget() +bool Config_WidgetAPI::toParentWidget() { - myCurrentNode = myCurrentNode->next; + if(myCurrentNode) { + myCurrentNode = myCurrentNode->parent; + } return myCurrentNode != NULL; } -std::string Config_WidgetAPI::widgetType() +std::string Config_WidgetAPI::widgetType() const { std::string result = ""; if(myCurrentNode) { @@ -47,7 +70,19 @@ std::string Config_WidgetAPI::widgetType() return result; } -std::string Config_WidgetAPI::getProperty(const char* thePropName) +bool Config_WidgetAPI::isContainerWidget() const +{ + return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP, + NULL); +} + +bool Config_WidgetAPI::isPagedWidget() const +{ + return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH, + NULL); +} + +std::string Config_WidgetAPI::getProperty(const char* thePropName) const { std::string result = ""; char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName); @@ -57,27 +92,22 @@ std::string Config_WidgetAPI::getProperty(const char* thePropName) return result; } -bool Config_WidgetAPI::isNode(xmlNodePtr theNode, const char* theNodeName, ...) +std::string Config_WidgetAPI::widgetId() const { - bool result = false; - const xmlChar* aName = theNode->name; - if (!aName || theNode->type != XML_ELEMENT_NODE) - return false; + return getProperty("id"); +} - if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) - return true; +std::string Config_WidgetAPI::widgetTooltip() const +{ + return getProperty("tooltip"); +} - va_list args; // define argument list variable - va_start(args, theNodeName); // init list; point to last defined argument - while(true) { - char *anArg = va_arg (args, char*); // get next argument - if (anArg == NULL) - break; - if (!xmlStrcmp(aName, (const xmlChar *) anArg)) { - va_end(args); // cleanup the system stack - return true; - } - } - va_end(args); // cleanup the system stack - return false; +std::string Config_WidgetAPI::widgetIcon() const +{ + return getProperty("icon"); +} + +std::string Config_WidgetAPI::widgetLabel() const +{ + return getProperty("label"); }