Salome HOME
Initial version
[modules/gui.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
19 #define MARGIN_SIZE      11
20 #define SPACING_SIZE      6
21 #define MIN_SPIN_WIDTH  100 
22
23 IntervalWindow::IntervalWindow ( QWidget* parent )
24      : QDialog( parent, "IntervalWindow" , true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
25 {
26   BEGIN_OF("IntervalWindow constructor")
27   setCaption( tr( "Refresh Interval"  ) );
28   setSizeGripEnabled( true );
29
30   QGridLayout* topLayout = new QGridLayout( this );
31   topLayout->setSpacing( SPACING_SIZE );
32   topLayout->setMargin( MARGIN_SIZE );
33
34   QGroupBox* intervalGrp = new QGroupBox( this, "intervalGrp" );
35   intervalGrp->setColumnLayout( 0, Qt::Horizontal );//Vertical
36   intervalGrp->layout()->setSpacing( 0 );
37   intervalGrp->layout()->setMargin( 0 );
38   QGridLayout* intervalGrpLayout = new QGridLayout( intervalGrp->layout() );
39   intervalGrpLayout->setAlignment( Qt::AlignTop );
40   intervalGrpLayout->setSpacing( SPACING_SIZE );
41   intervalGrpLayout->setMargin( MARGIN_SIZE  );  
42
43   QHBoxLayout* aBtnLayout = new QHBoxLayout;
44   aBtnLayout->setSpacing( SPACING_SIZE );
45   aBtnLayout->setMargin( 0 );
46
47   myButtonOk = new QPushButton( this, "buttonOk" );
48   myButtonOk->setText( tr( "BUT_OK"  ) );
49   myButtonOk->setAutoDefault( TRUE );
50   myButtonOk->setDefault( TRUE );
51   
52   myButtonCancel = new QPushButton( this, "buttonCancel" );
53   myButtonCancel->setText( tr( "BUT_CANCEL"  ) );
54   myButtonCancel->setAutoDefault( TRUE );
55
56   QLabel* TextLabel = new QLabel( intervalGrp, "TextLabel" );
57   TextLabel->setText( tr( "Please, enter a number of seconds:"  ) );
58
59   mySpinBox = new QSpinBox( 1, 999999999, 1, intervalGrp, "SpinBox" );
60   mySpinBox->setValue( 100 );
61   mySpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
62   mySpinBox->setMinimumWidth(MIN_SPIN_WIDTH);
63
64   intervalGrpLayout->addWidget(TextLabel, 0, 0);
65   intervalGrpLayout->addWidget(mySpinBox, 0, 1);
66
67   aBtnLayout->addWidget( myButtonOk );
68   aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
69   aBtnLayout->addWidget( myButtonCancel );
70
71   topLayout->addWidget( intervalGrp, 0, 0 );
72   topLayout->addLayout( aBtnLayout, 1, 0 ); 
73
74   END_OF("IntervalWindow constructor")
75 }
76 IntervalWindow::~IntervalWindow() {}
77 /* 
78    Sets start interval size
79 */
80 void IntervalWindow::setValue(const int size)
81 {
82   mySpinBox->setValue(size);
83 }
84
85 /*
86    Gets interval size
87 */
88 int IntervalWindow::getValue()
89 {
90   return mySpinBox->value();
91 }
92
93 /*
94    gets a pointer to myButtonOk
95 */
96 QPushButton* IntervalWindow::Ok()
97 {
98   return myButtonOk;
99 }
100
101 /*
102    gets a pointer to myButtonCancel
103 */
104 QPushButton* IntervalWindow::Cancel()
105 {
106   return myButtonCancel;
107 }