Improved the display_text_file(): moved to text.cpp and made it more independent.
[supertux.git] / src / text.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #ifndef SUPERTUX_TEXT_H
22 #define SUPERTUX_TEXT_H
23
24 #include "texture.h"
25
26 void display_text_file(char *file, char* surface);
27 void display_text_file(char *file, Surface* surface);
28
29 /* Kinds of texts. */
30 enum {
31    TEXT_TEXT,
32    TEXT_NUM
33 };
34
35 enum TextHAlign {
36    A_LEFT,
37    A_HMIDDLE,
38    A_RIGHT,
39 };
40
41 enum TextVAlign {
42    A_TOP,
43    A_VMIDDLE,
44    A_BOTTOM,
45 };
46
47 /* Text type */
48 class Text
49 {
50  public:
51   Surface* chars;
52   Surface* shadow_chars;
53   int kind;
54   int w;
55   int h;
56  public:
57   Text(const std::string& file, int kind, int w, int h);
58   ~Text();
59
60   void draw(const char* text, int x, int y, int shadowsize = 1, int update = NO_UPDATE);
61   void draw_chars(Surface* pchars, const char* text, int x, int y, int update = NO_UPDATE);
62   void drawf(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE);
63   void draw_align(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize = 1, int update = NO_UPDATE);
64   void erasetext(const char * text, int x, int y, Surface* surf, int update, int shadowsize);
65   void erasecenteredtext(const char * text, int y, Surface* surf, int update, int shadowsize);
66 };
67
68 #endif /*SUPERTUX_TEXT_H*/
69