2 // File : SMESHGUI_aParameterDlg.cxx
3 // Created : Wed Jun 12 21:06:21 2002
4 // Author : Nicolas REJNERI
8 // Copyright : Open CASCADE 2002
11 #include "SMESHGUI_aParameterDlg.h"
13 #include "QAD_SpinBoxDbl.h"
14 #include "QAD_Tools.h"
17 #include <qgroupbox.h>
19 #include <qpushbutton.h>
22 #include <qvalidator.h>
24 //======================================================================================
25 // function : SMESHGUI_aParameterDlg()
26 // purpose : Constructs a SMESHGUI_aParametertDlg for double values
28 // parent : parent widget
29 // title : is the title for the user in dialog box
30 // label : text label for the value
32 // bottom : the minimal value to be entered
33 // top : the maximum value to be entered
34 // decimals : number of decimals to be entered
36 // The dialog will by default be modal, unless you set 'modal' to
37 // false when constructing dialog
39 //======================================================================================
40 SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent,
47 : QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
48 myIntSpin( 0 ), myDblSpin( 0 )
50 /* creating widgets */
55 myTextLabel->setText( label );
57 myDblSpin->setRange( bottom, top );
58 ((QDoubleValidator*)(myDblSpin->validator()))->setRange( bottom, top, decimals );
60 /* Move widget on the botton right corner of main widget */
61 QAD_Tools::centerWidget( this, parent );
64 //======================================================================================
65 // function : SMESHGUI_aParameterDlg()
66 // purpose : Constructs a SMESHGUI_aParametertDlg for int values
68 // parent : parent widget
69 // title : is the title for the user in dialog box
70 // label : text label for the value
72 // bottom : the minimal value to be entered
73 // top : the maximum value to be entered
75 // The dialog will by default be modal, unless you set 'modal' to
76 // false when constructing dialog
78 //======================================================================================
79 SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent,
85 : QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ),
86 myIntSpin( 0 ), myDblSpin( 0 )
88 /* creating widgets */
93 myTextLabel->setText( label );
95 myIntSpin->setRange( bottom, top );
96 ((QIntValidator*)(myIntSpin->validator()))->setRange( bottom, top );
98 /* Move widget on the botton right corner of main widget */
99 QAD_Tools::centerWidget( this, parent );
102 //======================================================================================
103 // function : SMESHGUI_aParameterDlg::init()
104 // purpose : creates dialog's layout
105 //======================================================================================
106 void SMESHGUI_aParameterDlg::init( bool isDouble )
108 setSizeGripEnabled( TRUE );
110 QGridLayout* topLayout = new QGridLayout( this );
111 topLayout->setMargin( 11 ); topLayout->setSpacing( 6 );
113 /***************************************************************/
114 QGroupBox* GroupC1 = new QGroupBox( this, "GroupC1" );
115 GroupC1->setColumnLayout(0, Qt::Vertical );
116 GroupC1->layout()->setSpacing( 0 );
117 GroupC1->layout()->setMargin( 0 );
118 QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() );
119 GroupC1Layout->setAlignment( Qt::AlignTop );
120 GroupC1Layout->setSpacing( 6 );
121 GroupC1Layout->setMargin( 11 );
123 /* aTitle1 : text prompt on left of edit line */
124 myTextLabel = new QLabel( GroupC1, "TextLabel" );
125 GroupC1Layout->addWidget( myTextLabel, 0, 0 );
129 myDblSpin = new QAD_SpinBoxDbl( GroupC1 );
130 myDblSpin->setPrecision( 12 );
131 myDblSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
132 myDblSpin->setMinimumSize( 150, 0 );
133 GroupC1Layout->addWidget( myDblSpin, 0, 1 );
137 myIntSpin = new QSpinBox( GroupC1 );
138 myIntSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
139 myIntSpin->setMinimumSize( 150, 0 );
140 GroupC1Layout->addWidget( myIntSpin, 0, 1 );
143 /***************************************************************/
144 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
145 GroupButtons->setColumnLayout(0, Qt::Vertical );
146 GroupButtons->layout()->setSpacing( 0 );
147 GroupButtons->layout()->setMargin( 0 );
148 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
149 GroupButtonsLayout->setAlignment( Qt::AlignTop );
150 GroupButtonsLayout->setSpacing( 6 );
151 GroupButtonsLayout->setMargin( 11 );
153 myButtonOk = new QPushButton( GroupButtons, "buttonOk" );
154 myButtonOk->setText( tr("SMESH_BUT_OK") );
155 myButtonOk->setAutoDefault( TRUE );
156 myButtonOk->setDefault( TRUE );
157 GroupButtonsLayout->addWidget( myButtonOk, 0, 0 );
158 /* add spacer between buttons */
159 GroupButtonsLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
161 myButtonCancel = new QPushButton( GroupButtons, "buttonCancel" );
162 myButtonCancel->setText( tr("SMESH_BUT_CANCEL") );
163 myButtonCancel->setAutoDefault( TRUE );
164 GroupButtonsLayout->addWidget( myButtonCancel, 0, 2 );
166 /***************************************************************/
167 topLayout->addWidget( GroupC1, 0, 0);
168 topLayout->addWidget( GroupButtons, 1, 0);
170 /* signals and slots connections */
171 connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
172 connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
174 /* Retrieve SMESHGUI */
175 mySMESHGUI = SMESHGUI::GetSMESHGUI() ;
179 //======================================================================================
180 // function : ~SMESHGUI_aParameterDlg()
181 // purpose : Destructor
182 //======================================================================================
183 SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg()
187 //======================================================================================
188 // function : SMESHGUI_aParameterDlg::setValue
189 // purpose : sets double value
190 //======================================================================================
191 void SMESHGUI_aParameterDlg::setValue( const double val )
194 myDblSpin->setValue( val );
196 //======================================================================================
197 // function : SMESHGUI_aParameterDlg::setValue
198 // purpose : sets int value
199 //======================================================================================
200 void SMESHGUI_aParameterDlg::setValue( const int val )
203 myIntSpin->setValue( val );
205 //======================================================================================
206 // function : SMESHGUI_aParameterDlg::getDblValue
207 // purpose : returns double value entered by user
208 //======================================================================================
209 double SMESHGUI_aParameterDlg::getDblValue()
212 return myDblSpin->value();
216 //======================================================================================
217 // function : SMESHGUI_aParameterDlg::getIntValu
218 // purpose : returns int value entered by user
219 //======================================================================================
220 int SMESHGUI_aParameterDlg::getIntValue()
223 return myIntSpin->value();