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>
32 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle,
33 bool doInitLayout, bool isSplitter )
37 : QDockWidget( theModule->application()->desktop() ),
42 setWindowTitle( theTitle );
43 setAllowedAreas( Qt::RightDockWidgetArea );
46 QFrame* aFrame = new QFrame( this );
48 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
50 myMainFrame = new QFrame( aFrame );
51 QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
52 aMainLayout->setMargin( 0 );
53 aMainLayout->setSpacing( 5 );
56 mySplitter = new QSplitter( myMainFrame );
57 mySplitter->setOrientation( Qt::Vertical );
58 aMainLayout->addWidget( mySplitter, 1 );
63 aLayout->addWidget( myMainFrame, 1 );
65 myBtnFrame = new QFrame( aFrame );
66 aLayout->addWidget( myBtnFrame, 0 );
68 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
69 aBtnsLayout->setMargin( 5 );
70 aBtnsLayout->setSpacing( 5 );
72 myCancel = new QPushButton( tr( "CLOSE" ), myBtnFrame );
73 myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
76 myApplyAndClose = new QPushButton( tr( "APPLY_AND_CLOSE" ), myBtnFrame );
77 myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
79 aBtnsLayout->addWidget( myApplyAndClose, 0 );
80 aBtnsLayout->addWidget( myApply, 0 );
81 aBtnsLayout->addWidget( myCancel, 0 );
82 aBtnsLayout->addStretch( 1 );
83 aBtnsLayout->addWidget( myHelp, 0 );
85 connect( myApplyAndClose, SIGNAL( clicked() ), this, SLOT( onApplyAndClose() ) );
86 connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
88 connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
89 connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
92 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
96 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
101 bool HYDROGUI_InputPanel::isApplyEnabled() const
103 return myApply->isEnabled();
106 void HYDROGUI_InputPanel::setApplyEnabled( bool on )
108 myApplyAndClose->setEnabled( on );
109 myApply->setEnabled( on );
112 void HYDROGUI_InputPanel::onApplyAndClose()
114 emit panelApplyAndClose();
117 void HYDROGUI_InputPanel::onApply()
122 void HYDROGUI_InputPanel::onCancel()
127 void HYDROGUI_InputPanel::onHelp()
132 void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
137 void HYDROGUI_InputPanel::insertWidget( QWidget* theWidget, int theIndex, int theStretch )
141 mySplitter->insertWidget( theIndex, theWidget );
142 mySplitter->setStretchFactor( theIndex, theStretch );
146 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
147 aMainLayout->insertWidget( theIndex, theWidget, theStretch );
151 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
155 int s = mySplitter->count();
156 mySplitter->addWidget( theWidget );
157 mySplitter->setStretchFactor( s, theStretch );
161 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
162 aMainLayout->addWidget( theWidget, theStretch );
166 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout, int theStretch )
173 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
174 aMainLayout->addLayout( theLayout, theStretch );
178 void HYDROGUI_InputPanel::addStretch()
185 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
186 aMainLayout->addStretch();
190 QFrame* HYDROGUI_InputPanel::mainFrame() const
195 QFrame* HYDROGUI_InputPanel::buttonFrame() const
200 QSplitter* HYDROGUI_InputPanel::splitter() const