aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/IntegerRectangle.h
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2018-05-01 14:14:45 +1000
committerNeil <nyamatongwe@gmail.com>2018-05-01 14:14:45 +1000
commitf4c9e005de319d79fffae89e2695eb3d27005e85 (patch)
treec6dff56c891aa8eb33b0d659b4f5d39e20d6d80c /src/IntegerRectangle.h
parent086549b12567da2e3750dd7d45ff0f42bb5cb620 (diff)
downloadscintilla-mirror-f4c9e005de319d79fffae89e2695eb3d27005e85.tar.gz
Add IntegerRectangle to simplify drawing lines without casting.
Diffstat (limited to 'src/IntegerRectangle.h')
-rw-r--r--src/IntegerRectangle.h29
1 files changed, 29 insertions, 0 deletions
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 <neilh@scintilla.org>
+// 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<int>(rc.left)), top(static_cast<int>(rc.top)),
+ right(static_cast<int>(rc.right)), bottom(static_cast<int>(rc.bottom)) {
+ }
+ int Width() const noexcept { return right - left; }
+ int Height() const noexcept { return bottom - top; }
+};
+
+}
+
+#endif