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