Salome HOME
premiere version
[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 HELLO_ORB::HELLO_Gen_ptr HELLOGUI::InitHELLOGen(QAD_Desktop* parent)
25 {
26     Engines::Component_var comp =
27         parent->getEngine("FactoryServer", "HELLO");
28     HELLO_ORB::HELLO_Gen_ptr clr = HELLO_ORB::HELLO_Gen::_narrow(comp);
29     ASSERT(!CORBA::is_nil(clr));
30     return clr;
31     //return clr._retn();
32 }
33
34
35 bool HELLOGUI::OnGUIEvent (int theCommandID, QAD_Desktop* parent)
36 {
37   MESSAGE("HELLOGUI::OnGUIEvent");
38   
39   QAD_Study* myActiveStudy   = parent->getActiveStudy();
40
41   QString file;
42
43   switch (theCommandID)
44     {
45     case 941:
46       {
47         MESSAGE("command " << theCommandID << " activated");
48
49         QString myStudyName = myActiveStudy->getTitle();
50         int myStudyId = myActiveStudy->getStudyId();
51         
52         bool ok=FALSE;
53
54         QString meshName;
55         //meshName = QInputDialog::getText( "Saisie du PrĂ©nom", "Please, Enter your name", 
56         meshName = QInputDialog::getText( tr("QUE_HELLO_LABEL"), tr("QUE_HELLO_NAME"), 
57                 QLineEdit::Normal,
58                 QString::null, &ok);
59
60         if ( ! meshName.isEmpty())
61         {
62             HELLO_ORB::HELLO_Gen_ptr hellogen = HELLOGUI::InitHELLOGen(parent);
63             QString banner = hellogen->makeBanner(meshName);
64             QMessageBox::about( parent, tr("INF_HELLO_BANNER"), banner);
65
66         //    QAD_MessageBox::warn1 ((QWidget*)QAD_Application::getDesktop(),
67         //          Object::tr("WRN_WARNING"), 
68         //          QObject::tr("WRN_STUDY_LOCKED"),
69         //          QObject::tr("BUT_OK"));
70         }
71         else
72         {
73             MESSAGE("CANCEL");
74         }
75
76       }
77       break;
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 }