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