1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_InputPanel.h"
20 #include "HYDROGUI_Module.h"
22 #include <CAM_Application.h>
23 #include <SUIT_Desktop.h>
26 #include <QPushButton>
29 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout )
30 : QDockWidget( theModule->application()->desktop() ),
34 setWindowTitle( theTitle );
35 setAllowedAreas( Qt::RightDockWidgetArea );
38 QFrame* aFrame = new QFrame( this );
40 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
42 myMainFrame = new QFrame( aFrame );
43 QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
44 aMainLayout->setMargin( 0 );
45 aMainLayout->setSpacing( 5 );
47 aLayout->addWidget( myMainFrame, 1 );
49 myBtnFrame = new QFrame( aFrame );
50 aLayout->addWidget( myBtnFrame, 0 );
52 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
53 aBtnsLayout->setMargin( 5 );
54 aBtnsLayout->setSpacing( 5 );
56 myCancel = new QPushButton( tr( "CLOSE" ), myBtnFrame );
57 myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
60 myApplyAndClose = new QPushButton( tr( "APPLY_AND_CLOSE" ), myBtnFrame );
61 myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
63 aBtnsLayout->addWidget( myApplyAndClose, 0 );
64 aBtnsLayout->addWidget( myApply, 0 );
65 aBtnsLayout->addWidget( myCancel, 0 );
66 aBtnsLayout->addStretch( 1 );
67 aBtnsLayout->addWidget( myHelp, 0 );
69 connect( myApplyAndClose, SIGNAL( clicked() ), this, SLOT( onApplyAndClose() ) );
70 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 bool HYDROGUI_InputPanel::isApplyEnabled() const
87 return myApply->isEnabled();
90 void HYDROGUI_InputPanel::setApplyEnabled( bool on )
92 myApplyAndClose->setEnabled( on );
93 myApply->setEnabled( on );
96 void HYDROGUI_InputPanel::onApplyAndClose()
98 emit panelApplyAndClose();
101 void HYDROGUI_InputPanel::onApply()
106 void HYDROGUI_InputPanel::onCancel()
111 void HYDROGUI_InputPanel::onHelp()
116 void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
121 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
123 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
124 aMainLayout->addWidget( theWidget, theStretch );
127 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
129 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
130 aMainLayout->addLayout( theLayout );
133 void HYDROGUI_InputPanel::addStretch()
135 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
136 aMainLayout->addStretch();
139 QFrame* HYDROGUI_InputPanel::mainFrame() const
144 QFrame* HYDROGUI_InputPanel::buttonFrame() const