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 virtual void DoRedraw();
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
78 TGLVEntry(const TGLVContainer *p,
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 virtual void Activate(Bool_t a);
87 Bool_t IsActive() const { return fActive; }
88 TGString *GetItemName() const { return fItemName; }
89 virtual const char *GetTitle() const { 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 0; }
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 = 0, const TGPicture *smallpic = 0);
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 virtual TGDimension GetDefaultSize() const;
107 virtual Int_t GetSubnameWidth(Int_t idx) const { return fCtw[idx]; }
108
109 virtual void DrawCopy(Handle_t id, Int_t x, Int_t y);
110
111 ClassDef(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:
143 TGListView(const TGWindow *p, UInt_t w, UInt_t h,
146 virtual ~TGListView();
147
148 virtual void ResizeColumns();
149 virtual void Layout();
150 virtual void LayoutHeader(TGFrame *head);
151 virtual Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2);
152 virtual void ScrollHeader(Int_t pos);
153 virtual void SetContainer(TGFrame *f);
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 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
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 ClassDef(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 virtual void ActivateItem(TGFrameElement* el);
194 virtual void DeActivateItem(TGFrameElement* el);
195
196public:
197 TGLVContainer(const TGWindow *p, UInt_t w, UInt_t h,
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 virtual TGDimension GetPageDimension() const;
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 virtual void LineUp(Bool_t select = kFALSE);
225 virtual void LineDown(Bool_t select = kFALSE);
226 virtual void LineLeft(Bool_t select = kFALSE);
227 virtual void LineRight(Bool_t select = kFALSE);
228
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 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
240
241 ClassDef(TGLVContainer,0) // Listview container
242};
243
244#endif
@ kChildFrame
Definition GuiTypes.h:379
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
ULongptr_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
const Bool_t kFALSE
Definition RtypesCore.h:101
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
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
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=0)
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:581
const char * GetHeader(Int_t idx) const
Definition TGListView.h:238
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in container.
void SetDefaultHeaders()
Definition TGListView.h:237
TGListView * fListView
listview which contains this container
Definition TGListView.h:190
void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Definition TGListView.h:235
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.
virtual void LineRight(Bool_t select=kFALSE)
Move current position one column right.
virtual void ActivateItem(TGFrameElement *el)
Select/activate item.
virtual void LineUp(Bool_t select=kFALSE)
Make current position first line in window by scrolling up.
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
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.
virtual void LineDown(Bool_t select=kFALSE)
Move one line down.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list view container as a C++ statement(s) on output stream out.
TGLVEntry * fLastActive
last active item
Definition TGListView.h:191
virtual void RemoveItemWithData(void *userData)
Remove item with fUserData == userData from container.
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
virtual void DeActivateItem(TGFrameElement *el)
Unselect/deactivate item.
EListViewMode GetViewMode() const
Definition TGListView.h:214
virtual void LineLeft(Bool_t select=kFALSE)
Move current position one column left.
Bool_t GetMultipleSelection() const
Definition TGListView.h:232
TGLVContainer & operator=(const TGLVContainer &)=delete
EListViewMode fViewMode
list view viewing mode
Definition TGListView.h:186
virtual TGDimension GetPageDimension() const
Returns page dimension.
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
TGString ** fSubnames
sub names of item (details)
Definition TGListView.h:44
Int_t * fCpos
position of sub names
Definition TGListView.h:45
UInt_t fTWidth
width of name
Definition TGListView.h:48
virtual void DoRedraw()
Redraw list view item.
virtual void SetPictures(const TGPicture *bigpic=0, const TGPicture *smallpic=0)
change pictures
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
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 TGDimension GetDefaultSize() const
Get default size of list item.
virtual void SetViewMode(EListViewMode viewMode)
Set the view mode for this list item.
virtual TGString * GetSubname(Int_t idx) const
Definition TGListView.h:97
virtual void Activate(Bool_t a)
Make list view item active.
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
virtual const char * GetTitle() const
Returns title of object.
Definition TGListView.h:89
TGSelectedPicture * fSelPic
selected icon
Definition TGListView.h:57
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw list view item in other window.
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
Bool_t IsActive() const
Definition TGListView.h:87
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 Layout()
Layout list view components (container and contents of container).
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
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...
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
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.
virtual Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Handle messages generated by the list view components.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list view widget as a C++ statement(s) on output stream out.
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
virtual void SetContainer(TGFrame *f)
Set list view container.
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
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:136
TText * text
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
auto * lv
Definition textalign.C:5
REAL splitter
Definition triangle.c:617