#ifndef __Display_h #define __Display_h #include //#include struct Dimension { short width, height; Dimension(short w = 0,short h = 0) { width = w; height = h; } }; struct Point { short row, col; Point(short r,short c) { row = r; col = c; } Point operator +(Point p) { return Point(p.row + row,p.col + col); } Point operator +(short cols) { return Point(row,col + cols); } Point operator -(Point p) { return Point(row - p.row,col - p.col); } Point &operator +=(Point p) { row += p.row; col += p.col; return *this; } Point &operator -=(Point p) { row -= p.row; col -= p.col; return *this; } Point &operator +=(short cols) { col += cols; return *this; } }; struct Rect { short r1, c1; /* upper left corner */ short r2, c2; /* lower right corner */ short width() const { return c2 - c1 + 1; } short height() const { return r2 - r1 + 1; } Point origin() const { return Point(r1,c1); } Rect(short rw1 = 0,short cl1 = 0,short rw2 = 255,short cl2 = 255) : r1(rw1),c1(cl1),r2(rw2),c2(cl2) {} Rect(Point p1,Point p2) { r1 = p1.row; c1 = p1.col; r2 = p2.row; c2 = p2.col; } Rect(Point p1,int cols,int rows = 1); Rect operator +(Point p) const { return moverel(p.row,p.col); } Rect intersect(const Rect &) const ; Rect enclose(const Rect &) const; Rect moverel(short rows,short cols = 0) const; Rect moveabs(short row,short col) const; Rect expand(short amt) const; bool isempty() const { return r1 > r2 || c1 > c2; } }; #endif