Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
StringInputControl.hGo to the documentation of this file.00001 //-*-c++-*- 00002 #ifndef INCLUDED_StringInputControl_h_ 00003 #define INCLUDED_StringInputControl_h_ 00004 00005 #include "ControlBase.h" 00006 #include <string> 00007 00008 //! Upon activation, prompts the user for a string and stores it 00009 class StringInputControl : public ControlBase { 00010 public: 00011 //! Constructor 00012 StringInputControl(const std::string& n, const std::string& prompt) : ControlBase(n,prompt), lastInput(), userPrompt(prompt) {} 00013 //! Constructor 00014 StringInputControl(const std::string& n, const std::string& desc, const std::string& prompt) : ControlBase(n,desc), lastInput(), userPrompt(prompt) {} 00015 00016 // virtual ControlBase* activate(MC_ID disp_id, Socket* gui); 00017 00018 virtual void refresh(); 00019 00020 virtual ControlBase* doReadStdIn(const std::string& prompt/*=std::string()*/); 00021 00022 virtual ControlBase * takeInput(const std::string& msg) { 00023 lastInput=msg; 00024 return NULL; 00025 } 00026 00027 //! returns last call to takeInput() 00028 virtual const std::string& getLastInput() const { return lastInput; } 00029 00030 //! clears the last input (i.e. so you can easily tell later if new input is entered) 00031 virtual void clearLastInput() { takeInput(""); } 00032 00033 //! sets the prompt to give to the user 00034 virtual void setPrompt(const std::string& prompt) { userPrompt=prompt; } 00035 00036 protected: 00037 std::string lastInput; //!< stores the last input to takeInput() 00038 std::string userPrompt; //!< stores the prompt to send out 00039 }; 00040 00041 /*! @file 00042 * @brief Defines StringInputControl, which prompts for and stores a string from the user 00043 * @author ejt (Creator) 00044 */ 00045 00046 #endif |
Tekkotsu v5.1CVS |
Generated Mon May 9 04:58:51 2016 by Doxygen 1.6.3 |