Salome HOME
6e3181f93e409b6b0d1c7dc4f291335e87c14b36
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_InputPanel.cxx
1
2 #include <HYDROGUI_InputPanel.h>
3 #include <HYDROGUI_Module.h>
4 #include <CAM_Application.h>
5 #include <SUIT_Desktop.h>
6 #include <QLayout>
7 #include <QPushButton>
8
9 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle )
10 : QDockWidget( theModule->application()->desktop() ),
11   myModule( theModule )
12 {
13   setFloating( false );
14   setWindowTitle( theTitle );
15   setAllowedAreas( Qt::RightDockWidgetArea );
16
17   QFrame* aFrame = new QFrame( this );
18   setWidget( aFrame );
19   QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
20   
21   myMainFrame = new QFrame( this );
22   QGridLayout* aMainLayout = new QGridLayout( myMainFrame );
23   myBtnFrame = new QFrame( this );
24   aLayout->addWidget( myMainFrame, 1 );
25   aLayout->addWidget( myBtnFrame, 0 );
26
27   QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
28   aBtnsLayout->setMargin( 5 );
29   aBtnsLayout->setSpacing( 5 );
30
31   myApply = new QPushButton( tr( "APPLY" ), myBtnFrame ),
32   myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
33   myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
34
35   aBtnsLayout->addWidget( myApply, 0 );
36   aBtnsLayout->addWidget( myCancel, 0 );
37   aBtnsLayout->addStretch( 1 );
38   aBtnsLayout->addWidget( myHelp, 0 );
39
40   connect( myApply,  SIGNAL( clicked() ), this, SLOT( OnApply()  ) );
41   connect( myCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
42   connect( myHelp,   SIGNAL( clicked() ), this, SLOT( OnHelp()   ) );
43 }
44
45 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
46 {
47 }
48
49 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
50 {
51   return myModule;
52 }
53
54 void HYDROGUI_InputPanel::OnApply()
55 {
56   emit panelApply(); 
57 }
58
59 void HYDROGUI_InputPanel::OnCancel()
60 {
61   emit panelCancel();
62 }
63
64 void HYDROGUI_InputPanel::OnHelp()
65 {
66 }
67
68 void HYDROGUI_InputPanel::addWidget( const QString& theLabel, QWidget* theWidget )
69 {
70   QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
71   int aRow = aMainLayout->rowCount();
72   aMainLayout->addWidget( new QLabel( theLabel, this ), aRow, 0 );
73   aMainLayout->addWidget( theWidget, aRow, 1 );
74 }
75
76 void HYDROGUI_InputPanel::addSeparator()
77 {
78   QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
79   int aRow = aMainLayout->rowCount();
80
81   QFrame* aLine = new QFrame();
82   aLine->setFrameShape( QFrame::HLine );
83   aLine->setFrameShadow( QFrame::Sunken );
84
85   aMainLayout->addWidget( aLine, aRow, 0, 1, 2 );
86 }
87
88 void HYDROGUI_InputPanel::setRowStretch()
89 {
90   QGridLayout* aMainLayout = dynamic_cast<QGridLayout*>( myMainFrame->layout() );
91   int aRow = aMainLayout->rowCount();
92   aMainLayout->setRowStretch( aRow, 1 );
93 }