24 ClassImp(TGroupButton);
45 TGroupButton::TGroupButton(): TButton()
53 TGroupButton::TGroupButton(
const char *groupname,
const char *title,
const char *method, Double_t x1, Double_t y1,Double_t x2, Double_t y2)
54 :TButton(title,method,x1,y1,x2,y2)
56 SetName((
char*)groupname);
63 TGroupButton::~TGroupButton()
70 void TGroupButton::DisplayColorTable(
const char *action, Double_t x0, Double_t y0, Double_t wc, Double_t hc)
72 TGroupButton *colorpad;
75 Double_t xlow, ylow, hs, ws;
86 snprintf(command,32,
"%s(%d)",action,10*j+i+1);
87 colorpad =
new TGroupButton(
"Color",
"",command,xlow, ylow, xlow+0.9*ws, ylow+0.9*hs);
88 colorpad->SetFillColor(color);
89 colorpad->SetBorderSize(1);
90 if (i == 0 && j == 0) colorpad->SetBorderMode(-1);
103 void TGroupButton::ExecuteAction()
107 strlcpy(line,GetMethod(),128);
110 char *params = strchr(method,
'(');
114 char *end = strrchr(params,
')');
117 TDialogCanvas *canvas = (TDialogCanvas*)GetMother();
118 TObject *obj = canvas->GetRefObject();
120 if (strcmp(method,
"PIXELS")) {
121 obj->Execute(method,params);
123 TText *text = (TText*)GetListOfPrimitives()->First();
124 Int_t npixels = Int_t((YtoPixel(0) - YtoPixel(1))*text->GetTextSize());
126 pad = gROOT->GetSelectedPad();
128 Int_t nmax = (Int_t)(params-method);
129 if (obj->InheritsFrom(
"TPaveLabel")) {
130 TBox *pl = (TBox*)obj;
131 dy = pad->AbsPixeltoY(0) - pad->AbsPixeltoY(npixels);
132 snprintf(params,nmax,
"%f",dy/(pl->GetY2() - pl->GetY1()));
133 obj->Execute(
"SetTextSize",params);
135 if (obj->InheritsFrom(
"TPave")) {
136 dy = pad->AbsPixeltoY(0) - pad->AbsPixeltoY(npixels);
137 snprintf(params,nmax,
"%f",dy/(pad->GetY2() - pad->GetY1()));
138 obj->Execute(
"SetTextSize",params);
140 snprintf(params,nmax,
"%d",npixels);
141 obj->Execute(
"SetTextSizePixels",params);
152 void TGroupButton::ExecuteEvent(Int_t event, Int_t px, Int_t py)
154 if (fMother->IsEditable()) {
155 TPad::ExecuteEvent(event,px,py);
159 TCanvas *c = gPad->GetCanvas();
161 TIter next(c->GetListOfPrimitives());
163 TGroupButton *button;
165 TDialogCanvas *canvas;
181 if (!strcasecmp(GetName(),
"APPLY")) {
182 canvas = (TDialogCanvas*)GetMother();
183 if (!strcasecmp(GetTitle(),
"CLOSE")) {
187 pad = canvas->GetRefPad();
188 if (pad) pad->GetCanvas()->FeedbackMode(kFALSE);
189 canvas->Apply(GetTitle());
191 pad->Modified(kTRUE);
197 while ((obj = next())) {
198 if (obj ==
this)
continue;
199 if (obj->InheritsFrom(TGroupButton::Class())) {
200 button = (TGroupButton*)obj;
201 if (!strcmp(button->GetName(),GetName())) {
202 if (button->GetBorderMode() < 0) {
203 button->SetBorderMode(1);
221 void TGroupButton::SavePrimitive(std::ostream &out, Option_t * )
223 TPad *padsav = (TPad*)gPad;
225 if (gROOT->ClassSaved(TGroupButton::Class())) {
228 out<<
" TGroupButton *";
230 out<<
"button = new TGroupButton("<<quote<<GetName()<<quote<<
", "<<quote<<GetTitle()
231 <<quote<<
","<<quote<<GetMethod()<<quote
234 <<
","<<fXlowNDC+fWNDC
235 <<
","<<fYlowNDC+fHNDC
238 SaveFillAttributes(out,
"button",0,1001);
239 SaveLineAttributes(out,
"button",1,1,1);
240 SaveTextAttributes(out,
"button",22,0,1,62,.75);
242 if (GetBorderSize() != 2) {
243 out<<
" button->SetBorderSize("<<GetBorderSize()<<
");"<<std::endl;
245 if (GetBorderMode() != 1) {
246 out<<
" button->SetBorderMode("<<GetBorderMode()<<
");"<<std::endl;
249 out<<
" button->Draw();"<<std::endl;
250 out<<
" button->cd();"<<std::endl;
252 TIter next(GetListOfPrimitives());
253 TObject *obj = next();
255 while ((obj = next()))
256 obj->SavePrimitive(out, (Option_t *)next.GetOption());
258 out<<
" "<<padsav->GetName()<<
"->cd();"<<std::endl;