Salome HOME
multi-linguisme
[samples/hello.git] / src / HELLOGUI / HELLOGUI.cxx
1 using namespace std;
2 #include "HELLOGUI.h"
3
4 // SALOME Includes
5 #include "Utils_ORB_INIT.hxx"
6 #include "Utils_SINGLETON.hxx"
7 #include "utilities.h"
8
9 #include "SALOME_Selection.h"
10 #include "SALOME_InteractiveObject.hxx"
11 #include "SALOMEGUI_QtCatchCorbaException.hxx"
12
13 #include "QAD_MessageBox.h"
14 //#include "QAD_Tools.h"
15 //#include "QAD_FileDlg.h"
16
17 //#include "SMESH_TypeFilter.hxx"
18
19 // QT Includes
20 #include <qinputdialog.h>
21 #include <qmessagebox.h>
22
23
24 // launch HELLO component and return a handle
25 HELLO_ORB::HELLO_Gen_ptr HELLOGUI::InitHELLOGen(QAD_Desktop* parent)
26 {
27     Engines::Component_var comp =
28         parent->getEngine("FactoryServer", "HELLO");
29     HELLO_ORB::HELLO_Gen_ptr clr = HELLO_ORB::HELLO_Gen::_narrow(comp);
30     ASSERT(!CORBA::is_nil(clr));
31     return clr;
32     //return clr._retn();
33 }
34
35
36 bool HELLOGUI::OnGUIEvent (int theCommandID, QAD_Desktop* parent)
37 {
38   MESSAGE("HELLOGUI::OnGUIEvent");
39   
40   QAD_Study* myActiveStudy   = parent->getActiveStudy();
41
42   QString file;
43
44   switch (theCommandID)
45     {
46     case 901: // call getBanner service
47       {
48         MESSAGE("command " << theCommandID << " activated");
49
50         QString myStudyName = myActiveStudy->getTitle();
51         int myStudyId = myActiveStudy->getStudyId();
52         
53         bool ok=FALSE;
54
55         // Dialog to get the Name
56         QString myName;
57         myName = QInputDialog::getText( tr("QUE_HELLO_LABEL"), tr("QUE_HELLO_NAME"), 
58                 QLineEdit::Normal,
59                 QString::null, &ok);
60
61         if ( ! myName.isEmpty()) // if we got a name, get a HELLO component and ask for makeBanner
62         {
63             HELLO_ORB::HELLO_Gen_ptr hellogen = HELLOGUI::InitHELLOGen(parent);
64             QString banner = hellogen->makeBanner(myName);
65             QAD_MessageBox::info1( parent, tr("INF_HELLO_BANNER"), banner, tr("BUT_OK"));
66         }
67         else
68         {
69             MESSAGE("CANCEL");
70         }
71
72       }
73       break;
74     case 190: // just a test in File Menu
75       {
76             QAD_MessageBox::warn1 (parent,tr("INF_HELLO_BANNER"),tr("INF_HELLO_MENU"),tr("BUT_OK"));
77       }
78     }
79   return true;
80 }
81
82
83 bool HELLOGUI::SetSettings (QAD_Desktop* parent)
84 {
85   MESSAGE("HELLOGUI::SetSettings");
86   return true;
87 }
88
89
90 bool HELLOGUI::CustomPopup ( QAD_Desktop* parent,
91                            QPopupMenu* popup,
92                            const QString & theContext,
93                            const QString & theParent,
94                            const QString & theObject )
95 {
96   MESSAGE("HELLOGUI::CustomPopup");
97   return true;
98 }
99
100 void HELLOGUI::ActiveStudyChanged( QAD_Desktop* parent )
101 {
102   MESSAGE("HELLOGUI::ActiveStudyChanged");
103 }
104
105 void HELLOGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
106 {
107   MESSAGE("HELLOGUI::DefinePopup");
108   //theObject = "";
109   //theContext = "";
110 }
111
112
113
114
115 extern "C"
116 {
117   bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
118   {
119     return HELLOGUI::OnGUIEvent(theCommandID, parent);
120   }
121
122
123   bool SetSettings ( QAD_Desktop* parent )
124   {
125     return HELLOGUI::SetSettings( parent );
126   }
127
128   bool customPopup ( QAD_Desktop* parent,
129                      QPopupMenu* popup,
130                      const QString & theContext,
131                      const QString & theParent,
132                      const QString & theObject )
133   {
134     return HELLOGUI::CustomPopup( parent, popup, theContext,
135                                 theParent, theObject );
136   }
137
138   void definePopup ( QString & theContext, QString & theParent, QString & theObject )
139   {
140     HELLOGUI::DefinePopup( theContext, theParent, theObject );
141   }
142   
143   bool activeStudyChanged ( QAD_Desktop* parent )
144   {
145     HELLOGUI::ActiveStudyChanged( parent );
146   }
147 }