X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_WidgetAPI.cpp;h=9a77d778ac0825da41131e6ffc65a2ef0ea3c88c;hb=bb65863adf6a3887d3bd70748bfcfd51eaaa7f51;hp=14d5fa2aa9b18323806403b393f6de708c78580a;hpb=637bc35625b89379def6b9f9ff0915d32664babd;p=modules%2Fshaper.git diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 14d5fa2aa..9a77d778a 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,18 +25,38 @@ 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() { if(myCurrentNode) { - myCurrentNode = myCurrentNode->next; + myCurrentNode = myCurrentNode->parent; } return myCurrentNode != NULL; } @@ -48,6 +70,18 @@ std::string Config_WidgetAPI::widgetType() return result; } +bool Config_WidgetAPI::isContainerWidget() +{ + return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP, + NULL); +} + +bool Config_WidgetAPI::isPagedWidget() +{ + return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH, + NULL); +} + std::string Config_WidgetAPI::getProperty(const char* thePropName) { std::string result = ""; @@ -58,6 +92,11 @@ std::string Config_WidgetAPI::getProperty(const char* thePropName) return result; } +std::string Config_WidgetAPI::widgetId() +{ + return getProperty("id"); +} + std::string Config_WidgetAPI::widgetTooltip() { return getProperty("tooltip"); @@ -72,28 +111,3 @@ std::string Config_WidgetAPI::widgetLabel() { return getProperty("label"); } - -bool Config_WidgetAPI::isNode(xmlNodePtr theNode, const char* theNodeName, ...) -{ - bool result = false; - const xmlChar* aName = theNode->name; - if (!aName || theNode->type != XML_ELEMENT_NODE) - return false; - - if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) - return true; - - 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; -}