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

// 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 *fH1 = new TGHorizontalFrame(fVf, 10, 50, kFixedHeight);
   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");

   fFtop->AddFrame(fLtop, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 0, 0));
   fFbottom->AddFrame(fLbottom, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 0, 0));

   fH1->AddFrame(fFtop, new TGLayoutHints(kLHintsTop | kLHintsExpandY | kLHintsExpandX, 0, 0, 1, 2));
   fH2->AddFrame(fFbottom, new TGLayoutHints(kLHintsTop | kLHintsExpandY | kLHintsExpandX, 0, 0, 1, 2));

   fH1->Resize(fFtop->GetDefaultWidth(), fH1->GetDefaultHeight()+20);
   fH2->Resize(fFbottom->GetDefaultWidth(), fH2->GetDefaultHeight()+20);
   fVf->AddFrame(fH1, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

   TGHSplitter *hsplitter = new TGHSplitter(fVf,2,2);
   hsplitter->SetFrame(fH1, kTRUE);
   fVf->AddFrame(hsplitter, new TGLayoutHints(kLHintsTop | kLHintsExpandX));

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