diff options
| author | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2010-11-21 17:01:59 +0000 |
| commit | b891420946d5269cc326d67555c6aab3db41a01a (patch) | |
| tree | f6c5e7d6dbf18ec8c0ea9ec0b037251df46b4cbb /ycurses/src/curses/coordinate.cpp | |
| parent | a537e8323d932125232c305f9573daef89aef0df (diff) | |
added yhttpd and ycurses trunk versions
Diffstat (limited to 'ycurses/src/curses/coordinate.cpp')
| -rw-r--r-- | ycurses/src/curses/coordinate.cpp | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/ycurses/src/curses/coordinate.cpp b/ycurses/src/curses/coordinate.cpp new file mode 100644 index 0000000..efdf9e2 --- /dev/null +++ b/ycurses/src/curses/coordinate.cpp @@ -0,0 +1,134 @@ +#ifndef COORDONATE_CPP +#define COORDONATE_CPP + +#include "coordinate.h" + +coordinate::coordinate() +{ + y = x = 0; +} + +coordinate::coordinate(coordinate_type type, dummy_window& r_win) +{ + set(type, r_win); +} + +coordinate::coordinate(coordinate_type type) +{ + set(type); +} + +coordinate::coordinate(int y, int x) +{ + this->y = y; + this->x = x; +} + +coordinate& +coordinate::set(coordinate_type type, dummy_window& r_win) +{ + switch (type) + { + case Absolutecoord: + getyx(r_win.get_WINDOW(), y, x); + break; + + case Relativecoord: + getparyx(r_win.get_WINDOW(), y, x); + break; + + case Beginningcoord: + getbegyx(r_win.get_WINDOW(), y, x); + break; + + case windowSize: + getmaxyx(r_win.get_WINDOW(), y, x); + break; + + default: + set(type); + } + + return *this; +} + +coordinate& +coordinate::set(coordinate_type type) +{ + switch (type) + { + case TerminalSize: + y = COLS; + x = LINES; + break; + + case TerminalCenter: + y = static_cast<int>(COLS / 2); + x = static_cast<int>(LINES / 2); + break; + } + + return *this; +} + +coordinate& +coordinate::left() +{ + return left(1); +} + +coordinate& +coordinate::right() +{ + return right(1); +} + +coordinate& +coordinate::up() +{ + return up(1); +} + +coordinate& +coordinate::down() +{ + return down(1); +} + +coordinate& +coordinate::left(int i) +{ + x -= i; + return *this; +} + +coordinate& +coordinate::right(int i) +{ + x += i; + return *this; +} + +coordinate& +coordinate::up(int i) +{ + y -= i; + return *this; +} + +coordinate& +coordinate::down(int i) +{ + y += i; + return *this; +} + +coordinate& +coordinate::displace(int i_y, int i_x) +{ + y += i_y; + x += i_x; + return *this; +} + +#endif |
