Changeset - r26543:21aece3310ed
[Not reviewed]
master
0 2 0
Peter Nelson - 2 years ago 2022-09-28 16:16:46
peter1138@openttd.org
Codechange: Helpers to allow passing a Rect to some functions.
2 files changed with 42 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/gfx_func.h
Show inline comments
 
@@ -108,6 +108,42 @@ void GfxFillPolygon(const std::vector<Po
 
void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1, int dash = 0);
 
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
 

	
 
/* Versions of DrawString/DrawStringMultiLine that accept a Rect instead of separate left, right, top and bottom parameters. */
 
static inline int DrawString(const Rect &r, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawString(const Rect &r, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawString(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawStringMultiLine(const Rect &r, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawStringMultiLine(const Rect &r, const std::string &str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawStringMultiLine(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline void GfxFillRect(const Rect &r, int colour, FillRectMode mode = FILLRECT_OPAQUE)
 
{
 
	GfxFillRect(r.left, r.top, r.right, r.bottom, colour, mode);
 
}
 

	
 
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize = FS_NORMAL);
 
Dimension GetStringBoundingBox(const std::string &str, FontSize start_fontsize = FS_NORMAL);
 
Dimension GetStringBoundingBox(StringID strid);
src/window_gui.h
Show inline comments
 
@@ -142,6 +142,12 @@ enum WidgetDrawDistances {
 

	
 
/* widget.cpp */
 
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags);
 

	
 
static inline void DrawFrameRect(const Rect &r, Colours colour, FrameFlags flags)
 
{
 
	DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, flags);
 
}
 

	
 
void DrawCaption(const Rect &r, Colours colour, Owner owner, TextColour text_colour, StringID str, StringAlignment align);
 

	
 
/* window.cpp */
0 comments (0 inline, 0 general)