Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
guitest.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_gui
3/// Test program for ROOT native GUI classes
4/// Exactly like $ROOTSYS/test/guitest.cxx but using the new signal and slots communication mechanism.
5/// It is now possible to run this entire test program in the interpreter.
6/// Do either:
7/// ~~~{.cpp}
8/// .x guitest.C
9/// .x guitest.C++
10/// ~~~
11///
12/// \macro_code
13///
14/// \authors Ilka Antcheva, Bertrand Bellenot, Fons Rademakers, Valeri Onuchin
15
16#include <cstdlib>
17
18#include <TROOT.h>
19#include <TClass.h>
20#include <TApplication.h>
21#include <TVirtualX.h>
22#include <TVirtualPadEditor.h>
23#include <TGResourcePool.h>
24#include <TGListBox.h>
25#include <TGListTree.h>
26#include <TGFSContainer.h>
27#include <TGClient.h>
28#include <TGFrame.h>
29#include <TGIcon.h>
30#include <TGLabel.h>
31#include <TGButton.h>
32#include <TGTextEntry.h>
33#include <TGNumberEntry.h>
34#include <TGMsgBox.h>
35#include <TGMenu.h>
36#include <TGCanvas.h>
37#include <TGComboBox.h>
38#include <TGTab.h>
39#include <TGSlider.h>
40#include <TGDoubleSlider.h>
41#include <TGFileDialog.h>
42#include <TGTextEdit.h>
43#include <TGShutter.h>
44#include <TGProgressBar.h>
45#include <TGColorSelect.h>
46#include <RQ_OBJECT.h>
47#include <TRootEmbeddedCanvas.h>
48#include <TCanvas.h>
49#include <TColor.h>
50#include <TH1.h>
51#include <TH2.h>
52#include <TRandom.h>
53#include <TSystem.h>
54#include <TSystemDirectory.h>
55#include <TEnv.h>
56#include <TFile.h>
57#include <TKey.h>
58#include <TGDockableFrame.h>
59#include <TGFontDialog.h>
60
61enum ETestCommandIdentifiers {
62 M_FILE_OPEN,
63 M_FILE_SAVE,
64 M_FILE_SAVEAS,
65 M_FILE_PRINT,
66 M_FILE_PRINTSETUP,
67 M_FILE_EXIT,
68
69 M_TEST_DLG,
70 M_TEST_MSGBOX,
71 M_TEST_SLIDER,
72 M_TEST_SHUTTER,
73 M_TEST_DIRLIST,
74 M_TEST_FILELIST,
75 M_TEST_PROGRESS,
76 M_TEST_NUMBERENTRY,
77 M_TEST_FONTDIALOG,
78 M_TEST_NEWMENU,
79
80 M_VIEW_ENBL_DOCK,
81 M_VIEW_ENBL_HIDE,
82 M_VIEW_DOCK,
83 M_VIEW_UNDOCK,
84
85 M_HELP_CONTENTS,
86 M_HELP_SEARCH,
87 M_HELP_ABOUT,
88
89 M_CASCADE_1,
90 M_CASCADE_2,
91 M_CASCADE_3,
92
93 M_NEW_REMOVEMENU,
94
95 VId1,
96 HId1,
97 VId2,
98 HId2,
99
100 VSId1,
101 HSId1,
102 VSId2,
103 HSId2
104};
105
106Int_t mb_button_id[13] = {kMBYes, kMBNo, kMBOk, kMBApply, kMBRetry, kMBIgnore, kMBCancel,
108
110
111const char *filetypes[] = {"All files", "*", "ROOT files", "*.root", "ROOT macros",
112 "*.C", "Text files", "*.[tT][xX][tT]", nullptr, nullptr};
113
114struct shutterData_t {
115 const char *pixmap_name;
116 const char *tip_text;
117 Int_t id;
119};
120
121shutterData_t histo_data[] = {{"h1_s.xpm", "TH1", 1001, nullptr},
122 {"h2_s.xpm", "TH2", 1002, nullptr},
123 {"h3_s.xpm", "TH3", 1003, nullptr},
124 {"profile_s.xpm", "TProfile", 1004, nullptr},
125 {nullptr, nullptr, 0, nullptr}};
126
127shutterData_t function_data[] = {
128 {"f1_s.xpm", "TF1", 2001, nullptr}, {"f2_s.xpm", "TF2", 2002, nullptr}, {nullptr, nullptr, 0, nullptr}};
129
130shutterData_t tree_data[] = {{"ntuple_s.xpm", "TNtuple", 3001, nullptr},
131 {"tree_s.xpm", "TTree", 3002, nullptr},
132 {"chain_s.xpm", "TChain", 3003, nullptr},
133 {nullptr, nullptr, 0, nullptr}};
134
135const char *editortxt1 = "This is the ROOT text edit widget TGTextEdit. It is not intended as\n"
136 "a full developers editor, but it is relatively complete and can ideally\n"
137 "be used to edit scripts or to present users editable config files, etc.\n\n"
138 "The text edit widget supports standard emacs style ctrl-key navigation\n"
139 "in addition to the arrow keys. By default the widget has under the right\n"
140 "mouse button a popup menu giving access to several built-in functions.\n\n"
141 "Cut, copy and paste between different editor windows and any other\n"
142 "standard text handling application is supported.\n\n"
143 "Text can be selected with the mouse while holding the left button\n"
144 "or with the arrow keys while holding the shift key pressed. Use the\n"
145 "middle mouse button to paste text at the current mouse location.";
146const char *editortxt2 = "Mice with scroll-ball are properly supported.\n\n"
147 "This are the currently defined key bindings:\n"
148 "Left Arrow\n"
149 " Move the cursor one character leftwards.\n"
150 " Scroll when cursor is out of frame.\n"
151 "Right Arrow\n"
152 " Move the cursor one character rightwards.\n"
153 " Scroll when cursor is out of frame.\n"
154 "Backspace\n"
155 " Deletes the character on the left side of the text cursor and moves the\n"
156 " cursor one position to the left. If a text has been marked by the user";
157const char *editortxt3 = " (e.g. by clicking and dragging) the cursor will be put at the beginning\n"
158 " of the marked text and the marked text will be removed.\n"
159 "Home\n"
160 " Moves the text cursor to the left end of the line. If mark is TRUE text\n"
161 " will be marked towards the first position, if not any marked text will\n"
162 " be unmarked if the cursor is moved.\n"
163 "End\n"
164 " Moves the text cursor to the right end of the line. If mark is TRUE text\n"
165 " will be marked towards the last position, if not any marked text will\n"
166 " be unmarked if the cursor is moved.\n"
167 "Delete";
168const char *editortxt4 = " Deletes the character on the right side of the text cursor. If a text\n"
169 " has been marked by the user (e.g. by clicking and dragging) the cursor\n"
170 " will be put at the beginning of the marked text and the marked text will\n"
171 " be removed.\n"
172 "Shift - Left Arrow\n"
173 " Mark text one character leftwards.\n"
174 "Shift - Right Arrow\n"
175 " Mark text one character rightwards.\n"
176 "Control-A\n"
177 " Select the whole text.\n"
178 "Control-B\n"
179 " Move the cursor one character leftwards.";
180const char *editortxt5 = "Control-C\n"
181 " Copy the marked text to the clipboard.\n"
182 "Control-D\n"
183 " Delete the character to the right of the cursor.\n"
184 "Control-E\n"
185 " Move the cursor to the end of the line.\n"
186 "Control-F\n"
187 " Start Search Dialog.\n"
188 "Control-H\n"
189 " Delete the character to the left of the cursor.\n"
190 "Control-K\n"
191 " Delete marked text if any or delete all\n"
192 " characters to the right of the cursor.\n"
193 "Control-L\n"
194 " Start GoTo Line Dialog";
195const char *editortxt6 = "Control-U\n"
196 " Delete all characters on the line.\n"
197 "Control-V\n"
198 " Paste the clipboard text into line edit.\n"
199 "Control-X\n"
200 " Cut the marked text, copy to clipboard.\n"
201 "Control-Y\n"
202 " Paste the clipboard text into line edit.\n"
203 "Control-Z\n"
204 " Undo action.\n\n"
205 "All other keys with valid ASCII codes insert themselves into the line.";
206
207class TileFrame;
208
209class TestMainFrame {
210
211 RQ_OBJECT("TestMainFrame")
212
213private:
214 TGMainFrame *fMain;
215 TGDockableFrame *fMenuDock;
216 TGCompositeFrame *fStatusFrame;
217 TGCanvas *fCanvasWindow;
218 TileFrame *fContainer;
219 TGTextEntry *fTestText;
220 TGButton *fTestButton;
221 TGColorSelect *fColorSel;
222
223 TGMenuBar *fMenuBar;
224 TGPopupMenu *fMenuFile, *fMenuTest, *fMenuView, *fMenuHelp;
225 TGPopupMenu *fCascadeMenu, *fCascade1Menu, *fCascade2Menu;
226 TGPopupMenu *fMenuNew1, *fMenuNew2;
227 TGLayoutHints *fMenuBarLayout, *fMenuBarItemLayout, *fMenuBarHelpLayout;
228
229public:
230 TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
231 virtual ~TestMainFrame();
232
233 // slots
234 void CloseWindow();
235 void DoButton();
236 void HandleMenu(Int_t id);
237 void HandlePopup() { printf("menu popped up\n"); }
238 void HandlePopdown() { printf("menu popped down\n"); }
239
240 void Created() { Emit("Created()"); } //*SIGNAL*
241 void Welcome() { printf("TestMainFrame has been created. Welcome!\n"); }
242};
243
244class TestDialog {
245
246 RQ_OBJECT("TestDialog")
247
248private:
249 TGTransientFrame *fMain;
250 TGCompositeFrame *fFrame1, *fF1, *fF2, *fF3, *fF4, *fF5;
251 TGGroupFrame *fF6, *fF7;
252 TGButton *fOkButton, *fCancelButton, *fStartB, *fStopB;
253 TGButton *fBtn1, *fBtn2, *fChk1, *fChk2, *fRad1, *fRad2;
254 TGPictureButton *fPicBut1;
255 TGCheckButton *fCheck1;
256 TGCheckButton *fCheckMulti;
257 TGListBox *fListBox;
258 TGComboBox *fCombo;
259 TGTab *fTab;
260 TGTextEntry *fTxt1, *fTxt2;
261 TGLayoutHints *fL1, *fL2, *fL3, *fL4;
262 TRootEmbeddedCanvas *fEc1, *fEc2;
263 Int_t fFirstEntry;
264 Int_t fLastEntry;
265 Bool_t fFillHistos;
266 TH1F *fHpx;
267 TH2F *fHpxpy;
268
269 void FillHistos();
270
271public:
272 TestDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame);
273 virtual ~TestDialog();
274
275 // slots
276 void DoClose();
277 void CloseWindow();
278 void DoOK();
279 void DoCancel();
280 void DoTab(Int_t id);
281 void HandleButtons(Int_t id = -1);
282 void HandleEmbeddedCanvas(Int_t event, Int_t x, Int_t y, TObject *sel);
283};
284
285class TestMsgBox {
286
287 RQ_OBJECT("TestMsgBox")
288
289private:
290 TGTransientFrame *fMain;
291 TGCompositeFrame *f1, *f2, *f3, *f4, *f5;
292 TGButton *fTestButton, *fCloseButton;
293 TGPictureButton *fPictButton;
294 TGRadioButton *fR[4];
295 TGCheckButton *fC[13];
296 TGGroupFrame *fG1, *fG2;
297 TGLayoutHints *fL1, *fL2, *fL3, *fL4, *fL5, *fL6, *fL21;
298 TGTextEntry *fTitle, *fMsg;
299 TGTextBuffer *fTbtitle, *fTbmsg;
300 TGLabel *fLtitle, *fLmsg;
301 TGGC fRedTextGC;
302
303public:
304 TestMsgBox(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options = kVerticalFrame);
305 virtual ~TestMsgBox();
306
307 // slots
308 void TryToClose();
309 void CloseWindow();
310 void DoClose();
311 void DoRadio();
312 void DoTest();
313};
314
315class TestSliders {
316
317 RQ_OBJECT("TestSliders")
318
319private:
320 TGTransientFrame *fMain;
321 TGVerticalFrame *fVframe1, *fVframe2;
322 TGLayoutHints *fBly, *fBfly1;
323 TGHSlider *fHslider1, *fHslider2;
324 TGVSlider *fVslider1;
325 TGDoubleVSlider *fVslider2;
326 TGTextEntry *fTeh1, *fTev1, *fTeh2, *fTev2;
327 TGTextBuffer *fTbh1, *fTbv1, *fTbh2, *fTbv2;
328
329public:
330 TestSliders(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
331 virtual ~TestSliders();
332
333 // slots
334 void CloseWindow();
335 void DoText(const char *text);
336 void DoSlider(Int_t pos = 0);
337};
338
339class TestShutter {
340
341 RQ_OBJECT("TestShutter")
342
343private:
344 TGTransientFrame *fMain;
345 TGShutter *fShutter;
346 TGLayoutHints *fLayout;
347 const TGPicture *fDefaultPic;
348
349public:
350 TestShutter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
351 ~TestShutter();
352
353 void AddShutterItem(const char *name, shutterData_t *data);
354
355 // slots
356 void CloseWindow();
357 void HandleButtons();
358};
359
360class TestDirList {
361
362 RQ_OBJECT("TestDirList")
363
364protected:
365 TGTransientFrame *fMain;
366 TGListTree *fContents;
367 const TGPicture *fIcon;
368 TString DirName(TGListTreeItem *item);
369
370public:
371 TestDirList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
372 virtual ~TestDirList();
373
374 // slots
375 void OnDoubleClick(TGListTreeItem *item, Int_t btn);
376 void CloseWindow();
377};
378
379class TestFileList {
380
381 RQ_OBJECT("TestFileList")
382
383protected:
384 TGTransientFrame *fMain;
385 TGFileContainer *fContents;
386 TGPopupMenu *fMenu;
387
388 void DisplayFile(const TString &fname);
389 void DisplayDirectory(const TString &fname);
390 void DisplayObject(const TString &fname, const TString &name);
391
392public:
393 TestFileList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
394 virtual ~TestFileList();
395
396 // slots
397 void OnDoubleClick(TGLVEntry *, Int_t);
398 void DoMenu(Int_t);
399 void CloseWindow();
400};
401
402class TestProgress {
403
404private:
405 TGTransientFrame *fMain;
406 TGHorizontalFrame *fHframe1;
407 TGVerticalFrame *fVframe1;
408 TGLayoutHints *fHint1, *fHint2, *fHint3, *fHint4, *fHint5;
409 TGHProgressBar *fHProg1, *fHProg2, *fHProg3;
410 TGVProgressBar *fVProg1, *fVProg2;
411 TGTextButton *fGO;
412 Bool_t fClose;
413
414public:
415 TestProgress(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
416 virtual ~TestProgress();
417
418 // slots
419 void CloseWindow();
420 void DoClose();
421 void DoGo();
422};
423
424class EntryTestDlg {
425
426private:
427 TGTransientFrame *fMain;
428 TGVerticalFrame *fF1;
429 TGVerticalFrame *fF2;
430 TGHorizontalFrame *fF[13];
431 TGLayoutHints *fL1;
432 TGLayoutHints *fL2;
433 TGLayoutHints *fL3;
434 TGLabel *fLabel[13];
435 TGNumberEntry *fNumericEntries[13];
436 TGCheckButton *fLowerLimit;
437 TGCheckButton *fUpperLimit;
438 TGNumberEntry *fLimits[2];
439 TGCheckButton *fPositive;
440 TGCheckButton *fNonNegative;
441 TGButton *fSetButton;
442 TGButton *fExitButton;
443
444 // static const char *const numlabel[13];
445 // static const Double_t numinit[13];
446
447public:
448 EntryTestDlg(const TGWindow *p, const TGWindow *main);
449 virtual ~EntryTestDlg();
450
451 // slots
452 void CloseWindow();
453 void SetLimits();
454 void DoOK();
455};
456
457class Editor {
458
459private:
460 TGTransientFrame *fMain; // main frame of this widget
461 TGTextEdit *fEdit; // text edit widget
462 TGTextButton *fOK; // OK button
463 TGLayoutHints *fL1; // layout of TGTextEdit
464 TGLayoutHints *fL2; // layout of OK button
465
466public:
467 Editor(const TGWindow *main, UInt_t w, UInt_t h);
468 virtual ~Editor();
469
470 void LoadFile(const char *file);
471 void LoadBuffer(const char *buffer);
472 void AddBuffer(const char *buffer);
473
474 TGTextEdit *GetEditor() const { return fEdit; }
475
476 void SetTitle();
477 void Popup();
478
479 // slots
480 void CloseWindow();
481 void DoOK();
482 void DoOpen();
483 void DoSave();
484 void DoClose();
485};
486
487class TileFrame {
488
489 RQ_OBJECT("TileFrame")
490
491private:
492 TGCompositeFrame *fFrame;
493 TGCanvas *fCanvas;
494
495public:
496 TileFrame(const TGWindow *p);
497 virtual ~TileFrame() { delete fFrame; }
498
499 TGFrame *GetFrame() const { return fFrame; }
500
501 void SetCanvas(TGCanvas *canvas) { fCanvas = canvas; }
502 void HandleMouseWheel(Event_t *event);
503};
504
505TileFrame::TileFrame(const TGWindow *p)
506{
507 // Create tile view container. Used to show colormap.
508
510 fFrame->Connect("ProcessedEvent(Event_t*)", "TileFrame", this, "HandleMouseWheel(Event_t*)");
511 fCanvas = nullptr;
512 fFrame->SetLayoutManager(new TGTileLayout(fFrame, 8));
513
514 gVirtualX->GrabButton(fFrame->GetId(), kAnyButton, kAnyModifier,
516}
517
518void TileFrame::HandleMouseWheel(Event_t *event)
519{
520 // Handle mouse wheel to scroll.
521
522 if (event->fType != kButtonPress && event->fType != kButtonRelease)
523 return;
524
525 Int_t page = 0;
526 if (event->fCode == kButton4 || event->fCode == kButton5) {
527 if (!fCanvas)
528 return;
529 if (fCanvas->GetContainer()->GetHeight())
530 page = Int_t(Float_t(fCanvas->GetViewPort()->GetHeight() * fCanvas->GetViewPort()->GetHeight()) /
531 fCanvas->GetContainer()->GetHeight());
532 }
533
534 if (event->fCode == kButton4) {
535 // scroll up
536 Int_t newpos = fCanvas->GetVsbPosition() - page;
537 if (newpos < 0)
538 newpos = 0;
539 fCanvas->SetVsbPosition(newpos);
540 }
541 if (event->fCode == kButton5) {
542 // scroll down
543 Int_t newpos = fCanvas->GetVsbPosition() + page;
544 fCanvas->SetVsbPosition(newpos);
545 }
546}
547
548TestMainFrame::TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
549{
550 // Create test main frame. A TGMainFrame is a top level window.
551
552 fMain = new TGMainFrame(p, w, h);
553
554 // use hierarchical cleaning
555 fMain->SetCleanup(kDeepCleanup);
556
557 fMain->Connect("CloseWindow()", "TestMainFrame", this, "CloseWindow()");
558
559 // Create menubar and popup menus. The hint objects are used to place
560 // and group the different menu widgets with respect to eachother.
561 fMenuDock = new TGDockableFrame(fMain);
562 fMain->AddFrame(fMenuDock, new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
563 fMenuDock->SetWindowName("GuiTest Menu");
564
565 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsExpandX);
566 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
567 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
568
569 fMenuFile = new TGPopupMenu(gClient->GetRoot());
570 fMenuFile->AddEntry("&Open...", M_FILE_OPEN);
571 fMenuFile->AddEntry("&Save", M_FILE_SAVE);
572 fMenuFile->AddEntry("S&ave as...", M_FILE_SAVEAS);
573 fMenuFile->AddEntry("&Close", -1);
574 fMenuFile->AddSeparator();
575 fMenuFile->AddEntry("&Print", M_FILE_PRINT);
576 fMenuFile->AddEntry("P&rint setup...", M_FILE_PRINTSETUP);
577 fMenuFile->AddSeparator();
578 fMenuFile->AddEntry("E&xit", M_FILE_EXIT);
579
580 fMenuFile->DisableEntry(M_FILE_SAVEAS);
581 fMenuFile->HideEntry(M_FILE_PRINT);
582
583 fCascade2Menu = new TGPopupMenu(gClient->GetRoot());
584 fCascade2Menu->AddEntry("ID = 2&3", M_CASCADE_1);
585 fCascade2Menu->AddEntry("ID = 2&4", M_CASCADE_2);
586 fCascade2Menu->AddEntry("ID = 2&5", M_CASCADE_3);
587
588 fCascade1Menu = new TGPopupMenu(gClient->GetRoot());
589 fCascade1Menu->AddEntry("ID = 4&1", 41);
590 fCascade1Menu->AddEntry("ID = 4&2", 42);
591 fCascade1Menu->AddEntry("ID = 4&3", 43);
592 fCascade1Menu->AddSeparator();
593 fCascade1Menu->AddPopup("Cascade&d 2", fCascade2Menu);
594
595 fCascadeMenu = new TGPopupMenu(gClient->GetRoot());
596 fCascadeMenu->AddEntry("ID = 5&1", 51);
597 fCascadeMenu->AddEntry("ID = 5&2", 52);
598 fCascadeMenu->AddEntry("ID = 5&3", 53);
599 fCascadeMenu->AddSeparator();
600 fCascadeMenu->AddPopup("&Cascaded 1", fCascade1Menu);
601
602 fMenuTest = new TGPopupMenu(gClient->GetRoot());
603 fMenuTest->AddLabel("Test different features...");
604 fMenuTest->AddSeparator();
605 fMenuTest->AddEntry("&Dialog...", M_TEST_DLG);
606 fMenuTest->AddEntry("&Message Box...", M_TEST_MSGBOX);
607 fMenuTest->AddEntry("&Sliders...", M_TEST_SLIDER);
608 fMenuTest->AddEntry("Sh&utter...", M_TEST_SHUTTER);
609 fMenuTest->AddEntry("&List Directory...", M_TEST_DIRLIST);
610 fMenuTest->AddEntry("&File List...", M_TEST_FILELIST);
611 fMenuTest->AddEntry("&Progress...", M_TEST_PROGRESS);
612 fMenuTest->AddEntry("&Number Entry...", M_TEST_NUMBERENTRY);
613 fMenuTest->AddEntry("F&ont Dialog...", M_TEST_FONTDIALOG);
614 fMenuTest->AddSeparator();
615 fMenuTest->AddEntry("Add New Menus", M_TEST_NEWMENU);
616 fMenuTest->AddSeparator();
617 fMenuTest->AddPopup("&Cascaded menus", fCascadeMenu);
618
619 fMenuView = new TGPopupMenu(gClient->GetRoot());
620 fMenuView->AddEntry("&Dock", M_VIEW_DOCK);
621 fMenuView->AddEntry("&Undock", M_VIEW_UNDOCK);
622 fMenuView->AddSeparator();
623 fMenuView->AddEntry("Enable U&ndock", M_VIEW_ENBL_DOCK);
624 fMenuView->AddEntry("Enable &Hide", M_VIEW_ENBL_HIDE);
625 fMenuView->DisableEntry(M_VIEW_DOCK);
626
627 fMenuDock->EnableUndock(kTRUE);
628 fMenuDock->EnableHide(kTRUE);
629 fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
630 fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
631
632 // When using the DockButton of the MenuDock,
633 // the states 'enable' and 'disable' of menus have to be updated.
634 fMenuDock->Connect("Undocked()", "TestMainFrame", this, "HandleMenu(=M_VIEW_UNDOCK)");
635
636 fMenuHelp = new TGPopupMenu(gClient->GetRoot());
637 fMenuHelp->AddEntry("&Contents", M_HELP_CONTENTS);
638 fMenuHelp->AddEntry("&Search...", M_HELP_SEARCH);
639 fMenuHelp->AddSeparator();
640 fMenuHelp->AddEntry("&About", M_HELP_ABOUT);
641
642 fMenuNew1 = new TGPopupMenu();
643 fMenuNew1->AddEntry("Remove New Menus", M_NEW_REMOVEMENU);
644
645 fMenuNew2 = new TGPopupMenu();
646 fMenuNew2->AddEntry("Remove New Menus", M_NEW_REMOVEMENU);
647
648 // Menu button messages are handled by the main frame (i.e. "this")
649 // HandleMenu() method.
650 fMenuFile->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
651 fMenuFile->Connect("PoppedUp()", "TestMainFrame", this, "HandlePopup()");
652 fMenuFile->Connect("PoppedDown()", "TestMainFrame", this, "HandlePopdown()");
653 fMenuTest->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
654 fMenuView->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
655 fMenuHelp->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
656 fCascadeMenu->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
657 fCascade1Menu->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
658 fCascade2Menu->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
659 fMenuNew1->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
660 fMenuNew2->Connect("Activated(Int_t)", "TestMainFrame", this, "HandleMenu(Int_t)");
661
662 fMenuBar = new TGMenuBar(fMenuDock, 1, 1, kHorizontalFrame);
663 fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
664 fMenuBar->AddPopup("&Test", fMenuTest, fMenuBarItemLayout);
665 fMenuBar->AddPopup("&View", fMenuView, fMenuBarItemLayout);
666 fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
667
668 fMenuDock->AddFrame(fMenuBar, fMenuBarLayout);
669
670 // Create TGCanvas and a canvas container which uses a tile layout manager
671 fCanvasWindow = new TGCanvas(fMain, 400, 240);
672 fContainer = new TileFrame(fCanvasWindow->GetViewPort());
673 fContainer->SetCanvas(fCanvasWindow);
674 fCanvasWindow->SetContainer(fContainer->GetFrame());
675
676 // use hierarchical cleaning for container
677 fContainer->GetFrame()->SetCleanup(kDeepCleanup);
678
679 // Fill canvas with 256 colored frames
680 for (int i = 0; i < 256; ++i)
681 fCanvasWindow->AddFrame(
682 new TGFrame(fCanvasWindow->GetContainer(), 32, 32, 0, TColor::RGB2Pixel(0, 0, (i + 1) & 255)),
684
685 fMain->AddFrame(fCanvasWindow, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 2, 2));
686
687 // Create status frame containing a button and a text entry widget
688 fStatusFrame = new TGCompositeFrame(fMain, 60, 20, kHorizontalFrame | kSunkenFrame);
689
690 fTestButton = new TGTextButton(fStatusFrame, "&Open editor...", 150);
691 fTestButton->Connect("Clicked()", "TestMainFrame", this, "DoButton()");
692 fTestButton->SetToolTipText("Pops up\ntext editor");
693 fStatusFrame->AddFrame(fTestButton, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 0, 2, 2));
694 fTestText = new TGTextEntry(fStatusFrame, new TGTextBuffer(100));
695 fTestText->SetToolTipText("This is a text entry widget");
696 fTestText->Resize(300, fTestText->GetDefaultHeight());
697 fStatusFrame->AddFrame(fTestText, new TGLayoutHints(kLHintsTop | kLHintsLeft, 10, 2, 2, 2));
698 Pixel_t yellow;
699 gClient->GetColorByName("yellow", yellow);
700 fColorSel = new TGColorSelect(fStatusFrame, yellow, 0);
701 fStatusFrame->AddFrame(fColorSel, new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 0, 2, 2));
702
703 fMain->AddFrame(fStatusFrame, new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 1, 0));
704
705 fMain->SetWindowName("GuiTest Signal/Slots");
706
707 fMain->MapSubwindows();
708
709 // we need to use GetDefault...() to initialize the layout algorithm...
710 fMain->Resize();
711 fMain->MapWindow();
712 fMain->Print();
713 Connect("Created()", "TestMainFrame", this, "Welcome()");
714 Created();
715}
716
717TestMainFrame::~TestMainFrame()
718{
719 // Delete all created widgets.
720
721 delete fMenuFile;
722 delete fMenuTest;
723 delete fMenuView;
724 delete fMenuHelp;
725 delete fCascadeMenu;
726 delete fCascade1Menu;
727 delete fCascade2Menu;
728 delete fMenuNew1;
729 delete fMenuNew2;
730
731 delete fContainer;
732 delete fMain;
733}
734
735void TestMainFrame::CloseWindow()
736{
737 // Got close message for this MainFrame. Terminates the application.
738
740}
741
742void TestMainFrame::DoButton()
743{
744 // Handle button click.
745
746 Editor *ed = new Editor(fMain, 600, 400);
747 ed->LoadBuffer(editortxt1);
748 ed->AddBuffer(editortxt2);
749 ed->AddBuffer(editortxt3);
750 ed->AddBuffer(editortxt4);
751 ed->AddBuffer(editortxt5);
752 ed->AddBuffer(editortxt6);
753 ed->Popup();
754}
755
756void TestMainFrame::HandleMenu(Int_t id)
757{
758 // Handle menu items.
759
760 switch (id) {
761
762 case M_FILE_OPEN: {
763 static TString dir(".");
764 TGFileInfo fi;
765 fi.fFileTypes = filetypes;
766 fi.SetIniDir(dir);
767 printf("fIniDir = %s\n", fi.fIniDir);
768 new TGFileDialog(gClient->GetRoot(), fMain, kFDOpen, &fi);
769 printf("Open file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
770 dir = fi.fIniDir;
771 } break;
772
773 case M_FILE_SAVE: printf("M_FILE_SAVE\n"); break;
774
775 case M_FILE_PRINT:
776 printf("M_FILE_PRINT\n");
777 printf("Hiding itself, select \"Print Setup...\" to enable again\n");
778 fMenuFile->HideEntry(M_FILE_PRINT);
779 break;
780
781 case M_FILE_PRINTSETUP:
782 printf("M_FILE_PRINTSETUP\n");
783 printf("Enabling \"Print\"\n");
784 fMenuFile->EnableEntry(M_FILE_PRINT);
785 break;
786
787 case M_FILE_EXIT:
788 CloseWindow(); // terminate theApp no need to use SendCloseMessage()
789 break;
790
791 case M_TEST_DLG: new TestDialog(gClient->GetRoot(), fMain, 400, 200); break;
792
793 case M_TEST_MSGBOX: new TestMsgBox(gClient->GetRoot(), fMain, 400, 200); break;
794
795 case M_TEST_SLIDER: new TestSliders(gClient->GetRoot(), fMain, 400, 200); break;
796
797 case M_TEST_SHUTTER: new TestShutter(gClient->GetRoot(), fMain, 400, 200); break;
798
799 case M_TEST_DIRLIST: new TestDirList(gClient->GetRoot(), fMain, 400, 200); break;
800
801 case M_TEST_FILELIST: new TestFileList(gClient->GetRoot(), fMain, 400, 200); break;
802
803 case M_TEST_PROGRESS: new TestProgress(gClient->GetRoot(), fMain, 600, 300); break;
804
805 case M_TEST_NUMBERENTRY: new EntryTestDlg(gClient->GetRoot(), fMain); break;
806
807 case M_TEST_FONTDIALOG: {
809 new TGFontDialog(gClient->GetRoot(), fMain, &prop);
810 if (prop.fName != "")
811 printf("Selected font: %s, size %d, italic %s, bold %s, color 0x%lx, align %u\n", prop.fName.Data(),
812 prop.fSize, prop.fItalic ? "yes" : "no", prop.fBold ? "yes" : "no", prop.fColor, prop.fAlign);
813 } break;
814
815 case M_TEST_NEWMENU: {
816 if (fMenuTest->IsEntryChecked(M_TEST_NEWMENU)) {
817 HandleMenu(M_NEW_REMOVEMENU);
818 return;
819 }
820 fMenuTest->CheckEntry(M_TEST_NEWMENU);
821 TGPopupMenu *p = fMenuBar->GetPopup("Test");
822 fMenuBar->AddPopup("New 1", fMenuNew1, fMenuBarItemLayout, p);
823 p = fMenuBar->GetPopup("Help");
824 fMenuBar->AddPopup("New 2", fMenuNew2, fMenuBarItemLayout, p);
825 fMenuBar->MapSubwindows();
826 fMenuBar->Layout();
827
828 TGMenuEntry *e = fMenuTest->GetEntry("Add New Menus");
829 fMenuTest->AddEntry("Remove New Menus", M_NEW_REMOVEMENU, nullptr, nullptr, e);
830 } break;
831
832 case M_NEW_REMOVEMENU: {
833 fMenuBar->RemovePopup("New 1");
834 fMenuBar->RemovePopup("New 2");
835 fMenuBar->Layout();
836 fMenuTest->DeleteEntry(M_NEW_REMOVEMENU);
837 fMenuTest->UnCheckEntry(M_TEST_NEWMENU);
838 } break;
839
840 case M_VIEW_ENBL_DOCK:
841 fMenuDock->EnableUndock(!fMenuDock->EnableUndock());
842 if (fMenuDock->EnableUndock()) {
843 fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
844 fMenuView->EnableEntry(M_VIEW_UNDOCK);
845 } else {
846 fMenuView->UnCheckEntry(M_VIEW_ENBL_DOCK);
847 fMenuView->DisableEntry(M_VIEW_UNDOCK);
848 }
849 break;
850
851 case M_VIEW_ENBL_HIDE:
852 fMenuDock->EnableHide(!fMenuDock->EnableHide());
853 if (fMenuDock->EnableHide()) {
854 fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
855 } else {
856 fMenuView->UnCheckEntry(M_VIEW_ENBL_HIDE);
857 }
858 break;
859
860 case M_VIEW_DOCK:
861 fMenuDock->DockContainer();
862 fMenuView->EnableEntry(M_VIEW_UNDOCK);
863 fMenuView->DisableEntry(M_VIEW_DOCK);
864 break;
865
866 case M_VIEW_UNDOCK:
867 fMenuDock->UndockContainer();
868 fMenuView->EnableEntry(M_VIEW_DOCK);
869 fMenuView->DisableEntry(M_VIEW_UNDOCK);
870 break;
871
872 default: printf("Menu item %d selected\n", id); break;
873 }
874}
875
876TestDialog::TestDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options)
877{
878 // Create a dialog window. A dialog window pops up with respect to its
879 // "main" window.
880
881 fMain = new TGTransientFrame(p, main, w, h, options);
882 fMain->Connect("CloseWindow()", "TestDialog", this, "DoClose()");
883 fMain->DontCallClose(); // to avoid double deletions.
884
885 // use hierarchical cleaning
886 fMain->SetCleanup(kDeepCleanup);
887
888 fFrame1 = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
889
890 fOkButton = new TGTextButton(fFrame1, "&Ok", 1);
891 fOkButton->Connect("Clicked()", "TestDialog", this, "DoOK()");
892 fCancelButton = new TGTextButton(fFrame1, "&Cancel", 2);
893 fCancelButton->Connect("Clicked()", "TestDialog", this, "DoCancel()");
894
895 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
896 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
897
898 fFrame1->AddFrame(fOkButton, fL1);
899 fFrame1->AddFrame(fCancelButton, fL1);
900
901 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
902 fMain->AddFrame(fFrame1, fL2);
903
904 //--------- create Tab widget and some composite frames for Tab testing
905
906 fTab = new TGTab(fMain, 300, 300);
907 fTab->Connect("Selected(Int_t)", "TestDialog", this, "DoTab(Int_t)");
908
909 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
910
911 TGCompositeFrame *tf = fTab->AddTab("Tab 1");
912 fF1 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
913 fF1->AddFrame(new TGTextButton(fF1, "&Test button", 0), fL3);
914 fF1->AddFrame(fTxt1 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
915 fF1->AddFrame(fTxt2 = new TGTextEntry(fF1, new TGTextBuffer(100)), fL3);
916 tf->AddFrame(fF1, fL3);
917 fTxt1->Resize(150, fTxt1->GetDefaultHeight());
918 fTxt2->Resize(150, fTxt2->GetDefaultHeight());
919
920 tf = fTab->AddTab("Tab 2");
921 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 200, 2, 2, 2);
922 fF2 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
923 fF2->AddFrame(fBtn1 = new TGTextButton(fF2, "&Button 1", 61), fL1);
924 fF2->AddFrame(fBtn2 = new TGTextButton(fF2, "B&utton 2", 62), fL1);
925 fF2->AddFrame(fChk1 = new TGCheckButton(fF2, "C&heck 1", 71), fL1);
926 fF2->AddFrame(fChk2 = new TGCheckButton(fF2, "Chec&k 2", 72), fL1);
927 fF2->AddFrame(fRad1 = new TGRadioButton(fF2, "&Radio 1", 81), fL1);
928 fF2->AddFrame(fRad2 = new TGRadioButton(fF2, "R&adio 2", 82), fL1);
929 fCombo = new TGComboBox(fF2, 88);
930 fF2->AddFrame(fCombo, fL3);
931
932 tf->AddFrame(fF2, fL3);
933
934 int i;
935 char tmp[20];
936 for (i = 0; i < 20; i++) {
937
938 snprintf(tmp, 20, "Entry %i", i + 1);
939 fCombo->AddEntry(tmp, i + 1);
940 }
941
942 fCombo->Resize(150, 20);
943
944 fBtn1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
945 fBtn2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
946 fChk1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
947 fChk2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
948 fRad1->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
949 fRad2->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
950
951 //-------------- embedded canvas demo
952 fFillHistos = kFALSE;
953 fHpx = nullptr;
954 fHpxpy = nullptr;
955
956 tf = fTab->AddTab("Tab 3");
957 fF3 = new TGCompositeFrame(tf, 60, 20, kHorizontalFrame);
958 fStartB = new TGTextButton(fF3, "Start &Filling Hists", 40);
959 fStopB = new TGTextButton(fF3, "&Stop Filling Hists", 41);
960 fStartB->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
961 fStopB->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
962 fF3->AddFrame(fStartB, fL3);
963 fF3->AddFrame(fStopB, fL3);
964
965 fF5 = new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
966
968 fEc1 = new TRootEmbeddedCanvas("ec1", fF5, 100, 100);
969 fF5->AddFrame(fEc1, fL4);
970 fEc2 = new TRootEmbeddedCanvas("ec2", fF5, 100, 100);
971 fF5->AddFrame(fEc2, fL4);
972
973 tf->AddFrame(fF3, fL3);
974 tf->AddFrame(fF5, fL4);
975
976 fEc1->GetCanvas()->SetBorderMode(0);
977 fEc2->GetCanvas()->SetBorderMode(0);
979 fEc1->GetCanvas()->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "TestDialog", this,
980 "HandleEmbeddedCanvas(Int_t,Int_t,Int_t,TObject*)");
981
982 // make tab yellow
983 Pixel_t yellow;
984 gClient->GetColorByName("yellow", yellow);
985 TGTabElement *tabel = fTab->GetTabTab("Tab 3");
986 tabel->ChangeBackground(yellow);
987
988 //-------------- end embedded canvas demo
989
990 TGTextButton *bt;
991 tf = fTab->AddTab("Tab 4");
992 fF4 = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
993 fF4->AddFrame(bt = new TGTextButton(fF4, "A&dd Entry", 90), fL3);
994 bt->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
995
996 fF4->AddFrame(bt = new TGTextButton(fF4, "Remove &Entry", 91), fL3);
997 bt->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
998
999 fF4->AddFrame(fListBox = new TGListBox(fF4, 89), fL3);
1000 fF4->AddFrame(fCheckMulti = new TGCheckButton(fF4, "&Mutli Selectable", 92), fL3);
1001 fCheckMulti->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
1002 tf->AddFrame(fF4, fL3);
1003
1004 for (i = 0; i < 20; ++i) {
1005 snprintf(tmp, 20, "Entry %i", i);
1006 fListBox->AddEntry(tmp, i);
1007 }
1008 fFirstEntry = 0;
1009 fLastEntry = 20;
1010
1011 fListBox->Resize(150, 80);
1012
1013 //--- tab 5
1014 tf = fTab->AddTab("Tab 5");
1016
1017 fF6 = new TGGroupFrame(tf, "Options", kVerticalFrame);
1018 fF6->SetTitlePos(TGGroupFrame::kRight); // right aligned
1019 tf->AddFrame(fF6, fL3);
1020
1021 // 2 column, n rows
1022 fF6->SetLayoutManager(new TGMatrixLayout(fF6, 0, 2, 10));
1023 char buff[100];
1024 int j;
1025 for (j = 0; j < 4; j++) {
1026 snprintf(buff, 100, "Module %i", j + 1);
1027 fF6->AddFrame(new TGLabel(fF6, new TGHotString(buff)));
1028
1029 TGTextBuffer *tbuf = new TGTextBuffer(10);
1030 tbuf->AddText(0, "0.0");
1031
1032 TGTextEntry *tent = new TGTextEntry(fF6, tbuf);
1033 tent->Resize(50, tent->GetDefaultHeight());
1034 tent->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
1035 fF6->AddFrame(tent);
1036 }
1037 fF6->Resize();
1038
1039 // another matrix with text and buttons
1040 fF7 = new TGGroupFrame(tf, "Tab Handling", kVerticalFrame);
1041 tf->AddFrame(fF7, fL3);
1042
1043 fF7->SetLayoutManager(new TGMatrixLayout(fF7, 0, 1, 10));
1044
1045 fF7->AddFrame(bt = new TGTextButton(fF7, "Remove Tab", 101));
1046 bt->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
1047 bt->Resize(90, bt->GetDefaultHeight());
1048
1049 fF7->AddFrame(bt = new TGTextButton(fF7, "Add Tab", 103));
1050 bt->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
1051 bt->Resize(90, bt->GetDefaultHeight());
1052
1053 fF7->AddFrame(bt = new TGTextButton(fF7, "Remove Tab 5", 102));
1054 bt->Connect("Clicked()", "TestDialog", this, "HandleButtons()");
1055 bt->Resize(90, bt->GetDefaultHeight());
1056
1057 fF7->Resize(fF6->GetDefaultSize());
1058
1059 //--- end of last tab
1060
1062 fMain->AddFrame(fTab, fL5);
1063
1064 fMain->MapSubwindows();
1065 fMain->Resize();
1066
1067 // position relative to the parent's window
1068 fMain->CenterOnParent();
1069
1070 fMain->SetWindowName("Dialog");
1071
1072 fMain->MapWindow();
1073 // gClient->WaitFor(fMain); // otherwise canvas contextmenu does not work
1074}
1075
1076TestDialog::~TestDialog()
1077{
1078 // Delete test dialog widgets.
1079
1080 fMain->DeleteWindow(); // deletes fMain
1081}
1082
1083void TestDialog::FillHistos()
1084{
1085 // Fill histograms till user clicks "Stop Filling" button.
1086
1087 static int cnt;
1088
1089 if (!fHpx) {
1090 fHpx = new TH1F("hpx", "This is the px distribution", 100, -4, 4);
1091 fHpxpy = new TH2F("hpxpy", "py vs px", 40, -4, 4, 40, -4, 4);
1092 fHpx->SetFillColor(kRed);
1093 cnt = 0;
1094 }
1095
1096 const int kUPDATE = 1000;
1097 float px, py;
1098 TCanvas *c1 = fEc1->GetCanvas();
1099 TCanvas *c2 = fEc2->GetCanvas();
1100
1101 while (fFillHistos) {
1102 gRandom->Rannor(px, py); // px and py will be two gaussian random numbers
1103 fHpx->Fill(px);
1104 fHpxpy->Fill(px, py);
1105 cnt++;
1106 if (!(cnt % kUPDATE)) {
1107 if (cnt == kUPDATE) {
1108 c1->cd();
1109 fHpx->Draw();
1110 c2->cd();
1111 fHpxpy->Draw("cont");
1112 }
1113 c1->Modified();
1114 c1->Update();
1115 c2->Modified();
1116 c2->Update();
1117 gSystem->ProcessEvents(); // handle GUI events
1118 }
1119 }
1120}
1121
1122void TestDialog::DoClose()
1123{
1124 printf("\nTerminating dialog: via window manager\n");
1125 if (fFillHistos) {
1126 fFillHistos = kFALSE;
1127 TTimer::SingleShot(150, "TestDialog", this, "CloseWindow()");
1128 } else
1129 CloseWindow();
1130
1131 // Close the Ged editor if it was activated.
1134}
1135
1136void TestDialog::CloseWindow()
1137{
1138 // Called when window is closed via the window manager.
1139
1140 delete this;
1141}
1142
1143void TestDialog::DoOK()
1144{
1145 fFillHistos = kFALSE;
1146 printf("\nTerminating dialog: OK pressed\n");
1147 // Add protection against double-clicks
1148 fOkButton->SetState(kButtonDisabled);
1149 fCancelButton->SetState(kButtonDisabled);
1150
1151 // Send a close message to the main frame. This will trigger the
1152 // emission of a CloseWindow() signal, which will then call
1153 // TestDialog::CloseWindow(). Calling directly CloseWindow() will cause
1154 // a segv since the OK button is still accessed after the DoOK() method.
1155 // This works since the close message is handled synchronous (via
1156 // message going to/from X server).
1157 // fMain->SendCloseMessage();
1158
1159 // The same effect can be obtained by using a singleshot timer:
1160 TTimer::SingleShot(150, "TestDialog", this, "CloseWindow()");
1161
1162 // Close the Ged editor if it was activated.
1165}
1166
1167void TestDialog::DoCancel()
1168{
1169 fFillHistos = kFALSE;
1170 printf("\nTerminating dialog: Cancel pressed\n");
1171 // Add protection against double-clicks
1172 fOkButton->SetState(kButtonDisabled);
1173 fCancelButton->SetState(kButtonDisabled);
1174 TTimer::SingleShot(150, "TestDialog", this, "CloseWindow()");
1175 // Close the Ged editor if it was activated.
1178}
1179
1180void TestDialog::HandleButtons(Int_t id)
1181{
1182 // Handle different buttons.
1183
1184 if (id == -1) {
1185 TGButton *btn = (TGButton *)gTQSender;
1186 id = btn->WidgetId();
1187 }
1188
1189 printf("DoButton: id = %d\n", id);
1190
1191 char tmp[20];
1192 static int newtab = 0;
1193
1194 switch (id) {
1195 case 40: // start histogram filling
1196 fFillHistos = kTRUE;
1197 FillHistos();
1198 break;
1199 case 41: // stop histogram filling
1200 fFillHistos = kFALSE;
1201 break;
1202 case 61: // show item 1 in the combo box
1203 fCombo->Select(1);
1204 break;
1205 case 62: // show item 2 in the combo box
1206 fCombo->Select(2);
1207 break;
1208 case 90: // add one entry in list box
1209 fLastEntry++;
1210 snprintf(tmp, 20, "Entry %i", fLastEntry);
1211 fListBox->AddEntry(tmp, fLastEntry);
1212 fListBox->MapSubwindows();
1213 fListBox->Layout();
1214 break;
1215 case 91: // remove one entry in list box
1216 if (fFirstEntry <= fLastEntry) {
1217 fListBox->RemoveEntry(fFirstEntry);
1218 fListBox->Layout();
1219 fFirstEntry++;
1220 }
1221 break;
1222 case 101: // remove tabs
1223 {
1224 TString s = fTab->GetTabTab(0)->GetString();
1225 if ((s == "Tab 3") && (fMain->MustCleanup() != kDeepCleanup)) {
1226 // Need to delete the embedded canvases
1227 // since RemoveTab() will Destroy the container
1228 // window, which in turn will destroy the embedded
1229 // canvas windows.
1230 delete fEc1;
1231 fEc1 = nullptr;
1232 delete fEc2;
1233 fEc2 = nullptr;
1234 }
1235 fTab->RemoveTab(0);
1236 fTab->Layout();
1237 } break;
1238 case 102: // remove tab 5
1239 {
1240 int nt = fTab->GetNumberOfTabs();
1241 for (int i = 0; i < nt; i++) {
1242 TString s = fTab->GetTabTab(i)->GetString();
1243 if (s == "Tab 5") {
1244 fTab->RemoveTab(i);
1245 fTab->Layout();
1246 break;
1247 }
1248 }
1249 } break;
1250 case 103: // add tabs
1251 snprintf(tmp, 20, "New Tab %d", ++newtab);
1252 fTab->AddTab(tmp);
1253 fTab->MapSubwindows();
1254 fTab->Layout();
1255 break;
1256 case 81: fRad2->SetState(kButtonUp); break;
1257 case 82: fRad1->SetState(kButtonUp); break;
1258 case 92: fListBox->SetMultipleSelections(fCheckMulti->GetState()); break;
1259 default: break;
1260 }
1261}
1262
1263void TestDialog::DoTab(Int_t id)
1264{
1265 printf("Tab item %d activated\n", id);
1266}
1267
1268void TestDialog::HandleEmbeddedCanvas(Int_t event, Int_t x, Int_t y, TObject *sel)
1269{
1270 // Handle events in the left embedded canvas.
1271
1272 if (event == kButton3Down)
1273 printf("event = %d, x = %d, y = %d, obj = %s::%s\n", event, x, y, sel->IsA()->GetName(), sel->GetName());
1274}
1275
1276TestMsgBox::TestMsgBox(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, UInt_t options)
1277 : fRedTextGC(TGButton::GetDefaultGC())
1278{
1279 // Create message box test dialog. Use this dialog to select the different
1280 // message dialog box styles and show the message dialog by clicking the
1281 // "Test" button.
1282
1283 fMain = new TGTransientFrame(p, main, w, h, options);
1284 fMain->Connect("CloseWindow()", "TestMsgBox", this, "CloseWindow()");
1285 fMain->DontCallClose(); // to avoid double deletions.
1286
1287 // use hierarchical cleaning
1288 fMain->SetCleanup(kDeepCleanup);
1289
1290 //------------------------------
1291 // Set foreground color in graphics context for drawing of
1292 // TGlabel and TGButtons with text in red.
1293
1294 Pixel_t red;
1295 gClient->GetColorByName("red", red);
1296 fRedTextGC.SetForeground(red);
1297 //---------------------------------
1298
1299 int i;
1300
1301 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
1302
1303 f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame | kFixedWidth);
1304 f2 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
1305 f3 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
1306 f4 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
1307 f5 = new TGCompositeFrame(f2, 60, 20, kHorizontalFrame);
1308
1309 fTestButton = new TGTextButton(f1, "&Test", 1, fRedTextGC());
1310 fTestButton->Connect("Clicked()", "TestMsgBox", this, "DoTest()");
1311
1312 // Change background of fTestButton to green
1313 Pixel_t green;
1314 gClient->GetColorByName("green", green);
1315 fTestButton->ChangeBackground(green);
1316
1317 fCloseButton = new TGTextButton(f1, "&Close", 2);
1318 fCloseButton->Connect("Clicked()", "TestMsgBox", this, "DoClose()");
1319
1320 fPictButton = new TGPictureButton(f1, gClient->GetPicture("mb_stop_s.xpm"));
1321
1322 f1->Resize(fTestButton->GetDefaultWidth() + 40, fMain->GetDefaultHeight());
1323
1324 fL1 = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 2, 3, 0);
1325 fL2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 5, 0, 2);
1326 fL21 = new TGLayoutHints(kLHintsTop | kLHintsRight, 2, 5, 10, 0);
1327
1328 f1->AddFrame(fTestButton, fL1);
1329 f1->AddFrame(fCloseButton, fL1);
1330 f1->AddFrame(fPictButton, fL1);
1331 fMain->AddFrame(f1, fL21);
1332
1333 //--------- create check and radio buttons groups
1334
1335 fG1 = new TGGroupFrame(f3, new TGString("Buttons"), kVerticalFrame | kRaisedFrame);
1336 fG2 = new TGGroupFrame(f3, new TGString("Icons"), kVerticalFrame | kRaisedFrame);
1337
1339 fL4 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 5, 0);
1340
1341 fC[0] = new TGCheckButton(fG1, new TGHotString("Yes"), -1);
1342 fC[1] = new TGCheckButton(fG1, new TGHotString("No"), -1);
1343 fC[2] = new TGCheckButton(fG1, new TGHotString("OK"), -1);
1344 fC[3] = new TGCheckButton(fG1, new TGHotString("Apply"), -1);
1345 fC[4] = new TGCheckButton(fG1, new TGHotString("Retry"), -1);
1346 fC[5] = new TGCheckButton(fG1, new TGHotString("Ignore"), -1);
1347 fC[6] = new TGCheckButton(fG1, new TGHotString("Cancel"), -1);
1348 fC[7] = new TGCheckButton(fG1, new TGHotString("Close"), -1);
1349 fC[8] = new TGCheckButton(fG1, new TGHotString("Yes to All"), -1);
1350 fC[9] = new TGCheckButton(fG1, new TGHotString("No to All"), -1);
1351 fC[10] = new TGCheckButton(fG1, new TGHotString("Newer Only"), -1);
1352 fC[11] = new TGCheckButton(fG1, new TGHotString("Append"), -1);
1353 fC[12] = new TGCheckButton(fG1, new TGHotString("Dismiss"), -1);
1354
1355 for (i = 0; i < 13; ++i)
1356 fG1->AddFrame(fC[i], fL4);
1357
1358 fR[0] = new TGRadioButton(fG2, new TGHotString("Stop"), 21);
1359 fR[1] = new TGRadioButton(fG2, new TGHotString("Question"), 22);
1360 fR[2] = new TGRadioButton(fG2, new TGHotString("Exclamation"), 23);
1361 fR[3] = new TGRadioButton(fG2, new TGHotString("Asterisk"), 24);
1362
1363 for (i = 0; i < 4; ++i) {
1364 fG2->AddFrame(fR[i], fL4);
1365 fR[i]->Connect("Clicked()", "TestMsgBox", this, "DoRadio()");
1366 }
1367
1368 fC[2]->SetState(kButtonDown);
1369 fR[0]->SetState(kButtonDown);
1370
1371 f3->AddFrame(fG1, fL3);
1372 f3->AddFrame(fG2, fL3);
1373
1374 fLtitle = new TGLabel(f4, new TGString("Title:"), fRedTextGC());
1375 fLmsg = new TGLabel(f5, new TGString("Message:"));
1376
1377 fTitle = new TGTextEntry(f4, fTbtitle = new TGTextBuffer(100));
1378 fMsg = new TGTextEntry(f5, fTbmsg = new TGTextBuffer(100));
1379
1380 fTbtitle->AddText(0, "MsgBox");
1381 fTbmsg->AddText(0, "This is a test message box.");
1382
1383 fTitle->Resize(300, fTitle->GetDefaultHeight());
1384 fMsg->Resize(300, fMsg->GetDefaultHeight());
1385
1386 fL5 = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 5, 0, 0);
1387 fL6 = new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 2, 0, 0);
1388
1389 f4->AddFrame(fLtitle, fL5);
1390 f4->AddFrame(fTitle, fL6);
1391 f5->AddFrame(fLmsg, fL5);
1392 f5->AddFrame(fMsg, fL6);
1393
1394 f2->AddFrame(f3, fL1);
1395 f2->AddFrame(f4, fL1);
1396 f2->AddFrame(f5, fL1);
1397
1398 fMain->AddFrame(f2, fL2);
1399
1400 fMain->MapSubwindows();
1401 fMain->Resize();
1402
1403 // position relative to the parent's window
1404 fMain->CenterOnParent();
1405
1406 fMain->SetWindowName("Message Box Test");
1407
1408 fMain->MapWindow();
1409 gClient->WaitFor(fMain);
1410}
1411
1412// Order is important when deleting frames. Delete children first,
1413// parents last.
1414
1415TestMsgBox::~TestMsgBox()
1416{
1417 // Delete widgets created by dialog.
1418
1419 fMain->DeleteWindow(); // deletes fMain
1420}
1421
1422void TestMsgBox::CloseWindow()
1423{
1424 // Close dialog in response to window manager close.
1425
1426 delete this;
1427}
1428
1429void TestMsgBox::DoClose()
1430{
1431 // Handle Close button.
1432
1433 CloseWindow();
1434}
1435
1436void TestMsgBox::DoTest()
1437{
1438 // Handle test button.
1439
1440 int i, buttons, retval;
1441 EMsgBoxIcon icontype = kMBIconStop;
1442
1443 buttons = 0;
1444 for (i = 0; i < 13; i++)
1445 if (fC[i]->GetState() == kButtonDown)
1446 buttons |= mb_button_id[i];
1447
1448 for (i = 0; i < 4; i++)
1449 if (fR[i]->GetState() == kButtonDown) {
1450 icontype = mb_icon[i];
1451 break;
1452 }
1453
1454 // Since the message dialog box is created, we disable the
1455 // signal/slot communication mechanism, in order to ensure we
1456 // can't close the fMain window while the message box is open.
1457 fMain->Disconnect("CloseWindow()");
1458 fMain->Connect("CloseWindow()", "TestMsgBox", this, "TryToClose()");
1459 new TGMsgBox(gClient->GetRoot(), fMain, fTbtitle->GetString(), fTbmsg->GetString(), icontype, buttons, &retval);
1460 fMain->Disconnect("CloseWindow()");
1461 fMain->Connect("CloseWindow()", "TestMsgBox", this, "CloseWindow()");
1462}
1463
1464void TestMsgBox::TryToClose()
1465{
1466 // The user try to close the main window,
1467 // while a message dialog box is still open.
1468 printf("Can't close the window '%s' : a message box is still open\n", fMain->GetWindowName());
1469}
1470
1471void TestMsgBox::DoRadio()
1472{
1473 // Handle radio buttons.
1474
1475 TGButton *btn = (TGButton *)gTQSender;
1476 Int_t id = btn->WidgetId();
1477
1478 if (id >= 21 && id <= 24) {
1479 for (int i = 0; i < 4; i++)
1480 if (fR[i]->WidgetId() != id)
1481 fR[i]->SetState(kButtonUp);
1482 }
1483}
1484
1485TestSliders::TestSliders(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
1486{
1487 // Dialog used to test the different supported sliders.
1488
1489 fMain = new TGTransientFrame(p, main, w, h);
1490 fMain->Connect("CloseWindow()", "TestSliders", this, "CloseWindow()");
1491 fMain->DontCallClose(); // to avoid double deletions.
1492
1493 // use hierarchical cleaning
1494 fMain->SetCleanup(kDeepCleanup);
1495
1496 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
1497
1498 fVframe1 = new TGVerticalFrame(fMain, 0, 0, 0);
1499
1500 fTeh1 = new TGTextEntry(fVframe1, fTbh1 = new TGTextBuffer(10), HId1);
1501 fTev1 = new TGTextEntry(fVframe1, fTbv1 = new TGTextBuffer(10), VId1);
1502 fTbh1->AddText(0, "0");
1503 fTbv1->AddText(0, "0");
1504
1505 fTeh1->Connect("TextChanged(char*)", "TestSliders", this, "DoText(char*)");
1506 fTev1->Connect("TextChanged(char*)", "TestSliders", this, "DoText(char*)");
1507
1508 fHslider1 = new TGHSlider(fVframe1, 100, kSlider1 | kScaleBoth, HSId1);
1509 fHslider1->Connect("PositionChanged(Int_t)", "TestSliders", this, "DoSlider(Int_t)");
1510 fHslider1->SetRange(0, 50);
1511
1512 fVslider1 = new TGVSlider(fVframe1, 100, kSlider2 | kScaleBoth, VSId1);
1513 fVslider1->Connect("PositionChanged(Int_t)", "TestSliders", this, "DoSlider(Int_t)");
1514 fVslider1->SetRange(0, 8);
1515
1516 fVframe1->Resize(100, 100);
1517
1518 fVframe2 = new TGVerticalFrame(fMain, 0, 0, 0);
1519 fTeh2 = new TGTextEntry(fVframe2, fTbh2 = new TGTextBuffer(10), HId2);
1520 fTev2 = new TGTextEntry(fVframe2, fTbv2 = new TGTextBuffer(10), VId2);
1521 fTbh2->AddText(0, "0");
1522 fTbv2->AddText(0, "0");
1523
1524 fTeh2->Connect("TextChanged(char*)", "TestSliders", this, "DoText(char*)");
1525 fTev2->Connect("TextChanged(char*)", "TestSliders", this, "DoText(char*)");
1526
1527 fHslider2 = new TGHSlider(fVframe2, 150, kSlider2 | kScaleBoth, HSId2);
1528 fHslider2->Connect("PositionChanged(Int_t)", "TestSliders", this, "DoSlider(Int_t)");
1529 fHslider2->SetRange(0, 3);
1530
1531 fVslider2 = new TGDoubleVSlider(fVframe2, 100, kDoubleScaleBoth, VSId2);
1532
1533 fVslider2->SetRange(-10, 10);
1534 fVslider2->Connect("PositionChanged()", "TestSliders", this, "DoSlider()");
1535 fVframe2->Resize(100, 100);
1536
1537 //--- layout for buttons: top align, equally expand horizontally
1538 fBly = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 3, 0);
1539
1540 //--- layout for the frame: place at bottom, right aligned
1541 fBfly1 = new TGLayoutHints(kLHintsTop | kLHintsRight, 20, 10, 15, 0);
1542
1543 fVframe1->AddFrame(fHslider1, fBly);
1544 fVframe1->AddFrame(fVslider1, fBly);
1545 fVframe1->AddFrame(fTeh1, fBly);
1546 fVframe1->AddFrame(fTev1, fBly);
1547
1548 fVframe2->AddFrame(fHslider2, fBly);
1549 fVframe2->AddFrame(fVslider2, fBly);
1550 fVframe2->AddFrame(fTeh2, fBly);
1551 fVframe2->AddFrame(fTev2, fBly);
1552
1553 fMain->AddFrame(fVframe2, fBfly1);
1554 fMain->AddFrame(fVframe1, fBfly1);
1555
1556 fMain->SetWindowName("Slider Test");
1557 TGDimension size = fMain->GetDefaultSize();
1558 fMain->Resize(size);
1559
1560 fMain->SetWMSize(size.fWidth, size.fHeight);
1561 fMain->SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);
1564
1565 // position relative to the parent's window
1566 fMain->CenterOnParent();
1567
1568 fMain->MapSubwindows();
1569 fMain->MapWindow();
1570
1571 gClient->WaitFor(fMain);
1572}
1573
1574TestSliders::~TestSliders()
1575{
1576 // Delete dialog.
1577
1578 fMain->DeleteWindow(); // deletes fMain
1579}
1580
1581void TestSliders::CloseWindow()
1582{
1583 // Called when window is closed via the window manager.
1584
1585 delete this;
1586}
1587
1588void TestSliders::DoText(const char * /*text*/)
1589{
1590 // Handle text entry widgets.
1591
1593 Int_t id = te->WidgetId();
1594
1595 switch (id) {
1596 case HId1: fHslider1->SetPosition(atoi(fTbh1->GetString())); break;
1597 case VId1: fVslider1->SetPosition(atoi(fTbv1->GetString())); break;
1598 case HId2: fHslider2->SetPosition(atoi(fTbh2->GetString())); break;
1599 case VId2: fVslider2->SetPosition(atoi(fTbv2->GetString()), atoi(fTbv2->GetString()) + 2); break;
1600 default: break;
1601 }
1602}
1603
1604void TestSliders::DoSlider(Int_t pos)
1605{
1606 // Handle slider widgets.
1607
1608 Int_t id;
1609 TGFrame *frm = (TGFrame *)gTQSender;
1610 if (frm->IsA()->InheritsFrom(TGSlider::Class())) {
1611 TGSlider *sl = (TGSlider *)frm;
1612 id = sl->WidgetId();
1613 } else {
1614 TGDoubleSlider *sd = (TGDoubleSlider *)frm;
1615 id = sd->WidgetId();
1616 }
1617
1618 char buf[32];
1619 snprintf(buf, 32, "%d", pos);
1620
1621#ifdef CINT_FIXED
1622 switch (id) {
1623 case HSId1:
1624#else
1625 if (id == HSId1) {
1626#endif
1627 fTbh1->Clear();
1628 fTbh1->AddText(0, buf);
1629 // Re-align the cursor with the characters.
1630 fTeh1->SetCursorPosition(fTeh1->GetCursorPosition());
1631 fTeh1->Deselect();
1632 gClient->NeedRedraw(fTeh1);
1633#ifdef CINT_FIXED
1634 break;
1635 case VSId1:
1636#else
1637 } else if (id == VSId1) {
1638#endif
1639 fTbv1->Clear();
1640 fTbv1->AddText(0, buf);
1641 fTev1->SetCursorPosition(fTev1->GetCursorPosition());
1642 fTev1->Deselect();
1643 gClient->NeedRedraw(fTev1);
1644#ifdef CINT_FIXED
1645 break;
1646 case HSId2:
1647#else
1648 } else if (id == HSId2) {
1649#endif
1650 fTbh2->Clear();
1651 fTbh2->AddText(0, buf);
1652 fTeh2->SetCursorPosition(fTeh2->GetCursorPosition());
1653 fTeh2->Deselect();
1654 gClient->NeedRedraw(fTeh2);
1655#ifdef CINT_FIXED
1656 break;
1657 case VSId2:
1658#else
1659 } else if (id == VSId2) {
1660#endif
1661 snprintf(buf, 32, "%f", fVslider2->GetMinPosition());
1662 fTbv2->Clear();
1663 fTbv2->AddText(0, buf);
1664 fTev2->SetCursorPosition(fTev2->GetCursorPosition());
1665 fTev2->Deselect();
1666 gClient->NeedRedraw(fTev2);
1667#ifdef CINT_FIXED
1668 break;
1669 default: break;
1670#endif
1671 }
1672}
1673
1674TestShutter::TestShutter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
1675{
1676 // Create transient frame containing a shutter widget.
1677
1678 fMain = new TGTransientFrame(p, main, w, h);
1679 fMain->Connect("CloseWindow()", "TestShutter", this, "CloseWindow()");
1680 fMain->DontCallClose(); // to avoid double deletions.
1681
1682 // use hierarchical cleaning
1683 fMain->SetCleanup(kDeepCleanup);
1684
1685 fDefaultPic = gClient->GetPicture("folder_s.xpm");
1686 fShutter = new TGShutter(fMain, kSunkenFrame);
1687
1688 AddShutterItem("Histograms", histo_data);
1689 AddShutterItem("Functions", function_data);
1690 AddShutterItem("Trees", tree_data);
1691
1693 fMain->AddFrame(fShutter, fLayout);
1694
1695 fMain->MapSubwindows();
1696 fMain->Resize(80, 300);
1697
1698 // position relative to the parent's window
1699 fMain->CenterOnParent();
1700
1701 fMain->SetWindowName("Shutter Test");
1702
1703 fMain->MapWindow();
1704 // gClient->WaitFor(fMain);
1705}
1706
1707void TestShutter::AddShutterItem(const char *name, shutterData_t *data)
1708{
1709 TGShutterItem *item;
1710 TGCompositeFrame *container;
1712 const TGPicture *buttonpic;
1713 static int id = 5001;
1714
1716
1717 item = new TGShutterItem(fShutter, new TGHotString(name), id++);
1718 container = (TGCompositeFrame *)item->GetContainer();
1719
1720 for (int i = 0; data[i].pixmap_name != nullptr; i++) {
1721 buttonpic = gClient->GetPicture(data[i].pixmap_name);
1722 if (!buttonpic) {
1723 printf("<TestShutter::AddShutterItem>: missing pixmap \"%s\", using default", data[i].pixmap_name);
1724 buttonpic = fDefaultPic;
1725 }
1726
1727 button = new TGPictureButton(container, buttonpic, data[i].id);
1728
1729 container->AddFrame(button, l);
1730 button->Connect("Clicked()", "TestShutter", this, "HandleButtons()");
1731 button->SetToolTipText(data[i].tip_text);
1732 data[i].button = button;
1733 }
1734
1735 fShutter->AddItem(item);
1736}
1737
1738TestShutter::~TestShutter()
1739{
1740 // dtor
1741
1742 gClient->FreePicture(fDefaultPic);
1743 fMain->DeleteWindow(); // deletes fMain
1744}
1745
1746void TestShutter::CloseWindow()
1747{
1748 delete this;
1749}
1750
1751void TestShutter::HandleButtons()
1752{
1753 TGButton *btn = (TGButton *)gTQSender;
1754 printf("Shutter button %d\n", btn->WidgetId());
1755}
1756
1757TestDirList::TestDirList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
1758{
1759 // Create transient frame containing a dirlist widget.
1760
1761 fMain = new TGTransientFrame(p, main, w, h);
1762 fMain->Connect("CloseWindow()", "TestDirList", this, "CloseWindow()");
1763 fMain->DontCallClose(); // to avoid double deletions.
1764
1765 fIcon = gClient->GetPicture("rootdb_t.xpm");
1766 TGLayoutHints *lo;
1767
1768 // use hierarchical cleaning
1769 fMain->SetCleanup(kDeepCleanup);
1770
1771 TGCanvas *canvas = new TGCanvas(fMain, 500, 300);
1772 fContents = new TGListTree(canvas, kHorizontalFrame);
1774 fMain->AddFrame(canvas, lo);
1775 fContents->Connect("DoubleClicked(TGListTreeItem*,Int_t)", "TestDirList", this,
1776 "OnDoubleClick(TGListTreeItem*,Int_t)");
1777 fContents->Connect("Clicked(TGListTreeItem*,Int_t)", "TestDirList", this, "OnDoubleClick(TGListTreeItem*,Int_t)");
1778#ifdef R__WIN32
1779 fContents->AddItem(0, "c:\\"); // browse the upper directory
1780#else
1781 fContents->AddItem(nullptr, "/"); // browse the upper directory
1782#endif
1783
1784 // position relative to the parent's window
1785 fMain->CenterOnParent();
1786
1787 fMain->SetWindowName("List Dir Test");
1788
1789 fMain->MapSubwindows();
1790 fMain->Resize();
1791 fMain->MapWindow();
1792}
1793
1794TestDirList::~TestDirList()
1795{
1796 // Cleanup.
1797
1798 gClient->FreePicture(fIcon);
1799 delete fContents;
1800 fMain->DeleteWindow(); // delete fMain
1801}
1802
1803void TestDirList::CloseWindow()
1804{
1805 delete this;
1806}
1807
1808TString TestDirList::DirName(TGListTreeItem *item)
1809{
1810 // Returns an absolute path.
1811
1812 TGListTreeItem *parent;
1813 TString dirname = item->GetText();
1814
1815 while ((parent = item->GetParent())) {
1816 gSystem->PrependPathName(parent->GetText(), dirname);
1817 item = parent;
1818 }
1819
1820 return dirname;
1821}
1822
1823void TestDirList::OnDoubleClick(TGListTreeItem *item, Int_t btn)
1824{
1825 // Show contents of directory.
1826
1827 if ((btn != kButton1) || !item || (Bool_t)item->GetUserData())
1828 return;
1829
1830 // use UserData to indicate that item was already browsed
1831 item->SetUserData((void *)1);
1832
1833 TSystemDirectory dir(item->GetText(), DirName(item));
1834
1835 TList *files = dir.GetListOfFiles();
1836
1837 if (files) {
1838 TIter next(files);
1839 TSystemFile *file;
1840 TString fname;
1841
1842 while ((file = (TSystemFile *)next())) {
1843 fname = file->GetName();
1844 if (file->IsDirectory()) {
1845 if ((fname != "..") && (fname != ".")) { // skip it
1846 fContents->AddItem(item, fname);
1847 }
1848 } else if (fname.EndsWith(".root")) { // add root files
1849 fContents->AddItem(item, fname, fIcon, fIcon);
1850 }
1851 }
1852 delete files;
1853 }
1854}
1855
1856TestFileList::TestFileList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
1857{
1858 // Create transient frame containing a filelist widget.
1859
1860 TGLayoutHints *lo;
1861
1862 fMain = new TGTransientFrame(p, main, w, h);
1863 fMain->Connect("CloseWindow()", "TestDirList", this, "CloseWindow()");
1864 fMain->DontCallClose(); // to avoid double deletions.
1865
1866 // use hierarchical cleaning
1867 fMain->SetCleanup(kDeepCleanup);
1868
1869 TGMenuBar *mb = new TGMenuBar(fMain);
1870 lo = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
1871 fMain->AddFrame(mb, lo);
1872
1873 fMenu = mb->AddPopup("&View");
1874 fMenu->AddEntry("Lar&ge Icons", kLVLargeIcons);
1875 fMenu->AddEntry("S&mall Icons", kLVSmallIcons);
1876 fMenu->AddEntry("&List", kLVList);
1877 fMenu->AddEntry("&Details", kLVDetails);
1878 fMenu->AddSeparator();
1879 fMenu->AddEntry("&Close", 10);
1880 fMenu->Connect("Activated(Int_t)", "TestFileList", this, "DoMenu(Int_t)");
1881
1882 TGListView *lv = new TGListView(fMain, w, h);
1884 fMain->AddFrame(lv, lo);
1885
1886 Pixel_t white;
1887 gClient->GetColorByName("white", white);
1888 fContents = new TGFileContainer(lv, kSunkenFrame, white);
1889 fContents->Connect("DoubleClicked(TGFrame*,Int_t)", "TestFileList", this, "OnDoubleClick(TGLVEntry*,Int_t)");
1890
1891 // position relative to the parent's window
1892 fMain->CenterOnParent();
1893
1894 fMain->SetWindowName("File List Test");
1895 fMain->MapSubwindows();
1896 fMain->MapWindow();
1897 fContents->SetDefaultHeaders();
1898 fContents->DisplayDirectory();
1899 fContents->AddFile(".."); // up level directory
1900 fContents->Resize();
1901 fContents->StopRefreshTimer(); // stop refreshing
1902 fMain->Resize();
1903}
1904
1905TestFileList::~TestFileList()
1906{
1907 // Cleanup.
1908
1909 delete fContents;
1910 fMain->DeleteWindow(); // deletes fMain
1911}
1912
1913void TestFileList::DoMenu(Int_t mode)
1914{
1915 // Switch view mode.
1916
1917 if (mode < 10) {
1918 fContents->SetViewMode((EListViewMode)mode);
1919 } else {
1920 delete this;
1921 }
1922}
1923
1924void TestFileList::DisplayFile(const TString &fname)
1925{
1926 // Display content of ROOT file.
1927
1928 TFile file(fname);
1929 fContents->RemoveAll();
1930 fContents->AddFile(gSystem->WorkingDirectory());
1931 fContents->SetPagePosition(0, 0);
1932 fContents->SetColHeaders("Name", "Title");
1933
1934 TIter next(file.GetListOfKeys());
1935 TKey *key;
1936
1937 while ((key = (TKey *)next())) {
1938 TString cname = key->GetClassName();
1939 TString name = key->GetName();
1940 TGLVEntry *entry = new TGLVEntry(fContents, name, cname);
1941 entry->SetSubnames(key->GetTitle());
1942 fContents->AddItem(entry);
1943
1944 // user data is a filename
1945 entry->SetUserData((void *)StrDup(fname));
1946 }
1947 fMain->Resize();
1948}
1949
1950void TestFileList::DisplayDirectory(const TString &fname)
1951{
1952 // Display content of directory.
1953
1954 fContents->SetDefaultHeaders();
1955 gSystem->ChangeDirectory(fname);
1956 fContents->ChangeDirectory(fname);
1957 fContents->DisplayDirectory();
1958 fContents->AddFile(".."); // up level directory
1959 fMain->Resize();
1960}
1961
1962void TestFileList::DisplayObject(const TString &fname, const TString &name)
1963{
1964 // Browse object located in file.
1965
1966 TDirectory *sav = gDirectory;
1967
1968 static TFile *file = nullptr;
1969 if (file)
1970 delete file; // close
1971 file = new TFile(fname); // reopen
1972
1973 TObject *obj = file->Get(name);
1974 if (obj) {
1975 if (!obj->IsFolder()) {
1976 obj->Browse(nullptr);
1977 } else
1978 obj->Print();
1979 }
1980 gDirectory = sav;
1981}
1982
1983void TestFileList::OnDoubleClick(TGLVEntry *f, Int_t btn)
1984{
1985 // Handle double click.
1986
1987 if (btn != kButton1)
1988 return;
1989
1990 // set kWatch cursor
1991 ULong_t cur = gVirtualX->CreateCursor(kWatch);
1992 gVirtualX->SetCursor(fContents->GetId(), cur);
1993
1994 TString name(f->GetTitle());
1995 const char *fname = (const char *)f->GetUserData();
1996
1997 if (fname) {
1998 DisplayObject(fname, name);
1999 } else if (name.EndsWith(".root")) {
2000 DisplayFile(name);
2001 } else {
2002 DisplayDirectory(name);
2003 }
2004 // set kPointer cursor
2005 cur = gVirtualX->CreateCursor(kPointer);
2006 gVirtualX->SetCursor(fContents->GetId(), cur);
2007}
2008
2009void TestFileList::CloseWindow()
2010{
2011 delete this;
2012}
2013
2014TestProgress::TestProgress(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
2015{
2016 // Dialog used to test the different supported progress bars.
2017
2018 fClose = kTRUE;
2019
2020 fMain = new TGTransientFrame(p, main, w, h);
2021 fMain->Connect("CloseWindow()", "TestProgress", this, "DoClose()");
2022 fMain->DontCallClose();
2023
2024 // use hierarchical cleaning
2025 fMain->SetCleanup(kDeepCleanup);
2026
2027 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
2028
2029 fHframe1 = new TGHorizontalFrame(fMain, 0, 0, 0);
2030
2031 fVProg1 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300);
2032 fVProg1->SetBarColor("purple");
2033 fVProg2 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300);
2034 fVProg2->SetFillType(TGProgressBar::kBlockFill);
2035 fVProg2->SetBarColor("green");
2036
2037 fHframe1->Resize(300, 300);
2038
2039 fVframe1 = new TGVerticalFrame(fMain, 0, 0, 0);
2040
2041 fHProg1 = new TGHProgressBar(fVframe1, 300);
2042 fHProg1->ShowPosition();
2043 fHProg2 = new TGHProgressBar(fVframe1, TGProgressBar::kFancy, 300);
2044 fHProg2->SetBarColor("lightblue");
2045 fHProg2->ShowPosition(kTRUE, kFALSE, "%.0f events");
2046 fHProg3 = new TGHProgressBar(fVframe1, TGProgressBar::kStandard, 300);
2047 fHProg3->SetFillType(TGProgressBar::kBlockFill);
2048
2049 fGO = new TGTextButton(fVframe1, "Go", 10);
2050 fGO->Connect("Clicked()", "TestProgress", this, "DoGo()");
2051
2052 fVframe1->Resize(300, 300);
2053
2054 fHint1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 10, 5, 5);
2055 fHint2 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 10);
2056 fHint3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 0, 50, 50, 0);
2057 fHint4 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0);
2058 fHint5 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0);
2059
2060 fHframe1->AddFrame(fVProg1, fHint1);
2061 fHframe1->AddFrame(fVProg2, fHint1);
2062
2063 fVframe1->AddFrame(fHProg1, fHint2);
2064 fVframe1->AddFrame(fHProg2, fHint2);
2065 fVframe1->AddFrame(fHProg3, fHint2);
2066 fVframe1->AddFrame(fGO, fHint3);
2067
2068 fMain->AddFrame(fHframe1, fHint4);
2069 fMain->AddFrame(fVframe1, fHint5);
2070
2071 fMain->SetWindowName("Progress Test");
2072 TGDimension size = fMain->GetDefaultSize();
2073 fMain->Resize(size);
2074
2075 // position relative to the parent's window
2076 fMain->CenterOnParent();
2077
2078 fMain->MapSubwindows();
2079 fMain->MapWindow();
2080
2081 gClient->WaitFor(fMain);
2082}
2083
2084TestProgress::~TestProgress()
2085{
2086 // Delete dialog.
2087
2088 fMain->DeleteWindow(); // deletes fMain
2089}
2090
2091void TestProgress::CloseWindow()
2092{
2093 // Called when window is closed via the window manager.
2094
2095 delete this;
2096}
2097
2098void TestProgress::DoClose()
2099{
2100 // If fClose is false we are still in event processing loop in DoGo().
2101 // In that case, set the close flag true and use a timer to call
2102 // CloseWindow(). This gives us change to get out of the DoGo() loop.
2103 // Note: calling SendCloseMessage() will not work since that will
2104 // bring us back here (CloseWindow() signal is connected to this method)
2105 // with the fClose flag true, which will cause window deletion while
2106 // still being in the event processing loop (since SendCloseMessage()
2107 // is directly processed in ProcessEvents() without exiting DoGo()).
2108
2109 if (fClose)
2110 CloseWindow();
2111 else {
2112 fClose = kTRUE;
2113 TTimer::SingleShot(150, "TestProgress", this, "CloseWindow()");
2114 }
2115}
2116
2117void TestProgress::DoGo()
2118{
2119 // Handle Go button.
2120
2121 fClose = kFALSE;
2122 fVProg1->Reset();
2123 fVProg2->Reset();
2124 fHProg1->Reset();
2125 fHProg2->Reset();
2126 fHProg3->Reset();
2127 fVProg2->SetBarColor("green");
2128 int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0;
2129 int inc1 = 4, inc2 = 3, inc3 = 2, inc4 = 1;
2130 while (cnt1 < 100 || cnt2 < 100 || cnt3 < 100 || cnt4 < 100) {
2131 if (cnt1 < 100) {
2132 cnt1 += inc1;
2133 fVProg1->Increment(inc1);
2134 }
2135 if (cnt2 < 100) {
2136 cnt2 += inc2;
2137 fVProg2->Increment(inc2);
2138 if (cnt2 > 75)
2139 fVProg2->SetBarColor("red");
2140 }
2141 if (cnt3 < 100) {
2142 cnt3 += inc3;
2143 fHProg1->Increment(inc3);
2144 }
2145 if (cnt4 < 100) {
2146 cnt4 += inc4;
2147 fHProg2->Increment(inc4);
2148 fHProg3->Increment(inc4);
2149 }
2150 gSystem->Sleep(100);
2152 // if user closed window return
2153 if (fClose)
2154 return;
2155 }
2156 fClose = kTRUE;
2157}
2158
2159// TGNumberEntry widget test dialog
2160// const char *const EntryTestDlg::numlabel[] = {
2161const char *numlabel[] = {
2162 "Integer", "One digit real", "Two digit real", "Three digit real", "Four digit real", "Real", "Degree.min.sec",
2163 "Min:sec", "Hour:min", "Hour:min:sec", "Day/month/year", "Month/day/year", "Hex"};
2164
2165// const Double_t EntryTestDlg::numinit[] = {
2166const Double_t numinit[] = {12345,
2167 1.0,
2168 1.00,
2169 1.000,
2170 1.0000,
2171 1.2E-12,
2172 90 * 3600,
2173 120 * 60,
2174 12 * 60,
2175 12 * 3600 + 15 * 60,
2176 19991121,
2177 19991121,
2178 (Double_t)0xDEADFACEU};
2179
2180EntryTestDlg::EntryTestDlg(const TGWindow *p, const TGWindow *main)
2181{
2182 // build widgets
2183 fMain = new TGTransientFrame(p, main, 10, 10, kHorizontalFrame);
2184 fMain->Connect("CloseWindow()", "EntryTestDlg", this, "CloseWindow()");
2185 fMain->DontCallClose(); // to avoid double deletions.
2186
2187 // use hierarchical cleaning
2188 fMain->SetCleanup(kDeepCleanup);
2189
2190 TGGC myGC = *gClient->GetResourcePool()->GetFrameGC();
2191 TGFont *myfont = gClient->GetFont("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
2192 if (myfont)
2193 myGC.SetFont(myfont->GetFontHandle());
2194
2195 fF1 = new TGVerticalFrame(fMain, 200, 300);
2196 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
2197 fMain->AddFrame(fF1, fL1);
2198 fL2 = new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 2, 2, 2);
2199 for (int i = 0; i < 13; i++) {
2200 fF[i] = new TGHorizontalFrame(fF1, 200, 30);
2201 fF1->AddFrame(fF[i], fL2);
2202 fNumericEntries[i] = new TGNumberEntry(fF[i], numinit[i], 12, i + 20, (TGNumberFormat::EStyle)i);
2203 fF[i]->AddFrame(fNumericEntries[i], fL2);
2204 fLabel[i] = new TGLabel(fF[i], numlabel[i], myGC(), myfont->GetFontStruct());
2205 fF[i]->AddFrame(fLabel[i], fL2);
2206 }
2207 fF2 = new TGVerticalFrame(fMain, 200, 500);
2208 fL3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
2209 fMain->AddFrame(fF2, fL3);
2210 fLowerLimit = new TGCheckButton(fF2, "lower limit:", 4);
2211 fF2->AddFrame(fLowerLimit, fL3);
2212 fLimits[0] = new TGNumberEntry(fF2, 0, 12, 10);
2213 fLimits[0]->SetLogStep(kFALSE);
2214 fF2->AddFrame(fLimits[0], fL3);
2215 fUpperLimit = new TGCheckButton(fF2, "upper limit:", 5);
2216 fF2->AddFrame(fUpperLimit, fL3);
2217 fLimits[1] = new TGNumberEntry(fF2, 0, 12, 11);
2218 fLimits[1]->SetLogStep(kFALSE);
2219 fF2->AddFrame(fLimits[1], fL3);
2220 fPositive = new TGCheckButton(fF2, "Positive", 6);
2221 fF2->AddFrame(fPositive, fL3);
2222 fNonNegative = new TGCheckButton(fF2, "Non negative", 7);
2223 fF2->AddFrame(fNonNegative, fL3);
2224 fSetButton = new TGTextButton(fF2, " Set ", 2);
2225 fSetButton->Connect("Clicked()", "EntryTestDlg", this, "SetLimits()");
2226 fF2->AddFrame(fSetButton, fL3);
2227 fExitButton = new TGTextButton(fF2, " Close ", 1);
2228 fExitButton->Connect("Clicked()", "EntryTestDlg", this, "DoOK()");
2229 fF2->AddFrame(fExitButton, fL3);
2230
2231 // set dialog box title
2232 fMain->SetWindowName("Number Entry Test");
2233 fMain->SetIconName("Number Entry Test");
2234 fMain->SetClassHints("NumberEntryDlg", "NumberEntryDlg");
2235 // resize & move to center
2236 fMain->MapSubwindows();
2237 UInt_t width = fMain->GetDefaultWidth();
2238 UInt_t height = fMain->GetDefaultHeight();
2239 fMain->Resize(width, height);
2240 fMain->CenterOnParent();
2241 // make the message box non-resizable
2242 fMain->SetWMSize(width, height);
2243 fMain->SetWMSizeHints(width, height, width, height, 0, 0);
2246
2247 fMain->MapWindow();
2248 gClient->WaitFor(fMain);
2249}
2250
2251EntryTestDlg::~EntryTestDlg()
2252{
2253 // dtor
2254
2255 fMain->DeleteWindow();
2256}
2257
2258void EntryTestDlg::CloseWindow()
2259{
2260 delete this;
2261}
2262
2263void EntryTestDlg::DoOK()
2264{
2265 // Handle ok button.
2266
2267 fMain->SendCloseMessage();
2268}
2269
2270void EntryTestDlg::SetLimits()
2271{
2272 Double_t min = fLimits[0]->GetNumber();
2273 Bool_t low = (fLowerLimit->GetState() == kButtonDown);
2274 Double_t max = fLimits[1]->GetNumber();
2275 Bool_t high = (fUpperLimit->GetState() == kButtonDown);
2277 if (low && high) {
2279 } else if (low) {
2281 } else if (high) {
2283 } else {
2285 }
2286 Bool_t pos = (fPositive->GetState() == kButtonDown);
2287 Bool_t nneg = (fNonNegative->GetState() == kButtonDown);
2289 if (pos) {
2291 } else if (nneg) {
2293 } else {
2295 }
2296 for (int i = 0; i < 13; i++) {
2297 fNumericEntries[i]->SetFormat(fNumericEntries[i]->GetNumStyle(), attr);
2298 fNumericEntries[i]->SetLimits(lim, min, max);
2299 }
2300}
2301
2302Editor::Editor(const TGWindow *main, UInt_t w, UInt_t h)
2303{
2304 // Create an editor in a dialog.
2305
2306 fMain = new TGTransientFrame(gClient->GetRoot(), main, w, h);
2307 fMain->Connect("CloseWindow()", "Editor", this, "CloseWindow()");
2308 fMain->DontCallClose(); // to avoid double deletions.
2309
2310 // use hierarchical cleaning
2311 fMain->SetCleanup(kDeepCleanup);
2312
2313 fEdit = new TGTextEdit(fMain, w, h, kSunkenFrame | kDoubleBorder);
2314 fL1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 3, 3, 3, 3);
2315 fMain->AddFrame(fEdit, fL1);
2316 fEdit->Connect("Opened()", "Editor", this, "DoOpen()");
2317 fEdit->Connect("Saved()", "Editor", this, "DoSave()");
2318 fEdit->Connect("Closed()", "Editor", this, "DoClose()");
2319
2320 // set selected text colors
2321 Pixel_t pxl;
2322 gClient->GetColorByName("#3399ff", pxl);
2323 fEdit->SetSelectBack(pxl);
2324 fEdit->SetSelectFore(TGFrame::GetWhitePixel());
2325
2326 fOK = new TGTextButton(fMain, " &OK ");
2327 fOK->Connect("Clicked()", "Editor", this, "DoOK()");
2328 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 5);
2329 fMain->AddFrame(fOK, fL2);
2330
2331 SetTitle();
2332
2333 fMain->MapSubwindows();
2334
2335 fMain->Resize();
2336
2337 // editor covers right half of parent window
2338 fMain->CenterOnParent(kTRUE, TGTransientFrame::kRight);
2339}
2340
2341Editor::~Editor()
2342{
2343 // Delete editor dialog.
2344
2345 fMain->DeleteWindow(); // deletes fMain
2346}
2347
2348void Editor::SetTitle()
2349{
2350 // Set title in editor window.
2351
2352 TGText *txt = GetEditor()->GetText();
2353 Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
2354
2355 char title[256];
2356 if (untitled)
2357 snprintf(title, 256, "ROOT Editor - Untitled");
2358 else
2359 snprintf(title, 256, "ROOT Editor - %s", txt->GetFileName());
2360
2361 fMain->SetWindowName(title);
2362 fMain->SetIconName(title);
2363}
2364
2365void Editor::Popup()
2366{
2367 // Show editor.
2368
2369 fMain->MapWindow();
2370}
2371
2372void Editor::LoadBuffer(const char *buffer)
2373{
2374 // Load a text buffer in the editor.
2375
2376 fEdit->LoadBuffer(buffer);
2377}
2378
2379void Editor::LoadFile(const char *file)
2380{
2381 // Load a file in the editor.
2382
2383 fEdit->LoadFile(file);
2384}
2385
2386void Editor::AddBuffer(const char *buffer)
2387{
2388 // Add text to the editor.
2389
2390 TGText txt;
2391 txt.LoadBuffer(buffer);
2392 fEdit->AddText(&txt);
2393}
2394
2395void Editor::CloseWindow()
2396{
2397 // Called when closed via window manager action.
2398
2399 delete this;
2400}
2401
2402void Editor::DoOK()
2403{
2404 // Handle ok button.
2405
2406 CloseWindow();
2407}
2408
2409void Editor::DoOpen()
2410{
2411 SetTitle();
2412}
2413
2414void Editor::DoSave()
2415{
2416 SetTitle();
2417}
2418
2419void Editor::DoClose()
2420{
2421 // Handle close button.
2422
2423 CloseWindow();
2424}
2425
2426void guitest()
2427{
2428 new TestMainFrame(gClient->GetRoot(), 400, 220);
2429}
2430
2431//---- Main program ------------------------------------------------------------
2432#ifdef STANDALONE
2433int main(int argc, char **argv)
2434{
2435 TApplication theApp("App", &argc, argv);
2436
2437 if (gROOT->IsBatch()) {
2438 fprintf(stderr, "%s: cannot run in batch mode\n", argv[0]);
2439 return 1;
2440 }
2441
2442 guitest();
2443
2444 theApp.Run();
2445
2446 return 0;
2447}
2448#endif
@ kButton3Down
Definition Buttons.h:17
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
@ kWatch
Definition GuiTypes.h:375
@ kPointer
Definition GuiTypes.h:375
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton4
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:215
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
int main()
Definition Prototype.cxx:12
#define RQ_OBJECT(sender_class)
Definition RQ_OBJECT.h:87
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
#define e(i)
Definition RSha256.hxx:103
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned long ULong_t
Definition RtypesCore.h:55
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
@ kRed
Definition Rtypes.h:66
R__EXTERN TApplication * gApplication
#define gDirectory
Definition TDirectory.h:384
@ kButtonDown
Definition TGButton.h:54
@ kButtonDisabled
Definition TGButton.h:56
@ kButtonUp
Definition TGButton.h:53
#define gClient
Definition TGClient.h:157
@ kDoubleScaleBoth
@ kFDOpen
@ kMWMDecorResizeH
Definition TGFrame.h:65
@ kMWMFuncAll
Definition TGFrame.h:49
@ kMWMFuncResize
Definition TGFrame.h:50
@ kMWMDecorMaximize
Definition TGFrame.h:69
@ kMWMDecorMinimize
Definition TGFrame.h:68
@ kMWMDecorMenu
Definition TGFrame.h:67
@ kMWMDecorAll
Definition TGFrame.h:63
@ kMWMFuncMaximize
Definition TGFrame.h:53
@ kMWMInputModeless
Definition TGFrame.h:57
@ kMWMFuncMinimize
Definition TGFrame.h:52
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
EListViewMode
Definition TGListView.h:21
@ kLVDetails
Definition TGListView.h:25
@ kLVSmallIcons
Definition TGListView.h:23
@ kLVList
Definition TGListView.h:24
@ kLVLargeIcons
Definition TGListView.h:22
@ kMBNo
Definition TGMsgBox.h:32
@ kMBIgnore
Definition TGMsgBox.h:36
@ kMBApply
Definition TGMsgBox.h:34
@ kMBNoAll
Definition TGMsgBox.h:41
@ kMBClose
Definition TGMsgBox.h:38
@ kMBYes
Definition TGMsgBox.h:31
@ kMBAppend
Definition TGMsgBox.h:42
@ kMBRetry
Definition TGMsgBox.h:35
@ kMBCancel
Definition TGMsgBox.h:37
@ kMBOk
Definition TGMsgBox.h:33
@ kMBYesAll
Definition TGMsgBox.h:40
@ kMBNewer
Definition TGMsgBox.h:43
@ kMBDismiss
Definition TGMsgBox.h:39
EMsgBoxIcon
Definition TGMsgBox.h:21
@ kMBIconExclamation
Definition TGMsgBox.h:24
@ kMBIconAsterisk
Definition TGMsgBox.h:25
@ kMBIconStop
Definition TGMsgBox.h:22
@ kMBIconQuestion
Definition TGMsgBox.h:23
@ kScaleBoth
Definition TGSlider.h:36
@ kSlider2
Definition TGSlider.h:31
@ kSlider1
Definition TGSlider.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t sel
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char cname
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t button
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
@ kNoContextMenu
Definition TObject.h:373
R__EXTERN void * gTQSender
Definition TQObject.h:46
#define gROOT
Definition TROOT.h:406
R__EXTERN TRandom * gRandom
Definition TRandom.h:62
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2557
R__EXTERN TSystem * gSystem
Definition TSystem.h:561
#define gVirtualX
Definition TVirtualX.h:337
#define snprintf
Definition civetweb.c:1540
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
The Canvas class.
Definition TCanvas.h:23
Bool_t InheritsFrom(const char *cl) const override
Return kTRUE if this class inherits from a class with name "classname".
Definition TClass.cxx:4943
static ULong_t RGB2Pixel(Int_t r, Int_t g, Int_t b)
Convert r,g,b to graphics system dependent pixel value.
Definition TColor.cxx:2476
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Describe directory structure in memory.
Definition TDirectory.h:45
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Definition TFile.h:53
A button abstract base class.
Definition TGButton.h:68
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
virtual EButtonState GetState() const
Definition TGButton.h:112
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:235
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
Selects different options.
Definition TGButton.h:264
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set check button state.
Like a checkbutton but instead of the check mark there is color area with a little down arrow.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:1000
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
void RemoveAll() override
Remove all items from the container.
Definition TGCanvas.cxx:641
virtual void SetPagePosition(const TGPosition &pos)
Set page position.
Definition TGCanvas.cxx:764
A frame with handles that allow it to be undocked (i.e.
DoubleSlider widgets allow easy selection of a min and a max value out of a range.
virtual Float_t GetMinPosition() const
virtual void SetRange(Float_t min, Float_t max)
virtual void SetPosition(Float_t min, Float_t max)
Dragging the slider will generate the event:
This class creates a file selection dialog.
char * fFilename
selected file name
const char ** fFileTypes
file types used to filter selectable files
char * fIniDir
on input: initial directory, on output: new directory
void SetIniDir(const char *inidir)
Set directory name.
Font selection dialog, allowing to select one in the list of available fonts in the system.
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
FontH_t GetFontHandle() const
Definition TGFont.h:183
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:190
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
TClass * IsA() const override
Definition TGFrame.h:283
virtual void DeleteWindow()
Delete window.
Definition TGFrame.cxx:276
virtual void ChangeBackground(Pixel_t back)
Change frame background color.
Definition TGFrame.cxx:293
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
void SetFont(FontH_t v)
Set font.
Definition TGGC.cxx:411
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:278
A composite frame with a border and a title.
Definition TGFrame.h:522
TGDimension GetDefaultSize() const override
Returns default size.
Definition TGFrame.cxx:2131
virtual void SetTitlePos(ETitlePos pos=kLeft)
Definition TGFrame.h:564
Concrete class for horizontal slider.
Definition TGSlider.h:119
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
virtual void SetSubnames(const char *n1="", const char *n2="", const char *n3="", const char *n4="", const char *n5="", const char *n6="", const char *n7="", const char *n8="", const char *n9="", const char *n10="", const char *n11="", const char *n12="")
Sets new subnames.
void SetUserData(void *userData)
Definition TGListView.h:94
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
virtual void RemoveEntry(Int_t id=-1)
remove entry with id.
void Resize(UInt_t w, UInt_t h) override
Resize the listbox widget.
virtual void AddEntry(TGString *s, Int_t id)
Add entry with specified string and id to listbox.
void Layout() override
Layout the listbox components.
virtual void SetMultipleSelections(Bool_t multi=kTRUE)
Definition TGListBox.h:259
virtual const char * GetText() const =0
TGListTreeItem * GetParent() const
Definition TGListTree.h:58
virtual void * GetUserData() const =0
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition TGListTree.h:79
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:195
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
A list view is a widget that can contain a number of items arranged in a grid or list.
Definition TGListView.h:115
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:397
This layout managers does not make use of TGLayoutHints.
Definition TGLayout.h:269
The TGMenu.h header contains all different menu classes.
Definition TGMenu.h:282
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=nullptr)
Add popup menu to menu bar.
Definition TGMenu.cxx:418
This class contains all information about a menu entry.
Definition TGMenu.h:57
TGNumberEntry is a number entry input widget with up/down buttons.
@ kNEAPositive
Positive number.
@ kNEANonNegative
Non-negative number.
@ kNEAAnyNumber
Attributes of number entry field.
@ kNELNoLimits
Limit selection of number entry field.
@ kNELLimitMax
Upper limit only.
@ kNELLimitMin
Lower limit only.
@ kNELLimitMinMax
Both lower and upper limits.
Handle_t GetId() const
Definition TGObject.h:41
Yield an action as soon as it is clicked.
Definition TGButton.h:228
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Pixmap_t GetPicture() const
Definition TGPicture.h:54
This class creates a popup menu object.
Definition TGMenu.h:110
Selects different options.
Definition TGButton.h:321
void SetState(EButtonState state, Bool_t emit=kFALSE) override
Set radio button state.
TGFrame * GetContainer() const
Definition TGShutter.h:45
A shutter widget contains a set of shutter items that can be open and closed like a shutter.
Definition TGShutter.h:55
virtual void AddItem(TGShutterItem *item)
Add shutter item to shutter frame.
Definition TGShutter.cxx:73
Slider widgets allow easy selection of a range.
Definition TGSlider.h:40
virtual void SetPosition(Int_t pos)
Set slider position.
Definition TGSlider.cxx:110
static TClass * Class()
virtual void SetRange(Int_t min, Int_t max)
Set slider range.
Definition TGSlider.cxx:99
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Service classes of the tab widget.
Definition TGTab.h:117
const char * GetString() const
Definition TGTab.h:146
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:663
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition TGTab.cxx:709
virtual void RemoveTab(Int_t tabIndex=-1, Bool_t storeRemoved=kTRUE)
Remove container and tab of tab with index tabIndex.
Definition TGTab.cxx:427
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:376
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
void AddText(Int_t pos, const char *text)
const char * GetString() const
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A TGTextEdit is a specialization of TGTextView.
Definition TGTextEdit.h:22
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
Int_t GetCursorPosition() const
void Deselect()
Deselects all text (i.e.
virtual void SetCursorPosition(Int_t pos)
Set the cursor position to newPos.
virtual void SetFont(TGFont *font, Bool_t local=kTRUE)
Changes text font specified by pointer to TGFont object.
A TGText is a multi line text buffer.
Definition TGText.h:57
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
Definition TGText.cxx:513
const char * GetFileName() const
Definition TGText.h:88
This is a layout manager for the TGListView widget.
Definition TGLayout.h:303
Defines transient windows that typically are used for dialogs windows.
Definition TGFrame.h:498
Concrete class for vertical slider.
Definition TGSlider.h:92
A composite frame that layout their children in vertical way.
Definition TGFrame.h:374
Int_t WidgetId() const
Definition TGWidget.h:68
ROOT GUI Window base class.
Definition TGWindow.h:23
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:623
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition TH1.cxx:3346
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3068
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:308
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:393
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
const char * GetTitle() const override
Returns title (title can contain 32x32 xpm thumbnail/icon).
Definition TKey.cxx:1519
virtual const char * GetClassName() const
Definition TKey.h:75
A doubly linked list.
Definition TList.h:38
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:572
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:216
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:798
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:654
void SetBorderMode(Short_t bordermode) override
Definition TPad.h:325
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:869
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition TRandom.cxx:507
This class creates a TGCanvas in which a TCanvas is created.
TCanvas * GetCanvas() const
Basic string class.
Definition TString.h:139
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2244
Describes an Operating System directory for the browser.
A TSystemFile describes an operating system file.
Definition TSystemFile.h:29
virtual Bool_t IsDirectory(const char *dir=nullptr) const
Check if object is a directory.
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1081
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:862
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:437
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:871
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:416
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:258
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
static void Terminate()
Close the global pad editor. Static method.
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
TF1 * f1
Definition legend1.C:11
return c2
Definition legend2.C:14
__device__ AFloat max(AFloat x, AFloat y)
Definition Kernels.cuh:207
const char * cnt
Definition TXMLSetup.cxx:75
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
UInt_t fCode
key or button code
Definition GuiTypes.h:180
TLine lv
Definition textalign.C:5
TLine l
Definition textangle.C:4