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 <ndk++/pad.hh> |
9 |
|
10 |
#include <ndk++/window.hh> |
11 |
|
12 |
#include <stdexcept> |
13 |
|
14 |
using ndk::pad; |
15 |
|
16 |
pad::pad () |
17 |
: pad_ (newpad (1, 1), delwin) |
18 |
{ |
19 |
if (!pad_) |
20 |
throw std::runtime_error ("newpad failed"); |
21 |
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 |
return_unless (wresize (win (), h, w) == OK); |
32 |
} |
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 |
return_unless (copywin (win (), viewport.win (), y, x, 1, 1, |
56 |
viewport.height () - 2, viewport.width () - 2, FALSE) == OK); |
57 |
} |