1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2005 CEA/DEN, EDF R&D
7 // File : SalomeApp_ModuleDlg.cxx
8 // Author : Michael Zorin (mzn)
11 #include "SalomeApp_ModuleDlg.h"
15 #include <qpushbutton.h>
24 static const char* const default_icon[] = {
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 "................................................"};
92 //==============================================================================================================================
94 * SalomeApp_ModuleDlg::SalomeApp_ModuleDlg \n
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 )
102 QPixmap defaultIcon( ( const char** ) default_icon );
103 setCaption( tr( "CAPTION" ) );
104 setSizeGripEnabled( TRUE );
106 QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
107 ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
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 );
115 QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
116 myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
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 );
125 myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
126 QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
127 myComponentLab->setAlignment( AlignCenter );
129 myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
130 myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
133 QVBoxLayout* infoLayout = new QVBoxLayout();
134 infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
137 QFrame* myLine1 = new QFrame( this, "myLine1" );
138 myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
140 myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
141 myInfoLabel->setAlignment( AlignCenter );
143 QFrame* myLine2 = new QFrame( this, "myLine2" );
144 myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
146 infoLayout->addStretch();
147 infoLayout->addWidget( myLine1 );
148 infoLayout->addWidget( myInfoLabel );
149 infoLayout->addWidget( myLine2 );
150 infoLayout->addStretch();
153 QHBoxLayout* btnLayout = new QHBoxLayout();
154 btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
157 myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
158 myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
160 myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
161 myOpenBtn->setAutoDefault( true );
163 myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
164 myLoadBtn->setAutoDefault( true );
166 myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
167 myCancelBtn->setAutoDefault( true );
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 );
177 ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
178 ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
179 ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
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() ) );
188 //==============================================================================================================================
190 * SalomeApp_ModuleDlg::onButtonClicked
194 //==============================================================================================================================
195 void SalomeApp_ModuleDlg::onButtonClicked()
197 QPushButton* btn = ( QPushButton* )sender();
198 if ( btn == myNewBtn )
200 if ( btn == myOpenBtn )
202 if ( btn == myLoadBtn )