tahoma2d/toonz/sources/toonzfarm/tfarmclient/filebrowser.h

59 lines
1.4 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef FILEBROWSER_INCLUDED
#define FILEBROWSER_INCLUDED
#include "tw/tw.h"
#include "tfilepath.h"
//-------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class GenericFileBrowserAction {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
virtual ~GenericFileBrowserAction() {}
virtual void sendCommand(const TFilePath &) = 0;
2016-03-19 06:57:51 +13:00
};
//-------------------------------------------------------------------
template <class T>
2016-06-15 18:43:10 +12:00
class FileBrowserAction : public GenericFileBrowserAction {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
typedef void (T::*Method)(const TFilePath &);
FileBrowserAction(T *target, Method method)
: m_target(target), m_method(method) {}
void sendCommand(const TFilePath &fp) { (m_target->*m_method)(fp); }
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
T *m_target;
Method m_method;
2016-03-19 06:57:51 +13:00
};
//-------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
class FileBrowser : public TWidget {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FileBrowser(TWidget *parent, string name, const vector<string> &fileTypes);
~FileBrowser();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setFilter(const vector<string> &fileTypes);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void configureNotify(const TDimension &d);
void setBackgroundColor(const TGuiColor &);
void draw();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setFileSelChangeAction(GenericFileBrowserAction *action);
void setFileDblClickAction(GenericFileBrowserAction *action);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TFilePath getCurrentDir() const;
void setCurrentDir(const TFilePath &dirPath);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void selectParentDirectory();
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
class Data;
Data *m_data;
2016-03-19 06:57:51 +13:00
};
#endif