File diff r15609:02b794721f9c → r15610:623a23fb6560
src/gfx.cpp
Show inline comments
 
@@ -65,13 +65,14 @@ static void GfxMainBlitter(const Sprite 
 
struct DrawStringParams {
 
	FontSize fontsize;
 
	TextColour cur_colour, prev_colour;
 

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

	
 
	/** Switch to new colour \a c.
 
	/**
 
	 * Switch to new colour \a c.
 
	 * @param c New colour to use.
 
	 */
 
	FORCEINLINE void SetColour(TextColour c)
 
	{
 
		assert(c >=  TC_BLUE && c <= TC_BLACK);
 
		this->prev_colour = this->cur_colour;
 
@@ -81,13 +82,14 @@ struct DrawStringParams {
 
	/** Switch to previous colour. */
 
	FORCEINLINE void SetPreviousColour()
 
	{
 
		Swap(this->cur_colour, this->prev_colour);
 
	}
 

	
 
	/** Switch to using a new font \a f.
 
	/**
 
	 * Switch to using a new font \a f.
 
	 * @param f New font to use.
 
	 */
 
	FORCEINLINE void SetFontSize(FontSize f)
 
	{
 
		this->fontsize = f;
 
	}
 
@@ -355,13 +357,14 @@ static UChar *HandleBiDiAndArabicShapes(
 
	input_output[length] = '\0';
 
	return input_output;
 
}
 
#endif /* WITH_ICU */
 

	
 

	
 
/** Truncate a given string to a maximum width if neccessary.
 
/**
 
 * Truncate a given string to a maximum width if neccessary.
 
 * If the string is truncated, add three dots ('...') to show this.
 
 * @param *str string that is checked and possibly truncated
 
 * @param maxw maximum width in pixels of the string
 
 * @param ignore_setxy whether to ignore SETX(Y) or not
 
 * @param start_fontsize Fontsize to start the text with
 
 * @return new width of (truncated) string
 
@@ -755,13 +758,14 @@ end_of_inner_loop:
 
			for (; str[-1] != '\0';) *s++ = *str++;
 
		}
 
	}
 
}
 

	
 

	
 
/** Calculates height of string (in pixels). Accepts multiline string with '\0' as separators.
 
/**
 
 * Calculates height of string (in pixels). Accepts multiline string with '\0' as separators.
 
 * @param src string to check
 
 * @param num number of extra lines (output of FormatStringLinebreaks())
 
 * @param start_fontsize Fontsize to start the text with
 
 * @note assumes text won't be truncated. FormatStringLinebreaks() is a good way to ensure that.
 
 * @return height of pixels of string when it is drawn
 
 */
 
@@ -784,13 +788,14 @@ static int GetMultilineStringHeight(cons
 
			default:           maxy = max<int>(maxy, y + fh);       break;
 
		}
 
	}
 
}
 

	
 

	
 
/** Calculates height of string (in pixels). The string is changed to a multiline string if needed.
 
/**
 
 * Calculates height of string (in pixels). The string is changed to a multiline string if needed.
 
 * @param str string to check
 
 * @param maxw maximum string width
 
 * @return height of pixels of string when it is drawn
 
 */
 
int GetStringHeight(StringID str, int maxw)
 
{
 
@@ -800,13 +805,14 @@ int GetStringHeight(StringID str, int ma
 

	
 
	uint32 tmp = FormatStringLinebreaks(buffer, lastof(buffer), maxw);
 

	
 
	return GetMultilineStringHeight(buffer, GB(tmp, 0, 16), FS_NORMAL);
 
}
 

	
 
/** Calculate string bounding box for multi-line strings.
 
/**
 
 * Calculate string bounding box for multi-line strings.
 
 * @param str        String to check.
 
 * @param suggestion Suggested bounding box.
 
 * @return Bounding box for the multi-line string, may be bigger than \a suggestion.
 
 */
 
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion)
 
{
 
@@ -953,13 +959,14 @@ int DrawStringMultiLine(int left, int ri
 
{
 
	char buffer[DRAW_STRING_BUFFER];
 
	GetString(buffer, str, lastof(buffer));
 
	return DrawStringMultiLine(left, right, top, bottom, buffer, lastof(buffer), colour, align, underline);
 
}
 

	
 
/** Return the string dimension in pixels. The height and width are returned
 
/**
 
 * Return the string dimension in pixels. The height and width are returned
 
 * in a single Dimension value. TINYFONT, BIGFONT modifiers are only
 
 * supported as the first character of the string. The returned dimensions
 
 * are therefore a rough estimation correct for all the current strings
 
 * but not every possible combination
 
 * @param str string to calculate pixel-width
 
 * @param start_fontsize Fontsize to start the text with
 
@@ -1024,13 +1031,14 @@ Dimension GetStringBoundingBox(StringID 
 
void DrawCharCentered(WChar c, int x, int y, TextColour colour)
 
{
 
	SetColourRemap(colour);
 
	GfxMainBlitter(GetGlyph(FS_NORMAL, c), x - GetCharacterWidth(FS_NORMAL, c) / 2, y, BM_COLOUR_REMAP);
 
}
 

	
 
/** Draw a string at the given coordinates with the given colour.
 
/**
 
 * Draw a string at the given coordinates with the given colour.
 
 *  While drawing the string, parse it in case some formatting is specified,
 
 *  like new colour, new size or even positionning.
 
 * @param string              The string to draw. This is already bidi reordered.
 
 * @param x                   Offset from left side of the screen
 
 * @param y                   Offset from top side of the screen
 
 * @param params              Text drawing parameters
 
@@ -1703,13 +1711,14 @@ void SetDirtyBlocks(int left, int top, i
 
 */
 
void MarkWholeScreenDirty()
 
{
 
	SetDirtyBlocks(0, 0, _screen.width, _screen.height);
 
}
 

	
 
/** Set up a clipping area for only drawing into a certain area. To do this,
 
/**
 
 * Set up a clipping area for only drawing into a certain area. To do this,
 
 * Fill a DrawPixelInfo object with the supplied relative rectangle, backup
 
 * the original (calling) _cur_dpi and assign the just returned DrawPixelInfo
 
 * _cur_dpi. When you are done, give restore _cur_dpi's original value
 
 * @param *n the DrawPixelInfo that will be the clipping rectangle box allowed
 
 * for drawing
 
 * @param left,top,width,height the relative coordinates of the clipping