00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdlib.h>
00020 #include <time.h>
00021 #include <Riostream.h>
00022 #include <TString.h>
00023 #include <TROOT.h>
00024 #include <TClass.h>
00025 #include <TEnv.h>
00026 #include <TError.h>
00027 #include <TBenchmark.h>
00028 #include <TSystem.h>
00029 #include <TApplication.h>
00030 #include <TDatime.h>
00031 #include <TFile.h>
00032 #include <TObjArray.h>
00033
00034 #include <TGFrame.h>
00035 #include <TImage.h>
00036 #include <TCanvas.h>
00037
00038 #include <TMD5.h>
00039 #include <TG3DLine.h>
00040 #include <TGButton.h>
00041 #include <TGButtonGroup.h>
00042 #include <TGColorDialog.h>
00043 #include <TGComboBox.h>
00044 #include <TGLabel.h>
00045 #include <TGListBox.h>
00046 #include <TGListTree.h>
00047 #include <TGMenu.h>
00048 #include <TGMsgBox.h>
00049 #include <TGNumberEntry.h>
00050 #include <TGProgressBar.h>
00051 #include <TGResourcePool.h>
00052 #include <TGShutter.h>
00053 #include <TGSimpleTable.h>
00054 #include <TGTextEdit.h>
00055 #include <TRootCanvas.h>
00056 #include <TGTab.h>
00057 #include <TGPack.h>
00058 #include <TGColorDialog.h>
00059 #include <TGFontDialog.h>
00060 #include <TGTextEditDialogs.h>
00061 #include <TGTableLayout.h>
00062 #include <TGMdi.h>
00063 #include <TGSlider.h>
00064 #include <TGDoubleSlider.h>
00065 #include <TGTripleSlider.h>
00066 #include <TBrowser.h>
00067 #include <TGPasswdDialog.h>
00068 #include <TGImageMap.h>
00069 #include <TASPaletteEditor.h>
00070 #include <TControlBar.h>
00071 #include <TGSpeedo.h>
00072 #include <TGShapedFrame.h>
00073 #include <TGSplitFrame.h>
00074 #include <TGTextEditor.h>
00075 #include <TRootHelpDialog.h>
00076 #include <TGHtmlBrowser.h>
00077 #include <HelpText.h>
00078 #include <TSystemDirectory.h>
00079 #include <TInterpreter.h>
00080 #include <TStopwatch.h>
00081
00082 #include <TRecorder.h>
00083
00084 void stressGUI();
00085 void ProcessFrame(TGFrame *f, const char *title);
00086
00087
00088 void testLayout();
00089 void testTextAlign();
00090 void testGroupState();
00091 void testLabels();
00092 void testSplitButton();
00093 void testTextEntries();
00094 void testListTree();
00095 void testShutter();
00096 void testProgressBar();
00097 void testNumberEntry();
00098 void testEditor();
00099 void testCanvas();
00100 void testColorDlg();
00101 void testFontDlg();
00102 void testSearchDlg();
00103 void testTableLayout();
00104 void testPack();
00105 void testSliders();
00106 void testBrowsers();
00107 void testSplitFrame();
00108 void testControlBars();
00109 void testHelpDialog();
00110 void testPaletteEditor();
00111 void testHtmlBrowser();
00112
00113 void run_tutorials();
00114 void guitest_playback();
00115 void dnd_playback();
00116 void mditest_playback();
00117 void fitpanel_playback();
00118 void graph_edit_playback();
00119
00120
00121 RedirectHandle_t gRH;
00122 Int_t gTestNum = 0;
00123 Bool_t gOptionRef = kFALSE;
00124 Bool_t gOptionKeep = kFALSE;
00125 Bool_t gOptionFull = kFALSE;
00126 char outfile[80];
00127 char gLine[80];
00128 Int_t sizes[100];
00129 TString gTmpfilename;
00130 TString gRootSys;
00131
00132 FILE *sgref = 0;
00133
00134
00135 int main(int argc, char *argv[])
00136 {
00137
00138
00139
00140 gEnv->ReadFile(TString::Format("%s/etc/system.rootrc",
00141 gSystem->Getenv("ROOTSYS")), kEnvAll);
00142 gOptionRef = kFALSE;
00143 gOptionKeep = kFALSE;
00144 gOptionFull = kFALSE;
00145 gTmpfilename = "stress-gui";
00146 FILE *f = gSystem->TempFileName(gTmpfilename);
00147 fclose(f);
00148 for (int i = 0; i < argc; i++) {
00149 if (!strcmp(argv[i], "-ref")) gOptionRef = kTRUE;
00150 if (!strcmp(argv[i], "-keep")) gOptionKeep = kTRUE;
00151 if (!strcmp(argv[i], "-full")) gOptionFull = kTRUE;
00152 if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "-?")) {
00153 printf("Usage: stressGUI [-ref] [-keep] [-full] [-help] [-?] \n");
00154 printf("Options:\n");
00155 printf("\n");
00156 printf(" -ref: Generate the reference output file \"stressGUI.ref\"\n");
00157 printf("\n");
00158 printf(" -keep: Keep the png files even for passed tests\n");
00159 printf(" (by default the png files are deleted)\n");
00160 printf("\n");
00161 printf(" -full: Full test: replay also recorder sessions\n");
00162 printf(" (guitest, drag and drop, fitpanel, ...)\n");
00163 printf("\n");
00164 printf(" -help, -?: Print usage and exit\n");
00165 return 0;
00166 }
00167 }
00168 TApplication theApp("App", &argc, argv);
00169 gBenchmark = new TBenchmark();
00170 stressGUI();
00171 theApp.Terminate();
00172 return 0;
00173 }
00174
00175
00176 void stressGUI()
00177 {
00178
00179
00180 if (gOptionRef) {
00181 sgref = fopen("stressGUI.ref", "wt");
00182 }
00183 else {
00184
00185 sgref = fopen("stressGUI.ref", "rt");
00186 if (sgref == 0) {
00187 printf("\nReference file \"stressGUI.ref\" not found!\n");
00188 printf("Please generate the reference file by executing\n");
00189 printf("stressGUI with the -ref flag, as shown below:\n");
00190 printf(" stressGUI -ref\n");
00191 gSystem->Unlink(gTmpfilename.Data());
00192 exit(0);
00193 }
00194 char line[160];
00195 Int_t i = -1;
00196 while (fgets(line, 160, sgref)) {
00197 if ((i >= 0) && (strlen(line) > 15)) {
00198 sscanf(&line[8], "%d", &sizes[i]);
00199 }
00200 i++;
00201 }
00202 fclose(sgref);
00203 }
00204 gRootSys = gSystem->UnixPathName(gSystem->Getenv("ROOTSYS"));
00205 #ifdef WIN32
00206
00207 if (gRootSys[1] == ':' && gRootSys[2] == '/')
00208 gRootSys.Remove(0, 2);
00209 #endif
00210
00211 gVirtualX->Warp(gClient->GetDisplayWidth()-50, gClient->GetDisplayHeight()-50,
00212 gClient->GetDefaultRoot()->GetId());
00213
00214
00215
00216
00217
00218 if (gOptionRef) {
00219 fprintf(sgref, "Test# Size#\n");
00220 } else {
00221 cout << "**********************************************************************" <<endl;
00222 cout << "* Starting GUI - S T R E S S suite *" <<endl;
00223 cout << "**********************************************************************" <<endl;
00224 }
00225 gTestNum = 0;
00226
00227 gBenchmark->Start("stressGUI");
00228
00229 if (!gOptionRef) {
00230 cout << "* Running macros in $ROOTSYS/tutorials/gui - S T R E S S *" <<endl;
00231 cout << "**********************************************************************" <<endl;
00232 }
00233 run_tutorials();
00234 if (!gOptionRef) {
00235 cout << "**********************************************************************" <<endl;
00236 cout << "* Starting Basic GUI Widgets - S T R E S S *" <<endl;
00237 cout << "**********************************************************************" <<endl;
00238 }
00239 testLayout();
00240 testTextAlign();
00241 testGroupState();
00242 testLabels();
00243 testSplitButton();
00244 testTextEntries();
00245 testListTree();
00246 testShutter();
00247 testProgressBar();
00248 testNumberEntry();
00249 testTableLayout();
00250 if (!gOptionRef) {
00251 cout << "**********************************************************************" <<endl;
00252 cout << "* Starting High Level GUI Widgets - S T R E S S *" <<endl;
00253 cout << "**********************************************************************" <<endl;
00254 }
00255 testPack();
00256 testSearchDlg();
00257 testFontDlg();
00258 testColorDlg();
00259 testEditor();
00260 testCanvas();
00261 testSliders();
00262 testBrowsers();
00263 testSplitFrame();
00264 testControlBars();
00265 testHelpDialog();
00266 testPaletteEditor();
00267 testHtmlBrowser();
00268
00269 if (!gOptionRef) {
00270
00271 if (gOptionFull) {
00272 cout << "**********************************************************************" <<endl;
00273 cout << "* Starting Drag and Drop playback - S T R E S S *" <<endl;
00274 cout << "**********************************************************************" <<endl;
00275 dnd_playback();
00276
00277 cout << "**********************************************************************" <<endl;
00278 cout << "* Starting MDI test playback - S T R E S S *" <<endl;
00279 cout << "**********************************************************************" <<endl;
00280 mditest_playback();
00281
00282 cout << "**********************************************************************" <<endl;
00283 cout << "* Starting guitest recorder playback - S T R E S S *" <<endl;
00284 cout << "**********************************************************************" <<endl;
00285 guitest_playback();
00286
00287 cout << "**********************************************************************" <<endl;
00288 cout << "* Starting fit panel recorder playback - S T R E S S *" <<endl;
00289 cout << "**********************************************************************" <<endl;
00290 fitpanel_playback();
00291
00292 cout << "**********************************************************************" <<endl;
00293 cout << "* Starting graphic editors recorder playback - S T R E S S *" <<endl;
00294 cout << "**********************************************************************" <<endl;
00295 graph_edit_playback();
00296 }
00297 cout << "**********************************************************************" <<endl;
00298
00299 gBenchmark->Stop("stressGUI");
00300
00301
00302 Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0;
00303 if (UNIX) {
00304 TString sp = gSystem->GetFromPipe("uname -a");
00305 sp.Resize(60);
00306 printf("* SYS: %s\n",sp.Data());
00307 if (strstr(gSystem->GetBuildNode(),"Linux")) {
00308 sp = gSystem->GetFromPipe("lsb_release -d -s");
00309 printf("* SYS: %s\n",sp.Data());
00310 }
00311 if (strstr(gSystem->GetBuildNode(),"Darwin")) {
00312 sp = gSystem->GetFromPipe("sw_vers -productVersion");
00313 sp += " Mac OS X ";
00314 printf("* SYS: %s\n",sp.Data());
00315 }
00316 } else {
00317 const char *os = gSystem->Getenv("OS");
00318 if (!os) printf("* SYS: Windows 95\n");
00319 else printf("* SYS: %s %s \n",os,gSystem->Getenv("PROCESSOR_IDENTIFIER"));
00320 }
00321
00322 printf("**********************************************************************\n");
00323 printf("* ");
00324 gBenchmark->Print("stressGUI");
00325
00326 Double_t ct = gBenchmark->GetCpuTime("stressGUI");
00327 Double_t rt = gBenchmark->GetRealTime("stressGUI");
00328
00329 Double_t full_marks = 0.5 *((13.0/ct) + (300.0/rt));
00330 if (!gOptionFull)
00331 full_marks = 0.5 *((4.5/ct) + (35.0/rt));
00332 const Double_t rootmarks = 1000.0 * full_marks;
00333
00334 printf("**********************************************************************\n");
00335 printf("* ROOTMARKS = %6.1f * Root%-8s %d/%04d\n", rootmarks, gROOT->GetVersion(),
00336 gROOT->GetVersionDate(), gROOT->GetVersionTime());
00337 printf("**********************************************************************\n");
00338 }
00339 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
00340 if (gOptionRef) {
00341 fclose(sgref);
00342 }
00343 gSystem->Unlink(gTmpfilename.Data());
00344 #ifdef WIN32
00345 gSystem->Exec("erase /q /s TxtEdit* >nul 2>&1");
00346 gSystem->Exec("erase /q /s TxtView* >nul 2>&1");
00347 #else
00348 gSystem->Exec("rm -f TxtEdit*");
00349 gSystem->Exec("rm -f TxtView*");
00350 #endif
00351 }
00352
00353
00354
00355
00356
00357
00358 Int_t FileSize(const char *filename)
00359 {
00360
00361
00362 FileStat_t fs;
00363 gSystem->GetPathInfo(filename, fs);
00364 return (Int_t)fs.fSize;
00365 }
00366
00367
00368 Bool_t VerifySize(const char *filename, const char *title)
00369 {
00370
00371
00372 Int_t ftol = 0;
00373 Bool_t success = kFALSE;
00374 Int_t fsize = FileSize(filename);
00375
00376 if (strstr(title, "Browser")) ftol = 350;
00377
00378 if (strstr(title, "CPUMeter.C")) ftol = 50000;
00379 if (strstr(title, "games.C")) ftol = 150;
00380 if (strstr(title, "ntupleTableTest.C")) ftol = 100;
00381
00382 if (!gOptionRef) {
00383 if ((fsize < sizes[gTestNum] - ftol) || (fsize > sizes[gTestNum] + ftol))
00384 success = kFALSE;
00385 else
00386 success = kTRUE;
00387
00388 sprintf(gLine,"Test %2d: %s", gTestNum, title);
00389 const Int_t nch = strlen(gLine);
00390 if (success) {
00391 cout << gLine;
00392 for (Int_t i = nch; i < 67; i++) cout << ".";
00393 cout << " OK" << endl;
00394 } else {
00395 cout << gLine;
00396 for (Int_t i = nch; i < 63; i++) cout << ".";
00397 cout << " FAILED" << endl;
00398 cout << " File Size = " << fsize << endl;
00399 cout << " Ref Size = " << sizes[gTestNum] << endl;
00400 }
00401 } else {
00402 fprintf(sgref, "%5d%10d\n", gTestNum, fsize);
00403 success = kTRUE;
00404 }
00405 if (!gOptionKeep && success) gSystem->Unlink(filename);
00406 return success;
00407 }
00408
00409
00410 void ProcessFrame(TGFrame *f, const char *title)
00411 {
00412
00413
00414 gClient->HandleInput();
00415 gSystem->Sleep(50);
00416 gSystem->ProcessEvents();
00417 gErrorIgnoreLevel = 9999;
00418
00419 if (gOptionRef)
00420 sprintf(outfile, "sgui_%02d_ref.png", gTestNum);
00421 else
00422 sprintf(outfile, "sgui_%02d.png", gTestNum);
00423
00424 TImage *img = TImage::Create();
00425 f->RaiseWindow();
00426 img->FromWindow(f->GetId());
00427 img->WriteImage(outfile);
00428
00429 if (!gOptionRef) {
00430 if (!strstr(title, "Pack Frames") &&
00431 !strstr(title, "HTML Browser")) {
00432 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
00433 ((TGMainFrame *)f)->SaveSource(Form("sgui_%02d.C", gTestNum));
00434 gSystem->Unlink(Form("sgui_%02d.C", gTestNum));
00435 gSystem->RedirectOutput(0, 0, &gRH);
00436 }
00437 }
00438 VerifySize(outfile, title);
00439
00440 delete img;
00441 gErrorIgnoreLevel = 0;
00442 gTestNum++;
00443 }
00444
00445
00446 void ProcessMacro(const char *macro, const char *title)
00447 {
00448
00449
00450 Int_t nbpass = 1, npass = 0;
00451 TString capture = macro;
00452 capture.ReplaceAll(".C", "_0.png");
00453 if (strstr(macro, "games.C")) nbpass = 3;
00454 if (strstr(macro, "galaxy_image.C")) nbpass = 2;
00455
00456 while (npass < nbpass) {
00457 ++npass;
00458 capture.ReplaceAll(TString::Format("_%d.png", npass-1),
00459 TString::Format("_%d.png", npass));
00460 VerifySize(capture.Data(), title);
00461 gTestNum++;
00462 }
00463 }
00464
00465
00466 void CloseMainframes()
00467 {
00468 TClass* clGMainFrame = TClass::GetClass("TGMainFrame");
00469 TGWindow* win = 0;
00470 TIter iWin(gClient->GetListOfWindows());
00471 while ((win = (TGWindow*)iWin())) {
00472 const TObject* winGetParent = win->GetParent();
00473 Bool_t winIsMapped = kFALSE;
00474 if (winGetParent == gClient->GetDefaultRoot())
00475 winIsMapped = win->IsMapped();
00476 if (winIsMapped && win->InheritsFrom(clGMainFrame)) {
00477 ((TGMainFrame *)win)->CloseWindow();
00478 gSystem->Sleep(100);
00479 }
00480 gSystem->ProcessEvents();
00481 }
00482 gSystem->Sleep(100);
00483 }
00484
00485
00486
00487
00488
00489 class ButtonLayoutWindow : public TGMainFrame {
00490
00491 private:
00492 TGTextButton *test, *draw, *help, *ok, *cancel, *exit;
00493
00494 public:
00495 ButtonLayoutWindow(const TGWindow *p, UInt_t w, UInt_t h);
00496
00497 };
00498
00499
00500 ButtonLayoutWindow::ButtonLayoutWindow(const TGWindow *p, UInt_t w, UInt_t h) :
00501 TGMainFrame(p, w, h)
00502 {
00503
00504
00505 SetCleanup(kDeepCleanup);
00506
00507 TGVerticalFrame *hframe1 = new TGVerticalFrame(this, 170, 50, kFixedWidth);
00508 test = new TGTextButton(hframe1, "&Test ");
00509
00510 hframe1->AddFrame(test, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,0,2,2));
00511 AddFrame(hframe1, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1));
00512
00513
00514 TGCompositeFrame *cframe1 = new TGCompositeFrame(this, 170, 20, kHorizontalFrame | kFixedWidth);
00515 draw = new TGTextButton(cframe1, "&Draw");
00516
00517 cframe1->AddFrame(draw, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,2,2,2));
00518
00519
00520 ULong_t yellow;
00521 gClient->GetColorByName("yellow", yellow);
00522 help = new TGTextButton(cframe1, "&Help");
00523 help->ChangeBackground(yellow);
00524 cframe1->AddFrame(help, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,2,2,2));
00525 AddFrame(cframe1, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1));
00526
00527
00528 TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 170, 20, kHorizontalFrame | kFixedWidth);
00529 ok = new TGTextButton(cframe2, "OK");
00530 ok->SetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
00531 ok->SetEnabled(kFALSE);
00532
00533 cframe2->AddFrame(ok, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,3,2,2,2));
00534
00535 TGGC myGC = *gClient->GetResourcePool()->GetFrameGC();
00536
00537
00538 cancel = new TGTextButton(cframe2, "Cancel ");
00539 cancel->SetText("&Cancel ");
00540
00541 ok->SetEnabled(kTRUE);
00542 cancel->SetTextColor(yellow);
00543 cancel->SetState(kButtonEngaged);
00544 cframe2->AddFrame(cancel, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,3,2,2,2));
00545
00546 exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");
00547 cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,0,2,2));
00548 exit->SetText("&Exit ");
00549
00550 AddFrame(cframe2, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1));
00551
00552 SetWindowName("Buttons' Layout");
00553 MapSubwindows();
00554 Layout();
00555 Resize(GetDefaultSize());
00556 SetWMPosition(0, 0);
00557 MapWindow();
00558 }
00559
00560
00561 void testLayout()
00562 {
00563
00564
00565 ButtonLayoutWindow *f = new ButtonLayoutWindow(gClient->GetRoot(), 100, 100);
00566 ProcessFrame((TGMainFrame*)f, "Buttons 1 (layout)");
00567 f->CloseWindow();
00568 }
00569
00570
00571
00572 class TextMargin : public TGHorizontalFrame {
00573
00574 protected:
00575 TGNumberEntry *fEntry;
00576
00577 public:
00578 TextMargin(const TGWindow *p, const char *name) : TGHorizontalFrame(p)
00579 {
00580 fEntry = new TGNumberEntry(this, 0, 6, -1, TGNumberFormat::kNESInteger);
00581 AddFrame(fEntry, new TGLayoutHints(kLHintsLeft));
00582 TGLabel *label = new TGLabel(this, name);
00583 AddFrame(label, new TGLayoutHints(kLHintsLeft, 10));
00584 }
00585 TGTextEntry *GetEntry() const { return fEntry->GetNumberEntry(); }
00586
00587 };
00588
00589 class TextAlignWindow : public TGMainFrame {
00590
00591 protected:
00592 TGTextButton *fButton;
00593
00594 public:
00595 TextAlignWindow();
00596 void SetTextPosition(Int_t hid, Int_t vid);
00597
00598 };
00599
00600
00601 void TextAlignWindow::SetTextPosition(Int_t hid, Int_t vid)
00602 {
00603
00604
00605 Int_t tj = fButton->GetTextJustify();
00606 tj &= ~kTextCenterX;
00607 tj &= ~kTextLeft;
00608 tj &= ~kTextRight;
00609 tj &= ~kTextCenterY;
00610 tj &= ~kTextTop;
00611 tj &= ~kTextBottom;
00612 tj |= hid;
00613 tj |= vid;
00614 fButton->SetTextJustify(tj);
00615 }
00616
00617
00618 TextAlignWindow::TextAlignWindow() : TGMainFrame(gClient->GetRoot(), 10, 10, kHorizontalFrame)
00619 {
00620
00621
00622 SetCleanup(kDeepCleanup);
00623
00624
00625 TGVerticalFrame *controls = new TGVerticalFrame(this);
00626 AddFrame(controls, new TGLayoutHints(kLHintsRight | kLHintsExpandY, 5, 5, 5, 5));
00627
00628
00629 TGVertical3DLine *separator = new TGVertical3DLine(this);
00630 AddFrame(separator, new TGLayoutHints(kLHintsRight | kLHintsExpandY));
00631
00632
00633 TGHorizontalFrame *contents = new TGHorizontalFrame(this);
00634 AddFrame(contents, new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5));
00635
00636
00637 fButton = new TGTextButton(contents,
00638 "&This button has a multi-line label\nand shows features\navailable in the button classes");
00639 fButton->Resize(300, 200);
00640 fButton->ChangeOptions(fButton->GetOptions() | kFixedSize);
00641 fButton->SetToolTipText("The assigned tooltip\ncan be multi-line also", 200);
00642 contents->AddFrame(fButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 20, 20, 20, 20));
00643
00644 TGGroupFrame *group = new TGGroupFrame(controls, "Enable/Disable");
00645 group->SetTitlePos(TGGroupFrame::kCenter);
00646 TGCheckButton *disable = new TGCheckButton(group, "Switch state\nEnable/Disable");
00647 disable->SetOn();
00648 group->AddFrame(disable, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
00649 controls->AddFrame(group, new TGLayoutHints(kLHintsExpandX));
00650
00651
00652 TGButtonGroup *horizontal = new TGButtonGroup(controls, "Horizontal Position");
00653 horizontal->SetTitlePos(TGGroupFrame::kCenter);
00654 new TGRadioButton(horizontal, "Center", kTextCenterX);
00655 new TGRadioButton(horizontal, "Left", kTextLeft);
00656 new TGRadioButton(horizontal, "Right", kTextRight);
00657 horizontal->SetButton(kTextCenterX);
00658 controls->AddFrame(horizontal, new TGLayoutHints(kLHintsExpandX));
00659
00660
00661 TGButtonGroup *vertical = new TGButtonGroup(controls, "Vertical Position");
00662 vertical->SetTitlePos(TGGroupFrame::kCenter);
00663 new TGRadioButton(vertical, "Center", kTextCenterY);
00664 new TGRadioButton(vertical, "Top", kTextTop);
00665 new TGRadioButton(vertical, "Bottom", kTextBottom);
00666 vertical->SetButton(kTextCenterY);
00667 controls->AddFrame(vertical, new TGLayoutHints(kLHintsExpandX));
00668
00669
00670 TGGroupFrame *margins = new TGGroupFrame(controls, "Text Margins");
00671 margins->SetTitlePos(TGGroupFrame::kCenter);
00672
00673 TextMargin *left = new TextMargin(margins, "Left");
00674 margins->AddFrame(left, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
00675
00676 TextMargin *right = new TextMargin(margins, "Right");
00677 margins->AddFrame(right, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
00678
00679 TextMargin *top = new TextMargin(margins, "Top");
00680 margins->AddFrame(top, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
00681
00682 TextMargin *bottom = new TextMargin(margins, "Bottom");
00683 margins->AddFrame(bottom, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 2));
00684
00685 controls->AddFrame(margins, new TGLayoutHints(kLHintsExpandX));
00686
00687 TGTextButton *quit = new TGTextButton(controls, "Quit");
00688 controls->AddFrame(quit, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 0, 5));
00689
00690 SetWindowName("Button Test");
00691 MapSubwindows();
00692 Layout();
00693 Resize(GetDefaultSize());
00694 SetWMPosition(0, 0);
00695 MapWindow();
00696 }
00697
00698
00699 void testTextAlign()
00700 {
00701
00702
00703 TextAlignWindow *f = new TextAlignWindow();
00704 ProcessFrame((TGMainFrame*)f, "Buttons 2 (text alignment)");
00705 f->SetTextPosition(kTextLeft, kTextTop);
00706 ProcessFrame((TGMainFrame*)f, "Buttons 3 (text alignment)");
00707 f->SetTextPosition(kTextCenterX, kTextTop);
00708 ProcessFrame((TGMainFrame*)f, "Buttons 4 (text alignment)");
00709 f->SetTextPosition(kTextRight, kTextTop);
00710 ProcessFrame((TGMainFrame*)f, "Buttons 5 (text alignment)");
00711 f->SetTextPosition(kTextRight, kTextCenterY);
00712 ProcessFrame((TGMainFrame*)f, "Buttons 6 (text alignment)");
00713 f->SetTextPosition(kTextRight, kTextBottom);
00714 ProcessFrame((TGMainFrame*)f, "Buttons 7 (text alignment)");
00715 f->SetTextPosition(kTextCenterX, kTextBottom);
00716 ProcessFrame((TGMainFrame*)f, "Buttons 8 (text alignment)");
00717 f->SetTextPosition(kTextLeft, kTextBottom);
00718 ProcessFrame((TGMainFrame*)f, "Buttons 9 (text alignment)");
00719 f->SetTextPosition(kTextLeft, kTextCenterY);
00720 ProcessFrame((TGMainFrame*)f, "Buttons 10 (text alignment)");
00721 f->CloseWindow();
00722 }
00723
00724
00725
00726 class GroupStateWindow : public TGMainFrame {
00727
00728 public:
00729 TGTextButton *fExit;
00730 TGVButtonGroup *fButtonGroup;
00731 TGCheckButton *fCheckb[4];
00732 TGRadioButton *fRadiob[2];
00733
00734 public:
00735 GroupStateWindow(const TGWindow *p, UInt_t w, UInt_t h);
00736 };
00737
00738
00739 GroupStateWindow::GroupStateWindow(const TGWindow *p, UInt_t w, UInt_t h) :
00740 TGMainFrame(p, w, h)
00741 {
00742
00743
00744 SetCleanup(kDeepCleanup);
00745
00746 TGHorizontalFrame *fHL2 = new TGHorizontalFrame(this, 70, 100);
00747 fCheckb[0] = new TGCheckButton(fHL2, new TGHotString("Enable BG"), 100);
00748 fCheckb[0]->SetToolTipText("Enable/Disable the button group");
00749 fHL2->AddFrame(fCheckb[0], new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 1, 1, 1, 1));
00750 fButtonGroup = new TGVButtonGroup(fHL2, "My Button Group");
00751 fCheckb[1] = new TGCheckButton(fButtonGroup, new TGHotString("CB 2"), 101);
00752 fCheckb[2] = new TGCheckButton(fButtonGroup, new TGHotString("CB 3"), 102);
00753 fCheckb[3] = new TGCheckButton(fButtonGroup, new TGHotString("CB 4"), 103);
00754 fRadiob[0] = new TGRadioButton(fButtonGroup, new TGHotString("RB 1"), 104);
00755 fRadiob[1] = new TGRadioButton(fButtonGroup, new TGHotString("RB 2"), 105);
00756 fButtonGroup->Show();
00757
00758 fHL2->AddFrame(fButtonGroup, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 1, 1, 1, 1));
00759 AddFrame(fHL2);
00760
00761 TGHorizontalFrame *fHL3 = new TGHorizontalFrame(this, 70, 100, kFixedWidth);
00762 fExit = new TGTextButton(fHL3, "&Exit", 106);
00763 fHL3->AddFrame(fExit, new TGLayoutHints(kLHintsExpandX));
00764 AddFrame(fHL3, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 1, 1, 1, 1));
00765
00766
00767 fCheckb[0]->SetOn();
00768 fButtonGroup->SetState(kTRUE);
00769
00770 SetWindowName("My Button Group");
00771 MapSubwindows();
00772 Layout();
00773 Resize(GetDefaultSize());
00774 SetWMPosition(0, 0);
00775 MapWindow();
00776
00777 fButtonGroup->SetRadioButtonExclusive(kTRUE);
00778 fRadiob[1]->SetOn();
00779 };
00780
00781
00782 void testGroupState()
00783 {
00784
00785
00786 GroupStateWindow *f = new GroupStateWindow(gClient->GetRoot(), 100, 100);
00787 ProcessFrame((TGMainFrame*)f, "Buttons 11 (group state)");
00788 f->fCheckb[0]->SetOn(kFALSE);
00789 f->fButtonGroup->SetState(kFALSE);
00790 ProcessFrame((TGMainFrame*)f, "Buttons 12 (group state)");
00791
00792 f->CloseWindow();
00793 }
00794
00795
00796
00797 class LabelsWindow : public TGMainFrame {
00798
00799 private:
00800 TGLabel *fLbl1, *fLbl2, *fLbl3, *fLbl4;
00801 public:
00802 LabelsWindow(const TGWindow *p, UInt_t w, UInt_t h);
00803 void SwitchState();
00804 };
00805
00806
00807 LabelsWindow::LabelsWindow(const TGWindow *p, UInt_t w, UInt_t h) :
00808 TGMainFrame(p, w, h)
00809 {
00810
00811
00812 SetCleanup(kDeepCleanup);
00813
00814 TGGC *fTextGC;
00815 const TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-18-*-*-*-*-*-*-*");
00816 if (!font)
00817 font = gClient->GetResourcePool()->GetDefaultFont();
00818 FontStruct_t labelfont = font->GetFontStruct();
00819 GCValues_t gval;
00820 gval.fMask = kGCBackground | kGCFont | kGCForeground;
00821 gval.fFont = font->GetFontHandle();
00822 gClient->GetColorByName("yellow", gval.fBackground);
00823 fTextGC = gClient->GetGC(&gval, kTRUE);
00824
00825 ULong_t bcolor, ycolor;
00826 gClient->GetColorByName("yellow", ycolor);
00827 gClient->GetColorByName("blue", bcolor);
00828
00829
00830 fLbl1 = new TGLabel(this, "OwnFont & Bck/ForgrColor", fTextGC->GetGC(), labelfont, kChildFrame, bcolor);
00831 AddFrame(fLbl1, new TGLayoutHints(kLHintsNormal, 5, 5, 3, 4));
00832 fLbl1->SetTextColor(ycolor);
00833
00834 fLbl2 = new TGLabel(this, "Own Font & ForegroundColor", fTextGC->GetGC(), labelfont);
00835 AddFrame(fLbl2, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
00836 fLbl2->SetTextColor(ycolor);
00837
00838 fLbl3 = new TGLabel(this, "Normal Label");
00839 AddFrame(fLbl3, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
00840
00841 fLbl4 = new TGLabel(this, "Multi-line label, resized\nto 300x80 pixels",
00842 fTextGC->GetGC(), labelfont, kChildFrame, bcolor);
00843 AddFrame(fLbl4, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
00844 fLbl4->SetTextColor(ycolor);
00845 fLbl4->ChangeOptions(fLbl4->GetOptions() | kFixedSize);
00846 fLbl4->Resize(350, 80);
00847
00848
00849 TGTextButton *toggle = new TGTextButton(this, "&Toggle Labels");
00850 toggle->SetToolTipText("Click on the button to toggle label's state (enable/disable)");
00851 AddFrame(toggle, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
00852 TGTextButton *exit = new TGTextButton(this, "&Exit ");
00853 AddFrame(exit, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
00854
00855
00856 SetWindowName("Labels");
00857 MapSubwindows();
00858 Layout();
00859 Resize(GetDefaultSize());
00860 SetWMPosition(0, 0);
00861 MapWindow();
00862 }
00863
00864
00865 void LabelsWindow::SwitchState()
00866 {
00867
00868
00869 if (fLbl1->IsDisabled()) {
00870 fLbl1->Enable();
00871 fLbl2->Enable();
00872 fLbl3->Enable();
00873 fLbl4->Enable();
00874 } else {
00875 fLbl1->Disable();
00876 fLbl2->Disable();
00877 fLbl3->Disable();
00878 fLbl4->Disable();
00879 }
00880 }
00881
00882
00883 void testLabels()
00884 {
00885
00886
00887 LabelsWindow *f = new LabelsWindow(gClient->GetRoot(), 200, 200);
00888 ProcessFrame((TGMainFrame*)f, "Labels 1");
00889 f->SwitchState();
00890 ProcessFrame((TGMainFrame*)f, "Labels 2");
00891 f->CloseWindow();
00892 }
00893
00894
00895
00896 class SplitButtonWindow : public TGMainFrame {
00897
00898 public:
00899 TGCheckButton *fCButton;
00900 TGCheckButton *fEButton;
00901 TGSplitButton *fMButton;
00902 TGPopupMenu *fPopMenu;
00903
00904 public:
00905 SplitButtonWindow(const TGWindow *p, UInt_t w, UInt_t h);
00906
00907 };
00908
00909
00910 SplitButtonWindow::SplitButtonWindow(const TGWindow *p, UInt_t w, UInt_t h) :
00911 TGMainFrame(p, w, h)
00912 {
00913
00914
00915 SetCleanup(kDeepCleanup);
00916
00917 TGVerticalFrame *fVL = new TGVerticalFrame(this, 100, 100);
00918 TGHorizontalFrame *fHL = new TGHorizontalFrame(fVL, 100, 40);
00919
00920
00921 fPopMenu = new TGPopupMenu(gClient->GetRoot());
00922 fPopMenu->AddEntry("Button &1", 1001);
00923 fPopMenu->AddEntry("Button &2", 1002);
00924 fPopMenu->DisableEntry(1002);
00925 fPopMenu->AddEntry("Button &3", 1003);
00926 fPopMenu->AddSeparator();
00927
00928
00929 fMButton = new TGSplitButton(fHL, new TGHotString("Button &Options"),
00930 fPopMenu, 1101);
00931
00932
00933 fPopMenu->AddEntry("En&try with really really long name", 1004);
00934 fPopMenu->AddEntry("&Exit", 1005);
00935
00936 fCButton = new TGCheckButton(fHL, new TGHotString("Split"), 1102);
00937 fCButton->SetState(kButtonDown);
00938
00939
00940 fHL->AddFrame(fCButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
00941 0, 10, 0, 0));
00942 fEButton = new TGCheckButton(fHL, new TGHotString("Enable"), 1103);
00943 fEButton->SetState(kButtonDown);
00944
00945
00946 fHL->AddFrame(fEButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
00947 0, 10, 0, 0));
00948 fHL->AddFrame(fMButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));
00949 fVL->AddFrame(fHL, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));
00950 AddFrame(fVL, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));
00951
00952 SetWindowName("SplitButton Test");
00953 MapSubwindows();
00954 Layout();
00955 Resize(GetDefaultSize());
00956 SetWMPosition(0, 0);
00957 MapWindow();
00958 }
00959
00960
00961 void testSplitButton()
00962 {
00963
00964
00965 SplitButtonWindow *f = new SplitButtonWindow(gClient->GetRoot(),100,100);
00966 f->fCButton->SetState(kButtonDown);
00967 f->fEButton->SetState(kButtonDown);
00968 f->fMButton->SetState(kButtonUp);
00969 f->fMButton->SetSplit(kTRUE);
00970 ProcessFrame((TGMainFrame*)f, "Split Button 1");
00971 f->fCButton->SetState(kButtonUp);
00972 f->fEButton->SetState(kButtonDown);
00973 f->fMButton->SetState(kButtonUp);
00974 f->fMButton->SetSplit(kFALSE);
00975 ProcessFrame((TGMainFrame*)f, "Split Button 2");
00976 f->fCButton->SetState(kButtonDown);
00977 f->fEButton->SetState(kButtonUp);
00978 f->fMButton->SetState(kButtonDisabled);
00979 f->fMButton->SetSplit(kTRUE);
00980 ProcessFrame((TGMainFrame*)f, "Split Button 3");
00981 f->fCButton->SetState(kButtonUp);
00982 f->fEButton->SetState(kButtonUp);
00983 f->fMButton->SetState(kButtonDisabled);
00984 f->fMButton->SetSplit(kFALSE);
00985 ProcessFrame((TGMainFrame*)f, "Split Button 4");
00986 f->CloseWindow();
00987 }
00988
00989
00990
00991 class GroupBox : public TGGroupFrame {
00992 private:
00993 TGComboBox *fCombo;
00994 TGTextEntry *fEntry;
00995
00996 public:
00997 GroupBox(const TGWindow *p, const char *name, const char *title);
00998 TGTextEntry *GetEntry() const { return fEntry; }
00999 TGComboBox *GetCombo() const { return fCombo; }
01000 };
01001
01002
01003 GroupBox::GroupBox(const TGWindow *p, const char *name, const char *title) :
01004 TGGroupFrame(p, name)
01005 {
01006
01007
01008 TGHorizontalFrame *horz = new TGHorizontalFrame(this);
01009 AddFrame(horz, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
01010 TGLabel *label = new TGLabel(horz, title);
01011 horz->AddFrame(label, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
01012
01013 fCombo = new TGComboBox(horz);
01014 horz->AddFrame(fCombo, new TGLayoutHints(kLHintsRight | kLHintsExpandY,
01015 5, 0, 5, 5));
01016 fCombo->Resize(100, 20);
01017
01018 fEntry = new TGTextEntry(this);
01019 AddFrame(fEntry, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY));
01020 }
01021
01022
01023
01024 class TextEntryWindow : public TGMainFrame {
01025
01026 public:
01027 GroupBox *fEcho;
01028 GroupBox *fAlign;
01029 GroupBox *fAccess;
01030 GroupBox *fBorder;
01031
01032 public:
01033 TextEntryWindow();
01034 };
01035
01036
01037 TextEntryWindow::TextEntryWindow() : TGMainFrame(gClient->GetRoot(), 10, 10,
01038 kVerticalFrame)
01039 {
01040
01041
01042 TGComboBox *combo;
01043 TGTextEntry *entry;
01044
01045
01046 SetCleanup(kDeepCleanup);
01047
01048 fEcho = new GroupBox(this, "Echo", "Mode:");
01049 AddFrame(fEcho, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5));
01050 combo = fEcho->GetCombo();
01051 entry = fEcho->GetEntry();
01052 entry->SetText("The Quick Brown Fox Jumps");
01053
01054 combo->AddEntry("Normal", TGTextEntry::kNormal);
01055 combo->AddEntry("Password", TGTextEntry::kPassword);
01056 combo->AddEntry("No Echo", TGTextEntry::kNoEcho);
01057 combo->Select(TGTextEntry::kNormal);
01058
01059 fAlign = new GroupBox(this, "Alignment", "Type:");
01060 AddFrame(fAlign, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5));
01061 combo = fAlign->GetCombo();
01062 entry = fAlign->GetEntry();
01063 entry->SetText("Over The Lazy Dog");
01064
01065 combo->AddEntry("Left", kTextLeft);
01066 combo->AddEntry("Centered", kTextCenterX);
01067 combo->AddEntry("Right", kTextRight);
01068 combo->Select(kTextLeft);
01069
01070 fAccess = new GroupBox(this, "Access", "Read-only:");
01071 AddFrame(fAccess, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5));
01072 combo = fAccess->GetCombo();
01073 entry = fAccess->GetEntry();
01074 entry->SetText("The Quick Brown Fox Jumps");
01075
01076 combo->AddEntry("False", 1);
01077 combo->AddEntry("True", 0);
01078 combo->Select(1);
01079
01080 fBorder = new GroupBox(this, "Border", "Drawn:");
01081 AddFrame(fBorder, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5));
01082 combo = fBorder->GetCombo();
01083 entry = fBorder->GetEntry();
01084 entry->SetText("Over The Lazy Dog");
01085
01086 combo->AddEntry("False", 0);
01087 combo->AddEntry("True", 1);
01088 combo->Select(1);
01089
01090 SetWindowName("Text Entries");
01091 MapSubwindows();
01092 Layout();
01093 Resize(GetDefaultSize());
01094 SetWMPosition(0, 0);
01095 MapWindow();
01096 }
01097
01098
01099 void testTextEntries()
01100 {
01101
01102
01103 TGComboBox *combo;
01104 TGTextEntry *entry;
01105
01106 TextEntryWindow *f = new TextEntryWindow();
01107 ProcessFrame((TGMainFrame*)f, "Text Entries 1");
01108
01109 combo = f->fEcho->GetCombo();
01110 entry = f->fEcho->GetEntry();
01111 combo->Select(TGTextEntry::kPassword);
01112 entry->SetEchoMode(TGTextEntry::kPassword);
01113
01114 combo = f->fAlign->GetCombo();
01115 entry = f->fAlign->GetEntry();
01116 combo->Select(kTextCenterX);
01117 entry->SetAlignment(kTextCenterX);
01118
01119 combo = f->fAccess->GetCombo();
01120 entry = f->fAccess->GetEntry();
01121 combo->Select(0);
01122 entry->SetEnabled(0);
01123
01124 combo = f->fBorder->GetCombo();
01125 entry = f->fBorder->GetEntry();
01126 combo->Select(0);
01127 entry->SetFrameDrawn(0);
01128
01129 ProcessFrame((TGMainFrame*)f, "Text Entries 2");
01130
01131 combo = f->fEcho->GetCombo();
01132 entry = f->fEcho->GetEntry();
01133 combo->Select(TGTextEntry::kNoEcho);
01134 entry->SetEchoMode(TGTextEntry::kNoEcho);
01135
01136 combo = f->fAlign->GetCombo();
01137 entry = f->fAlign->GetEntry();
01138 combo->Select(kTextRight);
01139 entry->SetAlignment(kTextRight);
01140
01141 combo = f->fAccess->GetCombo();
01142 entry = f->fAccess->GetEntry();
01143 combo->Select(1);
01144 entry->SetEnabled(1);
01145
01146 combo = f->fBorder->GetCombo();
01147 entry = f->fBorder->GetEntry();
01148 combo->Select(1);
01149 entry->SetFrameDrawn(1);
01150
01151 ProcessFrame((TGMainFrame*)f, "Text Entries 3");
01152
01153 f->CloseWindow();
01154 }
01155
01156
01157
01158 class ListTreeWindow : public TGMainFrame {
01159
01160 private:
01161 TGListTree *fListTree;
01162 TGCanvas *fCanvas;
01163 TGViewPort *fViewPort;
01164 TList *fNamesList;
01165 TGTextButton *fTextButton;
01166
01167 public:
01168 ListTreeWindow(const TGWindow *p, UInt_t w, UInt_t h);
01169 void FillListTree();
01170 void SwitchState();
01171 };
01172
01173
01174 ListTreeWindow::ListTreeWindow(const TGWindow *p, UInt_t w, UInt_t h) :
01175 TGMainFrame(p, w, h, kVerticalFrame)
01176 {
01177
01178
01179 SetCleanup(kDeepCleanup);
01180
01181
01182 fCanvas = new TGCanvas(this, 300, 300);
01183
01184
01185 fViewPort = fCanvas->GetViewPort();
01186
01187
01188 fListTree = new TGListTree(fCanvas, kHorizontalFrame);
01189 fListTree->SetCheckMode(TGListTree::kRecursive);
01190
01191 fListTree->AddItem(0, "rootNode");
01192
01193 fNamesList = new TList();
01194
01195 TString *s1 = new TString("P1D/pclhcb08_CC-PC_HSys/CCPCAlg/Phist1");
01196 fNamesList->Add((TObject*)s1);
01197
01198 TString *s2 = new TString("H1D/pclhcb08_CC-PC_HSys/CCPCAlg/TELL1Mult_$T3/L1/Q0/myTell");
01199 fNamesList->Add((TObject*)s2);
01200
01201 TString *s3 = new TString("H1D/pclhcb08_CC-PC_HSys/CCPCAlg/TELL1Mult_$T3/L2/Q1/myTell");
01202 fNamesList->Add((TObject*)s3);
01203
01204 TString *s4 = new TString("H1D/pclhcb08_CC-PC_HSys/CCPCAlg/TELL1Mult_$T3/L2/Q0/myTell");
01205 fNamesList->Add((TObject*)s4);
01206
01207 TString *s5 = new TString("H2D/pclhcb08_CC-PC_HSys/CCPCAlg/Hist7");
01208 fNamesList->Add((TObject*)s5);
01209
01210 TString *s6 = new TString("P1D/sdf/GaudiExample/xyProfile");
01211 fNamesList->Add((TObject*)s6);
01212
01213 TString *s7 = new TString("H2D/sdf/GaudiExample/xyPositionPlot");
01214 fNamesList->Add((TObject*)s7);
01215
01216 TString *s8 = new TString("H1D/sdf/GaudiExample/Mass");
01217 fNamesList->Add((TObject*)s8);
01218
01219 TString *s9 = new TString("H1D/sdf/GaudiExample/eventtype");
01220 fNamesList->Add((TObject*)s9);
01221
01222 AddFrame(fCanvas, new TGLayoutHints(kLHintsLeft | kLHintsTop |
01223 kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 3));
01224 fTextButton = new TGTextButton(this,"Text &Button...");
01225 AddFrame(fTextButton, new TGLayoutHints(kLHintsLeft | kLHintsTop, 5, 5, 2, 5));
01226
01227 FillListTree();
01228
01229 SetWindowName("List Tree Test");
01230 MapSubwindows();
01231 Layout();
01232 Resize(490, 350);
01233 SetWMPosition(0, 0);
01234 MapWindow();
01235 }
01236
01237
01238 void ListTreeWindow::FillListTree()
01239 {
01240
01241
01242 TString *listItem = 0;
01243 TGListTreeItem *node = 0, *histoNode = 0;
01244
01245 TIter NextName(fNamesList);
01246 while ((listItem = (TString*)NextName())) {
01247 TObject *nameItem = 0;
01248 TObjArray *nameItems = listItem->Tokenize("/");
01249 TIter Next(nameItems);
01250 node = fListTree->GetFirstItem();
01251 fListTree->OpenItem(node);
01252 while ((nameItem = Next())) {
01253 if (fListTree->FindChildByName(node, nameItem->GetName())) {
01254 node = fListTree->FindChildByName(node, nameItem->GetName());
01255 } else {
01256 node = fListTree->AddItem(node, nameItem->GetName());
01257 fListTree->SetCheckBox(node, kTRUE);
01258 fListTree->ToggleItem(node);
01259 if (strcmp(nameItem->GetName(), "TELL1Mult_$T3"))
01260 fListTree->OpenItem(node);
01261 else
01262 fListTree->HighlightItem(node);
01263 }
01264 node->SetUserData(0);
01265 if (nameItem == nameItems->At(nameItems->GetEntriesFast()-2)) {
01266 histoNode = fListTree->AddItem(node, nameItems->Last()->GetName());
01267 fListTree->SetCheckBox(histoNode, kTRUE);
01268 fListTree->ToggleItem(histoNode);
01269 histoNode->SetUserData(listItem);
01270 break;
01271 }
01272 }
01273 }
01274 fListTree->ClearViewPort();
01275 }
01276
01277
01278 void ListTreeWindow::SwitchState()
01279 {
01280
01281
01282
01283 TGListTreeItem *root = 0, *node = 0;
01284 root = fListTree->GetFirstItem();
01285 node = fListTree->FindChildByName(root, "P1D");
01286 if (node) node = fListTree->FindChildByName(node, "pclhcb08_CC-PC_HSys");
01287 if (node) fListTree->CheckAllChildren(node, kTRUE);
01288 if (node && node->GetParent()) node->GetParent()->UpdateState();
01289
01290 node = fListTree->FindChildByName(root, "H1D");
01291 if (node) {
01292 fListTree->CheckAllChildren(node, kTRUE);
01293 node = fListTree->FindChildByName(node, "sdf");
01294 if (node) node = fListTree->FindChildByName(node, "GaudiExample");
01295 if (node) node = fListTree->FindChildByName(node, "eventtype");
01296 if (node) fListTree->CheckItem(node, kFALSE);
01297 while (node) {
01298 node->UpdateState();
01299 node = node->GetParent();
01300 }
01301 }
01302 fListTree->ClearViewPort();
01303 }
01304
01305
01306 void testListTree()
01307 {
01308
01309
01310 ListTreeWindow *f = new ListTreeWindow(gClient->GetRoot(), 100, 100);
01311 ProcessFrame((TGMainFrame*)f, "List Tree 1");
01312 f->SwitchState();
01313 ProcessFrame((TGMainFrame*)f, "List Tree 2");
01314 f->CloseWindow();
01315 }
01316
01317
01318
01319 struct shutterData_t {
01320 const char *pixmap_name;
01321 const char *tip_text;
01322 Int_t id;
01323 TGButton *button;
01324 };
01325
01326 shutterData_t histo_data[] = {
01327 { "h1_s.xpm", "TH1", 1001, 0 },
01328 { "h2_s.xpm", "TH2", 1002, 0 },
01329 { "h3_s.xpm", "TH3", 1003, 0 },
01330 { "profile_s.xpm", "TProfile", 1004, 0 },
01331 { 0, 0, 0, 0 }
01332 };
01333
01334 shutterData_t function_data[] = {
01335 { "f1_s.xpm", "TF1", 2001, 0 },
01336 { "f2_s.xpm", "TF2", 2002, 0 },
01337 { 0, 0, 0, 0 }
01338 };
01339
01340 shutterData_t tree_data[] = {
01341 { "ntuple_s.xpm", "TNtuple", 3001, 0 },
01342 { "tree_s.xpm", "TTree", 3002, 0 },
01343 { "chain_s.xpm", "TChain", 3003, 0 },
01344 { 0, 0, 0, 0 }
01345 };
01346
01347
01348 class ShutterWindow : public TGMainFrame {
01349
01350 private:
01351 TGShutter *fShutter;
01352 TGLayoutHints *fLayout;
01353 const TGPicture *fDefaultPic;
01354
01355 public:
01356 ShutterWindow(const TGWindow *p, UInt_t w, UInt_t h);
01357
01358 void AddShutterItem(const char *name, shutterData_t *data);
01359 void ToggleShutterItem(const char *name);
01360 };
01361
01362
01363 ShutterWindow::ShutterWindow(const TGWindow *p, UInt_t w, UInt_t h) :
01364 TGMainFrame(p, w, h, kVerticalFrame)
01365 {
01366
01367
01368
01369 SetCleanup(kDeepCleanup);
01370
01371 fDefaultPic = gClient->GetPicture("folder_s.xpm");
01372 fShutter = new TGShutter(this, kSunkenFrame);
01373
01374 AddShutterItem("Histograms", histo_data);
01375 AddShutterItem("Functions", function_data);
01376 AddShutterItem("Trees", tree_data);
01377
01378 fLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
01379 AddFrame(fShutter, fLayout);
01380
01381 SetWindowName("Shutter Test");
01382 MapSubwindows();
01383 Layout();
01384 Resize(80, 300);
01385 SetWMPosition(0, 0);
01386 MapWindow();
01387 }
01388
01389
01390 void ShutterWindow::AddShutterItem(const char *name, shutterData_t *data)
01391 {
01392
01393
01394 TGShutterItem *item;
01395 TGCompositeFrame *container;
01396 TGPictureButton *button;
01397 const TGPicture *buttonpic;
01398 static int id = 5001;
01399
01400 TGLayoutHints *l = new TGLayoutHints(kLHintsTop | kLHintsCenterX,
01401 5, 5, 5, 0);
01402
01403 item = new TGShutterItem(fShutter, new TGHotString(name), id++);
01404 container = (TGCompositeFrame *) item->GetContainer();
01405
01406 for (int i=0; data[i].pixmap_name != 0; i++) {
01407 buttonpic = gClient->GetPicture(data[i].pixmap_name);
01408 if (!buttonpic) {
01409 printf("<ShutterWindow::AddShutterItem>: missing pixmap \"%s\", using default",
01410 data[i].pixmap_name);
01411 buttonpic = fDefaultPic;
01412 }
01413
01414 button = new TGPictureButton(container, buttonpic, data[i].id);
01415
01416 button->SetPicture(buttonpic);
01417 if (i == 0)
01418 button->SetState(kButtonEngaged);
01419 else if (i == 1)
01420 button->SetState(kButtonDisabled);
01421 else
01422 button->SetDisabledPicture(buttonpic);
01423
01424 container->AddFrame(button, l);
01425 button->SetToolTipText(data[i].tip_text);
01426 data[i].button = button;
01427 }
01428
01429 fShutter->AddItem(item);
01430 }
01431
01432
01433 void ShutterWindow::ToggleShutterItem(const char *name)
01434 {
01435
01436 Long_t id = fShutter->GetItem(name)->WidgetId();
01437 SendMessage(fShutter, MK_MSG(kC_COMMAND, kCM_BUTTON), id, 0);
01438 for (int i=0; i<20;i++) {
01439 gSystem->ProcessEvents();
01440 gSystem->Sleep(10);
01441 }
01442 }
01443
01444
01445 void testShutter()
01446 {
01447
01448
01449 ShutterWindow *f = new ShutterWindow(gClient->GetRoot(), 400, 200);
01450 ProcessFrame((TGMainFrame*)f, "Shutter 1");
01451 f->ToggleShutterItem("Functions");
01452 ProcessFrame((TGMainFrame*)f, "Shutter 2");
01453 f->ToggleShutterItem("Trees");
01454 ProcessFrame((TGMainFrame*)f, "Shutter 3");
01455 f->CloseWindow();
01456 }
01457
01458
01459
01460 class ProgressbarWindow : public TGMainFrame {
01461
01462 private:
01463 TGHorizontalFrame *fHframe1;
01464 TGVerticalFrame *fVframe1;
01465 TGLayoutHints *fHint1, *fHint2, *fHint3, *fHint4, *fHint5;
01466 TGHProgressBar *fHProg1, *fHProg2, *fHProg3;
01467 TGVProgressBar *fVProg1, *fVProg2;
01468 TGTextButton *fGO;
01469
01470 public:
01471 ProgressbarWindow(const TGWindow *p, UInt_t w, UInt_t h);
01472
01473 void SetValues(Int_t ver);
01474 };
01475
01476
01477 ProgressbarWindow::ProgressbarWindow(const TGWindow *p, UInt_t w, UInt_t h) :
01478 TGMainFrame(p, w, h, kHorizontalFrame)
01479 {
01480
01481
01482
01483 SetCleanup(kDeepCleanup);
01484
01485 fHframe1 = new TGHorizontalFrame(this, 0, 0, 0);
01486
01487 fVProg1 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300);
01488 fVProg1->SetBarColor("purple");
01489 fVProg2 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300);
01490 fVProg2->SetFillType(TGProgressBar::kBlockFill);
01491 fVProg2->SetBarColor("green");
01492
01493 fHframe1->Resize(300, 300);
01494
01495 fVframe1 = new TGVerticalFrame(this, 0, 0, 0);
01496
01497 fHProg1 = new TGHProgressBar(fVframe1, 300);
01498 fHProg1->ShowPosition();
01499 fHProg2 = new TGHProgressBar(fVframe1, TGProgressBar::kFancy, 300);
01500 fHProg2->SetBarColor("lightblue");
01501 fHProg2->ShowPosition(kTRUE, kFALSE, "%.0f events");
01502 fHProg3 = new TGHProgressBar(fVframe1, TGProgressBar::kStandard, 300);
01503 fHProg3->SetFillType(TGProgressBar::kBlockFill);
01504
01505 fGO = new TGTextButton(fVframe1, "Go", 10);
01506
01507 fVframe1->Resize(300, 300);
01508
01509 fHint1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 10, 5, 5);
01510 fHint2 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 10);
01511 fHint3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 0, 50, 50, 0);
01512 fHint4 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0);
01513 fHint5 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0);
01514
01515 fHframe1->AddFrame(fVProg1, fHint1);
01516 fHframe1->AddFrame(fVProg2, fHint1);
01517
01518 fVframe1->AddFrame(fHProg1, fHint2);
01519 fVframe1->AddFrame(fHProg2, fHint2);
01520 fVframe1->AddFrame(fHProg3, fHint2);
01521 fVframe1->AddFrame(fGO, fHint3);
01522
01523 AddFrame(fHframe1, fHint4);
01524 AddFrame(fVframe1, fHint5);
01525
01526 SetWindowName("Text Entries");
01527 MapSubwindows();
01528 Layout();
01529 Resize(GetDefaultSize());
01530 SetWMPosition(0, 0);
01531 MapWindow();
01532 }
01533
01534
01535 void ProgressbarWindow::SetValues(Int_t ver)
01536 {
01537
01538
01539 fVProg1->Reset(); fVProg2->Reset();
01540 fHProg1->Reset(); fHProg2->Reset(); fHProg3->Reset();
01541 if (ver == 0) {
01542 fVProg2->SetBarColor("green");
01543 fVProg1->SetPosition(25.0);
01544 fVProg2->SetPosition(50.0);
01545 fHProg1->SetPosition(0.0);
01546 fHProg2->SetPosition(25.0);
01547 fHProg3->SetPosition(50.0);
01548 }
01549 else {
01550 fVProg2->SetBarColor("red");
01551 fVProg1->SetPosition(50.0);
01552 fVProg2->SetPosition(75.0);
01553 fHProg1->SetPosition(50.0);
01554 fHProg2->SetPosition(75.0);
01555 fHProg3->SetPosition(100.0);
01556 }
01557 }
01558
01559
01560 void testProgressBar()
01561 {
01562
01563
01564 ProgressbarWindow *f = new ProgressbarWindow(gClient->GetRoot(), 600, 300);
01565 f->SetValues(0);
01566 ProcessFrame((TGMainFrame*)f, "Progress Bars 1");
01567 f->SetValues(1);
01568 ProcessFrame((TGMainFrame*)f, "Progress Bars 2");
01569 f->CloseWindow();
01570 }
01571
01572
01573
01574 class NumberEntryWindow : public TGMainFrame {
01575
01576 private:
01577 TGVerticalFrame *fF1;
01578 TGVerticalFrame *fF2;
01579 TGHorizontalFrame *fF[13];
01580 TGLayoutHints *fL1;
01581 TGLayoutHints *fL2;
01582 TGLayoutHints *fL3;
01583 TGLabel *fLabel[13];
01584 TGNumberEntry *fNumericEntries[13];
01585 TGCheckButton *fLowerLimit;
01586 TGCheckButton *fUpperLimit;
01587 TGNumberEntry *fLimits[2];
01588 TGCheckButton *fPositive;
01589 TGCheckButton *fNonNegative;
01590 TGButton *fSetButton;
01591 TGButton *fExitButton;
01592
01593 public:
01594 NumberEntryWindow(const TGWindow *p);
01595 };
01596
01597 const char *numlabel[] = {
01598 "Integer",
01599 "One digit real",
01600 "Two digit real",
01601 "Three digit real",
01602 "Four digit real",
01603 "Real",
01604 "Degree.min.sec",
01605 "Min:sec",
01606 "Hour:min",
01607 "Hour:min:sec",
01608 "Day/month/year",
01609 "Month/day/year",
01610 "Hex"
01611 };
01612
01613 const Double_t numinit[] = {
01614 12345, 1.0, 1.00, 1.000, 1.0000, 1.2E-12,
01615 90 * 3600, 120 * 60, 12 * 60, 12 * 3600 + 15 * 60,
01616 19991121, 19991121, (Double_t) 0xDEADFACEU
01617 };
01618
01619
01620 NumberEntryWindow::NumberEntryWindow(const TGWindow *p) :
01621 TGMainFrame(p, 10, 10, kHorizontalFrame)
01622 {
01623
01624
01625
01626 SetCleanup(kDeepCleanup);
01627
01628 TGGC myGC = *gClient->GetResourcePool()->GetFrameGC();
01629 TGFont *myfont = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
01630 if (myfont) myGC.SetFont(myfont->GetFontHandle());
01631
01632 fF1 = new TGVerticalFrame(this, 200, 300);
01633 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
01634 AddFrame(fF1, fL1);
01635 fL2 = new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 2, 2, 2);
01636 for (int i = 0; i < 13; i++) {
01637 fF[i] = new TGHorizontalFrame(fF1, 200, 30);
01638 fF1->AddFrame(fF[i], fL2);
01639 fNumericEntries[i] = new TGNumberEntry(fF[i], numinit[i], 12, i + 20,
01640 (TGNumberFormat::EStyle) i);
01641 fF[i]->AddFrame(fNumericEntries[i], fL2);
01642 fLabel[i] = new TGLabel(fF[i], numlabel[i], myGC(), myfont->GetFontStruct());
01643 fF[i]->AddFrame(fLabel[i], fL2);
01644 }
01645 fF2 = new TGVerticalFrame(this, 200, 500);
01646 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
01647 AddFrame(fF2, fL3);
01648 fLowerLimit = new TGCheckButton(fF2, "lower limit:", 4);
01649 fF2->AddFrame(fLowerLimit, fL3);
01650 fLimits[0] = new TGNumberEntry(fF2, 0, 12, 10);
01651 fLimits[0]->SetLogStep(kFALSE);
01652 fF2->AddFrame(fLimits[0], fL3);
01653 fUpperLimit = new TGCheckButton(fF2, "upper limit:", 5);
01654 fF2->AddFrame(fUpperLimit, fL3);
01655 fLimits[1] = new TGNumberEntry(fF2, 0, 12, 11);
01656 fLimits[1]->SetLogStep(kFALSE);
01657 fF2->AddFrame(fLimits[1], fL3);
01658 fPositive = new TGCheckButton(fF2, "Positive", 6);
01659 fF2->AddFrame(fPositive, fL3);
01660 fNonNegative = new TGCheckButton(fF2, "Non negative", 7);
01661 fF2->AddFrame(fNonNegative, fL3);
01662 fSetButton = new TGTextButton(fF2, " Set ", 2);
01663 fF2->AddFrame(fSetButton, fL3);
01664 fExitButton = new TGTextButton(fF2, " Close ", 1);
01665 fF2->AddFrame(fExitButton, fL3);
01666
01667
01668 SetWindowName("Number Entry Test");
01669 MapSubwindows();
01670 Layout();
01671 Resize(GetDefaultSize());
01672 SetWMPosition(0, 0);
01673 MapWindow();
01674 }
01675
01676
01677 void testNumberEntry()
01678 {
01679
01680
01681 NumberEntryWindow *f = new NumberEntryWindow(gClient->GetRoot());
01682 ProcessFrame((TGMainFrame*)f, "Number Entries");
01683 f->CloseWindow();
01684 }
01685
01686
01687
01688 const char *editortxt1 =
01689 "This is the ROOT text edit widget TGTextEdit. It is not intended as\n"
01690 "a full developers editor, but it is relatively complete and can ideally\n"
01691 "be used to edit scripts or to present users editable config files, etc.\n\n"
01692 "The text edit widget supports standard emacs style ctrl-key navigation\n"
01693 "in addition to the arrow keys. By default the widget has under the right\n"
01694 "mouse button a popup menu giving access to several built-in functions.\n\n"
01695 "Cut, copy and paste between different editor windows and any other\n"
01696 "standard text handling application is supported.\n\n"
01697 "Text can be selected with the mouse while holding the left button\n"
01698 "or with the arrow keys while holding the shift key pressed. Use the\n"
01699 "middle mouse button to paste text at the current mouse location."
01700 ;
01701 const char *editortxt2 =
01702 "Mice with scroll-ball are properly supported.\n\n"
01703 "This are the currently defined key bindings:\n"
01704 "Left Arrow\n"
01705 " Move the cursor one character leftwards.\n"
01706 " Scroll when cursor is out of frame.\n"
01707 "Right Arrow\n"
01708 " Move the cursor one character rightwards.\n"
01709 " Scroll when cursor is out of frame.\n"
01710 "Backspace\n"
01711 " Deletes the character on the left side of the text cursor and moves the\n"
01712 " cursor one position to the left. If a text has been marked by the user"
01713 ;
01714 const char *editortxt3 =
01715 " (e.g. by clicking and dragging) the cursor will be put at the beginning\n"
01716 " of the marked text and the marked text will be removed.\n"
01717 "Home\n"
01718 " Moves the text cursor to the left end of the line. If mark is TRUE text\n"
01719 " will be marked towards the first position, if not any marked text will\n"
01720 " be unmarked if the cursor is moved.\n"
01721 "End\n"
01722 " Moves the text cursor to the right end of the line. If mark is TRUE text\n"
01723 " will be marked towards the last position, if not any marked text will\n"
01724 " be unmarked if the cursor is moved.\n"
01725 ;
01726
01727 class EditorWindow : public TGMainFrame {
01728
01729 private:
01730 TGTextEdit *fEdit;
01731 TGTextButton *fOK;
01732 TGLayoutHints *fL1;
01733 TGLayoutHints *fL2;
01734
01735 public:
01736 EditorWindow(const TGWindow *p, UInt_t w, UInt_t h);
01737
01738 void LoadBuffer(const char *buffer);
01739 void AddBuffer(const char *buffer);
01740
01741 };
01742
01743
01744 EditorWindow::EditorWindow(const TGWindow *p, UInt_t w, UInt_t h) :
01745 TGMainFrame(p, w, h)
01746 {
01747
01748
01749
01750 SetCleanup(kDeepCleanup);
01751
01752 fEdit = new TGTextEdit(this, w, h, kSunkenFrame | kDoubleBorder);
01753 fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
01754 AddFrame(fEdit, fL1);
01755
01756
01757 Pixel_t pxl;
01758 gClient->GetColorByName("#ccccff", pxl);
01759 fEdit->SetSelectBack(pxl);
01760 fEdit->SetSelectFore(TGFrame::GetBlackPixel());
01761
01762 fOK = new TGTextButton(this, " &OK ");
01763 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
01764 AddFrame(fOK, fL2);
01765
01766 SetWindowName("Number Entry Test");
01767 MapSubwindows();
01768 Layout();
01769 Resize(GetDefaultSize());
01770 SetWMPosition(0, 0);
01771 LoadBuffer(editortxt1);
01772 AddBuffer(editortxt2);
01773 AddBuffer(editortxt3);
01774 MapWindow();
01775 }
01776
01777
01778 void EditorWindow::LoadBuffer(const char *buffer)
01779 {
01780
01781
01782 fEdit->LoadBuffer(buffer);
01783 }
01784
01785
01786 void EditorWindow::AddBuffer(const char *buffer)
01787 {
01788
01789
01790 TGText txt;
01791 txt.LoadBuffer(buffer);
01792 fEdit->AddText(&txt);
01793 }
01794
01795
01796 void testEditor()
01797 {
01798
01799
01800 EditorWindow *f = new EditorWindow(gClient->GetRoot(), 550, 400);
01801 ProcessFrame((TGMainFrame*)f, "Text Editor");
01802 f->CloseWindow();
01803 }
01804
01805
01806
01807
01808 void testCanvas()
01809 {
01810
01811
01812 TCanvas *c = new TCanvas("c", "Test Canvas", 0, 0, 800, 600);
01813 TRootCanvas *rc = (TRootCanvas *)c->GetCanvasImp();
01814 ProcessFrame((TGMainFrame*)rc, "ROOT Canvas");
01815 c->Close();
01816 delete c;
01817 }
01818
01819
01820
01821 class MyColorDialog : public TGColorDialog {
01822
01823 public:
01824 MyColorDialog(const TGWindow *p = 0, const TGWindow *m = 0, Int_t *retc = 0,
01825 Pixel_t *color = 0);
01826
01827 void Close() { CloseWindow(); }
01828 void SwitchTab(Int_t pos);
01829 };
01830
01831
01832 MyColorDialog::MyColorDialog(const TGWindow *p, const TGWindow *m, Int_t *retc,
01833 ULong_t *color) : TGColorDialog(p, m, retc, color,
01834 kFALSE)
01835 {
01836
01837
01838 SetWMPosition(0, 0);
01839 MapWindow();
01840 }
01841
01842
01843 void MyColorDialog::SwitchTab(Int_t pos)
01844 {
01845 fTab->SetTab(pos, kFALSE);
01846 }
01847
01848
01849 void testColorDlg()
01850 {
01851
01852
01853 Int_t retc = 0;
01854 ULong_t color = 0xcfcfcf;
01855 MyColorDialog *dlg = new MyColorDialog(gClient->GetDefaultRoot(),
01856 gClient->GetDefaultRoot(),
01857 &retc, &color);
01858 ProcessFrame((TGMainFrame*)dlg, "Color Dialog 1");
01859 dlg->SwitchTab(1);
01860 ProcessFrame((TGMainFrame*)dlg, "Color Dialog 2");
01861 dlg->Close();
01862 delete dlg;
01863 }
01864
01865
01866
01867
01868 void testFontDlg()
01869 {
01870
01871
01872 TGFontDialog::FontProp_t prop;
01873 TGFontDialog *dlg = new TGFontDialog(gClient->GetDefaultRoot(),
01874 gClient->GetDefaultRoot(),
01875 &prop, "", 0, kFALSE);
01876 dlg->SetWMPosition(0, 0);
01877 dlg->MapWindow();
01878 ProcessFrame((TGMainFrame*)dlg, "Font Dialog");
01879 delete dlg;
01880 }
01881
01882
01883
01884
01885 void testSearchDlg()
01886 {
01887
01888
01889 Int_t retc = 0;
01890 TGSearchType sstruct;
01891 sstruct.fClose = kFALSE;
01892 TGSearchDialog *dlg = new TGSearchDialog(gClient->GetDefaultRoot(),
01893 gClient->GetDefaultRoot(),
01894 1, 1, &sstruct, &retc);
01895 dlg->SetWMPosition(0, 0);
01896 dlg->MapWindow();
01897 ProcessFrame((TGMainFrame*)dlg, "Search Dialog");
01898 delete dlg;
01899 }
01900
01901
01902
01903 class LabelEntry : public TGCompositeFrame {
01904 public:
01905 TGLabel * fLabel;
01906 TGNumberEntry * fNumberEntry;
01907 TGTextButton * fTextButton1, * fTextButton2;
01908 TGTableLayout * tabLayout;
01909
01910 public:
01911 LabelEntry(const TGWindow * parent, Int_t Width, Int_t Height);
01912 };
01913
01914
01915 LabelEntry::LabelEntry(const TGWindow * parent, Int_t Width, Int_t Height) :
01916 TGCompositeFrame(parent, Width, Height)
01917 {
01918
01919 tabLayout=new TGTableLayout(this, 2,5, kFALSE);
01920 SetLayoutManager(tabLayout);
01921
01922 fLabel = new TGLabel(this, "Label");
01923 fLabel->ChangeOptions(fLabel->GetOptions() | kFixedWidth);
01924 fNumberEntry = new TGNumberEntry(this, 0., 30, 1);
01925 fTextButton1 = new TGTextButton(this, "TextButton");
01926 fTextButton2 = new TGTextButton(this, "TextButton2");
01927
01928 AddFrame(fLabel, new TGTableLayoutHints(0,1,0,2,
01929 kLHintsExpandX | kLHintsExpandY |
01930 kLHintsCenterX | kLHintsCenterY |
01931 kLHintsFillX | kLHintsFillY,
01932 1, 1, 1, 1));
01933 AddFrame(fNumberEntry, new TGTableLayoutHints(1,2,0,2,
01934 kLHintsExpandX | kLHintsExpandY |
01935 kLHintsCenterX | kLHintsCenterY |
01936 kLHintsFillX|kLHintsFillY,
01937 1, 1, 1, 1));
01938 AddFrame(fTextButton1, new TGTableLayoutHints(2,3,0,1,
01939 kLHintsExpandX | kLHintsExpandY |
01940 kLHintsCenterX | kLHintsCenterY |
01941 kLHintsFillX | kLHintsFillY,
01942 1, 1, 1, 1));
01943 AddFrame(fTextButton2, new TGTableLayoutHints(2,3,1,2,
01944 kLHintsExpandX | kLHintsExpandY |
01945 kLHintsCenterX | kLHintsCenterY |
01946 kLHintsFillX | kLHintsFillY,
01947 1, 1, 1, 1));
01948
01949 Layout();
01950 Resize(Width, Height);
01951 ChangeOptions(GetOptions() | kFixedWidth);
01952 }
01953
01954
01955 void testTableLayout()
01956 {
01957
01958
01959 LabelEntry *l1, *l2;
01960 TGMainFrame *mf = new TGMainFrame (gClient->GetRoot(), 700, 200);
01961 mf->SetCleanup(kDeepCleanup);
01962
01963 l1= new LabelEntry(mf, 500, 60);
01964 l2= new LabelEntry(mf, 600, 70);
01965 mf->AddFrame(l1);
01966 mf->AddFrame(l2);
01967 mf->SetWindowName("Test Table Layout");
01968 mf->MapSubwindows();
01969 mf->Layout();
01970 mf->Resize(600, 130);
01971 mf->SetWMPosition(0, 0);
01972 mf->MapWindow();
01973 ProcessFrame((TGMainFrame*)mf, "Table Layout");
01974 mf->CloseWindow();
01975 }
01976
01977
01978
01979
01980 void testPack()
01981 {
01982
01983
01984 TGPack *hp = 0;
01985 TGPack *vp = 0;
01986 TGTextButton* b = 0;
01987
01988 TGMainFrame* mf = new TGMainFrame(0, 400, 300);
01989 mf->SetCleanup(kDeepCleanup);
01990 mf->SetWindowName("Foo");
01991
01992 hp = new TGPack(mf, mf->GetWidth(), mf->GetHeight());
01993 hp->SetVertical(kFALSE);
01994
01995 b = new TGTextButton(hp, "Ailaaha"); hp->AddFrame(b);
01996
01997 vp = new TGPack(hp, hp->GetWidth(), hp->GetHeight());
01998 b = new TGTextButton(vp, "Blaaaaa"); vp->AddFrameWithWeight(b, 0, 5);
01999 b = new TGTextButton(vp, "Blooooo"); vp->AddFrameWithWeight(b, 0, 3);
02000 b = new TGTextButton(vp, "Bleeeee"); vp->AddFrameWithWeight(b, 0, 5);
02001 hp->AddFrame(vp, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
02002
02003 b = new TGTextButton(hp, "Cilnouk"); hp->AddFrame(b);
02004
02005 mf->AddFrame(hp, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
02006
02007 mf->MapSubwindows();
02008 mf->Layout();
02009 mf->SetWMPosition(0, 0);
02010 mf->MapWindow();
02011 gSystem->ProcessEvents();
02012 gSystem->Sleep(10);
02013 ProcessFrame((TGMainFrame*)mf, "Pack Frames");
02014 mf->CloseWindow();
02015 }
02016
02017
02018
02019 enum ESlidersIds {
02020 VSId1,
02021 HSId1,
02022 VSId2,
02023 HSId2,
02024 VSId3,
02025 HSId3
02026 };
02027
02028 class SliderWindow : public TGMainFrame {
02029
02030 private:
02031 TGVerticalFrame *fVframe1, *fVframe2, *fVframe3;
02032 TGLayoutHints *fBly, *fBfly1;
02033 TGHSlider *fHslider1;
02034 TGVSlider *fVslider1;
02035 TGDoubleVSlider *fVslider2;
02036 TGDoubleHSlider *fHslider2;
02037 TGTripleVSlider *fVslider3;
02038 TGTripleHSlider *fHslider3;
02039
02040 public:
02041 SliderWindow(const TGWindow *p, UInt_t w, UInt_t h);
02042 };
02043
02044 SliderWindow::SliderWindow(const TGWindow *p, UInt_t w, UInt_t h) :
02045 TGMainFrame(p, w, h)
02046 {
02047
02048
02049
02050 SetCleanup(kDeepCleanup);
02051
02052 ChangeOptions((GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
02053
02054 fVframe1 = new TGVerticalFrame(this, 0, 0, 0);
02055
02056 fHslider1 = new TGHSlider(fVframe1, 100, kSlider1 | kScaleBoth, HSId1);
02057 fHslider1->SetRange(0,50);
02058
02059 fVslider1 = new TGVSlider(fVframe1, 100, kSlider2 | kScaleBoth, VSId1);
02060 fVslider1->SetRange(0,8);
02061
02062 fVframe1->Resize(100, 100);
02063
02064 fVframe2 = new TGVerticalFrame(this, 0, 0, 0);
02065
02066 fHslider2 = new TGDoubleHSlider(fVframe2, 150, kDoubleScaleBoth, HSId2);
02067 fHslider2->SetRange(0,3);
02068
02069 fVslider2 = new TGDoubleVSlider(fVframe2, 100, kDoubleScaleBoth, VSId2);
02070
02071 fVslider2->SetRange(-10,10);
02072 fVframe2->Resize(100, 100);
02073
02074 fVframe3 = new TGVerticalFrame(this, 0, 0, 0);
02075
02076 fHslider3 = new TGTripleHSlider(fVframe3, 100, kDoubleScaleBoth, HSId3,
02077 kHorizontalFrame, GetDefaultFrameBackground(),
02078 kFALSE, kFALSE, kFALSE, kFALSE);
02079 fHslider3->SetRange(0.05,5.0);
02080
02081 fVslider3 = new TGTripleVSlider(fVframe3, 100, kDoubleScaleBoth, VSId3,
02082 kVerticalFrame, GetDefaultFrameBackground(),
02083 kFALSE, kFALSE, kFALSE, kFALSE);
02084 fVslider3->SetRange(0.05,5.0);
02085 fVframe3->Resize(100, 100);
02086
02087
02088 fBly = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 3, 0);
02089
02090
02091 fBfly1 = new TGLayoutHints(kLHintsTop | kLHintsRight, 20, 10, 15, 0);
02092
02093 fVframe1->AddFrame(fHslider1, fBly);
02094 fVframe1->AddFrame(fVslider1, fBly);
02095
02096 fVframe2->AddFrame(fHslider2, fBly);
02097 fVframe2->AddFrame(fVslider2, fBly);
02098
02099 fVframe3->AddFrame(fHslider3, fBly);
02100 fVframe3->AddFrame(fVslider3, fBly);
02101
02102 AddFrame(fVframe3, fBfly1);
02103 AddFrame(fVframe2, fBfly1);
02104 AddFrame(fVframe1, fBfly1);
02105
02106 SetWindowName("Slider Test");
02107 TGDimension size = GetDefaultSize();
02108 Resize(size);
02109
02110 fHslider3->SetPosition(0.15,1.5);
02111 fHslider3->SetPointerPosition(0.75);
02112
02113 fVslider3->SetPosition(0.05,2.5);
02114 fVslider3->SetPointerPosition(1.0);
02115
02116 SetWMSize(size.fWidth, size.fHeight);
02117 SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);
02118 SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
02119 kMWMDecorMinimize | kMWMDecorMenu,
02120 kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
02121 kMWMFuncMinimize,
02122 kMWMInputModeless);
02123
02124 MapSubwindows();
02125 MapWindow();
02126
02127 }
02128
02129
02130 void testSliders()
02131 {
02132
02133
02134 SliderWindow *f = new SliderWindow(gClient->GetRoot(), 400, 200);
02135 ProcessFrame((TGMainFrame*)f, "Sliders 1");
02136 f->CloseWindow();
02137 }
02138
02139
02140
02141
02142 void testBrowsers()
02143 {
02144
02145 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02146 gEnv->SetValue("Browser.Name", "TRootBrowserLite");
02147 TBrowser *b = new TBrowser();
02148 gSystem->RedirectOutput(0, 0, &gRH);
02149 TGMainFrame *f = (TGMainFrame *)b->GetBrowserImp()->GetMainFrame();
02150 if (f) {
02151 ProcessFrame((TGMainFrame*)f, "Root Browser Lite");
02152 f->CloseWindow();
02153 }
02154 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02155 gEnv->SetValue("Browser.Name", "TRootBrowser");
02156 b = new TBrowser();
02157 gSystem->RedirectOutput(0, 0, &gRH);
02158 f = (TGMainFrame *)b->GetBrowserImp()->GetMainFrame();
02159 if (f) {
02160 ProcessFrame((TGMainFrame*)f, "Root Browser");
02161 f->CloseWindow();
02162 }
02163 }
02164
02165
02166
02167
02168 void testSplitFrame()
02169 {
02170
02171
02172 TGMainFrame *mf = new TGMainFrame(gClient->GetDefaultRoot(), 200, 200);
02173 mf->SetCleanup(kDeepCleanup);
02174 TGSplitFrame *first = new TGSplitFrame(mf, 200, 200);
02175 mf->AddFrame(first, new TGLayoutHints(kLHintsExpandX | kLHintsExpandX, 0, 0, 0, 0));
02176 first->HSplit();
02177 first->GetFirst()->VSplit();
02178 first->GetSecond()->VSplit();
02179 first->GetSecond()->GetSecond()->SetEditable();
02180 new TGTextEditor("stressGUI.cxx", gClient->GetRoot());
02181 first->GetSecond()->GetSecond()->SetEditable(kFALSE);
02182 mf->MapSubwindows();
02183 mf->Resize(600, 400);
02184 mf->SetWMPosition(0, 0);
02185 mf->MapWindow();
02186 ProcessFrame(mf, "Split Frame 1");
02187 mf->CloseWindow();
02188 }
02189
02190
02191
02192
02193 void testControlBars()
02194 {
02195
02196
02197 TControlBar *bar = new TControlBar("vertical", "Demos",10,10);
02198 bar->AddButton("Help Demos",".x demoshelp.C", "Click Here For Help on Running the Demos");
02199 bar->AddButton("browser", "new TBrowser;", "Start the ROOT Browser");
02200 bar->AddButton("framework", ".x graphics/framework.C","An Example of Object Oriented User Interface");
02201 bar->AddButton("first", ".x graphics/first.C", "An Example of Slide with Root");
02202 bar->AddButton("hsimple", ".x hsimple.C", "An Example Creating Histograms/Ntuples on File");
02203 bar->AddButton("hsum", ".x hist/hsum.C", "Filling Histograms and Some Graphics Options");
02204 bar->AddButton("formula1", ".x graphics/formula1.C","Simple Formula and Functions");
02205 bar->AddButton("surfaces", ".x graphs/surfaces.C", "Surface Drawing Options");
02206 bar->AddButton("fillrandom",".x hist/fillrandom.C", "Histograms with Random Numbers from a Function");
02207 bar->AddButton("fit1", ".x fit/fit1.C", "A Simple Fitting Example");
02208 bar->AddButton("multifit", ".x fit/multifit.C", "Fitting in Subranges of Histograms");
02209 bar->AddButton("h1draw", ".x hist/h1draw.C", "Drawing Options for 1D Histograms");
02210 bar->AddButton("graph", ".x graphs/graph.C", "Example of a Simple Graph");
02211 bar->AddButton("gerrors", ".x graphs/gerrors.C", "Example of a Graph with Error Bars");
02212 bar->AddButton("tornado", ".x graphics/tornado.C", "Examples of 3-D PolyMarkers");
02213 bar->AddButton("shapes", ".x geom/shapes.C", "The Geometry Shapes");
02214 bar->AddButton("geometry", ".x geom/geometry.C", "Creation of the NA49 Geometry File");
02215 bar->AddButton("na49view", ".x geom/na49view.C", "Two Views of the NA49 Detector Geometry");
02216 bar->AddButton("file", ".x io/file.C", "The ROOT File Format");
02217 bar->AddButton("fildir", ".x io/fildir.C", "The ROOT File, Directories and Keys");
02218 bar->AddButton("tree", ".x tree/tree.C", "The Tree Data Structure");
02219 bar->AddButton("ntuple1", ".x tree/ntuple1.C", "Ntuples and Selections");
02220 bar->AddButton("rootmarks", ".x rootmarks.C", "Prints an Estimated ROOTMARKS for Your Machine");
02221 bar->SetButtonWidth(90);
02222 bar->Show();
02223 TControlBarImp *imp = bar->GetControlBarImp();
02224 TGMainFrame *f = dynamic_cast<TGMainFrame*>(imp);
02225 if (f) {
02226 ProcessFrame(f, "Control Bar");
02227 f->CloseWindow();
02228 }
02229 }
02230
02231
02232
02233
02234 void testHelpDialog()
02235 {
02236
02237
02238 TRootHelpDialog *hd = new TRootHelpDialog(gClient->GetRoot(), "About ROOT...", 600, 400);
02239 hd->SetText(gHelpAbout);
02240 hd->Popup();
02241 ProcessFrame((TGMainFrame *)hd, "Help Dialog");
02242 hd->CloseWindow();
02243 }
02244
02245
02246
02247
02248 void testPaletteEditor()
02249 {
02250
02251
02252 const char *fname = "galaxy.root";
02253 TFile *gal = 0;
02254 if (!gSystem->AccessPathName(fname)) {
02255 gal = TFile::Open(fname);
02256 } else {
02257 gal = TFile::Open(Form("http://root.cern.ch/files/%s",fname));
02258 }
02259 if (!gal) return;
02260 TImage *img = (TImage*)gal->Get("n4254");
02261
02262
02263 TASPaletteEditor *f = new TASPaletteEditor((TAttImage *)img, 80, 25);
02264 ProcessFrame((TGMainFrame*)f, "Palette Editor");
02265 f->CloseWindow();
02266
02267 delete img;
02268 }
02269
02270
02271
02272
02273 void testHtmlBrowser()
02274 {
02275
02276
02277 TGHtmlBrowser *b = new TGHtmlBrowser("http://bellenot.web.cern.ch/bellenot/Public/html_test/html_test.html");
02278 ProcessFrame((TGMainFrame*)b, "HTML Browser 1");
02279 b->Selected("http://bellenot.web.cern.ch/bellenot/Public/html_test/gallery/");
02280 ProcessFrame((TGMainFrame*)b, "HTML Browser 2");
02281 b->CloseWindow();
02282 }
02283
02284
02285
02286
02287
02288
02289 const char *excluded[] = {
02290 "_playback",
02291 "QtFileDialog",
02292 "QtMultiFileDialog",
02293 "QtPrintDialog",
02294 "calendar",
02295 "customTH1Fmenu",
02296 "exec_macro",
02297 "guitest0",
02298 0
02299 };
02300
02301
02302 Int_t bexec(TString &dir, const char *macro)
02303 {
02304
02305
02306 #ifdef WIN32
02307 return gSystem->Exec(TString::Format("set ROOT_HIST=0 & root.exe -l -q exec_macro.C(\\\"%s/%s\\\") >nul 2>&1", dir.Data(), macro));
02308 #else
02309 return gSystem->Exec(TString::Format("ROOT_HIST=0 root.exe -l -q exec_macro.C\\(\\\"%s/%s\\\"\\) >&/dev/null", dir.Data(), macro));
02310 #endif
02311 }
02312
02313
02314 void run_tutorials()
02315 {
02316
02317
02318 gClient->HandleInput();
02319 gSystem->Sleep(50);
02320 gSystem->ProcessEvents();
02321 TString dir = gRootSys + "/tutorials/gui";
02322 TString savdir = gSystem->WorkingDirectory();
02323 TSystemDirectory sysdir(dir.Data(), dir.Data());
02324 TList *files = sysdir.GetListOfFiles();
02325
02326 dir = gRootSys + "/tutorials";
02327 TString reqfile = dir + "/hsimple.root";
02328 if (gSystem->AccessPathName(reqfile, kFileExists)) {
02329 bexec(dir, "hsimple.C");
02330 gSystem->Unlink("hsimple_1.png");
02331 }
02332 dir += "/tree";
02333 reqfile = dir + "/cernstaff.root";
02334 if (gSystem->AccessPathName(reqfile, kFileExists)) {
02335 bexec(dir, "cernbuild.C");
02336 }
02337 dir = gRootSys + "/tutorials/gui";
02338
02339 if (files) {
02340 TIter next(files);
02341 TSystemFile *file;
02342 TString fname;
02343
02344 while ((file=(TSystemFile*)next())) {
02345 fname = file->GetName();
02346 if (!file->IsDirectory() && fname.EndsWith(".C")) {
02347 Bool_t skip = kFALSE;
02348 for (int i=0; excluded[i]; i++) {
02349 if (strstr(fname, excluded[i])) {
02350 skip = kTRUE;
02351 break;
02352 }
02353 }
02354 if (!skip) {
02355 bexec(dir, fname.Data());
02356 ProcessMacro(fname.Data(), fname.Data());
02357 }
02358 }
02359 }
02360 delete files;
02361 }
02362 dir = gRootSys + "/tutorials/image";
02363 bexec(dir, "galaxy_image.C");
02364 ProcessMacro("galaxy_image.C", "galaxy_image.C");
02365
02366 gSystem->ChangeDirectory(savdir.Data());
02367 }
02368
02369
02370
02371
02372
02373
02374 Int_t file_size(const char *filename)
02375 {
02376
02377 FILE *lunin;
02378 Int_t c, wc = 0;
02379
02380 lunin = fopen(filename, "rb");
02381 if (lunin == 0) return -1;
02382 while (!feof(lunin)) {
02383 c = fgetc(lunin);
02384 if (c != 0x0d && c != 0x0a)
02385 wc++;
02386 }
02387 fclose(lunin);
02388 return wc;
02389 }
02390
02391
02392 void guitest_playback()
02393 {
02394 Int_t i;
02395 Bool_t ret;
02396 TRecorder r;
02397 Int_t guitest_ref[11], guitest_err[11], guitest_size[11];
02398
02399 printf("Guitest Playback..............................................");
02400 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02401 TString savdir = gSystem->WorkingDirectory();
02402 TString dir = gRootSys + "/tutorials/gui";
02403 gSystem->ChangeDirectory(dir.Data());
02404
02405
02406 for (i=0;i<11;++i) {
02407 gSystem->Unlink(TString::Format("%s/guitest%03d.C", dir.Data(), i+1));
02408 }
02409 TStopwatch sw;
02410 ret = r.Replay("http://root.cern.ch/files/guitest_playback.root");
02411
02412
02413 while (ret && r.GetState() == TRecorder::kReplaying) {
02414 gSystem->ProcessEvents();
02415 gSystem->Sleep(1);
02416 if (sw.RealTime() > 600.0) {
02417 r.ReplayStop();
02418 ret = kFALSE;
02419 }
02420 sw.Continue();
02421 }
02422
02423 gSystem->RedirectOutput(0, 0, &gRH);
02424 if (ret) printf("... DONE\n");
02425 else printf(". FAILED\n");
02426 CloseMainframes();
02427 for (i=0;i<11;++i) {
02428 guitest_ref[i] = 0;
02429 guitest_err[i] = 100;
02430 guitest_size[i] = file_size(TString::Format("%s/guitest%03d.C",
02431 dir.Data(), i+1));
02432 }
02433 guitest_ref[0] = 24957;
02434 guitest_ref[1] = 6913;
02435 guitest_ref[2] = 16402;
02436 guitest_ref[3] = 10688;
02437 guitest_ref[4] = 6554;
02438 guitest_ref[5] = 24239;
02439 guitest_ref[6] = 25069;
02440 guitest_ref[7] = 25126;
02441 guitest_ref[8] = 25175;
02442 guitest_ref[9] = 25324;
02443 guitest_ref[10] = 68657;
02444 for (i=0;i<11;++i) {
02445 printf("guitest %02d: output............................................", i+1);
02446 if (TMath::Abs(guitest_ref[i] - guitest_size[i]) <= guitest_err[i]) {
02447 printf("..... OK\n");
02448
02449 gSystem->Unlink(TString::Format("%s/guitest%03d.C", dir.Data(), i+1));
02450 }
02451 else {
02452 printf(". FAILED\n");
02453 printf(" File Size = %d\n", guitest_size[i]);
02454 printf(" Ref Size = %d\n", guitest_ref[i]);
02455 }
02456 }
02457 gSystem->ChangeDirectory(savdir.Data());
02458 }
02459
02460
02461
02462
02463 void dnd_playback()
02464 {
02465 Bool_t ret;
02466 TRecorder r;
02467 printf("Drag and Drop Playback........................................");
02468 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02469 TString savdir = gSystem->WorkingDirectory();
02470 TString filename = "http://bellenot.web.cern.ch/bellenot/recorder/dnd_playback";
02471 #ifdef WIN32
02472 filename += "_win.root";
02473 #else
02474 filename += "_x11.root";
02475 #endif
02476 TString dir = gRootSys + "/tutorials/gui";
02477 gSystem->ChangeDirectory(dir.Data());
02478
02479 TStopwatch sw;
02480 ret = r.Replay(filename.Data());
02481
02482
02483 while (ret && r.GetState() == TRecorder::kReplaying) {
02484 gSystem->ProcessEvents();
02485 gSystem->Sleep(1);
02486
02487 if (sw.RealTime() > 180.0) {
02488 r.ReplayStop();
02489 ret = kFALSE;
02490 }
02491 sw.Continue();
02492 }
02493 gSystem->RedirectOutput(0, 0, &gRH);
02494 if (ret) printf("... DONE\n");
02495 else printf(". FAILED\n");
02496 CloseMainframes();
02497 gSystem->ChangeDirectory(savdir.Data());
02498 }
02499
02500
02501
02502
02503 void mditest_playback()
02504 {
02505 Bool_t ret;
02506 TRecorder r;
02507 printf("MDI Test Playback.............................................");
02508 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02509 TString savdir = gSystem->WorkingDirectory();
02510 TString dir = gRootSys + "/tutorials/gui";
02511 gSystem->ChangeDirectory(dir.Data());
02512
02513 TStopwatch sw;
02514 ret = r.Replay("http://bellenot.web.cern.ch/bellenot/recorder/mditest_playback.root");
02515
02516
02517 while (ret && r.GetState() == TRecorder::kReplaying) {
02518 gSystem->ProcessEvents();
02519 gSystem->Sleep(1);
02520
02521 if (sw.RealTime() > 180.0) {
02522 r.ReplayStop();
02523 ret = kFALSE;
02524 }
02525 sw.Continue();
02526 }
02527 gSystem->RedirectOutput(0, 0, &gRH);
02528 if (ret) printf("... DONE\n");
02529 else printf(". FAILED\n");
02530 CloseMainframes();
02531 gSystem->ChangeDirectory(savdir.Data());
02532 }
02533
02534
02535
02536
02537 void graph_edit_playback()
02538 {
02539 Bool_t ret;
02540 TRecorder r;
02541 printf("Graphic Editors Playback......................................");
02542 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02543 TString savdir = gSystem->WorkingDirectory();
02544 TString dir = gRootSys + "/tutorials/graphics";
02545 gSystem->ChangeDirectory(dir.Data());
02546
02547 TStopwatch sw;
02548 ret = r.Replay("http://root.cern.ch/files/graphedit_playback.root");
02549
02550
02551 while (ret && r.GetState() == TRecorder::kReplaying) {
02552 gSystem->ProcessEvents();
02553 gSystem->Sleep(1);
02554
02555 if (sw.RealTime() > 300.0) {
02556 r.ReplayStop();
02557 ret = kFALSE;
02558 }
02559 sw.Continue();
02560 }
02561 gSystem->RedirectOutput(0, 0, &gRH);
02562 if (ret) printf("... DONE\n");
02563 else printf(". FAILED\n");
02564 CloseMainframes();
02565 gSystem->ChangeDirectory(savdir.Data());
02566 }
02567
02568
02569
02570
02571 void fitpanel_playback()
02572 {
02573 Bool_t ret;
02574 TRecorder r;
02575 printf("Fit Panel Playback ...........................................");
02576 gSystem->RedirectOutput(gTmpfilename.Data(), "w", &gRH);
02577 TString savdir = gSystem->WorkingDirectory();
02578 TString dir = gRootSys + "/tutorials/fit";
02579 gSystem->ChangeDirectory(dir.Data());
02580
02581 TStopwatch sw;
02582 ret = r.Replay("http://root.cern.ch/files/fitpanel_playback.root");
02583
02584
02585 while (ret && r.GetState() == TRecorder::kReplaying) {
02586 gSystem->ProcessEvents();
02587 gSystem->Sleep(1);
02588
02589 if (sw.RealTime() > 300.0) {
02590 r.ReplayStop();
02591 ret = kFALSE;
02592 }
02593 sw.Continue();
02594 }
02595 gSystem->RedirectOutput(0, 0, &gRH);
02596 if (ret) printf("... DONE\n");
02597 else printf(". FAILED\n");
02598 CloseMainframes();
02599 gSystem->ChangeDirectory(savdir.Data());
02600 }
02601