Hi.
Is there some ``theory of Root TG GUI widgets'' document that will
explain how to layout and use the various TG GUI classes? I have
looked through the newgui.html, the Xclass tutorial and some of the
code in tutorial/ and test/ but am still unsure about a lot of things.
In particular, when a frame holds other frames I am unsure about how
the sizing works. Often sub frames appear jumbled (manually resizing
the window causes them to sort out, but can't rely on that).
As a concrete example, consider the appended program. Running it via:
./test-gui 0 0 # jumbled
./test-gui 0 1 # jumbled
./test-gui 1 0 # layout okay, but canvases white
./test-gui 1 1 # layout okay, but canvases white
to see some of my confusion. In the latter two cases, manually
resizing the windows causes the canvases to turn their default grayish
colors.
Thanks,
-Brett.
//////////////////
// test-gui.cxx
// compile with:
// g++ -o test-gui test-gui.cxx `root-config --cflags --glibs`
#include "TROOT.h"
#include "TApplication.h"
#include "TGWindow.h"
#include "TGFrame.h"
#include "TGLayout.h"
#include "TRootEmbeddedCanvas.h"
#include <cstdlib>
#include <iostream>
UInt_t gCanvas1Offset = 0;
UInt_t gCanvas2Offset = 0;
class DisplayBase : public TGMainFrame {
protected:
TGCompositeFrame* fMainArea;
public:
DisplayBase(const TGWindow* win, UInt_t w, UInt_t h) : TGMainFrame(win,w,h) {
fMainArea = new TGCompositeFrame(this,w,h);
TGLayoutHints* loh = new TGLayoutHints(kLHintsTop |
kLHintsLeft |
kLHintsExpandX |
kLHintsExpandY);
this->AddFrame(fMainArea,loh);
}
virtual ~DisplayBase() {}
};
class ConcreteDisplay : public DisplayBase {
TRootEmbeddedCanvas *fRECanvas1, *fRECanvas2;
public:
ConcreteDisplay(const TGWindow* win, UInt_t w, UInt_t h) : DisplayBase(win,w,h) {
cerr << "ConcreteDisplay: fMainArea default size is "
<< fMainArea->GetWidth() << " X " << fMainArea->GetHeight() << endl;
TGLayoutHints* loh = new TGLayoutHints(kLHintsTop |
kLHintsLeft |
kLHintsExpandX |
kLHintsExpandY);
fRECanvas1 = new TRootEmbeddedCanvas("canvas 1", fMainArea,
w,h/2-gCanvas1Offset);
fMainArea->AddFrame(fRECanvas1,loh);
fRECanvas2 = new TRootEmbeddedCanvas("canvas 2", fMainArea,
w,h/2-gCanvas1Offset);
fMainArea->AddFrame(fRECanvas2,loh);
// as in guitest.C
this->MapSubwindows();
this->Resize(fMainArea->GetDefaultSize());
this->MapWindow();
};
};
int main (int argc, char *argv[])
{
TROOT blah("simple-main","MIDAD");
TApplication app("MIDAD",&argc,argv,0,0);
if (argc >= 2) gCanvas1Offset = atoi(argv[1]);
if (argc >= 2) gCanvas2Offset = atoi(argv[2]);
ConcreteDisplay c(gClient->GetRoot(),500,500);
app.Run();
return 0;
} // end of main()
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET