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