Salome HOME
refs #836: the icons of extrusion options with size 32x32
[modules/shaper.git] / src / ModuleBase / ModuleBase_WidgetToolbox.cpp
1 /*
2  * ModuleBase_WidgetToolbox.cpp
3  *
4  *  Created on: Feb 27, 2015
5  *      Author: sbh
6  */
7
8 #include <ModuleBase_WidgetToolbox.h>
9 #include <ModuleBase_PageBase.h>
10 #include <ModuleBase_ModelWidget.h>
11 #include <ModuleBase_Tools.h>
12 #include <ModuleBase_ToolBox.h>
13
14 #include <ModelAPI_AttributeString.h>
15
16 #include <QWidget>
17 #include <QList>
18 #include <QVBoxLayout>
19 #include <QIcon>
20
21 ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData,
22                                                    const std::string& theParentId)
23 : ModuleBase_PagedContainer(theParent, theData, theParentId)
24 {
25   QVBoxLayout* aMainLayout = new QVBoxLayout(this);
26   ModuleBase_Tools::zeroMargins(aMainLayout);
27   myToolBox = new ModuleBase_ToolBox(this);
28   // Dark-grey rounded tabs with button-like border #and bold font
29   // TODO: apply style to custom widget
30   QString css = "QToolBox::tab{background-color:#c8c8c8;"
31                               "border-radius:5px;"
32                               "border:1px inset;"
33                               //"font-weight:700;"
34                               "border-color:#fff #505050 #505050 #fff;}";
35   myToolBox->setStyleSheet(css);
36   // default vertical size policy is preferred
37   aMainLayout->addWidget(myToolBox);
38
39   connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
40 }
41
42 ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
43 {
44 }
45
46 int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
47                                       const QString& theName,
48                                       const QString& theCaseId,
49                                       const QPixmap& theIcon )
50 {
51   ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
52   QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
53   aFrame->setFrameShape(QFrame::Box);
54   aFrame->setFrameStyle(QFrame::Sunken);
55   myToolBox->addItem(aFrame, theName, theIcon );
56   return myToolBox->count();
57 }
58
59 int ModuleBase_WidgetToolbox::currentPageIndex() const
60 {
61   return myToolBox->currentIndex();
62 }
63
64 void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex)
65 {
66   bool isSignalsBlocked = myToolBox->blockSignals(true);
67   myToolBox->setCurrentIndex(theIndex);
68   myToolBox->blockSignals(isSignalsBlocked);
69 }
70
71