Salome HOME
To introduce default launch mode of SALOMEDS server
[modules/gui.git] / src / SalomeApp / SalomeApp_ModuleDlg.cxx
1 //  SALOME SALOMEGUI : implementation of desktop and GUI kernel
2 //
3 //  Copyright (C) 2005  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SalomeApp_ModuleDlg.cxx
8 //  Author : Michael Zorin (mzn)
9 //  Module : SALOME
10
11 #include "SalomeApp_ModuleDlg.h"
12
13 #include <qframe.h>
14 #include <qlabel.h>
15 #include <qpushbutton.h>
16 #include <qlayout.h>
17 #include <qpixmap.h>
18
19 #ifndef WNT
20 using namespace std;
21 #endif
22
23 /*!Default icon*/
24 static const char* const default_icon[] = { 
25 "48 48 17 1",
26 ". c None",
27 "# c #161e4c",
28 "b c #1d3638",
29 "e c #2f585b",
30 "i c #345b5e",
31 "c c #386266",
32 "g c #3f7477",
33 "d c #4d8589",
34 "m c #519099",
35 "o c #6abbc1",
36 "a c #70c9d3",
37 "f c #79ddea",
38 "n c #7adff2",
39 "k c #7ce2f4",
40 "j c #993550",
41 "h c #d84b71",
42 "l c #ef537d",
43 "................................................",
44 "................................................",
45 "................................................",
46 "................................................",
47 "................................................",
48 "................########.########.########......",
49 "...............#aaaaaa###aaaaaa###aaaaaa##......",
50 "..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
51 ".............########b########b########cc#......",
52 ".............#dddddd#b#dddddd#b#dddddd#cc#......",
53 "...........########d########d########d#cc#......",
54 "..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
55 ".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
56 "........########b########e########cc#d#c#.......",
57 "........#dddddd#b#dddddd#e#ffffff#cc#d####......",
58 "......########d########d########f#cc###g##......",
59 ".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
60 "....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
61 "...########b########i########jj#f#c#gg#cc#......",
62 "...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
63 "...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
64 "...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
65 "...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
66 "...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
67 "...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
68 "...########g########g########o##d#cc#gg#c#......",
69 "....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
70 "...########b########b########cc#d#c#gg#cc#......",
71 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
72 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
73 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
74 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
75 "...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
76 "...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
77 "...########g########g########g##g#cc#...........",
78 "....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
79 "...########b########b########cc#g#c#............",
80 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
81 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
82 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
83 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
84 "...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
85 "...#kkkkkk###kkkkkk###kkkkkk##..................",
86 "...########.########.########...................",
87 "................................................",
88 "................................................",
89 "................................................",
90 "................................................"};
91
92 //==============================================================================================================================
93 /*!
94  *  SalomeApp_ModuleDlg::SalomeApp_ModuleDlg \n
95  *
96  *  Constructor.
97  */
98 //==============================================================================================================================
99 SalomeApp_ModuleDlg::SalomeApp_ModuleDlg ( QWidget * parent, const QString& component, const QPixmap icon )
100      : QDialog ( parent, "ActivateModuleDlg", true,  WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
101 {
102   QPixmap defaultIcon( ( const char** ) default_icon );
103   setCaption( tr( "CAPTION" ) );
104   setSizeGripEnabled( TRUE );
105   
106   QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this ); 
107   ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
108
109   // Module's name and icon
110   myComponentFrame = new QFrame( this, "myComponentFrame" );
111   myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
112   myComponentFrame->setMinimumHeight( 100 );
113   myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
114   
115   QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame ); 
116   myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
117
118   // --> icon
119   myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
120   myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
121   myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
122   myComponentIcon->setScaledContents( false );
123   myComponentIcon->setAlignment( AlignCenter );
124   // --> name
125   myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
126   QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt ); 
127   myComponentLab->setAlignment( AlignCenter );
128
129   myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
130   myComponentFrameLayout->addWidget( myComponentLab,  0, 1 );
131
132   // Info
133   QVBoxLayout* infoLayout = new QVBoxLayout();
134   infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
135   
136   // --> top line
137   QFrame* myLine1 = new QFrame( this, "myLine1" );
138   myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
139   // --> info label  
140   myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
141   myInfoLabel->setAlignment( AlignCenter );
142   // --> bottom line
143   QFrame*  myLine2 = new QFrame( this, "myLine2" );
144   myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
145   
146   infoLayout->addStretch();
147   infoLayout->addWidget( myLine1 );
148   infoLayout->addWidget( myInfoLabel );
149   infoLayout->addWidget( myLine2 );
150   infoLayout->addStretch();
151   
152   // Buttons
153   QHBoxLayout* btnLayout = new QHBoxLayout(); 
154   btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
155   
156   // --> New
157   myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
158   myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
159   // --> Open
160   myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
161   myOpenBtn->setAutoDefault( true );
162   // --> Load
163   myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
164   myLoadBtn->setAutoDefault( true );
165   // --> Cancel
166   myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
167   myCancelBtn->setAutoDefault( true );
168   
169   btnLayout->addWidget( myNewBtn );
170   btnLayout->addWidget( myOpenBtn );
171   btnLayout->addWidget( myLoadBtn );
172   btnLayout->addStretch();
173   btnLayout->addSpacing( 70 );
174   btnLayout->addStretch();
175   btnLayout->addWidget( myCancelBtn );
176
177   ActivateModuleDlgLayout->addWidget(          myComponentFrame, 0,    0    );
178   ActivateModuleDlgLayout->addLayout(          infoLayout,       0,    1    );
179   ActivateModuleDlgLayout->addMultiCellLayout( btnLayout,        1, 1, 0, 1 );
180
181   // signals and slots connections
182   connect( myNewBtn,    SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
183   connect( myOpenBtn,   SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
184   connect( myLoadBtn,   SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
185   connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
186 }
187
188 //==============================================================================================================================
189 /*!
190  *  SalomeApp_ModuleDlg::onButtonClicked
191  *
192  *  Buttons slot
193  */
194 //==============================================================================================================================
195 void SalomeApp_ModuleDlg::onButtonClicked()
196 {
197   QPushButton* btn = ( QPushButton* )sender();
198   if ( btn == myNewBtn )
199     done( 1 );
200   if ( btn == myOpenBtn )
201     done( 2 );
202   if ( btn == myLoadBtn )
203     done( 3 );
204 }