Hi rooters,
I have build a very simple GUI class (see attached file) which
builds a frame with to frames inside separated by a vertical splitter. I
think I have done the things correctly, but the splitter doesn't work.
When you are over it the pointer changes accordingly, but it does not
resize the windows. I am missing something?...
I have tested with root.3.03.08 under linux 7.3 with gcc 2.96 and gcc 3.2
Thanks for your help,
Isidro
PS.: Instructions...
1) Save the attached file somewhere
2) Run root
3) root [0] .L RootMainFrame.C+
4) root [1] new RootMainFrame(gClient->GetRoot(),800,600)
5) Try to move the splitter....
+---------------------------+--------------------------------+
| Isidro González Caballero | mailto:Isidro.Gonzalez@cern.ch |
| CERN-EP / Mailbox: F28010 | http://home.cern.ch/~iglez/ |
| 1211 Geneva 23 | -o- |
| Switzerland | Tel: +41 22 76 73060, 73316 |
+---------------------------+--------------------------------+
#include <TGFrame.h>
#include <TGStatusBar.h> //For TGStatusBar::SetText...
#include <TGSplitter.h>
#include <RQ_OBJECT.h>
#include <iostream.h>
class RootMainFrame : public TGMainFrame {
RQ_OBJECT("RootMainFrame")
public:
//////////////////////////////////////////////////////////////
// Constructor and Destructor
//
RootMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~RootMainFrame();
private:
static Int_t fgDefaultXPosition; // default X position of top left corner
static Int_t fgDefaultYPosition; // default Y position of top left corner
//All the different layouts
TGLayoutHints* fLMainFrame;
TGLayoutHints* fLLeftFrame;
TGLayoutHints* fLRightFrame;
TGLayoutHints* fLVSplitter;
//Frames and subframes
TGCompositeFrame* fMainFrame; //The Central one
TGCompositeFrame* fLeftFrame; //For the left frame
TGCompositeFrame* fRightFrame; //For the right frame
TGVSplitter* fVSplitter; //Splitter between right and left frames
ClassDef(RootMainFrame,0)
};
Int_t RootMainFrame::fgDefaultXPosition = 25;
Int_t RootMainFrame::fgDefaultYPosition = 25;
/////////////////////////////////////////////////////////////////////////////
// Constructor
RootMainFrame::RootMainFrame(const TGWindow *p, UInt_t w, UInt_t h):
TGMainFrame(p, w, h) {
// Layout hints
fLMainFrame = new TGLayoutHints(kLHintsTop | kLHintsLeft |
kLHintsExpandY | kLHintsExpandX,
0, 0, 0, 0);
fLLeftFrame = new TGLayoutHints(kLHintsTop | kLHintsLeft |
kLHintsExpandX | kLHintsExpandY,
2, 2, 2, 2);
fLRightFrame = new TGLayoutHints(kLHintsTop | kLHintsRight |
kLHintsExpandX | kLHintsExpandY,
2, 2, 2, 2);
//------------------- Main frame in top Window
fMainFrame = new TGCompositeFrame(this, 100, 100,
kFixedWidth |
kHorizontalFrame | kRaisedFrame);
AddFrame(fMainFrame, fLMainFrame);
// ------- Create Left frame in Main Window
fLeftFrame = new TGVerticalFrame(fMainFrame, 100, 300,
kFixedWidth);
fMainFrame->AddFrame(fLeftFrame, fLLeftFrame);
// ------- Vertical splitter between frames
fVSplitter = new TGVSplitter(fMainFrame);
fVSplitter->SetFrame(fLeftFrame,kTRUE);
fLVSplitter = new TGLayoutHints(kLHintsLeft | kLHintsExpandY);
fMainFrame->AddFrame(fVSplitter,fLVSplitter);
// ------- Create Right Frame
fRightFrame = new TGVerticalFrame(fMainFrame, 500, 30,
kSunkenFrame | kDoubleBorder);
fMainFrame->AddFrame(fRightFrame, fLRightFrame);
//Set Window and Icon Name
SetWindowName("Root Window Name");
SetIconName("Root Icon Name");
//Last Operations for display
MapSubwindows();
Layout();
Resize(w,h); // this is used here to init layout algoritme
this->Move(fgDefaultXPosition, fgDefaultYPosition);
MapWindow();
//gSystem->ProcessEvents();
}
///////////////////////////////////////////////////////////////////////////
// Destructor
RootMainFrame::~RootMainFrame(){
//Layouts
if (fLLeftFrame)
delete fLLeftFrame;
if (fLRightFrame)
delete fLRightFrame;
if (fLVSplitter)
delete fLVSplitter;
if (fLMainFrame)
delete fLMainFrame;
//Frames
if (fLeftFrame)
delete fLeftFrame;
if (fRightFrame)
delete fRightFrame;
if (fVSplitter)
delete fVSplitter;
if (fMainFrame)
delete fMainFrame;
}
ClassImpQ(RootMainFrame)
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET