1 /*
2  *  Open Fodder
3  *  ---------------
4  *
5  *  Copyright (C) 2008-2018 Open Fodder
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License along
18  *  with this program; if not, write to the Free Software Foundation, Inc.,
19  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22 
23 class cDimension {
24 	public:
25 	unsigned int mWidth, mHeight;
26 
27 	public:
cDimension()28 		cDimension() : mWidth( 0 ), mHeight( 0 ) {}
cDimension(unsigned int pWidth,unsigned int pHeight)29 		cDimension( unsigned int pWidth, unsigned int pHeight ) : mWidth( pWidth ), mHeight( pHeight ) {}
30 
Set(unsigned int pWidth,unsigned int pHeight)31 		void Set( unsigned int pWidth, unsigned int pHeight ) { mWidth = pWidth; mHeight = pHeight; }
32 
WidthByHeight()33 		unsigned int WidthByHeight() { return mWidth * mHeight; }
getWidth() const34 		int getWidth() const { return mWidth; }
getHeight() const35 		int getHeight() const { return mHeight; }
36 
getCentre() const37         cPosition getCentre() const { return { mWidth / 2, mHeight / 2 }; };
38 
operator /(const cDimension & pDim)39         cDimension operator/(const cDimension& pDim) {
40             return cDimension(mWidth / pDim.mWidth, mHeight / pDim.mHeight);
41         }
42 
operator ==(const cDimension & pRight)43         bool operator==(const cDimension& pRight) {
44             return mWidth == pRight.mWidth && mHeight == pRight.mHeight;
45         }
46 
operator +(const cDimension & pRight)47 		cDimension operator+(const cDimension& pRight) {
48 
49 			return cDimension(mWidth + pRight.mWidth, mHeight + pRight.mHeight);
50 		}
51 };
52