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();
62 Connect(
"CloseWindow()",
"MyApplication",
this,
"DoExit()");
74 fComboCmd =
new TGComboBox(fHL2,
"", fIDs.GetUnID());
75 fCommand = fComboCmd->GetTextEntry();
76 fComboCmd->Resize(450, fCommand->GetDefaultHeight());
80 FILE *fhist = fopen(hist.Data(),
"rt");
83 while (fgets(histline, 256, fhist)) {
84 histline[strlen(histline) - 1] = 0;
85 fComboCmd->InsertEntry(histline, 0, -1);
91 gClient->GetColorByName(
"#c0c0c0", backpxl);
93 fTextView->SetBackground(backpxl);
97 fExit->Connect(
"Clicked()",
"MyApplication",
this,
"DoExit()");
101 SetWindowName(
"GUI with CLING Input/Output");
103 Resize(GetDefaultSize());
105 fCommand->Connect(
"ReturnPressed()",
"MyApplication",
this,
"DoEnteredCommand()");
106 fName =
Form(
"%soutput.log",
gSystem->WorkingDirectory());
109MyApplication::~MyApplication()
116void MyApplication::DoExit()
124void MyApplication::DoEnteredCommand()
128 const char *command = fCommand->GetTitle();
131 if (strlen(command)) {
133 prompt = ((
TRint *)
gROOT->GetApplication())->GetPrompt();
134 FILE *cintout = fopen(fName.Data(),
"a+t");
136 fputs(
Form(
"%s%s\n", prompt.
Data(), command), cintout);
139 gSystem->RedirectOutput(fName.Data(),
"a");
140 gROOT->ProcessLine(command);
141 fComboCmd->InsertEntry(command, 0, fIDs.GetUnID());
142 Gl_histadd((
char *)command);
143 gSystem->RedirectOutput(
nullptr);
144 fTextView->LoadFile(fName.Data());
145 if (fTextView->ReturnLineCount() > 10)
146 fTextView->SetVsbPosition(fTextView->ReturnLineCount());
149 printf(
"No command entered\n");
151 fTextView->ShowBottom();
156 new MyApplication(
gClient->GetRoot(), 600, 300);
ULong_t Pixel_t
Pixel value.
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
#define ClassDefOverride(name, id)
externTApplication * gApplication
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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