00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <TApplication.h>
00012 #include <TGClient.h>
00013 #include <TGButton.h>
00014 #include <TGFrame.h>
00015 #include <TGLayout.h>
00016 #include <TGWindow.h>
00017 #include <TGLabel.h>
00018 #include <TGNumberEntry.h>
00019 #include <TString.h>
00020
00021 class MyMainFrame : public TGMainFrame {
00022
00023 private:
00024 TGCompositeFrame *fHor1;
00025 TGTextButton *fExit;
00026 TGGroupFrame *fGframe;
00027 TGNumberEntry *fNumber;
00028 TGLabel *fLabel;
00029
00030 public:
00031 MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
00032 virtual ~MyMainFrame();
00033 void DoSetlabel();
00034
00035 ClassDef(MyMainFrame, 0)
00036 };
00037
00038 MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
00039 : TGMainFrame(p, w, h)
00040 {
00041
00042 fHor1 = new TGHorizontalFrame(this, 60, 20, kFixedWidth);
00043 fExit = new TGTextButton(fHor1, "&Exit", "gApplication->Terminate(0)");
00044 fHor1->AddFrame(fExit, new TGLayoutHints(kLHintsTop | kLHintsLeft |
00045 kLHintsExpandX, 4, 4, 4, 4));
00046 AddFrame(fHor1,new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
00047
00048 fNumber = new TGNumberEntry(this, 0, 9,999, TGNumberFormat::kNESInteger,
00049 TGNumberFormat::kNEANonNegative,
00050 TGNumberFormat::kNELLimitMinMax,
00051 0, 99999);
00052 fNumber->Connect("ValueSet(Long_t)", "MyMainFrame", this, "DoSetlabel()");
00053 (fNumber->GetNumberEntry())->Connect("ReturnPressed()", "MyMainFrame", this,
00054 "DoSetlabel()");
00055 AddFrame(fNumber, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
00056 fGframe = new TGGroupFrame(this, "Value");
00057 fLabel = new TGLabel(fGframe, "No input.");
00058 fGframe->AddFrame(fLabel, new TGLayoutHints(kLHintsTop | kLHintsLeft,
00059 5, 5, 5, 5));
00060 AddFrame(fGframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 1, 1));
00061
00062 SetCleanup(kDeepCleanup);
00063 SetWindowName("Number Entry");
00064 MapSubwindows();
00065 Resize(GetDefaultSize());
00066 MapWindow();
00067 }
00068
00069 MyMainFrame::~MyMainFrame()
00070 {
00071
00072
00073 Cleanup();
00074 }
00075
00076 void MyMainFrame::DoSetlabel()
00077 {
00078
00079
00080
00081 fLabel->SetText(Form("%d",fNumber->GetNumberEntry()->GetIntNumber()));
00082
00083
00084 fGframe->Layout();
00085 }
00086
00087 void numberEntry()
00088 {
00089 new MyMainFrame(gClient->GetRoot(), 50, 50);
00090 }