Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGListView.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 17/01/98
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_TGListView
13#define ROOT_TGListView
14
15
16#include "TGCanvas.h"
17#include "TGWidget.h"
18#include "TGSplitter.h"
19
20
26};
27
28
30class TGTextButton;
31class TGListView;
32class TGLVContainer;
33class TGHeaderFrame;
34
35
36class TGLVEntry : public TGFrame {
37
38private:
39 TGLVEntry(const TGLVEntry&) = delete;
40 TGLVEntry& operator=(const TGLVEntry&) = delete;
41
42protected:
43 TGString *fItemName; ///< name of item
44 TGString **fSubnames; ///< sub names of item (details)
45 Int_t *fCpos; ///< position of sub names
46 Int_t *fJmode; ///< alignment for sub names
47 Int_t *fCtw; ///< width of sub names
48 UInt_t fTWidth; ///< width of name
49 UInt_t fTHeight; ///< height of name
50 Bool_t fActive; ///< true if item is active
51 Bool_t fChecked; ///< true if item is checked
52 EListViewMode fViewMode; ///< list view viewing mode
53 const TGPicture *fBigPic; ///< big icon
54 const TGPicture *fSmallPic; ///< small icon
55 const TGPicture *fCurrent; ///< current icon
56 const TGPicture *fCheckMark; ///< checkmark
57 TGSelectedPicture *fSelPic; ///< selected icon
58 GContext_t fNormGC; ///< drawing graphics context
59 FontStruct_t fFontStruct; ///< text font
60 void *fUserData; ///< pointer to user data structure
61
62 static const TGFont *fgDefaultFont;
64
65 void DoRedraw() override;
66
68 static const TGGC &GetDefaultGC();
69
70public:
71 TGLVEntry(const TGWindow *p = nullptr,
72 const TGPicture *bigpic = nullptr, const TGPicture *smallpic = nullptr,
73 TGString *name = nullptr, TGString **subnames = nullptr,
74 EListViewMode ViewMode = kLVDetails,
75 UInt_t options = kChildFrame,
76 Pixel_t back = GetWhitePixel());
77
79 const TString& name, const TString& cname, TGString **subnames = nullptr,
80 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
81
82 virtual ~TGLVEntry();
83
84 virtual void SetViewMode(EListViewMode viewMode);
85
86 void Activate(Bool_t a) override;
87 Bool_t IsActive() const override { return fActive; }
88 TGString *GetItemName() const { return fItemName; }
89 const char *GetTitle() const override { return fItemName->GetString(); }
90 virtual void SetTitle(const char *text) { *fItemName = text; }
91 void SetItemName(const char *name) { *fItemName = name; }
92 const TGPicture *GetPicture() const { return fCurrent; }
94 void SetUserData(void *userData) { fUserData = userData; }
95 void *GetUserData() const { return fUserData; }
96 virtual TGString **GetSubnames() const { return fSubnames; }
97 virtual TGString *GetSubname(Int_t idx) const { if (fSubnames) return fSubnames[idx]; else return nullptr; }
98 virtual void SetSubnames(const char* n1="",const char* n2="",const char* n3="",
99 const char* n4="",const char* n5="",const char* n6="",
100 const char* n7="",const char* n8="",const char* n9="",
101 const char* n10="",const char* n11="",const char* n12="");
102 virtual void SetPictures(const TGPicture *bigpic = nullptr, const TGPicture *smallpic = nullptr);
103 virtual void SetColumns(Int_t *cpos, Int_t *jmode) { fCpos = cpos; fJmode = jmode; }
104 virtual void SetCheckedEntry(Bool_t check = kTRUE) { fChecked = check; }
105
106 TGDimension GetDefaultSize() const override;
107 virtual Int_t GetSubnameWidth(Int_t idx) const { return fCtw[idx]; }
108
109 void DrawCopy(Handle_t id, Int_t x, Int_t y) override;
110
111 ClassDefOverride(TGLVEntry,0) // Item that goes into a TGListView container
112};
113
114
115class TGListView : public TGCanvas {
116
117private:
118 TGListView(const TGListView&) = delete;
119 TGListView& operator=(const TGListView&) = delete;
120
121protected:
122 Int_t fNColumns; ///< number of columns
123 Int_t *fColumns; ///< column width
124 Int_t *fJmode; ///< column text alignment
125 EListViewMode fViewMode; ///< view mode if list view widget
126 TGDimension fMaxSize; ///< maximum item size
127 TGTextButton **fColHeader; ///< column headers for in detailed mode
128 TString *fColNames; ///< column titles for in detailed mode
129 TGVFileSplitter **fSplitHeader; ///< column splitters
130 GContext_t fNormGC; ///< drawing graphics context
131 FontStruct_t fFontStruct; ///< text font
132 TGHeaderFrame *fHeader; ///< frame used as container for column headers
133 Bool_t fJustChanged; ///< Indicate whether the view mode was just changed to Detail
134 UInt_t fMinColumnSize; ///< Minimun column size
135
136 static const TGFont *fgDefaultFont;
138
140 static const TGGC &GetDefaultGC();
141
142public:
146 virtual ~TGListView();
147
148 virtual void ResizeColumns();
149 void Layout() override;
150 virtual void LayoutHeader(TGFrame *head);
151 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
152 virtual void ScrollHeader(Int_t pos);
153 void SetContainer(TGFrame *f) override;
154 virtual void AdjustHeaders() { fJustChanged = kTRUE; LayoutHeader(nullptr); }
155 virtual void SetHeaders(Int_t ncolumns);
156 virtual void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx);
157 virtual void SetDefaultHeaders();
158 virtual void SetViewMode(EListViewMode viewMode);
162 virtual const char *GetHeader(Int_t idx) const;
163 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
164 virtual void SetIncrements(Int_t hInc, Int_t vInc);
167
168 virtual void SelectionChanged() { Emit("SelectionChanged()"); } //*SIGNAL*
169 virtual void Clicked(TGLVEntry *entry, Int_t btn); //*SIGNAL*
170 virtual void Clicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
171 virtual void DoubleClicked(TGLVEntry *entry, Int_t btn); //*SIGNAL*
172 virtual void DoubleClicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
173
174 ClassDefOverride(TGListView,0) // List view widget (iconbox, small icons or tabular view)
175};
176
177
179
180private:
181 TGLVContainer(const TGLVContainer&) = delete;
183
184protected:
185 TGLayoutHints *fItemLayout; ///< item layout hints
186 EListViewMode fViewMode; ///< list view viewing mode
187 Int_t *fCpos; ///< position of sub names
188 Int_t *fJmode; ///< alignment of sub names
189 Bool_t fMultiSelect; ///< true = multiple file selection
190 TGListView *fListView; ///< listview which contains this container
191 TGLVEntry *fLastActive; ///< last active item
192
193 void ActivateItem(TGFrameElement* el) override;
194 void DeActivateItem(TGFrameElement* el) override;
195
196public:
198 UInt_t options = kSunkenFrame,
202
203 virtual ~TGLVContainer();
204
205 TGListView *GetListView() const { return fListView; }
206
207 virtual void AddItem(TGLVEntry *item)
208 { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); fTotal++; }
209 virtual void SelectEntry(TGLVEntry *item);
210
211 virtual void SetListView(TGListView *lv) { fListView = lv; }
212 virtual void RemoveItemWithData(void *userData);
213 virtual void SetViewMode(EListViewMode viewMode);
215 virtual void SetColumns(Int_t *cpos, Int_t *jmode);
216
217 TGDimension GetPageDimension() const override;
218 virtual TGDimension GetMaxItemSize() const;
219 virtual Int_t GetMaxSubnameWidth(Int_t idx) const;
220 virtual void SetColHeaders(const char* n1="",const char* n2="",const char* n3="",
221 const char* n4="",const char* n5="",const char* n6="",
222 const char* n7="",const char* n8="",const char* n9="",
223 const char* n10="",const char* n11="",const char* n12="");
224 void LineUp(Bool_t select = kFALSE) override;
225 void LineDown(Bool_t select = kFALSE) override;
226 void LineLeft(Bool_t select = kFALSE) override;
227 void LineRight(Bool_t select = kFALSE) override;
228
229 Bool_t HandleButton(Event_t* event) override;
233 void SetMultipleSelection(Bool_t multi = kTRUE) { fMultiSelect = multi; };
234 void SetHeaders(Int_t ncolumns) { fListView->SetHeaders(ncolumns); }
235 void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
236 { fListView->SetHeader(s,hmode,cmode,idx); }
238 const char *GetHeader(Int_t idx) const { return fListView->GetHeader(idx); }
239 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
240
241 ClassDefOverride(TGLVContainer,0) // Listview container
242};
243
244#endif
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
@ kChildFrame
Definition GuiTypes.h:379
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
EListViewMode
Definition TGListView.h:21
@ kLVDetails
Definition TGListView.h:25
@ kLVSmallIcons
Definition TGListView.h:23
@ kLVList
Definition TGListView.h:24
@ kLVLargeIcons
Definition TGListView.h:22
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
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 cname
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
Manages a content area.
Definition TGCanvas.h:31
Int_t fTotal
total items
Definition TGCanvas.h:48
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:709
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
Horizontal Frame used to contain header buttons and splitters in a list view.
Definition TGFrame.h:580
const char * GetHeader(Int_t idx) const
Definition TGListView.h:238
void LineRight(Bool_t select=kFALSE) override
Move current position one column right.
void SetDefaultHeaders()
Definition TGListView.h:237
TGListView * fListView
listview which contains this container
Definition TGListView.h:190
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in container.
void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Definition TGListView.h:235
void LineDown(Bool_t select=kFALSE) override
Move one line down.
TList * GetSelectedItems()
Get list of selected items in container.
void SetMultipleSelection(Bool_t multi=kTRUE)
Definition TGListView.h:233
virtual void SetColumns(Int_t *cpos, Int_t *jmode)
Set column information for list items.
void LineLeft(Bool_t select=kFALSE) override
Move current position one column left.
virtual void SetColHeaders(const char *n1="", const char *n2="", const char *n3="", const char *n4="", const char *n5="", const char *n6="", const char *n7="", const char *n8="", const char *n9="", const char *n10="", const char *n11="", const char *n12="")
set columns headers
virtual void SelectEntry(TGLVEntry *item)
Select the TGLVEntry given as argument and de-select the previous one if the container is not in mult...
void SetHeaders(Int_t ncolumns)
Definition TGListView.h:234
Bool_t fMultiSelect
true = multiple file selection
Definition TGListView.h:189
virtual void AddItem(TGLVEntry *item)
Definition TGListView.h:207
void DeActivateItem(TGFrameElement *el) override
Unselect/deactivate item.
TGLayoutHints * fItemLayout
item layout hints
Definition TGListView.h:185
virtual Int_t GetMaxSubnameWidth(Int_t idx) const
Get width of largest subname in container.
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode for container.
TGLVEntry * fLastActive
last active item
Definition TGListView.h:191
virtual void RemoveItemWithData(void *userData)
Remove item with fUserData == userData from container.
void ActivateItem(TGFrameElement *el) override
Select/activate item.
TGListView * GetListView() const
Definition TGListView.h:205
Int_t * fCpos
position of sub names
Definition TGListView.h:187
virtual ~TGLVContainer()
Delete list view container.
virtual void SetListView(TGListView *lv)
Definition TGListView.h:211
TGLVContainer(const TGLVContainer &)=delete
TList * GetSelectedEntries()
Get list of selected items in container.
Int_t * fJmode
alignment of sub names
Definition TGListView.h:188
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a list view container as a C++ statement(s) on output stream out.
TGDimension GetPageDimension() const override
Returns page dimension.
EListViewMode GetViewMode() const
Definition TGListView.h:214
Bool_t GetMultipleSelection() const
Definition TGListView.h:232
void LineUp(Bool_t select=kFALSE) override
Make current position first line in window by scrolling up.
TGLVContainer & operator=(const TGLVContainer &)=delete
EListViewMode fViewMode
list view viewing mode
Definition TGListView.h:186
virtual TGDimension GetMaxItemSize() const
Get size of largest item in container.
TGLVEntry & operator=(const TGLVEntry &)=delete
const TGPicture * fCurrent
current icon
Definition TGListView.h:55
void * fUserData
pointer to user data structure
Definition TGListView.h:60
UInt_t fTHeight
height of name
Definition TGListView.h:49
void SetItemName(const char *name)
Definition TGListView.h:91
virtual void SetTitle(const char *text)
Definition TGListView.h:90
virtual void SetPictures(const TGPicture *bigpic=nullptr, const TGPicture *smallpic=nullptr)
change pictures
TGString ** fSubnames
sub names of item (details)
Definition TGListView.h:44
void DoRedraw() override
Redraw list view item.
Int_t * fCpos
position of sub names
Definition TGListView.h:45
UInt_t fTWidth
width of name
Definition TGListView.h:48
TGDimension GetDefaultSize() const override
Get default size of list item.
const char * GetTitle() const override
Returns title of object.
Definition TGListView.h:89
void Activate(Bool_t a) override
Make list view item active.
virtual void SetColumns(Int_t *cpos, Int_t *jmode)
Definition TGListView.h:103
Bool_t fActive
true if item is active
Definition TGListView.h:50
void DrawCopy(Handle_t id, Int_t x, Int_t y) override
Draw list view item in other window.
FontStruct_t fFontStruct
text font
Definition TGListView.h:59
EListViewMode fViewMode
list view viewing mode
Definition TGListView.h:52
GContext_t fNormGC
drawing graphics context
Definition TGListView.h:58
TGString * fItemName
name of item
Definition TGListView.h:43
EListViewMode GetViewMode() const
Definition TGListView.h:93
virtual TGString ** GetSubnames() const
Definition TGListView.h:96
void * GetUserData() const
Definition TGListView.h:95
const TGPicture * fBigPic
big icon
Definition TGListView.h:53
const TGPicture * GetPicture() const
Definition TGListView.h:92
virtual void SetViewMode(EListViewMode viewMode)
Set the view mode for this list item.
virtual TGString * GetSubname(Int_t idx) const
Definition TGListView.h:97
TGString * GetItemName() const
Definition TGListView.h:88
virtual ~TGLVEntry()
Delete a list view item.
Bool_t fChecked
true if item is checked
Definition TGListView.h:51
TGLVEntry(const TGLVEntry &)=delete
virtual void SetCheckedEntry(Bool_t check=kTRUE)
Definition TGListView.h:104
Int_t * fCtw
width of sub names
Definition TGListView.h:47
TGSelectedPicture * fSelPic
selected icon
Definition TGListView.h:57
Bool_t IsActive() const override
Definition TGListView.h:87
const TGPicture * fSmallPic
small icon
Definition TGListView.h:54
virtual Int_t GetSubnameWidth(Int_t idx) const
Definition TGListView.h:107
Int_t * fJmode
alignment for sub names
Definition TGListView.h:46
virtual void SetSubnames(const char *n1="", const char *n2="", const char *n3="", const char *n4="", const char *n5="", const char *n6="", const char *n7="", const char *n8="", const char *n9="", const char *n10="", const char *n11="", const char *n12="")
Sets new subnames.
static const TGGC & GetDefaultGC()
Return the default graphics context in use.
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
const TGPicture * fCheckMark
checkmark
Definition TGListView.h:56
static TGGC * fgDefaultGC
Definition TGListView.h:63
void SetUserData(void *userData)
Definition TGListView.h:94
static const TGFont * fgDefaultFont
Definition TGListView.h:62
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A list view is a widget that can contain a number of items arranged in a grid or list.
Definition TGListView.h:115
Int_t * fJmode
column text alignment
Definition TGListView.h:124
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
virtual void DoubleClicked(TGLVEntry *entry, Int_t btn)
Emit DoubleClicked() signal.
virtual void AdjustHeaders()
Definition TGListView.h:154
virtual void ResizeColumns()
Resize column headers to show whole item names.
EListViewMode fViewMode
view mode if list view widget
Definition TGListView.h:125
virtual void ScrollHeader(Int_t pos)
Scroll header buttons with horizontal scrollbar.
TGListView(const TGListView &)=delete
Int_t * fColumns
column width
Definition TGListView.h:123
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a list view widget as a C++ statement(s) on output stream out.
virtual void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Set header button idx [0-fNColumns>, hmode is the x text alignmode (ETextJustification) for the heade...
void Layout() override
Layout list view components (container and contents of container).
FontStruct_t fFontStruct
text font
Definition TGListView.h:131
virtual void SetIncrements(Int_t hInc, Int_t vInc)
Set horizontal and vertical scrollbar increments.
EListViewMode GetViewMode() const
Definition TGListView.h:161
TGTextButton ** GetHeaderButtons()
Definition TGListView.h:159
void SetContainer(TGFrame *f) override
Set list view container.
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
GContext_t fNormGC
drawing graphics context
Definition TGListView.h:130
static const TGGC & GetDefaultGC()
Return the default graphics context in use.
Int_t fNColumns
number of columns
Definition TGListView.h:122
TGDimension fMaxSize
maximum item size
Definition TGListView.h:126
TGHeaderFrame * fHeader
frame used as container for column headers
Definition TGListView.h:132
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
UInt_t GetNumColumns()
Definition TGListView.h:160
TString * fColNames
column titles for in detailed mode
Definition TGListView.h:128
virtual void SelectionChanged()
Definition TGListView.h:168
UInt_t fMinColumnSize
Minimun column size.
Definition TGListView.h:134
TGTextButton ** fColHeader
column headers for in detailed mode
Definition TGListView.h:127
virtual void SetDefaultHeaders()
Default headers are: Name, Attributes, Size, Owner, Group, Modified.
virtual void Clicked(TGLVEntry *entry, Int_t btn)
Emit Clicked() signal.
virtual void LayoutHeader(TGFrame *head)
Layout list view components (container and contents of container).
Bool_t fJustChanged
Indicate whether the view mode was just changed to Detail.
Definition TGListView.h:133
virtual ~TGListView()
Delete a list view widget.
TGListView & operator=(const TGListView &)=delete
virtual void SetDefaultColumnWidth(TGVFileSplitter *splitter)
Set default column width of the columns headers.
static const TGFont * fgDefaultFont
Definition TGListView.h:136
TGVFileSplitter ** fSplitHeader
column splitters
Definition TGListView.h:129
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
TGDimension GetMaxItemSize() const
Definition TGListView.h:166
static TGGC * fgDefaultGC
Definition TGListView.h:137
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Handle messages generated by the list view components.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
const char * GetString() const
Definition TGString.h:30
Yield an action as soon as it is clicked.
Definition TGButton.h:142
ROOT GUI Window base class.
Definition TGWindow.h:23
A doubly linked list.
Definition TList.h:38
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:139
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
TLine lv
Definition textalign.C:5
double splitter
Definition triangle.c:617