1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Common structure and methods for positional information.
4 // Author: Vadim Zeitlin, Robin Dunn, Brad Anderson, Bryan Petty
6 // Copyright: (c) 2007 The wxWidgets Team
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_POSITION_H_
11 #define _WX_POSITION_H_
13 #include "wx/gdicmn.h"
15 class WXDLLIMPEXP_CORE wxPosition
18 wxPosition() : m_row(0), m_column(0) {}
19 wxPosition(int row
, int col
) : m_row(row
), m_column(col
) {}
21 // default copy ctor and assignment operator are okay.
23 int GetRow() const { return m_row
; }
24 int GetColumn() const { return m_column
; }
25 int GetCol() const { return GetColumn(); }
26 void SetRow(int row
) { m_row
= row
; }
27 void SetColumn(int column
) { m_column
= column
; }
28 void SetCol(int column
) { SetColumn(column
); }
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
); }
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; }
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
); }
58 #endif // _WX_POSITION_H_