Salome HOME
NRI : Add message (GUI lib not found).
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_CloseDlg.cxx
1 using namespace std;
2 // File      : SALOMEGUI_CloseDlg.cxx
3 // Created   : Wed Feb 26 11:40:52 2003
4 // Author    : Vasily RUSYAEV (vrv)
5 // Copyright : Open CASCADE
6
7 #include "SALOMEGUI_CloseDlg.h"
8
9 #include <qpushbutton.h>
10 #include <qhbuttongroup.h>
11 #include <qlayout.h> 
12 #include <qlabel.h> 
13 #include <qmessagebox.h>
14
15
16 SALOMEGUI_CloseDlg::SALOMEGUI_CloseDlg ( QWidget * parent, const char * name, bool modal, WFlags f )
17      : QDialog ( parent, "", TRUE,  WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
18 {
19   setSizeGripEnabled ( TRUE ) ;
20   setCaption( tr( "CAPTION" ) );
21
22   QVBoxLayout* m_vbL = new QVBoxLayout( this );
23   m_vbL->setMargin( 11 ); m_vbL->setSpacing( 6 );
24
25   QLabel* m_lIcon  = new QLabel (this, "m_lDescr");
26   QPixmap pm = QMessageBox::standardIcon( QMessageBox::Warning );
27   m_lIcon->setPixmap( pm );
28   m_lIcon->setScaledContents( false );
29   m_lIcon->setAlignment( Qt::AlignCenter );
30
31   QLabel* m_lDescr = new QLabel (this, "m_lDescr");
32   m_lDescr->setText ( tr ("CLOSE_DESCRIPTION") );
33   m_lDescr->setAlignment( Qt::AlignCenter );
34   m_lDescr->setMinimumHeight( m_lDescr->sizeHint().height()*5 );
35   m_lDescr->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
36
37   QHBoxLayout* m_hl1 = new QHBoxLayout();
38   m_hl1->setMargin( 0 ); m_hl1->setSpacing( 6 );
39   m_hl1->addWidget( m_lIcon );
40   m_hl1->addWidget( m_lDescr );
41
42   m_pb1 = new QPushButton( tr ("SAVE_CLOSE"), this );
43   m_pb2 = new QPushButton( tr ("CLOSE"),      this );
44   m_pb3 = new QPushButton( tr ("UNLOAD"),     this );
45   m_pb4 = new QPushButton( tr ("CANCEL"),     this );
46
47   QGridLayout* m_hl2 = new QGridLayout();
48   m_hl2->setMargin( 0 ); m_hl2->setSpacing( 6 );
49   m_hl2->addWidget( m_pb1, 0, 0 );
50   m_hl2->addWidget( m_pb2, 0, 1 );
51   m_hl2->addWidget( m_pb3, 0, 2 );
52   m_hl2->addColSpacing( 3, 10 );
53   m_hl2->setColStretch( 3, 5 );
54   m_hl2->addWidget( m_pb4, 0, 4 );
55   
56   m_vbL->addLayout( m_hl1 );
57   m_vbL->addLayout( m_hl2 );
58
59   connect( m_pb1, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
60   connect( m_pb2, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
61   connect( m_pb3, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
62   connect( m_pb4, SIGNAL( clicked() ), this, SLOT( reject() ) );
63 }
64
65 void SALOMEGUI_CloseDlg::onButtonClicked()
66 {
67   QPushButton* btn = ( QPushButton* )sender();
68   if ( btn == m_pb1 )
69     done( 1 );
70   if ( btn == m_pb2 )
71     done( 2 );
72   if ( btn == m_pb3 )
73     done( 3 );
74 }