1 /*
2  * This file is part of TONG.              http://www.nongnu.org/tong
3  * Copyright 2004, 2007 Owen Swerkstrom
4  *
5  * TONG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * Tong is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __TEXT_H__
20 #define __TEXT_H__
21 
22 class Text;
23 class Menu;
24 
25 #include <stdlib.h>
26 #include <string.h>
27 
28 #include "SDL.h"
29 #include "SDL_image.h"
30 #include "option.h"
31 
32 #ifdef GP2X
33 #define TEXTWIDTH  8
34 #define TEXTHEIGHT 16
35 #define MENUTILE   16
36 #else
37 #define TEXTWIDTH  16
38 #define TEXTHEIGHT 32
39 #define MENUTILE   32
40 #endif
41 
42 #define NORMAL      0
43 #define HIGHLIGHTED (3 * TEXTHEIGHT)
44 #define DISABLED    (6 * TEXTHEIGHT)
45 
46 
47 class Text {
48  private:
49 	int x, y;
50 	char* text;
51 	SDL_Rect destrect;
52 	SDL_Surface* textbits;
53 	void LoadGraphics();
54  public:
55 	Text();
56 	~Text();
57 	void SetText(const char*);
58 	void SetX(int);
59 	void SetY(int);
60 	int GetLines();
61 	void Init(int, int, const char*);
62 	void Draw(SDL_Surface*);
63 };
64 
65 class Menu {
66  private:
67 	char* content;
68 	int* states;
69 	int x, y;
70 	int boxesw, boxesh;
71 	unsigned int choices, current;
72 	bool active;
73 	SDL_Rect destrect;
74 	SDL_Surface* textbits;
75 	SDL_Surface* menubits;
76 	void CalcArea();
77 	void LoadGraphics();
78  public:
79 	Menu();
80 	~Menu();
81 	bool IsActive();
82 	void SetActive(bool);
83 	void AddChoice(const char*, int);
84 	bool ModChoice(const char*, unsigned int);
85 	bool MoveCursor(int);
86 	int GetState(int);
87 	bool SetState(int, int);
88 	int GetChoice();
89 	void SetChoice(int);
90 	int NumChoices();
91 	void SetPos(int, int);
92 	void Draw(SDL_Surface*);
93 };
94 
95 
96 #endif
97