Salome HOME
no message
[modules/gui.git] / src / STD / STD_CloseDlg.cxx
1 #include "STD_CloseDlg.h"
2
3 #include <qpushbutton.h>
4 #include <qhbuttongroup.h>
5 #include <qlayout.h> 
6 #include <qlabel.h> 
7 #include <qmessagebox.h>
8
9 #ifndef WNT
10 using namespace std;
11 #endif
12
13 //================================================================================
14 /*!
15  * \brief creates a Close dialog box
16  * \param parent a parent widget
17  * \param modal bool argument, if true the dialog box is a modal dialog box
18  * \param f style flags
19  * 
20  */
21 //================================================================================
22
23 STD_CloseDlg::STD_CloseDlg ( QWidget * parent, bool modal, WFlags f )
24      : QDialog ( parent, "", TRUE,  WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
25 {
26   setSizeGripEnabled ( TRUE ) ;
27   setCaption( tr( "CLOSE_DLG_CAPTION" ) );
28
29   QVBoxLayout* m_vbL = new QVBoxLayout( this );
30   m_vbL->setMargin( 11 ); m_vbL->setSpacing( 6 );
31
32   QLabel* m_lIcon  = new QLabel (this, "m_lDescr");
33   QPixmap pm = QMessageBox::standardIcon( QMessageBox::Warning );
34   m_lIcon->setPixmap( pm );
35   m_lIcon->setScaledContents( false );
36   m_lIcon->setAlignment( Qt::AlignCenter );
37
38   QLabel* m_lDescr = new QLabel (this, "m_lDescr");
39   m_lDescr->setText ( tr ("CLOSE_DLG_DESCRIPTION") );
40   m_lDescr->setAlignment( Qt::AlignCenter );
41   m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 );
42   m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
43
44   QHBoxLayout* m_hl1 = new QHBoxLayout();
45   m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
46   m_hl1->addWidget( m_lIcon );
47   m_hl1->addWidget( m_lDescr );
48
49   m_pb1 = new QPushButton( tr ("CLOSE_DLG_SAVE_CLOSE"), this );
50   m_pb2 = new QPushButton( tr ("CLOSE_DLG_CLOSE"),      this );
51   m_pb3 = new QPushButton( tr ("CLOSE_DLG_UNLOAD"),     this );
52   m_pb4 = new QPushButton( tr ("BUT_CANCEL"), this );
53
54   QGridLayout* m_hl2 = new QGridLayout();
55   m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
56   m_hl2->addWidget( m_pb1, 0, 0 );
57   m_hl2->addWidget( m_pb2, 0, 1 );
58   m_hl2->addWidget( m_pb3, 0, 2 );
59   m_hl2->addColSpacing( 3, 10 );
60   m_hl2->setColStretch( 3, 5 );
61   m_hl2->addWidget( m_pb4, 0, 4 );
62   
63   m_vbL->addLayout( m_hl1 );
64   m_vbL->addLayout( m_hl2 );
65
66   connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
67   connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
68   connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
69   connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) );
70 }
71
72 //================================================================================
73 /*!
74  * \brief reaction on clicked(pressed) button
75  */
76 //================================================================================
77
78 void STD_CloseDlg::onButtonClicked()
79 {
80   QPushButton* btn = ( QPushButton* )sender();
81   if ( btn == m_pb1 )
82     done( 1 );
83   if ( btn == m_pb2 )
84     done( 2 );
85   if ( btn == m_pb3 )
86     done( 3 );
87 }