From $ROOTSYS/tutorials/gui/splitterVertical.C

//
// Author: Ilka Antcheva   1/12/2006

// 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");

   fFleft->AddFrame(fLleft, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                              3, 0, 0, 0));
   fFright->AddFrame(fLright, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
                                                3, 0, 0, 0));

   fV1->AddFrame(fFleft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
                                           0, 0, 5, 10));
   fV2->AddFrame(fFright, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
                                            0, 0, 5, 10));

   fV1->Resize(fFleft->GetDefaultWidth()+20, fV1->GetDefaultHeight());
   fV2->Resize(fFright->GetDefaultWidth(), fV1->GetDefaultHeight());
   fHf->AddFrame(fV1, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));

   TGVSplitter *splitter = new TGVSplitter(fHf,2,2);
   splitter->SetFrame(fV1, kTRUE);
   fHf->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));

   fHf->AddFrame(fV2, new TGLayoutHints(kLHintsRight | kLHintsExpandX |
                                        kLHintsExpandY));
   AddFrame(fHf, new TGLayoutHints(kLHintsRight | kLHintsExpandX |
                                   kLHintsExpandY));

   // button frame
   TGVerticalFrame *vframe = new TGVerticalFrame(this, 10, 10);
   TGCompositeFrame *cframe2 = new TGCompositeFrame(vframe, 170, 20,
                                             kHorizontalFrame | kFixedWidth);
   TGTextButton *save = new TGTextButton(cframe2, "&Save");
   cframe2->AddFrame(save, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             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)");
   cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
                                             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);
}
 splitterVertical.C:1
 splitterVertical.C:2
 splitterVertical.C:3
 splitterVertical.C:4
 splitterVertical.C:5
 splitterVertical.C:6
 splitterVertical.C:7
 splitterVertical.C:8
 splitterVertical.C:9
 splitterVertical.C:10
 splitterVertical.C:11
 splitterVertical.C:12
 splitterVertical.C:13
 splitterVertical.C:14
 splitterVertical.C:15
 splitterVertical.C:16
 splitterVertical.C:17
 splitterVertical.C:18
 splitterVertical.C:19
 splitterVertical.C:20
 splitterVertical.C:21
 splitterVertical.C:22
 splitterVertical.C:23
 splitterVertical.C:24
 splitterVertical.C:25
 splitterVertical.C:26
 splitterVertical.C:27
 splitterVertical.C:28
 splitterVertical.C:29
 splitterVertical.C:30
 splitterVertical.C:31
 splitterVertical.C:32
 splitterVertical.C:33
 splitterVertical.C:34
 splitterVertical.C:35
 splitterVertical.C:36
 splitterVertical.C:37
 splitterVertical.C:38
 splitterVertical.C:39
 splitterVertical.C:40
 splitterVertical.C:41
 splitterVertical.C:42
 splitterVertical.C:43
 splitterVertical.C:44
 splitterVertical.C:45
 splitterVertical.C:46
 splitterVertical.C:47
 splitterVertical.C:48
 splitterVertical.C:49
 splitterVertical.C:50
 splitterVertical.C:51
 splitterVertical.C:52
 splitterVertical.C:53
 splitterVertical.C:54
 splitterVertical.C:55
 splitterVertical.C:56
 splitterVertical.C:57
 splitterVertical.C:58
 splitterVertical.C:59
 splitterVertical.C:60
 splitterVertical.C:61
 splitterVertical.C:62
 splitterVertical.C:63
 splitterVertical.C:64
 splitterVertical.C:65
 splitterVertical.C:66
 splitterVertical.C:67
 splitterVertical.C:68
 splitterVertical.C:69
 splitterVertical.C:70
 splitterVertical.C:71
 splitterVertical.C:72
 splitterVertical.C:73
 splitterVertical.C:74
 splitterVertical.C:75
 splitterVertical.C:76
 splitterVertical.C:77
 splitterVertical.C:78
 splitterVertical.C:79
 splitterVertical.C:80
 splitterVertical.C:81
 splitterVertical.C:82
 splitterVertical.C:83
 splitterVertical.C:84
 splitterVertical.C:85
 splitterVertical.C:86
 splitterVertical.C:87
 splitterVertical.C:88
 splitterVertical.C:89
 splitterVertical.C:90
 splitterVertical.C:91
 splitterVertical.C:92
 splitterVertical.C:93
 splitterVertical.C:94
 splitterVertical.C:95
 splitterVertical.C:96
 splitterVertical.C:97
 splitterVertical.C:98
 splitterVertical.C:99
 splitterVertical.C:100
 splitterVertical.C:101
 splitterVertical.C:102
 splitterVertical.C:103
 splitterVertical.C:104
 splitterVertical.C:105
 splitterVertical.C:106
 splitterVertical.C:107
 splitterVertical.C:108
 splitterVertical.C:109
 splitterVertical.C:110
 splitterVertical.C:111
 splitterVertical.C:112
 splitterVertical.C:113
 splitterVertical.C:114
 splitterVertical.C:115
 splitterVertical.C:116
 splitterVertical.C:117
 splitterVertical.C:118
 splitterVertical.C:119
 splitterVertical.C:120
 splitterVertical.C:121
 splitterVertical.C:122