ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

text.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_VISUAL_TEXT_H
00024 #define STARK_VISUAL_TEXT_H
00025 
00026 #include "engines/stark/visual/visual.h"
00027 
00028 #include "engines/stark/services/fontprovider.h"
00029 
00030 #include "common/rect.h"
00031 #include "graphics/font.h"
00032 
00033 namespace Stark {
00034 
00035 namespace Gfx {
00036 class Driver;
00037 class SurfaceRenderer;
00038 class Texture;
00039 }
00040 
00041 struct Color {
00042     uint8 r;
00043     uint8 g;
00044     uint8 b;
00045     uint8 a;
00046 
00047     Color(uint8 red, uint8 green, uint8 blue, uint8 alpha = 0xFF) :
00048             r(red), g(green), b(blue), a(alpha) {}
00049 
00050     bool operator==(const Color &color) const {
00051         return r == color.r &&
00052                g == color.g &&
00053                b == color.b &&
00054                a == color.a;
00055     }
00056 };
00057 
00061 class VisualText : public Visual {
00062 public:
00063     static const VisualType TYPE = Visual::kImageText;
00064 
00065     explicit VisualText(Gfx::Driver *gfx);
00066     ~VisualText() override;
00067 
00068     Common::Rect getRect();
00069 
00070     void setText(const Common::String &text);
00071     void setColor(const Color &color);
00072     void setBackgroundColor(const Color &color);
00073     void setAlign(Graphics::TextAlign align);
00074     void setTargetWidth(uint32 width);
00075     void setTargetHeight(uint32 height);
00076     void setFont(FontProvider::FontType type, int32 customFontIndex = -1);
00077 
00078     uint getTargetWidth() { return _targetWidth; }
00079     uint getTargetHeight() { return _targetHeight; }
00080 
00081     void render(const Common::Point &position);
00082     void resetTexture();
00083 
00084 private:
00085     void createTexture();
00086     void freeTexture();
00087 
00089     bool isBlank();
00090 
00091     Gfx::Driver *_gfx;
00092     Gfx::SurfaceRenderer *_surfaceRenderer;
00093     Gfx::Texture *_texture;
00094     Gfx::Texture *_bgTexture;
00095 
00096     Common::String _text;
00097     Color _color;
00098     Color _backgroundColor;
00099     Graphics::TextAlign _align;
00100     uint32 _targetWidth;
00101     uint32 _targetHeight;
00102     Common::Rect _originalRect;
00103 
00104     FontProvider::FontType _fontType;
00105     int32 _fontCustomIndex;
00106 };
00107 
00108 } // End of namespace Stark
00109 
00110 #endif // STARK_VISUAL_TEXT_H


Generated on Sat Sep 14 2019 05:01:27 for ResidualVM by doxygen 1.7.1
curved edge   curved edge