Salome HOME
Union of validator and filter functionalities.
[modules/shaper.git] / src / ModuleBase / ModuleBase_PageWidget.cpp
1 /*
2  * ModuleBase_PageWidget.cpp
3  *
4  *  Created on: Mar 4, 2015
5  *      Author: sbh
6  */
7
8 #include <ModuleBase_PageWidget.h>
9 #include <ModuleBase_ModelWidget.h>
10 #include <ModuleBase_Tools.h>
11
12 #include <QGridLayout>
13
14 #include <iostream>
15
16 ModuleBase_PageWidget::ModuleBase_PageWidget(QWidget* theParent)
17 : QFrame(theParent)
18 {
19   myMainLayout = new QGridLayout(this);
20   ModuleBase_Tools::adjustMargins(myMainLayout);
21   setLayout(myMainLayout);
22 }
23
24 ModuleBase_PageWidget::~ModuleBase_PageWidget()
25 {
26 }
27
28 void ModuleBase_PageWidget::addPageStretch()
29 {
30   myMainLayout->setRowStretch(myMainLayout->rowCount(), 1);
31 }
32
33 void ModuleBase_PageWidget::placeModelWidget(ModuleBase_ModelWidget* theWidget)
34 {
35   const int kCol = 0;
36   const int kRow = myMainLayout->count();
37   myMainLayout->addWidget(theWidget, kRow, kCol);
38   myMainLayout->setRowStretch(kRow, 0);
39 }
40
41 void ModuleBase_PageWidget::placePageWidget(ModuleBase_PageBase* theWidget)
42 {
43   QWidget* aWidget = dynamic_cast<QWidget*>(theWidget);
44   if (!aWidget) {
45     #ifdef _DEBUG
46     std::cout << "ModuleBase_PageWidget::placePageWidget: can not cast page" << std::endl;
47     #endif
48     return;
49   }
50   const int kCol = 0;
51   const int kRow = myMainLayout->count();
52   myMainLayout->addWidget(aWidget, kRow, kCol);
53   myMainLayout->setRowStretch(kRow, 0);
54 }
55
56 QLayout* ModuleBase_PageWidget::pageLayout()
57 {
58   return myMainLayout;
59 }