Logo ROOT  
Reference Guide
splitterHorizontal.C File Reference

Detailed Description

This macro gives an example of how to create a horizontal splitter. To run it do either:

.x splitterHorizontal.C
.x splitterHorizontal.C++
#include <TGClient.h>
#include <TGButton.h>
#include <TGLabel.h>
#include <TGFrame.h>
#include <TGLayout.h>
#include <TGSplitter.h>
class MyMainFrame : public TGMainFrame {
public:
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MyMainFrame();
void DoSave();
void CloseWindow();
ClassDef(MyMainFrame, 0)
};
void MyMainFrame::DoSave()
{
//------ TGMainFrame::SaveSource() --------
Printf("Save in progress...");
SaveSource("","");
}
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
TGMainFrame(p, w, h)
{
// Create horizontal splitter
TGVerticalFrame *fVf = new TGVerticalFrame(this, 10, 10);
TGHorizontalFrame *fH2 = new TGHorizontalFrame(fVf, 10, 10);
TGCompositeFrame *fFtop = new TGCompositeFrame(fH1, 10, 10, kSunkenFrame);
TGCompositeFrame *fFbottom = new TGCompositeFrame(fH2, 10, 10, kSunkenFrame);
TGLabel *fLtop = new TGLabel(fFtop, "Top Frame");
TGLabel *fLbottom = new TGLabel(fFbottom, "Bottom Frame");
3, 0, 0, 0));
fFbottom->AddFrame(fLbottom, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
3, 0, 0, 0));
kLHintsExpandX, 0, 0, 1, 2));
kLHintsExpandX, 0, 0, 1, 2));
fH1->Resize(fFtop->GetDefaultWidth(), fH1->GetDefaultHeight()+20);
fH2->Resize(fFbottom->GetDefaultWidth(), fH2->GetDefaultHeight()+20);
TGHSplitter *hsplitter = new TGHSplitter(fVf,2,2);
hsplitter->SetFrame(fH1, kTRUE);
// button frame
TGVerticalFrame *hframe = new TGVerticalFrame(this, 10, 10);
TGCompositeFrame *cframe2 = new TGCompositeFrame(hframe, 170, 50,
TGTextButton *save = new TGTextButton(cframe2, "&Save");
3, 2, 2, 2));
save->Connect("Clicked()", "MyMainFrame", this, "DoSave()");
save->SetToolTipText("Click on the button to save the application as C++ macro");
TGTextButton *exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");
2, 0, 2, 2));
hframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
// What to clean up in dtor
SetCleanup(kDeepCleanup);
// Set a name to the main frame
SetWindowName("Horizontal Splitter");
SetWMSizeHints(300, 250, 600, 600, 0, 0);
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
// Clean up all widgets, frames and layouthints that were used
Cleanup();
}
//______________________________________________________________________________
void MyMainFrame::CloseWindow()
{
// Called when window is closed via the window manager.
delete this;
}
void splitterHorizontal()
{
// Popup the GUI...
new MyMainFrame(gClient->GetRoot(), 300, 250);
}
Author
Ilka Antcheva 1/12/2006

Definition in file splitterHorizontal.C.

TGButton::SetToolTipText
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition: TGButton.cxx:398
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
kFixedWidth
@ kFixedWidth
Definition: GuiTypes.h:387
TGMainFrame
Definition: TGFrame.h:444
kLHintsTop
@ kLHintsTop
Definition: TGLayout.h:40
TGLayout.h
kLHintsLeft
@ kLHintsLeft
Definition: TGLayout.h:37
TGLabel
Definition: TGLabel.h:32
TGTextButton
Definition: TGButton.h:142
TGHorizontalFrame
Definition: TGFrame.h:423
gClient
#define gClient
Definition: TGClient.h:166
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
kFixedHeight
@ kFixedHeight
Definition: GuiTypes.h:389
kLHintsCenterY
@ kLHintsCenterY
Definition: TGLayout.h:41
h
#define h(i)
Definition: RSha256.hxx:124
TGVerticalFrame
Definition: TGFrame.h:412
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGFrame.h
kLHintsRight
@ kLHintsRight
Definition: TGLayout.h:39
TGLayoutHints
Definition: TGLayout.h:57
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
kLHintsExpandY
@ kLHintsExpandY
Definition: TGLayout.h:44
TGClient.h
TGMainFrame::CloseWindow
virtual void CloseWindow()
Close and delete main frame.
Definition: TGFrame.cxx:1731
TGCompositeFrame::GetDefaultHeight
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:351
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
Printf
void Printf(const char *fmt,...)
TGLabel.h
TGHSplitter
Definition: TGSplitter.h:100
TQObject::Connect
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition: TQObject.cxx:864
TGHSplitter::SetFrame
virtual void SetFrame(TGFrame *frame, Bool_t above)
Set frame to be resized.
Definition: TGSplitter.cxx:341
TGSplitter.h
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGButton.h
kDeepCleanup
@ kDeepCleanup
Definition: TGFrame.h:51
kLHintsExpandX
@ kLHintsExpandX
Definition: TGLayout.h:43
TGCompositeFrame::GetDefaultWidth
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:349
TGCompositeFrame
Definition: TGFrame.h:324
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102