62 enum ETestCommandIdentifiers {
108 Int_t mb_button_id[13] = { kMBYes, kMBNo, kMBOk, kMBApply,
109 kMBRetry, kMBIgnore, kMBCancel,
110 kMBClose, kMBYesAll, kMBNoAll,
111 kMBNewer, kMBAppend, kMBDismiss};
113 EMsgBoxIcon mb_icon[4] = { kMBIconStop, kMBIconQuestion,
114 kMBIconExclamation, kMBIconAsterisk };
116 const char *filetypes[] = {
"All files",
"*",
117 "ROOT files",
"*.root",
118 "ROOT macros",
"*.C",
119 "Text files",
"*.[tT][xX][tT]",
122 struct shutterData_t {
123 const char *pixmap_name;
124 const char *tip_text;
129 shutterData_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 },
137 shutterData_t function_data[] = {
138 {
"f1_s.xpm",
"TF1", 2001, 0 },
139 {
"f2_s.xpm",
"TF2", 2002, 0 },
143 shutterData_t tree_data[] = {
144 {
"ntuple_s.xpm",
"TNtuple", 3001, 0 },
145 {
"tree_s.xpm",
"TTree", 3002, 0 },
146 {
"chain_s.xpm",
"TChain", 3003, 0 },
151 const 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."
164 const char *editortxt2 =
165 "Mice with scroll-ball are properly supported.\n\n"
166 "This are the currently defined key bindings:\n"
168 " Move the cursor one character leftwards.\n"
169 " Scroll when cursor is out of frame.\n"
171 " Move the cursor one character rightwards.\n"
172 " Scroll when cursor is out of frame.\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"
177 const 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"
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"
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"
190 const 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"
195 "Shift - Left Arrow\n"
196 " Mark text one character leftwards.\n"
197 "Shift - Right Arrow\n"
198 " Mark text one character rightwards.\n"
200 " Select the whole text.\n"
202 " Move the cursor one character leftwards."
204 const char *editortxt5 =
206 " Copy the marked text to the clipboard.\n"
208 " Delete the character to the right of the cursor.\n"
210 " Move the cursor to the end of the line.\n"
212 " Start Search Dialog.\n"
214 " Delete the character to the left of the cursor.\n"
216 " Delete marked text if any or delete all\n"
217 " characters to the right of the cursor.\n"
219 " Start GoTo Line Dialog"
221 const char *editortxt6 =
223 " Delete all characters on the line.\n"
225 " Paste the clipboard text into line edit.\n"
227 " Cut the marked text, copy to clipboard.\n"
229 " Paste the clipboard text into line edit.\n"
232 "All other keys with valid ASCII codes insert themselves into the line.";
238 class TestMainFrame {
240 RQ_OBJECT(
"TestMainFrame")
244 TGDockableFrame *fMenuDock;
245 TGCompositeFrame *fStatusFrame;
246 TGCanvas *fCanvasWindow;
247 TileFrame *fContainer;
248 TGTextEntry *fTestText;
249 TGButton *fTestButton;
250 TGColorSelect *fColorSel;
253 TGPopupMenu *fMenuFile, *fMenuTest, *fMenuView, *fMenuHelp;
254 TGPopupMenu *fCascadeMenu, *fCascade1Menu, *fCascade2Menu;
255 TGPopupMenu *fMenuNew1, *fMenuNew2;
256 TGLayoutHints *fMenuBarLayout, *fMenuBarItemLayout, *fMenuBarHelpLayout;
259 TestMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
260 virtual ~TestMainFrame();
265 void HandleMenu(Int_t
id);
266 void HandlePopup() { printf(
"menu popped up\n"); }
267 void HandlePopdown() { printf(
"menu popped down\n"); }
269 void Created() { Emit(
"Created()"); }
270 void Welcome() { printf(
"TestMainFrame has been created. Welcome!\n"); }
275 RQ_OBJECT(
"TestDialog")
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;
289 TGTextEntry *fTxt1, *fTxt2;
290 TGLayoutHints *fL1, *fL2, *fL3, *fL4;
291 TRootEmbeddedCanvas *fEc1, *fEc2;
301 TestDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h,
302 UInt_t options = kVerticalFrame);
303 virtual ~TestDialog();
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);
317 RQ_OBJECT(
"TestMsgBox")
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;
334 TestMsgBox(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h,
335 UInt_t options = kVerticalFrame);
336 virtual ~TestMsgBox();
349 RQ_OBJECT(
"TestSliders")
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;
362 TestSliders(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
363 virtual ~TestSliders();
367 void DoText(const
char *text);
368 void DoSlider(Int_t pos = 0);
374 RQ_OBJECT(
"TestShutter")
377 TGTransientFrame *fMain;
379 TGLayoutHints *fLayout;
380 const TGPicture *fDefaultPic;
383 TestShutter(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
386 void AddShutterItem(const
char *name, shutterData_t *data);
390 void HandleButtons();
396 RQ_OBJECT(
"TestDirList")
399 TGTransientFrame *fMain;
400 TGListTree *fContents;
401 const TGPicture *fIcon;
402 TString DirName(TGListTreeItem* item);
405 TestDirList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
406 virtual ~TestDirList();
409 void OnDoubleClick(TGListTreeItem* item, Int_t btn);
416 RQ_OBJECT(
"TestFileList")
419 TGTransientFrame *fMain;
420 TGFileContainer *fContents;
423 void DisplayFile(const TString &fname);
424 void DisplayDirectory(const TString &fname);
425 void DisplayObject(const TString& fname,const TString& name);
428 TestFileList(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h);
429 virtual ~TestFileList();
432 void OnDoubleClick(TGLVEntry*,Int_t);
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;
450 TestProgress(
const TGWindow *p,
const TGWindow *main, UInt_t w, UInt_t h);
451 virtual ~TestProgress();
463 TGTransientFrame *fMain;
464 TGVerticalFrame *fF1;
465 TGVerticalFrame *fF2;
466 TGHorizontalFrame *fF[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;
484 EntryTestDlg(
const TGWindow *p,
const TGWindow *main);
485 virtual ~EntryTestDlg();
497 TGTransientFrame *fMain;
504 Editor(
const TGWindow *main, UInt_t w, UInt_t h);
507 void LoadFile(
const char *file);
508 void LoadBuffer(
const char *buffer);
509 void AddBuffer(
const char *buffer);
511 TGTextEdit *GetEditor()
const {
return fEdit; }
527 RQ_OBJECT(
"TileFrame")
530 TGCompositeFrame *fFrame;
534 TileFrame(const TGWindow *p);
535 virtual ~TileFrame() {
delete fFrame; }
537 TGFrame *GetFrame()
const {
return fFrame; }
539 void SetCanvas(TGCanvas *canvas) { fCanvas = canvas; }
540 void HandleMouseWheel(Event_t *event);
543 TileFrame::TileFrame(
const TGWindow *p)
547 fFrame =
new TGCompositeFrame(p, 10, 10, kHorizontalFrame,
548 TGFrame::GetWhitePixel());
549 fFrame->Connect(
"ProcessedEvent(Event_t*)",
"TileFrame",
this,
550 "HandleMouseWheel(Event_t*)");
552 fFrame->SetLayoutManager(
new TGTileLayout(fFrame, 8));
554 gVirtualX->GrabButton(fFrame->GetId(), kAnyButton, kAnyModifier,
555 kButtonPressMask | kButtonReleaseMask |
556 kPointerMotionMask, kNone, kNone);
559 void TileFrame::HandleMouseWheel(Event_t *event)
563 if (event->fType != kButtonPress && event->fType != kButtonRelease)
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());
575 if (event->fCode == kButton4) {
577 Int_t newpos = fCanvas->GetVsbPosition() - page;
578 if (newpos < 0) newpos = 0;
579 fCanvas->SetVsbPosition(newpos);
581 if (event->fCode == kButton5) {
583 Int_t newpos = fCanvas->GetVsbPosition() + page;
584 fCanvas->SetVsbPosition(newpos);
589 TestMainFrame::TestMainFrame(
const TGWindow *p, UInt_t w, UInt_t h)
593 fMain =
new TGMainFrame(p, w, h);
596 fMain->SetCleanup(kDeepCleanup);
598 fMain->Connect(
"CloseWindow()",
"TestMainFrame",
this,
"CloseWindow()");
602 fMenuDock =
new TGDockableFrame(fMain);
603 fMain->AddFrame(fMenuDock,
new TGLayoutHints(kLHintsExpandX, 0, 0, 1, 0));
604 fMenuDock->SetWindowName(
"GuiTest Menu");
606 fMenuBarLayout =
new TGLayoutHints(kLHintsTop | kLHintsExpandX);
607 fMenuBarItemLayout =
new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
608 fMenuBarHelpLayout =
new TGLayoutHints(kLHintsTop | kLHintsRight);
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);
621 fMenuFile->DisableEntry(M_FILE_SAVEAS);
622 fMenuFile->HideEntry(M_FILE_PRINT);
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);
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);
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);
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);
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);
668 fMenuDock->EnableUndock(kTRUE);
669 fMenuDock->EnableHide(kTRUE);
670 fMenuView->CheckEntry(M_VIEW_ENBL_DOCK);
671 fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
675 fMenuDock->Connect(
"Undocked()",
"TestMainFrame",
this,
"HandleMenu(=M_VIEW_UNDOCK)");
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);
683 fMenuNew1 =
new TGPopupMenu();
684 fMenuNew1->AddEntry(
"Remove New Menus", M_NEW_REMOVEMENU);
686 fMenuNew2 =
new TGPopupMenu();
687 fMenuNew2->AddEntry(
"Remove New Menus", M_NEW_REMOVEMENU);
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)");
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);
718 fMenuDock->AddFrame(fMenuBar, fMenuBarLayout);
721 fCanvasWindow =
new TGCanvas(fMain, 400, 240);
722 fContainer =
new TileFrame(fCanvasWindow->GetViewPort());
723 fContainer->SetCanvas(fCanvasWindow);
724 fCanvasWindow->SetContainer(fContainer->GetFrame());
727 fContainer->GetFrame()->SetCleanup(kDeepCleanup);
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)),
733 new TGLayoutHints(kLHintsExpandY | kLHintsRight));
735 fMain->AddFrame(fCanvasWindow,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
739 fStatusFrame =
new TGCompositeFrame(fMain, 60, 20, kHorizontalFrame |
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,
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));
758 fMain->AddFrame(fStatusFrame,
new TGLayoutHints(kLHintsBottom | kLHintsExpandX,
761 fMain->SetWindowName(
"GuiTest Signal/Slots");
763 fMain->MapSubwindows();
769 Connect(
"Created()",
"TestMainFrame",
this,
"Welcome()");
773 TestMainFrame::~TestMainFrame()
782 delete fCascade1Menu;
783 delete fCascade2Menu;
791 void TestMainFrame::CloseWindow()
795 gApplication->Terminate();
798 void TestMainFrame::DoButton()
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);
812 void TestMainFrame::HandleMenu(Int_t
id)
820 static TString dir(
".");
822 fi.fFileTypes = filetypes;
823 fi.fIniDir = StrDup(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);
832 printf(
"M_FILE_SAVE\n");
836 printf(
"M_FILE_PRINT\n");
837 printf(
"Hiding itself, select \"Print Setup...\" to enable again\n");
838 fMenuFile->HideEntry(M_FILE_PRINT);
841 case M_FILE_PRINTSETUP:
842 printf(
"M_FILE_PRINTSETUP\n");
843 printf(
"Enabling \"Print\"\n");
844 fMenuFile->EnableEntry(M_FILE_PRINT);
852 new TestDialog(gClient->GetRoot(), fMain, 400, 200);
856 new TestMsgBox(gClient->GetRoot(), fMain, 400, 200);
860 new TestSliders(gClient->GetRoot(), fMain, 400, 200);
864 new TestShutter(gClient->GetRoot(), fMain, 400, 200);
868 new TestDirList(gClient->GetRoot(), fMain, 400, 200);
871 case M_TEST_FILELIST:
872 new TestFileList(gClient->GetRoot(), fMain, 400, 200);
875 case M_TEST_PROGRESS:
876 new TestProgress(gClient->GetRoot(), fMain, 600, 300);
879 case M_TEST_NUMBERENTRY:
880 new EntryTestDlg(gClient->GetRoot(), fMain);
883 case M_TEST_FONTDIALOG:
885 TGFontDialog::FontProp_t prop;
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);
896 if (fMenuTest->IsEntryChecked(M_TEST_NEWMENU)) {
897 HandleMenu(M_NEW_REMOVEMENU);
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();
908 TGMenuEntry *e = fMenuTest->GetEntry(
"Add New Menus");
909 fMenuTest->AddEntry(
"Remove New Menus", M_NEW_REMOVEMENU, 0, 0, e);
913 case M_NEW_REMOVEMENU:
915 fMenuBar->RemovePopup(
"New 1");
916 fMenuBar->RemovePopup(
"New 2");
918 fMenuTest->DeleteEntry(M_NEW_REMOVEMENU);
919 fMenuTest->UnCheckEntry(M_TEST_NEWMENU);
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);
929 fMenuView->UnCheckEntry(M_VIEW_ENBL_DOCK);
930 fMenuView->DisableEntry(M_VIEW_UNDOCK);
934 case M_VIEW_ENBL_HIDE:
935 fMenuDock->EnableHide(!fMenuDock->EnableHide());
936 if (fMenuDock->EnableHide()) {
937 fMenuView->CheckEntry(M_VIEW_ENBL_HIDE);
939 fMenuView->UnCheckEntry(M_VIEW_ENBL_HIDE);
944 fMenuDock->DockContainer();
945 fMenuView->EnableEntry(M_VIEW_UNDOCK);
946 fMenuView->DisableEntry(M_VIEW_DOCK);
950 fMenuDock->UndockContainer();
951 fMenuView->EnableEntry(M_VIEW_DOCK);
952 fMenuView->DisableEntry(M_VIEW_UNDOCK);
956 printf(
"Menu item %d selected\n",
id);
962 TestDialog::TestDialog(
const TGWindow *p,
const TGWindow *main, UInt_t w,
963 UInt_t h, UInt_t options)
968 fMain =
new TGTransientFrame(p, main, w, h, options);
969 fMain->Connect(
"CloseWindow()",
"TestDialog",
this,
"DoClose()");
970 fMain->DontCallClose();
973 fMain->SetCleanup(kDeepCleanup);
975 fFrame1 =
new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
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()");
982 fL1 =
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
984 fL2 =
new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1);
986 fFrame1->AddFrame(fOkButton, fL1);
987 fFrame1->AddFrame(fCancelButton, fL1);
989 fFrame1->Resize(150, fOkButton->GetDefaultHeight());
990 fMain->AddFrame(fFrame1, fL2);
994 fTab =
new TGTab(fMain, 300, 300);
995 fTab->Connect(
"Selected(Int_t)",
"TestDialog",
this,
"DoTab(Int_t)");
997 fL3 =
new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
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());
1008 tf = fTab->AddTab(
"Tab 2");
1009 fL1 =
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
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);
1021 tf->AddFrame(fF2, fL3);
1025 for (i = 0; i < 20; i++) {
1027 sprintf(tmp,
"Entry %i", i+1);
1028 fCombo->AddEntry(tmp, i+1);
1031 fCombo->Resize(150, 20);
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()");
1041 fFillHistos = kFALSE;
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);
1054 fF5 =
new TGCompositeFrame(tf, 60, 60, kHorizontalFrame);
1056 fL4 =
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
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);
1063 tf->AddFrame(fF3, fL3);
1064 tf->AddFrame(fF5, fL4);
1066 fEc1->GetCanvas()->SetBorderMode(0);
1067 fEc2->GetCanvas()->SetBorderMode(0);
1068 fEc1->GetCanvas()->SetBit(kNoContextMenu);
1069 fEc1->GetCanvas()->Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
1071 "HandleEmbeddedCanvas(Int_t,Int_t,Int_t,TObject*)");
1075 gClient->GetColorByName(
"yellow", yellow);
1076 TGTabElement *tabel = fTab->GetTabTab(
"Tab 3");
1077 tabel->ChangeBackground(yellow);
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()");
1087 fF4->AddFrame(bt =
new TGTextButton(fF4,
"Remove &Entry", 91), fL3);
1088 bt->Connect(
"Clicked()",
"TestDialog",
this,
"HandleButtons()");
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);
1095 for (i = 0; i < 20; ++i) {
1096 sprintf(tmp,
"Entry %i", i);
1097 fListBox->AddEntry(tmp, i);
1102 fListBox->Resize(150, 80);
1105 tf = fTab->AddTab(
"Tab 5");
1106 tf->SetLayoutManager(
new TGHorizontalLayout(tf));
1108 fF6 =
new TGGroupFrame(tf,
"Options", kVerticalFrame);
1109 fF6->SetTitlePos(TGGroupFrame::kRight);
1110 tf->AddFrame(fF6, fL3);
1113 fF6->SetLayoutManager(
new TGMatrixLayout(fF6, 0, 2, 10));
1116 for (j = 0; j < 4; j++) {
1117 sprintf(buff,
"Module %i", j+1);
1118 fF6->AddFrame(
new TGLabel(fF6,
new TGHotString(buff)));
1120 TGTextBuffer *tbuf =
new TGTextBuffer(10);
1121 tbuf->AddText(0,
"0.0");
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);
1131 fF7 =
new TGGroupFrame(tf,
"Tab Handling", kVerticalFrame);
1132 tf->AddFrame(fF7, fL3);
1134 fF7->SetLayoutManager(
new TGMatrixLayout(fF7, 0, 1, 10));
1136 fF7->AddFrame(bt =
new TGTextButton(fF7,
"Remove Tab", 101));
1137 bt->Connect(
"Clicked()",
"TestDialog",
this,
"HandleButtons()");
1138 bt->Resize(90, bt->GetDefaultHeight());
1140 fF7->AddFrame(bt =
new TGTextButton(fF7,
"Add Tab", 103));
1141 bt->Connect(
"Clicked()",
"TestDialog",
this,
"HandleButtons()");
1142 bt->Resize(90, bt->GetDefaultHeight());
1144 fF7->AddFrame(bt =
new TGTextButton(fF7,
"Remove Tab 5", 102));
1145 bt->Connect(
"Clicked()",
"TestDialog",
this,
"HandleButtons()");
1146 bt->Resize(90, bt->GetDefaultHeight());
1148 fF7->Resize(fF6->GetDefaultSize());
1152 TGLayoutHints *fL5 =
new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
1153 kLHintsExpandY, 2, 2, 5, 1);
1154 fMain->AddFrame(fTab, fL5);
1156 fMain->MapSubwindows();
1160 fMain->CenterOnParent();
1162 fMain->SetWindowName(
"Dialog");
1168 TestDialog::~TestDialog()
1172 fMain->DeleteWindow();
1175 void TestDialog::FillHistos()
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);
1188 const int kUPDATE = 1000;
1190 TCanvas *c1 = fEc1->GetCanvas();
1191 TCanvas *c2 = fEc2->GetCanvas();
1193 while (fFillHistos) {
1194 gRandom->Rannor(px,py);
1196 fHpxpy->Fill(px,py);
1198 if (!(cnt % kUPDATE)) {
1199 if (cnt == kUPDATE) {
1203 fHpxpy->Draw(
"cont");
1209 gSystem->ProcessEvents();
1214 void TestDialog::DoClose()
1216 printf(
"\nTerminating dialog: via window manager\n");
1218 fFillHistos = kFALSE;
1219 TTimer::SingleShot(150,
"TestDialog",
this,
"CloseWindow()");
1224 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
1225 TVirtualPadEditor::Terminate();
1228 void TestDialog::CloseWindow()
1235 void TestDialog::DoOK()
1237 fFillHistos = kFALSE;
1238 printf(
"\nTerminating dialog: OK pressed\n");
1240 fOkButton->SetState(kButtonDisabled);
1241 fCancelButton->SetState(kButtonDisabled);
1252 TTimer::SingleShot(150,
"TestDialog",
this,
"CloseWindow()");
1255 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
1256 TVirtualPadEditor::Terminate();
1260 void TestDialog::DoCancel()
1262 fFillHistos = kFALSE;
1263 printf(
"\nTerminating dialog: Cancel pressed\n");
1265 fOkButton->SetState(kButtonDisabled);
1266 fCancelButton->SetState(kButtonDisabled);
1267 TTimer::SingleShot(150,
"TestDialog",
this,
"CloseWindow()");
1269 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
1270 TVirtualPadEditor::Terminate();
1273 void TestDialog::HandleButtons(Int_t
id)
1278 TGButton *btn = (TGButton *) gTQSender;
1279 id = btn->WidgetId();
1282 printf(
"DoButton: id = %d\n",
id);
1285 static int newtab = 0;
1289 fFillHistos = kTRUE;
1293 fFillHistos = kFALSE;
1303 sprintf(tmp,
"Entry %i", fLastEntry);
1304 fListBox->AddEntry(tmp, fLastEntry);
1305 fListBox->MapSubwindows();
1309 if (fFirstEntry <= fLastEntry) {
1310 fListBox->RemoveEntry(fFirstEntry);
1317 TString s = fTab->GetTabTab(0)->GetString();
1318 if ((s ==
"Tab 3") && (fMain->MustCleanup() != kDeepCleanup)) {
1323 delete fEc1; fEc1 = 0;
1324 delete fEc2; fEc2 = 0;
1332 int nt = fTab->GetNumberOfTabs();
1333 for (
int i = 0 ; i < nt; i++) {
1334 TString s = fTab->GetTabTab(i)->GetString();
1344 sprintf(tmp,
"New Tab %d", ++newtab);
1346 fTab->MapSubwindows();
1350 fRad2->SetState(kButtonUp);
1353 fRad1->SetState(kButtonUp);
1356 fListBox->SetMultipleSelections(fCheckMulti->GetState());
1363 void TestDialog::DoTab(Int_t
id)
1365 printf(
"Tab item %d activated\n",
id);
1368 void TestDialog::HandleEmbeddedCanvas(Int_t event, Int_t x, Int_t y,
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());
1378 TestMsgBox::TestMsgBox(
const TGWindow *p,
const TGWindow *main,
1379 UInt_t w, UInt_t h, UInt_t options) :
1380 fRedTextGC(TGButton::GetDefaultGC())
1386 fMain =
new TGTransientFrame(p, main, w, h, options);
1387 fMain->Connect(
"CloseWindow()",
"TestMsgBox",
this,
"CloseWindow()");
1388 fMain->DontCallClose();
1391 fMain->SetCleanup(kDeepCleanup);
1398 gClient->GetColorByName(
"red", red);
1399 fRedTextGC.SetForeground(red);
1404 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
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);
1412 fTestButton =
new TGTextButton(f1,
"&Test", 1, fRedTextGC());
1413 fTestButton->Connect(
"Clicked()",
"TestMsgBox",
this,
"DoTest()");
1417 gClient->GetColorByName(
"green", green);
1418 fTestButton->ChangeBackground(green);
1420 fCloseButton =
new TGTextButton(f1,
"&Close", 2);
1421 fCloseButton->Connect(
"Clicked()",
"TestMsgBox",
this,
"DoClose()");
1423 fPictButton =
new TGPictureButton(f1, gClient->GetPicture(
"mb_stop_s.xpm"));
1425 f1->Resize(fTestButton->GetDefaultWidth()+40, fMain->GetDefaultHeight());
1427 fL1 =
new TGLayoutHints(kLHintsTop | kLHintsExpandX,
1429 fL2 =
new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX,
1431 fL21 =
new TGLayoutHints(kLHintsTop | kLHintsRight,
1434 f1->AddFrame(fTestButton, fL1);
1435 f1->AddFrame(fCloseButton, fL1);
1436 f1->AddFrame(fPictButton, fL1);
1437 fMain->AddFrame(f1, fL21);
1441 fG1 =
new TGGroupFrame(f3,
new TGString(
"Buttons"),kVerticalFrame|kRaisedFrame);
1442 fG2 =
new TGGroupFrame(f3,
new TGString(
"Icons"),kVerticalFrame|kRaisedFrame);
1444 fL3 =
new TGLayoutHints(kLHintsTop | kLHintsLeft |
1445 kLHintsExpandX | kLHintsExpandY,
1447 fL4 =
new TGLayoutHints(kLHintsTop | kLHintsLeft,
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);
1464 for (i=0; i<13; ++i) fG1->AddFrame(fC[i], fL4);
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);
1471 for (i = 0; i < 4; ++i) {
1472 fG2->AddFrame(fR[i], fL4);
1473 fR[i]->Connect(
"Clicked()",
"TestMsgBox",
this,
"DoRadio()");
1476 fC[2]->SetState(kButtonDown);
1477 fR[0]->SetState(kButtonDown);
1479 f3->AddFrame(fG1, fL3);
1480 f3->AddFrame(fG2, fL3);
1482 fLtitle =
new TGLabel(f4,
new TGString(
"Title:"), fRedTextGC());
1483 fLmsg =
new TGLabel(f5,
new TGString(
"Message:"));
1485 fTitle =
new TGTextEntry(f4, fTbtitle =
new TGTextBuffer(100));
1486 fMsg =
new TGTextEntry(f5, fTbmsg =
new TGTextBuffer(100));
1488 fTbtitle->AddText(0,
"MsgBox");
1489 fTbmsg->AddText(0,
"This is a test message box.");
1491 fTitle->Resize(300, fTitle->GetDefaultHeight());
1492 fMsg->Resize(300, fMsg->GetDefaultHeight());
1494 fL5 =
new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
1496 fL6 =
new TGLayoutHints(kLHintsRight | kLHintsCenterY,
1499 f4->AddFrame(fLtitle, fL5);
1500 f4->AddFrame(fTitle, fL6);
1501 f5->AddFrame(fLmsg, fL5);
1502 f5->AddFrame(fMsg, fL6);
1504 f2->AddFrame(f3, fL1);
1505 f2->AddFrame(f4, fL1);
1506 f2->AddFrame(f5, fL1);
1508 fMain->AddFrame(f2, fL2);
1510 fMain->MapSubwindows();
1514 fMain->CenterOnParent();
1516 fMain->SetWindowName(
"Message Box Test");
1519 gClient->WaitFor(fMain);
1525 TestMsgBox::~TestMsgBox()
1529 fMain->DeleteWindow();
1532 void TestMsgBox::CloseWindow()
1539 void TestMsgBox::DoClose()
1546 void TestMsgBox::DoTest()
1550 int i, buttons, retval;
1551 EMsgBoxIcon icontype = kMBIconStop;
1554 for (i = 0; i < 13; i++)
1555 if (fC[i]->GetState() == kButtonDown)
1556 buttons |= mb_button_id[i];
1558 for (i = 0; i < 4; i++)
1559 if (fR[i]->GetState() == kButtonDown) {
1560 icontype = mb_icon[i];
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()");
1577 void TestMsgBox::TryToClose()
1581 printf(
"Can't close the window '%s' : a message box is still open\n", fMain->GetWindowName());
1584 void TestMsgBox::DoRadio()
1588 TGButton *btn = (TGButton *) gTQSender;
1589 Int_t
id = btn->WidgetId();
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);
1599 TestSliders::TestSliders(
const TGWindow *p,
const TGWindow *main,
1604 fMain =
new TGTransientFrame(p, main, w, h);
1605 fMain->Connect(
"CloseWindow()",
"TestSliders",
this,
"CloseWindow()");
1606 fMain->DontCallClose();
1609 fMain->SetCleanup(kDeepCleanup);
1611 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
1613 fVframe1 =
new TGVerticalFrame(fMain, 0, 0, 0);
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");
1620 fTeh1->Connect(
"TextChanged(char*)",
"TestSliders",
this,
"DoText(char*)");
1621 fTev1->Connect(
"TextChanged(char*)",
"TestSliders",
this,
"DoText(char*)");
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);
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);
1631 fVframe1->Resize(100, 100);
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");
1639 fTeh2->Connect(
"TextChanged(char*)",
"TestSliders",
this,
"DoText(char*)");
1640 fTev2->Connect(
"TextChanged(char*)",
"TestSliders",
this,
"DoText(char*)");
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);
1646 fVslider2 =
new TGDoubleVSlider(fVframe2, 100, kDoubleScaleBoth, VSId2);
1648 fVslider2->SetRange(-10,10);
1649 fVslider2->Connect(
"PositionChanged()",
"TestSliders",
this,
"DoSlider()");
1650 fVframe2->Resize(100, 100);
1653 fBly =
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 3, 0);
1656 fBfly1 =
new TGLayoutHints(kLHintsTop | kLHintsRight, 20, 10, 15, 0);
1658 fVframe1->AddFrame(fHslider1, fBly);
1659 fVframe1->AddFrame(fVslider1, fBly);
1660 fVframe1->AddFrame(fTeh1, fBly);
1661 fVframe1->AddFrame(fTev1, fBly);
1663 fVframe2->AddFrame(fHslider2, fBly);
1664 fVframe2->AddFrame(fVslider2, fBly);
1665 fVframe2->AddFrame(fTeh2, fBly);
1666 fVframe2->AddFrame(fTev2, fBly);
1668 fMain->AddFrame(fVframe2, fBfly1);
1669 fMain->AddFrame(fVframe1, fBfly1);
1671 fMain->SetWindowName(
"Slider Test");
1672 TGDimension size = fMain->GetDefaultSize();
1673 fMain->Resize(size);
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 |
1678 kMWMDecorMinimize | kMWMDecorMenu,
1679 kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
1684 fMain->CenterOnParent();
1686 fMain->MapSubwindows();
1689 gClient->WaitFor(fMain);
1692 TestSliders::~TestSliders()
1696 fMain->DeleteWindow();
1699 void TestSliders::CloseWindow()
1706 void TestSliders::DoText(
const char * )
1710 TGTextEntry *te = (TGTextEntry *) gTQSender;
1711 Int_t
id = te->WidgetId();
1715 fHslider1->SetPosition(atoi(fTbh1->GetString()));
1718 fVslider1->SetPosition(atoi(fTbv1->GetString()));
1721 fHslider2->SetPosition(atoi(fTbh2->GetString()));
1724 fVslider2->SetPosition(atoi(fTbv2->GetString()),
1725 atoi(fTbv2->GetString())+2);
1732 void TestSliders::DoSlider(Int_t pos)
1737 TGFrame *frm = (TGFrame *) gTQSender;
1738 if (frm->IsA()->InheritsFrom(TGSlider::Class())) {
1739 TGSlider *sl = (TGSlider*) frm;
1740 id = sl->WidgetId();
1742 TGDoubleSlider *sd = (TGDoubleSlider *) frm;
1743 id = sd->WidgetId();
1747 sprintf(buf,
"%d", pos);
1756 fTbh1->AddText(0, buf);
1758 fTeh1->SetCursorPosition(fTeh1->GetCursorPosition());
1760 gClient->NeedRedraw(fTeh1);
1766 else if (
id == VSId1) {
1769 fTbv1->AddText(0, buf);
1770 fTev1->SetCursorPosition(fTev1->GetCursorPosition());
1772 gClient->NeedRedraw(fTev1);
1778 else if (
id == HSId2) {
1781 fTbh2->AddText(0, buf);
1782 fTeh2->SetCursorPosition(fTeh2->GetCursorPosition());
1784 gClient->NeedRedraw(fTeh2);
1790 else if (
id == VSId2) {
1792 sprintf(buf,
"%f", fVslider2->GetMinPosition());
1794 fTbv2->AddText(0, buf);
1795 fTev2->SetCursorPosition(fTev2->GetCursorPosition());
1797 gClient->NeedRedraw(fTev2);
1807 TestShutter::TestShutter(
const TGWindow *p,
const TGWindow *main,
1812 fMain =
new TGTransientFrame(p, main, w, h);
1813 fMain->Connect(
"CloseWindow()",
"TestShutter",
this,
"CloseWindow()");
1814 fMain->DontCallClose();
1817 fMain->SetCleanup(kDeepCleanup);
1819 fDefaultPic = gClient->GetPicture(
"folder_s.xpm");
1820 fShutter =
new TGShutter(fMain, kSunkenFrame);
1822 AddShutterItem(
"Histograms", histo_data);
1823 AddShutterItem(
"Functions", function_data);
1824 AddShutterItem(
"Trees", tree_data);
1826 fLayout =
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
1827 fMain->AddFrame(fShutter, fLayout);
1829 fMain->MapSubwindows();
1830 fMain->Resize(80, 300);
1833 fMain->CenterOnParent();
1835 fMain->SetWindowName(
"Shutter Test");
1841 void TestShutter::AddShutterItem(
const char *name, shutterData_t *data)
1843 TGShutterItem *item;
1844 TGCompositeFrame *container;
1846 const TGPicture *buttonpic;
1847 static int id = 5001;
1849 TGLayoutHints *l =
new TGLayoutHints(kLHintsTop | kLHintsCenterX,
1852 item =
new TGShutterItem(fShutter,
new TGHotString(name),
id++);
1853 container = (TGCompositeFrame *) item->GetContainer();
1855 for (
int i=0; data[i].pixmap_name != 0; i++) {
1856 buttonpic = gClient->GetPicture(data[i].pixmap_name);
1858 printf(
"<TestShutter::AddShutterItem>: missing pixmap \"%s\", using default",
1859 data[i].pixmap_name);
1860 buttonpic = fDefaultPic;
1863 button =
new TGPictureButton(container, buttonpic, data[i].
id);
1865 container->AddFrame(button, l);
1866 button->Connect(
"Clicked()",
"TestShutter",
this,
"HandleButtons()");
1867 button->SetToolTipText(data[i].tip_text);
1868 data[i].button = button;
1871 fShutter->AddItem(item);
1874 TestShutter::~TestShutter()
1878 gClient->FreePicture(fDefaultPic);
1879 fMain->DeleteWindow();
1882 void TestShutter::CloseWindow()
1887 void TestShutter::HandleButtons()
1889 TGButton *btn = (TGButton *) gTQSender;
1890 printf(
"Shutter button %d\n", btn->WidgetId());
1894 TestDirList::TestDirList(
const TGWindow *p,
const TGWindow *main,
1899 fMain =
new TGTransientFrame(p, main, w, h);
1900 fMain->Connect(
"CloseWindow()",
"TestDirList",
this,
"CloseWindow()");
1901 fMain->DontCallClose();
1903 fIcon = gClient->GetPicture(
"rootdb_t.xpm");
1907 fMain->SetCleanup(kDeepCleanup);
1909 TGCanvas* canvas =
new TGCanvas(fMain, 500, 300);
1910 fContents =
new TGListTree(canvas, kHorizontalFrame);
1911 lo =
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsBottom);
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)");
1918 fContents->AddItem(0,
"c:\\");
1920 fContents->AddItem(0,
"/");
1924 fMain->CenterOnParent();
1926 fMain->SetWindowName(
"List Dir Test");
1928 fMain->MapSubwindows();
1933 TestDirList::~TestDirList()
1937 gClient->FreePicture(fIcon);
1939 fMain->DeleteWindow();
1942 void TestDirList::CloseWindow()
1947 TString TestDirList::DirName(TGListTreeItem* item)
1951 TGListTreeItem* parent;
1952 TString dirname = item->GetText();
1954 while ((parent=item->GetParent())) {
1955 dirname = gSystem->ConcatFileName(parent->GetText(),dirname);
1962 void TestDirList::OnDoubleClick(TGListTreeItem* item, Int_t btn)
1966 if ((btn!=kButton1) || !item || (Bool_t)item->GetUserData())
return;
1969 item->SetUserData((
void*)1);
1971 TSystemDirectory dir(item->GetText(),DirName(item));
1973 TList *files = dir.GetListOfFiles();
1980 while ((file=(TSystemFile*)next())) {
1981 fname = file->GetName();
1982 if (file->IsDirectory()) {
1983 if ((fname!=
"..") && (fname!=
".")) {
1984 fContents->AddItem(item,fname);
1986 }
else if (fname.EndsWith(
".root")) {
1987 fContents->AddItem(item,fname,fIcon,fIcon);
1995 TestFileList::TestFileList(
const TGWindow *p,
const TGWindow *main, UInt_t w, UInt_t h)
2001 fMain =
new TGTransientFrame(p, main, w, h);
2002 fMain->Connect(
"CloseWindow()",
"TestDirList",
this,
"CloseWindow()");
2003 fMain->DontCallClose();
2006 fMain->SetCleanup(kDeepCleanup);
2008 TGMenuBar* mb =
new TGMenuBar(fMain);
2009 lo =
new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
2010 fMain->AddFrame(mb, lo);
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)");
2021 TGListView* lv =
new TGListView(fMain, w, h);
2022 lo =
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
2023 fMain->AddFrame(lv,lo);
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)");
2032 fMain->CenterOnParent();
2034 fMain->SetWindowName(
"File List Test");
2035 fMain->MapSubwindows();
2037 fContents->SetDefaultHeaders();
2038 fContents->DisplayDirectory();
2039 fContents->AddFile(
"..");
2040 fContents->Resize();
2041 fContents->StopRefreshTimer();
2045 TestFileList::~TestFileList()
2050 fMain->DeleteWindow();
2053 void TestFileList::DoMenu(Int_t mode)
2058 fContents->SetViewMode((EListViewMode)mode);
2064 void TestFileList::DisplayFile(
const TString &fname)
2069 fContents->RemoveAll();
2070 fContents->AddFile(gSystem->WorkingDirectory());
2071 fContents->SetPagePosition(0,0);
2072 fContents->SetColHeaders(
"Name",
"Title");
2074 TIter next(file.GetListOfKeys());
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);
2085 entry->SetUserData((
void*)StrDup(fname));
2090 void TestFileList::DisplayDirectory(
const TString &fname)
2094 fContents->SetDefaultHeaders();
2095 gSystem->ChangeDirectory(fname);
2096 fContents->ChangeDirectory(fname);
2097 fContents->DisplayDirectory();
2098 fContents->AddFile(
"..");
2102 void TestFileList::DisplayObject(
const TString& fname,
const TString& name)
2106 TDirectory *sav = gDirectory;
2108 static TFile *file = 0;
2109 if (file)
delete file;
2110 file =
new TFile(fname);
2112 TObject* obj = file->Get(name);
2114 if (!obj->IsFolder()) {
2116 }
else obj->Print();
2121 void TestFileList::OnDoubleClick(TGLVEntry *f, Int_t btn)
2125 if (btn != kButton1)
return;
2128 ULong_t cur = gVirtualX->CreateCursor(kWatch);
2129 gVirtualX->SetCursor(fContents->GetId(), cur);
2131 TString name(f->GetTitle());
2132 const char* fname = (
const char*)f->GetUserData();
2135 DisplayObject(fname, name);
2136 }
else if (name.EndsWith(
".root")) {
2139 DisplayDirectory(name);
2142 cur = gVirtualX->CreateCursor(kPointer);
2143 gVirtualX->SetCursor(fContents->GetId(), cur);
2146 void TestFileList::CloseWindow()
2151 TestProgress::TestProgress(
const TGWindow *p,
const TGWindow *main,
2158 fMain =
new TGTransientFrame(p, main, w, h);
2159 fMain->Connect(
"CloseWindow()",
"TestProgress",
this,
"DoClose()");
2160 fMain->DontCallClose();
2163 fMain->SetCleanup(kDeepCleanup);
2165 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame);
2167 fHframe1 =
new TGHorizontalFrame(fMain, 0, 0, 0);
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");
2175 fHframe1->Resize(300, 300);
2177 fVframe1 =
new TGVerticalFrame(fMain, 0, 0, 0);
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);
2187 fGO =
new TGTextButton(fVframe1,
"Go", 10);
2188 fGO->Connect(
"Clicked()",
"TestProgress",
this,
"DoGo()");
2190 fVframe1->Resize(300, 300);
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);
2198 fHframe1->AddFrame(fVProg1, fHint1);
2199 fHframe1->AddFrame(fVProg2, fHint1);
2201 fVframe1->AddFrame(fHProg1, fHint2);
2202 fVframe1->AddFrame(fHProg2, fHint2);
2203 fVframe1->AddFrame(fHProg3, fHint2);
2204 fVframe1->AddFrame(fGO, fHint3);
2206 fMain->AddFrame(fHframe1, fHint4);
2207 fMain->AddFrame(fVframe1, fHint5);
2209 fMain->SetWindowName(
"Progress Test");
2210 TGDimension size = fMain->GetDefaultSize();
2211 fMain->Resize(size);
2214 fMain->CenterOnParent();
2216 fMain->MapSubwindows();
2219 gClient->WaitFor(fMain);
2222 TestProgress::~TestProgress()
2226 fMain->DeleteWindow();
2229 void TestProgress::CloseWindow()
2236 void TestProgress::DoClose()
2251 TTimer::SingleShot(150,
"TestProgress",
this,
"CloseWindow()");
2255 void TestProgress::DoGo()
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) {
2268 fVProg1->Increment(inc1);
2272 fVProg2->Increment(inc2);
2274 fVProg2->SetBarColor(
"red");
2278 fHProg1->Increment(inc3);
2282 fHProg2->Increment(inc4);
2283 fHProg3->Increment(inc4);
2285 gSystem->Sleep(100);
2286 gSystem->ProcessEvents();
2296 const char *numlabel[] = {
2313 const 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
2319 EntryTestDlg::EntryTestDlg(
const TGWindow *p,
const TGWindow *main)
2322 fMain =
new TGTransientFrame(p, main, 10, 10, kHorizontalFrame);
2323 fMain->Connect(
"CloseWindow()",
"EntryTestDlg",
this,
"CloseWindow()");
2324 fMain->DontCallClose();
2327 fMain->SetCleanup(kDeepCleanup);
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());
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,
2341 (TGNumberFormat::EStyle) i);
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);
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);
2371 fMain->SetWindowName(
"Number Entry Test");
2372 fMain->SetIconName(
"Number Entry Test");
2373 fMain->SetClassHints(
"NumberEntryDlg",
"NumberEntryDlg");
2375 fMain->MapSubwindows();
2376 UInt_t width = fMain->GetDefaultWidth();
2377 UInt_t height = fMain->GetDefaultHeight();
2378 fMain->Resize(width, height);
2379 fMain->CenterOnParent();
2381 fMain->SetWMSize(width, height);
2382 fMain->SetWMSizeHints(width, height, width, height, 0, 0);
2383 fMain->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
2384 kMWMDecorMinimize | kMWMDecorMenu,
2385 kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
2386 kMWMFuncMinimize, kMWMInputModeless);
2389 gClient->WaitFor(fMain);
2392 EntryTestDlg::~EntryTestDlg()
2396 fMain->DeleteWindow();
2399 void EntryTestDlg::CloseWindow()
2404 void EntryTestDlg::DoOK()
2408 fMain->SendCloseMessage();
2411 void EntryTestDlg::SetLimits()
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);
2417 TGNumberFormat::ELimit lim;
2419 lim = TGNumberFormat::kNELLimitMinMax;
2421 lim = TGNumberFormat::kNELLimitMin;
2423 lim = TGNumberFormat::kNELLimitMax;
2425 lim = TGNumberFormat::kNELNoLimits;
2427 Bool_t pos = (fPositive->GetState() == kButtonDown);
2428 Bool_t nneg = (fNonNegative->GetState() == kButtonDown);
2429 TGNumberFormat::EAttribute attr;
2431 attr = TGNumberFormat::kNEAPositive;
2433 attr = TGNumberFormat::kNEANonNegative;
2435 attr = TGNumberFormat::kNEAAnyNumber;
2437 for (
int i = 0; i < 13; i++) {
2438 fNumericEntries[i]->SetFormat(fNumericEntries[i]->GetNumStyle(), attr);
2439 fNumericEntries[i]->SetLimits(lim, min, max);
2444 Editor::Editor(
const TGWindow *main, UInt_t w, UInt_t h)
2448 fMain =
new TGTransientFrame(gClient->GetRoot(), main, w, h);
2449 fMain->Connect(
"CloseWindow()",
"Editor",
this,
"CloseWindow()");
2450 fMain->DontCallClose();
2453 fMain->SetCleanup(kDeepCleanup);
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()");
2464 gClient->GetColorByName(
"#3399ff", pxl);
2465 fEdit->SetSelectBack(pxl);
2466 fEdit->SetSelectFore(TGFrame::GetWhitePixel());
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);
2475 fMain->MapSubwindows();
2480 fMain->CenterOnParent(kTRUE, TGTransientFrame::kRight);
2487 fMain->DeleteWindow();
2490 void Editor::SetTitle()
2494 TGText *txt = GetEditor()->GetText();
2495 Bool_t untitled = !strlen(txt->GetFileName()) ? kTRUE : kFALSE;
2499 sprintf(title,
"ROOT Editor - Untitled");
2501 sprintf(title,
"ROOT Editor - %s", txt->GetFileName());
2503 fMain->SetWindowName(title);
2504 fMain->SetIconName(title);
2507 void Editor::Popup()
2514 void Editor::LoadBuffer(
const char *buffer)
2518 fEdit->LoadBuffer(buffer);
2521 void Editor::LoadFile(
const char *file)
2525 fEdit->LoadFile(file);
2528 void Editor::AddBuffer(
const char *buffer)
2533 txt.LoadBuffer(buffer);
2534 fEdit->AddText(&txt);
2537 void Editor::CloseWindow()
2551 void Editor::DoOpen()
2556 void Editor::DoSave()
2561 void Editor::DoClose()
2571 new TestMainFrame(gClient->GetRoot(), 400, 220);
2576 int main(
int argc,
char **argv)
2578 TApplication theApp(
"App", &argc, argv);
2580 if (gROOT->IsBatch()) {
2581 fprintf(stderr,
"%s: cannot run in batch mode\n", argv[0]);