25 class TextViewMainFrame :
public TGMainFrame
28 TGTextButton *fReset, *fExit;
29 TGTextViewostream *fTextView;
30 TGVerticalFrame *fContents;
31 TGHorizontalFrame *fButtons, *fCommandFrame;
32 TGTextEntry *fCommand;
36 virtual ~TextViewMainFrame() {}
40 ClassDef(TextViewMainFrame, 0)
45 TextViewMainFrame::TextViewMainFrame() : TGMainFrame(gClient->GetRoot())
49 SetCleanup(kDeepCleanup);
52 fContents =
new TGVerticalFrame(
this);
53 fButtons =
new TGHorizontalFrame(fContents);
56 fTextView =
new TGTextViewostream(fContents, 500, 300);
57 fContents->AddFrame(fTextView,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 0));
59 fCommandFrame =
new TGHorizontalFrame(fContents);
60 fCommand =
new TGTextEntry(fCommandFrame, (
const char *)
"", 20);
61 fCommand->Connect(
"ReturnPressed()",
"TextViewMainFrame",
this,
"HandleReturn()");
62 fCommandFrame->AddFrame(
new TGLabel(fCommandFrame,
"Command: "),
63 new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 5, 5));
64 fCommandFrame->AddFrame(fCommand,
new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
65 fContents->AddFrame(fCommandFrame,
new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
68 fReset =
new TGTextButton(fButtons,
"&Reset");
69 fReset->SetToolTipText(
"Press to clear the command entry\nand the TGTextView", 200);
70 fReset->Connect(
"Clicked()",
"TextViewMainFrame",
this,
"Reset()");
71 fButtons->AddFrame(fReset,
new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5, 5, 5, 5));
73 fExit =
new TGTextButton(fButtons,
"&Exit");
74 fExit->SetToolTipText(
"Terminate the application", 200);
75 fButtons->AddFrame(fExit,
new TGLayoutHints(kLHintsExpandX | kLHintsTop, 5, 5, 5, 5));
76 fExit->Connect(
"Pressed()",
"TApplication", gApplication,
"Terminate()");
78 fContents->AddFrame(fButtons,
new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 0, 0));
79 Connect(
"CloseWindow()",
"TApplication", gApplication,
"Terminate()");
82 AddFrame(fContents,
new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY));
84 Resize(GetDefaultSize());
86 SetWindowName(
"TGTextView Demo");
91 void TextViewMainFrame::Reset()
98 void TextViewMainFrame::HandleReturn()
101 std::string command = fCommand->GetText();
102 *fTextView << gSystem->GetFromPipe(command.c_str()).Data() << std::endl;
103 fTextView->ShowBottom();
108 void textviewostream()
112 new TextViewMainFrame();