1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_InputPanel.h"
24 #include "HYDROGUI_Module.h"
26 #include <CAM_Application.h>
27 #include <SUIT_Desktop.h>
30 #include <QPushButton>
31 #include <QStackedLayout>
33 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle )
34 : QDockWidget( theModule->application()->desktop() ),
38 setWindowTitle( theTitle );
39 setAllowedAreas( Qt::RightDockWidgetArea );
41 QFrame* aFrame = new QFrame( this );
43 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
45 myMainFrame = new QFrame( aFrame );
46 QVBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
47 aMainLayout->setMargin( 0 );
48 aMainLayout->setSpacing( 5 );
50 myStackedLayout = new QStackedLayout();
52 myBtnFrame = new QFrame( aFrame );
53 activateWidget( myBtnFrame );
55 aLayout->addWidget( myMainFrame, 3 );
56 aLayout->addLayout( myStackedLayout, 1 );
58 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
59 aBtnsLayout->setMargin( 5 );
60 aBtnsLayout->setSpacing( 5 );
62 myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
63 myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
64 myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
66 aBtnsLayout->addWidget( myApply, 0 );
67 aBtnsLayout->addWidget( myCancel, 0 );
68 aBtnsLayout->addStretch( 1 );
69 aBtnsLayout->addWidget( myHelp, 0 );
71 connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
72 connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
73 connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
76 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
80 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
85 void HYDROGUI_InputPanel::onApply()
90 void HYDROGUI_InputPanel::onCancel()
95 void HYDROGUI_InputPanel::onHelp()
99 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget )
101 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
102 aMainLayout->addWidget( theWidget );
105 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
107 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
108 aMainLayout->addLayout( theLayout );
111 void HYDROGUI_InputPanel::addStretch()
113 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
114 aMainLayout->addStretch();
117 QFrame* HYDROGUI_InputPanel::mainFrame() const
122 void HYDROGUI_InputPanel::activateWidget( QWidget* theWidget )
124 if (theWidget == 0) {
125 myStackedLayout->setCurrentIndex( 0 );
128 if ( myStackedLayout->indexOf( theWidget ) == -1 )
129 myStackedLayout->addWidget( theWidget );
130 myStackedLayout->setCurrentWidget( theWidget );