Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetFactory.cpp
index e5212c7e85f70d8d4f61cf562f204976ca77dfd3..1ef8c83d8bedc66cea3b12e801dd69b0ee4d303c 100644 (file)
@@ -25,6 +25,9 @@
 #include <QPixmap>
 #include <QGroupBox>
 #include <QToolBox>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QCheckBox>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -104,13 +107,20 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
   QWidget* result = NULL;
   if (theType == WDG_DOUBLEVALUE) {
     result = doubleSpinBoxControl();
+
   } else if (theType == WDG_INFO) {
     result = labelControl(theParent);
-  }
-  else if (theType == WDG_POINT_SELECTOR) {
+
+  } else if (theType == WDG_SELECTOR) {
+    result = selectorControl(theParent);
+
+  } else if (theType == WDG_BOOLVALUE) {
+    result = booleanControl(theParent);
+
+  } else if (theType == WDG_POINT_SELECTOR) {
     result = pointSelectorControl(theParent);
-  }
-  else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
+
+  else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
     result = createContainer(theType, theParent);
   }
 #ifdef _DEBUG
@@ -215,3 +225,44 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
 {
   return QString::fromStdString(theStdString);
 }
+
+
+QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
+{
+  QWidget* aRes = new QWidget();
+  QHBoxLayout* aLayout = new QHBoxLayout(aRes);
+
+  aLayout->setContentsMargins(0, 0, 0, 0);
+  QString aLabelText = qs(myWidgetApi->widgetLabel());
+  QString aLabelIcon = qs(myWidgetApi->widgetIcon());
+  QLabel* aLabel = new QLabel(aLabelText, aRes);
+  aLabel->setPixmap(QPixmap(aLabelIcon));
+
+  aLayout->addWidget(aLabel);
+
+  QLineEdit* aTextLine = new QLineEdit(aRes);
+  aTextLine->setReadOnly(true);
+
+  aLayout->addWidget(aTextLine);
+
+  QToolButton* aActivateBtn = new QToolButton(aRes);
+  aActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
+  aActivateBtn->setCheckable(true);
+
+  aLayout->addWidget(aActivateBtn);
+
+  return aRes;
+}
+
+
+QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
+{
+  QString aText = qs(myWidgetApi->widgetLabel());
+  QString aToolTip = qs(myWidgetApi->widgetTooltip());
+  QString aDefault = qs(myWidgetApi->getProperty("default"));
+
+  QCheckBox* aRes = new QCheckBox(aText, theParent);
+  aRes->setToolTip(aToolTip);
+  aRes->setChecked(aDefault == "true");
+  return aRes;
+}
\ No newline at end of file