00001 #ifndef COMMONSTRUCTS_H 00002 #define COMMONSTRUCTS_H 00003 00004 #pragma once 00005 #include "CommonDefs.h" 00006 00007 struct tRect 00008 { 00009 public: 00010 union 00011 { 00012 struct 00013 { 00014 int left; 00015 int right; 00016 int top; 00017 int bottom; 00018 }; 00019 int m_iSide[4]; 00020 }; 00021 00022 tRect() {left = right = top = bottom = 0;}; 00023 virtual ~tRect() {}; 00024 00025 tRect(int x1, int x2, int y1, int y2) 00026 { 00027 left = x1; right = x2; 00028 top = y1; bottom = y2; 00029 }; 00030 00034 const tRect& operator = (const tRect& other) 00035 { 00036 left = other.left; 00037 right = other.right; 00038 top = other.top; 00039 bottom = other.bottom; 00040 00041 return *this; 00042 }; 00043 00047 const int operator [] (int i) 00048 { 00049 if(i == 0) 00050 return left; 00051 else if(i == 1) 00052 return right; 00053 else if(i == 2) 00054 return top; 00055 else if(i == 3) 00056 return bottom; 00057 00058 return -1; 00059 }; 00060 00064 UINT Width() 00065 { return right - left; }; 00066 00070 UINT Height() 00071 { return top - bottom; }; 00072 00073 }; 00074 00076 00079 struct tVERTEX2f 00080 { 00081 tVERTEX2f(float x = 0, float y = 0) : x(x), y(y){}; 00082 float x; 00083 float y; 00085 const tVERTEX2f& operator = (const tVERTEX2f& other) 00086 { 00087 x = other.x; 00088 y = other.y; 00089 00090 return *this; 00091 }; 00092 00093 const int operator [] (int i) 00094 { 00095 if(i == 0) 00096 return x; 00097 else if(i == 1) 00098 return y; 00099 00100 return -1; 00101 }; 00102 }; 00103 00105 00108 struct tVERTEX2d 00109 { 00110 tVERTEX2d(int x = 0, int y = 0) : x(x), y(y){}; 00111 int x; 00112 int y; 00114 const tVERTEX2d& operator = (const tVERTEX2f& other) 00115 { 00116 x = other.x; 00117 y = other.y; 00118 00119 return *this; 00120 }; 00121 00122 const int operator [] (int i) 00123 { 00124 if(i == 0) 00125 return x; 00126 else if(i == 1) 00127 return y; 00128 00129 return -1; 00130 }; 00131 }; 00132 00133 #endif