[4838] | 1 | /*! |
---|
[5068] | 2 | * @file shell.h |
---|
| 3 | * Definition of a on-screen-shell |
---|
[3245] | 4 | */ |
---|
[1853] | 5 | |
---|
[5068] | 6 | #ifndef _SHELL_H |
---|
| 7 | #define _SHELL_H |
---|
[1853] | 8 | |
---|
[5068] | 9 | #include "element_2d.h" |
---|
[5069] | 10 | #include "event_listener.h" |
---|
[1853] | 11 | |
---|
[5068] | 12 | #include <stdarg.h> |
---|
| 13 | |
---|
[4838] | 14 | // FORWARD DECLARATION |
---|
[5068] | 15 | class Text; |
---|
[5179] | 16 | class ShellInput; |
---|
[5141] | 17 | class ShellCommandBase; |
---|
[5068] | 18 | template<class T> class tList; |
---|
[5118] | 19 | template<class T> class tIterator; |
---|
[3543] | 20 | |
---|
[5068] | 21 | //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands |
---|
| 22 | /** |
---|
| 23 | * the major idea is, that all the Output can be redirected to the Shell, |
---|
| 24 | * and does not have to be displayed to the opening Shell, this is good, |
---|
| 25 | * for developers using Windows, where all output is otherwise redirected |
---|
| 26 | * to stdout.txt |
---|
| 27 | * |
---|
| 28 | * Furthermore the Shell should enable us, to input some simple commands |
---|
| 29 | * Each Class can tell check itself in to the Shell, and listen for commands. |
---|
| 30 | * |
---|
| 31 | * @todo implement what is written above :/ |
---|
| 32 | */ |
---|
[5069] | 33 | class Shell : public Element2D, public EventListener { |
---|
[3543] | 34 | |
---|
[5068] | 35 | public: |
---|
| 36 | virtual ~Shell(); |
---|
| 37 | /** @returns a Pointer to the only object of this Class */ |
---|
[5072] | 38 | inline static Shell* getInstance() { if (!Shell::singletonRef) Shell::singletonRef = new Shell(); return Shell::singletonRef; }; |
---|
[5175] | 39 | /** @returns true if this class is instanciated, false otherwise */ |
---|
[5176] | 40 | inline static bool isInstanciated() { return (Shell::singletonRef == NULL)?false:true; }; |
---|
[2036] | 41 | |
---|
[5113] | 42 | void activate(); |
---|
| 43 | void deactivate(); |
---|
[5176] | 44 | inline bool isActive() const { return this->bActive; }; |
---|
[1853] | 45 | |
---|
[5113] | 46 | void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1); |
---|
| 47 | void rebuildText(); |
---|
[3245] | 48 | |
---|
[5175] | 49 | // BUFFERS |
---|
[5176] | 50 | void flush(); |
---|
[5113] | 51 | void setBufferDisplaySize(unsigned int bufferDisplaySize); |
---|
[5118] | 52 | void printToDisplayBuffer(const char* text); |
---|
[3245] | 53 | |
---|
[5130] | 54 | void clear(); |
---|
| 55 | |
---|
[5069] | 56 | // EventListener |
---|
| 57 | virtual void process(const Event &event); |
---|
| 58 | |
---|
[5068] | 59 | // Element2D-functions |
---|
| 60 | virtual void draw() const; |
---|
| 61 | |
---|
| 62 | void debug() const; |
---|
| 63 | |
---|
| 64 | private: |
---|
| 65 | |
---|
[5120] | 66 | // helpers // |
---|
| 67 | Vector calculateLinePosition(unsigned int lineNumber); |
---|
[5166] | 68 | // void testI (int i); |
---|
| 69 | // void testS (const char* s); |
---|
| 70 | // void testB (bool b); |
---|
| 71 | // void testF (float f); |
---|
| 72 | // void testSF (const char* s, float f); |
---|
[5113] | 73 | |
---|
[5068] | 74 | private: |
---|
| 75 | Shell(); |
---|
[5129] | 76 | static Shell* singletonRef; //!< The singleton-reference to the only memeber of this class. |
---|
[5068] | 77 | |
---|
[5180] | 78 | // GENERAL |
---|
| 79 | bool bActive; //!< if the shell is active; |
---|
| 80 | unsigned int shellHeight; //!< The hight of the Shell in Pixels |
---|
| 81 | unsigned int lineSpacing; //!< The Spacing between lines. |
---|
| 82 | unsigned int textSize; //!< The size of the text. |
---|
[5068] | 83 | |
---|
[5175] | 84 | // HANDLING TEXT INPUT |
---|
[5179] | 85 | ShellInput* shellInput; |
---|
[5180] | 86 | // BUFFER |
---|
| 87 | unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters) |
---|
[5129] | 88 | Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer |
---|
[1853] | 89 | }; |
---|
| 90 | |
---|
[5068] | 91 | #endif /* _SHELL_H */ |
---|