33#include "RConfigure.h"
63 Error(
"TGTreeLBEntry",
"icon not found for entry %s",
text->GetString());
76 int max_ascent, max_descent;
120 lx =
x + (
int)(
fPic->GetWidth() + 4);
135 int max_ascent, max_descent;
205 fClient->GetPicture(
"folder_t.xpm"), 0),
213 const char *homeDir =
gSystem->HomeDirectory();
217 const char *curdrive =
"";
218 if (volumes && curvol) {
224 fLbc.emplace_back(infos.
Data(),
Form(
"%s\\", curdrive),
"hdisk_t.xpm", 0);
226 fLbc.back().fPixmap =
"fdisk_t.xpm";
228 fLbc.back().fPixmap =
"hdisk_t.xpm";
230 fLbc.back().fPixmap =
"cdrom_t.xpm";
232 fLbc.back().fPixmap =
"netdisk_t.xpm";
234 fLbc.emplace_back(
"Root",
"/",
"hdisk_t.xpm", 1);
237 fLbc.emplace_back(
"Root",
"/",
"hdisk_t.xpm", 1);
238 fLbc.emplace_back(
"Floppy",
"/floppy",
"fdisk_t.xpm", 1);
239 fLbc.emplace_back(
"CD-ROM",
"/cdrom",
"cdrom_t.xpm", 1);
241 fLbc.emplace_back(
"Home",
"$HOME",
"home_t.xpm", 1);
242 fLbc.emplace_back(
"RootSys",
gROOT->GetRootSys(),
"root_t.xpm", 1);
244 if (volumes && curvol) {
247 while ((drive = (
TNamed *)next())) {
248 if (!strcmp(drive->
GetName(), curdrive))
255 fLbc.back().fPixmap =
"fdisk_t.xpm";
257 fLbc.back().fPixmap =
"hdisk_t.xpm";
259 fLbc.back().fPixmap =
"cdrom_t.xpm";
261 fLbc.back().fPixmap =
"netdisk_t.xpm";
269 for (
auto &entry :
fLbc) {
270 entry.fId = ++cnt * 1000;
271 if (entry.fPath.find(
"$HOME") == 0) {
273 std::string newpath = homeDir;
274 newpath.append(entry.fPath.substr(5));
275 entry.fPath = newpath;
286 for (
auto &entry :
fLbc) {
288 int indent = 4 + (entry.fIndent * 10);
289 auto pic =
fClient->GetPicture(entry.fPixmap.c_str());
290 if (!pic)
Error(
"TGFSComboBox",
"pixmap not found: %s", entry.fPixmap.c_str());
292 new TGString(entry.fName.c_str()), pic, entry.fId,
305 char dirname[1024], mpath[1024];
306 const char *tailpath = 0;
307 int indent_lvl = 0, afterID = -1, sel = -1;
311 for (
int i = 0; i < (
int)
fLbc.size() - 1; ++i)
316 for (
auto &entry :
fLbc) {
318 int slen = entry.fPath.length();
319 if (strncmp(path, entry.fPath.c_str(), slen) == 0) {
321 sel = afterID = entry.fId;
322 indent_lvl = entry.fIndent + 1;
323 if ((len > 0) && ((path[slen] ==
'\\') || (path[slen] ==
'/') ||
325 tailpath = path + slen;
326 strlcpy(mpath, entry.fPath.c_str(), 1024);
333 if (tailpath && *tailpath) {
334 if ((*tailpath ==
'/') || (*tailpath ==
'\\')) ++tailpath;
338 const char *semi = strchr(tailpath,
'/');
339 if (semi == 0) semi = strchr(tailpath,
'\\');
341 strlcpy(dirname, tailpath, 1024);
342 picname =
"ofolder_t.xpm";
344 strlcpy(dirname, tailpath, (semi-tailpath)+1);
345 picname =
"folder_t.xpm";
347 if ((mpath[strlen(mpath)-1] !=
'/') &&
348 (mpath[strlen(mpath)-1] !=
'\\')) {
349 strlcat(mpath,
"/", 1024-strlen(mpath));
351 strlcat(mpath, dirname, 1024-strlen(mpath));
352 int indent = 4 + (indent_lvl * 10);
354 if (!pic)
Error(
"Update",
"pixmap not found: %s", picname);
356 new TGString(dirname), pic, afterID+1,
363 if (semi == 0)
break;
378 out <<
"\n // file system combo box\n";
379 out <<
" TGFSComboBox *" <<
GetName() <<
" = new TGFSComboBox(" <<
fParent->GetName()
380 <<
"," <<
fWidgetId << extra_args <<
");\n";
381 if (option && strstr(option,
"keep_names"))
382 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");\n";
const Mask_t kButtonPressMask
const Mask_t kPointerMotionMask
Handle_t GContext_t
Graphics context handle.
const Mask_t kButtonReleaseMask
Handle_t FontStruct_t
Pointer to font structure.
ULongptr_t Handle_t
Generic resource handle.
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
const char Option_t
Option string (const char).
static void indent(ostringstream &buf, int indent_level)
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
virtual Int_t GetSelected() const
TGComboBox(const TGComboBox &)=delete
virtual void AddEntry(TGString *s, Int_t id)
TGListBox * fListBox
the listbox with text items
virtual void SetTopEntry(TGLBEntry *e, TGLayoutHints *lh)
Set a new combo box value (normally update of text string in fSelEntry is done via fSelEntry::Update(...
virtual void RemoveEntries(Int_t from_ID, Int_t to_ID)
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
virtual void InsertEntry(TGString *s, Int_t id, Int_t afterID)
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a file system combo box as a C++ statement(s) on output stream out.
TGFSComboBox(const TGWindow *p=nullptr, Int_t id=-1, UInt_t options=kHorizontalFrame|kSunkenFrame|kDoubleBorder, Pixel_t back=GetWhitePixel())
Create a file system combobox showing system directories.
std::vector< Lbc_t > fLbc
! list of default entries
virtual void Update(const char *path)
Update file system combo box.
Encapsulate fonts used in the GUI system.
UInt_t fHeight
frame height
static Pixel_t fgDefaultSelectedBackground
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
static Pixel_t fgWhitePixel
static Pixel_t fgBlackPixel
Encapsulate a graphics context used in the low level graphics.
TGLBEntry(const TGWindow *p=nullptr, Int_t id=-1, UInt_t options=kHorizontalFrame, Pixel_t back=GetWhitePixel())
Base class entry constructor.
This class describes layout hints used by the layout classes.
TGClient * fClient
Connection to display server.
Handle_t fId
X11/Win32 Window identifier.
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
static const TGFont * fgDefaultFont
static TGGC * fgDefaultGC
UInt_t fTWidth
width of entry text
void Activate(Bool_t a) override
Make entry active (highlight picture).
const TGPicture * GetPicture() const
const TGPicture * fPic
entry picture
Bool_t fActive
true if active
TGDimension GetDefaultSize() const override
Return default size of tree listbox entry.
FontStruct_t fFontStruct
font
UInt_t fTHeight
height of entry text
TGString * fPath
entry path
static const TGGC & GetDefaultGC()
Return default graphics context.
const TGString * GetText() const
GContext_t fNormGC
entry drawing context
~TGTreeLBEntry() override
Delete tree listbox entry.
TGSelectedPicture * fSelPic
selected picture
TGString * fText
entry description
void Update(TGLBEntry *e) override
Update text and picture of a listbox entry.
TGTreeLBEntry(const TGWindow *p=nullptr, TGString *text=nullptr, const TGPicture *pic=nullptr, Int_t id=-1, TGString *path=nullptr, GContext_t norm=GetDefaultGC()(), FontStruct_t font=GetDefaultFontStruct(), UInt_t options=kHorizontalFrame, Pixel_t back=GetWhitePixel())
Create a tree (i.e.
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
void DrawCopy(Handle_t id, Int_t x, Int_t y) override
Redraw the tree listbox entry on pixmap/window.
void DoRedraw() override
Redraw the tree listbox entry.
ROOT GUI Window base class.
const TGWindow * fParent
Parent window.
virtual void SetWindowName(const char *name=nullptr)
Set window name.
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const