ROOT
master
Reference Guide
splitterHorizontal.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This macro gives an example of how to create a horizontal splitter.
4
/// To run it do either:
5
/// ~~~
6
/// .x splitterHorizontal.C
7
/// .x splitterHorizontal.C++
8
/// ~~~
9
///
10
/// \macro_code
11
///
12
/// \author Ilka Antcheva 1/12/2006
13
14
#include <
TGClient.h
>
15
#include <
TGButton.h
>
16
#include <
TGLabel.h
>
17
#include <
TGFrame.h
>
18
#include <
TGLayout.h
>
19
#include <
TGSplitter.h
>
20
21
22
class
MyMainFrame :
public
TGMainFrame
{
23
24
public
:
25
MyMainFrame(
const
TGWindow
*p,
UInt_t
w,
UInt_t
h
);
26
virtual
~MyMainFrame();
27
void
DoSave();
28
void
CloseWindow
();
29
30
ClassDef
(MyMainFrame, 0)
31
};
32
33
void
MyMainFrame::DoSave()
34
{
35
//------ TGMainFrame::SaveSource() --------
36
Printf
(
"Save in progress..."
);
37
SaveSource(
""
,
""
);
38
}
39
40
MyMainFrame::MyMainFrame(
const
TGWindow
*p,
UInt_t
w,
UInt_t
h
) :
41
TGMainFrame
(p, w,
h
)
42
{
43
// Create horizontal splitter
44
TGVerticalFrame
*fVf =
new
TGVerticalFrame
(
this
, 10, 10);
45
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
);
50
51
TGLabel
*fLtop =
new
TGLabel
(fFtop,
"Top Frame"
);
52
TGLabel
*fLbottom =
new
TGLabel
(fFbottom,
"Bottom Frame"
);
53
54
fFtop->
AddFrame
(fLtop,
new
TGLayoutHints
(
kLHintsLeft
|
kLHintsCenterY
,
55
3, 0, 0, 0));
56
fFbottom->
AddFrame
(fLbottom,
new
TGLayoutHints
(
kLHintsLeft
|
kLHintsCenterY
,
57
3, 0, 0, 0));
58
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));
63
64
fH1->
Resize
(fFtop->
GetDefaultWidth
(), fH1->
GetDefaultHeight
()+20);
65
fH2->
Resize
(fFbottom->
GetDefaultWidth
(), fH2->
GetDefaultHeight
()+20);
66
fVf->
AddFrame
(fH1,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
));
67
68
TGHSplitter
*hsplitter =
new
TGHSplitter
(fVf,2,2);
69
hsplitter->
SetFrame
(fH1,
kTRUE
);
70
fVf->
AddFrame
(hsplitter,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
));
71
72
fVf->
AddFrame
(fH2,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
));
73
74
// button frame
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
,
80
3, 2, 2, 2));
81
save->
Connect
(
"Clicked()"
,
"MyMainFrame"
,
this
,
"DoSave()"
);
82
save->
SetToolTipText
(
"Click on the button to save the application as C++ macro"
);
83
84
TGTextButton
*exit =
new
TGTextButton
(cframe2,
"&Exit "
,
"gApplication->Terminate(0)"
);
85
cframe2->
AddFrame
(exit,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
,
86
2, 0, 2, 2));
87
hframe->
AddFrame
(cframe2,
new
TGLayoutHints
(
kLHintsExpandX
, 2, 2, 5, 1));
88
89
AddFrame(fVf,
new
TGLayoutHints
(
kLHintsRight
|
kLHintsExpandX
|
kLHintsExpandY
));
90
AddFrame(hframe,
new
TGLayoutHints
(
kLHintsExpandX
, 2, 2, 5, 1));
91
92
// What to clean up in dtor
93
SetCleanup(
kDeepCleanup
);
94
95
// Set a name to the main frame
96
SetWindowName(
"Horizontal Splitter"
);
97
SetWMSizeHints(300, 250, 600, 600, 0, 0);
98
MapSubwindows();
99
Resize(GetDefaultSize());
100
MapWindow();
101
}
102
103
MyMainFrame::~MyMainFrame()
104
{
105
// Clean up all widgets, frames and layouthints that were used
106
Cleanup();
107
}
108
109
//______________________________________________________________________________
110
void
MyMainFrame::CloseWindow()
111
{
112
// Called when window is closed via the window manager.
113
114
delete
this
;
115
}
116
117
void
splitterHorizontal()
118
{
119
// Popup the GUI...
120
121
new
MyMainFrame(
gClient
->GetRoot(), 300, 250);
122
}
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:443
kLHintsTop
@ kLHintsTop
Definition:
TGLayout.h:34
TGLayout.h
kLHintsLeft
@ kLHintsLeft
Definition:
TGLayout.h:31
TGLabel
Definition:
TGLabel.h:32
TGTextButton
Definition:
TGButton.h:142
TGHorizontalFrame
Definition:
TGFrame.h:422
gClient
#define gClient
Definition:
TGClient.h:166
kSunkenFrame
@ kSunkenFrame
Definition:
GuiTypes.h:383
kFixedHeight
@ kFixedHeight
Definition:
GuiTypes.h:389
kLHintsCenterY
@ kLHintsCenterY
Definition:
TGLayout.h:35
h
#define h(i)
Definition:
RSha256.hxx:106
TGVerticalFrame
Definition:
TGFrame.h:411
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:33
TGLayoutHints
Definition:
TGLayout.h:57
UInt_t
unsigned int UInt_t
Definition:
RtypesCore.h:46
kLHintsExpandY
@ kLHintsExpandY
Definition:
TGLayout.h:38
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:350
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:866
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:50
kLHintsExpandX
@ kLHintsExpandX
Definition:
TGLayout.h:37
TGCompositeFrame::GetDefaultWidth
virtual UInt_t GetDefaultWidth() const
Definition:
TGFrame.h:348
TGCompositeFrame
Definition:
TGFrame.h:323
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
tutorials
gui
splitterHorizontal.C
ROOT master - Reference Guide Generated on Thu Feb 25 2021 12:01:48 (GVA Time) using Doxygen 1.9.0