Homepage | Demos | Overview | Downloads | Tutorials | Reference | Credits |
00001 //-*-c++-*- 00002 #ifndef INCLUDED_FileBrowserControl_h_ 00003 #define INCLUDED_FileBrowserControl_h_ 00004 00005 #include "ControlBase.h" 00006 #include <string> 00007 #include <vector> 00008 00009 //! Displays the contents of a directory in a control menu, probably useful as a baseclass for other controls 00010 /*! Causes the selectedFile() function to be called on the root FileBrowserControl with the selected file */ 00011 class FileBrowserControl : public ControlBase { 00012 public: 00013 //!@name Constructors/Destructors 00014 //!constructor 00015 FileBrowserControl() : ControlBase(), recurse(true), root(), paths(), filter("*") {init("");} 00016 //!constructor pass name and root path 00017 FileBrowserControl(const std::string& nm, const std::string& desc, const std::string& path) : ControlBase(nm,desc), recurse(true), root(), paths(), filter("*") { init(path); } 00018 //@} 00019 00020 //!@name ControlBase Inheritance 00021 virtual ControlBase * activate(MotionManager::MC_ID display, Socket * gui); 00022 virtual ControlBase* doSelect(); 00023 //@} 00024 00025 //!@name Accessors 00026 void setRecurse(bool r) { recurse=r; } //!< sets #recurse 00027 bool getRecurse() const { return recurse; } //!< returns #recurse 00028 00029 void setRoot(const std::string& path); //!< sets #root 00030 std::string getRoot() const { return root; } //!< returns #root 00031 00032 void setPath(const std::string& path); //!< sets #paths 00033 00034 void setFilter(const std::string& filt) {filter=filt;} //!< sets #filter; remember can only use one wildcard, e.g. *.ext or filename.ext or filename* 00035 //@} 00036 00037 protected: 00038 00039 //! the big money function - by default calls the parent if it exists, otherwise nothing 00040 /*! returning NULL means deactivate, this (default) to stay put, or a different Control if you want a submenu */ 00041 virtual ControlBase* selectedFile(const std::string&) { return this; } 00042 00043 //! returns the path from root as a string, with no trailing '/' 00044 std::string makePath(); 00045 00046 //! returns the path from root as a string, appends filename 00047 std::string makePath(const std::string& filename); 00048 00049 //! returns true if @a file matches @a filt 00050 static bool match(const std::string& file, const std::string& filt); 00051 00052 //!rescans current directory and builds menus 00053 void rebuildmenu(); 00054 00055 //!sets a junk menu item to mark this as having submenus, and sets root to path 00056 void init(std::string path) { pushSlot(NULL); setRoot(path); } 00057 00058 bool recurse; //!< if true (default), will show directories; if false, subdirectories are hidden 00059 std::string root; //!< the path to browse, default "/" 00060 std::vector<std::string> paths; //!< list of directories from root 00061 00062 std::string filter; //!< default "*", only display matching files; only can use one wildcard, e.g. *.ext or filename.ext or filename* 00063 00064 private: 00065 // FileBrowserControl(const FileBrowserControl& ); //!< don't call 00066 // FileBrowserControl& operator=(const FileBrowserControl& ); //!< don't call 00067 }; 00068 00069 /*! @file 00070 * @brief Describes FileBrowserControl, which displays the contents of a directory 00071 * @author ejt (Creator) 00072 * 00073 * $Author: ejt $ 00074 * $Name: tekkotsu-1_4_1 $ 00075 * $Revision: 1.7 $ 00076 * $State: Exp $ 00077 * $Date: 2003/06/10 00:53:48 $ 00078 */ 00079 00080 #endif
Tekkotsu v1.4 |
Generated Sat Jul 19 00:06:30 2003 by Doxygen 1.3.2 |