Exemplo n.º 1
0
//! The write filename callback
void FileDialog::writeFilename(GuiElement* elem){
  FileDialog* dia = dynamic_cast<FileDialog*>(elem->getParent());
  InputField* inp = dynamic_cast<InputField*>(dia->getElement(2));
  ListBox* files = dynamic_cast<ListBox*>(dia->getElement(1));
  string file = files->selectedItem();
  inp->setText(file);
}
Exemplo n.º 2
0
//! The change directory callback
void FileDialog::changeDir(GuiElement* elem){
  Dialog* dia = dynamic_cast<Dialog*>(elem->getParent());
  ListBox* dirs = dynamic_cast<ListBox*>(dia->getElement(0));
  string dir = dirs->selectedItem();
  //collapse path when .. is chosen and the situation is appropriate
  if (dir == ".." && path_.length() > 1 && path_[path_.length()-1] != '.'){
    size_t n = path_.find_last_of(SEPARATOR);
    if (n != path_.npos)
      path_.erase(n);
    else
      path_ += ".";
  }
  else
    path_ += SEPARATOR+dir;
  dirs->clear();
  dirs->addEntries(Filesystem::getDirectories(cwd_+SEPARATOR+path_));
  //update file list
  ListBox* files = dynamic_cast<ListBox*>(dia->getElement(1));
  files->clear();
  files->addEntries(Filesystem::getFiles(cwd_+SEPARATOR+path_));
}