Salome HOME
HYDROGUI_Wizard has been refactored and now uses QStackedWidget instead of QWizard.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_InputPanel.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_InputPanel.h"
24 #include "HYDROGUI_Module.h"
25
26 #include <CAM_Application.h>
27 #include <SUIT_Desktop.h>
28
29 #include <QLayout>
30 #include <QPushButton>
31
32 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout )
33 : QDockWidget( theModule->application()->desktop() ),
34   myModule( theModule )
35 {
36   setFloating( false );
37   setWindowTitle( theTitle );
38   setAllowedAreas( Qt::RightDockWidgetArea );
39
40
41   QFrame* aFrame = new QFrame( this );
42   setWidget( aFrame );
43   QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
44   
45   myMainFrame = new QFrame( aFrame );
46   QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
47   aMainLayout->setMargin( 0 );
48   aMainLayout->setSpacing( 5 );
49     
50   aLayout->addWidget( myMainFrame, 1 );
51
52   myBtnFrame = new QFrame( aFrame );
53   aLayout->addWidget( myBtnFrame, 0 );
54
55   QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
56   aBtnsLayout->setMargin( 5 );
57   aBtnsLayout->setSpacing( 5 );
58
59   myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
60   myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
61
62   if ( doInitLayout ) {
63     myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
64
65     aBtnsLayout->addWidget( myApply, 0 );
66     aBtnsLayout->addWidget( myCancel, 0 );
67     aBtnsLayout->addStretch( 1 );
68     aBtnsLayout->addWidget( myHelp, 0 );
69
70     connect( myApply,  SIGNAL( clicked() ), this, SLOT( onApply()  ) );
71   }
72   connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
73   connect( myHelp,   SIGNAL( clicked() ), this, SLOT( onHelp()   ) );
74 }
75
76 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
77 {
78 }
79
80 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
81 {
82   return myModule;
83 }
84
85 void HYDROGUI_InputPanel::onApply()
86 {
87   emit panelApply(); 
88 }
89
90 void HYDROGUI_InputPanel::onCancel()
91 {
92   emit panelCancel();
93 }
94
95 void HYDROGUI_InputPanel::onHelp()
96 {
97 }
98
99 void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
100 {
101   emit panelCancel();
102 }
103
104 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
105 {
106   QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
107   aMainLayout->addWidget( theWidget, theStretch );
108 }
109
110 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
111 {
112   QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
113   aMainLayout->addLayout( theLayout );
114 }
115
116 void HYDROGUI_InputPanel::addStretch()
117 {
118   QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
119   aMainLayout->addStretch();
120 }
121
122 QFrame* HYDROGUI_InputPanel::mainFrame() const
123 {
124   return myMainFrame;
125 }
126
127 QFrame* HYDROGUI_InputPanel::buttonFrame() const
128 {
129   return myBtnFrame;
130 }