From b6d0e64d6580693892b5aac89be61ef9cc10c198 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Wed, 13 May 2026 08:36:28 +0200 Subject: [PATCH 1/3] [nfc][gpad] clarify what decoration is included --- graf2d/gpad/src/TCanvas.cxx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/graf2d/gpad/src/TCanvas.cxx b/graf2d/gpad/src/TCanvas.cxx index be3908b3b363e..01339a807eb81 100644 --- a/graf2d/gpad/src/TCanvas.cxx +++ b/graf2d/gpad/src/TCanvas.cxx @@ -112,9 +112,10 @@ of the canvas. It gives a short explanation about the canvas' menus. A canvas may be automatically divided into pads via `TPad::Divide`. At creation time, no matter if in interactive or batch mode, the constructor -defines the size of the canvas window (including the size of the window -manager's decoration). To define precisely the graphics area size of a canvas in -the interactive mode, the following four lines of code should be used: +defines the size of the canvas window (including the size of the ROOT menu bar but +excluding the size of the OS window manager's decoration). To define precisely the +graphics area size of a canvas in batch/interactive mode, the following code should +be used: ~~~ {.cpp} { Double_t w = 600; @@ -123,11 +124,20 @@ the interactive mode, the following four lines of code should be used: c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh())); } ~~~ -and in the batch mode simply do: +Or if always in batch mode, simply do: ~~~ {.cpp} c->SetCanvasSize(w,h); ~~~ +If canvas was created with default size, you can use instead, both +for interactive/batch mode, to ensure compatible size in either mode: +~~~ {.cpp} + { + auto c = new TCanvas("c", "c"); + c->SetWindowSize(c->GetWindowWidth() + (c->GetWindowWidth() - c->GetWw()), c->GetWindowHeight() + (c->GetWindowHeight() - c->GetWh())); + } +~~~ + If the canvas size exceeds the window size, scroll bars will be added to the canvas This allows to display very large canvases (even bigger than the screen size). The Following example shows how to proceed. @@ -1940,8 +1950,8 @@ void TCanvas::SetBatch(Bool_t batch) /// are greater than the current canvas window a scroll bar is automatically /// generated. Use this function to zoom in a canvas and navigate via /// the scroll bars. The Width and Height in this method are different from those -/// given in the TCanvas constructors where these two dimension include the size -/// of the window decoration whereas they do not in this method. +/// given in the TCanvas constructors where these two dimensions include the size +/// of the ROOT canvas menubar decoration whereas they do not in this method. /// When both ww==0 and wh==0, auto resize mode will be enabled again and /// canvas drawing area will automatically fit available window size From 5b1f33b916b26f2bae4b293f72bf8ca59017d154 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 18 May 2026 09:21:36 +0200 Subject: [PATCH 2/3] Apply suggestion from @linev Co-authored-by: Sergey Linev --- graf2d/gpad/src/TCanvas.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/graf2d/gpad/src/TCanvas.cxx b/graf2d/gpad/src/TCanvas.cxx index 01339a807eb81..a95fae441065a 100644 --- a/graf2d/gpad/src/TCanvas.cxx +++ b/graf2d/gpad/src/TCanvas.cxx @@ -129,8 +129,7 @@ Or if always in batch mode, simply do: c->SetCanvasSize(w,h); ~~~ -If canvas was created with default size, you can use instead, both -for interactive/batch mode, to ensure compatible size in either mode: +To ensure similar painting size for the canvas created with default size for both interactive and batch mode: ~~~ {.cpp} { auto c = new TCanvas("c", "c"); From 1a0eb0246daf60c33efa6b6d922ce29a3b17454a Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Mon, 18 May 2026 09:25:20 +0200 Subject: [PATCH 3/3] reorder --- graf2d/gpad/src/TCanvas.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/graf2d/gpad/src/TCanvas.cxx b/graf2d/gpad/src/TCanvas.cxx index a95fae441065a..02f318e4a2f30 100644 --- a/graf2d/gpad/src/TCanvas.cxx +++ b/graf2d/gpad/src/TCanvas.cxx @@ -124,10 +124,6 @@ be used: c->SetWindowSize(w + (w - c->GetWw()), h + (h - c->GetWh())); } ~~~ -Or if always in batch mode, simply do: -~~~ {.cpp} - c->SetCanvasSize(w,h); -~~~ To ensure similar painting size for the canvas created with default size for both interactive and batch mode: ~~~ {.cpp} @@ -137,6 +133,11 @@ To ensure similar painting size for the canvas created with default size for bot } ~~~ +If you are in batch mode, you can also specify the fixed painting area as follows: +~~~ {.cpp} + c->SetCanvasSize(w, h); +~~~ + If the canvas size exceeds the window size, scroll bars will be added to the canvas This allows to display very large canvases (even bigger than the screen size). The Following example shows how to proceed.