Hi There,
This is probably a simple questions, but I haven’t found an elegant solution and was hoping for some help.
I would like to end up with a window containing a canvas with a predetermined size. The problem is:
-
Using TCanvas::SetWindowSize() causes the window to have the dimensions specified but the canvas will be smaller
-
Using TCanvas::SetCanvasSize() gives the correct canvas size but the window size is not modified so in most cases scroll bars show up (which I don’t want).
Is there a way to specify a canvas size and have the window grow automatically?
TCanvas::SetWindowSize() passes the Width and Height to TCanvasImp::SetWindowSize() which is an inline empty function as far as I can find. Where does ROOT save the new window size and how is the canvas resized to the window when using SetWindowSize()?
Basically, if I could find out how to calculate the size of the menu, border etc. I could expand the window by this amount and have the desired canvas size without scrollbars on the window. Unfortunately, I can’t find where ROOT calculates these sizes.
Thanks for you help.
Hi, [quote]Is there a way to specify a canvas size and have the window grow automatically?[/quote]To specify the canvas size (cw, ch) and have the window around this canvas resized accordingly, you need to use TCanvas::SetWindowSize(cw+4, ch+28) method. The additional 4 pixels along the width and 28 pixels along the height are for borders and the menu. All this is hard coded in TCanvas.cxx. [quote]Where does ROOT save the new window size and how is the canvas resized to the window when using SetWindowSize()? [/quote]TRootCanvas class takes care about the GUI around the canvas window, but it keeps the sizes as they are set in TCanvas.cxx for fCw, fCh, fWindowWidth and fWindowHeight.
Cheers, Ilka
Thanks Ilka,
If that’s the “approved” way to do it, then that’s good enough. Perhaps it would be useful to have the “available window size” as a member variable (accessible through an access function) so that if these constants change in the future, it wouldn’t break anybody’s code. Or perhaps this isn’t that important to most people, just a suggestions.
Also, I added this thread after doing a search and didn’t notice that I ended up in the wrong forum. Is there anyway to move this thread to a more appropriate forum?
Sorry about that, and thanks for your help.
Josh
Hi Josh,
First, I moved this topic to ROOT Support. About the rest, I can only say that the code was as it is since years. I will try to understand the reasons why it was done this way and will include your request in our todo list.
Cheers, Ilka