#ifndef RECTCC_H__F4098557_9A48_446d_AF28_2BE45D29F68D__INCLUDED_ #define RECTCC_H__F4098557_9A48_446d_AF28_2BE45D29F68D__INCLUDED_ /* * Copyright (c) 2001,2002, Gary R. Van Sickle. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * A copy of the GNU General Public License can be found at * http://www.gnu.org/ * * Written by Gary R. Van Sickle * */ #include /* Thin wrapper around GDI's RECT, mainly to allow what would otherwise have to be a ton of "OffsetRect(&rect, 1, 2);"-type calls to be more easily written. Also has a few gimmes like width() and height(). Note this is derived from GDI's RECT *struct*, so that they're interchangable, and is not a class proper. Not a general-purpose Rectangle class, not intended to be a general-purpose Rectangle class. */ struct RECTPP : public RECT { // Get interesting facts about the RECT/RECTPP int width() const { return right - left; }; int height() const { return bottom - top; }; POINT center() const; // Do interesting things to the RECT/RECTPP RECTPP& operator=(const RECT & r); void offset(int x, int y); }; inline RECTPP& RECTPP::operator=(const RECT & r) { right = r.right; left = r.left; top = r.top; bottom = r.bottom; return *this; }; inline POINT RECTPP::center() const { // Return the center point of the rect. POINT retval; retval.x = (left + right)/2; retval.y = (top + bottom)/2; return retval; } inline void RECTPP::offset(int x, int y) { // Offset the whole rect by [x,y] OffsetRect(this, x, y); }; #endif // RECTCC_H__F4098557_9A48_446d_AF28_2BE45D29F68D__INCLUDED_