1 /////////////////////////////////////////////////////////////////////////////
2 // Name:        wx/position.h
3 // Purpose:     Common structure and methods for positional information.
4 // Author:      Vadim Zeitlin, Robin Dunn, Brad Anderson, Bryan Petty
5 // Created:     2007-03-13
6 // Copyright:   (c) 2007 The wxWidgets Team
7 // Licence:     wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9 
10 #ifndef _WX_POSITION_H_
11 #define _WX_POSITION_H_
12 
13 #include "wx/gdicmn.h"
14 
15 class WXDLLIMPEXP_CORE wxPosition
16 {
17 public:
wxPosition()18     wxPosition() : m_row(0), m_column(0) {}
wxPosition(int row,int col)19     wxPosition(int row, int col) : m_row(row), m_column(col) {}
20 
21     // default copy ctor and assignment operator are okay.
22 
GetRow()23     int GetRow() const          { return m_row; }
GetColumn()24     int GetColumn() const       { return m_column; }
GetCol()25     int GetCol() const          { return GetColumn(); }
SetRow(int row)26     void SetRow(int row)        { m_row = row; }
SetColumn(int column)27     void SetColumn(int column)  { m_column = column; }
SetCol(int column)28     void SetCol(int column)     { SetColumn(column); }
29 
30     bool operator==(const wxPosition& p) const
31         { return m_row == p.m_row && m_column == p.m_column; }
32     bool operator!=(const wxPosition& p) const
33         { return !(*this == p); }
34 
35     wxPosition& operator+=(const wxPosition& p)
36         { m_row += p.m_row; m_column += p.m_column; return *this; }
37     wxPosition& operator-=(const wxPosition& p)
38         { m_row -= p.m_row; m_column -= p.m_column; return *this; }
39     wxPosition& operator+=(const wxSize& s)
40         { m_row += s.y; m_column += s.x; return *this; }
41     wxPosition& operator-=(const wxSize& s)
42         { m_row -= s.y; m_column -= s.x; return *this; }
43 
44     wxPosition operator+(const wxPosition& p) const
45         { return wxPosition(m_row + p.m_row, m_column + p.m_column); }
46     wxPosition operator-(const wxPosition& p) const
47         { return wxPosition(m_row - p.m_row, m_column - p.m_column); }
48     wxPosition operator+(const wxSize& s) const
49         { return wxPosition(m_row + s.y, m_column + s.x); }
50     wxPosition operator-(const wxSize& s) const
51         { return wxPosition(m_row - s.y, m_column - s.x); }
52 
53 private:
54     int m_row;
55     int m_column;
56 };
57 
58 #endif // _WX_POSITION_H_
59 
60