FIFE 2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_GUICHAN_ADDON_COMMANDLINE_H 00023 #define FIFE_GUICHAN_ADDON_COMMANDLINE_H 00024 00025 // Standard C++ library includes 00026 #include <string> 00027 #include <vector> 00028 00029 // 3rd party library includes 00030 #include <boost/function.hpp> 00031 #include <guichan.hpp> 00032 00033 // FIFE includes 00034 // These includes are split up in two parts, separated by one empty line 00035 // First block: files included from the FIFE root src directory 00036 // Second block: files included from the same folder 00037 #include "util/time/timer.h" 00038 #include "gui/widgets/utf8textfield.h" 00039 00040 namespace FIFE { 00041 00044 class CommandLine : public gcn::UTF8TextField { 00045 public: 00046 typedef boost::function1<void,std::string> type_callback; 00047 00050 CommandLine(); 00051 00054 ~CommandLine(); 00055 00056 void keyPressed(gcn::KeyEvent& keyEvent); 00057 virtual void drawCaret(gcn::Graphics * graphics, int x); 00058 00061 void setCallback(const type_callback& cb); 00062 00065 void toggleCaretVisible(); 00066 00069 void startBlinking(); 00070 00073 void stopBlinking(); 00074 private: 00075 type_callback m_callback; 00076 std::vector<std::string> m_history; 00077 size_t m_history_position; 00078 std::string m_cmdline; 00079 bool m_caretVisible; 00080 Timer m_blinkTimer; 00081 Timer m_suppressBlinkTimer; 00082 }; 00083 } 00084 #endif 00085 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */