]> SALOME platform Git repositories - modules/kernel.git/blob - src/SALOMEGUI/SALOMEGUI_OpenWith.cxx
Salome HOME
Initialisation de la base KERNEL avec la version operationnelle de KERNEL_SRC issue...
[modules/kernel.git] / src / SALOMEGUI / SALOMEGUI_OpenWith.cxx
1 using namespace std;
2 //  File      : SALOMEGUI_OpenWith.cxx
3 //  Created   : Wed Oct 24 12:19:34 2001
4 //  Author    : Nicolas REJNERI
5 //  Project   : SALOME
6 //  Module    : SALOMEGUI
7 //  Copyright : Open CASCADE
8 //  $Header$
9
10
11 #include "SALOMEGUI_OpenWith.h"
12
13 #include <qlabel.h>
14 #include <qcheckbox.h>
15 #include <qpushbutton.h>
16 #include <qlayout.h>
17 #include <qlistbox.h>
18
19 #define SPACING_SIZE             6
20 #define MARGIN_SIZE             11
21 #define MIN_LISTBOX_WIDTH      150
22 #define MIN_LISTBOX_HEIGHT     100
23
24 /* 
25  *  Constructs modal SALOMEGUI_OpenWith which is a child of 'parent', with the 
26  *  name 'name' 
27  */
28 SALOMEGUI_OpenWith::SALOMEGUI_OpenWith(QWidget* parent,  const char* name)
29     : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
30 {
31   if ( !name )
32     setName( "SALOMEGUI_OpenWith" );
33   setCaption( tr("OPEN_WITH_TLT") );
34   setSizeGripEnabled( TRUE );
35
36   QGridLayout* aTopLayout = new QGridLayout(this);
37   aTopLayout->setMargin(MARGIN_SIZE);
38   aTopLayout->setSpacing(SPACING_SIZE);
39   
40   AllwaysCheckBox = 0;
41 /*  
42   AllwaysCheckBox = new QCheckBox( this, "AllwaysCheckBox" );
43   AllwaysCheckBox->setText( tr( "MEN_COMPONENT_CHOICE1"  ) );
44 */  
45   QHBoxLayout* aBtnLayout = new QHBoxLayout;
46   aBtnLayout->setSpacing( SPACING_SIZE );
47   aBtnLayout->setMargin( 0 );
48
49   buttonOk = new QPushButton( this, "buttonOk" );
50   buttonOk->setText( tr( "BUT_OK"  ) );
51   buttonOk->setAutoDefault( true );
52   buttonOk->setDefault( true );
53   
54   buttonCancel = new QPushButton( this, "buttonCancel" );
55   buttonCancel->setText( tr( "BUT_CANCEL"  ) );
56   buttonCancel->setAutoDefault( true );
57   
58   aBtnLayout->addWidget( buttonOk );
59   aBtnLayout->addItem( new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
60   aBtnLayout->addWidget( buttonCancel );
61
62   ListComponent = new QListBox( this, "ListComponent" );
63   ListComponent->setVScrollBarMode(QListBox::AlwaysOn);
64   ListComponent->setMinimumSize(MIN_LISTBOX_WIDTH, MIN_LISTBOX_HEIGHT);
65   ListComponent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
66   ListComponent->setSelectionMode(QListBox::Single);
67   
68   aTopLayout->addWidget(ListComponent,   0, 0);
69 //  aTopLayout->addWidget(AllwaysCheckBox, 1, 0);
70   aTopLayout->addLayout(aBtnLayout,      1, 0);
71   
72   // signals and slots connections
73   connect( buttonOk,      SIGNAL( clicked() ),          this, SLOT( accept() ) );
74   connect( buttonCancel,  SIGNAL( clicked() ),          this, SLOT( reject() ) );
75   connect( ListComponent, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ));
76
77   updateButtonState();
78 }
79
80 /*  
81  *  Destroys the object and frees any allocated resources
82  */
83 SALOMEGUI_OpenWith::~SALOMEGUI_OpenWith()
84 {
85 }
86
87 /*
88    Inserts new component into component list
89 */
90 void SALOMEGUI_OpenWith::addComponent(const QString& aComp)
91 {
92   ListComponent->insertItem(aComp);
93 }
94
95 /*
96    Returns choosen component
97 */
98 QString SALOMEGUI_OpenWith::getComponent()
99 {
100   return ListComponent->currentText();
101 }
102
103 bool SALOMEGUI_OpenWith::getAlwaysFlag()
104 {
105   if ( AllwaysCheckBox )
106     return AllwaysCheckBox->isChecked();
107   return false;
108 }
109 void SALOMEGUI_OpenWith::onSelectionChanged()
110 {
111   updateButtonState();
112 }
113
114 void SALOMEGUI_OpenWith:: updateButtonState()
115 {
116   buttonOk->setEnabled( ListComponent->currentItem() >=0 && 
117                         ListComponent->currentItem() < ListComponent->count() ) ;
118 }