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( "CANCEL" ), myBtnFrame );
57 myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
60 myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
62 aBtnsLayout->addWidget( myApply, 0 );
63 aBtnsLayout->addWidget( myCancel, 0 );
64 aBtnsLayout->addStretch( 1 );
65 aBtnsLayout->addWidget( myHelp, 0 );
67 connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
69 connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
70 connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
73 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
77 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
82 bool HYDROGUI_InputPanel::isApplyEnabled() const
84 return myApply->isEnabled();
87 void HYDROGUI_InputPanel::setApplyEnabled( bool on )
89 myApply->setEnabled( on );
92 void HYDROGUI_InputPanel::onApply()
97 void HYDROGUI_InputPanel::onCancel()
102 void HYDROGUI_InputPanel::onHelp()
107 void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
112 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
114 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
115 aMainLayout->addWidget( theWidget, theStretch );
118 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
120 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
121 aMainLayout->addLayout( theLayout );
124 void HYDROGUI_InputPanel::addStretch()
126 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
127 aMainLayout->addStretch();
130 QFrame* HYDROGUI_InputPanel::mainFrame() const
135 QFrame* HYDROGUI_InputPanel::buttonFrame() const