#ifndef ROOT_TGListView #define ROOT_TGListView //+SEQ,CopyRight,T=NOINCLUDE. ////////////////////////////////////////////////////////////////////////// // // // TGListView, TGLVContainer and TGLVEntry // // // // A list view is a widget that can contain a number of items // // arranged in a grid or list. The items can be represented either // // by a string or by an icon. // // // // The TGListView is user callable. The other classes are service // // classes of the list view. // // // // A list view can generate the following events: // // kC_CONTAINER, kCT_SELCHANGED, total items, selected items. // // kC_CONTAINER, kCT_ITEMCLICK, which button, location (y<<16|x). // // kC_CONTAINER, kCT_ITEMDBLCLICK, which button, location (y<<16|x). // // // ////////////////////////////////////////////////////////////////////////// #ifndef ROOT_TGCanvas //*KEEP,TGCanvas. #include "TGCanvas.h" //*KEND. #endif #ifndef ROOT_TGWidget //*KEEP,TGWidget. #include "TGWidget.h" //*KEND. #endif enum EListViewMode { kLVLargeIcons, kLVSmallIcons, kLVList, kLVDetails }; class TGSelectedPicture; class TGTextButton; class TGLVEntry : public TGFrame { friend class TGClient; protected: TGString *fName; // name of item TGString **fSubnames; // sub names of item (details) Int_t *fCpos; // position of sub names Int_t *fJmode; // alignment for sub names Int_t *fCtw; // width of sub names UInt_t fTWidth; // width of name UInt_t fTHeight; // height of name Bool_t fActive; // true if item is active EListViewMode fViewMode; // list view viewing mode const TGPicture *fBigPic; // big icon const TGPicture *fSmallPic; // small icon const TGPicture *fCurrent; // current icon TGSelectedPicture *fSelPic; // selected icon GContext_t fNormGC; // drawing graphics context FontStruct_t fFontStruct; // text font void *fUserData; // pointer to user data structure static FontStruct_t fgDefaultFontStruct; static GContext_t fgDefaultGC; static ULong_t fgSelPixel; virtual void DoRedraw(); public: TGLVEntry(const TGWindow *p, const TGPicture *bigpic, const TGPicture *smallpic, TGString *name, TGString **subnames, EListViewMode ViewMode, UInt_t options = kChildFrame, ULong_t back = fgWhitePixel); virtual ~TGLVEntry(); virtual void SetViewMode(EListViewMode ViewMode); void Activate(Bool_t a); Bool_t IsActive() const { return fActive; } const TGString *GetItemName() const { return fName; } const TGPicture *GetPicture() const { return fCurrent; } void SetUserData(void *userData) { fUserData = userData; } void *GetUserData() const { return fUserData; } void SetColumns(Int_t *cpos, Int_t *jmode) { fCpos = cpos; fJmode = jmode; } virtual TGDimension GetDefaultSize() const; ClassDef(TGLVEntry,0) // Item that goes into a TGListView container }; class TGLVContainer : public TGCompositeFrame { friend class TGClient; protected: TGLVEntry *fLastActive; // last active list view item TGLayoutHints *fItemLayout; // item layout hints EListViewMode fViewMode; // list view viewing mode Int_t *fCpos; // position of sub names Int_t *fJmode; // alignment of sub names Int_t fXp, fYp; // previous pointer position Int_t fX0, fY0; // corner of rubber band box Int_t fXf, fYf; // other corner of rubber band box Int_t fTotal; // total items Int_t fSelected; // number of selected items Bool_t fDragging; // true if in dragging mode const TGWindow *fMsgWindow; // window handling container messages static GContext_t fgLineGC; public: TGLVContainer(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options = kSunkenFrame, ULong_t back = fgDefaultFrameBackground); virtual ~TGLVContainer(); virtual void AddItem(TGLVEntry *item) { AddFrame(item, fItemLayout); item->SetColumns(fCpos, fJmode); } virtual Bool_t HandleButton(Event_t *event); virtual Bool_t HandleDoubleClick(Event_t *event); virtual Bool_t HandleMotion(Event_t *event); virtual void Associate(const TGWindow *w) { fMsgWindow = w; } virtual void SelectAll(); virtual void UnSelectAll(); virtual void InvertSelection(); virtual void RemoveAll(); virtual void RemoveItem(TGLVEntry *item); virtual void RemoveItemWithData(void *userData); virtual void SetViewMode(EListViewMode ViewMode); virtual void SetColumns(Int_t *cpos, Int_t *jmode); virtual const TGLVEntry *GetNextSelected(void **current); virtual Int_t NumItems() const { return fTotal; } virtual Int_t NumSelected() const { return fSelected; } virtual TGDimension GetMaxItemSize() const; ClassDef(TGLVContainer,0) // Listview container }; class TGListView : public TGCanvas { friend class TGClient; protected: Int_t fColumns[7]; // column width Int_t fJmode[7]; // column text alignment EListViewMode fViewMode; // view mode if list view widget TGDimension fMaxSize; // maximum item size TGTextButton *fColHeader[7]; // column headers for in detailed mode static GContext_t fgDefaultGC; static FontStruct_t fgDefaultFontStruct; public: TGListView(const TGWindow *p, UInt_t w, UInt_t h, UInt_t options = kSunkenFrame | kDoubleBorder, ULong_t back = fgDefaultFrameBackground); virtual ~TGListView(); virtual void Layout(); virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2); virtual void SetContainer(TGFrame *f); virtual void SetHeader(const char *s, Int_t mode, Int_t idx); virtual void SetViewMode(EListViewMode ViewMode); ClassDef(TGListView,0) // List view widget (iconbox, small icons or tabular view) }; #endif