35 Int_t GetUnID(
void) {
return ++fID; }
38 class MyApplication :
public TGMainFrame {
43 TGComboBox *fComboCmd;
44 TGTextBuffer *fCommandBuf;
45 TGTextEntry *fCommand;
46 TGTextView *fTextView;
49 MyApplication(
const TGWindow *p, UInt_t w, UInt_t h);
50 virtual ~MyApplication();
53 void DoEnteredCommand();
55 ClassDef(MyApplication, 0)
58 MyApplication::MyApplication(
const TGWindow *p, UInt_t w, UInt_t h)
59 : TGMainFrame(p, w, h)
61 SetCleanup(kDeepCleanup);
63 Connect(
"CloseWindow()",
"MyApplication",
this,
"DoExit()");
66 TGHorizontalFrame *fHL2 =
new TGHorizontalFrame(
this, 70, 100);
67 AddFrame(fHL2,
new TGLayoutHints(kLHintsNormal, 5, 5, 5, 5));
68 TGLabel *fInlabel =
new TGLabel(fHL2,
"CINT Prompt:");
69 fHL2->AddFrame(fInlabel,
new TGLayoutHints(kLHintsCenterY));
71 TGLabel *fOutlabel =
new TGLabel(
this,
"Output Window:");
74 fCommandBuf =
new TGTextBuffer(256);
75 fComboCmd =
new TGComboBox(fHL2,
"", fIDs.GetUnID());
76 fCommand = fComboCmd->GetTextEntry();
77 fComboCmd->Resize(450, fCommand->GetDefaultHeight());
78 fHL2->AddFrame(fComboCmd,
new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 20,0,0,0));
80 TString hist(Form(
"%s/.root_hist", gSystem->UnixPathName(gSystem->HomeDirectory())));
81 FILE *fhist = fopen(hist.Data(),
"rt");
84 while (fgets(histline, 256, fhist)) {
85 histline[strlen(histline)-1] = 0;
86 fComboCmd->InsertEntry(histline, 0, -1);
92 gClient->GetColorByName(
"#c0c0c0", backpxl);
93 fTextView =
new TGTextView(
this, 500, 94, fIDs.GetUnID(), kFixedWidth | kFixedHeight);
94 fTextView->SetBackground(backpxl);
95 AddFrame(fTextView,
new TGLayoutHints(kLHintsExpandX));
96 TGHorizontalFrame *fHL3 =
new TGHorizontalFrame(
this, 70, 150, kFixedWidth);
97 fExit =
new TGTextButton(fHL3,
"&Exit", fIDs.GetUnID());
98 fExit->Connect(
"Clicked()",
"MyApplication",
this,
"DoExit()");
99 fHL3->AddFrame(fExit,
new TGLayoutHints(kLHintsExpandX));
100 AddFrame(fHL3,
new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 1, 1, 1, 1));
102 SetWindowName(
"GUI with CINT Input/Output");
104 Resize(GetDefaultSize());
106 fCommand->Connect(
"ReturnPressed()",
"MyApplication",
this,
"DoEnteredCommand()");
107 fName = Form(
"%soutput.log", gSystem->WorkingDirectory());
110 MyApplication::~MyApplication()
117 void MyApplication::DoExit()
121 gSystem->Unlink(fName.Data());
122 gApplication->Terminate();
125 void MyApplication::DoEnteredCommand()
129 const char *command = fCommand->GetTitle();
132 if (strlen(command)) {
134 prompt = ((TRint*)gROOT->GetApplication())->GetPrompt();
135 FILE *cintout = fopen(fName.Data(),
"a+t");
137 fputs(Form(
"%s%s\n",prompt.Data(), command), cintout);
140 gSystem->RedirectOutput(fName.Data(),
"a");
141 gROOT->ProcessLine(command);
142 fComboCmd->InsertEntry(command, 0, fIDs.GetUnID());
143 Gl_histadd((
char *)command);
144 gSystem->RedirectOutput(0);
145 fTextView->LoadFile(fName.Data());
146 if (fTextView->ReturnLineCount() > 10)
147 fTextView->SetVsbPosition(fTextView->ReturnLineCount());
150 printf(
"No command entered\n");
152 fTextView->ShowBottom();
157 new MyApplication(gClient->GetRoot(),600,300);