src/misc/rect.hpp
author KUDr
Sun, 18 Feb 2007 19:45:00 +0000
branchcpp_gui
changeset 6259 0f36789984b1
parent 6258 a2f86b8fd99b
child 6262 bd89f58e8623
permissions -rw-r--r--
(svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
-PointT has now base PointRawT without constructor (plain struct compatible with unions)
-struct Point declared in gfx.h replaced by PointT<int>
-use of Point in WindowEvent::we union members replaced by PointRawT<int>
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     1
/* $Id$ */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     2
#ifndef RECT_H
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     3
#define RECT_H
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
     4
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
     5
/** Template based point without ctor/dtor (raw) for use in unions */
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
     6
template <typename T> struct PointRawT {
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
     7
	T x, y;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
     8
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
     9
	PointRawT operator -() const
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    10
	{
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    11
		PointRawT pt = {-x, -y};
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    12
		return pt;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    13
	}
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    14
};
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    15
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    16
/** Template based point */
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    17
template <typename T> struct PointT : public PointRawT<T> {
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    18
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    19
	PointT(T x_a = 0, T y_a = 0)
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    20
	{
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    21
		x = x_a;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    22
		y = y_a;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    23
	}
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    24
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    25
	template <typename Ta> PointT(const PointRawT<Ta> &src)
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    26
	{
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    27
		x = (T)src.x;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    28
		y = (T)src.y;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    29
	}
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    30
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    31
	PointT& operator =(const PointRawT &src)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    32
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    33
		x = (T)src.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    34
		y = (T)src.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    35
		return *this;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    36
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    37
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    38
	PointT operator -() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    39
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    40
		return PointT(-x, -y);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    41
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    42
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    43
	void DoMove(T dx, T dy)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    44
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    45
		x += dx;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    46
		y += dy;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    47
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    48
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    49
	void DoMove(const PointRawT &offset)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    50
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    51
		DoMove((T)offset.x, (T)offset.y);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    52
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    53
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    54
	PointT operator +(const PointRawT &offset) const
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    55
	{
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    56
		PointT pt(*this);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    57
		pt.DoMove(offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    58
		return pt;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    59
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    60
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    61
	PointT operator -(const PointRawT &offset) const
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    62
	{
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    63
		PointT pt(*this);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    64
		pt.DoMove(-offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    65
		return pt;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    66
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    67
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    68
	PointT& operator +=(const PointRawT &offset)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    69
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    70
		DoMove(offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    71
		return *this;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    72
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    73
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
    74
	PointT& operator -=(const PointRawT &offset)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    75
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    76
		DoMove(-offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    77
		return *this;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    78
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    79
};
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    80
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    81
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    82
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    83
/** Template based rectangle */
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    84
template <typename T> struct RectT
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    85
{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    86
	PointT<T> top_left, bottom_right;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    87
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    88
	RectT(T left = 0, T top = 0, T right = 0, T bottom = 0)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    89
		: top_left(left, top), bottom_right(right, bottom)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    90
	{}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    91
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    92
	template <typename Ta> RectT(const RectT<Ta> &src)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    93
		: top_left(src.top_left), bottom_right(src.bottom_right)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    94
	{}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    95
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    96
	T Left() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    97
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    98
		return top_left.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
    99
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   100
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   101
	T Top() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   102
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   103
		return top_left.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   104
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   105
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   106
	T Right() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   107
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   108
		return bottom_right.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   109
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   110
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   111
	T Bottom() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   112
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   113
		return bottom_right.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   114
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   115
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   116
	T Width() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   117
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   118
		return bottom_right.x - top_left.x + 1;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   119
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   120
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   121
	T Height() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   122
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   123
		return bottom_right.y - top_left.y + 1;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   124
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   125
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   126
	const PointT<T>& TopLeft() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   127
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   128
		return top_left;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   129
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   130
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   131
	const PointT<T>& BottomRight() const
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   132
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   133
		return bottom_right;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   134
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   135
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   136
	void SetLeft(T val)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   137
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   138
		top_left.x = val;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   139
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   140
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   141
	void SetTop(T val)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   142
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   143
		top_left.y = val;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   144
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   145
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   146
	void SetRight(T val)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   147
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   148
		bottom_right.x = val;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   149
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   150
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   151
	void SetBottom(T val)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   152
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   153
		bottom_right.y = val;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   154
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   155
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   156
	void SetWidth(T val)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   157
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   158
		bottom_right.x = top_left.x + val - 1;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   159
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   160
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   161
	void SetHeight(T val)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   162
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   163
		bottom_right.y = top_left.y + val - 1;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   164
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   165
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   166
	void SetTopLeft(const PointRawT<T> &pt)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   167
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   168
		top_left = pt;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   169
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   170
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   171
	void SetBottomRight(const PointRawT<T> &pt)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   172
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   173
		bottom_right = pt;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   174
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   175
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   176
	bool PtInRect(const PointRawT<T> &pt) const
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   177
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   178
		return (top_left.x <= pt.x && pt.x <= bottom_right.x && top_left.y <= pt.y && pt.y <= bottom_right.y);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   179
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   180
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   181
	RectT& operator =(const RectT &src)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   182
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   183
		top_left     = src.top_left;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   184
		bottom_right = src.bottom_right;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   185
		return *this;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   186
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   187
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   188
	void DoMove(T dx, T dy)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   189
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   190
		DoMove(PointT<T>(dx, dy));
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   191
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   192
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   193
	void DoMove(const PointRawT<T> &offset)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   194
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   195
		top_left.DoMove(offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   196
		bottom_right.DoMove(offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   197
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   198
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   199
	RectT operator +(const PointRawT<T> &offset) const
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   200
	{
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   201
		RectT r(*this);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   202
		r.DoMove(offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   203
		return r;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   204
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   205
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   206
	RectT operator -(const PointRawT<T> &offset) const
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   207
	{
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   208
		RectT r(*this);
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   209
		r.DoMove(-offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   210
		return r;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   211
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   212
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   213
	RectT& operator +=(const PointRawT<T> &offset)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   214
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   215
		DoMove(offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   216
		return *this;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   217
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   218
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   219
	RectT& operator -=(const PointRawT<T> &offset)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   220
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   221
		DoMove(-offset);
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   222
		return *this;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   223
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   224
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   225
	void DoUnion(const PointRawT<T> &pt)
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   226
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   227
		if (pt.x < top_left.x) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   228
			top_left.x = pt.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   229
		} else if (pt.x > bottom_right.x) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   230
			bottom_right.x = pt.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   231
		}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   232
		if (pt.y < top_left.y) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   233
			top_left.y = pt.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   234
		} else if (pt.y > bottom_right.y) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   235
			bottom_right.y = pt.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   236
		}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   237
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   238
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   239
	void DoUnion(const RectT &rc)
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   240
	{
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   241
		if (rc.top_left.x < top_left.x) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   242
			top_left.x = rc.top_left.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   243
		} else if (rc.bottom_right.x > bottom_right.x) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   244
			bottom_right.x = rc.bottom_right.x;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   245
		}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   246
		if (rc.top_left.y < top_left.y) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   247
			top_left.y = rc.top_left.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   248
		} else if (rc.bottom_right.y > bottom_right.y) {
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   249
			bottom_right.y = rc.bottom_right.y;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   250
		}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   251
	}
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   252
};
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   253
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   254
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   255
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   256
typedef PointRawT<int> PointRaw;
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   257
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   258
typedef PointT<int16> Point16;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   259
typedef PointT<int32> Point32;
6259
0f36789984b1 (svn r8803) [cpp_gui] -Codechange: point structures (Point, Point16) made compatible
KUDr
parents: 6258
diff changeset
   260
typedef PointT<int>   Point;
6258
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   261
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   262
typedef RectT<int16> Rect16;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   263
typedef RectT<int32> Rect32;
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   264
a2f86b8fd99b (svn r8801) [cpp_gui] -Codechange: few changes towards OO GUI:
KUDr
parents:
diff changeset
   265
#endif /*RECT_H*/