Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
splitterVertical.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 vertical splitter.
4/// To run it do either:
5/// ~~~
6/// .x splitterVertical.C
7/// .x splitterVertical.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
21class MyMainFrame : public TGMainFrame {
22
23public:
24 MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
25 ~MyMainFrame() override;
26 void DoSave();
27 void CloseWindow() override;
28
29 ClassDefOverride(MyMainFrame, 0)
30};
31
32//______________________________________________________________________________
33void MyMainFrame::DoSave()
34{
35 Printf("Save in progress...");
36 SaveSource("", "");
37}
38
39//______________________________________________________________________________
40MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
41{
42 // Create vertical splitter
43
44 TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 50, 50);
45
46 TGVerticalFrame *fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
47 TGVerticalFrame *fV2 = new TGVerticalFrame(fHf, 10, 10);
48 TGCompositeFrame *fFleft = new TGCompositeFrame(fV1, 10, 10, kSunkenFrame);
49 TGCompositeFrame *fFright = new TGCompositeFrame(fV2, 10, 10, kSunkenFrame);
50
51 TGLabel *fLleft = new TGLabel(fFleft, "Left Frame");
52 TGLabel *fLright = new TGLabel(fFright, "Right Frame");
53
54 fFleft->AddFrame(fLleft, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 0, 0));
55 fFright->AddFrame(fLright, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 0, 0));
56
57 fV1->AddFrame(fFleft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 5, 10));
58 fV2->AddFrame(fFright, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 5, 10));
59
60 fV1->Resize(fFleft->GetDefaultWidth() + 20, fV1->GetDefaultHeight());
61 fV2->Resize(fFright->GetDefaultWidth(), fV1->GetDefaultHeight());
63
64 TGVSplitter *splitter = new TGVSplitter(fHf, 2, 2);
65 splitter->SetFrame(fV1, kTRUE);
66 fHf->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
67
70
71 // button frame
72 TGVerticalFrame *vframe = new TGVerticalFrame(this, 10, 10);
73 TGCompositeFrame *cframe2 = new TGCompositeFrame(vframe, 170, 20, kHorizontalFrame | kFixedWidth);
74 TGTextButton *save = new TGTextButton(cframe2, "&Save");
75 cframe2->AddFrame(save, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 3, 2, 2, 2));
76 save->Connect("Clicked()", "MyMainFrame", this, "DoSave()");
77 save->SetToolTipText("Click on the button to save the application as C++ macro");
78
79 TGTextButton *exit = new TGTextButton(cframe2, "&Exit ", "gApplication->Terminate(0)");
80 cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 2, 0, 2, 2));
81 vframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
82 AddFrame(vframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
83
84 // What to clean up in destructor
85 SetCleanup(kDeepCleanup);
86
87 // Set a name to the main frame
88 SetWindowName("Vertical Splitter");
89 SetWMSizeHints(350, 200, 600, 400, 0, 0);
91 Resize(GetDefaultSize());
92 MapWindow();
93}
94
95//______________________________________________________________________________
96MyMainFrame::~MyMainFrame()
97{
98 // Clean up all widgets, frames and layouthints that were used
99 Cleanup();
100}
101
102//______________________________________________________________________________
103void MyMainFrame::CloseWindow()
104{
105 // Called when window is closed via the window manager.
106
107 delete this;
108}
109
110void splitterVertical()
111{
112 // Popup the GUI...
113 new MyMainFrame(gClient->GetRoot(), 350, 200);
114}
@ 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
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
#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
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2503
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=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
UInt_t GetDefaultWidth() const override
Definition TGFrame.h:312
UInt_t GetDefaultHeight() const override
Definition TGFrame.h:314
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:385
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:397
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
void SetFrame(TGFrame *frame, Bool_t left) override
Set frame to be resized.
A composite frame that layout their children in vertical way.
Definition TGFrame.h:374
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