Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/gui.git] / src / RegistryDisplay / IntervalWindow.cxx
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 //  SALOME RegistryDisplay : GUI for Registry server implementation
20 //
21 //  File   : IntervalWindow.cxx
22 //  Author : Oksana TCHEBANOVA
23 //  Module : SALOME
24
25 #include <IntervalWindow.hxx>
26
27 #include <qbuttongroup.h>
28 #include <qlabel.h>
29 #include <qpushbutton.h>
30 #include <qlayout.h>
31 # include "utilities.h"
32
33 #define MARGIN_SIZE      11
34 #define SPACING_SIZE      6
35 #define MIN_SPIN_WIDTH  100 
36
37 /*!
38   Constructor
39 */
40 IntervalWindow::IntervalWindow ( QWidget* parent )
41      : QDialog( parent, "IntervalWindow" , true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose )
42 {
43   BEGIN_OF("IntervalWindow constructor")
44   setCaption( tr( "Refresh Interval"  ) );
45   setSizeGripEnabled( true );
46
47   QGridLayout* topLayout = new QGridLayout( this );
48   topLayout->setSpacing( SPACING_SIZE );
49   topLayout->setMargin( MARGIN_SIZE );
50
51   QGroupBox* intervalGrp = new QGroupBox( this, "intervalGrp" );
52   intervalGrp->setColumnLayout( 0, Qt::Horizontal );//Vertical
53   intervalGrp->layout()->setSpacing( 0 );
54   intervalGrp->layout()->setMargin( 0 );
55   QGridLayout* intervalGrpLayout = new QGridLayout( intervalGrp->layout() );
56   intervalGrpLayout->setAlignment( Qt::AlignTop );
57   intervalGrpLayout->setSpacing( SPACING_SIZE );
58   intervalGrpLayout->setMargin( MARGIN_SIZE  );  
59
60   QHBoxLayout* aBtnLayout = new QHBoxLayout;
61   aBtnLayout->setSpacing( SPACING_SIZE );
62   aBtnLayout->setMargin( 0 );
63
64   myButtonOk = new QPushButton( this, "buttonOk" );
65   myButtonOk->setText( tr( "BUT_OK"  ) );
66   myButtonOk->setAutoDefault( TRUE );
67   myButtonOk->setDefault( TRUE );
68   
69   myButtonCancel = new QPushButton( this, "buttonCancel" );
70   myButtonCancel->setText( tr( "BUT_CANCEL"  ) );
71   myButtonCancel->setAutoDefault( TRUE );
72
73   QLabel* TextLabel = new QLabel( intervalGrp, "TextLabel" );
74   TextLabel->setText( tr( "Please, enter a number of seconds:"  ) );
75
76   mySpinBox = new QSpinBox( 1, 999999999, 1, intervalGrp, "SpinBox" );
77   mySpinBox->setValue( 100 );
78   mySpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
79   mySpinBox->setMinimumWidth(MIN_SPIN_WIDTH);
80
81   intervalGrpLayout->addWidget(TextLabel, 0, 0);
82   intervalGrpLayout->addWidget(mySpinBox, 0, 1);
83
84   aBtnLayout->addWidget( myButtonOk );
85   aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
86   aBtnLayout->addWidget( myButtonCancel );
87
88   topLayout->addWidget( intervalGrp, 0, 0 );
89   topLayout->addLayout( aBtnLayout, 1, 0 ); 
90
91   END_OF("IntervalWindow constructor")
92 }
93
94 /*!
95   Destructor
96 */
97 IntervalWindow::~IntervalWindow() {}
98
99 /*!
100    Sets start interval size
101 */
102 void IntervalWindow::setValue(const int size)
103 {
104   mySpinBox->setValue(size);
105 }
106
107 /*!
108    Gets interval size
109 */
110 int IntervalWindow::getValue()
111 {
112   return mySpinBox->value();
113 }
114
115 /*!
116    gets a pointer to myButtonOk
117 */
118 QPushButton* IntervalWindow::Ok()
119 {
120   return myButtonOk;
121 }
122
123 /*!
124    gets a pointer to myButtonCancel
125 */
126 QPushButton* IntervalWindow::Cancel()
127 {
128   return myButtonCancel;
129 }