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>
21 #include <HYDROGUI_Module.h>
22 #include <CAM_Application.h>
23 #include <SUIT_Desktop.h>
28 #include <QPushButton>
31 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout )
35 : QDockWidget( theModule->application()->desktop() ),
40 setWindowTitle( theTitle );
41 setAllowedAreas( Qt::RightDockWidgetArea );
44 QFrame* aFrame = new QFrame( this );
46 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
48 myMainFrame = new QFrame( aFrame );
49 QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
50 aMainLayout->setMargin( 0 );
51 aMainLayout->setSpacing( 5 );
53 aLayout->addWidget( myMainFrame, 1 );
55 myBtnFrame = new QFrame( aFrame );
56 aLayout->addWidget( myBtnFrame, 0 );
58 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
59 aBtnsLayout->setMargin( 5 );
60 aBtnsLayout->setSpacing( 5 );
62 myCancel = new QPushButton( tr( "CLOSE" ), myBtnFrame );
63 myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
66 myApplyAndClose = new QPushButton( tr( "APPLY_AND_CLOSE" ), myBtnFrame );
67 myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
69 aBtnsLayout->addWidget( myApplyAndClose, 0 );
70 aBtnsLayout->addWidget( myApply, 0 );
71 aBtnsLayout->addWidget( myCancel, 0 );
72 aBtnsLayout->addStretch( 1 );
73 aBtnsLayout->addWidget( myHelp, 0 );
75 connect( myApplyAndClose, SIGNAL( clicked() ), this, SLOT( onApplyAndClose() ) );
76 connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
78 connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
79 connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
82 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
86 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
91 bool HYDROGUI_InputPanel::isApplyEnabled() const
93 return myApply->isEnabled();
96 void HYDROGUI_InputPanel::setApplyEnabled( bool on )
98 myApplyAndClose->setEnabled( on );
99 myApply->setEnabled( on );
102 void HYDROGUI_InputPanel::onApplyAndClose()
104 emit panelApplyAndClose();
107 void HYDROGUI_InputPanel::onApply()
112 void HYDROGUI_InputPanel::onCancel()
117 void HYDROGUI_InputPanel::onHelp()
122 void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
127 void HYDROGUI_InputPanel::insertWidget( QWidget* theWidget, int theIndex, int theStretch )
129 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
130 aMainLayout->insertWidget( theIndex, theWidget, theStretch );
133 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
135 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
136 aMainLayout->addWidget( theWidget, theStretch );
139 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout, int theStretch )
141 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
142 aMainLayout->addLayout( theLayout, theStretch );
145 void HYDROGUI_InputPanel::addStretch()
147 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
148 aMainLayout->addStretch();
151 QFrame* HYDROGUI_InputPanel::mainFrame() const
156 QFrame* HYDROGUI_InputPanel::buttonFrame() const