2 * Copyright (c) 2001,2002, Gary R. Van Sickle.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
16 #ifndef SETUP_RECTWRAPPER_H
17 #define SETUP_RECTWRAPPER_H
23 Thin wrapper around GDI's RECT, mainly to allow what would otherwise have to
24 be a ton of "OffsetRect(&rect, 1, 2);"-type calls to be more easily written.
25 Also has a few gimmes like width() and height(). Note this is derived from
26 GDI's RECT *struct*, so that they're interchangable, and is not a class proper.
27 Not a general-purpose Rectangle class, not intended to be a general-purpose
29 DO NOT add virtual members or you'll wreck the RECT==RECTWrapper duality.
32 struct RECTWrapper
: public RECT
34 // Get interesting facts about the RECT/RECTWrapper
35 int width() const { return right
- left
; };
36 int height() const { return bottom
- top
; };
39 // Do interesting things to the RECT/RECTWrapper
40 RECTWrapper
& operator=(const RECT
& r
);
41 void move(int x
, int y
);
44 inline RECTWrapper
& RECTWrapper::operator=(const RECT
& r
)
53 inline POINT
RECTWrapper::center() const
55 // Return the center point of the rect.
57 retval
.x
= (left
+ right
)/2;
58 retval
.y
= (top
+ bottom
)/2;
62 inline void RECTWrapper::move(int x
, int y
)
64 // Move the whole rect by [x,y].
65 // Windows refers to this as offsetting.
66 OffsetRect(this, x
, y
);
69 #endif /* SETUP_RECTWRAPPER_H */