32#include "RConfigure.h"
63 Error(
"TGTreeLBEntry",
"icon not found for entry %s",
text->GetString());
76 int max_ascent, max_descent;
135 int max_ascent, max_descent;
222 const char *curdrive =
"";
223 if (volumes && curvol) {
229 fLbc.emplace_back(infos.
Data(),
Form(
"%s\\", curdrive),
"hdisk_t.xpm", 0);
231 fLbc.back().fPixmap =
"fdisk_t.xpm";
233 fLbc.back().fPixmap =
"hdisk_t.xpm";
235 fLbc.back().fPixmap =
"cdrom_t.xpm";
237 fLbc.back().fPixmap =
"netdisk_t.xpm";
239 fLbc.emplace_back(
"Root",
"/",
"hdisk_t.xpm", 1);
242 fLbc.emplace_back(
"Root",
"/",
"hdisk_t.xpm", 1);
243 fLbc.emplace_back(
"Floppy",
"/floppy",
"fdisk_t.xpm", 1);
244 fLbc.emplace_back(
"CD-ROM",
"/cdrom",
"cdrom_t.xpm", 1);
246 fLbc.emplace_back(
"Home",
"$HOME",
"home_t.xpm", 1);
248 fLbc.emplace_back(
"RootSys",
"$ROOTSYS",
"root_t.xpm", 1);
250 fLbc.emplace_back(ROOTPREFIX, ROOTPREFIX,
"root_t.xpm", 1);
253 if (volumes && curvol) {
256 while ((drive = (
TNamed *)next())) {
257 if (!strcmp(drive->
GetName(), curdrive))
264 fLbc.back().fPixmap =
"fdisk_t.xpm";
266 fLbc.back().fPixmap =
"hdisk_t.xpm";
268 fLbc.back().fPixmap =
"cdrom_t.xpm";
270 fLbc.back().fPixmap =
"netdisk_t.xpm";
278 for (
auto &entry :
fLbc) {
279 entry.fId = ++cnt * 1000;
280 if (entry.fPath.find(
"$HOME") == 0) {
282 std::string newpath = homeDir;
283 newpath.append(entry.fPath.substr(5));
284 entry.fPath = newpath;
296 if (entry.fPath.find(
"$ROOTSYS") == 0) {
300 std::string newpath = rootSys;
301 newpath.append(entry.fPath.substr(plen));
302 entry.fPath = newpath;
314 for (
auto &entry :
fLbc) {
316 int indent = 4 + (entry.fIndent * 10);
318 if (!pic)
Error(
"TGFSComboBox",
"pixmap not found: %s", entry.fPixmap.c_str());
320 new TGString(entry.fName.c_str()), pic, entry.fId,
333 char dirname[1024], mpath[1024];
334 const char *tailpath = 0;
335 int indent_lvl = 0, afterID = -1, sel = -1;
339 for (
int i = 0; i < (
int)
fLbc.size() - 1; ++i)
344 for (
auto &entry :
fLbc) {
346 int slen = entry.fPath.length();
347 if (strncmp(path, entry.fPath.c_str(), slen) == 0) {
349 sel = afterID = entry.fId;
350 indent_lvl = entry.fIndent + 1;
351 if ((len > 0) && ((path[slen] ==
'\\') || (path[slen] ==
'/') ||
353 tailpath = path + slen;
354 strlcpy(mpath, entry.fPath.c_str(), 1024);
361 if (tailpath && *tailpath) {
362 if ((*tailpath ==
'/') || (*tailpath ==
'\\')) ++tailpath;
366 const char *semi = strchr(tailpath,
'/');
367 if (semi == 0) semi = strchr(tailpath,
'\\');
369 strlcpy(dirname, tailpath, 1024);
370 picname =
"ofolder_t.xpm";
372 strlcpy(dirname, tailpath, (semi-tailpath)+1);
373 picname =
"folder_t.xpm";
375 if ((mpath[strlen(mpath)-1] !=
'/') &&
376 (mpath[strlen(mpath)-1] !=
'\\')) {
377 strlcat(mpath,
"/", 1024-strlen(mpath));
379 strlcat(mpath, dirname, 1024-strlen(mpath));
380 int indent = 4 + (indent_lvl * 10);
382 if (!pic)
Error(
"Update",
"pixmap not found: %s", picname);
384 new TGString(dirname), pic, afterID+1,
391 if (semi == 0)
break;
405 out << std::endl <<
" // file system combo box" << std::endl;
406 out <<
" TGFSComboBox *";
411 out <<
");" << std::endl;
418 if (option && strstr(option,
"keep_names"))
419 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
ULong_t Handle_t
Generic resource handle.
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.
static void indent(ostringstream &buf, int indent_level)
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
const TGResourcePool * GetResourcePool() const
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
virtual Int_t GetSelected() const
virtual void AddEntry(TGString *s, Int_t id)
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)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a file system combo box as a C++ statement(s) on output stream out.
TGFSComboBox(const TGWindow *p=0, 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.
FontStruct_t GetFontStruct() const
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
static Pixel_t GetWhitePixel()
Get white pixel value.
static Pixel_t fgDefaultSelectedBackground
virtual UInt_t GetOptions() const
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
static Pixel_t fgWhitePixel
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
static Pixel_t fgBlackPixel
virtual TGFrame * GetContainer() const
void Draw(Option_t *="")
Default Draw method for all objects.
Pixel_t GetSelectedFgndColor() const
const char * GetString() const
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
virtual void Activate(Bool_t a)
Make entry active (highlight picture).
static const TGFont * fgDefaultFont
virtual ~TGTreeLBEntry()
Delete tree listbox entry.
static TGGC * fgDefaultGC
virtual TGDimension GetDefaultSize() const
Return default size of tree listbox entry.
virtual void DoRedraw()
Redraw the tree listbox entry.
const TGPicture * GetPicture() const
TGTreeLBEntry(const TGWindow *p=0, TGString *text=0, const TGPicture *pic=0, Int_t id=-1, TGString *path=0, GContext_t norm=GetDefaultGC()(), FontStruct_t font=GetDefaultFontStruct(), UInt_t options=kHorizontalFrame, Pixel_t back=GetWhitePixel())
Create a tree (i.e.
virtual void Update(TGLBEntry *e)
Update text and picture of a listbox entry.
static const TGGC & GetDefaultGC()
Return default graphics context.
const TGString * GetText() const
virtual void DrawCopy(Handle_t id, Int_t x, Int_t y)
Redraw the tree listbox entry on pixmap/window.
TGSelectedPicture * fSelPic
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
virtual void SetWindowName(const char *name=0)
Set window name.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
virtual TObject * At(Int_t idx) const
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.
virtual const char * GetTitle() const
Returns title of object.
virtual const char * GetName() const
Returns name of object.
const char * Data() const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual const char * Getenv(const char *env)
Get environment variable.
virtual TList * GetVolumes(Option_t *) const
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
virtual const char * HomeDirectory(const char *userName=nullptr)
Return the user's home directory.
Short_t Max(Short_t a, Short_t b)