Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/shell/shell.h @ 5204

Last change on this file since 5204 was 5204, checked in by bensch, 19 years ago

orxonox/trunk: Shell now has a real nice help function

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