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