Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGPack.h
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TGPack
13#define ROOT_TGPack
14
15#include "TGFrame.h"
16#include "TGLayout.h"
17
18class TGSplitter;
19
20
22{
23private:
26
27public:
28 Float_t fWeight; ///< relative weight
29 TGFrameElementPack* fSplitFE; ///<! cached variable for optimisation
30
31 TGFrameElementPack(TGFrame *frame, TGLayoutHints* lh = nullptr, Float_t weight = 1):
32 TGFrameElement(frame, lh), fWeight(weight), fSplitFE(nullptr) { }
33
34 ClassDefOverride(TGFrameElementPack, 0); // Class used in TGPack.
35};
36
37//==============================================================================
38
40{
41private:
42 TGPack(const TGPack&) = delete;
43 TGPack& operator=(const TGPack&) = delete;
44
45protected:
49
51
52 Float_t fWeightSum; ///< total sum of sub frame weights
53 Int_t fNVisible; ///< number of visible frames
54
55 Int_t GetFrameLength(const TGFrame* f) const { return fVertical ? f->GetHeight() : f->GetWidth(); }
56 Int_t GetLength() const { return GetFrameLength(this); }
58
60 void SetFramePosition(TGFrame* f, Int_t pos);
61
62 void FindFrames(TGFrame* splitter, TGFrameElementPack*& f0, TGFrameElementPack*& f1) const;
63
66 void RefitFramesToPack();
67
68 void AddFrameInternal(TGFrame *f, TGLayoutHints* l = nullptr, Float_t weight = 1);
70
71public:
72 TGPack(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0,
74 TGPack(TGClient *c, Window_t id, const TGWindow *parent = nullptr);
75 ~TGPack() override;
76
78 void AddFrame(TGFrame *f, TGLayoutHints* l = nullptr) override;
79
80 virtual void DeleteFrame(TGFrame *f);
81 void RemoveFrame(TGFrame *f) override;
82 void ShowFrame(TGFrame *f) override;
83 void HideFrame(TGFrame *f) override;
84
86 void Resize(UInt_t w = 0, UInt_t h = 0) override;
87
89 void MapSubwindows() override;
90
91 void MoveResize(Int_t x, Int_t y, UInt_t w = 0, UInt_t h = 0) override;
92 void Layout() override;
93
94 void Dump() const override;
95
96 void EqualizeFrames();
98 void HandleSplitterResize(Int_t delta);
99
100 // ----------------------------------------------------------------
101
102 Bool_t GetVertical() const { return fVertical; }
103 void SetVertical(Bool_t x);
104
105 // For now assume this is always true. Length of splitter = 4 pixels.
108
109 ClassDefOverride(TGPack, 0); // Horizontal or vertical stack of frames.
110};
111
112#endif
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
float Float_t
Definition RtypesCore.h:57
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Window client.
Definition TGClient.h:37
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
Float_t fWeight
relative weight
Definition TGPack.h:28
TGFrameElementPack * fSplitFE
! cached variable for optimisation
Definition TGPack.h:29
TGFrameElementPack(TGFrame *frame, TGLayoutHints *lh=nullptr, Float_t weight=1)
Definition TGPack.h:31
TGFrameElementPack & operator=(const TGFrameElementPack &)=delete
TGFrameElementPack(const TGFrameElementPack &)=delete
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Stack of frames in horizontal (default) or vertical stack.
Definition TGPack.h:40
Bool_t fVertical
Definition TGPack.h:46
void MapSubwindows() override
Virtual method of TGcompositeFrame.
Definition TGPack.cxx:407
void SetUseSplitters(Bool_t x)
Definition TGPack.h:107
void RemoveFrameInternal(TGFrame *f)
Remove frame f.
Definition TGPack.cxx:284
void ResizeExistingFrames()
Resize (shrink or expand) existing frames by amount in total.
Definition TGPack.cxx:138
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and resize the pack.
Definition TGPack.cxx:448
Int_t GetAvailableLength() const
Return length of entire frame without splitters.
Definition TGPack.cxx:76
void Dump() const override
Print sub frame info.
Definition TGPack.cxx:333
Int_t fSplitterLen
Definition TGPack.h:48
virtual void DeleteFrame(TGFrame *f)
Remove frame f and refit existing frames to pack size.
Definition TGPack.cxx:313
Int_t GetFrameLength(const TGFrame *f) const
Definition TGPack.h:55
virtual void AddFrameWithWeight(TGFrame *f, TGLayoutHints *l, Float_t w)
Add frame f at the end with given weight.
Definition TGPack.cxx:265
void RefitFramesToPack()
Refit existing frames to pack size.
Definition TGPack.cxx:185
TGPack & operator=(const TGPack &)=delete
void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr) override
Add frame f at the end with default weight.
Definition TGPack.cxx:275
Bool_t GetUseSplitters() const
Definition TGPack.h:106
Int_t GetLength() const
Definition TGPack.h:56
~TGPack() override
Destructor.
Definition TGPack.cxx:67
void EqualizeFrames()
Refit existing frames so that their lengths are equal.
Definition TGPack.cxx:477
void HandleSplitterStart()
Called when splitter drag starts.
Definition TGPack.cxx:498
Float_t fWeightSum
total sum of sub frame weights
Definition TGPack.h:52
void RemoveFrame(TGFrame *f) override
Remove frame f and refit existing frames to pack size.
Definition TGPack.cxx:324
TGPack(const TGPack &)=delete
void AddFrameInternal(TGFrame *f, TGLayoutHints *l=nullptr, Float_t weight=1)
Add frame f at the end.
Definition TGPack.cxx:221
Bool_t fUseSplitters
Definition TGPack.h:47
void SetVertical(Bool_t x)
Sets the vertical flag and reformats the back to new stacking direction.
Definition TGPack.cxx:569
void HandleSplitterResize(Int_t delta)
Handle resize events from splitters.
Definition TGPack.cxx:506
void SetFrameLength(TGFrame *f, Int_t len)
Set pack-wise length of frame f.
Definition TGPack.cxx:87
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the pack.
Definition TGPack.cxx:432
void SetFramePosition(TGFrame *f, Int_t pos)
Set pack-wise position of frame f.
Definition TGPack.cxx:98
void CheckSplitterVisibility()
Check if splitter of first visible frame is hidden.
Definition TGPack.cxx:110
Int_t fNVisible
number of visible frames
Definition TGPack.h:53
void Layout() override
Reposition the frames so that they fit correctly.
Definition TGPack.cxx:458
Int_t fDragOverflow
!
Definition TGPack.h:50
void ShowFrame(TGFrame *f) override
Show sub frame.
Definition TGPack.cxx:350
void HideFrame(TGFrame *f) override
Hide sub frame.
Definition TGPack.cxx:378
void FindFrames(TGFrame *splitter, TGFrameElementPack *&f0, TGFrameElementPack *&f1) const
Find frames around splitter and return them f0 (previous) and f1 (next).
Definition TGPack.cxx:201
Bool_t GetVertical() const
Definition TGPack.h:102
A splitter allows the frames left and right or above and below of it to be resized.
Definition TGSplitter.h:19
ROOT GUI Window base class.
Definition TGWindow.h:23
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TF1 * f1
Definition legend1.C:11
TLine l
Definition textangle.C:4