ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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);
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);
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);
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); }
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:185
virtual void Activate(Bool_t a)
Make list view item active.
Definition: TGListView.cxx:254
virtual void AdjustHeaders()
Definition: TGListView.h:178
virtual void Clicked(TGLVEntry *entry, Int_t btn)
Emit Clicked() signal.
const char Option_t
Definition: RtypesCore.h:62
virtual void SetTitle(const char *text)
Definition: TGListView.h:114
virtual TGDimension GetPageDimension() const
Returns page dimension.
UInt_t fTWidth
Definition: TGListView.h:72
virtual void LineLeft(Bool_t select=kFALSE)
Move current position one column left.
Definition: TGListView.cxx:953
virtual void RemoveItemWithData(void *userData)
Remove item with fUserData == userData from container.
Definition: TGListView.cxx:735
REAL splitter
Definition: triangle.c:616
FontStruct_t fFontStruct
Definition: TGListView.h:83
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
virtual Int_t GetSubnameWidth(Int_t idx) const
Definition: TGListView.h:131
void SetHeaders(Int_t ncolumns)
Definition: TGListView.h:259
virtual void LineDown(Bool_t select=kFALSE)
Move one line down.
GContext_t fNormGC
Definition: TGListView.h:154
TGLVContainer(const TGLVContainer &)
virtual TGString ** GetSubnames() const
Definition: TGListView.h:120
EListViewMode
Definition: TGListView.h:45
TGVFileSplitter ** fSplitHeader
Definition: TGListView.h:153
const char * GetHeader(Int_t idx) const
Definition: TGListView.h:263
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list view widget as a C++ statement(s) on output stream out.
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
virtual void SetColumns(Int_t *cpos, Int_t *jmode)
Set column information for list items.
Definition: TGListView.cxx:674
TArc * a
Definition: textangle.C:12
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t * fColumns
Definition: TGListView.h:147
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
virtual void LayoutHeader(TGFrame *head)
Layout list view components (container and contents of container).
virtual void SelectionChanged()
Definition: TGListView.h:192
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
Definition: TGListView.cxx:565
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode for container.
Definition: TGListView.cxx:608
const TGPicture * GetPicture() const
Definition: TGListView.h:116
virtual void Layout()
Layout list view components (container and contents of container).
Int_t * fJmode
Definition: TGListView.h:70
TGString * GetItemName() const
Definition: TGListView.h:112
TFile * f
static const TGGC & GetDefaultGC()
Return the default graphics context in use.
virtual ~TGLVContainer()
Delete list view container.
Definition: TGListView.cxx:554
virtual void LineRight(Bool_t select=kFALSE)
Move current position one column right.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a list view container as a C++ statement(s) on output stream out.
TGListView * GetListView() const
Definition: TGListView.h:229
Bool_t fChecked
Definition: TGListView.h:75
TList * GetSelectedEntries()
Get list of selected items in container.
Definition: TGListView.cxx:919
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 SetIncrements(Int_t hInc, Int_t vInc)
Set horizontal and vertical scrollbar increments.
virtual void SetCheckedEntry(Bool_t check=kTRUE)
Definition: TGListView.h:128
virtual void ScrollHeader(Int_t pos)
Scroll header buttons with horizontal scrollbar.
TGTextButton ** GetHeaderButtons()
Definition: TGListView.h:183
TGFrameElement * GetFrameElement() const
Definition: TGFrame.h:298
TGString * fItemName
Definition: TGListView.h:67
virtual TGDimension GetDefaultSize() const
Get default size of list item.
Definition: TGListView.cxx:463
virtual void SetDefaultColumnWidth(TGVFileSplitter *splitter)
Set default column width of the columns headers.
Bool_t fActive
Definition: TGListView.h:74
void SetDefaultHeaders()
Definition: TGListView.h:262
virtual void DoubleClicked(TGLVEntry *entry, Int_t btn)
Emit DoubleClicked() signal.
TGListView(const TGListView &)
char * out
Definition: TBase64.cxx:29
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
TGTextButton ** fColHeader
Definition: TGListView.h:151
A doubly linked list.
Definition: TList.h:47
void * fUserData
Definition: TGListView.h:84
UInt_t fMinColumnSize
Definition: TGListView.h:158
void SetUserData(void *userData)
Definition: TGListView.h:118
UInt_t fTHeight
Definition: TGListView.h:73
const TGPicture * fSmallPic
Definition: TGListView.h:78
static TGGC * fgDefaultGC
Definition: TGListView.h:87
TGLVEntry(const TGLVEntry &)
FontStruct_t fFontStruct
Definition: TGListView.h:155
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Draw list view item in other window.
Definition: TGListView.cxx:324
static FontStruct_t GetDefaultFontStruct()
Return the default font structure in use.
TString * fColNames
Definition: TGListView.h:152
unsigned int UInt_t
Definition: RtypesCore.h:42
Int_t * fCpos
Definition: TGListView.h:211
EListViewMode GetViewMode() const
Definition: TGListView.h:239
TGDimension GetMaxItemSize() const
Definition: TGListView.h:190
virtual void DeActivateItem(TGFrameElement *el)
Unselect/deactivate item.
Definition: TGListView.cxx:760
EListViewMode GetViewMode() const
Definition: TGListView.h:117
virtual void ActivateItem(TGFrameElement *el)
Select/activate item.
Definition: TGListView.cxx:751
TGListView * fListView
Definition: TGListView.h:214
TGLVEntry & operator=(const TGLVEntry &)
virtual ~TGListView()
Delete a list view widget.
void SetMultipleSelection(Bool_t multi=kTRUE)
Definition: TGListView.h:258
virtual void AddItem(TGLVEntry *item)
Definition: TGListView.h:231
Bool_t fMultiSelect
Definition: TGListView.h:213
void SetItemName(const char *name)
Definition: TGListView.h:115
Long64_t entry
TGDimension fMaxSize
Definition: TGListView.h:150
virtual void SetColumns(Int_t *cpos, Int_t *jmode)
Definition: TGListView.h:127
TList * GetSelectedItems()
Get list of selected items in container.
Definition: TGListView.cxx:936
virtual void LineUp(Bool_t select=kFALSE)
Make current position first line in window by scrolling up.
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
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
EListViewMode fViewMode
Definition: TGListView.h:76
void select(Int_t replica=1, Int_t color=kGreen)
Definition: runplugin.C:24
TText * text
static const TGFont * fgDefaultFont
Definition: TGListView.h:160
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in container.
Definition: TGListView.cxx:769
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
void * GetUserData() const
Definition: TGListView.h:119
Definition: TGFont.h:155
Int_t * fJmode
Definition: TGListView.h:212
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle messages generated by the list view components.
Double_t y[n]
Definition: legend1.C:17
TGListView & operator=(const TGListView &)
virtual const char * GetTitle() const
Returns title of object.
Definition: TGListView.h:113
Int_t * fCtw
Definition: TGListView.h:71
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
virtual void SetViewMode(EListViewMode viewMode)
Set the view mode for this list item.
Definition: TGListView.cxx:271
virtual void SelectEntry(TGLVEntry *item)
Definition: TGListView.h:233
Int_t * fJmode
Definition: TGListView.h:148
#define name(a, b)
Definition: linkTestLib0.cpp:5
TGSelectedPicture * fSelPic
Definition: TGListView.h:81
const TGPicture * fCurrent
Definition: TGListView.h:79
Bool_t IsActive() const
Definition: TGListView.h:111
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
Bool_t GetMultipleSelection() const
Definition: TGListView.h:257
GContext_t fNormGC
Definition: TGListView.h:82
virtual void SetListView(TGListView *lv)
Definition: TGListView.h:236
virtual TGString * GetSubname(Int_t idx) const
Definition: TGListView.h:121
TLine * lv
Definition: textalign.C:5
EListViewMode fViewMode
Definition: TGListView.h:210
Int_t fTotal
Definition: TGCanvas.h:60
virtual Int_t GetMaxSubnameWidth(Int_t idx) const
Get width of largest subname in container.
Definition: TGListView.cxx:714
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...
const char * GetString() const
Definition: TGString.h:44
virtual TGDimension GetMaxItemSize() const
Get size of largest item in container.
Definition: TGListView.cxx:690
virtual void ResizeColumns()
Resize column headers to show whole item names.
void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Definition: TGListView.h:260
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
virtual void SetContainer(TGFrame *f)
Set list view container.
TGLVContainer & operator=(const TGLVContainer &)
TGHeaderFrame * fHeader
Definition: TGListView.h:156
ULong_t Handle_t
Definition: GuiTypes.h:27