src/object/text_object.hpp

Go to the documentation of this file.
00001 //  SuperTux
00002 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
00003 //
00004 //  This program is free software: you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation, either version 3 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 
00017 #ifndef HEADER_SUPERTUX_OBJECT_TEXT_OBJECT_HPP
00018 #define HEADER_SUPERTUX_OBJECT_TEXT_OBJECT_HPP
00019 
00020 #include "object/anchor_point.hpp"
00021 #include "scripting/text.hpp"
00022 #include "supertux/game_object.hpp"
00023 #include "supertux/script_interface.hpp"
00024 #include "video/color.hpp"
00025 #include "video/font_ptr.hpp"
00026 
00028 class TextObject : public GameObject, 
00029                    public scripting::Text,
00030                    public ScriptInterface
00031 {
00032   static Color default_color;
00033 public:
00034   TextObject(std::string name = "");
00035   virtual ~TextObject();
00036 
00037   void expose(HSQUIRRELVM vm, SQInteger table_idx);
00038   void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
00039 
00040   void set_text(const std::string& text);
00041   void set_font(const std::string& name);
00042   void fade_in(float fadetime);
00043   void fade_out(float fadetime);
00044   void set_visible(bool visible);
00045   void set_centered(bool centered);
00046   bool is_visible();
00047 
00048   void set_anchor_point(AnchorPoint anchor) {
00049     this->anchor = anchor;
00050   }
00051   AnchorPoint get_anchor_point() const {
00052     return anchor;
00053   }
00054 
00055   void set_pos(const Vector& pos) {
00056     this->pos = pos; 
00057   } 
00058   void set_pos(float x, float y) {
00059     set_pos(Vector(x, y));
00060   }
00061   const Vector& get_pos() const {
00062     return pos; 
00063   }
00064   float get_pos_x() {
00065     return pos.x;
00066   }
00067   float get_pos_y() {
00068     return pos.y;
00069   }
00070 
00071   void set_anchor_point(int anchor) {
00072     set_anchor_point((AnchorPoint) anchor);
00073   }
00074   int get_anchor_point() {
00075     return (int) get_anchor_point();
00076   }
00077 
00078   void draw(DrawingContext& context);
00079   void update(float elapsed_time);
00080 
00081 private:
00082   FontPtr font;
00083   std::string text;
00084   float fading;
00085   float fadetime;
00086   bool visible;
00087   bool centered;
00088   AnchorPoint anchor;
00089   Vector pos;
00090 
00091 private:
00092   TextObject(const TextObject&);
00093   TextObject& operator=(const TextObject&);
00094 };
00095 
00096 #endif
00097 
00098 /* EOF */

Generated on Mon Jun 9 03:38:20 2014 for SuperTux by  doxygen 1.5.1