Skip to content
Snippets Groups Projects
Commit e57af6dd authored by Fons Rademakers's avatar Fons Rademakers
Browse files

From Bertrand:

support listbox entries with icons in addition to text.


git-svn-id: http://root.cern.ch/svn/root/trunk@13156 27541ba8-7e3a-0410-8455-c3a389f83636
parent 96864b0b
No related branches found
No related tags found
No related merge requests found
/* @(#)root/gui:$Name: $:$Id: LinkDef2.h,v 1.16 2004/02/19 15:36:45 brun Exp $ */ /* @(#)root/gui:$Name: $:$Id: LinkDef2.h,v 1.17 2004/10/15 17:07:27 rdm Exp $ */
/************************************************************************* /*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#pragma link C++ class TGLBEntry; #pragma link C++ class TGLBEntry;
#pragma link C++ class TGTextLBEntry; #pragma link C++ class TGTextLBEntry;
#pragma link C++ class TGLineLBEntry; #pragma link C++ class TGLineLBEntry;
#pragma link C++ class TGIconLBEntry;
#pragma link C++ class TGLBContainer; #pragma link C++ class TGLBContainer;
#pragma link C++ class TGListBox; #pragma link C++ class TGListBox;
#pragma link C++ class TGComboBoxPopup; #pragma link C++ class TGComboBoxPopup;
......
// @(#)root/gui:$Name: $:$Id: TGListBox.h,v 1.23 2004/12/10 17:35:58 brun Exp $ // @(#)root/gui:$Name: $:$Id: TGListBox.h,v 1.24 2005/07/05 12:36:06 brun Exp $
// Author: Fons Rademakers 12/01/98 // Author: Fons Rademakers 12/01/98
/************************************************************************* /*************************************************************************
...@@ -168,6 +168,40 @@ public: ...@@ -168,6 +168,40 @@ public:
ClassDef(TGLineLBEntry, 0) // Line width listbox entry ClassDef(TGLineLBEntry, 0) // Line width listbox entry
}; };
//////////////////////////////////////////////////////////////////////////
// //
// TGIconLBEntry //
// //
// Icon + text listbox entry. //
// //
//////////////////////////////////////////////////////////////////////////
class TGIconLBEntry : public TGTextLBEntry {
protected:
const TGPicture *fPicture; // icon
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) // Icon + text listbox entry
};
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// // // //
// TGLBContainer // // TGLBContainer //
......
// @(#)root/gui:$Name: $:$Id: TGListBox.cxx,v 1.45 2005/07/05 12:36:06 brun Exp $ // @(#)root/gui:$Name: $:$Id: TGListBox.cxx,v 1.46 2005/08/23 17:00:41 brun Exp $
// Author: Fons Rademakers 12/01/98 // Author: Fons Rademakers 12/01/98
/************************************************************************* /*************************************************************************
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
// // // //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
#include "TGPicture.h"
#include "TGListBox.h" #include "TGListBox.h"
#include "TGScrollBar.h" #include "TGScrollBar.h"
#include "TGResourcePool.h" #include "TGResourcePool.h"
...@@ -342,6 +343,91 @@ void TGLineLBEntry::DoRedraw() ...@@ -342,6 +343,91 @@ void TGLineLBEntry::DoRedraw()
DrawCopy(fId, 0, 0); DrawCopy(fId, 0, 0);
} }
//////////////////////////////////////////////////////////////////////////
// //
// TGIconLBEntry //
// //
// Icon + text listbox entry. //
// //
//////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
TGIconLBEntry::TGIconLBEntry(const TGWindow *p, Int_t id, const char *str,
const TGPicture *pic,
UInt_t w, Style_t style, UInt_t options, ULong_t back) :
TGTextLBEntry(p, new TGString(str), id, GetDefaultGC()(),
GetDefaultFontStruct(), options, back)
{
// Create the Icon & text listbox entry
int max_ascent, max_descent;
fPicture = pic;
if (fPicture) {
fTWidth += fPicture->GetWidth() + 4;
((TGPicture *)pic)->AddReference();
}
else
fTWidth += 20;
gVirtualX->GetFontProperties(GetDefaultFontStruct(),
max_ascent, max_descent);
fTHeight = max_ascent + max_descent;
if (fPicture->GetHeight() > fTHeight)
fTHeight = fPicture->GetHeight();
Resize(fTWidth, fTHeight + 1);
SetWindowName();
}
//______________________________________________________________________________
TGIconLBEntry::~TGIconLBEntry()
{
// Delete icon & text listbox entry.
fClient->FreePicture(fPicture);
}
//______________________________________________________________________________
void TGIconLBEntry::Update(TGLBEntry *e)
{
// Update icon & text listbox entry.
TGTextLBEntry::Update(e);
}
//______________________________________________________________________________
void TGIconLBEntry::DrawCopy(Handle_t id, Int_t x, Int_t y)
{
// draw copy on window/pixmap
Int_t off_x = 0;
if (fPicture) {
fPicture->Draw(id, fNormGC, x + 2, y);
off_x = fPicture->GetWidth() + 4;
}
TGTextLBEntry::DrawCopy(id, x + off_x, y);
}
//______________________________________________________________________________
void TGIconLBEntry::DoRedraw()
{
// Redraw line style listbox entry.
DrawCopy(fId, 0, 0);
}
//___________________________________________________________________________
void TGIconLBEntry::SetPicture(const TGPicture *pic)
{
// Change list tree item icons.
fClient->FreePicture(fPicture);
((TGPicture *)pic)->AddReference();
fPicture = pic;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// // // //
// TGLBContainer // // TGLBContainer //
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment