Hi Galina, you can use check button http://root.cern.ch/root/html302/TGCheckButton.html Does it mean that you want "check button behavior" for text button? Regards. Valeriy > Hello, > > I'm using ROOT 3.02/07 under SuSE Linux 7.2 for an application (gui) > developing and I have a question concerning a button - it is not > sensitive enough - I mean when one wants to stop a process (that's the > aim of my button) he should see that the button really goes down (is > pressed). Otherwise, if you just click on it, without paying attention > does it sink, nothing happens - the process is still running. Does > anybody have any idea what is the reason for this and how it can be done? > The attachment is the code I've written - ArchiveStatus.cpp and > ArchiveStatus.h - concern the class which is doing all the stuff about > the button and the small piece of code after is where I'm using > ArchiveStatus.*. > > ArchiveStatus *as = new ArchiveStatus(gClient->GetRoot(), 230, 80); > Bool_t not_stop = kTRUE; > while (gtime <= end){ > if (as->fCancel->IsDown()){ > as->fStop = kTRUE; > not_stop = kFALSE; > break; > } > > Int_t skip = StepSize; > Bool_t SetIsComplete = kTRUE; > for (Int_t i=0; i < nr; i++) { > TTFFloatData *d = FetchObj(list[i],i, gtime,skip, cntr, names, signs, > values); > gtime, i, skip); > if ( (d == NULL) || (d->EventTime() > end) || (d->bad()) ) { > SetIsComplete = kFALSE; > if (d != NULL) delete d; > break; > } > else if (i == 0) ftime = d->EventTime(); > else if (ftime != d->EventTime()) { > SetIsComplete = kFALSE; > delete d; > break; > } > *data[i] = *d; > delete d; > } > > if (SetIsComplete) { > all++; > TTFFCp *FC = new TTFFCp[cntr]; > for (int j = 0; j < cntr; j++) > { > FC[j] = new TTFFetchCache(); > PosCacheCon[j] = 0; > } > Bool_t full_set = kTRUE; > for (int j = 0; j < cntr; j++){ > TTFFloatData > *cfe=ConditionFileEvent(names[j],signs[j],values[j],j,gtime,skip, FC[j], > p); > > if ((cfe == NULL) || (cfe->bad()) || (cfe->EventTime() > end)) > { > full_set = kFALSE; > if (cfe != NULL) delete cfe; > if (FC[j] != NULL) delete FC[j]; > break; > } > if (cfe->EventTime() != data[0]->EventTime()) > { > full_set = kFALSE; > delete cfe; > if (FC[j] != NULL) delete FC[j]; > break; > } > delete cfe; > cfe = NULL; > delete FC[j]; > > } > if (full_set){ > tree->Fill(); > ++counter; > gtime = data[0]->EventTime(); > SetEventsNumber(counter); > > if (not_stop) > as->RunFilter(TTFEventTime::Diff(gtime,begin)*100/iInterval); > > } > delete[] FC; > } > > for (Int_t j=0; j < nr; j++) data[j]->Reset(); > if (skip == -1) { > std::cerr << "Fatal error, aborting." << endl; > break; > } > gtime += skip; > gSystem->ProcessEvents(); > } > > for (int i = 0; i < nr; i++) delete fCache[i]; > > if (not_stop) as->CloseWindow(); > file://============ArchiveStatus.h > > #ifndef __ArchiveStatus_h__ > #define __ArchiveStatus_h__ > > > #include <TGFrame.h> > #include <TGClient.h> > #include <TGButton.h> > #include <TGProgressBar.h> > > #include "TTFConstant.h" > > const char PROGRESS_TITLE[] = "Estimated time"; > > enum ProgressBarWidgets > { > BT_STOP > }; > > class ArchiveStatus: public TGMainFrame{ > > private: > TGHorizontalFrame *fHorFr; > TGVerticalFrame *fVerFr; > TGLayoutHints *fHint, *fHint1; > > public: > > TGHProgressBar *fBar; > TGTextButton *fCancel; > Bool_t fStop; > > ArchiveStatus(const TGWindow *p, UInt_t w, UInt_t h); > ~ArchiveStatus(); > > void CloseWindow(void); > void FrameClose(void); > void RunFilter(Int_t increment); > file://Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); > inline void ResetBar(void) {fBar->Reset();}; > > ClassDef(ArchiveStatus,1) > > }; > > #endif > > > file://============ArchiveStatus.cpp > > #include <stdlib.h> > #include <iostream> > #include "TTFTransBuffer.h" > #include "ArchiveStatus.h" > #include <TGFrame.h> > > ClassImp(ArchiveStatus); > > ArchiveStatus::ArchiveStatus(const TGWindow *p, UInt_t w, UInt_t h): > TGMainFrame(p, w, h) > { > > fStop = kFALSE; > fHorFr = new TGHorizontalFrame(this, w, 40, kFixedWidth); > fVerFr = new TGVerticalFrame(this, w, 70, kFixedWidth); > > fBar = new TGHProgressBar (fVerFr, TGProgressBar::kStandard, 200); > fBar->ShowPosition(); > fBar->SetBarColor("lightblue"); > > fCancel = new TGTextButton(fVerFr, "Stop filter", BT_STOP); > fCancel->Connect("Clicked()", "ArchiveStatus", this, "FrameClose()"); > > fHint = new TGLayoutHints(kLHintsCenterX|kLHintsExpandX | > kLHintsCenterY,10,5,10,0); > fHint1 = new TGLayoutHints(kLHintsCenterX|kLHintsExpandX | > kLHintsCenterY,60,60,15,0); > fVerFr->Resize(230, 130); > > fHorFr->AddFrame(fBar, fHint); > fVerFr->AddFrame(fBar, fHint); > fVerFr->AddFrame(fCancel, fHint1); > AddFrame(fVerFr); > > > MapSubwindows(); > Layout(); > SetWindowName(PROGRESS_TITLE); > SetIconName("ArchiveStatus"); > MapWindow(); > > } > > ArchiveStatus::~ArchiveStatus() > { > delete fHint; > delete fBar; > delete fHorFr; > } > > void ArchiveStatus::CloseWindow() > { > SendCloseMessage(); > delete this; > } > > void ArchiveStatus::FrameClose(void) > { > cout << "Archive Filter aborted!" << endl; > if (fStop) SendCloseMessage(); > } > > void ArchiveStatus::RunFilter(Int_t increment) > { > fBar->SetPosition(increment); > } > >
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:16 MET