X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_WidgetAPI.cpp;h=333f9219a37594c61f653bdd7b529c76dbc6d216;hb=53df1b33d7d3787a433f8e4f3936eed28850c48b;hp=38b4476ade39806eec6eaf0f6213a177f73b9017;hpb=a002dc2fe33da6b7ab8e0faff3b6b591efaf17b0;p=modules%2Fshaper.git diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 38b4476ad..333f9219a 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -6,48 +6,81 @@ */ #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); } - 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) { + if (myCurrentNode) { result = std::string((char *) myCurrentNode->name); } 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 +90,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::widgetIcon() const +{ + return getProperty(ANY_WDG_ICON); +} - 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::widgetLabel() const +{ + return getProperty(ANY_WDG_LABEL); +} + +std::string Config_WidgetAPI::widgetTooltip() const +{ + return getProperty(ANY_WDG_TOOLTIP); }