00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <TGClient.h>
00011 #include <TGButton.h>
00012 #include <TGFrame.h>
00013
00014 class MyMainFrame : public TGMainFrame {
00015
00016 private:
00017 TGCompositeFrame *fCframe;
00018 TGTextButton *fStart, *fPause, *fExit;
00019 Bool_t start, pause;
00020
00021 public:
00022 MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
00023 virtual ~MyMainFrame();
00024
00025 void ChangeStartLabel();
00026 void ChangePauseLabel();
00027
00028 ClassDef(MyMainFrame, 0)
00029 };
00030
00031 void MyMainFrame::ChangeStartLabel()
00032 {
00033
00034
00035
00036 fStart->SetState(kButtonDown);
00037 if (!start) {
00038 fStart->SetText("&Stop");
00039 start = kTRUE;
00040 } else {
00041 fStart->SetText("&Start");
00042 start = kFALSE;
00043 }
00044 fStart->SetState(kButtonUp);
00045 }
00046
00047 void MyMainFrame::ChangePauseLabel()
00048 {
00049
00050
00051
00052 fPause->SetState(kButtonDown);
00053 if (!pause) {
00054 fPause->SetText("&Resume");
00055 pause = kTRUE;
00056 } else {
00057 fPause->SetText("&Pause");
00058 pause = kFALSE;
00059 }
00060 fPause->SetState(kButtonUp);
00061 }
00062
00063 MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
00064 TGMainFrame(p, w, h)
00065 {
00066
00067 fCframe = new TGCompositeFrame(this, 170, 20, kHorizontalFrame|kFixedWidth);
00068
00069 fStart = new TGTextButton(fCframe, "&Start");
00070 fStart->Connect("Clicked()", "MyMainFrame", this, "ChangeStartLabel()");
00071 fCframe->AddFrame(fStart, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
00072 3, 2, 2, 2));
00073 fStart->SetToolTipText("Click to toggle the button label (Start/Stop)");
00074 start = kFALSE;
00075
00076 fPause = new TGTextButton(fCframe, "&Pause");
00077 fPause->Connect("Clicked()", "MyMainFrame", this, "ChangePauseLabel()");
00078 fPause->SetToolTipText("Click to toggle the button label (Pause/Resume)");
00079 fCframe->AddFrame(fPause, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
00080 3, 2, 2, 2));
00081 pause = kFALSE;
00082
00083 AddFrame(fCframe, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1));
00084
00085 fExit = new TGTextButton(this, "&Exit ","gApplication->Terminate(0)");
00086 AddFrame(fExit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,5,5,2,2));
00087
00088 SetWindowName("Change Labels");
00089
00090 MapSubwindows();
00091 Resize(GetDefaultSize());
00092 MapWindow();
00093 }
00094
00095
00096 MyMainFrame::~MyMainFrame()
00097 {
00098
00099 fCframe->Cleanup();
00100 Cleanup();
00101 }
00102
00103
00104 void buttonChangelabel()
00105 {
00106
00107 new MyMainFrame(gClient->GetRoot(), 350, 80);
00108 }