From 97660d421354b0d711e916e2032a2d369bbee294 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 8 Apr 2007 00:49:41 +0000 Subject: [PATCH] added wxPosition helper class (extracted from patch 1671181) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- build/bakefiles/files.bkl | 1 + include/wx/position.h | 60 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100755 include/wx/position.h diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index 3d2921ab1f..dba73a7d3c 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -769,6 +769,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! wx/palette.h wx/panel.h wx/pen.h + wx/position.h wx/radiobox.h wx/radiobut.h wx/renderer.h diff --git a/include/wx/position.h b/include/wx/position.h new file mode 100755 index 0000000000..2f74b7b42d --- /dev/null +++ b/include/wx/position.h @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: include/wx/position.h +// Purpose: Common structure and methods for positional information. +// Author: Vadim Zeitlin, Robin Dunn, Brad Anderson, Bryan Petty +// Created: 2007-0r-13 +// RCS-ID: $Id$ +// Copyright: (c) 2007 The wxWidgets Team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_POSITION_H_ +#define _WX_POSITION_H_ + +#include "wx/gdicmn.h" + +class wxPosition +{ +public: + wxPosition() : m_row(0), m_column(0) {} + wxPosition(int row, int col) : m_row(row), m_column(col) {} + + // default copy ctor and assignment operator are okay. + + int GetRow() const { return m_row; } + int GetColumn() const { return m_column; } + int GetCol() const { return GetColumn(); } + void SetRow(int row) { m_row = row; } + void SetColumn(int column) { m_column = column; } + void SetCol(int column) { SetColumn(column); } + + bool operator==(const wxPosition& p) const + { return m_row == p.m_row && m_column == p.m_column; } + bool operator!=(const wxPosition& p) const + { return !(*this == p); } + + wxPosition& operator+=(const wxPosition& p) + { m_row += p.m_row; m_column += p.m_column; return *this; } + wxPosition& operator-=(const wxPosition& p) + { m_row -= p.m_row; m_column -= p.m_column; return *this; } + wxPosition& operator+=(const wxSize& s) + { m_row += s.y; m_column += s.x; return *this; } + wxPosition& operator-=(const wxSize& s) + { m_row -= s.y; m_column -= s.x; return *this; } + + wxPosition operator+(const wxPosition& p) const + { return wxPosition(m_row + p.m_row, m_column + p.m_column); } + wxPosition operator-(const wxPosition& p) const + { return wxPosition(m_row - p.m_row, m_column - p.m_column); } + wxPosition operator+(const wxSize& s) const + { return wxPosition(m_row + s.y, m_column + s.x); } + wxPosition operator-(const wxSize& s) const + { return wxPosition(m_row - s.y, m_column - s.x); } + +private: + int m_row; + int m_column; +}; + +#endif // _WX_POSITION_H_ + -- 2.45.2