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