1 // Copyright (C) 2005 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
21 #include <SUIT_MessageBox.h>
22 #include <SUIT_ResourceMgr.h>
23 #include <SalomeApp_Application.h>
25 #include <SALOME_LifeCycleCORBA.hxx>
28 #include <qinputdialog.h>
33 HELLOGUI::HELLOGUI() :
34 SalomeApp_Module( "HELLO" ) // default name
38 // Gets an reference to the module's engine
39 HELLO_ORB::HELLO_Gen_ptr HELLOGUI::InitHELLOGen( SalomeApp_Application* app )
41 Engines::Component_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","HELLO" );
42 HELLO_ORB::HELLO_Gen_ptr clr = HELLO_ORB::HELLO_Gen::_narrow(comp);
43 ASSERT(!CORBA::is_nil(clr));
47 // Module's initialization
48 void HELLOGUI::initialize( CAM_Application* app )
51 SalomeApp_Module::initialize( app );
53 InitHELLOGen( dynamic_cast<SalomeApp_Application*>( app ) );
55 QWidget* aParent = app->desktop();
56 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
59 createAction( 190, tr( "TLT_MY_NEW_ITEM" ), QIconSet(), tr( "MEN_MY_NEW_ITEM" ), tr( "STS_MY_NEW_ITEM" ), 0, aParent, false,
60 this, SLOT( OnMyNewItem() ) );
61 QPixmap aPixmap = aResourceMgr->loadPixmap( "HELLO",tr( "ICON_GET_BANNER" ) );
62 createAction( 901, tr( "TLT_GET_BANNER" ), QIconSet( aPixmap ), tr( "MEN_GET_BANNER" ), tr( "STS_GET_BANNER" ), 0, aParent, false,
63 this, SLOT( OnGetBanner() ) );
67 aMenuId = createMenu( tr( "MEN_FILE" ), -1, -1 );
68 createMenu( separator(), aMenuId, -1, 10 );
69 aMenuId = createMenu( tr( "MEN_FILE_HELLO" ), aMenuId, -1, 10 );
70 createMenu( 190, aMenuId );
72 aMenuId = createMenu( tr( "MEN_HELLO" ), -1, -1, 30 );
73 createMenu( 901, aMenuId, 10 );
76 int aToolId = createTool ( tr( "TOOL_HELLO" ) );
77 createTool( 901, aToolId );
80 // Module's engine IOR
81 QString HELLOGUI::engineIOR() const
83 CORBA::String_var anIOR = getApp()->orb()->object_to_string( InitHELLOGen( getApp() ) );
84 return QString( anIOR.in() );
87 // Module's activation
88 bool HELLOGUI::activateModule( SUIT_Study* theStudy )
90 bool bOk = SalomeApp_Module::activateModule( theStudy );
98 // Module's deactivation
99 bool HELLOGUI::deactivateModule( SUIT_Study* theStudy )
101 setMenuShown( false );
102 setToolShown( false );
104 return SalomeApp_Module::deactivateModule( theStudy );
108 void HELLOGUI::windows( QMap<int, int>& theMap ) const
111 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
112 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
116 void HELLOGUI::OnMyNewItem()
118 SUIT_MessageBox::warn1( getApp()->desktop(),tr( "INF_HELLO_BANNER" ), tr( "INF_HELLO_MENU" ), tr( "BUT_OK" ) );
122 void HELLOGUI::OnGetBanner()
124 // Dialog to get the Name
126 QString myName = QInputDialog::getText( tr( "QUE_HELLO_LABEL" ), tr( "QUE_HELLO_NAME" ),
127 QLineEdit::Normal, QString::null, &ok );
129 if ( ok && !myName.isEmpty()) // if we got a name, get a HELLO component and ask for makeBanner
131 HELLO_ORB::HELLO_Gen_ptr hellogen = HELLOGUI::InitHELLOGen( getApp() );
132 QString banner = hellogen->makeBanner( myName );
133 SUIT_MessageBox::info1( getApp()->desktop(), tr( "INF_HELLO_BANNER" ), banner, tr( "BUT_OK" ) );
139 CAM_Module* createModule()
141 return new HELLOGUI();