33#include "RConfigure.h"
64 Error(
"TGTreeLBEntry",
"icon not found for entry %s",
text->GetString());
77 int max_ascent, max_descent;
136 int max_ascent, max_descent;
223 const char *curdrive =
"";
224 if (volumes && curvol) {
230 fLbc.emplace_back(infos.
Data(),
Form(
"%s\\", curdrive),
"hdisk_t.xpm", 0);
232 fLbc.back().fPixmap =
"fdisk_t.xpm";
234 fLbc.back().fPixmap =
"hdisk_t.xpm";
236 fLbc.back().fPixmap =
"cdrom_t.xpm";
238 fLbc.back().fPixmap =
"netdisk_t.xpm";
240 fLbc.emplace_back(
"Root",
"/",
"hdisk_t.xpm", 1);
243 fLbc.emplace_back(
"Root",
"/",
"hdisk_t.xpm", 1);
244 fLbc.emplace_back(
"Floppy",
"/floppy",
"fdisk_t.xpm", 1);
245 fLbc.emplace_back(
"CD-ROM",
"/cdrom",
"cdrom_t.xpm", 1);
247 fLbc.emplace_back(
"Home",
"$HOME",
"home_t.xpm", 1);
249 fLbc.emplace_back(
"RootSys",
"$ROOTSYS",
"root_t.xpm", 1);
251 fLbc.emplace_back(ROOTPREFIX, ROOTPREFIX,
"root_t.xpm", 1);
254 if (volumes && curvol) {
257 while ((drive = (
TNamed *)next())) {
258 if (!strcmp(drive->
GetName(), curdrive))
265 fLbc.back().fPixmap =
"fdisk_t.xpm";
267 fLbc.back().fPixmap =
"hdisk_t.xpm";
269 fLbc.back().fPixmap =
"cdrom_t.xpm";
271 fLbc.back().fPixmap =
"netdisk_t.xpm";
279 for (
auto &entry :
fLbc) {
280 entry.fId = ++cnt * 1000;
281 if (entry.fPath.find(
"$HOME") == 0) {
283 std::string newpath = homeDir;
284 newpath.append(entry.fPath.substr(5));
285 entry.fPath = newpath;
297 if (entry.fPath.find(
"$ROOTSYS") == 0) {
301 std::string newpath = rootSys;
302 newpath.append(entry.fPath.substr(plen));
303 entry.fPath = newpath;
315 for (
auto &entry :
fLbc) {
317 int indent = 4 + (entry.fIndent * 10);
319 if (!pic)
Error(
"TGFSComboBox",
"pixmap not found: %s", entry.fPixmap.c_str());
321 new TGString(entry.fName.c_str()), pic, entry.fId,
334 char dirname[1024], mpath[1024];
335 const char *tailpath = 0;
336 int indent_lvl = 0, afterID = -1, sel = -1;
340 for (
int i = 0; i < (
int)
fLbc.size() - 1; ++i)
345 for (
auto &entry :
fLbc) {
347 int slen = entry.fPath.length();
348 if (strncmp(path, entry.fPath.c_str(), slen) == 0) {
350 sel = afterID = entry.fId;
351 indent_lvl = entry.fIndent + 1;
352 if ((len > 0) && ((path[slen] ==
'\\') || (path[slen] ==
'/') ||
354 tailpath = path + slen;
355 strlcpy(mpath, entry.fPath.c_str(), 1024);
362 if (tailpath && *tailpath) {
363 if ((*tailpath ==
'/') || (*tailpath ==
'\\')) ++tailpath;
367 const char *semi = strchr(tailpath,
'/');
368 if (semi == 0) semi = strchr(tailpath,
'\\');
370 strlcpy(dirname, tailpath, 1024);
371 picname =
"ofolder_t.xpm";
373 strlcpy(dirname, tailpath, (semi-tailpath)+1);
374 picname =
"folder_t.xpm";
376 if ((mpath[strlen(mpath)-1] !=
'/') &&
377 (mpath[strlen(mpath)-1] !=
'\\')) {
378 strlcat(mpath,
"/", 1024-strlen(mpath));
380 strlcat(mpath, dirname, 1024-strlen(mpath));
381 int indent = 4 + (indent_lvl * 10);
383 if (!pic)
Error(
"Update",
"pixmap not found: %s", picname);
385 new TGString(dirname), pic, afterID+1,
392 if (semi == 0)
break;
406 out << std::endl <<
" // file system combo box" << std::endl;
407 out <<
" TGFSComboBox *";
412 out <<
");" << std::endl;
419 if (option && strstr(option,
"keep_names"))
420 out <<
" " <<
GetName() <<
"->SetName(\"" <<
GetName() <<
"\");" << std::endl;
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.
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.
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
virtual Int_t GetSelected() const
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)
This is a combo box that is used in the File Selection dialog box.
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.
Encapsulate fonts used in the GUI system.
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.
UInt_t fHeight
frame height
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().
Pixel_t fBackground
frame background color
static Pixel_t fgBlackPixel
Encapsulate a graphics context used in the low level graphics.
This class describes layout hints used by the layout classes.
virtual TGFrame * GetContainer() const
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.
void Draw(Option_t *="")
Default Draw method for all objects.
Pixel_t GetSelectedFgndColor() const
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
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.
UInt_t fTWidth
width of entry text
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.
const TGPicture * fPic
entry picture
Bool_t fActive
true if active
FontStruct_t fFontStruct
font
UInt_t fTHeight
height of entry text
TGString * fPath
entry path
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.
GContext_t fNormGC
entry drawing context
TGSelectedPicture * fSelPic
selected picture
TGString * fText
entry description
static FontStruct_t GetDefaultFontStruct()
Return default font structure.
ROOT GUI Window base class.
virtual void SetWindowName(const char *name=0)
Set window name.
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
const TGWindow * fParent
Parent window.
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)