Logo ROOT   6.12/07
Reference Guide
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-2000, 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 
47 class TGSelectedPicture;
48 class TGTextButton;
49 class TGListView;
50 class TGLVContainer;
51 class TGHeaderFrame;
52 
53 
54 class TGLVEntry : public TGFrame {
55 
56 private:
57  TGLVEntry(const TGLVEntry&); // Not implemented
58  TGLVEntry& operator=(const TGLVEntry&); // Not implemented
59 
60 protected:
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
77  FontStruct_t fFontStruct; // text font
78  void *fUserData; // pointer to user data structure
79 
80  static const TGFont *fgDefaultFont;
81  static TGGC *fgDefaultGC;
82 
83  virtual void DoRedraw();
84 
86  static const TGGC &GetDefaultGC();
87 
88 public:
89  TGLVEntry(const TGWindow *p = 0,
90  const TGPicture *bigpic = 0, const TGPicture *smallpic = 0,
91  TGString *name = 0, TGString **subnames = 0,
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 = 0,
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; }
111  EListViewMode GetViewMode() const { return fViewMode; }
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 
133 class TGListView : public TGCanvas {
134 
135 private:
136  TGListView(const TGListView&); // Not implemented
137  TGListView& operator=(const TGListView&); // Not implemented
138 
139 protected:
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
149  FontStruct_t fFontStruct; // text font
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;
155  static TGGC *fgDefaultGC;
156 
158  static const TGGC &GetDefaultGC();
159 
160 public:
161  TGListView(const TGWindow *p, UInt_t w, UInt_t h,
162  UInt_t options = kSunkenFrame | kDoubleBorder,
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);
172  virtual void AdjustHeaders() { fJustChanged = kTRUE; LayoutHeader(0); }
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);
177  TGTextButton** GetHeaderButtons() { return fColHeader; }
178  UInt_t GetNumColumns() { return fNColumns; }
179  EListViewMode GetViewMode() const { return fViewMode; }
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);
183  virtual void SetDefaultColumnWidth(TGVFileSplitter* splitter);
184  TGDimension GetMaxItemSize() const { return fMaxSize; }
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 
196 class TGLVContainer : public TGContainer {
197 
198 private:
199  TGLVContainer(const TGLVContainer&); // Not implemented
200  TGLVContainer& operator=(const TGLVContainer&); // Not implemented
201 
202 protected:
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 
214 public:
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  { ActivateItem(item->GetFrameElement()); }
229 
230  virtual void SetListView(TGListView *lv) { fListView = lv; }
231  virtual void RemoveItemWithData(void *userData);
232  virtual void SetViewMode(EListViewMode viewMode);
233  EListViewMode GetViewMode() const { return fViewMode; }
234  virtual void SetColumns(Int_t *cpos, Int_t *jmode);
235 
236  virtual TGDimension GetPageDimension() const;
237  virtual TGDimension GetMaxItemSize() const;
238  virtual Int_t GetMaxSubnameWidth(Int_t idx) const;
239  virtual void SetColHeaders(const char* n1="",const char* n2="",const char* n3="",
240  const char* n4="",const char* n5="",const char* n6="",
241  const char* n7="",const char* n8="",const char* n9="",
242  const char* n10="",const char* n11="",const char* n12="");
243  virtual void LineUp(Bool_t select = kFALSE);
244  virtual void LineDown(Bool_t select = kFALSE);
245  virtual void LineLeft(Bool_t select = kFALSE);
246  virtual void LineRight(Bool_t select = kFALSE);
247 
248  virtual Bool_t HandleButton(Event_t* event);
249  TList *GetSelectedItems();
250  TList *GetSelectedEntries();
251  Bool_t GetMultipleSelection() const { return fMultiSelect; };
252  void SetMultipleSelection(Bool_t multi = kTRUE) { fMultiSelect = multi; };
253  void SetHeaders(Int_t ncolumns) { fListView->SetHeaders(ncolumns); }
254  void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
255  { fListView->SetHeader(s,hmode,cmode,idx); }
256  void SetDefaultHeaders() { fListView->SetDefaultHeaders(); }
257  const char *GetHeader(Int_t idx) const { return fListView->GetHeader(idx); }
258  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
259 
260  ClassDef(TGLVContainer,0) // Listview container
261 };
262 
263 #endif
TGString ** fSubnames
Definition: TGListView.h:62
Handle_t FontStruct_t
Definition: GuiTypes.h:38
EListViewMode GetViewMode() const
Definition: TGListView.h:233
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:230
virtual void Activate(Bool_t a)
Make list view item active.
Definition: TGListView.cxx:254
virtual Int_t GetSubnameWidth(Int_t idx) const
Definition: TGListView.h:125
virtual void AdjustHeaders()
Definition: TGListView.h:172
const char Option_t
Definition: RtypesCore.h:62
virtual void SetTitle(const char *text)
Definition: TGListView.h:108
UInt_t fTWidth
Definition: TGListView.h:66
REAL splitter
Definition: triangle.c:616
TH1 * h
Definition: legend2.C:5
FontStruct_t fFontStruct
Definition: TGListView.h:77
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
void SetHeaders(Int_t ncolumns)
Definition: TGListView.h:253
TGListView * GetListView() const
Definition: TGListView.h:223
GContext_t fNormGC
Definition: TGListView.h:148
leg SetHeader("The Legend Title")
EListViewMode
Definition: TGListView.h:39
TGVFileSplitter ** fSplitHeader
Definition: TGListView.h:147
Handle_t GContext_t
Definition: GuiTypes.h:37
Basic string class.
Definition: TString.h:125
const TGPicture * fCheckMark
Definition: TGListView.h:74
EListViewMode fViewMode
Definition: TGListView.h:143
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
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.
Definition: TGListView.cxx:197
Int_t * fColumns
Definition: TGListView.h:141
EListViewMode GetViewMode() const
Definition: TGListView.h:111
virtual void SelectionChanged()
Definition: TGListView.h:186
Int_t * fJmode
Definition: TGListView.h:64
Bool_t fChecked
Definition: TGListView.h:69
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
virtual void SetDefaultHeaders()
Default headers are: Name, Attributes, Size, Owner, Group, Modified.
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual void SetCheckedEntry(Bool_t check=kTRUE)
Definition: TGListView.h:122
TGTextButton ** GetHeaderButtons()
Definition: TGListView.h:177
virtual void Layout()
Definition: TGFrame.h:246
TGString * fItemName
Definition: TGListView.h:61
EListViewMode GetViewMode() const
Definition: TGListView.h:179
Bool_t fActive
Definition: TGListView.h:68
void SetDefaultHeaders()
Definition: TGListView.h:256
auto * lv
Definition: textalign.C:5
TGTextButton ** fColHeader
Definition: TGListView.h:145
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
A doubly linked list.
Definition: TList.h:44
virtual TGString * GetSubname(Int_t idx) const
Definition: TGListView.h:115
void * fUserData
Definition: TGListView.h:78
UInt_t fMinColumnSize
Definition: TGListView.h:152
void SetUserData(void *userData)
Definition: TGListView.h:112
virtual TGString ** GetSubnames() const
Definition: TGListView.h:114
UInt_t fTHeight
Definition: TGListView.h:67
const TGPicture * fSmallPic
Definition: TGListView.h:72
static TGGC * fgDefaultGC
Definition: TGListView.h:81
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a frame widget as a C++ statement(s) on output stream out.
Definition: TGFrame.cxx:3187
Bool_t IsActive() const
Definition: TGListView.h:105
TGLVEntry(const TGLVEntry &)
FontStruct_t fFontStruct
Definition: TGListView.h:149
void * GetUserData() const
Definition: TGListView.h:113
auto * a
Definition: textangle.C:12
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw list view item in other window.
Definition: TGListView.cxx:324
TString * fColNames
Definition: TGListView.h:146
Bool_t GetMultipleSelection() const
Definition: TGListView.h:251
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t * fCpos
Definition: TGListView.h:205
TGListView * fListView
Definition: TGListView.h:208
TGLVEntry & operator=(const TGLVEntry &)
void SetMultipleSelection(Bool_t multi=kTRUE)
Definition: TGListView.h:252
const TGPicture * GetPicture() const
Definition: TGListView.h:110
virtual void AddItem(TGLVEntry *item)
Definition: TGListView.h:225
Bool_t fMultiSelect
Definition: TGListView.h:207
virtual const char * GetTitle() const
Returns title of object.
Definition: TGListView.h:107
void SetItemName(const char *name)
Definition: TGListView.h:109
TGDimension fMaxSize
Definition: TGListView.h:144
virtual void SetColumns(Int_t *cpos, Int_t *jmode)
Definition: TGListView.h:121
virtual TGDimension GetDefaultSize() const
Get default size of list item.
Definition: TGListView.cxx:463
const char * GetString() const
Definition: TGString.h:40
const Bool_t kFALSE
Definition: RtypesCore.h:88
Bool_t fJustChanged
Definition: TGListView.h:151
Int_t * fCpos
Definition: TGListView.h:63
long Long_t
Definition: RtypesCore.h:50
TGLayoutHints * fItemLayout
Definition: TGListView.h:203
TGDimension GetMaxItemSize() const
Definition: TGListView.h:184
EListViewMode fViewMode
Definition: TGListView.h:70
TText * text
static const TGFont * fgDefaultFont
Definition: TGListView.h:154
virtual void SetPictures(const TGPicture *bigpic=0, const TGPicture *smallpic=0)
change pictures
Definition: TGListView.cxx:292
static const TGFont * fgDefaultFont
Definition: TGListView.h:80
Definition: TGFont.h:149
Int_t * fJmode
Definition: TGListView.h:206
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t HandleButton(Event_t *)
Definition: TGFrame.h:208
static constexpr double s
Int_t * fCtw
Definition: TGListView.h:65
virtual void SetViewMode(EListViewMode viewMode)
Set the view mode for this list item.
Definition: TGListView.cxx:271
const char * GetHeader(Int_t idx) const
Definition: TGListView.h:257
virtual void SelectEntry(TGLVEntry *item)
Definition: TGListView.h:227
Int_t * fJmode
Definition: TGListView.h:142
TGSelectedPicture * fSelPic
Definition: TGListView.h:75
const TGPicture * fCurrent
Definition: TGListView.h:73
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
UInt_t GetNumColumns()
Definition: TGListView.h:178
static const TGGC & GetDefaultGC()
Return the default graphics context in use.
Definition: TGListView.cxx:500
static TGGC * fgDefaultGC
Definition: TGListView.h:155
TGLVEntry * fLastActive
Definition: TGListView.h:209
GContext_t fNormGC
Definition: TGListView.h:76
virtual void SetListView(TGListView *lv)
Definition: TGListView.h:230
EListViewMode fViewMode
Definition: TGListView.h:204
TGFrameElement * GetFrameElement() const
Definition: TGFrame.h:282
virtual void DoRedraw()
Redraw list view item.
Definition: TGListView.cxx:314
Int_t fNColumns
Definition: TGListView.h:140
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 Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Definition: TGListView.h:254
TGString * GetItemName() const
Definition: TGListView.h:106
virtual ~TGLVEntry()
Delete a list view item.
Definition: TGListView.cxx:183
const TGPicture * fBigPic
Definition: TGListView.h:71
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
Definition: TGListView.cxx:490
const Bool_t kTRUE
Definition: RtypesCore.h:87
Definition: TGGC.h:31
char name[80]
Definition: TGX11.cxx:109
TGHeaderFrame * fHeader
Definition: TGListView.h:150
ULong_t Handle_t
Definition: GuiTypes.h:25