OpenRCT2/src/openrct2/drawing/Text.h

70 lines
2.0 KiB
C
Raw Normal View History

2017-07-22 22:08:25 +02:00
/*****************************************************************************
2020-07-21 15:04:34 +02:00
* Copyright (c) 2014-2020 OpenRCT2 developers
2017-07-22 22:08:25 +02:00
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
2017-07-22 22:08:25 +02:00
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
2017-07-22 22:08:25 +02:00
*****************************************************************************/
#pragma once
#include "../common.h"
2021-02-27 12:49:14 +01:00
#include "../interface/Colour.h"
#include "Font.h"
struct ScreenCoordsXY;
struct rct_drawpixelinfo;
class Formatter;
2017-07-22 22:08:25 +02:00
enum class TextAlignment
{
LEFT,
CENTRE,
RIGHT
};
2021-02-26 21:11:26 +01:00
enum class TextUnderline
{
Off,
On,
};
2017-07-22 22:08:25 +02:00
struct TextPaint
{
2021-02-27 12:49:14 +01:00
colour_t Colour = COLOUR_BLACK;
FontSpriteBase SpriteBase = FontSpriteBase::SMALL;
2021-02-26 21:11:26 +01:00
TextUnderline UnderlineText = TextUnderline::Off;
2018-06-22 22:59:03 +02:00
TextAlignment Alignment = TextAlignment::LEFT;
2017-07-22 22:08:25 +02:00
};
class StaticLayout
{
private:
2020-07-08 14:43:23 +02:00
utf8string Buffer;
TextPaint Paint;
int32_t LineCount = 0;
int32_t LineHeight;
int32_t MaxWidth;
2017-07-22 22:08:25 +02:00
2017-10-14 23:53:45 +02:00
StaticLayout();
2018-06-22 22:59:03 +02:00
StaticLayout(const StaticLayout&);
2017-10-14 23:53:45 +02:00
2017-07-22 22:08:25 +02:00
public:
StaticLayout(utf8string source, const TextPaint& paint, int32_t width);
void Draw(rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords);
int32_t GetHeight();
int32_t GetWidth();
int32_t GetLineCount();
2017-07-22 22:08:25 +02:00
};
void DrawTextBasic(
2020-08-26 15:38:27 +02:00
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const Formatter& ft, colour_t colour,
TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
void DrawTextBasic(
2020-08-26 15:38:27 +02:00
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, rct_string_id format, const void* args, colour_t colour,
TextAlignment alignment = TextAlignment::LEFT, bool underline = false);
void DrawTextEllipsised(
rct_drawpixelinfo* dpi, const ScreenCoordsXY& coords, int32_t width, rct_string_id format, const Formatter& ft,
colour_t colour, TextAlignment alignment = TextAlignment::LEFT, bool underline = false);