22 class MyMainFrame :
public TGMainFrame {
25 MyMainFrame(
const TGWindow *p, UInt_t w, UInt_t h);
26 virtual ~MyMainFrame();
30 ClassDef(MyMainFrame, 0)
33 void MyMainFrame::DoSave()
36 Printf(
"Save in progress...");
40 MyMainFrame::MyMainFrame(
const TGWindow *p, UInt_t w, UInt_t h) :
44 TGVerticalFrame *fVf =
new TGVerticalFrame(
this, 10, 10);
46 TGHorizontalFrame *fH1 =
new TGHorizontalFrame(fVf, 10, 50, kFixedHeight);
47 TGHorizontalFrame *fH2 =
new TGHorizontalFrame(fVf, 10, 10);
48 TGCompositeFrame *fFtop =
new TGCompositeFrame(fH1, 10, 10, kSunkenFrame);
49 TGCompositeFrame *fFbottom =
new TGCompositeFrame(fH2, 10, 10, kSunkenFrame);
51 TGLabel *fLtop =
new TGLabel(fFtop,
"Top Frame");
52 TGLabel *fLbottom =
new TGLabel(fFbottom,
"Bottom Frame");
54 fFtop->AddFrame(fLtop,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
56 fFbottom->AddFrame(fLbottom,
new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
59 fH1->AddFrame(fFtop,
new TGLayoutHints(kLHintsTop | kLHintsExpandY |
60 kLHintsExpandX, 0, 0, 1, 2));
61 fH2->AddFrame(fFbottom,
new TGLayoutHints(kLHintsTop | kLHintsExpandY |
62 kLHintsExpandX, 0, 0, 1, 2));
64 fH1->Resize(fFtop->GetDefaultWidth(), fH1->GetDefaultHeight()+20);
65 fH2->Resize(fFbottom->GetDefaultWidth(), fH2->GetDefaultHeight()+20);
66 fVf->AddFrame(fH1,
new TGLayoutHints(kLHintsTop | kLHintsExpandX));
68 TGHSplitter *hsplitter =
new TGHSplitter(fVf,2,2);
69 hsplitter->SetFrame(fH1, kTRUE);
70 fVf->AddFrame(hsplitter,
new TGLayoutHints(kLHintsTop | kLHintsExpandX));
72 fVf->AddFrame(fH2,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
75 TGVerticalFrame *hframe =
new TGVerticalFrame(
this, 10, 10);
76 TGCompositeFrame *cframe2 =
new TGCompositeFrame(hframe, 170, 50,
77 kHorizontalFrame | kFixedWidth);
78 TGTextButton *save =
new TGTextButton(cframe2,
"&Save");
79 cframe2->AddFrame(save,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,
81 save->Connect(
"Clicked()",
"MyMainFrame",
this,
"DoSave()");
82 save->SetToolTipText(
"Click on the button to save the application as C++ macro");
84 TGTextButton *exit =
new TGTextButton(cframe2,
"&Exit ",
"gApplication->Terminate(0)");
85 cframe2->AddFrame(exit,
new TGLayoutHints(kLHintsTop | kLHintsExpandX,
87 hframe->AddFrame(cframe2,
new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
89 AddFrame(fVf,
new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY));
90 AddFrame(hframe,
new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
93 SetCleanup(kDeepCleanup);
96 SetWindowName(
"Horizontal Splitter");
97 SetWMSizeHints(300, 250, 600, 600, 0, 0);
99 Resize(GetDefaultSize());
103 MyMainFrame::~MyMainFrame()
110 void MyMainFrame::CloseWindow()
117 void splitterHorizontal()
121 new MyMainFrame(gClient->GetRoot(), 300, 250);