Control: Change controls to use new callback infrastrucure.
[gemrb.git] / gemrb / core / Console.h
blob0add912bd12b5cf7e5905f912b943ac7c2d19508
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * @file Console.h
23 * Declares Console widget, input field for direct poking into GemRB innards.
24 * @author The GemRB Project
27 #ifndef CONSOLE_H
28 #define CONSOLE_H
30 #include "Control.h"
31 #include "TextArea.h"
33 class Palette;
35 /**
36 * @class Console
37 * Widget displaying debugging console, input field for direct poking
38 * into GemRB innards.
39 * The console accepts and executes python statements and has already
40 * GemRB python module loaded, so almost any command
41 * from GUIScripts can be used.
44 /** the number of remembered lines in the cheat console*/
45 #define HISTORY_SIZE 5
47 class Console : public Control {
48 public:
49 Console(void);
50 ~Console(void);
51 /** Draws the Console on the Output Display */
52 void Draw(unsigned short x, unsigned short y);
53 /** Set Font */
54 void SetFont(Font* f);
55 /** Set Cursor */
56 void SetCursor(Sprite2D* cur);
57 /** Set BackGround */
58 void SetBackGround(Sprite2D* back);
59 /** Sets the Text of the current control */
60 int SetText(const char* string, int pos = 0);
61 private:
62 /** Text Editing Cursor Sprite */
63 Sprite2D* Cursor;
64 /** Text Font */
65 Font* font;
66 /** Background */
67 Sprite2D* Back;
68 /** Max Edit Text Length */
69 unsigned short max;
70 /** Text Buffer */
71 unsigned char* Buffer;
72 /** History Buffer */
73 unsigned char* History[HISTORY_SIZE];
74 /** Cursor Position */
75 unsigned short CurPos;
76 /** History Position and size */
77 unsigned short HistPos, HistMax;
78 /** Color Palette */
79 Palette* palette;
81 public: //Events
82 /** Key Press Event */
83 void OnKeyPress(unsigned char Key, unsigned short Mod);
84 /** Special Key Press */
85 void OnSpecialKeyPress(unsigned char Key);
86 bool SetEvent(int eventType, EventHandler handler);
87 private:
88 void HistoryBack();
89 void HistoryForward();
90 void HistoryAdd(bool force);
93 #endif