Logo ROOT   6.08/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 #ifndef ROOT_TGCanvas
35 #include "TGCanvas.h"
36 #endif
37 #ifndef ROOT_TGWidget
38 #include "TGWidget.h"
39 #endif
40 #ifndef ROOT_TGSplitter
41 #include "TGSplitter.h"
42 #endif
43 
44 
50 };
51 
52 
53 class TGSelectedPicture;
54 class TGTextButton;
55 class TGListView;
56 class TGLVContainer;
57 class TGHeaderFrame;
58 
59 
60 class TGLVEntry : public TGFrame {
61 
62 private:
63  TGLVEntry(const TGLVEntry&); // Not implemented
64  TGLVEntry& operator=(const TGLVEntry&); // Not implemented
65 
66 protected:
67  TGString *fItemName; // name of item
68  TGString **fSubnames; // sub names of item (details)
69  Int_t *fCpos; // position of sub names
70  Int_t *fJmode; // alignment for sub names
71  Int_t *fCtw; // width of sub names
72  UInt_t fTWidth; // width of name
73  UInt_t fTHeight; // height of name
74  Bool_t fActive; // true if item is active
75  Bool_t fChecked; // true if item is checked
76  EListViewMode fViewMode; // list view viewing mode
77  const TGPicture *fBigPic; // big icon
78  const TGPicture *fSmallPic; // small icon
79  const TGPicture *fCurrent; // current icon
80  const TGPicture *fCheckMark; // checkmark
81  TGSelectedPicture *fSelPic; // selected icon
82  GContext_t fNormGC; // drawing graphics context
83  FontStruct_t fFontStruct; // text font
84  void *fUserData; // pointer to user data structure
85 
86  static const TGFont *fgDefaultFont;
87  static TGGC *fgDefaultGC;
88 
89  virtual void DoRedraw();
90 
92  static const TGGC &GetDefaultGC();
93 
94 public:
95  TGLVEntry(const TGWindow *p = 0,
96  const TGPicture *bigpic = 0, const TGPicture *smallpic = 0,
97  TGString *name = 0, TGString **subnames = 0,
98  EListViewMode ViewMode = kLVDetails,
99  UInt_t options = kChildFrame,
100  Pixel_t back = GetWhitePixel());
101 
102  TGLVEntry(const TGLVContainer *p,
103  const TString& name, const TString& cname, TGString **subnames = 0,
104  UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
105 
106  virtual ~TGLVEntry();
107 
108  virtual void SetViewMode(EListViewMode viewMode);
109 
110  virtual void Activate(Bool_t a);
111  Bool_t IsActive() const { return fActive; }
112  TGString *GetItemName() const { return fItemName; }
113  virtual const char *GetTitle() const { return fItemName->GetString(); }
114  virtual void SetTitle(const char *text) { *fItemName = text; }
115  void SetItemName(const char *name) { *fItemName = name; }
116  const TGPicture *GetPicture() const { return fCurrent; }
117  EListViewMode GetViewMode() const { return fViewMode; }
118  void SetUserData(void *userData) { fUserData = userData; }
119  void *GetUserData() const { return fUserData; }
120  virtual TGString **GetSubnames() const { return fSubnames; }
121  virtual TGString *GetSubname(Int_t idx) const { if (fSubnames) return fSubnames[idx]; else return 0; }
122  virtual void SetSubnames(const char* n1="",const char* n2="",const char* n3="",
123  const char* n4="",const char* n5="",const char* n6="",
124  const char* n7="",const char* n8="",const char* n9="",
125  const char* n10="",const char* n11="",const char* n12="");
126  virtual void SetPictures(const TGPicture *bigpic = 0, const TGPicture *smallpic = 0);
127  virtual void SetColumns(Int_t *cpos, Int_t *jmode) { fCpos = cpos; fJmode = jmode; }
128  virtual void SetCheckedEntry(Bool_t check = kTRUE) { fChecked = check; }
129 
130  virtual TGDimension GetDefaultSize() const;
131  virtual Int_t GetSubnameWidth(Int_t idx) const { return fCtw[idx]; }
132 
133  virtual void DrawCopy(Handle_t id, Int_t x, Int_t y);
134 
135  ClassDef(TGLVEntry,0) // Item that goes into a TGListView container
136 };
137 
138 
139 class TGListView : public TGCanvas {
140 
141 private:
142  TGListView(const TGListView&); // Not implemented
143  TGListView& operator=(const TGListView&); // Not implemented
144 
145 protected:
146  Int_t fNColumns; // number of columns
147  Int_t *fColumns; // column width
148  Int_t *fJmode; // column text alignment
149  EListViewMode fViewMode; // view mode if list view widget
150  TGDimension fMaxSize; // maximum item size
151  TGTextButton **fColHeader; // column headers for in detailed mode
152  TString *fColNames; // column titles for in detailed mode
153  TGVFileSplitter **fSplitHeader; // column splitters
154  GContext_t fNormGC; // drawing graphics context
155  FontStruct_t fFontStruct; // text font
156  TGHeaderFrame *fHeader; // frame used as container for column headers
157  Bool_t fJustChanged; // Indicate whether the view mode was just changed to Detail
158  UInt_t fMinColumnSize; // Minimun column size
159 
160  static const TGFont *fgDefaultFont;
161  static TGGC *fgDefaultGC;
162 
164  static const TGGC &GetDefaultGC();
165 
166 public:
167  TGListView(const TGWindow *p, UInt_t w, UInt_t h,
168  UInt_t options = kSunkenFrame | kDoubleBorder,
170  virtual ~TGListView();
171 
172  virtual void ResizeColumns();
173  virtual void Layout();
174  virtual void LayoutHeader(TGFrame *head);
175  virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
176  virtual void ScrollHeader(Int_t pos);
177  virtual void SetContainer(TGFrame *f);
178  virtual void AdjustHeaders() { fJustChanged = kTRUE; LayoutHeader(0); }
179  virtual void SetHeaders(Int_t ncolumns);
180  virtual void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx);
181  virtual void SetDefaultHeaders();
182  virtual void SetViewMode(EListViewMode viewMode);
183  TGTextButton** GetHeaderButtons() { return fColHeader; }
184  UInt_t GetNumColumns() { return fNColumns; }
185  EListViewMode GetViewMode() const { return fViewMode; }
186  virtual const char *GetHeader(Int_t idx) const;
187  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
188  virtual void SetIncrements(Int_t hInc, Int_t vInc);
189  virtual void SetDefaultColumnWidth(TGVFileSplitter* splitter);
190  TGDimension GetMaxItemSize() const { return fMaxSize; }
191 
192  virtual void SelectionChanged() { Emit("SelectionChanged()"); } //*SIGNAL*
193  virtual void Clicked(TGLVEntry *entry, Int_t btn); //*SIGNAL*
194  virtual void Clicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
195  virtual void DoubleClicked(TGLVEntry *entry, Int_t btn); //*SIGNAL*
196  virtual void DoubleClicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y); //*SIGNAL*
197 
198  ClassDef(TGListView,0) // List view widget (iconbox, small icons or tabular view)
199 };
200 
201 
202 class TGLVContainer : public TGContainer {
203 
204 private:
205  TGLVContainer(const TGLVContainer&); // Not implemented
206  TGLVContainer& operator=(const TGLVContainer&); // Not implemented
207 
208 protected:
209  TGLayoutHints *fItemLayout; // item layout hints
210  EListViewMode fViewMode; // list view viewing mode
211  Int_t *fCpos; // position of sub names
212  Int_t *fJmode; // alignment of sub names
213  Bool_t fMultiSelect; // true = multiple file selection
214  TGListView *fListView; // listview which contains this container
215  TGLVEntry *fLastActive; // last active item
216 
217  virtual void ActivateItem(TGFrameElement* el);
218  virtual void DeActivateItem(TGFrameElement* el);
219 
220 public:
221  TGLVContainer(const TGWindow *p, UInt_t w, UInt_t h,
222  UInt_t options = kSunkenFrame,
226 
227  virtual ~TGLVContainer();
228 
229  TGListView *GetListView() const { return fListView; }
230 
231  virtual void AddItem(TGLVEntry *item)
232  { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); fTotal++; }
233  virtual void SelectEntry(TGLVEntry *item)
234  { ActivateItem(item->GetFrameElement()); }
235 
236  virtual void SetListView(TGListView *lv) { fListView = lv; }
237  virtual void RemoveItemWithData(void *userData);
238  virtual void SetViewMode(EListViewMode viewMode);
239  EListViewMode GetViewMode() const { return fViewMode; }
240  virtual void SetColumns(Int_t *cpos, Int_t *jmode);
241 
242  virtual TGDimension GetPageDimension() const;
243  virtual TGDimension GetMaxItemSize() const;
244  virtual Int_t GetMaxSubnameWidth(Int_t idx) const;
245  virtual void SetColHeaders(const char* n1="",const char* n2="",const char* n3="",
246  const char* n4="",const char* n5="",const char* n6="",
247  const char* n7="",const char* n8="",const char* n9="",
248  const char* n10="",const char* n11="",const char* n12="");
249  virtual void LineUp(Bool_t select = kFALSE);
250  virtual void LineDown(Bool_t select = kFALSE);
251  virtual void LineLeft(Bool_t select = kFALSE);
252  virtual void LineRight(Bool_t select = kFALSE);
253 
254  virtual Bool_t HandleButton(Event_t* event);
255  TList *GetSelectedItems();
256  TList *GetSelectedEntries();
257  Bool_t GetMultipleSelection() const { return fMultiSelect; };
258  void SetMultipleSelection(Bool_t multi = kTRUE) { fMultiSelect = multi; };
259  void SetHeaders(Int_t ncolumns) { fListView->SetHeaders(ncolumns); }
260  void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
261  { fListView->SetHeader(s,hmode,cmode,idx); }
262  void SetDefaultHeaders() { fListView->SetDefaultHeaders(); }
263  const char *GetHeader(Int_t idx) const { return fListView->GetHeader(idx); }
264  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
265 
266  ClassDef(TGLVContainer,0) // Listview container
267 };
268 
269 #endif
TGString ** fSubnames
Definition: TGListView.h:68
Handle_t FontStruct_t
Definition: GuiTypes.h:40
EListViewMode GetViewMode() const
Definition: TGListView.h:239
virtual Bool_t ProcessMessage(Long_t, Long_t, Long_t)
Definition: TGFrame.h:246
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:131
virtual void AdjustHeaders()
Definition: TGListView.h:178
const char Option_t
Definition: RtypesCore.h:62
virtual void SetTitle(const char *text)
Definition: TGListView.h:114
UInt_t fTWidth
Definition: TGListView.h:72
REAL splitter
Definition: triangle.c:616
TH1 * h
Definition: legend2.C:5
FontStruct_t fFontStruct
Definition: TGListView.h:83
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
void SetHeaders(Int_t ncolumns)
Definition: TGListView.h:259
TGListView * GetListView() const
Definition: TGListView.h:229
GContext_t fNormGC
Definition: TGListView.h:154
leg SetHeader("The Legend Title")
EListViewMode
Definition: TGListView.h:45
TGVFileSplitter ** fSplitHeader
Definition: TGListView.h:153
Handle_t GContext_t
Definition: GuiTypes.h:39
Basic string class.
Definition: TString.h:137
const TGPicture * fCheckMark
Definition: TGListView.h:80
EListViewMode fViewMode
Definition: TGListView.h:149
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
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t * fColumns
Definition: TGListView.h:147
EListViewMode GetViewMode() const
Definition: TGListView.h:117
virtual void SelectionChanged()
Definition: TGListView.h:192
Int_t * fJmode
Definition: TGListView.h:70
Bool_t fChecked
Definition: TGListView.h:75
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
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:128
TGTextButton ** GetHeaderButtons()
Definition: TGListView.h:183
virtual void Layout()
Definition: TGFrame.h:262
TGString * fItemName
Definition: TGListView.h:67
EListViewMode GetViewMode() const
Definition: TGListView.h:185
Bool_t fActive
Definition: TGListView.h:74
void SetDefaultHeaders()
Definition: TGListView.h:262
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:561
TGTextButton ** fColHeader
Definition: TGListView.h:151
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
A doubly linked list.
Definition: TList.h:47
virtual TGString * GetSubname(Int_t idx) const
Definition: TGListView.h:121
void * fUserData
Definition: TGListView.h:84
UInt_t fMinColumnSize
Definition: TGListView.h:158
void SetUserData(void *userData)
Definition: TGListView.h:118
virtual TGString ** GetSubnames() const
Definition: TGListView.h:120
UInt_t fTHeight
Definition: TGListView.h:73
const TGPicture * fSmallPic
Definition: TGListView.h:78
static TGGC * fgDefaultGC
Definition: TGListView.h:87
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:3188
Bool_t IsActive() const
Definition: TGListView.h:111
TGLVEntry(const TGLVEntry &)
FontStruct_t fFontStruct
Definition: TGListView.h:155
void * GetUserData() const
Definition: TGListView.h:119
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:152
Bool_t GetMultipleSelection() const
Definition: TGListView.h:257
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t * fCpos
Definition: TGListView.h:211
TGListView * fListView
Definition: TGListView.h:214
TGLVEntry & operator=(const TGLVEntry &)
void SetMultipleSelection(Bool_t multi=kTRUE)
Definition: TGListView.h:258
const TGPicture * GetPicture() const
Definition: TGListView.h:116
virtual void AddItem(TGLVEntry *item)
Definition: TGListView.h:231
Bool_t fMultiSelect
Definition: TGListView.h:213
virtual const char * GetTitle() const
Returns title of object.
Definition: TGListView.h:113
void SetItemName(const char *name)
Definition: TGListView.h:115
TGDimension fMaxSize
Definition: TGListView.h:150
virtual void SetColumns(Int_t *cpos, Int_t *jmode)
Definition: TGListView.h:127
virtual TGDimension GetDefaultSize() const
Get default size of list item.
Definition: TGListView.cxx:463
const char * GetString() const
Definition: TGString.h:44
Bool_t fJustChanged
Definition: TGListView.h:157
Int_t * fCpos
Definition: TGListView.h:69
long Long_t
Definition: RtypesCore.h:50
TGLayoutHints * fItemLayout
Definition: TGListView.h:209
double f(double x)
TGDimension GetMaxItemSize() const
Definition: TGListView.h:190
EListViewMode fViewMode
Definition: TGListView.h:76
TText * text
static const TGFont * fgDefaultFont
Definition: TGListView.h:160
virtual void SetPictures(const TGPicture *bigpic=0, const TGPicture *smallpic=0)
change pictures
Definition: TGListView.cxx:292
static const TGFont * fgDefaultFont
Definition: TGListView.h:86
Definition: TGFont.h:155
Int_t * fJmode
Definition: TGListView.h:212
Double_t y[n]
Definition: legend1.C:17
virtual Bool_t HandleButton(Event_t *)
Definition: TGFrame.h:224
Int_t * fCtw
Definition: TGListView.h:71
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:263
virtual void SelectEntry(TGLVEntry *item)
Definition: TGListView.h:233
Int_t * fJmode
Definition: TGListView.h:148
TGSelectedPicture * fSelPic
Definition: TGListView.h:81
const TGPicture * fCurrent
Definition: TGListView.h:79
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
UInt_t GetNumColumns()
Definition: TGListView.h:184
static const TGGC & GetDefaultGC()
Return the default graphics context in use.
Definition: TGListView.cxx:500
static TGGC * fgDefaultGC
Definition: TGListView.h:161
TGLVEntry * fLastActive
Definition: TGListView.h:215
GContext_t fNormGC
Definition: TGListView.h:82
virtual void SetListView(TGListView *lv)
Definition: TGListView.h:236
TLine * lv
Definition: textalign.C:5
EListViewMode fViewMode
Definition: TGListView.h:210
TGFrameElement * GetFrameElement() const
Definition: TGFrame.h:298
virtual void DoRedraw()
Redraw list view item.
Definition: TGListView.cxx:314
Int_t fNColumns
Definition: TGListView.h:146
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 SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Definition: TGListView.h:260
TGString * GetItemName() const
Definition: TGListView.h:112
virtual ~TGLVEntry()
Delete a list view item.
Definition: TGListView.cxx:183
const Bool_t kTRUE
Definition: Rtypes.h:91
const TGPicture * fBigPic
Definition: TGListView.h:77
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
Definition: TGListView.cxx:490
Definition: TGGC.h:35
char name[80]
Definition: TGX11.cxx:109
TGHeaderFrame * fHeader
Definition: TGListView.h:156
ULong_t Handle_t
Definition: GuiTypes.h:27