Salome HOME
PR: mergefrom_BR_CCRT_11Nov04
[modules/kernel.git] / src / RegistryDisplay / IntervalWindow.cxx
1 //  SALOME RegistryDisplay : GUI for Registry server implementation
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : IntervalWindow.cxx
8 //  Author : Oksana TCHEBANOVA
9 //  Module : SALOME
10
11 #include <IntervalWindow.hxx>
12
13 #include <qbuttongroup.h>
14 #include <qlabel.h>
15 #include <qpushbutton.h>
16 #include <qlayout.h>
17 # include "utilities.h"
18 using namespace std;
19
20 #define MARGIN_SIZE      11
21 #define SPACING_SIZE      6
22 #define MIN_SPIN_WIDTH  100 
23
24 IntervalWindow::IntervalWindow ( QWidget* parent )
25      : QDialog( parent, "IntervalWindow" , true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
26 {
27   BEGIN_OF("IntervalWindow constructor")
28   setCaption( tr( "Refresh Interval"  ) );
29   setSizeGripEnabled( true );
30
31   QGridLayout* topLayout = new QGridLayout( this );
32   topLayout->setSpacing( SPACING_SIZE );
33   topLayout->setMargin( MARGIN_SIZE );
34
35   QGroupBox* intervalGrp = new QGroupBox( this, "intervalGrp" );
36   intervalGrp->setColumnLayout( 0, Qt::Horizontal );//Vertical
37   intervalGrp->layout()->setSpacing( 0 );
38   intervalGrp->layout()->setMargin( 0 );
39   QGridLayout* intervalGrpLayout = new QGridLayout( intervalGrp->layout() );
40   intervalGrpLayout->setAlignment( Qt::AlignTop );
41   intervalGrpLayout->setSpacing( SPACING_SIZE );
42   intervalGrpLayout->setMargin( MARGIN_SIZE  );  
43
44   QHBoxLayout* aBtnLayout = new QHBoxLayout;
45   aBtnLayout->setSpacing( SPACING_SIZE );
46   aBtnLayout->setMargin( 0 );
47
48   myButtonOk = new QPushButton( this, "buttonOk" );
49   myButtonOk->setText( tr( "BUT_OK"  ) );
50   myButtonOk->setAutoDefault( TRUE );
51   myButtonOk->setDefault( TRUE );
52   
53   myButtonCancel = new QPushButton( this, "buttonCancel" );
54   myButtonCancel->setText( tr( "BUT_CANCEL"  ) );
55   myButtonCancel->setAutoDefault( TRUE );
56
57   QLabel* TextLabel = new QLabel( intervalGrp, "TextLabel" );
58   TextLabel->setText( tr( "Please, enter a number of seconds:"  ) );
59
60   mySpinBox = new QSpinBox( 1, 999999999, 1, intervalGrp, "SpinBox" );
61   mySpinBox->setValue( 100 );
62   mySpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
63   mySpinBox->setMinimumWidth(MIN_SPIN_WIDTH);
64
65   intervalGrpLayout->addWidget(TextLabel, 0, 0);
66   intervalGrpLayout->addWidget(mySpinBox, 0, 1);
67
68   aBtnLayout->addWidget( myButtonOk );
69   aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
70   aBtnLayout->addWidget( myButtonCancel );
71
72   topLayout->addWidget( intervalGrp, 0, 0 );
73   topLayout->addLayout( aBtnLayout, 1, 0 ); 
74
75   END_OF("IntervalWindow constructor")
76 }
77 IntervalWindow::~IntervalWindow() {}
78 /* 
79    Sets start interval size
80 */
81 void IntervalWindow::setValue(const int size)
82 {
83   mySpinBox->setValue(size);
84 }
85
86 /*
87    Gets interval size
88 */
89 int IntervalWindow::getValue()
90 {
91   return mySpinBox->value();
92 }
93
94 /*
95    gets a pointer to myButtonOk
96 */
97 QPushButton* IntervalWindow::Ok()
98 {
99   return myButtonOk;
100 }
101
102 /*
103    gets a pointer to myButtonCancel
104 */
105 QPushButton* IntervalWindow::Cancel()
106 {
107   return myButtonCancel;
108 }