13#include "KVFileDialog.h"
47static const char* gDefTypes[] = {
"All files",
"*",
48 "ROOT files",
"*.root",
66 EKVFileDialogMode dlg_type,
TGFileInfo* file_info) :
74 Connect(
"CloseWindow()",
"KVFileDialog",
this,
"CloseWindow()");
84 Error(
"KVFileDialog",
"file_info argument not set");
86 if (fFileInfo->fIniDir) {
88 fFileInfo->fIniDir = 0;
90 if (fFileInfo->fFilename) {
91 delete [] fFileInfo->fFilename;
92 fFileInfo->fFilename = 0;
94 fFileInfo->fFileTypeIdx = 0;
97 fFileInfo = file_info;
99 if (!fFileInfo->fFileTypes)
100 fFileInfo->fFileTypes = gDefTypes;
102 if (!fFileInfo->fIniDir)
103 fFileInfo->fIniDir =
StrDup(
".");
109 ?
"S&ave in:" :
"&Look in:"));
111 fTreeLB->Associate(
this);
113 fPcdup = fClient->GetPicture(
"tb_uplevel.xpm");
114 fPnewf = fClient->GetPicture(
"tb_newfolder.xpm");
115 fPlist = fClient->GetPicture(
"tb_list.xpm");
116 fPdetails = fClient->GetPicture(
"tb_details.xpm");
118 if (!(fPcdup && fPnewf && fPlist && fPdetails))
119 Error(
"KVFileDialog",
"missing toolbar pixmap(s).\n");
126 fCdup->SetStyle(
gClient->GetStyle());
127 fNewf->SetStyle(
gClient->GetStyle());
128 fList->SetStyle(
gClient->GetStyle());
129 fDetails->SetStyle(
gClient->GetStyle());
131 fCdup->SetToolTipText(
"Up One Level");
132 fNewf->SetToolTipText(
"Create New Folder");
133 fList->SetToolTipText(
"List");
134 fDetails->SetToolTipText(
"Details");
136 fCdup->Associate(
this);
137 fNewf->Associate(
this);
138 fList->Associate(
this);
139 fDetails->Associate(
this);
141 fList->AllowStayDown(
kTRUE);
142 fDetails->AllowStayDown(
kTRUE);
144 fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());
153 if (dlg_type == kKVFDSave) {
155 fCheckB->SetToolTipText(
"Overwrite a file without displaying a message if selected");
159 fCheckB->SetToolTipText(
"Allows multiple file selection when SHIFT is pressed");
160 fCheckB->Connect(
"Toggled(Bool_t)",
"TGFileInfo", fFileInfo,
"SetMultipleSelection(Bool_t)");
163 fCheckB->SetOn(fFileInfo->fMultipleSelection);
172 fFc->Associate(
this);
174 fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
175 fFv->SetContainer(fFc);
177 fFv->SetIncrements(1, 19);
181 buttons[0]->
Connect(
"Clicked()",
"TGFileContainer", fFc,
"Sort(=kSortByName)");
182 buttons[1]->
Connect(
"Clicked()",
"TGFileContainer", fFc,
"Sort(=kSortByType)");
183 buttons[2]->
Connect(
"Clicked()",
"TGFileContainer", fFc,
"Sort(=kSortBySize)");
184 buttons[3]->
Connect(
"Clicked()",
"TGFileContainer", fFc,
"Sort(=kSortByOwner)");
185 buttons[4]->
Connect(
"Clicked()",
"TGFileContainer", fFc,
"Sort(=kSortByGroup)");
186 buttons[5]->
Connect(
"Clicked()",
"TGFileContainer", fFc,
"Sort(=kSortByDate)");
189 fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx + 1]);
191 fFc->ChangeDirectory(fFileInfo->fIniDir);
192 fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
193 fTreeLB->Update(fFc->GetDirectory());
199 if (dlg_type == kKVFDOpen) {
200 fCheckB->Connect(
"Toggled(Bool_t)",
"TGFileContainer", fFc,
"SetMultipleSelection(Bool_t)");
201 fCheckB->Connect(
"Toggled(Bool_t)",
"TGFileContainer", fFc,
"UnSelectAll()");
215 fName->Resize(230, fName->GetDefaultHeight());
216 fName->Associate(
this);
227 fTypes->Associate(
this);
228 fTypes->Resize(230, fName->GetDefaultHeight());
231 for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
232 s.Form(
"%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i + 1]);
233 fTypes->AddEntry(s.Data(), i);
235 fTypes->Select(fFileInfo->fFileTypeIdx);
241 if (fFileInfo->fFilename && fFileInfo->fFilename[0])
242 fTbfname->AddText(0, fFileInfo->fFilename);
246 fTypes->GetListBox()->Resize(230, 120);
259 ?
"&Save" :
"&Open"),
kIDF_OK);
262 fOk->Associate(
this);
263 fCancel->Associate(
this);
274 SetEditDisabled(kEditDisable);
288 SetWMSize(
size.fWidth,
size.fHeight);
291 const char* wname = ((dlg_type == kKVFDSave) ?
"Save As..." : (dlg_type == kKVFDOpen) ?
"Open" :
"Choose directory...");
292 SetWindowName(wname);
294 SetClassHints(
"FileDialog",
"FileDialog");
303 fFc->DisplayDirectory();
304 fClient->WaitFor(
this);
318 if (str.Contains(
"Multiple"))
372 txt =
"Please provide file name or use \"Cancel\"";
382 txt = TString::Format(
"File name %s already exists, OK to overwrite it?",
438 strlcpy(answer,
"(empty)",
sizeof(answer));
440 "Enter directory name:",
443 while (strcmp(answer,
"(empty)") == 0) {
445 "Please enter a valid directory name.",
448 "Enter directory name:",
451 if (strcmp(answer,
"") == 0)
459 TString::Format(
"Directory name \'%s\' already exists!", answer),
542 tmpString +=
"\"" + el->
GetString() +
"\" ";
573 txt = TString::Format(
"File name %s already exists, OK to overwrite it?",
612 const char* txt2 =
"Please provide file name or use \"Cancel\"";
633 txt = TString::Format(
"File name %s already exists, OK to overwrite it?",
size_t size(const MatrixT &matrix)
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void SetMWMHints
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t SetWMSizeHints
char * StrDup(const char *str)
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
Modified version of TGFileDialog file selection dialog.
virtual ~KVFileDialog()
Delete file dialog.
TGPictureButton * fList
top toolbar button
const TGPicture * fPlist
picture for fList
TGTextBuffer * fTbfname
text buffer of file name
TGTextButton * fOk
ok button
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages generated by the user input in the file dialog.
TGTextEntry * fName
file name text entry
TGFileInfo * fFileInfo
file info passed to this dialog
EKVFileDialogMode fDlgMode
TGComboBox * fTypes
file type combo box
TGFSComboBox * fTreeLB
file system path combo box
TGListView * fFv
file list view
TGPictureButton * fDetails
top toolbar button
const TGPicture * fPcdup
OR set on/off multiple file selection for SaveAs dialog.
TGFileContainer * fFc
file list view container (containing the files)
virtual void CloseWindow()
Close file dialog.
const TGPicture * fPdetails
picture for fDetails
const TGPicture * fPnewf
picture for fNewf
const TGWindow * GetRoot() const
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
void FreePicture(const TGPicture *pic)
virtual TGLBEntry * GetSelectedEntry() const
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
UInt_t GetDefaultHeight() const override
virtual const TGFrame * GetNextSelected(void **current)
virtual Int_t NumSelected() const
virtual void Update(const char *path)
virtual void SetDisplayStat(Bool_t stat=kTRUE)
virtual void ChangeDirectory(const char *path)
virtual void DisplayDirectory()
virtual void SetFilter(const char *filter)
const char * GetDirectory() const
Bool_t fMultipleSelection
virtual void Resize(TGDimension size)
virtual void DeleteWindow()
TList * GetSelectedItems()
TGString * GetItemName() const
virtual void SetViewMode(EListViewMode viewMode)
const char * GetString() const
void AddText(Int_t pos, const char *text)
const char * GetString() const
UInt_t GetTextLength() const
const char * GetTitle() const override
TString GetString() const
virtual void SetText(const char *text, Bool_t emit=kTRUE)
virtual const TGWindow * GetMainFrame() const
void Add(TObject *obj) override
void Delete(Option_t *option="") override
const TString & GetString() const
R__ALWAYS_INLINE Bool_t IsZombie() const
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
const char * Data() const
Bool_t cd(const char *path)
virtual char * ConcatFileName(const char *dir, const char *name)
virtual int MakeDirectory(const char *name)
virtual int GetPathInfo(const char *path, FileStat_t &buf)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
virtual Bool_t ChangeDirectory(const char *path)
virtual const char * UnixPathName(const char *unixpathname)
virtual Bool_t IsAbsoluteFileName(const char *dir)
virtual char * ExpandPathName(const char *path)
virtual const char * WorkingDirectory()
Type GetType(const std::string &Name)
Double_t Max(Double_t a, Double_t b)