Salome HOME
NRI : Add message (GUI lib not found).
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_TrihedronSizeDlg.cxx
1 using namespace std;
2 //  File      : SALOMEGUI_TrihedronSizeDlg.cxx
3 //  Created   : Fri Mar 22 16:34:27 2002
4 //  Author    : Nicolas REJNERI
5 //  Project   : SALOME
6 //  Module    : SALOMEGUI
7 //  Copyright : Open CASCADE 2002
8 //  $Header$
9
10 #include "SALOMEGUI_TrihedronSizeDlg.h"
11
12 #include <qbuttongroup.h>
13 #include <qlabel.h>
14 #include <qpushbutton.h>
15 #include <qspinbox.h>
16 #include <qlayout.h>
17
18 #define MARGIN_SIZE      11
19 #define SPACING_SIZE      6
20 #define MIN_SPIN_WIDTH  100 
21
22 /* 
23  *  Constructs a modal SALOMEGUI_TrihedronSizeDlg which is a child of 'parent'
24  *
25  */
26 SALOMEGUI_TrihedronSizeDlg::SALOMEGUI_TrihedronSizeDlg( QWidget* parent )
27      : QDialog( parent, "SALOMEGUI_TrihedronSizeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
28 {
29   setCaption( tr( "MEN_TRIHEDRON"  ) );
30   setSizeGripEnabled( true );
31
32   QGridLayout* topLayout = new QGridLayout( this );
33   topLayout->setSpacing( SPACING_SIZE );
34   topLayout->setMargin( MARGIN_SIZE );
35
36   QGroupBox* trihedronGrp = new QGroupBox( this, "trihedronGrp" );
37   trihedronGrp->setColumnLayout( 0, Qt::Vertical );
38   trihedronGrp->layout()->setSpacing( 0 );
39   trihedronGrp->layout()->setMargin( 0 );
40   QGridLayout* trihedronGrpLayout = new QGridLayout( trihedronGrp->layout() );
41   trihedronGrpLayout->setAlignment( Qt::AlignTop );
42   trihedronGrpLayout->setSpacing( SPACING_SIZE );
43   trihedronGrpLayout->setMargin( MARGIN_SIZE  );  
44
45   QHBoxLayout* aBtnLayout = new QHBoxLayout;
46   aBtnLayout->setSpacing( SPACING_SIZE );
47   aBtnLayout->setMargin( 0 );
48
49   QPushButton* buttonOk = new QPushButton( this, "buttonOk" );
50   buttonOk->setText( tr( "BUT_OK"  ) );
51   buttonOk->setAutoDefault( TRUE );
52   buttonOk->setDefault( TRUE );
53   
54   QPushButton* buttonCancel = new QPushButton( this, "buttonCancel" );
55   buttonCancel->setText( tr( "BUT_CANCEL"  ) );
56   buttonCancel->setAutoDefault( TRUE );
57
58   QLabel* TextLabel = new QLabel( trihedronGrp, "TextLabel" );
59   TextLabel->setText( tr( "MEN_TRIHEDRON_SIZE"  ) );
60
61   SpinBox = new QSpinBox( 1, 999999999, 1, trihedronGrp, "SpinBox" );
62   SpinBox->setValue( 100 );
63   SpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
64   SpinBox->setMinimumWidth(MIN_SPIN_WIDTH);
65
66   trihedronGrpLayout->addWidget(TextLabel, 0, 0);
67   trihedronGrpLayout->addWidget(SpinBox, 0, 1);
68
69   aBtnLayout->addWidget( buttonOk );
70   aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
71   aBtnLayout->addWidget( buttonCancel );
72
73   topLayout->addWidget( trihedronGrp, 0, 0 );
74   topLayout->addLayout( aBtnLayout, 1, 0 ); 
75
76   // signals and slots connections
77   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
78   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
79 }
80
81 /*  
82  *  Destroys the object and frees any allocated resources
83  */
84 SALOMEGUI_TrihedronSizeDlg::~SALOMEGUI_TrihedronSizeDlg()
85 {
86     // no need to delete child widgets, Qt does it all for us
87 }
88
89 /*
90    Sets start trihedron size
91 */
92 void SALOMEGUI_TrihedronSizeDlg::setTrihedronSize(const int size)
93 {
94   SpinBox->setValue(size);
95 }
96
97 /*
98    Gets trihedron size
99 */
100 int SALOMEGUI_TrihedronSizeDlg::getTrihedronSize()
101 {
102   return SpinBox->value();
103 }