Salome HOME
NRI : Add message (GUI lib not found).
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_ViewChoiceDlg.cxx
1 using namespace std;
2 //  File      : SALOMEGUI_ViewChoiceDlg.cxx
3 //  Created   : Mon Jul 29 22:16:49 2002
4 //  Author    : Nicolas REJNERI
5
6 //  Project   : SALOME
7 //  Module    : SALOMEGUI
8 //  Copyright : Open CASCADE 2002
9 //  $Header$
10
11 #include "SALOMEGUI_ViewChoiceDlg.h"
12 #include "QAD_Config.h"
13 #include "QAD_StudyFrame.h"
14
15 #include <qcombobox.h>
16 #include <qgroupbox.h>
17 #include <qlabel.h>
18 #include <qpushbutton.h>
19 #include <qlayout.h>
20 #include <qvariant.h>
21 #include <qtooltip.h>
22 #include <qwhatsthis.h>
23
24 /* 
25  *  Constructs a SALOMEGUI_ViewChoiceDlg which is a child of 'parent', with the 
26  *  name 'name' and widget flags set to 'f' 
27  *
28  *  The dialog will by default be modeless, unless you set 'modal' to
29  *  TRUE to construct a modal dialog.
30  */
31 SALOMEGUI_ViewChoiceDlg::SALOMEGUI_ViewChoiceDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
32     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
33 {
34     if ( !name )
35         setName( "SALOMEGUI_ViewChoiceDlg" );
36     setCaption( tr( "MEN_CHOICE" ) );
37     setSizeGripEnabled( true );
38
39     QGridLayout* theBaseLayout = new QGridLayout( this, 2, 1, 11, 6);
40
41     GroupBox1 = new QGroupBox(0, Qt::Vertical, tr("MEN_VIEW"), this);
42     theBaseLayout->addWidget(GroupBox1, 0, 0);
43
44     QHBoxLayout* aBoxLayout = new QHBoxLayout(GroupBox1->layout()); 
45
46     QHBoxLayout* aInternalLayout = new QHBoxLayout(6);
47
48     TextLabel1 = new QLabel(tr("MEN_VIEWER_TYPE"), GroupBox1);
49     aInternalLayout->addWidget(TextLabel1);
50
51     ComboBox1 = new QComboBox( false, GroupBox1);
52     ComboBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
53     ComboBox1->setMinimumWidth( 200 );
54     // OCC Viewer
55     ComboBox1->insertItem(tr("MEN_VIEWER_OCC"));
56     myViewers.append(VIEW_OCC);
57     if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_OCC )
58       ComboBox1->setCurrentItem( ComboBox1->count()-1 );
59     // VTK Viewer
60     ComboBox1->insertItem(tr("MEN_VIEWER_VTK"));
61     myViewers.append(VIEW_VTK);
62     if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_VTK )
63       ComboBox1->setCurrentItem( ComboBox1->count()-1 );
64     // SUPERVISOR Viewer
65 //    ComboBox1->insertItem(tr("MEN_VIEWER_GRAPH"));
66 //    myViewers.append(VIEW_GRAPHSUPERV);
67 //    if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_GRAPHSUPERV )
68 //      ComboBox1->setCurrentItem( ComboBox1->count()-1 );
69     // Plot2d Viewer
70     ComboBox1->insertItem(tr("MEN_VIEWER_PLOT2D"));
71     myViewers.append(VIEW_PLOT2D);
72     if ( QAD_CONFIG->getSetting( "Viewer:DefaultViewer").toInt() == VIEW_PLOT2D )
73       ComboBox1->setCurrentItem( ComboBox1->count()-1 );
74     TextLabel1->setBuddy(ComboBox1);
75     aInternalLayout->addWidget(ComboBox1);
76
77     aBoxLayout->addLayout(aInternalLayout);
78     
79     QFrame* aButtonFrame = new QFrame( this );
80     theBaseLayout->addWidget(aButtonFrame, 1, 0);
81
82     QHBoxLayout* aButtLayout = new QHBoxLayout(aButtonFrame); 
83
84     buttonOk = new QPushButton(tr("BUT_OK"), aButtonFrame);
85     buttonOk->setAutoDefault(true);
86     buttonOk->setDefault(true);
87     aButtLayout->addWidget(buttonOk);
88
89     QSpacerItem* aSpacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding);
90     aButtLayout->addItem(aSpacer);
91
92     buttonCancel = new QPushButton(tr( "BUT_CANCEL" ),  aButtonFrame);
93     buttonCancel->setAutoDefault(true);
94     aButtLayout->addWidget(buttonCancel);
95
96     connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
97     connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
98 }
99
100 /*  
101  *  Destroys the object and frees any allocated resources
102  */
103 SALOMEGUI_ViewChoiceDlg::~SALOMEGUI_ViewChoiceDlg()
104 {
105     // no need to delete child widgets, Qt does it all for us
106 }
107
108 /*!
109   Gets user's choice
110 */
111 int SALOMEGUI_ViewChoiceDlg::getSelectedViewer()
112 {
113   return myViewers[ ComboBox1->currentItem() ];
114 }