TCanvas::SetWindowSize extension proposal

The TCanvas::SetCanvasSize method works in interactive and batch modes while the TCanvas::SetWindowSize works in interactive mode only.

So, I would like to propose that the TCanvas::SetWindowSize is modified into (it will then work in both modes, too):

void              SetWindowSize(UInt_t ww, UInt_t wh) { if (fBatch) SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2); else if (fCanvasImp) fCanvasImp->SetWindowSize(ww, wh); }

BTW. Wonder why “SetCanvasSize((ww + fCw) / 2, (wh + fCh) / 2)”? Well, that’s because the TCanvas shows the typical usage “c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh()));”, so we need to “recalculate” parameters’ values (in order to get the original “w” and “h”).

1 Like

Thanks for your input.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

After applying your patch always get:

Processing canvas_size.C...
798 575
800 600
798 575
800 600
796 572
800 600
796 572
800 600

running canvas_size.C (1.2 KB)

Patch applied: https://github.com/root-project/root/pull/1138