Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGFSContainer.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 19/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGFileIcon
25 \ingroup guiwidgets
26
27Utility class used by the file selection dialog (TGFSDialog).
28
29*/
30
31/** \class TGFileEntry
32 \ingroup guiwidgets
33
34Utility class used by the file selection dialog (TGFSDialog).
35
36*/
37
38/** \class TGFSContainer
39 \ingroup guiwidgets
40
41Utility class used by the file selection dialog (TGFSDialog).
42
43*/
44
45#include "TGFSContainer.h"
46#include "TGIcon.h"
47#include "TGMsgBox.h"
48#include "TGMimeTypes.h"
49#include "TRegexp.h"
50#include "TList.h"
51#include "TSystem.h"
52#include "TVirtualX.h"
53#include "TGDNDManager.h"
54#include "TRemoteObject.h"
55#include "TBufferFile.h"
56#include "TImage.h"
57#include "snprintf.h"
58
59#include <ctime>
60#include <cstdlib>
61#include <iostream>
62
63
64class TViewUpdateTimer : public TTimer {
65
66private:
68
69public:
71 Bool_t Notify() override;
72};
73
74
75
76class TGFileIcon : public TGIcon {
77
78protected:
79 const TGPicture *fLpic; // icon picture
80
81 void DoRedraw() override;
82
83public:
85 UInt_t options = kChildFrame, Pixel_t back = GetWhitePixel()) :
86 TGIcon(p, pic, 0, 0, options, back) { fLpic = lpic; }
87};
88
89
90
91////////////////////////////////////////////////////////////////////////////////
92
94public:
95 TGFileContainer *fContainer; // file container
96
97 Bool_t IsSortable() const override { return kTRUE; }
98 Int_t Compare(const TObject *obj) const override;
99};
100
101////////////////////////////////////////////////////////////////////////////////
102/// Sort frame elements in file selection list view container.
103
105{
107
109 TGFileItem *f2 = (TGFileItem *) ((TGFrameElement *) obj)->fFrame;
110
111 switch (fContainer->fSortType) {
112 default:
113 case kSortByName:
114 //--- this is not exactly what I want...
115 type1 = f1->GetType();
116 type2 = f2->GetType();
117
118 //--- use posix macros
119 if (R_ISDIR(type1)) type1 = 1;
120 else type1 = 6;
121
122 if (R_ISDIR(type2)) type2 = 1;
123 else type2 = 6;
124
125 if (type1 < type2) return -1;
126 if (type1 > type2) return 1;
127 return strcmp(f1->GetItemName()->GetString(),
128 f2->GetItemName()->GetString());
129
130 case kSortByOwner:
131 if (f1->GetUid() != f2->GetUid()) {
132 if (f1->GetUid() < f2->GetUid())
133 return -1;
134 else
135 return +1;
136 }
137
138 // else sort by name
139 type1 = f1->GetType();
140 type2 = f2->GetType();
141
142 //--- use posix macros
143 if (R_ISDIR(type1)) type1 = 1;
144 else type1 = 6;
145
146 if (R_ISDIR(type2)) type2 = 1;
147 else type2 = 6;
148
149 if (type1 < type2) return -1;
150 if (type1 > type2) return 1;
151 return strcmp(f1->GetItemName()->GetString(),
152 f2->GetItemName()->GetString());
153
154 case kSortByGroup:
155 if (f1->GetGid() != f2->GetGid()) {
156 if (f1->GetGid() < f2->GetGid())
157 return -1;
158 else
159 return +1;
160 }
161
162 // else sort by name
163 type1 = f1->GetType();
164 type2 = f2->GetType();
165
166 //--- use posix macros
167 if (R_ISDIR(type1)) type1 = 1;
168 else type1 = 6;
169
170 if (R_ISDIR(type2)) type2 = 1;
171 else type2 = 6;
172
173 if (type1 < type2) return -1;
174 if (type1 > type2) return 1;
175 return strcmp(f1->GetItemName()->GetString(),
176 f2->GetItemName()->GetString());
177
178 case kSortByType:
179 //--- this is not exactly what I want...
180
181 type1 = f1->GetType();
182 type2 = f2->GetType();
183
184 //--- use posix macros
185
186 if (R_ISDIR(type1)) type1 = 1;
187 else if (R_ISLNK(type1)) type1 = 2;
188 else if (R_ISSOCK(type1)) type1 = 3;
189 else if (R_ISFIFO(type1)) type1 = 4;
190 else if (R_ISREG(type1) && (type1 & kS_IXUSR)) type1 = 5;
191 else type1 = 6;
192
193 if (R_ISDIR(type2)) type2 = 1;
194 else if (R_ISLNK(type2)) type2 = 2;
195 else if (R_ISSOCK(type2)) type2 = 3;
196 else if (R_ISFIFO(type2)) type2 = 4;
197 else if (R_ISREG(type2) && (type2 & kS_IXUSR)) type2 = 5;
198 else type2 = 6;
199
200 if (type1 < type2) return -1;
201 if (type1 > type2) return 1;
202 return strcmp(f1->GetItemName()->GetString(),
203 f2->GetItemName()->GetString());
204
205 case kSortBySize:
206 if (f1->GetSize() < f2->GetSize()) return -1;
207 if (f1->GetSize() > f2->GetSize()) return 1;
208 return strcmp(f1->GetItemName()->GetString(),
209 f2->GetItemName()->GetString());
210
211 case kSortByDate:
212 time_t loctimeF1 = (time_t) f1->GetModTime();
213 // coverity[returned_null]
214 struct tm tmF1 = *localtime(&loctimeF1);
215
216 time_t loctimeF2 = (time_t) f2->GetModTime();
217 // coverity[returned_null]
218 struct tm tmF2 = *localtime(&loctimeF2);
219
220 if ( tmF1.tm_year != tmF2.tm_year )
221 return (tmF1.tm_year < tmF2.tm_year) ? +1 : -1;
222 else if ( tmF1.tm_mon != tmF2.tm_mon )
223 return (tmF1.tm_mon < tmF2.tm_mon) ? +1 : -1;
224 else if ( tmF1.tm_mday != tmF2.tm_mday )
225 return (tmF1.tm_mday < tmF2.tm_mday) ? +1 : -1;
226 else if ( tmF1.tm_hour != tmF2.tm_hour )
227 return (tmF1.tm_hour < tmF2.tm_hour) ? +1 : -1;
228 else if ( tmF1.tm_min != tmF2.tm_min )
229 return (tmF1.tm_min < tmF2.tm_min) ? +1 : -1;
230 else if ( tmF1.tm_sec != tmF2.tm_sec )
231 return (tmF1.tm_sec < tmF2.tm_sec) ? +1 : -1;
232 else
233 return 0;
234 }
235}
236
237
238////////////////////////////////////////////////////////////////////////////////
239/// Reset the timer.
240
242{
244 Reset();
245 return kFALSE;
246}
247
248
249////////////////////////////////////////////////////////////////////////////////
250/// Draw icon.
251
253{
255 if (fLpic) fLpic->Draw(fId, GetBckgndGC()(), 0, 0);
256}
257
258
259////////////////////////////////////////////////////////////////////////////////
260/// Create a list view item.
261
263 const TGPicture *bpic, const TGPicture *blpic,
264 const TGPicture *spic, const TGPicture *slpic,
266 Int_t gid, Long_t modtime, EListViewMode viewMode,
267 UInt_t options, Pixel_t back) :
268 TGLVEntry(p, bpic, spic, name, 0, viewMode, options, back)
269{
270 FileStat_t buf;
271
272 buf.fMode = type;
273 buf.fSize = size;
274 buf.fUid = uid;
275 buf.fGid = gid;
276 buf.fMtime = modtime;
277 buf.fIsLink = (blpic != 0); // FIXME: hack...
278
279 Init(blpic, slpic, buf, viewMode);
280}
281
282////////////////////////////////////////////////////////////////////////////////
283/// Create a list view item.
284
286 const TGPicture *bpic, const TGPicture *blpic,
287 const TGPicture *spic, const TGPicture *slpic,
289 UInt_t options, Pixel_t back) :
290 TGLVEntry(p, bpic, spic, name, 0, viewMode, options, back)
291{
292 Init(blpic, slpic, stat, viewMode);
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Common initializer for file list view item.
297
300{
301 char tmp[256];
302 Long64_t fsize, bsize;
303
304 fBuf = 0;
305 fDNDData.fData = 0;
308 fLcurrent =
309 fBlpic = blpic;
310 fSlpic = slpic;
311
314
315 fType = stat.fMode;
316 fSize = stat.fSize;
317 fUid = stat.fUid;
318 fGid = stat.fGid;
319 fModTime = stat.fMtime;
320 fIsLink = stat.fIsLink;
321
322 fSubnames = new TGString* [6];
323
324 // file type
325 snprintf(tmp, sizeof(tmp), "%c%c%c%c%c%c%c%c%c%c",
326 (fIsLink ?
327 'l' :
328 R_ISREG(fType) ?
329 '-' :
330 (R_ISDIR(fType) ?
331 'd' :
332 (R_ISCHR(fType) ?
333 'c' :
334 (R_ISBLK(fType) ?
335 'b' :
336 (R_ISFIFO(fType) ?
337 'p' :
338 (R_ISSOCK(fType) ?
339 's' : '?' )))))),
340 ((fType & kS_IRUSR) ? 'r' : '-'),
341 ((fType & kS_IWUSR) ? 'w' : '-'),
342 ((fType & kS_ISUID) ? 's' : ((fType & kS_IXUSR) ? 'x' : '-')),
343 ((fType & kS_IRGRP) ? 'r' : '-'),
344 ((fType & kS_IWGRP) ? 'w' : '-'),
345 ((fType & kS_ISGID) ? 's' : ((fType & kS_IXGRP) ? 'x' : '-')),
346 ((fType & kS_IROTH) ? 'r' : '-'),
347 ((fType & kS_IWOTH) ? 'w' : '-'),
348 ((fType & kS_ISVTX) ? 't' : ((fType & kS_IXOTH) ? 'x' : '-')));
349 fSubnames[0] = new TGString(tmp);
350
351 // file size
352 fsize = bsize = fSize;
353 if (fsize > 1024) {
354 fsize /= 1024;
355 if (fsize > 1024) {
356 // 3.7MB is more informative than just 3MB
357 snprintf(tmp, sizeof(tmp), "%lld.%lldM", fsize/1024, (fsize%1024)/103);
358 } else {
359 snprintf(tmp, sizeof(tmp), "%lld.%lldK", bsize/1024, (bsize%1024)/103);
360 }
361 } else {
362 snprintf(tmp, sizeof(tmp), "%lld", bsize);
363 }
364 fSubnames[1] = new TGString(tmp);
365
366 {
367 struct UserGroup_t *user_group;
368
370 if (user_group) {
371 fSubnames[2] = new TGString(user_group->fUser);
372 fSubnames[3] = new TGString(user_group->fGroup);
373 delete user_group;
374 } else {
375 fSubnames[2] = new TGString(TString::Format("%d", fUid));
376 fSubnames[3] = new TGString(TString::Format("%d", fGid));
377 }
378 }
379
380 struct tm *newtime;
381 time_t loctime = (time_t) fModTime;
383 if (newtime) {
384 snprintf(tmp, sizeof(tmp), "%d-%02d-%02d %02d:%02d", newtime->tm_year + 1900,
385 newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour,
386 newtime->tm_min);
387 fSubnames[4] = new TGString(tmp);
388 }
389 else
390 fSubnames[4] = new TGString("1901-01-01 00:00");
391
392 fSubnames[5] = 0;
393
394 int i;
395 for (i = 0; fSubnames[i] != 0; ++i)
396 ;
397 fCtw = new int[i+1];
398 fCtw[i] = 0;
399 for (i = 0; fSubnames[i] != 0; ++i)
400 fCtw[i] = gVirtualX->TextWidth(fFontStruct, fSubnames[i]->GetString(),
401 fSubnames[i]->GetLength());
402
404}
405
406////////////////////////////////////////////////////////////////////////////////
407/// Destructor.
408
410{
411 delete fBuf;
412}
413
414////////////////////////////////////////////////////////////////////////////////
415/// Set container item view mode.
416
428
429////////////////////////////////////////////////////////////////////////////////
430/// Draw list view container item.
431
433{
434 int ix, iy;
435
437 if (!fLcurrent) return;
438
439 if (fViewMode == kLVLargeIcons) {
440 ix = (fWidth - fLcurrent->GetWidth()) >> 1;
441 iy = 0;
442 } else {
443 ix = 0;
444 iy = (fHeight - fLcurrent->GetHeight()) >> 1;
445 }
446
447 fLcurrent->Draw(fId, fNormGC, ix, iy);
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Handle drag and drop enter
452
454{
455 if (!IsDNDTarget()) return kNone;
456 return gVirtualX->InternAtom("application/root", kFALSE);
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Set drag and drop data
461
463{
464 if (fDNDData.fDataLength > 0)
466 fDNDData.fData = calloc(data->fDataLength, sizeof(unsigned char));
467 if (fDNDData.fData)
468 memcpy(fDNDData.fData, data->fData, data->fDataLength);
469 fDNDData.fDataLength = data->fDataLength;
470 fDNDData.fDataType = data->fDataType;
471}
472
473////////////////////////////////////////////////////////////////////////////////
474/// Set drag and drop object
475
477{
480 fBuf->WriteObject(obj);
483 fDNDData.fDataType = gVirtualX->InternAtom("application/root", kFALSE);
484}
485
486
487
488////////////////////////////////////////////////////////////////////////////////
489/// Create a list view container which will hold the contents of
490/// the current directory.
491
493 UInt_t options, Pixel_t back) :
494 TGLVContainer(p, w, h, options, back)
495{
497 fFilter = 0;
498 fMtime = 0;
500 fRefresh = new TViewUpdateTimer(this, 1000);
504 fCleanups = new TList;
505
506 fFolder_s = fClient->GetPicture("folder_s.xpm");
507 fFolder_t = fClient->GetPicture("folder_t.xpm");
508 fApp_s = fClient->GetPicture("app_s.xpm");
509 fApp_t = fClient->GetPicture("app_t.xpm");
510 fDoc_s = fClient->GetPicture("doc_s.xpm");
511 fDoc_t = fClient->GetPicture("doc_t.xpm");
512 fSlink_s = fClient->GetPicture("slink_s.xpm");
513 fSlink_t = fClient->GetPicture("slink_t.xpm");
514
515 if (!fFolder_s || !fFolder_t ||
516 !fApp_s || !fApp_t ||
517 !fDoc_s || !fDoc_t ||
518 !fSlink_s || !fSlink_t)
519 Error("TGFileContainer", "required pixmap(s) missing\n");
520
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Create a list view container which will hold the contents of
526/// the current directory.
527
529 TGLVContainer(p,options, back)
530{
532 fFilter = 0;
533 fMtime = 0;
535 fRefresh = new TViewUpdateTimer(this, 1000);
539 fCleanups = new TList;
540
541 fFolder_s = fClient->GetPicture("folder_s.xpm");
542 fFolder_t = fClient->GetPicture("folder_t.xpm");
543 fApp_s = fClient->GetPicture("app_s.xpm");
544 fApp_t = fClient->GetPicture("app_t.xpm");
545 fDoc_s = fClient->GetPicture("doc_s.xpm");
546 fDoc_t = fClient->GetPicture("doc_t.xpm");
547 fSlink_s = fClient->GetPicture("slink_s.xpm");
548 fSlink_t = fClient->GetPicture("slink_t.xpm");
549
550 if (!fFolder_s || !fFolder_t ||
551 !fApp_s || !fApp_t ||
552 !fDoc_s || !fDoc_t ||
553 !fSlink_s || !fSlink_t)
554 Error("TGFileContainer", "required pixmap(s) missing\n");
555
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Delete list view file container.
561
584
585////////////////////////////////////////////////////////////////////////////////
586/// Add frame to the composite frame.
587
589{
591
592 nw = new TGFSFrameElement;
593 nw->fFrame = f;
594 nw->fLayout = l ? l : fgDefaultHints;
595 nw->fState = 1;
596 nw->fContainer = this;
597 fList->Add(nw);
598}
599
600////////////////////////////////////////////////////////////////////////////////
601/// Refresh container contents. Check every 5 seconds to see if the
602/// directory modification date has changed.
603
605{
607
609 if (fMtime != (ULong_t)sbuf.fMtime) DisplayDirectory();
610
611 return kTRUE;
612}
613
614////////////////////////////////////////////////////////////////////////////////
615/// Set file selection filter.
616
617void TGFileContainer::SetFilter(const char *filter)
618{
619 if (fFilter) delete fFilter;
620 fFilter = new TRegexp(filter, kTRUE);
621}
622
623////////////////////////////////////////////////////////////////////////////////
624/// Sort file system list view container according to sortType.
625
627{
629
630 fList->Sort();
631
632 const TGWindow *parent = this->GetParent();
633 if (parent) {
634 TGCanvas *canvas = (TGCanvas *)parent->GetParent();
635 if (canvas)
636 canvas->Layout();
637 }
638}
639
640////////////////////////////////////////////////////////////////////////////////
641/// Determine the file picture for the given file type.
642
645 const char *name, Bool_t /*small*/)
646{
647 static TString cached_ext;
648 static const TGPicture *cached_spic = 0;
649 static const TGPicture *cached_lpic = 0;
650 const char *ext = name ? strrchr(name, '.') : 0;
651 *pic = 0;
652 *lpic = 0;
653
655 *pic = cached_spic;
656 *lpic = cached_lpic;
657 if (!is_link) return;
658 }
659
660 if (R_ISREG(file_type)) {
662 if (is_link && fname.EndsWith(".lnk")) {
663 fname.Remove(fname.Length()-4);
664 }
667
668 if (*pic) {
669 if (!*lpic) *lpic = *pic;
670 if (ext) {
671 cached_ext = ext;
672 cached_spic = *pic;
673 cached_lpic = *lpic;
674 if (!is_link) return;
675 }
676 }
677 } else {
678 *pic = 0;
679 }
680
681 if (*pic == 0) {
682 *pic = fDoc_t;
683 *lpic = fDoc_s;
684
685 if (R_ISREG(file_type) && (file_type) & kS_IXUSR) {
686 *pic = fApp_t;
687 *lpic = fApp_s;
688 }
689 if (R_ISDIR(file_type)) {
690 *pic = fFolder_t;
691 *lpic = fFolder_s;
692 }
693 }
694 if (is_link) {
695 TImage *img1, *img2;
696 if (*pic && *lpic) {
699 if (img1) {
700 img1->SetImage(((const TGPicture *)*pic)->GetPicture(),
701 ((const TGPicture *)*pic)->GetMask());
702 img2 = TImage::Open("slink_t.xpm");
703 if (img2) img1->Merge(img2);
704 lnk_name = ((const TGPicture *)*pic)->GetName();
705 lnk_name.Prepend("lnk_");
707 img1->GetPixmap(), img1->GetMask());
708 fCleanups->Add(((TObject *)*pic));
709 if (img2) delete img2;
710 delete img1;
711 }
713 if (img1) {
714 img1->SetImage(((const TGPicture *)*lpic)->GetPicture(),
715 ((const TGPicture *)*lpic)->GetMask());
716 img2 = TImage::Open("slink_s.xpm");
717 if (img2) img1->Merge(img2);
718 lnk_name = ((const TGPicture *)*lpic)->GetName();
719 lnk_name.Prepend("lnk_");
721 img1->GetPixmap(), img1->GetMask());
722 fCleanups->Add(((TObject *)*lpic));
723 if (img2) delete img2;
724 delete img1;
725 }
726 }
727 else {
728 *pic = fSlink_t;
729 *lpic = fSlink_s;
730 }
731 }
732
733 cached_lpic = 0;
734 cached_spic = 0;
735 cached_ext = "";
736}
737
738////////////////////////////////////////////////////////////////////////////////
739/// Change current directory.
740
742{
744 gSystem->ChangeDirectory(fDirectory.Data()); // so path of ".." will work
745 char *exppath = gSystem->ExpandPathName(path);
750 }
751 delete[] exppath;
752}
753
754////////////////////////////////////////////////////////////////////////////////
755/// Display the contents of the current directory in the container.
756/// This can be used to refresh the contents of the window.
757
759{
760 RemoveAll();
762
763 // This automatically calls layout
765
766 // Make TGExplorerMainFrame display total objects in status bar
769
771}
772
773////////////////////////////////////////////////////////////////////////////////
774/// This function creates the file list from current dir.
775
777{
779 if (!gSystem->ChangeDirectory(fDirectory.Data())) return;
780
782 if (gSystem->GetPathInfo(".", sbuf) == 0)
783 fMtime = sbuf.fMtime;
784
785 void *dirp;
786 if ((dirp = gSystem->OpenDirectory(".")) == 0) {
788 return;
789 }
790
791 const char *name;
792 while ((name = gSystem->GetDirEntry(dirp)) != 0 && fDisplayStat) {
793 if (strcmp(name, ".") && strcmp(name, ".."))
794 AddFile(name);
796 }
798
800}
801
802////////////////////////////////////////////////////////////////////////////////
803/// Add file in container.
804
806 const TGPicture *ilpic)
807{
809 TGFileItem *item = 0;
810 const TGPicture *spic, *slpic;
811 TGPicture *pic, *lpic;
812
814
815 if (gSystem->GetPathInfo(name, sbuf)) {
816 if (sbuf.fIsLink) {
817 Info("AddFile", "Broken symlink of %s.", name);
818 } else if (errno != ENOENT) {
819 TString msg;
820 msg.Form("Can't read file attributes of \"%s\": %s.",
821 name, gSystem->GetError());
823 "Error", msg.Data(), kMBIconStop, kMBOk);
824 }
825 return item;
826 }
827
828 filename = name;
829 if (R_ISDIR(sbuf.fMode) || fFilter == 0 ||
830 (fFilter && filename.Index(*fFilter) != kNPOS)) {
831
832 if (ipic && ilpic) { // dynamic icons
833 spic = ipic;
834 slpic = ilpic;
835 } else {
836 GetFilePictures(&spic, &slpic, sbuf.fMode, sbuf.fIsLink, name, kTRUE);
837 }
838
839 pic = (TGPicture*)spic; pic->AddReference();
840 lpic = (TGPicture*)slpic; lpic->AddReference();
841
842 item = new TGFileItem(this, lpic, slpic, spic, pic,
844 sbuf, fViewMode);
845 AddItem(item);
846 }
847
848 return item;
849}
850
851////////////////////////////////////////////////////////////////////////////////
852/// Add remote file in container.
853
855 const TGPicture *ilpic)
856{
858 TGFileItem *item = 0;
859 const TGPicture *spic, *slpic;
860 TGPicture *pic, *lpic;
861
863
865
866 robj->GetFileStat(&sbuf);
867 filename = robj->GetName();
868
869 if (R_ISDIR(sbuf.fMode) || fFilter == 0 ||
870 (fFilter && filename.Index(*fFilter) != kNPOS)) {
871
872 if (ipic && ilpic) { // dynamic icons
873 spic = ipic;
874 slpic = ilpic;
875 } else {
876 GetFilePictures(&spic, &slpic, sbuf.fMode, sbuf.fIsLink, filename, kTRUE);
877 }
878
879 pic = (TGPicture*)spic; pic->AddReference();
880 lpic = (TGPicture*)slpic; lpic->AddReference();
881
882 item = new TGFileItem(this, lpic, slpic, spic, pic, new TGString(filename),
883 sbuf, fViewMode);
884 AddItem(item);
885 }
886 return item;
887}
888
889////////////////////////////////////////////////////////////////////////////////
890/// stop refresh timer
891
893{
894 if (fRefresh) delete fRefresh;
895 fRefresh = 0;
896}
897
898////////////////////////////////////////////////////////////////////////////////
899/// start refreshing
900
906
907////////////////////////////////////////////////////////////////////////////////
908/// Save a file container widget as a C++ statement(s) on output stream out.
909
910void TGFileContainer::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
911{
912 // save options and color if necessary
914
915 out << "\n // container frame\n";
916 out << " TGFileContainer *" << GetName() << " = new TGFileContainer(";
917
918 if ((fParent->GetParent())->InheritsFrom(TGCanvas::Class()))
919 out << GetCanvas()->GetName();
920 else
921 out << fParent->GetName() << "," << GetWidth() << "," << GetHeight();
922
923 out << extra_args << ");\n";
924
925 if (option && strstr(option, "keep_names"))
926 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
927 out << " " << GetCanvas()->GetName() << "->SetContainer(" << GetName() << ");\n";
928 out << " " << GetName() << "->DisplayDirectory();\n";
929 out << " " << GetName() << "->AddFile(\"..\");\n";
930 out << " " << GetName() << "->StopRefreshTimer();\n";
931}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kChildFrame
Definition GuiTypes.h:379
@ kSunkenFrame
Definition GuiTypes.h:383
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:208
EFSSortMode
@ kSortByDate
@ kSortByOwner
@ kSortByName
@ kSortByGroup
@ kSortByType
@ kSortBySize
EListViewMode
Definition TGListView.h:21
@ kLVLargeIcons
Definition TGListView.h:22
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconStop
Definition TGMsgBox.h:22
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
void Sort()
Bool_t R_ISFIFO(Int_t mode)
Definition TSystem.h:128
Bool_t R_ISSOCK(Int_t mode)
Definition TSystem.h:129
Bool_t R_ISBLK(Int_t mode)
Definition TSystem.h:125
Bool_t R_ISREG(Int_t mode)
Definition TSystem.h:126
Bool_t R_ISLNK(Int_t mode)
Definition TSystem.h:127
Bool_t R_ISDIR(Int_t mode)
Definition TSystem.h:123
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
Bool_t R_ISCHR(Int_t mode)
Definition TSystem.h:124
@ kS_IRGRP
Definition TSystem.h:114
@ kS_IWUSR
Definition TSystem.h:111
@ kS_ISUID
Definition TSystem.h:106
@ kS_IRUSR
Definition TSystem.h:110
@ kS_IXOTH
Definition TSystem.h:120
@ kS_ISGID
Definition TSystem.h:107
@ kS_IROTH
Definition TSystem.h:118
@ kS_IWGRP
Definition TSystem.h:115
@ kS_IXUSR
Definition TSystem.h:112
@ kS_ISVTX
Definition TSystem.h:108
@ kS_IWOTH
Definition TSystem.h:119
@ kS_IXGRP
Definition TSystem.h:116
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kCT_SELCHANGED
@ kC_CONTAINER
#define free
Definition civetweb.c:1578
#define calloc
Definition civetweb.c:1576
#define snprintf
Definition civetweb.c:1579
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Int_t Length() const
Definition TBuffer.h:100
char * Buffer() const
Definition TBuffer.h:96
Drag and drop data container.
Atom_t fDataType
Data type description.
Int_t fDataLength
Length of data.
void * fData
Actual data.
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
void Layout() override
Create layout for canvas.
static TClass * Class()
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
TGMimeTypes * GetMimeTypeList() const
Definition TGClient.h:147
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
TGPicturePool * GetPicturePool() const
Definition TGClient.h:126
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
TList * fList
container of frame elements
Definition TGFrame.h:294
static TGLayoutHints * fgDefaultHints
Definition TGFrame.h:299
const TGWindow * fMsgWindow
window handling container messages
Definition TGCanvas.h:42
TGCanvas * GetCanvas() const
Definition TGCanvas.h:99
Int_t fSelected
number of selected items
Definition TGCanvas.h:49
Int_t fTotal
total items
Definition TGCanvas.h:48
void RemoveAll() override
Remove all items from the container.
Definition TGCanvas.cxx:638
Int_t Compare(const TObject *obj) const override
Sort frame elements in file selection list view container.
TGFileContainer * fContainer
Bool_t IsSortable() const override
const TGPicture * fSlink_s
big symbolic link icon
void CreateFileList()
This function creates the file list from current dir.
const TGPicture * fFolder_s
big folder icon
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a file container widget as a C++ statement(s) on output stream out.
Bool_t HandleTimer(TTimer *t) override
Refresh container contents.
TList * fCleanups
list of pictures to cleanup
TString fDirectory
current directory
TViewUpdateTimer * fRefresh
refresh timer
void StopRefreshTimer()
stop refresh timer
const TGPicture * fDoc_t
small document icon
const TGPicture * fApp_t
small application icon
const TGPicture * fApp_s
big application icon
void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr) override
Add frame to the composite frame.
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
const TGPicture * fDoc_s
big document icon
~TGFileContainer() override
Delete list view file container.
Bool_t fCachePictures
kTRUE use caching
virtual void ChangeDirectory(const char *path)
Change current directory.
const TGPicture * fSlink_t
small symbolic link icon
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
ULong_t fMtime
directory modification time
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=nullptr, const TGPicture *lpic=nullptr)
Add file in container.
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=nullptr, const TGPicture *ilpic=nullptr)
Add remote file in container.
void StartRefreshTimer(ULong_t msec=1000)
start refreshing
const TGPicture * fFolder_t
small folder icon
TRegexp * fFilter
file filter
friend class TGFSFrameElement
Bool_t fDisplayStat
kFALSE to interrupt display directory contents in case of many files inside
virtual void SetFilter(const char *filter)
Set file selection filter.
virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic, Int_t file_type, Bool_t is_link, const char *ext, Bool_t small)
Determine the file picture for the given file type.
TGFileContainer(const TGWindow *p=nullptr, UInt_t w=1, UInt_t h=1, UInt_t options=kSunkenFrame, Pixel_t back=GetDefaultFrameBackground())
Create a list view container which will hold the contents of the current directory.
EFSSortMode fSortType
sorting mode of contents
Utility class used by the file selection dialog (TGFSDialog).
TGFileIcon(const TGWindow *p, const TGPicture *pic, const TGPicture *lpic, UInt_t options=kChildFrame, Pixel_t back=GetWhitePixel())
void DoRedraw() override
Draw icon.
const TGPicture * fLpic
Int_t fGid
file uid and gid
void DoRedraw() override
Draw list view container item.
Int_t GetUid() const
Long64_t fSize
file size
const TGPicture * fLcurrent
current icon
void SetViewMode(EListViewMode viewMode) override
Set container item view mode.
Int_t GetGid() const
TBufferFile * fBuf
buffer used for Drag and Drop
const TGPicture * fBlpic
big icon
Atom_t HandleDNDEnter(Atom_t *) override
Handle drag and drop enter.
void Init(const TGPicture *blpic, const TGPicture *slpic, FileStat_t &stat, EListViewMode viewMode)
Common initializer for file list view item.
~TGFileItem() override
Destructor.
Long_t fModTime
modification time
const TGPicture * fSlpic
small icon
Long64_t GetSize() const
void SetDNDObject(TObject *obj)
Set drag and drop object.
TDNDData fDNDData
Drag and Drop data.
Long_t GetModTime() const
Int_t fType
file type
Int_t GetType() const
void SetDNDData(TDNDData *data)
Set drag and drop data.
TGFileItem(const TGWindow *p=nullptr, const TGPicture *bpic=nullptr, const TGPicture *blpic=nullptr, const TGPicture *spic=nullptr, const TGPicture *slpic=nullptr, TGString *name=nullptr, Int_t type=0, Long64_t size=1, Int_t uid=0, Int_t gid=0, Long_t modtime=0, EListViewMode viewMode=kLVList, UInt_t options=kVerticalFrame, Pixel_t back=GetWhitePixel())
Create a list view item.
Bool_t fIsLink
true if symbolic link
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:701
UInt_t fHeight
frame height
Definition TGFrame.h:88
Bool_t IsDNDTarget() const
Definition TGFrame.h:275
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
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,...
Definition TGFrame.cxx:2493
UInt_t GetWidth() const
Definition TGFrame.h:226
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:767
This class handles GUI icons.
Definition TGIcon.h:22
void DoRedraw() override
Redraw picture.
Definition TGIcon.cxx:125
virtual void AddItem(TGLVEntry *item)
Definition TGListView.h:207
EListViewMode fViewMode
list view viewing mode
Definition TGListView.h:186
TGString ** fSubnames
sub names of item (details)
Definition TGListView.h:44
void DoRedraw() override
Redraw list view item.
FontStruct_t fFontStruct
text font
Definition TGListView.h:59
EListViewMode fViewMode
list view viewing mode
Definition TGListView.h:52
GContext_t fNormGC
drawing graphics context
Definition TGListView.h:58
virtual void SetViewMode(EListViewMode viewMode)
Set the view mode for this list item.
TGString * GetItemName() const
Definition TGListView.h:88
Int_t * fCtw
width of sub names
Definition TGListView.h:47
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
const TGPicture * GetIcon(const char *filename, Bool_t small_icon)
Return icon belonging to mime type of filename.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
void FreePicture(const TGPicture *pic)
Remove picture from cache if nobody is using it anymore.
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition TGPicture.cxx:80
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:150
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
const TGWindow * GetParent() const
Definition TGWindow.h:83
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:117
static TImage * Create()
Create an image.
Definition TImage.cxx:34
A doubly linked list.
Definition TList.h:38
void Clear(Option_t *option="") override
Remove all objects from the list.
Definition TList.cxx:399
void Add(TObject *obj) override
Definition TList.h:81
virtual void Sort(Bool_t order=kSortAscending)
Sort linked list.
Definition TList.cxx:934
Mother of all ROOT objects.
Definition TObject.h:41
Regular expression class.
Definition TRegexp.h:31
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
Basic string class.
Definition TString.h:138
const char * Data() const
Definition TString.h:384
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2384
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1285
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition TSystem.cxx:855
virtual void * OpenDirectory(const char *name)
Open a directory.
Definition TSystem.cxx:846
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition TSystem.cxx:1409
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition TSystem.cxx:863
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:872
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:469
virtual const char * BaseName(const char *pathname)
Base name of a file name. Base name of /user/root is root.
Definition TSystem.cxx:944
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:881
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:414
virtual const char * GetError()
Return system error string.
Definition TSystem.cxx:252
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure.
Definition TSystem.cxx:1612
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
TViewUpdateTimer(TGFileContainer *t, Long_t ms)
Bool_t Notify() override
Reset the timer.
TGFileContainer * fContainer
TF1 * f1
Definition legend1.C:11
Int_t fMode
Definition TSystem.h:135
Long64_t fSize
Definition TSystem.h:138
Int_t fGid
Definition TSystem.h:137
Long_t fMtime
Definition TSystem.h:139
Bool_t fIsLink
Definition TSystem.h:140
Int_t fUid
Definition TSystem.h:136
TLine l
Definition textangle.C:4