GUI "overlay"

Hi Rooters,
I have confused people when asking this question. I’ll try to be more specifiic: I use scripts from within my MFC application using process line with the following in my scripts:
{
TCanvas* fCanvas2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(“ScriptCanvas”);

Everything done in the script now appears within the “ScriptCanvas”. I would like to use GUI widgets ias well but I have only been able to do so by instantiating a new TGMainFrame:
fMain = new TGMainFrame(gClient->GetRoot(), 100, 100);[/color]
Is there a way to build a GUI frame within my canvas?
Cheers,
Steve

Hi Steve,

I’m not sure I understand very well what you want to do…
Do you want to mix ROOT GUI widgets with (or within) MFC controls/windows ?
If it is what you want to do, it is not possible. The one and only ROOT widget you can embed in an external window is a TCanvas.
Why not using MFC controls directly ?
Or even better, just use ROOT alone (without MFC), and build your own GUI…
If I didn’t understand correctly, maybe send a demo application with the precise description of what you want to achieve.

Cheers,
Bertrand.

Bertrand,
We had thought to use Root scripts when possible to make it easier to migrate to an all Root solution when possible. If we are forced to continue with a Windows machine we plan to use QT4 when it is supported. Until then the GUI elements will be MFC based. Thanks.
Cheers,
Steve

Hi Steve,

FYI, ROOT GUI works natively on Windows, without need of any extra layer… and is fully compatible with Linux & MAC.
(And I’m personaly not a big fan of Qt :wink: )

Cheers,
Bertrand.

Bertrand,
We have a requirement for a “windows look and feel”. Can you suggest an example of a standalone example?
Regards,
Steve

Try for example (ROOTSYS)/test/guitest.exe or (ROOTSYS)/test/RootShower.exe (see attached picture).
I have real examples used in industry, if you want I can put some screenshots.


[quote=“salam”]If we are forced to continue with a Windows machine we plan to use QT4 when it is supported. [/quote]Just for record. Qt4 will be supported by the end of June from Brookhaven National Laboratory ( root.bnl.gov ). “Look and feel” will be defined by your local Qt installation. This means if your local installation is “Windows Vista” you may have choosed “Vista”, for example. (You can still use the “old” Windows Windows95 “Look and Feel” also).

[quote=“salam”]Hi Rooters,
I have confused people when asking this question. I’ll try to be more specifiic: I use scripts from within my MFC application using process line with the following in my scripts:
{
TCanvas* fCanvas2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject(“ScriptCanvas”);

Everything done in the script now appears within the “ScriptCanvas”. I would like to use GUI widgets ias well but I have only been able to do so by instantiating a new TGMainFrame:
fMain = new TGMainFrame(gClient->GetRoot(), 100, 100);[/color]
Is there a way to build a GUI frame within my canvas?
Cheers,
Steve[/quote]Hi Steve,
The “frame” around of the TCanvas object is created by TCanvasImp class object. The later is created at the time of the TCanvas instantiation. This means, at the time of the FindObject invocation your TCanvas had been built with some sort of the main frame. At this point it is too later to change things.

From your description it is appeared you want the “embedded” TCanvas, i.e. you want to see TCanvas object as a part of your GUI. With the embedded TCanvas the “frame” is not created automatically. It is the end-user code responsibility.

You have to create it yourselves using some sort of GUI library (ROOT GUI / Qt GUI those provide you TCanvasImp class implementation or you have to invent TCanvasImp implementation on your own :slight_smile: . Either way you have to do that BEFORE FindObject is applied.

There are the other so-called “simplified solutions” to work within alien GUI environment. One is still required :open_mouth: to create his/her GUI object. However he /she is not required to provide TCanvasImp interface. (i.e. these are non-OO solutions. I do not think this thread is a right place to discuss OO / non-OO pro / cons ).

The “simplified solutions” look simpler :confused: to start with because one does not need to think much :wink: and learn the TCanvasImp interface. However, they are not scalable.

It is not possible to say in advance whether the “simplified solution” would satisfy your current and future needs.

I think ROOT tutorials contains many different examples of the “embedded” TCanvas done with all kind of the approaches I mentioned above to compare and choose one that fits your needs.

But … let me highlight. There is no magic here. You either use ready-to-eat one size fit all standard ROOT TCanvas frame or have to create it yourself. You have to write GUI code to work amid your GUI widgets and adjust it each time you upgrade the ROOT version/