96 TButton::TButton(): TPad()
111 TButton::TButton(
const char *title,
const char *method, Double_t x1, Double_t y1,Double_t x2, Double_t y2)
112 :TPad(
"button",title,x1,y1,x2,y2,18,2,1), TAttText(22,0,1,61,0.65)
119 TLatex *text =
new TLatex(0.5*(fX1+fX2),0.5*(fY1+fY2),title);
120 fPrimitives->Add(text);
133 if (fPrimitives) fPrimitives->Delete();
139 void TButton::Draw(Option_t *option)
141 if (fCanvas) AppendPad(option);
149 void TButton::ExecuteEvent(Int_t event, Int_t px, Int_t py)
152 if (!TestBit(kNotDeleted))
return;
155 TPad::ExecuteEvent(event,px,py);
159 TPad *cdpad = (TPad*)gROOT->GetSelectedPad();
165 TPad::ExecuteEvent(event,px,py);
180 if (px<XtoAbsPixel(1) && px>XtoAbsPixel(0) &&
181 py<YtoAbsPixel(0) && py>YtoAbsPixel(1)) {
186 GetCanvas()->Modified();
189 }
else if (fFocused) {
193 GetCanvas()->Modified();
201 if (cdpad) cdpad->cd();
202 gROOT->ProcessLine(GetMethod());
205 if (!TestBit(kNotDeleted))
return;
217 void TButton::Paint(Option_t *option)
219 if (!fCanvas)
return;
220 if (!fPrimitives) fPrimitives =
new TList();
221 TObject *obj = GetListOfPrimitives()->First();
222 if (obj && obj->InheritsFrom(TText::Class())) {
223 TLatex *text = (TLatex*)obj;
224 text->SetTitle(GetTitle());
225 text->SetTextSize(GetTextSize());
226 text->SetTextFont(GetTextFont());
227 text->SetTextAlign(GetTextAlign());
228 text->SetTextColor(GetTextColor());
229 text->SetTextAngle(GetTextAngle());
239 void TButton::PaintModified()
241 if (!fCanvas)
return;
242 if (!fPrimitives) fPrimitives =
new TList();
243 TObject *obj = GetListOfPrimitives()->First();
244 if (obj && obj->InheritsFrom(TText::Class())) {
245 TLatex *text = (TLatex*)obj;
246 text->SetTitle(GetTitle());
247 text->SetTextSize(GetTextSize());
248 text->SetTextFont(GetTextFont());
249 text->SetTextAlign(GetTextAlign());
250 text->SetTextColor(GetTextColor());
251 text->SetTextAngle(GetTextAngle());
255 TPad::PaintModified();
261 void TButton::Range(Double_t x1, Double_t y1, Double_t x2, Double_t y2)
263 TPad::Range(x1,y1,x2,y2);
269 void TButton::SavePrimitive(std::ostream &out, Option_t * )
271 TPad *padsav = (TPad*)gPad;
273 if (gROOT->ClassSaved(TButton::Class())) {
278 char *cm = (
char*)GetMethod();
279 Int_t nch = strlen(cm);
280 char *cmethod =
new char[nch+10];
292 out<<
"button = new TButton("<<quote<<GetTitle()
293 <<quote<<
","<<quote<<cmethod<<quote
296 <<
","<<fXlowNDC+fWNDC
297 <<
","<<fYlowNDC+fHNDC
301 SaveFillAttributes(out,
"button",0,1001);
302 SaveLineAttributes(out,
"button",1,1,1);
303 SaveTextAttributes(out,
"button",22,0,1,61,.65);
305 if (GetBorderSize() != 2) {
306 out<<
" button->SetBorderSize("<<GetBorderSize()<<
");"<<std::endl;
308 if (GetBorderMode() != 1) {
309 out<<
" button->SetBorderMode("<<GetBorderMode()<<
");"<<std::endl;
312 if (GetFraming()) out<<
"button->SetFraming();"<<std::endl;
313 if (IsEditable()) out<<
"button->SetEditable(kTRUE);"<<std::endl;
315 out<<
" button->Draw();"<<std::endl;
317 TIter next(GetListOfPrimitives());
318 TObject *obj = next();
321 while ((obj = next())) {
322 if (!nprim) out<<
" button->cd();"<<std::endl;
324 obj->SavePrimitive(out, (Option_t *)next.GetOption());
327 if (nprim) out<<
" "<<padsav->GetName()<<
"->cd();"<<std::endl;
334 void TButton::SetFraming(Bool_t f)
337 if (f) SetBit(kFraming);
338 else ResetBit(kFraming);