warzone2100/lib/ivis_common/textdraw.h

97 lines
2.8 KiB
C

/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2009 Warzone Resurrection Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _INCLUDED_TEXTDRAW_
#define _INCLUDED_TEXTDRAW_
#include "ivisdef.h"
#include "piepalette.h"
#ifdef __cplusplus
extern "C"
{
#endif //__cplusplus
enum iV_fonts
{
font_regular,
font_large,
font_small,
};
#define PIE_TEXT_WHITE (-1)
#define PIE_TEXT_LIGHTBLUE (-2)
#define PIE_TEXT_DARKBLUE (-3)
extern void iV_TextInit(void);
extern void iV_TextShutdown(void);
extern void iV_font(const char *fontName, const char *fontFace, const char *fontFaceBold);
extern void iV_SetFont(enum iV_fonts FontID);
extern int iV_GetTextAboveBase(void);
extern int iV_GetTextBelowBase(void);
extern int iV_GetTextLineSize(void);
extern unsigned int iV_GetTextWidth(const char* String);
extern unsigned int iV_GetCountedTextWidth(const char* string, size_t string_length);
extern unsigned int iV_GetCharWidth(uint32_t charCode);
extern unsigned int iV_GetTextHeight(const char* string);
extern void iV_SetTextColour(PIELIGHT colour);
#define ASCII_SPACE (32)
#define ASCII_NEWLINE ('@')
#define ASCII_COLOURMODE ('#')
#define TEXT_UTF8_SPACE " "
#define TEXT_UTF8_NEWLINE "\n"
static const char text_space_utf8[] = TEXT_UTF8_SPACE;
static const char text_newline_utf8[] = TEXT_UTF8_NEWLINE;
// Valid values for "Justify" argument of iV_DrawFormattedText().
enum {
FTEXT_LEFTJUSTIFY, // Left justify.
FTEXT_CENTRE, // Centre justify.
FTEXT_RIGHTJUSTIFY, // Right justify.
};
extern int iV_DrawFormattedText(const char* String, UDWORD x, UDWORD y, UDWORD Width, UDWORD Justify);
extern void iV_SetTextSize(float size);
extern void iV_DrawTextRotated(const char* string, float x, float y, float rotation);
/** Draws text with a printf syntax to the screen.
*/
static inline void iV_DrawText(const char* string, float x, float y)
{
iV_DrawTextRotated(string, x, y, 0.f);
}
extern void iV_DrawTextF(float x, float y, const char* format, ...) WZ_DECL_FORMAT(printf, 3, 4);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif // _INCLUDED_TEXTDRAW_