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