From 3de73c8508e74834a38f63f5c4584f1fb2012b52 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 1 May 2018 14:14:45 +1000 Subject: Backport: Add IntegerRectangle to simplify drawing lines without casting. Backport of changeset 6773:9a027c16f8c3. --- src/IntegerRectangle.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/IntegerRectangle.h (limited to 'src/IntegerRectangle.h') diff --git a/src/IntegerRectangle.h b/src/IntegerRectangle.h new file mode 100644 index 000000000..4eaf39c43 --- /dev/null +++ b/src/IntegerRectangle.h @@ -0,0 +1,29 @@ +// Scintilla source code edit control +/** @file IntegerRectangle.h + ** A rectangle with integer coordinates. + **/ +// Copyright 2018 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef INTEGERRECTANGLE_H +#define INTEGERRECTANGLE_H + +namespace Scintilla { + +struct IntegerRectangle { + int left; + int top; + int right; + int bottom; + + explicit IntegerRectangle(PRectangle rc) noexcept : + left(static_cast(rc.left)), top(static_cast(rc.top)), + right(static_cast(rc.right)), bottom(static_cast(rc.bottom)) { + } + int Width() const noexcept { return right - left; } + int Height() const noexcept { return bottom - top; } +}; + +} + +#endif -- cgit v1.2.3