1 | // TODO ! |
---|
2 | |
---|
3 | // |
---|
4 | // ******************************************************************** |
---|
5 | // * License and Disclaimer * |
---|
6 | // * * |
---|
7 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
8 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
9 | // * conditions of the Geant4 Software License, included in the file * |
---|
10 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
11 | // * include a list of copyright holders. * |
---|
12 | // * * |
---|
13 | // * Neither the authors of this software system, nor their employing * |
---|
14 | // * institutes,nor the agencies providing financial support for this * |
---|
15 | // * work make any representation or warranty, express or implied, * |
---|
16 | // * regarding this software system or assume any liability for its * |
---|
17 | // * use. Please see the license in the file LICENSE and URL above * |
---|
18 | // * for the full disclaimer and the limitation of liability. * |
---|
19 | // * * |
---|
20 | // * This code implementation is the result of the scientific and * |
---|
21 | // * technical work of the GEANT4 collaboration. * |
---|
22 | // * By using, copying, modifying or distributing the software (or * |
---|
23 | // * any work based on the software) you agree to acknowledge its * |
---|
24 | // * use in resulting scientific publications, and indicate your * |
---|
25 | // * acceptance of all terms of the Geant4 Software license. * |
---|
26 | // ******************************************************************** |
---|
27 | // |
---|
28 | // |
---|
29 | // $Id: G4UIQt.cc,v 1.14 2007/05/29 11:09:49 $ |
---|
30 | // GEANT4 tag $Name: geant4-08-01 $ |
---|
31 | // |
---|
32 | // L. Garnier |
---|
33 | |
---|
34 | //#define DEBUG |
---|
35 | |
---|
36 | #ifdef G4UI_BUILD_QT_SESSION |
---|
37 | |
---|
38 | #include "G4Types.hh" |
---|
39 | |
---|
40 | #include <string.h> |
---|
41 | |
---|
42 | #include "G4UIQt.hh" |
---|
43 | #include "G4UImanager.hh" |
---|
44 | #include "G4StateManager.hh" |
---|
45 | #include "G4UIcommandTree.hh" |
---|
46 | #include "G4UIcommandStatus.hh" |
---|
47 | |
---|
48 | #include "G4Qt.hh" |
---|
49 | |
---|
50 | #include <QtGui/qapplication.h> |
---|
51 | #include <QtGui/qwidget.h> |
---|
52 | #include <QtGui/qmenu.h> |
---|
53 | #include <QtGui/qmenubar.h> |
---|
54 | #include <QtGui/qboxlayout.h> |
---|
55 | #include <QtGui/qpushbutton.h> |
---|
56 | #include <QtGui/qlabel.h> |
---|
57 | #include <QtGui/qsplitter.h> |
---|
58 | #include <QtGui/qscrollbar.h> |
---|
59 | |
---|
60 | #include <stdlib.h> |
---|
61 | |
---|
62 | static G4bool ConvertStringToInt(const char*,int&); |
---|
63 | //static void ExecuteChangeSizeFunction(Widget); |
---|
64 | |
---|
65 | static G4bool exitSession = true; |
---|
66 | static G4bool exitPause = true; |
---|
67 | static G4bool exitHelp = true; |
---|
68 | /***************************************************************************/ |
---|
69 | /** |
---|
70 | Build a Qt window with a menubar, output area and promt area |
---|
71 | +-----------------------+ |
---|
72 | |exit menu| | |
---|
73 | | | |
---|
74 | | +-------------------+ | |
---|
75 | | | | | |
---|
76 | | | Output area | | |
---|
77 | | | | | |
---|
78 | | +-------------------+ | |
---|
79 | | | clear | | |
---|
80 | | +-------------------+ | |
---|
81 | | | promt history | | |
---|
82 | | +-------------------+ | |
---|
83 | | +-------------------+ | |
---|
84 | | |> promt area | | |
---|
85 | | +-------------------+ | |
---|
86 | +-----------------------+ |
---|
87 | */ |
---|
88 | |
---|
89 | G4UIQt::G4UIQt ( |
---|
90 | int argc, |
---|
91 | char** argv |
---|
92 | ) |
---|
93 | /***************************************************************************/ |
---|
94 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
95 | { |
---|
96 | G4Qt* interactorManager = G4Qt::getInstance (); |
---|
97 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP |
---|
98 | if(UI!=NULL) UI->SetSession(this); // TO KEEP |
---|
99 | |
---|
100 | fMainWindow = new QMainWindow(); |
---|
101 | fMainWindow->setWindowTitle( "G4UI Session" ); |
---|
102 | fMainWindow->resize(800,600); |
---|
103 | |
---|
104 | QSplitter *splitter = new QSplitter(Qt::Vertical); |
---|
105 | fTextArea = new QTextEdit(); |
---|
106 | QPushButton *clearButton = new QPushButton("clear"); |
---|
107 | connect(clearButton, SIGNAL(clicked()), SLOT(clearButtonCallback())); |
---|
108 | |
---|
109 | fCommandHistoryArea = new QTextEdit(); |
---|
110 | fCommandLabel = new QLabel(); |
---|
111 | |
---|
112 | fCommandArea = new QLineEdit(); |
---|
113 | fCommandArea->activateWindow(); |
---|
114 | connect(fCommandArea, SIGNAL(returnPressed()), SLOT(commandEnteredCallback())); |
---|
115 | fCommandArea->setFocusPolicy ( Qt::StrongFocus ); |
---|
116 | fCommandArea->setFocus(Qt::TabFocusReason); |
---|
117 | fTextArea->setReadOnly(true); |
---|
118 | fCommandHistoryArea->setReadOnly(true); |
---|
119 | |
---|
120 | |
---|
121 | QVBoxLayout *layoutSplitter = new QVBoxLayout; |
---|
122 | |
---|
123 | QWidget* topWidget = new QWidget(); |
---|
124 | QVBoxLayout *layoutTop = new QVBoxLayout; |
---|
125 | |
---|
126 | QWidget* bottomWidget = new QWidget(); |
---|
127 | QVBoxLayout *layoutBottom = new QVBoxLayout; |
---|
128 | |
---|
129 | |
---|
130 | layoutTop->addWidget(fTextArea); |
---|
131 | layoutTop->addWidget(clearButton); |
---|
132 | topWidget->setLayout(layoutTop); |
---|
133 | |
---|
134 | layoutBottom->addWidget(fCommandHistoryArea); |
---|
135 | layoutBottom->addWidget(fCommandLabel); |
---|
136 | layoutBottom->addWidget(fCommandArea); |
---|
137 | bottomWidget->setLayout(layoutBottom); |
---|
138 | |
---|
139 | |
---|
140 | layoutSplitter->addWidget(topWidget); |
---|
141 | layoutSplitter->addWidget(bottomWidget); |
---|
142 | splitter->setLayout(layoutSplitter); |
---|
143 | |
---|
144 | fMainWindow->setCentralWidget(splitter); |
---|
145 | |
---|
146 | |
---|
147 | // QMenu *menuFile = new QMenu("File"); |
---|
148 | // fMainWindow->menuBar()->addMenu(menuFile); |
---|
149 | |
---|
150 | |
---|
151 | |
---|
152 | // QMainWindow top = (QMainWindow)interactorManager->GetMainInteractor(); |
---|
153 | |
---|
154 | // if(getenv("XENVIRONMENT")==NULL) { |
---|
155 | // XrmDatabase database = XrmGetDatabase(XtDisplay(top)); |
---|
156 | // if(database!=NULL) { |
---|
157 | // XrmPutLineResource(&database,"*topShadowColor:white"); |
---|
158 | // XrmPutLineResource(&database,"*bottomShadowColor:black"); |
---|
159 | // XrmPutLineResource(&database,"*foreground:black"); |
---|
160 | // XrmPutLineResource(&database,"*background:lightgrey"); |
---|
161 | // XrmPutLineResource(&database,"*borderColor:lightgrey"); |
---|
162 | // XrmPutLineResource(&database,"*fontList:-*-helvetica-bold-r-*-*-*-120-*-*-*-*-iso8859-1"); |
---|
163 | // XrmPutLineResource(&database,"*text.background:white"); |
---|
164 | // XrmPutLineResource(&database,"*text.fontList:*courier*-r-*--14-*"); |
---|
165 | // XrmPutLineResource(&database,"*text.maxLength:8000"); |
---|
166 | // } |
---|
167 | // } |
---|
168 | |
---|
169 | // Arg args[9]; |
---|
170 | // XtSetArg(args[0],XmNkeyboardFocusPolicy,XmPOINTER); // For completion. |
---|
171 | // shell = XtAppCreateShell ("G4UIXm","G4UIXm", |
---|
172 | // topLevelShellWidgetClass,XtDisplay(top), |
---|
173 | // args,1); |
---|
174 | // form = XmCreateForm (shell,(char*)"form",NULL,0); |
---|
175 | // XtManageChild (form); |
---|
176 | |
---|
177 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_FORM); |
---|
178 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
179 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
180 | // menuBar = XmCreateMenuBar (form,(char*)"menuBar",args,3); |
---|
181 | |
---|
182 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE); |
---|
183 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
184 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
185 | // XtSetArg(args[3],XmNbottomAttachment ,XmATTACH_FORM); |
---|
186 | // command = XmCreateCommand (form,(char*)"command",args,4); |
---|
187 | // XtManageChild (command); |
---|
188 | |
---|
189 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_NONE); |
---|
190 | // XtSetArg(args[1],XmNleftAttachment ,XmATTACH_FORM); |
---|
191 | // XtSetArg(args[2],XmNrightAttachment ,XmATTACH_FORM); |
---|
192 | // XtSetArg(args[3],XmNbottomAttachment,XmATTACH_WIDGET); |
---|
193 | // XtSetArg(args[4],XmNbottomWidget ,command); |
---|
194 | // XmString cps = XmStringLtoRCreate((char*)"Clear",XmSTRING_DEFAULT_CHARSET); |
---|
195 | // XtSetArg (args[5],XmNlabelString,cps); |
---|
196 | // Widget clearButton = XmCreatePushButton(form,(char*)"clearButton",args,6); |
---|
197 | // XmStringFree (cps); |
---|
198 | // XtManageChild (clearButton); |
---|
199 | |
---|
200 | // XtSetArg(args[0],XmNtopAttachment ,XmATTACH_WIDGET); |
---|
201 | // XtSetArg(args[1],XmNtopWidget ,menuBar); |
---|
202 | // XtSetArg(args[2],XmNleftAttachment ,XmATTACH_FORM); |
---|
203 | // XtSetArg(args[3],XmNrightAttachment ,XmATTACH_FORM); |
---|
204 | // XtSetArg(args[4],XmNbottomAttachment,XmATTACH_WIDGET); |
---|
205 | // XtSetArg(args[5],XmNbottomWidget ,clearButton); |
---|
206 | // XtSetArg(args[6],XmNeditMode ,XmMULTI_LINE_EDIT); |
---|
207 | // XtSetArg(args[7],XmNrows ,12); |
---|
208 | // XtSetArg(args[8],XmNcolumns ,80); |
---|
209 | // text = XmCreateSGcrolledText (form,(char*)"text",args,9); |
---|
210 | // XtManageChild (text); |
---|
211 | |
---|
212 | // XtAddCallback(clearButton,XmNactivateCallback, |
---|
213 | // clearButtonCallback,(XtPointer)text); |
---|
214 | // XtAddCallback(command,XmNcommandEnteredCallback, |
---|
215 | // commandEnteredCallback,(XtPointer)this); |
---|
216 | |
---|
217 | // Widget commandText = XmCommandGetChild(command,XmDIALOG_COMMAND_TEXT); |
---|
218 | // XtAddEventHandler(commandText,KeyPressMask,False,keyHandler,(XtPointer)this); |
---|
219 | |
---|
220 | // XtRealizeWidget(shell); |
---|
221 | // XtMapWidget(shell); |
---|
222 | |
---|
223 | if(UI!=NULL) UI->SetCoutDestination(this); // TO KEEP |
---|
224 | } |
---|
225 | /***************************************************************************/ |
---|
226 | G4UIQt::~G4UIQt( |
---|
227 | ) |
---|
228 | /***************************************************************************/ |
---|
229 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
230 | { |
---|
231 | G4UImanager* UI = G4UImanager::GetUIpointer(); // TO KEEP |
---|
232 | if(UI!=NULL) { // TO KEEP |
---|
233 | UI->SetSession(NULL); // TO KEEP |
---|
234 | UI->SetCoutDestination(NULL); // TO KEEP |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | if (fMainWindow!=NULL) |
---|
239 | delete fMainWindow; |
---|
240 | } |
---|
241 | /***************************************************************************/ |
---|
242 | /* |
---|
243 | Start the Qt main loop |
---|
244 | */ |
---|
245 | G4UIsession* G4UIQt::SessionStart ( |
---|
246 | ) |
---|
247 | /***************************************************************************/ |
---|
248 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
249 | { |
---|
250 | |
---|
251 | G4Qt* interactorManager = G4Qt::getInstance (); |
---|
252 | fMainWindow->show(); |
---|
253 | Prompt("session"); |
---|
254 | exitSession = false; |
---|
255 | |
---|
256 | |
---|
257 | printf("disable secondary loop\n"); |
---|
258 | interactorManager->DisableSecondaryLoop (); // TO KEEP |
---|
259 | ((QApplication*)interactorManager->GetMainInteractor())->exec(); |
---|
260 | // on ne passe pas le dessous ? FIXME ???? |
---|
261 | |
---|
262 | |
---|
263 | |
---|
264 | |
---|
265 | |
---|
266 | |
---|
267 | // void* event; // TO KEEP |
---|
268 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
269 | // interactorManager->DispatchEvent(event); // TO KEEP |
---|
270 | // if(exitSession==true) break; // TO KEEP |
---|
271 | // } // TO KEEP |
---|
272 | interactorManager->EnableSecondaryLoop (); // TO KEEP |
---|
273 | printf("enable secondary loop\n"); |
---|
274 | return this; // TO KEEP |
---|
275 | } |
---|
276 | /***************************************************************************/ |
---|
277 | |
---|
278 | /** |
---|
279 | Display the prompt in the prompt area |
---|
280 | */ |
---|
281 | void G4UIQt::Prompt ( |
---|
282 | G4String aPrompt |
---|
283 | ) |
---|
284 | /***************************************************************************/ |
---|
285 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
286 | { |
---|
287 | fCommandLabel->setText((char*)aPrompt.data()); |
---|
288 | } |
---|
289 | /***************************************************************************/ |
---|
290 | void G4UIQt::SessionTerminate ( |
---|
291 | ) |
---|
292 | /***************************************************************************/ |
---|
293 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
294 | { |
---|
295 | } |
---|
296 | /***************************************************************************/ |
---|
297 | void G4UIQt::PauseSessionStart ( |
---|
298 | G4String a_state |
---|
299 | ) |
---|
300 | /***************************************************************************/ |
---|
301 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
302 | { |
---|
303 | if(a_state=="G4_pause> ") { // TO KEEP |
---|
304 | SecondaryLoop ("Pause, type continue to exit this state"); // TO KEEP |
---|
305 | } // TO KEEP |
---|
306 | |
---|
307 | if(a_state=="EndOfEvent") { // TO KEEP |
---|
308 | // Picking with feed back in event data Done here !!! |
---|
309 | SecondaryLoop ("End of event, type continue to exit this state"); // TO KEEP |
---|
310 | } // TO KEEP |
---|
311 | } |
---|
312 | /***************************************************************************/ |
---|
313 | void G4UIQt::SecondaryLoop ( |
---|
314 | G4String a_prompt |
---|
315 | ) |
---|
316 | /***************************************************************************/ |
---|
317 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
318 | { |
---|
319 | G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? |
---|
320 | Prompt(a_prompt); // TO KEEP |
---|
321 | exitPause = false; // TO KEEP |
---|
322 | void* event; // TO KEEP |
---|
323 | while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
324 | interactorManager->DispatchEvent(event); // TO KEEP |
---|
325 | if(exitPause==true) break; // TO KEEP |
---|
326 | } // TO KEEP |
---|
327 | Prompt("session"); // TO KEEP |
---|
328 | } |
---|
329 | /***************************************************************************/ |
---|
330 | /** |
---|
331 | Receive a cout from Geant4. We have to display it in the cout zone |
---|
332 | */ |
---|
333 | G4int G4UIQt::ReceiveG4cout ( |
---|
334 | G4String a_string |
---|
335 | ) |
---|
336 | /***************************************************************************/ |
---|
337 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
338 | { |
---|
339 | fTextArea->append(QString((char*)a_string.data()).trimmed()); |
---|
340 | fTextArea->verticalScrollBar()->setSliderPosition(fTextArea->verticalScrollBar()->maximum()); |
---|
341 | return 0; |
---|
342 | } |
---|
343 | /***************************************************************************/ |
---|
344 | /** |
---|
345 | Receive a cerr from Geant4. We have to display it in the cout zone |
---|
346 | */ |
---|
347 | G4int G4UIQt::ReceiveG4cerr ( |
---|
348 | G4String a_string |
---|
349 | ) |
---|
350 | /***************************************************************************/ |
---|
351 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
352 | { |
---|
353 | QColor previousColor = fTextArea->textColor(); |
---|
354 | fTextArea->setTextColor(Qt::red); |
---|
355 | fTextArea->append(QString((char*)a_string.data()).trimmed()); |
---|
356 | fTextArea->setTextColor(previousColor); |
---|
357 | return 0; |
---|
358 | } |
---|
359 | /***************************************************************************/ |
---|
360 | G4bool G4UIQt::GetHelpChoice( |
---|
361 | G4int& aInt |
---|
362 | ) |
---|
363 | /***************************************************************************/ |
---|
364 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
365 | { |
---|
366 | // fHelp = true; // TO KEEP |
---|
367 | // // SecondaryLoop : // TO KEEP |
---|
368 | // G4Qt* interactorManager = G4Qt::getInstance (); // TO KEEP ? |
---|
369 | // Prompt("Help"); // TO KEEP |
---|
370 | // exitHelp = false; // TO KEEP |
---|
371 | // void* event; // TO KEEP |
---|
372 | // while((event = interactorManager->GetEvent())!=NULL) { // TO KEEP |
---|
373 | // interactorManager->DispatchEvent(event); // TO KEEP |
---|
374 | // if(exitHelp==true) break; // TO KEEP |
---|
375 | // } // TO KEEP |
---|
376 | // Prompt("session"); // TO KEEP |
---|
377 | // // // TO KEEP |
---|
378 | // if(fHelp==false) return false; // TO KEEP |
---|
379 | // aInt = fHelpChoice; // TO KEEP |
---|
380 | // fHelp = false; // TO KEEP |
---|
381 | // return true; // TO KEEP |
---|
382 | } |
---|
383 | /***************************************************************************/ |
---|
384 | void G4UIQt::ExitHelp( |
---|
385 | ) |
---|
386 | /***************************************************************************/ |
---|
387 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
388 | { |
---|
389 | } |
---|
390 | /***************************************************************************/ |
---|
391 | void G4UIQt::AddMenu ( |
---|
392 | const char* a_name |
---|
393 | ,const char* a_label |
---|
394 | ) |
---|
395 | /***************************************************************************/ |
---|
396 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
397 | { |
---|
398 | // if(menuBar==NULL) return; |
---|
399 | // if(a_name==NULL) return; |
---|
400 | // if(a_label==NULL) return; |
---|
401 | // XtManageChild (menuBar); |
---|
402 | // // Pulldown menu : |
---|
403 | // Widget widget; |
---|
404 | // widget = XmCreatePulldownMenu (menuBar,(char*)a_name,NULL,0); |
---|
405 | // AddInteractor (a_name,(G4Interactor)widget); |
---|
406 | // // Cascade button : |
---|
407 | // Arg args[2]; |
---|
408 | // XmString cps = XmStringLtoRCreate((char*)a_label,XmSTRING_DEFAULT_CHARSET); |
---|
409 | // XtSetArg (args[0],XmNlabelString,cps); |
---|
410 | // XtSetArg (args[1],XmNsubMenuId,widget); |
---|
411 | // widget = XmCreateCascadeButton (menuBar,(char*)a_name,args,2); |
---|
412 | // XmStringFree (cps); |
---|
413 | // XtManageChild (widget); |
---|
414 | // ExecuteChangeSizeFunction(form); |
---|
415 | } |
---|
416 | /***************************************************************************/ |
---|
417 | void G4UIQt::AddButton ( |
---|
418 | const char* a_menu |
---|
419 | ,const char* a_label |
---|
420 | ,const char* a_command |
---|
421 | ) |
---|
422 | /***************************************************************************/ |
---|
423 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
424 | { |
---|
425 | // if(a_menu==NULL) return; // TO KEEP |
---|
426 | // if(a_label==NULL) return; // TO KEEP |
---|
427 | // if(a_command==NULL) return; // TO KEEP |
---|
428 | // Widget parent = (Widget)GetInteractor(a_menu); |
---|
429 | // if(parent==NULL) return; |
---|
430 | // Widget widget = XmCreatePushButton(parent,(char*)a_label,NULL,0); |
---|
431 | // XtManageChild (widget); |
---|
432 | // XtAddCallback (widget,XmNactivateCallback,ButtonCallback,(XtPointer)this); |
---|
433 | // commands[widget] = a_command; |
---|
434 | } |
---|
435 | // /***************************************************************************/ |
---|
436 | // G4String G4UIXm::GetCommand ( |
---|
437 | // Widget a_widget |
---|
438 | // ) |
---|
439 | // /***************************************************************************/ |
---|
440 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
441 | // { |
---|
442 | // return commands[a_widget]; |
---|
443 | // } |
---|
444 | /***************************************************************************/ |
---|
445 | /***************************************************************************/ |
---|
446 | /***************************************************************************/ |
---|
447 | |
---|
448 | /** |
---|
449 | Callback call when "enter" clicked on the command zone. |
---|
450 | Send the command to geant4 |
---|
451 | */ |
---|
452 | // TODO ! |
---|
453 | void G4UIQt::commandEnteredCallback ( |
---|
454 | ) |
---|
455 | /***************************************************************************/ |
---|
456 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
457 | { |
---|
458 | G4String command (fCommandArea->text().toStdString().c_str()); |
---|
459 | if (fCommandArea->text().toStdString().c_str() != "") { |
---|
460 | fCommandHistoryArea->append(fCommandArea->text()); |
---|
461 | if(fHelp==true) { |
---|
462 | exitHelp = true; |
---|
463 | fHelp = ConvertStringToInt(command.data(),fHelpChoice); |
---|
464 | } else { |
---|
465 | ApplyShellCommand (command,exitSession,exitPause); |
---|
466 | } |
---|
467 | } |
---|
468 | fCommandArea->setText(""); |
---|
469 | } |
---|
470 | // /***************************************************************************/ |
---|
471 | // void G4UIXm::keyHandler ( |
---|
472 | // Widget a_widget |
---|
473 | // ,XtPointer a_tag |
---|
474 | // ,XEvent* a_event |
---|
475 | // ,Boolean* |
---|
476 | // ) |
---|
477 | // /***************************************************************************/ |
---|
478 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
479 | // { |
---|
480 | // KeySym keySym; |
---|
481 | // XLookupString(&(a_event->xkey),NULL,0,&keySym,NULL); |
---|
482 | // if(keySym!=XK_Tab) return; |
---|
483 | // G4UIXm* This = (G4UIXm*)a_tag; |
---|
484 | // char* s = XmTextGetString(a_widget); |
---|
485 | // G4String ss = This->Complete(s); |
---|
486 | // XmTextSetString(a_widget,(char*)ss.data()); |
---|
487 | // XtFree(s); |
---|
488 | // XmTextSetInsertionPosition(a_widget,XmTextGetLastPosition(a_widget)); |
---|
489 | //} |
---|
490 | |
---|
491 | /***************************************************************************/ |
---|
492 | void G4UIQt::clearButtonCallback ( |
---|
493 | ) |
---|
494 | /***************************************************************************/ |
---|
495 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
496 | { |
---|
497 | fTextArea->clear(); |
---|
498 | } |
---|
499 | |
---|
500 | /***************************************************************************/ |
---|
501 | // TODO ! |
---|
502 | //void G4UIQt::ButtonCallback ( |
---|
503 | // Widget a_widget |
---|
504 | //,XtPointer a_tag |
---|
505 | //,XtPointer |
---|
506 | //) |
---|
507 | /***************************************************************************/ |
---|
508 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
509 | //{ |
---|
510 | // G4UIXm* This = (G4UIXm*)a_tag; |
---|
511 | // if(This->fHelp==true) return; // Disabled when in help. |
---|
512 | // G4String ss = This->GetCommand (a_widget); |
---|
513 | // //printf ("debug : execute:\n%s\n",ss.data()); |
---|
514 | // This->ApplyShellCommand(ss,exitSession,exitPause); |
---|
515 | //} |
---|
516 | /***************************************************************************/ |
---|
517 | /***************************************************************************/ |
---|
518 | /***************************************************************************/ |
---|
519 | // char* XmConvertCompoundStringToString ( |
---|
520 | // XmString a_cps |
---|
521 | // ,int a_number |
---|
522 | // ) |
---|
523 | // /***************************************************************************/ |
---|
524 | // /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
525 | // { |
---|
526 | // if(a_cps==NULL) return NULL; |
---|
527 | // char* ss = NULL; |
---|
528 | // XmStringContext context; |
---|
529 | // XmStringInitContext(&context,a_cps); |
---|
530 | // int icount = 0; |
---|
531 | // Boolean Done = False; |
---|
532 | // while(Done==False) { |
---|
533 | // char* text = NULL; |
---|
534 | // XmStringCharSet charset = NULL; |
---|
535 | // XmStringDirection direct; |
---|
536 | // Boolean sep; |
---|
537 | // if(XmStringGetNextSegment(context,&text,&charset,&direct,&sep)==True) { |
---|
538 | // XtFree(charset); |
---|
539 | // if(sep==True) Done = True; |
---|
540 | // if(icount==a_number) { |
---|
541 | // ss = text; |
---|
542 | // break; |
---|
543 | // } |
---|
544 | // icount++; |
---|
545 | // XtFree(text); |
---|
546 | // } |
---|
547 | // else |
---|
548 | // Done = True; |
---|
549 | // } |
---|
550 | // XmStringFreeContext(context); |
---|
551 | // return ss; |
---|
552 | //} |
---|
553 | ////////////////////////////////////////////////////////////////////////////// |
---|
554 | G4bool ConvertStringToInt( |
---|
555 | const char* aString |
---|
556 | ,int& aInt |
---|
557 | ) |
---|
558 | ////////////////////////////////////////////////////////////////////////////// |
---|
559 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
560 | { |
---|
561 | aInt = 0; // TO KEEP |
---|
562 | if(aString==NULL) return false; // TO KEEP |
---|
563 | char* s; // TO KEEP |
---|
564 | long value = strtol(aString,&s,10); // TO KEEP |
---|
565 | if(s==aString) return false; // TO KEEP |
---|
566 | aInt = value; // TO KEEP |
---|
567 | return true; // TO KEEP |
---|
568 | } |
---|
569 | #include <X11/IntrinsicP.h> |
---|
570 | ////////////////////////////////////////////////////////////////////////////// |
---|
571 | // void ExecuteChangeSizeFunction ( |
---|
572 | // Widget aWidget |
---|
573 | // ) |
---|
574 | // ////////////////////////////////////////////////////////////////////////////// |
---|
575 | // //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
576 | // { |
---|
577 | // if(aWidget==NULL) return; |
---|
578 | // if(aWidget->core.widget_class->core_class.resize==NULL) return; |
---|
579 | // (aWidget->core.widget_class->core_class.resize)(aWidget); |
---|
580 | // } |
---|
581 | |
---|
582 | |
---|
583 | #endif |
---|