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