FileInputControl.h
Go to the documentation of this file.00001
00002 #ifndef INCLUDED_FileInputControl_h_
00003 #define INCLUDED_FileInputControl_h_
00004
00005 #include "FileBrowserControl.h"
00006 #include <string>
00007
00008
00009 class FileInputControl : public FileBrowserControl {
00010 public:
00011
00012 FileInputControl()
00013 : FileBrowserControl("Select file","Select a file","/"), file(NULL), myfile(), acceptNonExistant(false)
00014 {}
00015
00016
00017 FileInputControl(const std::string& nm, const std::string& desc, const std::string& path, std::string* store=NULL)
00018 : FileBrowserControl(nm,desc,path), file(store), myfile(), acceptNonExistant(false)
00019 {}
00020
00021
00022 virtual const std::string& getLastInput() { return myfile; }
00023
00024
00025 virtual void clearLastInput() { selectedFile(""); }
00026
00027
00028 virtual void setStore(std::string* store) { file=store; }
00029
00030
00031 virtual void setAcceptNonExistant(bool b) { acceptNonExistant=b; }
00032
00033 virtual bool getAcceptNonExistant() const { return acceptNonExistant; }
00034
00035 protected:
00036 virtual ControlBase* selectedFile(const std::string& f) {
00037 myfile=f;
00038 if(file!=NULL)
00039 *file=f;
00040 return NULL;
00041 }
00042 virtual ControlBase* invalidInput(const std::string& msg, bool ambiguous) {
00043 if(!acceptNonExistant)
00044 return FileBrowserControl::invalidInput(msg,ambiguous);
00045 return selectedFile(makePath(msg));
00046 }
00047
00048 std::string* file;
00049 std::string myfile;
00050 bool acceptNonExistant;
00051
00052 private:
00053 FileInputControl(const FileInputControl& );
00054 FileInputControl& operator=(const FileInputControl& );
00055 };
00056
00057
00058
00059
00060
00061
00062 #endif