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"
25 #include "HYDROGUI_RunBrowser.h"
27 #include <CAM_Application.h>
28 #include <SUIT_Desktop.h>
31 #include <QPushButton>
34 HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout )
35 : QDockWidget( theModule->application()->desktop() ),
39 setWindowTitle( theTitle );
40 setAllowedAreas( Qt::RightDockWidgetArea );
43 QFrame* aFrame = new QFrame( this );
45 QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
47 myMainFrame = new QFrame( aFrame );
48 QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
49 aMainLayout->setMargin( 0 );
50 aMainLayout->setSpacing( 5 );
52 aLayout->addWidget( myMainFrame, 1 );
54 myBtnFrame = new QFrame( aFrame );
55 aLayout->addWidget( myBtnFrame, 0 );
57 QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
58 aBtnsLayout->setMargin( 5 );
59 aBtnsLayout->setSpacing( 5 );
61 myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame );
62 myHelp = new QPushButton( tr( "HELP" ), myBtnFrame );
65 myApply = new QPushButton( tr( "APPLY" ), myBtnFrame );
67 aBtnsLayout->addWidget( myApply, 0 );
68 aBtnsLayout->addWidget( myCancel, 0 );
69 aBtnsLayout->addStretch( 1 );
70 aBtnsLayout->addWidget( myHelp, 0 );
72 connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) );
74 connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) );
75 connect( myHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
78 HYDROGUI_InputPanel::~HYDROGUI_InputPanel()
82 HYDROGUI_Module* HYDROGUI_InputPanel::module() const
87 void HYDROGUI_InputPanel::onApply()
92 void HYDROGUI_InputPanel::onCancel()
97 void HYDROGUI_InputPanel::onHelp()
99 QString aModuleName = myModule->moduleName();
101 QString aPagePath = HYDROGUI_RunBrowser::getPagePath( aModuleName );
103 QString aPageName = "";
104 QString aWindowTitle = windowTitle();
105 if ( !aWindowTitle.isEmpty() )
107 aPageName = QStringList( aWindowTitle.split( " " ) ).join( "_" ).append( ".html" );
111 QString aPage = aPagePath + QDir::separator() + aPageName;
112 HYDROGUI_RunBrowser::showPage( myModule->getApp(), aPage );
115 void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
120 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
122 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
123 aMainLayout->addWidget( theWidget, theStretch );
126 void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
128 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
129 aMainLayout->addLayout( theLayout );
132 void HYDROGUI_InputPanel::addStretch()
134 QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
135 aMainLayout->addStretch();
138 QFrame* HYDROGUI_InputPanel::mainFrame() const
143 QFrame* HYDROGUI_InputPanel::buttonFrame() const