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>
21 static const char* const default_icon[] = {
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 "................................................"};
89 //==============================================================================================================================
91 * SalomeApp_ModuleDlg::SalomeApp_ModuleDlg \n
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 )
99 QPixmap defaultIcon( ( const char** ) default_icon );
100 setCaption( tr( "CAPTION" ) );
101 setSizeGripEnabled( TRUE );
103 QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
104 ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
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 );
112 QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
113 myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
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 );
122 myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
123 QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
124 myComponentLab->setAlignment( AlignCenter );
126 myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
127 myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
130 QVBoxLayout* infoLayout = new QVBoxLayout();
131 infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
134 QFrame* myLine1 = new QFrame( this, "myLine1" );
135 myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
137 myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
138 myInfoLabel->setAlignment( AlignCenter );
140 QFrame* myLine2 = new QFrame( this, "myLine2" );
141 myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
143 infoLayout->addStretch();
144 infoLayout->addWidget( myLine1 );
145 infoLayout->addWidget( myInfoLabel );
146 infoLayout->addWidget( myLine2 );
147 infoLayout->addStretch();
150 QHBoxLayout* btnLayout = new QHBoxLayout();
151 btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
154 myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
155 myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
157 myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
158 myOpenBtn->setAutoDefault( true );
160 myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
161 myLoadBtn->setAutoDefault( true );
163 myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
164 myCancelBtn->setAutoDefault( true );
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 );
174 ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
175 ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
176 ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
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() ) );
185 //==============================================================================================================================
187 * SalomeApp_ModuleDlg::onButtonClicked
191 //==============================================================================================================================
192 void SalomeApp_ModuleDlg::onButtonClicked()
194 QPushButton* btn = ( QPushButton* )sender();
195 if ( btn == myNewBtn )
197 if ( btn == myOpenBtn )
199 if ( btn == myLoadBtn )