ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/backend/ncxx/pad.cpp
Revision: 1.2
Committed: Mon Oct 18 14:11:47 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.1: +3 -3 lines
Log Message:
check and log but do not die when ncurses stuff fails

File Contents

# User Rev Content
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/assert.hh>
11     #include <ncurses/window.hh>
12    
13     #include <stdexcept>
14    
15     using ncurses::pad;
16    
17     pad::pad ()
18     : pad_ (newpad (1, 1), delwin)
19     {
20     if (!pad_)
21     throw runtime_error ("newpad failed");
22     keypad (win (), TRUE); /* initialize advanced keycodes for this window */
23     }
24    
25     pad::~pad ()
26     {
27     }
28    
29     void
30     pad::resize (int w, int h)
31     {
32 sf-pippijn 1.2 return_unless (wresize (win (), h, w) == OK);
33 sf-pippijn 1.1 }
34    
35     int
36     pad::width () const
37     {
38     int x, y;
39    
40     getmaxyx (win (), y, x);
41     return x;
42     }
43    
44     int
45     pad::height () const
46     {
47     int x, y;
48    
49     getmaxyx (win (), y, x);
50     return y;
51     }
52    
53     void
54     pad::draw (window &viewport, int x, int y)
55     {
56     /* ncurses assert here? */
57 sf-pippijn 1.2 return_unless (copywin (win (), viewport.win (), y, x, 0, 0,
58     viewport.height () - 1, viewport.width () - 1, FALSE) == OK);
59 sf-pippijn 1.1 }