00001 // wg_point.h 00002 // 00003 // CPoint class interface 00004 // 00005 // 00006 // Copyright (c) 2002-2004 Rob Wiskow 00007 // rob-dev@boxedchaos.com 00008 // 00009 // This library is free software; you can redistribute it and/or 00010 // modify it under the terms of the GNU Lesser General Public 00011 // License as published by the Free Software Foundation; either 00012 // version 2.1 of the License, or (at your option) any later version. 00013 // 00014 // This library is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 // Lesser General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public 00020 // License along with this library; if not, write to the Free Software 00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 // 00023 00024 00025 #ifndef _WG_POINT_H_ 00026 #define _WG_POINT_H_ 00027 00028 #include "std_ex.h" 00029 00030 namespace wGui 00031 { 00032 00034 00037 00038 class CPoint 00039 { 00040 public: 00042 CPoint() : m_XPos(0), m_YPos(0) { } 00043 00047 CPoint(const int x, const int y) : m_XPos(x), m_YPos(y) { } 00048 00050 CPoint(const CPoint& p) : m_XPos(p.m_XPos), m_YPos(p.m_YPos) { } 00051 00053 virtual ~CPoint() { } 00054 00057 void SetX(const int x) { m_XPos = x; } 00058 00061 void SetY(const int y) { m_YPos = y; } 00062 00065 int XPos(void) const { return m_XPos; } 00066 00069 int YPos(void) const { return m_YPos; } 00070 00072 CPoint operator+(const CPoint& p) const; 00073 00075 CPoint operator-(const CPoint& p) const; 00076 00078 CPoint operator=(const CPoint& p); 00079 00081 bool operator==(const CPoint& p) const { return ((m_XPos == p.m_XPos) && (m_YPos == p.m_YPos)); } 00082 00084 bool operator!=(const CPoint& p) const { return ((m_XPos != p.m_XPos) || (m_YPos != p.m_YPos)); } 00085 00088 bool leftof(const CPoint& p) const { return (m_XPos < p.m_XPos); } 00089 00092 bool rightof(const CPoint& p) const { return (m_XPos > p.m_XPos); } 00093 00096 bool above(const CPoint& p) const { return (m_YPos < p.m_YPos); } 00097 00100 bool below(const CPoint& p) const { return (m_YPos > p.m_YPos); } 00101 00104 std::wstring ToString(void) const { return stdex::itoa(m_XPos) + L"," + stdex::itoa(m_YPos); } 00105 00106 protected: 00108 int m_XPos; 00109 00111 int m_YPos; 00112 }; 00113 00114 } 00115 00116 00117 #include "unit_tests/wg_point_unittests.h" 00118 00119 #endif // _WG_POINT_H_ 00120