KaliVeda
Toolkit for HIC analysis
KVFileDialog.cpp
1 // @(#)root/gui:$Id: KVFileDialog.cxx 43842 2012-04-19 13:09:11Z bellenot $
2 // Author: Fons Rademakers 20/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 #include "KVFileDialog.h"
14 #include "TGLabel.h"
15 #include "TGButton.h"
16 #include "TGTextEntry.h"
17 #include "TGComboBox.h"
18 #include "TGListView.h"
19 #include "TGFSContainer.h"
20 #include "TGFSComboBox.h"
21 #include "TGMsgBox.h"
22 #include "TSystem.h"
23 #include "TGInputDialog.h"
24 #include "TObjString.h"
25 #include "TMath.h"
26 #include "KVError.h"
27 #include <sys/stat.h>
28 
29 
31 
32 enum EFileFialog {
33  kIDF_CDUP,
35  kIDF_LIST,
38  kIDF_FSLB,
40  kIDF_OK,
42 };
43 
44 
45 
47 
48 static const char* gDefTypes[] = { "All files", "*",
49  "ROOT files", "*.root",
50  "ROOT macros", "*.C",
51  0, 0
52  };
53 
54 
55 static TGFileInfo gInfo;
56 
57 
59 
60 
61 
62 
67  EKVFileDialogMode dlg_type, TGFileInfo* file_info) :
68  TGTransientFrame(p, main, 10, 10, kVerticalFrame),
69  fSaveWorkingDirectory(gSystem->WorkingDirectory())
70 {
71  // Create a file selection dialog. Depending on the dlg_type it can be
72  // used for opening or saving a file or selecting a directory.
73 
74  fDlgMode = dlg_type;
75  SetCleanup(kDeepCleanup);
76  Connect("CloseWindow()", "KVFileDialog", this, "CloseWindow()");
77  DontCallClose();
78 
79  int i;
80 
81  if (!p && !main) {
82  MakeZombie();
83  return;
84  }
85  if (!file_info) {
86  KVError::Error(this, "KVFileDialog", "file_info argument not set");
87  fFileInfo = &gInfo;
88  if (fFileInfo->fIniDir) {
89  delete [] fFileInfo->fIniDir;
90  fFileInfo->fIniDir = 0;
91  }
92  if (fFileInfo->fFilename) {
93  delete [] fFileInfo->fFilename;
94  fFileInfo->fFilename = 0;
95  }
96  fFileInfo->fFileTypeIdx = 0;
97  }
98  else
99  fFileInfo = file_info;
100 
101  if (!fFileInfo->fFileTypes)
102  fFileInfo->fFileTypes = gDefTypes;
103 
104  if (!fFileInfo->fIniDir)
105  fFileInfo->fIniDir = StrDup(".");
106 
107  TGHorizontalFrame* fHtop = new TGHorizontalFrame(this, 10, 10);
108 
109  //--- top toolbar elements
110  TGLabel* fLookin = new TGLabel(fHtop, new TGHotString((dlg_type == kKVFDSave)
111  ? "S&ave in:" : "&Look in:"));
112  fTreeLB = new TGFSComboBox(fHtop, kIDF_FSLB);
113  fTreeLB->Associate(this);
114 
115  fPcdup = fClient->GetPicture("tb_uplevel.xpm");
116  fPnewf = fClient->GetPicture("tb_newfolder.xpm");
117  fPlist = fClient->GetPicture("tb_list.xpm");
118  fPdetails = fClient->GetPicture("tb_details.xpm");
119 
120  if (!(fPcdup && fPnewf && fPlist && fPdetails))
121  KVError::Error(this, "KVFileDialog", "missing toolbar pixmap(s).\n");
122 
123  fCdup = new TGPictureButton(fHtop, fPcdup, kIDF_CDUP);
124  fNewf = new TGPictureButton(fHtop, fPnewf, kIDF_NEW_FOLDER);
125  fList = new TGPictureButton(fHtop, fPlist, kIDF_LIST);
126  fDetails = new TGPictureButton(fHtop, fPdetails, kIDF_DETAILS);
127 
128  fCdup->SetStyle(gClient->GetStyle());
129  fNewf->SetStyle(gClient->GetStyle());
130  fList->SetStyle(gClient->GetStyle());
131  fDetails->SetStyle(gClient->GetStyle());
132 
133  fCdup->SetToolTipText("Up One Level");
134  fNewf->SetToolTipText("Create New Folder");
135  fList->SetToolTipText("List");
136  fDetails->SetToolTipText("Details");
137 
138  fCdup->Associate(this);
139  fNewf->Associate(this);
140  fList->Associate(this);
141  fDetails->Associate(this);
142 
143  fList->AllowStayDown(kTRUE);
144  fDetails->AllowStayDown(kTRUE);
145 
146  fTreeLB->Resize(200, fTreeLB->GetDefaultHeight());
147 
148  fHtop->AddFrame(fLookin, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
149  fHtop->AddFrame(fTreeLB, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 3, 0, 2, 2));
150  fHtop->AddFrame(fCdup, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
151  fHtop->AddFrame(fNewf, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
152  fHtop->AddFrame(fList, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 2, 2));
153  fHtop->AddFrame(fDetails, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 0, 8, 2, 2));
154 
155  if (dlg_type == kKVFDSave) {
156  fCheckB = new TGCheckButton(fHtop, "&Overwrite", kIDF_CHECKB);
157  fCheckB->SetToolTipText("Overwrite a file without displaying a message if selected");
158  }
159  else {
160  fCheckB = new TGCheckButton(fHtop, "&Multiple files", kIDF_CHECKB);
161  fCheckB->SetToolTipText("Allows multiple file selection when SHIFT is pressed");
162  fCheckB->Connect("Toggled(Bool_t)", "TGFileInfo", fFileInfo, "SetMultipleSelection(Bool_t)");
163  }
164  fHtop->AddFrame(fCheckB, new TGLayoutHints(kLHintsLeft | kLHintsCenterY));
165  fCheckB->SetOn(fFileInfo->fMultipleSelection);
166  AddFrame(fHtop, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
167 
168  //--- file view
169 
170  fFv = new TGListView(this, 400, 161);
171 
172  fFc = new TGFileContainer(fFv->GetViewPort(),
173  10, 10, kHorizontalFrame, fgWhitePixel);
174  fFc->Associate(this);
175 
176  fFv->GetViewPort()->SetBackgroundColor(fgWhitePixel);
177  fFv->SetContainer(fFc);
178  fFv->SetViewMode(kLVList);
179  fFv->SetIncrements(1, 19); // set vertical scroll one line height at a time
180 
181  TGTextButton** buttons = fFv->GetHeaderButtons();
182  if (buttons) {
183  buttons[0]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByName)");
184  buttons[1]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByType)");
185  buttons[2]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortBySize)");
186  buttons[3]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByOwner)");
187  buttons[4]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByGroup)");
188  buttons[5]->Connect("Clicked()", "TGFileContainer", fFc, "Sort(=kSortByDate)");
189  }
190 
191  fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx + 1]);
192  fFc->Sort(kSortByName);
193  fFc->ChangeDirectory(fFileInfo->fIniDir);
194  fFc->SetMultipleSelection(fFileInfo->fMultipleSelection);
195  fTreeLB->Update(fFc->GetDirectory());
196 
197  fList->SetState(kButtonEngaged);
198 
199  AddFrame(fFv, new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY, 4, 4, 3, 1));
200 
201  if (dlg_type == kKVFDOpen) {
202  fCheckB->Connect("Toggled(Bool_t)", "TGFileContainer", fFc, "SetMultipleSelection(Bool_t)");
203  fCheckB->Connect("Toggled(Bool_t)", "TGFileContainer", fFc, "UnSelectAll()");
204  }
205 
206  //--- file name and types
207 
208  TGHorizontalFrame* fHf = new TGHorizontalFrame(this, 10, 10);
209 
210  TGVerticalFrame* fVf = new TGVerticalFrame(fHf, 10, 10);
211 
212  TGHorizontalFrame* fHfname = new TGHorizontalFrame(fVf, 10, 10);
213 
214  TGLabel* fLfname = new TGLabel(fHfname, new TGHotString("File &name:"));
215  fTbfname = new TGTextBuffer(1034);
216  fName = new TGTextEntry(fHfname, fTbfname);
217  fName->Resize(230, fName->GetDefaultHeight());
218  fName->Associate(this);
219 
220  fHfname->AddFrame(fLfname, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
221  fHfname->AddFrame(fName, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));
222 
224 
225  TGHorizontalFrame* fHftype = new TGHorizontalFrame(fVf, 10, 10);
226 
227  TGLabel* fLftypes = new TGLabel(fHftype, new TGHotString("Files of &type:"));
228  fTypes = new TGComboBox(fHftype, kIDF_FTYPESLB);
229  fTypes->Associate(this);
230  fTypes->Resize(230, fName->GetDefaultHeight());
231 
232  TString s;
233  for (i = 0; fFileInfo->fFileTypes[i] != 0; i += 2) {
234  s.Form("%s (%s)", fFileInfo->fFileTypes[i], fFileInfo->fFileTypes[i + 1]);
235  fTypes->AddEntry(s.Data(), i);
236  }
237  fTypes->Select(fFileInfo->fFileTypeIdx);
238 
239  // Show all items in combobox without scrollbar
240  //TGDimension fw = fTypes->GetListBox()->GetContainer()->GetDefaultSize();
241  //fTypes->GetListBox()->Resize(fw.fWidth, fw.fHeight);
242 
243  if (fFileInfo->fFilename && fFileInfo->fFilename[0])
244  fTbfname->AddText(0, fFileInfo->fFilename);
245  else
246  fTbfname->Clear();
247 
248  fTypes->GetListBox()->Resize(230, 120);
249  fHftype->AddFrame(fLftypes, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2));
250  fHftype->AddFrame(fTypes, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 0, 20, 2, 2));
251 
253 
255 
256  //--- Open/Save and Cancel buttons
257 
258  TGVerticalFrame* fVbf = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
259 
260  fOk = new TGTextButton(fVbf, new TGHotString((dlg_type == kKVFDSave)
261  ? "&Save" : "&Open"), kIDF_OK);
262  fCancel = new TGTextButton(fVbf, new TGHotString("Cancel"), kIDF_CANCEL);
263 
264  fOk->Associate(this);
265  fCancel->Associate(this);
266 
267  fVbf->AddFrame(fOk, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
268  fVbf->AddFrame(fCancel, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 2, 2));
269 
270  UInt_t width = TMath::Max(fOk->GetDefaultWidth(), fCancel->GetDefaultWidth()) + 20;
271  fVbf->Resize(width + 20, fVbf->GetDefaultHeight());
272 
274 
275  AddFrame(fHf, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 4, 4, 3, 1));
276  SetEditDisabled(kEditDisable);
277 
278  MapSubwindows();
279 
280  TGDimension size = GetDefaultSize();
281 
282  Resize(size);
283 
284  //---- position relative to the parent's window
285 
286  CenterOnParent();
287 
288  //---- make the message box non-resizable
289 
290  SetWMSize(size.fWidth, size.fHeight);
291  SetWMSizeHints(size.fWidth, size.fHeight, 10000, 10000, 1, 1);
292 
293  const char* wname = ((dlg_type == kKVFDSave) ? "Save As..." : (dlg_type == kKVFDOpen) ? "Open" : "Choose directory...");
294  SetWindowName(wname);
295  SetIconName(wname);
296  SetClassHints("FileDialog", "FileDialog");
297 
303 
304  MapWindow();
305  fFc->DisplayDirectory();
306  fClient->WaitFor(this);
307 }
308 
309 
310 
313 
315 {
316  // Delete file dialog.
317 
318  if (IsZombie()) return;
319  TString str = fCheckB->GetString();
320  if (str.Contains("Multiple"))
321  fCheckB->Disconnect("Toggled(Bool_t)");
322  fClient->FreePicture(fPcdup);
323  fClient->FreePicture(fPnewf);
324  fClient->FreePicture(fPlist);
325  fClient->FreePicture(fPdetails);
326  delete fFc;
327 
328  // reset filesystem working directory
329  gSystem->cd(fSaveWorkingDirectory);
330 }
331 
332 
333 
337 
339 {
340  // Close file dialog.
341 
342  // reset filesystem working directory
343  gSystem->cd(fSaveWorkingDirectory);
344  if (fFileInfo->fFilename)
345  delete [] fFileInfo->fFilename;
346  fFileInfo->fFilename = 0;
347  if (fFileInfo->fFileNamesList != 0) {
348  fFileInfo->fFileNamesList->Delete();
349  fFileInfo->fFileNamesList = 0;
350  }
351  DeleteWindow();
352 }
353 
354 
355 
358 
360 {
361  // Process messages generated by the user input in the file dialog.
362 
363  if (!fFc->GetDisplayStat()) return kTRUE; // Cancel button was pressed
364 
365  TGTreeLBEntry* e;
366  TGTextLBEntry* te;
367  TGFileItem* f;
368  void* p = 0;
369  TString txt;
370  TString sdir = gSystem->WorkingDirectory();
371 
372  switch (GET_MSG(msg)) {
373  case kC_COMMAND:
374  switch (GET_SUBMSG(msg)) {
375  case kCM_BUTTON:
376  switch (parm1) {
377  case kIDF_OK:
378  // same code as under kTE_ENTER
379  if ((fDlgMode != kKVFDDirectory) && (fTbfname->GetTextLength() == 0)) {
380  txt = "Please provide file name or use \"Cancel\"";
382  "Missing File Name", txt, kMBIconExclamation,
383  kMBOk);
384  return kTRUE;
385  }
386  else if (!gSystem->AccessPathName(fTbfname->GetString(), kFileExists) &&
387  !strcmp(fOk->GetTitle(), "Save") &&
388  (!(fCheckB->GetState() == kButtonDown))) {
389  Int_t ret;
390  txt = TString::Format("File name %s already exists, OK to overwrite it?",
391  fTbfname->GetString());
393  "File Name Exist", txt.Data(), kMBIconExclamation,
394  kMBYes | kMBNo, &ret);
395  if (ret == kMBNo)
396  return kTRUE;
397  }
398  if (fFileInfo->fMultipleSelection) {
399  if (fFileInfo->fFilename)
400  delete [] fFileInfo->fFilename;
401  fFileInfo->fFilename = 0;
402  }
403  else {
404  if (fFileInfo->fFilename)
405  delete [] fFileInfo->fFilename;
406  if (gSystem->IsAbsoluteFileName(fTbfname->GetString()))
407  fFileInfo->fFilename = StrDup(fTbfname->GetString());
408  else
409  fFileInfo->fFilename = gSystem->ConcatFileName(fFc->GetDirectory(),
410  fTbfname->GetString());
411  fFileInfo->fFilename = StrDup(gSystem->UnixPathName(gSystem->ExpandPathName(fFileInfo->fFilename)));
412  }
413  if (fCheckB && (fCheckB->GetState() == kButtonDown))
414  fFileInfo->fOverwrite = kTRUE;
415  else
416  fFileInfo->fOverwrite = kFALSE;
417  DeleteWindow();
418  break;
419 
420  case kIDF_CANCEL:
421  if (fFileInfo->fFilename)
422  delete [] fFileInfo->fFilename;
423  fFileInfo->fFilename = 0;
424  if (fFc->GetDisplayStat())
425  fFc->SetDisplayStat(kFALSE);
426  if (fFileInfo->fFileNamesList != 0) {
427  fFileInfo->fFileNamesList->Delete();
428  fFileInfo->fFileNamesList = 0;
429  }
430  DeleteWindow();
431  return kTRUE; //no need to redraw fFc
432  break;
433 
434  case kIDF_CDUP:
435  fFc->ChangeDirectory("..");
436  fTreeLB->Update(fFc->GetDirectory());
437  if (fFileInfo->fIniDir) delete [] fFileInfo->fIniDir;
438  fFileInfo->fIniDir = StrDup(fFc->GetDirectory());
439  if (strcmp(gSystem->WorkingDirectory(), fFc->GetDirectory())) {
440  gSystem->cd(fFc->GetDirectory());
441  }
442  break;
443 
444  case kIDF_NEW_FOLDER: {
445  char answer[128];
446  strlcpy(answer, "(empty)", sizeof(answer));
447  new TGInputDialog(gClient->GetRoot(), GetMainFrame(),
448  "Enter directory name:",
449  answer/*"(empty)"*/, answer);
450 
451  while (strcmp(answer, "(empty)") == 0) {
452  new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
453  "Please enter a valid directory name.",
454  kMBIconStop, kMBOk);
455  new TGInputDialog(gClient->GetRoot(), GetMainFrame(),
456  "Enter directory name:",
457  answer, answer);
458  }
459  if (strcmp(answer, "") == 0) // Cancel button was pressed
460  break;
461 
462  if (strcmp(gSystem->WorkingDirectory(), fFc->GetDirectory())) {
463  gSystem->cd(fFc->GetDirectory());
464  }
465  if (gSystem->MakeDirectory(answer) != 0)
466  new TGMsgBox(gClient->GetRoot(), GetMainFrame(), "Error",
467  TString::Format("Directory name \'%s\' already exists!", answer),
468  kMBIconStop, kMBOk);
469  else {
470  fFc->DisplayDirectory();
471  }
472  gSystem->ChangeDirectory(sdir.Data());
473  break;
474  }
475 
476  case kIDF_LIST:
477  fFv->SetViewMode(kLVList);
478  fDetails->SetState(kButtonUp);
479  break;
480 
481  case kIDF_DETAILS:
482  fFv->SetViewMode(kLVDetails);
483  fList->SetState(kButtonUp);
484  break;
485  }
486  break;
487 
488  case kCM_COMBOBOX:
489  switch (parm1) {
490  case kIDF_FSLB:
491  e = (TGTreeLBEntry*) fTreeLB->GetSelectedEntry();
492  if (e) {
493  fFc->ChangeDirectory(e->GetPath()->GetString());
494  fTreeLB->Update(fFc->GetDirectory());
495  if (fFileInfo->fIniDir) delete [] fFileInfo->fIniDir;
496  fFileInfo->fIniDir = StrDup(fFc->GetDirectory());
497  if (strcmp(gSystem->WorkingDirectory(), fFc->GetDirectory())) {
498  gSystem->cd(fFc->GetDirectory());
499  }
500  }
501  break;
502 
503  case kIDF_FTYPESLB:
504  te = (TGTextLBEntry*) fTypes->GetSelectedEntry();
505  if (te) {
506  //fTbfname->Clear();
507  //fTbfname->AddText(0, fFileInfo->fFileTypes[te->EntryId()+1]);
508  fFileInfo->fFileTypeIdx = te->EntryId();
509  fFc->SetFilter(fFileInfo->fFileTypes[fFileInfo->fFileTypeIdx + 1]);
510  fFc->DisplayDirectory();
511  fClient->NeedRedraw(fName);
512  }
513  break;
514  }
515  break;
516 
517  default:
518  break;
519  } // switch(GET_SUBMSG(msg))
520  break;
521 
522  case kC_CONTAINER:
523  switch (GET_SUBMSG(msg)) {
524  case kCT_ITEMCLICK:
525  if (parm1 == kButton1) {
526  if (fFc->NumSelected() > 0) {
527  if (fFileInfo->fMultipleSelection == kFALSE) {
528  TGLVEntry* e2 = (TGLVEntry*) fFc->GetNextSelected(&p);
529  if ((e2) && !R_ISDIR(((TGFileItem*)e2)->GetType())) {
530  fTbfname->Clear();
531  if (e2->GetItemName())
532  fTbfname->AddText(0, e2->GetItemName()->GetString());
533  fClient->NeedRedraw(fName);
534  }
535  }
536  else {
537  TString tmpString;
538  TList* tmp = fFc->GetSelectedItems();
539  TObjString* el;
540  TIter next(tmp);
541  if (fFileInfo->fFileNamesList != 0) {
542  fFileInfo->fFileNamesList->Delete();
543  }
544  else {
545  fFileInfo->fFileNamesList = new TList();
546  }
547  while ((el = (TObjString*) next())) {
548  char* s = gSystem->ConcatFileName(fFc->GetDirectory(),
549  el->GetString());
550  tmpString += "\"" + el->GetString() + "\" ";
551  fFileInfo->fFileNamesList->Add(new TObjString(s));
552  delete [] s;
553  }
554  fTbfname->Clear();
555  fTbfname->AddText(0, tmpString);
556  fClient->NeedRedraw(fName);
557  }
558  }
559  }
560  break;
561 
562  case kCT_ITEMDBLCLICK:
563 
564  if (parm1 == kButton1) {
565  if (fFc->NumSelected() == 1) {
566  f = (TGFileItem*) fFc->GetNextSelected(&p);
567  if (f && R_ISDIR(f->GetType())) {
568  fFc->ChangeDirectory(f->GetItemName()->GetString());
569  fTreeLB->Update(fFc->GetDirectory());
570  if (fFileInfo->fIniDir) delete [] fFileInfo->fIniDir;
571  fFileInfo->fIniDir = StrDup(fFc->GetDirectory());
572  if (strcmp(gSystem->WorkingDirectory(), fFc->GetDirectory())) {
573  gSystem->cd(fFc->GetDirectory());
574  }
575  }
576  else {
577  if (!strcmp(fOk->GetTitle(), "Save") &&
578  (!(fCheckB->GetState() == kButtonDown))) {
579 
580  Int_t ret;
581  txt = TString::Format("File name %s already exists, OK to overwrite it?",
582  fTbfname->GetString());
584  "File Name Exist", txt.Data(), kMBIconExclamation,
585  kMBYes | kMBNo, &ret);
586  if (ret == kMBNo)
587  return kTRUE;
588  }
589  if (fFileInfo->fFilename)
590  delete [] fFileInfo->fFilename;
591  if (gSystem->IsAbsoluteFileName(fTbfname->GetString()))
592  fFileInfo->fFilename = StrDup(fTbfname->GetString());
593  else
594  fFileInfo->fFilename = gSystem->ConcatFileName(fFc->GetDirectory(),
595  fTbfname->GetString());
596  fFileInfo->fFilename = StrDup(gSystem->UnixPathName(gSystem->ExpandPathName(fFileInfo->fFilename)));
597  if (fCheckB && (fCheckB->GetState() == kButtonDown))
598  fFileInfo->fOverwrite = kTRUE;
599  else
600  fFileInfo->fOverwrite = kFALSE;
601 
602  DeleteWindow();
603  }
604  }
605  }
606 
607  break;
608 
609  default:
610  break;
611 
612  } // switch(GET_SUBMSG(msg))
613  break;
614 
615  case kC_TEXTENTRY:
616  switch (GET_SUBMSG(msg)) {
617  case kTE_ENTER:
618  // same code as under kIDF_OK
619  if ((fDlgMode != kKVFDDirectory) && (fTbfname->GetTextLength() == 0)) {
620  const char* txt2 = "Please provide file name or use \"Cancel\"";
622  "Missing File Name", txt2, kMBIconExclamation,
623  kMBOk);
624  return kTRUE;
625  }
626  else if (!gSystem->AccessPathName(fTbfname->GetString(), kFileExists)) {
627  FileStat_t buf;
628  if (!gSystem->GetPathInfo(fTbfname->GetString(), buf) &&
629  R_ISDIR(buf.fMode)) {
630  fFc->ChangeDirectory(fTbfname->GetString());
631  fTreeLB->Update(fFc->GetDirectory());
632  if (strcmp(gSystem->WorkingDirectory(), fFc->GetDirectory())) {
633  gSystem->cd(fFc->GetDirectory());
634  }
635  fName->SetText("", kFALSE);
636  return kTRUE;
637  }
638  else if (!strcmp(fOk->GetTitle(), "Save") &&
639  (!(fCheckB->GetState() == kButtonDown))) {
640  Int_t ret;
641  txt = TString::Format("File name %s already exists, OK to overwrite it?",
642  fTbfname->GetString());
644  "File Name Exist", txt.Data(), kMBIconExclamation,
645  kMBYes | kMBNo, &ret);
646  if (ret == kMBNo)
647  return kTRUE;
648  }
649  }
650  if (fFileInfo->fFilename)
651  delete [] fFileInfo->fFilename;
652  fFileInfo->fFilename = gSystem->ConcatFileName(fFc->GetDirectory(),
653  fTbfname->GetString());
654  fFileInfo->fFilename = StrDup(gSystem->UnixPathName(gSystem->ExpandPathName(fFileInfo->fFilename)));
655  if (fCheckB && (fCheckB->GetState() == kButtonDown))
656  fFileInfo->fOverwrite = kTRUE;
657  else
658  fFileInfo->fOverwrite = kFALSE;
659  DeleteWindow();
660  break;
661 
662  default:
663  break;
664  }
665  break;
666 
667  default:
668  break;
669 
670  } // switch(GET_MSG(msg))
671 
672  fClient->NeedRedraw(fFc);
673  return kTRUE;
674 }
675 
676 
int Int_t
unsigned int UInt_t
long Long_t
kFixedWidth
kHorizontalFrame
kButton1
#define f(i)
#define e(i)
size_t size(const MatrixT &matrix)
bool Bool_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
kButtonDown
kButtonUp
kButtonEngaged
#define gClient
kSortByName
EFileFialog
kIDF_OK
kIDF_FTYPESLB
kIDF_FSLB
kIDF_CDUP
kIDF_DETAILS
kIDF_NEW_FOLDER
kIDF_CHECKB
kIDF_LIST
kIDF_CANCEL
kMWMDecorResizeH
kMWMFuncAll
kMWMFuncResize
kMWMDecorMaximize
kMWMDecorMinimize
kMWMDecorMenu
kMWMDecorAll
kMWMFuncMaximize
kMWMInputModeless
kMWMFuncMinimize
kDeepCleanup
kLHintsRight
kLHintsExpandY
kLHintsLeft
kLHintsCenterY
kLHintsTop
kLHintsExpandX
kLVDetails
kLVList
kMBNo
kMBYes
kMBOk
kMBIconExclamation
kMBIconStop
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
Option_t Option_t width
char * StrDup(const char *str)
kFileExists
Bool_t R_ISDIR(Int_t mode)
R__EXTERN TSystem * gSystem
Int_t GET_MSG(Long_t val)
kCM_COMBOBOX
kTE_ENTER
kCT_ITEMCLICK
kC_COMMAND
kCM_BUTTON
kC_TEXTENTRY
kCT_ITEMDBLCLICK
kC_CONTAINER
Int_t GET_SUBMSG(Long_t val)
Modified version of TGFileDialog file selection dialog.
Definition: KVFileDialog.h:49
virtual ~KVFileDialog()
Delete file dialog.
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2) override
Process messages generated by the user input in the file dialog.
void CloseWindow() override
virtual EButtonState GetState() const
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
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)
Bool_t GetDisplayStat()
const char * GetDirectory() const
TList * fFileNamesList
char * fFilename
Int_t fFileTypeIdx
const char ** fFileTypes
char * fIniDir
Bool_t fOverwrite
Bool_t fMultipleSelection
virtual void Resize(TGDimension size)
virtual void DeleteWindow()
Int_t EntryId() const
TList * GetSelectedItems()
TGString * GetItemName() const
virtual void SetViewMode(EListViewMode viewMode)
TGClient * fClient
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
static TString Format(const char *fmt,...)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) 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()
int main(int argc, char **argv)
void Error(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:116
Type GetType(const std::string &Name)
Double_t Max(Double_t a, Double_t b)
ClassImp(TPyArg)