console.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_GUICHAN_ADDON_CONSOLE_H
00023 #define FIFE_GUICHAN_ADDON_CONSOLE_H
00024
00025
00026 #include <string>
00027
00028
00029 #include <guichan.hpp>
00030
00031
00032
00033
00034
00035 #include "util/time/timer.h"
00036
00037 namespace FIFE {
00038
00039 class CommandLine;
00040 class GuiFont;
00041
00045 class ConsoleExecuter {
00046 public:
00049 virtual ~ConsoleExecuter() {}
00050
00053 virtual void onToolsClick() = 0;
00054
00058 virtual std::string onConsoleCommand(const std::string& command) = 0;
00059 };
00060
00061
00064 class Console : public gcn::Container, public gcn::ActionListener, public gcn::FocusListener {
00065 public:
00068 Console();
00069
00072 virtual ~Console();
00073
00076 void println(const std::string & s);
00077
00083 void show();
00084
00089 void hide();
00090
00093 void clear();
00094
00099 void toggleShowHide();
00100
00109 void execute(std::string cmd);
00110
00114 void updateCaption();
00115
00119 void updateAnimation();
00120
00123 void action(const gcn::ActionEvent & event);
00124
00127 void setConsoleExecuter(ConsoleExecuter* const consoleexec);
00128
00131 void removeConsoleExecuter();
00132
00135 void reLayout();
00136
00139 void setIOFont(GuiFont* font);
00140
00143 void focusLost(const gcn::Event& event);
00144 private:
00145
00146 bool m_isAttached;
00147 ConsoleExecuter* m_consoleexec;
00148
00149 CommandLine* m_input;
00150 gcn::TextBox* m_output;
00151 gcn::ScrollArea* m_outputscrollarea;
00152 gcn::Label* m_status;
00153 gcn::Button* m_toolsbutton;
00154 static const unsigned m_maxOutputRows;
00155
00156 std::string m_prompt;
00157
00158 int m_hiddenPos;
00159 int m_animationDelta;
00160
00161 bool m_hiding;
00162
00163 Timer m_fpsTimer;
00164 Timer m_animationTimer;
00165
00166 void doShow();
00167 void doHide();
00168 };
00169 }
00170 #endif
00171