Public Member Functions | |
TestProgress (const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h) | |
virtual | ~TestProgress () |
void | CloseWindow () |
void | DoClose () |
void | DoGo () |
Private Attributes | |
TGTransientFrame * | fMain |
TGHorizontalFrame * | fHframe1 |
TGVerticalFrame * | fVframe1 |
TGLayoutHints * | fHint1 |
TGLayoutHints * | fHint2 |
TGLayoutHints * | fHint3 |
TGLayoutHints * | fHint4 |
TGLayoutHints * | fHint5 |
TGHProgressBar * | fHProg1 |
TGHProgressBar * | fHProg2 |
TGHProgressBar * | fHProg3 |
TGVProgressBar * | fVProg1 |
TGVProgressBar * | fVProg2 |
TGTextButton * | fGO |
Bool_t | fClose |
Definition at line 431 of file guitest.C.
TestProgress::TestProgress | ( | const TGWindow * | p, | |
const TGWindow * | main, | |||
UInt_t | w, | |||
UInt_t | h | |||
) |
Definition at line 2145 of file guitest.C.
02147 { 02148 // Dialog used to test the different supported progress bars. 02149 02150 fClose = kTRUE; 02151 02152 fMain = new TGTransientFrame(p, main, w, h); 02153 fMain->Connect("CloseWindow()", "TestProgress", this, "DoClose()"); 02154 fMain->DontCallClose(); 02155 02156 // use hierarchical cleaning 02157 fMain->SetCleanup(kDeepCleanup); 02158 02159 fMain->ChangeOptions((fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame); 02160 02161 fHframe1 = new TGHorizontalFrame(fMain, 0, 0, 0); 02162 02163 fVProg1 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300); 02164 fVProg1->SetBarColor("purple"); 02165 fVProg2 = new TGVProgressBar(fHframe1, TGProgressBar::kFancy, 300); 02166 fVProg2->SetFillType(TGProgressBar::kBlockFill); 02167 fVProg2->SetBarColor("green"); 02168 02169 fHframe1->Resize(300, 300); 02170 02171 fVframe1 = new TGVerticalFrame(fMain, 0, 0, 0); 02172 02173 fHProg1 = new TGHProgressBar(fVframe1, 300); 02174 fHProg1->ShowPosition(); 02175 fHProg2 = new TGHProgressBar(fVframe1, TGProgressBar::kFancy, 300); 02176 fHProg2->SetBarColor("lightblue"); 02177 fHProg2->ShowPosition(kTRUE, kFALSE, "%.0f events"); 02178 fHProg3 = new TGHProgressBar(fVframe1, TGProgressBar::kStandard, 300); 02179 fHProg3->SetFillType(TGProgressBar::kBlockFill); 02180 02181 fGO = new TGTextButton(fVframe1, "Go", 10); 02182 fGO->Connect("Clicked()", "TestProgress", this, "DoGo()"); 02183 02184 fVframe1->Resize(300, 300); 02185 02186 fHint1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 10, 5, 5); 02187 fHint2 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 5, 5, 5, 10); 02188 fHint3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 0, 50, 50, 0); 02189 fHint4 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0); 02190 fHint5 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0); 02191 02192 fHframe1->AddFrame(fVProg1, fHint1); 02193 fHframe1->AddFrame(fVProg2, fHint1); 02194 02195 fVframe1->AddFrame(fHProg1, fHint2); 02196 fVframe1->AddFrame(fHProg2, fHint2); 02197 fVframe1->AddFrame(fHProg3, fHint2); 02198 fVframe1->AddFrame(fGO, fHint3); 02199 02200 fMain->AddFrame(fHframe1, fHint4); 02201 fMain->AddFrame(fVframe1, fHint5); 02202 02203 fMain->SetWindowName("Progress Test"); 02204 TGDimension size = fMain->GetDefaultSize(); 02205 fMain->Resize(size); 02206 02207 // position relative to the parent's window 02208 fMain->CenterOnParent(); 02209 02210 fMain->MapSubwindows(); 02211 fMain->MapWindow(); 02212 02213 gClient->WaitFor(fMain); 02214 }
TestProgress::~TestProgress | ( | ) | [virtual] |
void TestProgress::CloseWindow | ( | ) |
void TestProgress::DoClose | ( | ) |
Definition at line 2230 of file guitest.C.
02231 { 02232 // If fClose is false we are still in event processing loop in DoGo(). 02233 // In that case, set the close flag true and use a timer to call 02234 // CloseWindow(). This gives us change to get out of the DoGo() loop. 02235 // Note: calling SendCloseMessage() will not work since that will 02236 // bring us back here (CloseWindow() signal is connected to this method) 02237 // with the fClose flag true, which will cause window deletion while 02238 // still being in the event processing loop (since SendCloseMessage() 02239 // is directly processed in ProcessEvents() without exiting DoGo()). 02240 02241 if (fClose) 02242 CloseWindow(); 02243 else { 02244 fClose = kTRUE; 02245 TTimer::SingleShot(150, "TestProgress", this, "CloseWindow()"); 02246 } 02247 }
void TestProgress::DoGo | ( | ) |
Definition at line 2249 of file guitest.C.
02250 { 02251 // Handle Go button. 02252 02253 fClose = kFALSE; 02254 fVProg1->Reset(); fVProg2->Reset(); 02255 fHProg1->Reset(); fHProg2->Reset(); fHProg3->Reset(); 02256 fVProg2->SetBarColor("green"); 02257 int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; 02258 int inc1 = 4, inc2 = 3, inc3 = 2, inc4 = 1; 02259 while (cnt1 < 100 || cnt2 < 100 || cnt3 < 100 || cnt4 <100) { 02260 if (cnt1 < 100) { 02261 cnt1 += inc1; 02262 fVProg1->Increment(inc1); 02263 } 02264 if (cnt2 < 100) { 02265 cnt2 += inc2; 02266 fVProg2->Increment(inc2); 02267 if (cnt2 > 75) 02268 fVProg2->SetBarColor("red"); 02269 } 02270 if (cnt3 < 100) { 02271 cnt3 += inc3; 02272 fHProg1->Increment(inc3); 02273 } 02274 if (cnt4 < 100) { 02275 cnt4 += inc4; 02276 fHProg2->Increment(inc4); 02277 fHProg3->Increment(inc4); 02278 } 02279 gSystem->Sleep(100); 02280 gSystem->ProcessEvents(); 02281 // if user closed window return 02282 if (fClose) return; 02283 } 02284 fClose = kTRUE; 02285 }
TGTransientFrame* TestProgress::fMain [private] |
TGHorizontalFrame* TestProgress::fHframe1 [private] |
TGVerticalFrame* TestProgress::fVframe1 [private] |
TGLayoutHints* TestProgress::fHint1 [private] |
TGLayoutHints * TestProgress::fHint2 [private] |
TGLayoutHints * TestProgress::fHint3 [private] |
TGLayoutHints * TestProgress::fHint4 [private] |
TGLayoutHints * TestProgress::fHint5 [private] |
TGHProgressBar* TestProgress::fHProg1 [private] |
TGHProgressBar * TestProgress::fHProg2 [private] |
TGHProgressBar * TestProgress::fHProg3 [private] |
TGVProgressBar* TestProgress::fVProg1 [private] |
TGVProgressBar * TestProgress::fVProg2 [private] |
TGTextButton* TestProgress::fGO [private] |
Bool_t TestProgress::fClose [private] |