Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
splitterVertical.C File Reference

Detailed Description

This macro gives an example of how to create a vertical splitter.

To run it do either:

.x splitterVertical.C
.x splitterVertical.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()
{
Printf("Save in progress...");
SaveSource("","");
}
//______________________________________________________________________________
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
TGMainFrame(p, w, h)
{
// Create vertical splitter
TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 50, 50);
TGVerticalFrame *fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
TGVerticalFrame *fV2 = new TGVerticalFrame(fHf, 10, 10);
TGCompositeFrame *fFleft = new TGCompositeFrame(fV1, 10, 10, kSunkenFrame);
TGCompositeFrame *fFright = new TGCompositeFrame(fV2, 10, 10, kSunkenFrame);
TGLabel *fLleft = new TGLabel(fFleft, "Left Frame");
TGLabel *fLright = new TGLabel(fFright, "Right Frame");
3, 0, 0, 0));
3, 0, 0, 0));
0, 0, 5, 10));
0, 0, 5, 10));
fV1->Resize(fFleft->GetDefaultWidth()+20, fV1->GetDefaultHeight());
fV2->Resize(fFright->GetDefaultWidth(), fV1->GetDefaultHeight());
TGVSplitter *splitter = new TGVSplitter(fHf,2,2);
splitter->SetFrame(fV1, kTRUE);
// button frame
TGVerticalFrame *vframe = new TGVerticalFrame(this, 10, 10);
TGCompositeFrame *cframe2 = new TGCompositeFrame(vframe, 170, 20,
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));
vframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
AddFrame(vframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
// What to clean up in destructor
SetCleanup(kDeepCleanup);
// Set a name to the main frame
SetWindowName("Vertical Splitter");
SetWMSizeHints(350, 200, 600, 400, 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 splitterVertical()
{
// Popup the GUI...
new MyMainFrame(gClient->GetRoot(), 350, 200);
}
@ kSunkenFrame
Definition GuiTypes.h:383
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
#define h(i)
Definition RSha256.hxx:106
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassDef(name, id)
Definition Rtypes.h:325
#define gClient
Definition TGClient.h:157
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
void Printf(const char *fmt,...)
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:445
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:312
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:314
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:386
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:398
virtual void CloseWindow()
Close and delete main frame.
Definition TGFrame.cxx:1770
Yield an action as soon as it is clicked.
Definition TGButton.h:142
A composite frame that layout their children in vertical way.
Definition TGFrame.h:375
ROOT GUI Window base class.
Definition TGWindow.h:23
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:869
REAL splitter
Definition triangle.c:617
Author
Ilka Antcheva 1/12/2006

Definition in file splitterVertical.C.