]> cygwin.com Git - cygwin-apps/setup.git/blob - RECTWrapper.h
Support xz and lzma decompression via liblzma
[cygwin-apps/setup.git] / RECTWrapper.h
1 /*
2 * Copyright (c) 2001,2002, Gary R. Van Sickle.
3 *
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.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Gary R. Van Sickle <g.r.vansickle@worldnet.att.net>
13 *
14 */
15
16 #ifndef SETUP_RECTWRAPPER_H
17 #define SETUP_RECTWRAPPER_H
18
19
20 #include "win32.h"
21
22 /*
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
28 Rectangle class.
29 DO NOT add virtual members or you'll wreck the RECT==RECTWrapper duality.
30 */
31
32 struct RECTWrapper : public RECT
33 {
34 // Get interesting facts about the RECT/RECTWrapper
35 int width() const { return right - left; };
36 int height() const { return bottom - top; };
37 POINT center() const;
38
39 // Do interesting things to the RECT/RECTWrapper
40 RECTWrapper& operator=(const RECT & r);
41 void move(int x, int y);
42 };
43
44 inline RECTWrapper& RECTWrapper::operator=(const RECT & r)
45 {
46 right = r.right;
47 left = r.left;
48 top = r.top;
49 bottom = r.bottom;
50 return *this;
51 };
52
53 inline POINT RECTWrapper::center() const
54 {
55 // Return the center point of the rect.
56 POINT retval;
57 retval.x = (left + right)/2;
58 retval.y = (top + bottom)/2;
59 return retval;
60 }
61
62 inline void RECTWrapper::move(int x, int y)
63 {
64 // Move the whole rect by [x,y].
65 // Windows refers to this as offsetting.
66 OffsetRect(this, x, y);
67 };
68
69 #endif /* SETUP_RECTWRAPPER_H */
This page took 0.039397 seconds and 5 git commands to generate.