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