-converted remaining classes to GameObject
[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 <string>
25 #include "texture.h"
26 #include "vector.h"
27
28 void display_text_file(const std::string& file, const std::string& surface, float scroll_speed);
29 void display_text_file(const std::string& file, Surface* surface, float scroll_speed);
30
31 /* Kinds of texts. */
32 enum {
33    TEXT_TEXT,
34    TEXT_NUM
35 };
36
37 enum TextHAlign {
38    A_LEFT,
39    A_HMIDDLE,
40    A_RIGHT,
41 };
42
43 enum TextVAlign {
44    A_TOP,
45    A_VMIDDLE,
46    A_BOTTOM,
47 };
48
49 /* Text type */
50 class Text
51 {
52  public:
53   Surface* chars;
54   Surface* shadow_chars;
55   int kind;
56   int w;
57   int h;
58  public:
59   Text(const std::string& file, int kind, int w, int h);
60   ~Text();
61
62   void draw(const char* text, int x, int y, int shadowsize = 1, int update = NO_UPDATE);
63   void draw_chars(Surface* pchars, const char* text, int x, int y, int update = NO_UPDATE);
64   void drawf(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize, int update = NO_UPDATE);
65   void draw_align(const char* text, int x, int y, TextHAlign halign, TextVAlign valign, int shadowsize = 1, int update = NO_UPDATE);
66   void erasetext(const char * text, int x, int y, Surface* surf, int update, int shadowsize);
67   void erasecenteredtext(const char * text, int y, Surface* surf, int update, int shadowsize);
68
69   /// conveniance function
70   void draw(const char* text, const Vector& pos, int shadowsize = 1, int update
71       = NO_UPDATE)
72   {
73     draw(text, int(pos.x), int(pos.y), shadowsize, update);
74   }
75 };
76
77 #endif /*SUPERTUX_TEXT_H*/
78