Changeset - r18420:dd047dbfb7e6
[Not reviewed]
master
0 2 0
rubidium - 13 years ago 2011-11-20 11:50:12
rubidium@openttd.org
(svn r23272) -Codechange: pass the initial font size to DrawString and friends
2 files changed with 20 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -65,7 +65,7 @@ struct DrawStringParams {
 
	FontSize fontsize;
 
	TextColour cur_colour, prev_colour;
 

	
 
	DrawStringParams(TextColour colour) : fontsize(FS_NORMAL), cur_colour(colour), prev_colour(colour) {}
 
	DrawStringParams(TextColour colour, FontSize fontsize) : fontsize(fontsize), cur_colour(colour), prev_colour(colour) {}
 

	
 
	/**
 
	 * Switch to new colour \a c.
 
@@ -624,12 +624,13 @@ static int DrawString(int left, int righ
 
 *               case a right-to-left language is chosen this is inverted so it
 
 *               will be drawn in the right direction.
 
 * @param underline Whether to underline what has been drawn or not.
 
 * @param fontsize The size of the initial characters.
 
 */
 
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline)
 
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 
	strecpy(buffer, str, lastof(buffer));
 
	DrawStringParams params(colour);
 
	DrawStringParams params(colour, fontsize);
 
	return DrawString(left, right, top, buffer, lastof(buffer), params, align, underline);
 
}
 

	
 
@@ -645,12 +646,13 @@ int DrawString(int left, int right, int 
 
 *               case a right-to-left language is chosen this is inverted so it
 
 *               will be drawn in the right direction.
 
 * @param underline Whether to underline what has been drawn or not.
 
 * @param fontsize The size of the initial characters.
 
 */
 
int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align, bool underline)
 
int DrawString(int left, int right, int top, StringID str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 
	GetString(buffer, str, lastof(buffer));
 
	DrawStringParams params(colour);
 
	DrawStringParams params(colour, fontsize);
 
	return DrawString(left, right, top, buffer, lastof(buffer), params, align, underline);
 
}
 

	
 
@@ -834,10 +836,11 @@ Dimension GetStringMultiLineBoundingBox(
 
 * @param colour Colour used for drawing the string, see DoDrawString() for details
 
 * @param align  The horizontal and vertical alignment of the string.
 
 * @param underline Whether to underline all strings
 
 * @param fontsize The size of the initial characters.
 
 *
 
 * @return If \a align is #SA_BOTTOM, the top to where we have written, else the bottom to where we have written.
 
 */
 
static int DrawStringMultiLine(int left, int right, int top, int bottom, char *str, const char *last, TextColour colour, StringAlignment align, bool underline)
 
static int DrawStringMultiLine(int left, int right, int top, int bottom, char *str, const char *last, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
 
{
 
	int maxw = right - left + 1;
 
	int maxh = bottom - top + 1;
 
@@ -883,7 +886,7 @@ static int DrawStringMultiLine(int left,
 
	}
 

	
 
	const char *src = str;
 
	DrawStringParams params(colour);
 
	DrawStringParams params(colour, fontsize);
 
	int written_top = bottom; // Uppermost position of rendering a line of text
 
	for (;;) {
 
		if (skip_lines == 0) {
 
@@ -933,14 +936,15 @@ static int DrawStringMultiLine(int left,
 
 * @param colour Colour used for drawing the string, see DoDrawString() for details
 
 * @param align  The horizontal and vertical alignment of the string.
 
 * @param underline Whether to underline all strings
 
 * @param fontsize The size of the initial characters.
 
 *
 
 * @return If \a align is #SA_BOTTOM, the top to where we have written, else the bottom to where we have written.
 
 */
 
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline)
 
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 
	strecpy(buffer, str, lastof(buffer));
 
	return DrawStringMultiLine(left, right, top, bottom, buffer, lastof(buffer), colour, align, underline);
 
	return DrawStringMultiLine(left, right, top, bottom, buffer, lastof(buffer), colour, align, underline, fontsize);
 
}
 

	
 
/**
 
@@ -954,14 +958,15 @@ int DrawStringMultiLine(int left, int ri
 
 * @param colour Colour used for drawing the string, see DoDrawString() for details
 
 * @param align  The horizontal and vertical alignment of the string.
 
 * @param underline Whether to underline all strings
 
 * @param fontsize The size of the initial characters.
 
 *
 
 * @return If \a align is #SA_BOTTOM, the top to where we have written, else the bottom to where we have written.
 
 */
 
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour, StringAlignment align, bool underline)
 
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 
	GetString(buffer, str, lastof(buffer));
 
	return DrawStringMultiLine(left, right, top, bottom, buffer, lastof(buffer), colour, align, underline);
 
	return DrawStringMultiLine(left, right, top, bottom, buffer, lastof(buffer), colour, align, underline, fontsize);
 
}
 

	
 
/**
src/gfx_func.h
Show inline comments
 
@@ -110,10 +110,10 @@ enum StringAlignment {
 
};
 
DECLARE_ENUM_AS_BIT_SET(StringAlignment)
 

	
 
int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false);
 
int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false);
 
int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
 
int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL);
 

	
 
void DrawCharCentered(uint32 c, int x, int y, TextColour colour);
 

	
0 comments (0 inline, 0 general)