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