35 Int_t GetUnID(
void) {
return ++fID; }
43 TGComboBox *fComboCmd;
44 TGTextBuffer *fCommandBuf;
45 TGTextEntry *fCommand;
46 TGTextView *fTextView;
50 ~MyApplication()
override;
53 void DoEnteredCommand();
63 Connect(
"CloseWindow()",
"MyApplication",
this,
"DoExit()");
75 fComboCmd =
new TGComboBox(fHL2,
"", fIDs.GetUnID());
76 fCommand = fComboCmd->GetTextEntry();
77 fComboCmd->Resize(450, fCommand->GetDefaultHeight());
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);
94 fTextView->SetBackground(backpxl);
98 fExit->Connect(
"Clicked()",
"MyApplication",
this,
"DoExit()");
102 SetWindowName(
"GUI with CLING Input/Output");
104 Resize(GetDefaultSize());
106 fCommand->Connect(
"ReturnPressed()",
"MyApplication",
this,
"DoEnteredCommand()");
107 fName =
Form(
"%soutput.log",
gSystem->WorkingDirectory());
110MyApplication::~MyApplication()
117void MyApplication::DoExit()
125void 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(
nullptr);
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);
ULong_t Pixel_t
Pixel value.
#define ClassDefOverride(name, id)
R__EXTERN TApplication * gApplication
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void w
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
R__EXTERN TSystem * gSystem
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
A composite frame that layout their children in horizontal way.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
Yield an action as soon as it is clicked.
A TGTextView is a text viewer widget.
ROOT GUI Window base class.
const char * Data() const