1 | /*! |
---|
2 | * @file shell.h |
---|
3 | * Definition of a on-screen-shell |
---|
4 | * |
---|
5 | * @todo check for smooth deletion process |
---|
6 | * @todo Buffer Display in different Colors for different debug mode. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef _SHELL_H |
---|
10 | #define _SHELL_H |
---|
11 | |
---|
12 | #include "element_2d.h" |
---|
13 | #include "event_listener.h" |
---|
14 | |
---|
15 | #include <stdarg.h> |
---|
16 | |
---|
17 | // FORWARD DECLARATION |
---|
18 | class Text; |
---|
19 | class ShellInput; |
---|
20 | class ShellCommandBase; |
---|
21 | template<class T> class tList; |
---|
22 | template<class T> class tIterator; |
---|
23 | |
---|
24 | //! A class that is able to redirect all output to a openGL-Shell, and that one can use to input some commands |
---|
25 | /** |
---|
26 | * the major idea is, that all the Output can be redirected to the Shell, |
---|
27 | * and does not have to be displayed to the opening Shell, this is good, |
---|
28 | * for developers using Windows, where all output is otherwise redirected |
---|
29 | * to stdout.txt |
---|
30 | * |
---|
31 | * Furthermore the Shell should enable us, to input some simple commands |
---|
32 | * Each Class can tell check itself in to the Shell, and listen for commands. |
---|
33 | * |
---|
34 | * @todo implement what is written above :/ |
---|
35 | */ |
---|
36 | class Shell : public Element2D, public EventListener { |
---|
37 | |
---|
38 | public: |
---|
39 | Shell(); |
---|
40 | virtual ~Shell(); |
---|
41 | |
---|
42 | void activate(); |
---|
43 | void deactivate(); |
---|
44 | /** @returns true if the Shell is active, false otherwise. */ |
---|
45 | inline bool isActive() const { return this->bActive; }; |
---|
46 | |
---|
47 | void setTextSize(unsigned int textSize, unsigned int lineSpacing = 1); |
---|
48 | void rebuildText(); |
---|
49 | |
---|
50 | // BUFFERS |
---|
51 | void setBufferDisplaySize(unsigned int bufferDisplaySize); |
---|
52 | void printToDisplayBuffer(const char* text); |
---|
53 | void flush(); |
---|
54 | |
---|
55 | void clear(); |
---|
56 | |
---|
57 | // EventListener |
---|
58 | virtual void process(const Event &event); |
---|
59 | // Element2D-functions |
---|
60 | virtual void draw() const; |
---|
61 | |
---|
62 | void debug() const; |
---|
63 | |
---|
64 | private: |
---|
65 | // helpers // |
---|
66 | Vector calculateLinePosition(unsigned int lineNumber); |
---|
67 | |
---|
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); |
---|
73 | |
---|
74 | private: |
---|
75 | |
---|
76 | // GENERAL |
---|
77 | bool bActive; //!< if the shell is active; |
---|
78 | unsigned int shellHeight; //!< The hight of the Shell in Pixels |
---|
79 | unsigned int lineSpacing; //!< The Spacing between lines. |
---|
80 | unsigned int textSize; //!< The size of the text. |
---|
81 | char* textFont; //!< The file containing the font. |
---|
82 | |
---|
83 | // HANDLING TEXT INPUT |
---|
84 | ShellInput* shellInput; //!< The inputLine of the Shell. |
---|
85 | // BUFFER |
---|
86 | unsigned int bufferDisplaySize; //!< The Size of the Display-buffer, in lines (not in characters) |
---|
87 | Text** bufferText; //!< A list of stored bufferTexts for the display of the buffer |
---|
88 | }; |
---|
89 | |
---|
90 | #endif /* _SHELL_H */ |
---|