1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEGUI_ViewChoiceDlg.cxx
25 // Author : Nicolas REJNERI
30 #include "SALOMEGUI_ViewChoiceDlg.h"
31 #include "QAD_Config.h"
32 #include "QAD_StudyFrame.h"
34 #include <qcombobox.h>
35 #include <qgroupbox.h>
37 #include <qpushbutton.h>
41 #include <qwhatsthis.h>
44 * Constructs a SALOMEGUI_ViewChoiceDlg which is a child of 'parent', with the
45 * name 'name' and widget flags set to 'f'
47 * The dialog will by default be modeless, unless you set 'modal' to
48 * TRUE to construct a modal dialog.
50 SALOMEGUI_ViewChoiceDlg::SALOMEGUI_ViewChoiceDlg( QWidget* parent, const char* name, bool modal, WFlags fl )
51 : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
54 setName( "SALOMEGUI_ViewChoiceDlg" );
55 setCaption( tr( "MEN_CHOICE" ) );
56 setSizeGripEnabled( true );
58 QGridLayout* theBaseLayout = new QGridLayout( this, 2, 1, 11, 6);
60 GroupBox1 = new QGroupBox(0, Qt::Vertical, tr("MEN_VIEW"), this);
61 theBaseLayout->addWidget(GroupBox1, 0, 0);
63 QHBoxLayout* aBoxLayout = new QHBoxLayout(GroupBox1->layout());
65 QHBoxLayout* aInternalLayout = new QHBoxLayout(6);
67 TextLabel1 = new QLabel(tr("MEN_VIEWER_TYPE"), GroupBox1);
68 aInternalLayout->addWidget(TextLabel1);
70 ComboBox1 = new QComboBox( false, GroupBox1);
71 ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
72 ComboBox1->setMinimumWidth( 200 );
74 ComboBox1->insertItem(tr("MEN_VIEWER_OCC"));
75 myViewers.append(VIEW_OCC);
76 if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_OCC )
77 ComboBox1->setCurrentItem( ComboBox1->count()-1 );
79 ComboBox1->insertItem(tr("MEN_VIEWER_VTK"));
80 myViewers.append(VIEW_VTK);
81 if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_VTK )
82 ComboBox1->setCurrentItem( ComboBox1->count()-1 );
84 // ComboBox1->insertItem(tr("MEN_VIEWER_GRAPH"));
85 // myViewers.append(VIEW_GRAPHSUPERV);
86 // if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_GRAPHSUPERV )
87 // ComboBox1->setCurrentItem( ComboBox1->count()-1 );
89 ComboBox1->insertItem(tr("MEN_VIEWER_PLOT2D"));
90 myViewers.append(VIEW_PLOT2D);
91 if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_PLOT2D )
92 ComboBox1->setCurrentItem( ComboBox1->count()-1 );
93 TextLabel1->setBuddy(ComboBox1);
94 aInternalLayout->addWidget(ComboBox1);
96 aBoxLayout->addLayout(aInternalLayout);
98 QFrame* aButtonFrame = new QFrame( this );
99 theBaseLayout->addWidget(aButtonFrame, 1, 0);
101 QHBoxLayout* aButtLayout = new QHBoxLayout(aButtonFrame);
103 buttonOk = new QPushButton(tr("BUT_OK"), aButtonFrame);
104 buttonOk->setAutoDefault(true);
105 buttonOk->setDefault(true);
106 aButtLayout->addWidget(buttonOk);
108 QSpacerItem* aSpacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding);
109 aButtLayout->addItem(aSpacer);
111 buttonCancel = new QPushButton(tr( "BUT_CANCEL" ), aButtonFrame);
112 buttonCancel->setAutoDefault(true);
113 aButtLayout->addWidget(buttonCancel);
115 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
116 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
120 * Destroys the object and frees any allocated resources
122 SALOMEGUI_ViewChoiceDlg::~SALOMEGUI_ViewChoiceDlg()
124 // no need to delete child widgets, Qt does it all for us
130 int SALOMEGUI_ViewChoiceDlg::getSelectedViewer()
132 return myViewers[ ComboBox1->currentItem() ];