#ifndef ROOT_TGListBox
#define ROOT_TGListBox
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGCanvas
#include "TGCanvas.h"
#endif
#ifndef ROOT_TGScrollBar
#include "TGScrollBar.h"
#endif
#ifndef ROOT_TList
#include "TList.h"
#endif
class TGListBox;
class TGLBEntry : public TGFrame {
protected:
Int_t fEntryId;
Pixel_t fBkcolor;
Bool_t fActive;
virtual void DoRedraw() { }
public:
TGLBEntry(const TGWindow *p = 0, Int_t id = -1, UInt_t options = kHorizontalFrame,
Pixel_t back = GetWhitePixel());
virtual void Activate(Bool_t a);
virtual void Toggle();
virtual void Update(TGLBEntry *) { }
Int_t EntryId() const { return fEntryId; }
Bool_t IsActive() const { return fActive; }
virtual void SetBackgroundColor(Pixel_t col) { TGFrame::SetBackgroundColor(col); fBkcolor = col; }
ClassDef(TGLBEntry,0)
};
class TGTextLBEntry : public TGLBEntry {
protected:
TGString *fText;
UInt_t fTWidth;
UInt_t fTHeight;
Bool_t fTextChanged;
GContext_t fNormGC;
FontStruct_t fFontStruct;
virtual void DoRedraw();
static const TGFont *fgDefaultFont;
static TGGC *fgDefaultGC;
private:
TGTextLBEntry(const TGTextLBEntry &);
TGTextLBEntry &operator=(const TGTextLBEntry &);
public:
static FontStruct_t GetDefaultFontStruct();
static const TGGC &GetDefaultGC();
TGTextLBEntry(const TGWindow *p = 0, TGString *s = 0, Int_t id = -1,
GContext_t norm = GetDefaultGC()(),
FontStruct_t font = GetDefaultFontStruct(),
UInt_t options = kHorizontalFrame,
Pixel_t back = GetWhitePixel());
virtual ~TGTextLBEntry();
virtual TGDimension GetDefaultSize() const { return TGDimension(fTWidth, fTHeight+1); }
const TGString *GetText() const { return fText; }
void SetText(TGString *new_text);
virtual const char *GetTitle() const { return fText->Data(); }
virtual void SetTitle(const char *text) { *fText = text; }
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y);
virtual void Update(TGLBEntry *e)
{ SetText(new TGString(((TGTextLBEntry *)e)->GetText())); }
GContext_t GetNormGC() const { return fNormGC; }
FontStruct_t GetFontStruct() const { return fFontStruct; }
virtual void SavePrimitive(ostream &out, Option_t * = "");
ClassDef(TGTextLBEntry,0)
};
class TGLineLBEntry : public TGTextLBEntry {
private:
TGLineLBEntry(const TGLineLBEntry&);
TGLineLBEntry operator=(const TGLineLBEntry&);
protected:
UInt_t fLineWidth;
Style_t fLineStyle;
UInt_t fLineLength;
TGGC *fLineGC;
virtual void DoRedraw();
public:
TGLineLBEntry(const TGWindow *p = 0, Int_t id = -1, const char *str = 0,
UInt_t w = 0, Style_t s = 0,
UInt_t options = kHorizontalFrame,
Pixel_t back = GetWhitePixel());
virtual ~TGLineLBEntry();
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fTWidth, fTHeight+1); }
virtual Int_t GetLineWidth() const { return fLineWidth; }
virtual void SetLineWidth(Int_t width);
Style_t GetLineStyle() const { return fLineStyle; }
virtual void SetLineStyle(Style_t style);
TGGC *GetLineGC() const { return fLineGC; }
virtual void Update(TGLBEntry *e);
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y);
ClassDef(TGLineLBEntry, 0)
};
class TGIconLBEntry : public TGTextLBEntry {
private:
TGIconLBEntry(const TGIconLBEntry&);
TGIconLBEntry operator=(const TGIconLBEntry&);
protected:
const TGPicture *fPicture;
virtual void DoRedraw();
public:
TGIconLBEntry(const TGWindow *p = 0, Int_t id = -1, const char *str = 0,
const TGPicture *pic = 0,
UInt_t w = 0, Style_t s = 0,
UInt_t options = kHorizontalFrame,
Pixel_t back = GetWhitePixel());
virtual ~TGIconLBEntry();
virtual TGDimension GetDefaultSize() const
{ return TGDimension(fTWidth, fTHeight+1); }
const TGPicture *GetPicture() const { return fPicture; }
virtual void SetPicture(const TGPicture *pic = 0);
virtual void Update(TGLBEntry *e);
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y);
ClassDef(TGIconLBEntry, 0)
};
class TGLBContainer : public TGContainer {
friend class TGListBox;
private:
TGLBContainer(const TGLBContainer&);
TGLBContainer operator=(const TGLBContainer&);
protected:
TGLBEntry *fLastActive;
TGListBox *fListBox;
Bool_t fMultiSelect;
Int_t fChangeStatus;
virtual void OnAutoScroll();
virtual void DoRedraw();
public:
TGLBContainer(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
UInt_t options = kSunkenFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGLBContainer();
virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints);
virtual void AddEntrySort(TGLBEntry *lbe, TGLayoutHints *lhints);
virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID);
virtual void RemoveEntry(Int_t id);
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID);
virtual void RemoveAll();
virtual void Associate(const TGWindow *w) { fMsgWindow = w; }
virtual void SetListBox(TGListBox *lb) { fListBox = lb; }
TGListBox *GetListBox() const { return fListBox; }
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
virtual Int_t GetSelected() const;
virtual Bool_t GetSelection(Int_t id);
virtual Int_t GetPos(Int_t id);
TGLBEntry *GetSelectedEntry() const { return fLastActive; }
virtual void GetSelectedEntries(TList *selected);
virtual TGLBEntry *Select(Int_t id, Bool_t sel);
virtual TGLBEntry *Select(Int_t id);
virtual TGVScrollBar *GetVScrollbar() const;
virtual void SetVsbPosition(Int_t newPos);
virtual void Layout();
virtual UInt_t GetDefaultWidth() const { return fWidth; }
virtual void SetMultipleSelections(Bool_t multi);
virtual Bool_t GetMultipleSelections() const { return fMultiSelect; }
ClassDef(TGLBContainer,0)
};
class TGListBox : public TGCompositeFrame, public TGWidget {
private:
TGListBox(const TGListBox&);
TGListBox operator=(const TGListBox&);
protected:
UInt_t fItemVsize;
Bool_t fIntegralHeight;
TGLBContainer *fLbc;
TGViewPort *fVport;
TGVScrollBar *fVScrollbar;
void SetContainer(TGFrame *f) { fVport->SetContainer(f); }
virtual void InitListBox();
public:
TGListBox(const TGWindow *p = 0, Int_t id = -1,
UInt_t options = kSunkenFrame | kDoubleBorder,
Pixel_t back = GetWhitePixel());
virtual ~TGListBox();
virtual void AddEntry(TGString *s, Int_t id);
virtual void AddEntry(const char *s, Int_t id);
virtual void AddEntry(TGLBEntry *lbe, TGLayoutHints *lhints);
virtual void AddEntrySort(TGString *s, Int_t id);
virtual void AddEntrySort(const char *s, Int_t id);
virtual void AddEntrySort(TGLBEntry *lbe, TGLayoutHints *lhints);
virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID);
virtual void InsertEntry(const char *s , Int_t id, Int_t afterID);
virtual void InsertEntry(TGLBEntry *lbe, TGLayoutHints *lhints, Int_t afterID);
virtual void NewEntry(const char *s = "Entry");
virtual void RemoveEntry(Int_t id = -1);
virtual void RemoveAll();
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID);
virtual void ChangeBackground(Pixel_t back);
virtual void SetTopEntry(Int_t id = -1);
virtual void SetMultipleSelections(Bool_t multi = kTRUE)
{ fLbc->SetMultipleSelections(multi); }
virtual Bool_t GetMultipleSelections() const
{ return fLbc->GetMultipleSelections(); }
virtual Int_t GetNumberOfEntries() const
{ return fLbc->GetList()->GetSize(); }
virtual TGLBEntry *GetEntry(Int_t id) const;
virtual TGLBEntry *FindEntry(const char *s) const;
virtual TGFrame *GetContainer() const { return fVport->GetContainer(); }
virtual TGViewPort *GetViewPort() const { return fVport; }
virtual TGScrollBar *GetScrollBar() const { return fVScrollbar; }
virtual TGVScrollBar *GetVScrollbar() const { return fVScrollbar; }
virtual void DrawBorder();
virtual void Resize(UInt_t w, UInt_t h);
virtual void Resize(TGDimension size) { Resize(size.fWidth, size.fHeight); }
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h);
virtual void Layout();
virtual void SetLayoutManager(TGLayoutManager*) { }
virtual void SortByName(Bool_t ascend = kTRUE);
virtual void IntegralHeight(Bool_t mode) { fIntegralHeight = mode; }
virtual TGDimension GetDefaultSize() const;
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
virtual TGLBEntry *Select(Int_t id, Bool_t sel = kTRUE)
{ return fLbc->Select(id, sel); }
virtual Int_t GetSelected() const;
virtual Bool_t GetSelection(Int_t id) { return fLbc->GetSelection(id); }
virtual TGLBEntry *GetSelectedEntry() const { return fLbc->GetSelectedEntry(); }
virtual void GetSelectedEntries(TList *selected);
UInt_t GetItemVsize() const { return fItemVsize; }
virtual void SavePrimitive(ostream &out, Option_t *option = "");
virtual void Selected(Int_t widgetId, Int_t id);
virtual void Selected(Int_t id) { Emit("Selected(Int_t)", id); }
virtual void Selected(const char *txt) { Emit("Selected(char*)", txt); }
virtual void SelectionChanged() { Emit("SelectionChanged()"); }
ClassDef(TGListBox,0)
};
#endif