Salome HOME
NRI : Merge from V1_2.
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_TrihedronSizeDlg.cxx
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEGUI_TrihedronSizeDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 using namespace std;
30 #include "SALOMEGUI_TrihedronSizeDlg.h"
31
32 #include <qbuttongroup.h>
33 #include <qlabel.h>
34 #include <qpushbutton.h>
35 #include <qspinbox.h>
36 #include <qlayout.h>
37
38 #define MARGIN_SIZE      11
39 #define SPACING_SIZE      6
40 #define MIN_SPIN_WIDTH  100 
41
42 /* 
43  *  Constructs a modal SALOMEGUI_TrihedronSizeDlg which is a child of 'parent'
44  *
45  */
46 SALOMEGUI_TrihedronSizeDlg::SALOMEGUI_TrihedronSizeDlg( QWidget* parent )
47      : QDialog( parent, "SALOMEGUI_TrihedronSizeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
48 {
49   setCaption( tr( "MEN_TRIHEDRON"  ) );
50   setSizeGripEnabled( true );
51
52   QGridLayout* topLayout = new QGridLayout( this );
53   topLayout->setSpacing( SPACING_SIZE );
54   topLayout->setMargin( MARGIN_SIZE );
55
56   QGroupBox* trihedronGrp = new QGroupBox( this, "trihedronGrp" );
57   trihedronGrp->setColumnLayout( 0, Qt::Vertical );
58   trihedronGrp->layout()->setSpacing( 0 );
59   trihedronGrp->layout()->setMargin( 0 );
60   QGridLayout* trihedronGrpLayout = new QGridLayout( trihedronGrp->layout() );
61   trihedronGrpLayout->setAlignment( Qt::AlignTop );
62   trihedronGrpLayout->setSpacing( SPACING_SIZE );
63   trihedronGrpLayout->setMargin( MARGIN_SIZE  );  
64
65   QHBoxLayout* aBtnLayout = new QHBoxLayout;
66   aBtnLayout->setSpacing( SPACING_SIZE );
67   aBtnLayout->setMargin( 0 );
68
69   QPushButton* buttonOk = new QPushButton( this, "buttonOk" );
70   buttonOk->setText( tr( "BUT_OK"  ) );
71   buttonOk->setAutoDefault( TRUE );
72   buttonOk->setDefault( TRUE );
73   
74   QPushButton* buttonCancel = new QPushButton( this, "buttonCancel" );
75   buttonCancel->setText( tr( "BUT_CANCEL"  ) );
76   buttonCancel->setAutoDefault( TRUE );
77
78   QLabel* TextLabel = new QLabel( trihedronGrp, "TextLabel" );
79   TextLabel->setText( tr( "MEN_TRIHEDRON_SIZE"  ) );
80
81   SpinBox = new QSpinBox( 1, 999999999, 1, trihedronGrp, "SpinBox" );
82   SpinBox->setValue( 100 );
83   SpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
84   SpinBox->setMinimumWidth(MIN_SPIN_WIDTH);
85
86   trihedronGrpLayout->addWidget(TextLabel, 0, 0);
87   trihedronGrpLayout->addWidget(SpinBox, 0, 1);
88
89   aBtnLayout->addWidget( buttonOk );
90   aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
91   aBtnLayout->addWidget( buttonCancel );
92
93   topLayout->addWidget( trihedronGrp, 0, 0 );
94   topLayout->addLayout( aBtnLayout, 1, 0 ); 
95
96   // signals and slots connections
97   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
98   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
99 }
100
101 /*  
102  *  Destroys the object and frees any allocated resources
103  */
104 SALOMEGUI_TrihedronSizeDlg::~SALOMEGUI_TrihedronSizeDlg()
105 {
106     // no need to delete child widgets, Qt does it all for us
107 }
108
109 /*
110    Sets start trihedron size
111 */
112 void SALOMEGUI_TrihedronSizeDlg::setTrihedronSize(const int size)
113 {
114   SpinBox->setValue(size);
115 }
116
117 /*
118    Gets trihedron size
119 */
120 int SALOMEGUI_TrihedronSizeDlg::getTrihedronSize()
121 {
122   return SpinBox->value();
123 }