1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : SALOMEGUI_ActivateComponentDlg.cxx
8 // Author : Michael Zorin (mzn)
11 #include "SALOMEGUI_ActivateComponentDlg.h"
15 #include <qpushbutton.h>
20 static const char* const default_icon[] = {
39 "................................................",
40 "................................................",
41 "................................................",
42 "................................................",
43 "................................................",
44 "................########.########.########......",
45 "...............#aaaaaa###aaaaaa###aaaaaa##......",
46 "..............#aaaaaa#b#aaaaaa#b#aaaaaa#c#......",
47 ".............########b########b########cc#......",
48 ".............#dddddd#b#dddddd#b#dddddd#cc#......",
49 "...........########d########d########d#cc#......",
50 "..........#aaaaaa###aaaaaa###aaaaaa##d#cc#......",
51 ".........#aaaaaa#b#aaaaaa#b#aaaaaa#c#d#cc#......",
52 "........########b########e########cc#d#c#.......",
53 "........#dddddd#b#dddddd#e#ffffff#cc#d####......",
54 "......########d########d########f#cc###g##......",
55 ".....#aaaaaa###aaaaaa###hhhhhh##f#cc#gg#c#......",
56 "....#aaaaaa#b#aaaaaa#i#hhhhhh#j#f#cc###cc#......",
57 "...########b########i########jj#f#c#gg#cc#......",
58 "...#kkkkkk#b#kkkkkk#i#llllll#jj#f####g#cc#......",
59 "...#kkkkkk#b#kkkkkk#i#llllll#jj###m##g#cc#......",
60 "...#knnkkk#b#kkkkkk#i#llllll#jj#mm#c#g#cc#......",
61 "...#knnkkk#b#kkkkkk#i#llllll#jj###cc#g#c#.......",
62 "...#kkkkkk#b#kkkkkk#i#llllll#j#dd#cc#g####......",
63 "...#kkkkkk###kkkkkk###llllll####d#cc###g##......",
64 "...########g########g########o##d#cc#gg#c#......",
65 "....#gggggg#b#gggggg#b#oooooo#c#d#cc###cc#......",
66 "...########b########b########cc#d#c#gg#cc#......",
67 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#d####g#cc#......",
68 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###g##g#cc#......",
69 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#gg#c#g#cc#......",
70 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###cc#g#c#.......",
71 "...#kkkkkk#b#kkkkkk#b#kkkkkk#c#gg#cc#g##........",
72 "...#kkkkkk###kkkkkk###kkkkkk####g#cc###.........",
73 "...########g########g########g##g#cc#...........",
74 "....#gggggg#b#gggggg#b#gggggg#c#g#cc#...........",
75 "...########b########b########cc#g#c#............",
76 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#g##.............",
77 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc###..............",
78 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
79 "...#kkkkkk#b#kkkkkk#b#kkkkkk#cc#................",
80 "...#kkkkkk#b#kkkkkk#b#kkkkkk#c#.................",
81 "...#kkkkkk###kkkkkk###kkkkkk##..................",
82 "...########.########.########...................",
83 "................................................",
84 "................................................",
85 "................................................",
86 "................................................"};
88 //==============================================================================================================================
90 * SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg
94 //==============================================================================================================================
95 SALOMEGUI_ActivateComponentDlg::SALOMEGUI_ActivateComponentDlg ( QWidget * parent, const QString& component, const QPixmap icon )
96 : QDialog ( parent, "ActivateModuleDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
98 QPixmap defaultIcon( ( const char** ) default_icon );
99 setCaption( tr( "CAPTION" ) );
100 setSizeGripEnabled( TRUE );
102 QGridLayout* ActivateModuleDlgLayout = new QGridLayout( this );
103 ActivateModuleDlgLayout->setMargin( 11 ); ActivateModuleDlgLayout->setSpacing( 6 );
105 // Module's name and icon
106 myComponentFrame = new QFrame( this, "myComponentFrame" );
107 myComponentFrame->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ) );
108 myComponentFrame->setMinimumHeight( 100 );
109 myComponentFrame->setFrameStyle( QFrame::Box | QFrame::Sunken );
111 QGridLayout* myComponentFrameLayout = new QGridLayout( myComponentFrame );
112 myComponentFrameLayout->setMargin( 11 ); myComponentFrameLayout->setSpacing( 6 );
115 myComponentIcon = new QLabel( myComponentFrame, "myComponentIcon" );
116 myComponentIcon->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) );
117 myComponentIcon->setPixmap( !icon.isNull() ? icon : defaultIcon );
118 myComponentIcon->setScaledContents( false );
119 myComponentIcon->setAlignment( AlignCenter );
121 myComponentLab = new QLabel( component, myComponentFrame, "myComponentLab" );
122 QFont fnt = myComponentLab->font(); fnt.setBold( TRUE ); myComponentLab->setFont( fnt );
123 myComponentLab->setAlignment( AlignCenter );
125 myComponentFrameLayout->addWidget( myComponentIcon, 0, 0 );
126 myComponentFrameLayout->addWidget( myComponentLab, 0, 1 );
129 QVBoxLayout* infoLayout = new QVBoxLayout();
130 infoLayout->setMargin( 0 ); infoLayout->setSpacing( 6 );
133 QFrame* myLine1 = new QFrame( this, "myLine1" );
134 myLine1->setFrameStyle( QFrame::HLine | QFrame::Plain );
136 myInfoLabel = new QLabel( tr ("ActivateComponent_DESCRIPTION"), this, "myInfoLabel" );
137 myInfoLabel->setAlignment( AlignCenter );
139 QFrame* myLine2 = new QFrame( this, "myLine2" );
140 myLine2->setFrameStyle( QFrame::HLine | QFrame::Plain );
142 infoLayout->addStretch();
143 infoLayout->addWidget( myLine1 );
144 infoLayout->addWidget( myInfoLabel );
145 infoLayout->addWidget( myLine2 );
146 infoLayout->addStretch();
149 QHBoxLayout* btnLayout = new QHBoxLayout();
150 btnLayout->setMargin( 0 ); btnLayout->setSpacing( 6 );
153 myNewBtn = new QPushButton( tr( "NEW" ), this, "myNewBtn" );
154 myNewBtn->setDefault( true ); myNewBtn->setAutoDefault( true );
156 myOpenBtn = new QPushButton( tr( "OPEN" ), this, "myOpenBtn" );
157 myOpenBtn->setAutoDefault( true );
159 myLoadBtn = new QPushButton( tr( "LOAD" ), this, "myLoadBtn" );
160 myLoadBtn->setAutoDefault( true );
162 myCancelBtn = new QPushButton( tr( "CANCEL" ), this, "myCancelBtn" );
163 myCancelBtn->setAutoDefault( true );
165 btnLayout->addWidget( myNewBtn );
166 btnLayout->addWidget( myOpenBtn );
167 btnLayout->addWidget( myLoadBtn );
168 btnLayout->addStretch();
169 btnLayout->addSpacing( 70 );
170 btnLayout->addStretch();
171 btnLayout->addWidget( myCancelBtn );
173 ActivateModuleDlgLayout->addWidget( myComponentFrame, 0, 0 );
174 ActivateModuleDlgLayout->addLayout( infoLayout, 0, 1 );
175 ActivateModuleDlgLayout->addMultiCellLayout( btnLayout, 1, 1, 0, 1 );
177 // signals and slots connections
178 connect( myNewBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
179 connect( myOpenBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
180 connect( myLoadBtn, SIGNAL( clicked() ), this, SLOT( onButtonClicked() ) );
181 connect( myCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) );
184 //==============================================================================================================================
186 * SALOMEGUI_ActivateComponentDlg::onButtonClicked
190 //==============================================================================================================================
191 void SALOMEGUI_ActivateComponentDlg::onButtonClicked()
193 QPushButton* btn = ( QPushButton* )sender();
194 if ( btn == myNewBtn )
196 if ( btn == myOpenBtn )
198 if ( btn == myLoadBtn )