Warning, file /include/root/TGListView.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGListView
0013 #define ROOT_TGListView
0014
0015
0016 #include "TGCanvas.h"
0017 #include "TGWidget.h"
0018 #include "TGSplitter.h"
0019
0020
0021 enum EListViewMode {
0022 kLVLargeIcons,
0023 kLVSmallIcons,
0024 kLVList,
0025 kLVDetails
0026 };
0027
0028
0029 class TGSelectedPicture;
0030 class TGTextButton;
0031 class TGListView;
0032 class TGLVContainer;
0033 class TGHeaderFrame;
0034
0035
0036 class TGLVEntry : public TGFrame {
0037
0038 private:
0039 TGLVEntry(const TGLVEntry&) = delete;
0040 TGLVEntry& operator=(const TGLVEntry&) = delete;
0041
0042 protected:
0043 TGString *fItemName;
0044 TGString **fSubnames;
0045 Int_t *fCpos;
0046 Int_t *fJmode;
0047 Int_t *fCtw;
0048 UInt_t fTWidth;
0049 UInt_t fTHeight;
0050 Bool_t fActive;
0051 Bool_t fChecked;
0052 EListViewMode fViewMode;
0053 const TGPicture *fBigPic;
0054 const TGPicture *fSmallPic;
0055 const TGPicture *fCurrent;
0056 const TGPicture *fCheckMark;
0057 TGSelectedPicture *fSelPic;
0058 GContext_t fNormGC;
0059 FontStruct_t fFontStruct;
0060 void *fUserData;
0061
0062 static const TGFont *fgDefaultFont;
0063 static TGGC *fgDefaultGC;
0064
0065 void DoRedraw() override;
0066
0067 static FontStruct_t GetDefaultFontStruct();
0068 static const TGGC &GetDefaultGC();
0069
0070 public:
0071 TGLVEntry(const TGWindow *p = nullptr,
0072 const TGPicture *bigpic = nullptr, const TGPicture *smallpic = nullptr,
0073 TGString *name = nullptr, TGString **subnames = nullptr,
0074 EListViewMode ViewMode = kLVDetails,
0075 UInt_t options = kChildFrame,
0076 Pixel_t back = GetWhitePixel());
0077
0078 TGLVEntry(const TGLVContainer *p,
0079 const TString& name, const TString& cname, TGString **subnames = nullptr,
0080 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel());
0081
0082 ~TGLVEntry() override;
0083
0084 virtual void SetViewMode(EListViewMode viewMode);
0085
0086 void Activate(Bool_t a) override;
0087 Bool_t IsActive() const override { return fActive; }
0088 TGString *GetItemName() const { return fItemName; }
0089 const char *GetTitle() const override { return fItemName->GetString(); }
0090 virtual void SetTitle(const char *text) { *fItemName = text; }
0091 void SetItemName(const char *name) { *fItemName = name; }
0092 const TGPicture *GetPicture() const { return fCurrent; }
0093 EListViewMode GetViewMode() const { return fViewMode; }
0094 void SetUserData(void *userData) { fUserData = userData; }
0095 void *GetUserData() const { return fUserData; }
0096 virtual TGString **GetSubnames() const { return fSubnames; }
0097 virtual TGString *GetSubname(Int_t idx) const { if (fSubnames) return fSubnames[idx]; else return nullptr; }
0098 virtual void SetSubnames(const char* n1="",const char* n2="",const char* n3="",
0099 const char* n4="",const char* n5="",const char* n6="",
0100 const char* n7="",const char* n8="",const char* n9="",
0101 const char* n10="",const char* n11="",const char* n12="");
0102 virtual void SetPictures(const TGPicture *bigpic = nullptr, const TGPicture *smallpic = nullptr);
0103 virtual void SetColumns(Int_t *cpos, Int_t *jmode) { fCpos = cpos; fJmode = jmode; }
0104 virtual void SetCheckedEntry(Bool_t check = kTRUE) { fChecked = check; }
0105
0106 TGDimension GetDefaultSize() const override;
0107 virtual Int_t GetSubnameWidth(Int_t idx) const { return fCtw[idx]; }
0108
0109 void DrawCopy(Handle_t id, Int_t x, Int_t y) override;
0110
0111 ClassDefOverride(TGLVEntry,0)
0112 };
0113
0114
0115 class TGListView : public TGCanvas {
0116
0117 private:
0118 TGListView(const TGListView&) = delete;
0119 TGListView& operator=(const TGListView&) = delete;
0120
0121 protected:
0122 Int_t fNColumns;
0123 Int_t *fColumns;
0124 Int_t *fJmode;
0125 EListViewMode fViewMode;
0126 TGDimension fMaxSize;
0127 TGTextButton **fColHeader;
0128 TString *fColNames;
0129 TGVFileSplitter **fSplitHeader;
0130 GContext_t fNormGC;
0131 FontStruct_t fFontStruct;
0132 TGHeaderFrame *fHeader;
0133 Bool_t fJustChanged;
0134 UInt_t fMinColumnSize;
0135
0136 static const TGFont *fgDefaultFont;
0137 static TGGC *fgDefaultGC;
0138
0139 static FontStruct_t GetDefaultFontStruct();
0140 static const TGGC &GetDefaultGC();
0141
0142 public:
0143 TGListView(const TGWindow *p, UInt_t w, UInt_t h,
0144 UInt_t options = kSunkenFrame | kDoubleBorder,
0145 Pixel_t back = GetDefaultFrameBackground());
0146 ~TGListView() override;
0147
0148 virtual void ResizeColumns();
0149 void Layout() override;
0150 virtual void LayoutHeader(TGFrame *head);
0151 Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0152 virtual void ScrollHeader(Int_t pos);
0153 void SetContainer(TGFrame *f) override;
0154 virtual void AdjustHeaders() { fJustChanged = kTRUE; LayoutHeader(nullptr); }
0155 virtual void SetHeaders(Int_t ncolumns);
0156 virtual void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx);
0157 virtual void SetDefaultHeaders();
0158 virtual void SetViewMode(EListViewMode viewMode);
0159 TGTextButton** GetHeaderButtons() { return fColHeader; }
0160 UInt_t GetNumColumns() { return fNColumns; }
0161 EListViewMode GetViewMode() const { return fViewMode; }
0162 virtual const char *GetHeader(Int_t idx) const;
0163 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0164 virtual void SetIncrements(Int_t hInc, Int_t vInc);
0165 virtual void SetDefaultColumnWidth(TGVFileSplitter* splitter);
0166 TGDimension GetMaxItemSize() const { return fMaxSize; }
0167
0168 virtual void SelectionChanged() { Emit("SelectionChanged()"); }
0169 virtual void Clicked(TGLVEntry *entry, Int_t btn);
0170 virtual void Clicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y);
0171 virtual void DoubleClicked(TGLVEntry *entry, Int_t btn);
0172 virtual void DoubleClicked(TGLVEntry *entry, Int_t btn, Int_t x, Int_t y);
0173
0174 ClassDefOverride(TGListView,0)
0175 };
0176
0177
0178 class TGLVContainer : public TGContainer {
0179
0180 private:
0181 TGLVContainer(const TGLVContainer&) = delete;
0182 TGLVContainer& operator=(const TGLVContainer&) = delete;
0183
0184 protected:
0185 TGLayoutHints *fItemLayout;
0186 EListViewMode fViewMode;
0187 Int_t *fCpos;
0188 Int_t *fJmode;
0189 Bool_t fMultiSelect;
0190 TGListView *fListView;
0191 TGLVEntry *fLastActive;
0192
0193 void ActivateItem(TGFrameElement* el) override;
0194 void DeActivateItem(TGFrameElement* el) override;
0195
0196 public:
0197 TGLVContainer(const TGWindow *p, UInt_t w, UInt_t h,
0198 UInt_t options = kSunkenFrame,
0199 Pixel_t back = GetDefaultFrameBackground());
0200 TGLVContainer(TGCanvas *p, UInt_t options = kSunkenFrame,
0201 Pixel_t back = GetDefaultFrameBackground());
0202
0203 ~TGLVContainer() override;
0204
0205 TGListView *GetListView() const { return fListView; }
0206
0207 virtual void AddItem(TGLVEntry *item)
0208 { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); fTotal++; }
0209 virtual void SelectEntry(TGLVEntry *item);
0210
0211 virtual void SetListView(TGListView *lv) { fListView = lv; }
0212 virtual void RemoveItemWithData(void *userData);
0213 virtual void SetViewMode(EListViewMode viewMode);
0214 EListViewMode GetViewMode() const { return fViewMode; }
0215 virtual void SetColumns(Int_t *cpos, Int_t *jmode);
0216
0217 TGDimension GetPageDimension() const override;
0218 virtual TGDimension GetMaxItemSize() const;
0219 virtual Int_t GetMaxSubnameWidth(Int_t idx) const;
0220 virtual void SetColHeaders(const char* n1="",const char* n2="",const char* n3="",
0221 const char* n4="",const char* n5="",const char* n6="",
0222 const char* n7="",const char* n8="",const char* n9="",
0223 const char* n10="",const char* n11="",const char* n12="");
0224 void LineUp(Bool_t select = kFALSE) override;
0225 void LineDown(Bool_t select = kFALSE) override;
0226 void LineLeft(Bool_t select = kFALSE) override;
0227 void LineRight(Bool_t select = kFALSE) override;
0228
0229 Bool_t HandleButton(Event_t* event) override;
0230 TList *GetSelectedItems();
0231 TList *GetSelectedEntries();
0232 Bool_t GetMultipleSelection() const { return fMultiSelect; };
0233 void SetMultipleSelection(Bool_t multi = kTRUE) { fMultiSelect = multi; };
0234 void SetHeaders(Int_t ncolumns) { fListView->SetHeaders(ncolumns); }
0235 void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
0236 { fListView->SetHeader(s,hmode,cmode,idx); }
0237 void SetDefaultHeaders() { fListView->SetDefaultHeaders(); }
0238 const char *GetHeader(Int_t idx) const { return fListView->GetHeader(idx); }
0239 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0240
0241 ClassDefOverride(TGLVContainer,0)
0242 };
0243
0244 #endif