| 1 |
sf-pippijn |
1.1 |
/* pad.cc |
| 2 |
|
|
* This file is part of ncursesxx library |
| 3 |
|
|
* Copyright (c) 2003,2004 by Stanislav Ievlev |
| 4 |
|
|
* |
| 5 |
|
|
* This file is covered by the GNU Library General Public License, |
| 6 |
|
|
* which should be included with libncursesxx as the file COPYING. |
| 7 |
|
|
*/ |
| 8 |
|
|
#include <ncurses/pad.hh> |
| 9 |
|
|
|
| 10 |
|
|
#include <ncurses/window.hh> |
| 11 |
|
|
|
| 12 |
|
|
#include <stdexcept> |
| 13 |
|
|
|
| 14 |
|
|
using ncurses::pad; |
| 15 |
|
|
|
| 16 |
|
|
pad::pad () |
| 17 |
|
|
: pad_ (newpad (1, 1), delwin) |
| 18 |
|
|
{ |
| 19 |
|
|
if (!pad_) |
| 20 |
sf-pippijn |
1.3 |
throw std::runtime_error ("newpad failed"); |
| 21 |
sf-pippijn |
1.1 |
keypad (win (), TRUE); /* initialize advanced keycodes for this window */ |
| 22 |
|
|
} |
| 23 |
|
|
|
| 24 |
|
|
pad::~pad () |
| 25 |
|
|
{ |
| 26 |
|
|
} |
| 27 |
|
|
|
| 28 |
|
|
void |
| 29 |
|
|
pad::resize (int w, int h) |
| 30 |
|
|
{ |
| 31 |
sf-pippijn |
1.2 |
return_unless (wresize (win (), h, w) == OK); |
| 32 |
sf-pippijn |
1.1 |
} |
| 33 |
|
|
|
| 34 |
|
|
int |
| 35 |
|
|
pad::width () const |
| 36 |
|
|
{ |
| 37 |
|
|
int x, y; |
| 38 |
|
|
|
| 39 |
|
|
getmaxyx (win (), y, x); |
| 40 |
|
|
return x; |
| 41 |
|
|
} |
| 42 |
|
|
|
| 43 |
|
|
int |
| 44 |
|
|
pad::height () const |
| 45 |
|
|
{ |
| 46 |
|
|
int x, y; |
| 47 |
|
|
|
| 48 |
|
|
getmaxyx (win (), y, x); |
| 49 |
|
|
return y; |
| 50 |
|
|
} |
| 51 |
|
|
|
| 52 |
|
|
void |
| 53 |
|
|
pad::draw (window &viewport, int x, int y) |
| 54 |
|
|
{ |
| 55 |
|
|
/* ncurses assert here? */ |
| 56 |
sf-pippijn |
1.3 |
return_unless (copywin (win (), viewport.win (), y, x, 1, 1, |
| 57 |
|
|
viewport.height () - 2, viewport.width () - 2, FALSE) == OK); |
| 58 |
sf-pippijn |
1.1 |
} |