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//////////////////////////////////////////////////////////////////////////
17// //
18// TGListView, TGLVContainer and TGLVEntry //
19// //
20// A list view is a widget that can contain a number of items //
21// arranged in a grid or list. The items can be represented either //
22// by a string or by an icon. //
23// //
24// The TGListView is user callable. The other classes are service //
25// classes of the list view. //
26// //
27// A list view can generate the following events: //
28// kC_CONTAINER, kCT_SELCHANGED, total items, selected items. //
29// kC_CONTAINER, kCT_ITEMCLICK, which button, location (y<<16|x). //
30// kC_CONTAINER, kCT_ITEMDBLCLICK, which button, location (y<<16|x). //
31// //
32//////////////////////////////////////////////////////////////////////////
33
34#include "TGCanvas.h"
35#include "TGWidget.h"
36#include "TGSplitter.h"
37
38
44};
45
46
48class TGTextButton;
49class TGListView;
50class TGLVContainer;
51class TGHeaderFrame;
52
53
54class TGLVEntry : public TGFrame {
55
56private:
57 TGLVEntry(const TGLVEntry&) = delete;
58 TGLVEntry& operator=(const TGLVEntry&) = delete;
59
60protected:
61 TGString *fItemName; // name of item
62 TGString **fSubnames; // sub names of item (details)
63 Int_t *fCpos; // position of sub names
64 Int_t *fJmode; // alignment for sub names
65 Int_t *fCtw; // width of sub names
66 UInt_t fTWidth; // width of name
67 UInt_t fTHeight; // height of name
68 Bool_t fActive; // true if item is active
69 Bool_t fChecked; // true if item is checked
70 EListViewMode fViewMode; // list view viewing mode
71 const TGPicture *fBigPic; // big icon
72 const TGPicture *fSmallPic; // small icon
73 const TGPicture *fCurrent; // current icon
74 const TGPicture *fCheckMark; // checkmark
75 TGSelectedPicture *fSelPic; // selected icon
76 GContext_t fNormGC; // drawing graphics context
78 void *fUserData; // pointer to user data structure
79
80 static const TGFont *fgDefaultFont;
82
83 virtual void DoRedraw();
84
86 static const TGGC &GetDefaultGC();
87
88public:
89 TGLVEntry(const TGWindow *p = nullptr,
90 const TGPicture *bigpic = nullptr, const TGPicture *smallpic = nullptr,
91 TGString *name = nullptr, TGString **subnames = nullptr,
92 EListViewMode ViewMode = kLVDetails,
93 UInt_t options = kChildFrame,
94 Pixel_t back = GetWhitePixel());
95
96 TGLVEntry(const TGLVContainer *p,
97 const TString& name, const TString& cname, TGString **subnames = nullptr,
98 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
99
100 virtual ~TGLVEntry();
101
102 virtual void SetViewMode(EListViewMode viewMode);
103
104 virtual void Activate(Bool_t a);
105 Bool_t IsActive() const { return fActive; }
106 TGString *GetItemName() const { return fItemName; }
107 virtual const char *GetTitle() const { return fItemName->GetString(); }
108 virtual void SetTitle(const char *text) { *fItemName = text; }
109 void SetItemName(const char *name) { *fItemName = name; }
110 const TGPicture *GetPicture() const { return fCurrent; }
112 void SetUserData(void *userData) { fUserData = userData; }
113 void *GetUserData() const { return fUserData; }
114 virtual TGString **GetSubnames() const { return fSubnames; }
115 virtual TGString *GetSubname(Int_t idx) const { if (fSubnames) return fSubnames[idx]; else return 0; }
116 virtual void SetSubnames(const char* n1="",const char* n2="",const char* n3="",
117 const char* n4="",const char* n5="",const char* n6="",
118 const char* n7="",const char* n8="",const char* n9="",
119 const char* n10="",const char* n11="",const char* n12="");
120 virtual void SetPictures(const TGPicture *bigpic = 0, const TGPicture *smallpic = 0);
121 virtual void SetColumns(Int_t *cpos, Int_t *jmode) { fCpos = cpos; fJmode = jmode; }
122 virtual void SetCheckedEntry(Bool_t check = kTRUE) { fChecked = check; }
123
124 virtual TGDimension GetDefaultSize() const;
125 virtual Int_t GetSubnameWidth(Int_t idx) const { return fCtw[idx]; }
126
127 virtual void DrawCopy(Handle_t id, Int_t x, Int_t y);
128
129 ClassDef(TGLVEntry,0) // Item that goes into a TGListView container
130};
131
132
133class TGListView : public TGCanvas {
134
135private:
136 TGListView(const TGListView&) = delete;
137 TGListView& operator=(const TGListView&) = delete;
138
139protected:
140 Int_t fNColumns; // number of columns
141 Int_t *fColumns; // column width
142 Int_t *fJmode; // column text alignment
143 EListViewMode fViewMode; // view mode if list view widget
144 TGDimension fMaxSize; // maximum item size
145 TGTextButton **fColHeader; // column headers for in detailed mode
146 TString *fColNames; // column titles for in detailed mode
147 TGVFileSplitter **fSplitHeader; // column splitters
148 GContext_t fNormGC; // drawing graphics context
150 TGHeaderFrame *fHeader; // frame used as container for column headers
151 Bool_t fJustChanged; // Indicate whether the view mode was just changed to Detail
152 UInt_t fMinColumnSize; // Minimun column size
153
154 static const TGFont *fgDefaultFont;
156
158 static const TGGC &GetDefaultGC();
159
160public:
161 TGListView(const TGWindow *p, UInt_t w, UInt_t h,
164 virtual ~TGListView();
165
166 virtual void ResizeColumns();
167 virtual void Layout();
168 virtual void LayoutHeader(TGFrame *head);
169 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
170 virtual void ScrollHeader(Int_t pos);
171 virtual void SetContainer(TGFrame *f);
173 virtual void SetHeaders(Int_t ncolumns);
174 virtual void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx);
175 virtual void SetDefaultHeaders();
176 virtual void SetViewMode(EListViewMode viewMode);
180 virtual const char *GetHeader(Int_t idx) const;
181 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
182 virtual void SetIncrements(Int_t hInc, Int_t vInc);
185
186 virtual void SelectionChanged() { Emit("SelectionChanged()"); } //*SIGNAL*
187 virtual void Clicked(TGLVEntry *entry, Int_t btn); //*SIGNAL*
188 virtual void Clicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
189 virtual void DoubleClicked(TGLVEntry *entry, Int_t btn); //*SIGNAL*
190 virtual void DoubleClicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
191
192 ClassDef(TGListView,0) // List view widget (iconbox, small icons or tabular view)
193};
194
195
197
198private:
199 TGLVContainer(const TGLVContainer&) = delete;
201
202protected:
203 TGLayoutHints *fItemLayout; // item layout hints
204 EListViewMode fViewMode; // list view viewing mode
205 Int_t *fCpos; // position of sub names
206 Int_t *fJmode; // alignment of sub names
207 Bool_t fMultiSelect; // true = multiple file selection
208 TGListView *fListView; // listview which contains this container
209 TGLVEntry *fLastActive; // last active item
210
211 virtual void ActivateItem(TGFrameElement* el);
212 virtual void DeActivateItem(TGFrameElement* el);
213
214public:
215 TGLVContainer(const TGWindow *p, UInt_t w, UInt_t h,
216 UInt_t options = kSunkenFrame,
220
221 virtual ~TGLVContainer();
222
223 TGListView *GetListView() const { return fListView; }
224
225 virtual void AddItem(TGLVEntry *item)
226 { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); fTotal++; }
227 virtual void SelectEntry(TGLVEntry *item);
228
229 virtual void SetListView(TGListView *lv) { fListView = lv; }
230 virtual void RemoveItemWithData(void *userData);
231 virtual void SetViewMode(EListViewMode viewMode);
233 virtual void SetColumns(Int_t *cpos, Int_t *jmode);
234
235 virtual TGDimension GetPageDimension() const;
236 virtual TGDimension GetMaxItemSize() const;
237 virtual Int_t GetMaxSubnameWidth(Int_t idx) const;
238 virtual void SetColHeaders(const char* n1="",const char* n2="",const char* n3="",
239 const char* n4="",const char* n5="",const char* n6="",
240 const char* n7="",const char* n8="",const char* n9="",
241 const char* n10="",const char* n11="",const char* n12="");
242 virtual void LineUp(Bool_t select = kFALSE);
243 virtual void LineDown(Bool_t select = kFALSE);
244 virtual void LineLeft(Bool_t select = kFALSE);
245 virtual void LineRight(Bool_t select = kFALSE);
246
247 virtual Bool_t HandleButton(Event_t* event);
251 void SetMultipleSelection(Bool_t multi = kTRUE) { fMultiSelect = multi; };
252 void SetHeaders(Int_t ncolumns) { fListView->SetHeaders(ncolumns); }
253 void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
254 { fListView->SetHeader(s,hmode,cmode,idx); }
256 const char *GetHeader(Int_t idx) const { return fListView->GetHeader(idx); }
257 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
258
259 ClassDef(TGLVContainer,0) // Listview container
260};
261
262#endif
ULong_t Handle_t
Generic resource handle.
Definition GuiTypes.h:26
@ 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
#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
const Bool_t kFALSE
Definition RtypesCore.h:92
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
const Bool_t kTRUE
Definition RtypesCore.h:91
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
EListViewMode
Definition TGListView.h:39
@ kLVDetails
Definition TGListView.h:43
@ kLVSmallIcons
Definition TGListView.h:41
@ kLVList
Definition TGListView.h:42
@ kLVLargeIcons
Definition TGListView.h:40
char name[80]
Definition TGX11.cxx:110
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
Int_t fTotal
Definition TGCanvas.h:58
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
Definition TGGC.h:31
const char * GetHeader(Int_t idx) const
Definition TGListView.h:256
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in container.
void SetDefaultHeaders()
Definition TGListView.h:255
TGListView * fListView
Definition TGListView.h:208
void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Definition TGListView.h:253
TList * GetSelectedItems()
Get list of selected items in container.
void SetMultipleSelection(Bool_t multi=kTRUE)
Definition TGListView.h:251
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:252
Bool_t fMultiSelect
Definition TGListView.h:207
virtual void AddItem(TGLVEntry *item)
Definition TGListView.h:225
TGLayoutHints * fItemLayout
Definition TGListView.h:203
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
Definition TGListView.h:209
virtual void RemoveItemWithData(void *userData)
Remove item with fUserData == userData from container.
TGListView * GetListView() const
Definition TGListView.h:223
Int_t * fCpos
Definition TGListView.h:205
virtual ~TGLVContainer()
Delete list view container.
virtual void SetListView(TGListView *lv)
Definition TGListView.h:229
TGLVContainer(const TGLVContainer &)=delete
TList * GetSelectedEntries()
Get list of selected items in container.
Int_t * fJmode
Definition TGListView.h:206
virtual void DeActivateItem(TGFrameElement *el)
Unselect/deactivate item.
EListViewMode GetViewMode() const
Definition TGListView.h:232
virtual void LineLeft(Bool_t select=kFALSE)
Move current position one column left.
Bool_t GetMultipleSelection() const
Definition TGListView.h:250
TGLVContainer & operator=(const TGLVContainer &)=delete
EListViewMode fViewMode
Definition TGListView.h:204
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
Definition TGListView.h:73
void * fUserData
Definition TGListView.h:78
UInt_t fTHeight
Definition TGListView.h:67
void SetItemName(const char *name)
Definition TGListView.h:109
virtual void SetTitle(const char *text)
Definition TGListView.h:108
TGString ** fSubnames
Definition TGListView.h:62
Int_t * fCpos
Definition TGListView.h:63
UInt_t fTWidth
Definition TGListView.h:66
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:121
Bool_t fActive
Definition TGListView.h:68
FontStruct_t fFontStruct
Definition TGListView.h:77
EListViewMode fViewMode
Definition TGListView.h:70
GContext_t fNormGC
Definition TGListView.h:76
TGString * fItemName
Definition TGListView.h:61
EListViewMode GetViewMode() const
Definition TGListView.h:111
virtual TGString ** GetSubnames() const
Definition TGListView.h:114
void * GetUserData() const
Definition TGListView.h:113
const TGPicture * fBigPic
Definition TGListView.h:71
const TGPicture * GetPicture() const
Definition TGListView.h:110
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:115
virtual void Activate(Bool_t a)
Make list view item active.
TGString * GetItemName() const
Definition TGListView.h:106
virtual ~TGLVEntry()
Delete a list view item.
Bool_t fChecked
Definition TGListView.h:69
TGLVEntry(const TGLVEntry &)=delete
virtual void SetCheckedEntry(Bool_t check=kTRUE)
Definition TGListView.h:122
Int_t * fCtw
Definition TGListView.h:65
virtual const char * GetTitle() const
Returns title of object.
Definition TGListView.h:107
TGSelectedPicture * fSelPic
Definition TGListView.h:75
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw list view item in other window.
const TGPicture * fSmallPic
Definition TGListView.h:72
virtual Int_t GetSubnameWidth(Int_t idx) const
Definition TGListView.h:125
Int_t * fJmode
Definition TGListView.h:64
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
Definition TGListView.h:74
static TGGC * fgDefaultGC
Definition TGListView.h:81
void SetUserData(void *userData)
Definition TGListView.h:112
static const TGFont * fgDefaultFont
Definition TGListView.h:80
Bool_t IsActive() const
Definition TGListView.h:105
Int_t * fJmode
Definition TGListView.h:142
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:172
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle messages generated by the list view components.
virtual void ResizeColumns()
Resize column headers to show whole item names.
EListViewMode fViewMode
Definition TGListView.h:143
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
Definition TGListView.h:141
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
Definition TGListView.h:149
virtual void SetIncrements(Int_t hInc, Int_t vInc)
Set horizontal and vertical scrollbar increments.
EListViewMode GetViewMode() const
Definition TGListView.h:179
TGTextButton ** GetHeaderButtons()
Definition TGListView.h:177
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
GContext_t fNormGC
Definition TGListView.h:148
static const TGGC & GetDefaultGC()
Return the default graphics context in use.
Int_t fNColumns
Definition TGListView.h:140
TGDimension fMaxSize
Definition TGListView.h:144
TGHeaderFrame * fHeader
Definition TGListView.h:150
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
UInt_t GetNumColumns()
Definition TGListView.h:178
TString * fColNames
Definition TGListView.h:146
virtual void SelectionChanged()
Definition TGListView.h:186
UInt_t fMinColumnSize
Definition TGListView.h:152
TGTextButton ** fColHeader
Definition TGListView.h:145
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
Definition TGListView.h:151
virtual ~TGListView()
Delete a list view widget.
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:154
virtual void SetContainer(TGFrame *f)
Set list view container.
TGVFileSplitter ** fSplitHeader
Definition TGListView.h:147
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
TGDimension GetMaxItemSize() const
Definition TGListView.h:184
static TGGC * fgDefaultGC
Definition TGListView.h:155
const char * GetString() const
Definition TGString.h:40
A doubly linked list.
Definition TList.h:44
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:616