Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FILEBROWSER_INCLUDED
Toshihiro Shimizu 890ddd
#define FILEBROWSER_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tw/tw.h"
Toshihiro Shimizu 890ddd
#include "tfilepath.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class GenericFileBrowserAction {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  virtual ~GenericFileBrowserAction() {}
Shinya Kitaoka 120a6e
  virtual void sendCommand(const TFilePath &) = 0;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
template <class t=""></class>
Shinya Kitaoka 120a6e
class FileBrowserAction : public GenericFileBrowserAction {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef void (T::*Method)(const TFilePath &);
Shinya Kitaoka 120a6e
  FileBrowserAction(T *target, Method method)
Shinya Kitaoka 120a6e
      : m_target(target), m_method(method) {}
Shinya Kitaoka 120a6e
  void sendCommand(const TFilePath &fp) { (m_target->*m_method)(fp); }
Shinya Kitaoka 120a6e
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  T *m_target;
Shinya Kitaoka 120a6e
  Method m_method;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class FileBrowser : public TWidget {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FileBrowser(TWidget *parent, string name, const vector<string> &fileTypes);</string>
Shinya Kitaoka 120a6e
  ~FileBrowser();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setFilter(const vector<string> &fileTypes);</string>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void configureNotify(const TDimension &d);
Shinya Kitaoka 120a6e
  void setBackgroundColor(const TGuiColor &);
Shinya Kitaoka 120a6e
  void draw();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setFileSelChangeAction(GenericFileBrowserAction *action);
Shinya Kitaoka 120a6e
  void setFileDblClickAction(GenericFileBrowserAction *action);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFilePath getCurrentDir() const;
Shinya Kitaoka 120a6e
  void setCurrentDir(const TFilePath &dirPath);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void selectParentDirectory();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  class Data;
Shinya Kitaoka 120a6e
  Data *m_data;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif