]> ncurses.scripts.mit.edu Git - ncurses.git/blob - c++/cursesw.h
ncurses 5.6 - patch 20070929
[ncurses.git] / c++ / cursesw.h
1 // * This makes emacs happy -*-Mode: C++;-*-
2 /****************************************************************************
3  * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc.              *
4  *                                                                          *
5  * Permission is hereby granted, free of charge, to any person obtaining a  *
6  * copy of this software and associated documentation files (the            *
7  * "Software"), to deal in the Software without restriction, including      *
8  * without limitation the rights to use, copy, modify, merge, publish,      *
9  * distribute, distribute with modifications, sublicense, and/or sell       *
10  * copies of the Software, and to permit persons to whom the Software is    *
11  * furnished to do so, subject to the following conditions:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23  *                                                                          *
24  * Except as contained in this notice, the name(s) of the above copyright   *
25  * holders shall not be used in advertising or otherwise to promote the     *
26  * sale, use or other dealings in this Software without prior written       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 #ifndef NCURSES_CURSESW_H_incl
31 #define NCURSES_CURSESW_H_incl 1
32
33 // $Id: cursesw.h,v 1.44 2007/04/07 18:42:04 tom Exp $
34
35 #include <etip.h>
36
37 extern "C" {
38 #  include   <curses.h>
39 }
40
41 /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
42    Undefine it here, because NCursesWindow uses lines as a method.  */
43 #undef lines
44
45 /* "Convert" macros to inlines. We'll define it as another symbol to avoid
46  * conflict with library symbols.
47  */
48 #undef UNDEF
49 #define UNDEF(name) CUR_ ##name
50
51 #ifdef addch
52 inline int UNDEF(addch)(chtype ch)  { return addch(ch); }
53 #undef addch
54 #define addch UNDEF(addch)
55 #endif
56
57 #ifdef echochar
58 inline int UNDEF(echochar)(chtype ch)  { return echochar(ch); }
59 #undef echochar
60 #define echochar UNDEF(echochar)
61 #endif
62
63 #ifdef insdelln
64 inline int UNDEF(insdelln)(int n)  { return insdelln(n); }
65 #undef insdelln
66 #define insdelln UNDEF(insdelln)
67 #endif
68
69 #ifdef addstr
70 inline int UNDEF(addstr)(const char * str)  { return addstr(str); }
71 #undef addstr
72 #define addstr UNDEF(addstr)
73 #endif
74
75 #ifdef attron
76 inline int UNDEF(attron)(chtype at) { return attron(at); }
77 #undef attron
78 #define attron UNDEF(attron)
79 #endif
80
81 #ifdef attroff
82 inline int UNDEF(attroff)(chtype at) { return attroff(at); }
83 #undef attroff
84 #define attroff UNDEF(attroff)
85 #endif
86
87 #ifdef attrset
88 inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
89 #undef attrset
90 #define attrset UNDEF(attrset)
91 #endif
92
93 #ifdef color_set
94 inline chtype UNDEF(color_set)(short p, void* opts) { return color_set(p, opts); }
95 #undef color_set
96 #define color_set UNDEF(color_set)
97 #endif
98
99 #ifdef border
100 inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
101 { return border(ls, rs, ts, bs, tl, tr, bl, br); }
102 #undef border
103 #define border UNDEF(border)
104 #endif
105
106 #ifdef box
107 inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
108 #undef box
109 #define box UNDEF(box)
110 #endif
111
112 #ifdef mvwhline
113 inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
114   return mvwhline(win, y, x, c, n); }
115 #undef mvwhline
116 #define mvwhline UNDEF(mvwhline)
117 #endif
118
119 #ifdef mvwvline
120 inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
121   return mvwvline(win, y, x, c, n); }
122 #undef mvwvline
123 #define mvwvline UNDEF(mvwvline)
124 #endif
125
126 #ifdef clear
127 inline int UNDEF(clear)()  { return clear(); }
128 #undef clear
129 #define clear UNDEF(clear)
130 #endif
131
132 #ifdef clearok
133 inline int UNDEF(clearok)(WINDOW* win, bool bf)  { return clearok(win, bf); }
134 #undef clearok
135 #define clearok UNDEF(clearok)
136 #else
137 extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
138 #endif
139
140 #ifdef clrtobot
141 inline int UNDEF(clrtobot)()  { return clrtobot(); }
142 #undef clrtobot
143 #define clrtobot UNDEF(clrtobot)
144 #endif
145
146 #ifdef clrtoeol
147 inline int UNDEF(clrtoeol)()  { return clrtoeol(); }
148 #undef clrtoeol
149 #define clrtoeol UNDEF(clrtoeol)
150 #endif
151
152 #ifdef delch
153 inline int UNDEF(delch)()  { return delch(); }
154 #undef delch
155 #define delch UNDEF(delch)
156 #endif
157
158 #ifdef deleteln
159 inline int UNDEF(deleteln)()  { return deleteln(); }
160 #undef deleteln
161 #define deleteln UNDEF(deleteln)
162 #endif
163
164 #ifdef erase
165 inline int UNDEF(erase)()  { return erase(); }
166 #undef erase
167 #define erase UNDEF(erase)
168 #endif
169
170 #ifdef flushok
171 inline int UNDEF(flushok)(WINDOW* _win, bool _bf)  {
172   return flushok(_win, _bf); }
173 #undef flushok
174 #define flushok UNDEF(flushok)
175 #else
176 #define _no_flushok
177 #endif
178
179 #ifdef getch
180 inline int UNDEF(getch)()  { return getch(); }
181 #undef getch
182 #define getch UNDEF(getch)
183 #endif
184
185 #ifdef getstr
186 inline int UNDEF(getstr)(char *_str)  { return getstr(_str); }
187 #undef getstr
188 #define getstr UNDEF(getstr)
189 #endif
190
191 #ifdef instr
192 inline int UNDEF(instr)(char *_str)  { return instr(_str); }
193 #undef instr
194 #define instr UNDEF(instr)
195 #endif
196
197 #ifdef innstr
198 inline int UNDEF(innstr)(char *_str, int n)  { return innstr(_str, n); }
199 #undef innstr
200 #define innstr UNDEF(innstr)
201 #endif
202
203 #ifdef mvwinnstr
204 inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
205   return mvwinnstr(win, y, x, _str, n); }
206 #undef mvwinnstr
207 #define mvwinnstr UNDEF(mvwinnstr)
208 #endif
209
210 #ifdef mvinnstr
211 inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
212   return mvinnstr(y, x, _str, n); }
213 #undef mvinnstr
214 #define mvinnstr UNDEF(mvinnstr)
215 #endif
216
217 #ifdef winsstr
218 inline int UNDEF(winsstr)(WINDOW *w, const char *_str)  {
219   return winsstr(w, _str); }
220 #undef winsstr
221 #define winsstr UNDEF(winsstr)
222 #endif
223
224 #ifdef mvwinsstr
225 inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x,  const char *_str)  {
226   return mvwinsstr(w, y, x, _str); }
227 #undef mvwinsstr
228 #define mvwinsstr UNDEF(mvwinsstr)
229 #endif
230
231 #ifdef insstr
232 inline int UNDEF(insstr)(const char *_str)  {
233   return insstr(_str); }
234 #undef insstr
235 #define insstr UNDEF(insstr)
236 #endif
237
238 #ifdef mvinsstr
239 inline int UNDEF(mvinsstr)(int y, int x, const char *_str)  {
240   return mvinsstr(y, x, _str); }
241 #undef mvinsstr
242 #define mvinsstr UNDEF(mvinsstr)
243 #endif
244
245 #ifdef insnstr
246 inline int UNDEF(insnstr)(const char *_str, int n)  {
247   return insnstr(_str, n); }
248 #undef insnstr
249 #define insnstr UNDEF(insnstr)
250 #endif
251
252 #ifdef mvwinsnstr
253 inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
254   return mvwinsnstr(w, y, x, _str, n); }
255 #undef mvwinsnstr
256 #define mvwinsnstr UNDEF(mvwinsnstr)
257 #endif
258
259 #ifdef mvinsnstr
260 inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
261   return mvinsnstr(y, x, _str, n); }
262 #undef mvinsnstr
263 #define mvinsnstr UNDEF(mvinsnstr)
264 #endif
265
266 #ifdef getnstr
267 inline int UNDEF(getnstr)(char *_str, int n)  { return getnstr(_str, n); }
268 #undef getnstr
269 #define getnstr UNDEF(getnstr)
270 #endif
271
272 #ifdef getyx
273 inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
274   getyx(win, y, x); }
275 #undef getyx
276 #define getyx UNDEF(getyx)
277 #endif
278
279 #ifdef getbegyx
280 inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
281 #undef getbegyx
282 #define getbegyx UNDEF(getbegyx)
283 #endif
284
285 #ifdef getmaxyx
286 inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
287 #undef getmaxyx
288 #define getmaxyx UNDEF(getmaxyx)
289 #endif
290
291 #ifdef hline
292 inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
293 #undef hline
294 #define hline UNDEF(hline)
295 #endif
296
297 #ifdef inch
298 inline chtype UNDEF(inch)()  { return inch(); }
299 #undef inch
300 #define inch UNDEF(inch)
301 #endif
302
303 #ifdef insch
304 inline int UNDEF(insch)(chtype c)  { return insch(c); }
305 #undef insch
306 #define insch UNDEF(insch)
307 #endif
308
309 #ifdef insertln
310 inline int UNDEF(insertln)()  { return insertln(); }
311 #undef insertln
312 #define insertln UNDEF(insertln)
313 #endif
314
315 #ifdef leaveok
316 inline int UNDEF(leaveok)(WINDOW* win, bool bf)  { return leaveok(win, bf); }
317 #undef leaveok
318 #define leaveok UNDEF(leaveok)
319 #else
320 extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
321 #endif
322
323 #ifdef move
324 inline int UNDEF(move)(int x, int y)  { return move(x, y); }
325 #undef move
326 #define move UNDEF(move)
327 #endif
328
329 #ifdef refresh
330 inline int UNDEF(refresh)()  { return refresh(); }
331 #undef refresh
332 #define refresh UNDEF(refresh)
333 #endif
334
335 #ifdef redrawwin
336 inline int UNDEF(redrawwin)(WINDOW *win)  { return redrawwin(win); }
337 #undef redrawwin
338 #define redrawwin UNDEF(redrawwin)
339 #endif
340
341 #ifdef scrl
342 inline int UNDEF(scrl)(int l) { return scrl(l); }
343 #undef scrl
344 #define scrl UNDEF(scrl)
345 #endif
346
347 #ifdef scroll
348 inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
349 #undef scroll
350 #define scroll UNDEF(scroll)
351 #endif
352
353 #ifdef scrollok
354 inline int UNDEF(scrollok)(WINDOW* win, bool bf)  { return scrollok(win, bf); }
355 #undef scrollok
356 #define scrollok UNDEF(scrollok)
357 #else
358 #if     defined(__NCURSES_H)
359 extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
360 #else
361 extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
362 #endif
363 #endif
364
365 #ifdef setscrreg
366 inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
367 #undef setscrreg
368 #define setscrreg UNDEF(setscrreg)
369 #endif
370
371 #ifdef standend
372 inline int UNDEF(standend)()  { return standend(); }
373 #undef standend
374 #define standend UNDEF(standend)
375 #endif
376
377 #ifdef standout
378 inline int UNDEF(standout)()  { return standout(); }
379 #undef standout
380 #define standout UNDEF(standout)
381 #endif
382
383 #ifdef subpad
384 inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
385 { return derwin(p, l, c, y, x); }
386 #undef subpad
387 #define subpad UNDEF(subpad)
388 #endif
389
390 #ifdef timeout
391 inline void UNDEF(timeout)(int delay) { timeout(delay); }
392 #undef timeout
393 #define timeout UNDEF(timeout)
394 #endif
395
396 #ifdef touchline
397 inline int UNDEF(touchline)(WINDOW *win, int s, int c)
398 { return touchline(win, s, c); }
399 #undef touchline
400 #define touchline UNDEF(touchline)
401 #endif
402
403 #ifdef touchwin
404 inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
405 #undef touchwin
406 #define touchwin UNDEF(touchwin)
407 #endif
408
409 #ifdef untouchwin
410 inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
411 #undef untouchwin
412 #define untouchwin UNDEF(untouchwin)
413 #endif
414
415 #ifdef vline
416 inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
417 #undef vline
418 #define vline UNDEF(vline)
419 #endif
420
421 #ifdef waddstr
422 inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
423 #undef waddstr
424 #define waddstr UNDEF(waddstr)
425 #endif
426
427 #ifdef waddchstr
428 inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
429 #undef waddchstr
430 #define waddchstr UNDEF(waddchstr)
431 #endif
432
433 #ifdef wstandend
434 inline int UNDEF(wstandend)(WINDOW *win)  { return wstandend(win); }
435 #undef wstandend
436 #define wstandend UNDEF(wstandend)
437 #endif
438
439 #ifdef wstandout
440 inline int UNDEF(wstandout)(WINDOW *win)  { return wstandout(win); }
441 #undef wstandout
442 #define wstandout UNDEF(wstandout)
443 #endif
444
445
446 #ifdef wattroff
447 inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
448 #undef wattroff
449 #define wattroff UNDEF(wattroff)
450 #endif
451
452 #ifdef chgat
453 inline int UNDEF(chgat)(int n, attr_t attr, short color, const void *opts) {
454   return chgat(n, attr, color, opts); }
455 #undef chgat
456 #define chgat UNDEF(chgat)
457 #endif
458
459 #ifdef mvchgat
460 inline int UNDEF(mvchgat)(int y, int x, int n,
461                           attr_t attr, short color, const void *opts) {
462   return mvchgat(y, x, n, attr, color, opts); }
463 #undef mvchgat
464 #define mvchgat UNDEF(mvchgat)
465 #endif
466
467 #ifdef mvwchgat
468 inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
469                            attr_t attr, short color, const void *opts) {
470   return mvwchgat(win, y, x, n, attr, color, opts); }
471 #undef mvwchgat
472 #define mvwchgat UNDEF(mvwchgat)
473 #endif
474
475 #ifdef wattrset
476 inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
477 #undef wattrset
478 #define wattrset UNDEF(wattrset)
479 #endif
480
481 #ifdef winch
482 inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
483 #undef winch
484 #define winch UNDEF(winch)
485 #endif
486
487 #ifdef mvwaddch
488 inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
489 { return mvwaddch(win, y, x, ch); }
490 #undef mvwaddch
491 #define mvwaddch UNDEF(mvwaddch)
492 #endif
493
494 #ifdef mvwaddchnstr
495 inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, chtype *str, int n)
496 { return mvwaddchnstr(win, y, x, str, n); }
497 #undef mvwaddchnstr
498 #define mvwaddchnstr UNDEF(mvwaddchnstr)
499 #endif
500
501 #ifdef mvwaddchstr
502 inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, chtype *str)
503 { return mvwaddchstr(win, y, x, str); }
504 #undef mvwaddchstr
505 #define mvwaddchstr UNDEF(mvwaddchstr)
506 #endif
507
508 #ifdef addnstr
509 inline int UNDEF(addnstr)(const char *str, int n)
510 { return addnstr(str, n); }
511 #undef addnstr
512 #define addnstr UNDEF(addnstr)
513 #endif
514
515 #ifdef mvwaddnstr
516 inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
517 { return mvwaddnstr(win, y, x, str, n); }
518 #undef mvwaddnstr
519 #define mvwaddnstr UNDEF(mvwaddnstr)
520 #endif
521
522 #ifdef mvwaddstr
523 inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
524 { return mvwaddstr(win, y, x, str); }
525 #undef mvwaddstr
526 #define mvwaddstr UNDEF(mvwaddstr)
527 #endif
528
529 #ifdef mvwdelch
530 inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
531 { return mvwdelch(win, y, x); }
532 #undef mvwdelch
533 #define mvwdelch UNDEF(mvwdelch)
534 #endif
535
536 #ifdef mvwgetch
537 inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
538 #undef mvwgetch
539 #define mvwgetch UNDEF(mvwgetch)
540 #endif
541
542 #ifdef mvwgetstr
543 inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
544 {return mvwgetstr(win, y, x, str);}
545 #undef mvwgetstr
546 #define mvwgetstr UNDEF(mvwgetstr)
547 #endif
548
549 #ifdef mvwgetnstr
550 inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
551 {return mvwgetnstr(win, y, x, str, n);}
552 #undef mvwgetnstr
553 #define mvwgetnstr UNDEF(mvwgetnstr)
554 #endif
555
556 #ifdef mvwinch
557 inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
558   return mvwinch(win, y, x);}
559 #undef mvwinch
560 #define mvwinch UNDEF(mvwinch)
561 #endif
562
563 #ifdef mvwinsch
564 inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
565 { return mvwinsch(win, y, x, c); }
566 #undef mvwinsch
567 #define mvwinsch UNDEF(mvwinsch)
568 #endif
569
570 #ifdef mvaddch
571 inline int UNDEF(mvaddch)(int y, int x, chtype ch)
572 { return mvaddch(y, x, ch); }
573 #undef mvaddch
574 #define mvaddch UNDEF(mvaddch)
575 #endif
576
577 #ifdef mvaddnstr
578 inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
579 { return mvaddnstr(y, x, str, n); }
580 #undef mvaddnstr
581 #define mvaddnstr UNDEF(mvaddnstr)
582 #endif
583
584 #ifdef mvaddstr
585 inline int UNDEF(mvaddstr)(int y, int x, const char * str)
586 { return mvaddstr(y, x, str); }
587 #undef mvaddstr
588 #define mvaddstr UNDEF(mvaddstr)
589 #endif
590
591 #ifdef mvdelch
592 inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
593 #undef mvdelch
594 #define mvdelch UNDEF(mvdelch)
595 #endif
596
597 #ifdef mvgetch
598 inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
599 #undef mvgetch
600 #define mvgetch UNDEF(mvgetch)
601 #endif
602
603 #ifdef mvgetstr
604 inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
605 #undef mvgetstr
606 #define mvgetstr UNDEF(mvgetstr)
607 #endif
608
609 #ifdef mvgetnstr
610 inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
611   return mvgetnstr(y, x, str, n);}
612 #undef mvgetnstr
613 #define mvgetnstr UNDEF(mvgetnstr)
614 #endif
615
616 #ifdef mvinch
617 inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
618 #undef mvinch
619 #define mvinch UNDEF(mvinch)
620 #endif
621
622 #ifdef mvinsch
623 inline int UNDEF(mvinsch)(int y, int x, chtype c)
624 { return mvinsch(y, x, c); }
625 #undef mvinsch
626 #define mvinsch UNDEF(mvinsch)
627 #endif
628
629 #ifdef napms
630 inline void UNDEF(napms)(unsigned long x) { napms(x); }
631 #undef napms
632 #define napms UNDEF(napms)
633 #endif
634
635 #ifdef fixterm
636 inline int UNDEF(fixterm)(void) { return fixterm(); }
637 #undef fixterm
638 #define fixterm UNDEF(fixterm)
639 #endif
640
641 #ifdef resetterm
642 inline int UNDEF(resetterm)(void) { return resetterm(); }
643 #undef resetterm
644 #define resetterm UNDEF(resetterm)
645 #endif
646
647 #ifdef saveterm
648 inline int UNDEF(saveterm)(void) { return saveterm(); }
649 #undef saveterm
650 #define saveterm UNDEF(saveterm)
651 #endif
652
653 #ifdef crmode
654 inline int UNDEF(crmode)(void) { return crmode(); }
655 #undef crmode
656 #define crmode UNDEF(crmode)
657 #endif
658
659 #ifdef nocrmode
660 inline int UNDEF(nocrmode)(void) { return nocrmode(); }
661 #undef nocrmode
662 #define nocrmode UNDEF(nocrmode)
663 #endif
664
665 #ifdef getbkgd
666 inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
667 #undef getbkgd
668 #define getbkgd UNDEF(getbkgd)
669 #endif
670
671 #ifdef bkgd
672 inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
673 #undef bkgd
674 #define bkgd UNDEF(bkgd)
675 #endif
676
677 #ifdef bkgdset
678 inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
679 #undef bkgdset
680 #define bkgdset UNDEF(bkgdset)
681 #endif
682
683 /*
684  *
685  * C++ class for windows.
686  *
687  */
688
689 extern "C" int     _nc_ripoffline(int, int (*init)(WINDOW*, int));
690 extern "C" int     _nc_xx_ripoff_init(WINDOW *, int);
691 extern "C" int     _nc_has_mouse(void);
692
693 class NCURSES_IMPEXP NCursesWindow
694 {
695   friend class NCursesMenu;
696   friend class NCursesForm;
697
698 private:
699   static bool    b_initialized;
700   static void    initialize();
701   void           constructing();
702   friend int     _nc_xx_ripoff_init(WINDOW *, int);
703
704   void           set_keyboard();
705
706   short          getcolor(int getback) const;
707   short          getPair() const;
708
709   static int     setpalette(short fore, short back, short pair);
710   static int     colorInitialized;
711
712   // This private constructor is only used during the initialization
713   // of windows generated by ripoffline() calls.
714   NCursesWindow(WINDOW* win, int ncols);
715
716 protected:
717   virtual void   err_handler(const char *) const THROWS(NCursesException);
718   // Signal an error with the given message text.
719
720   static long count;        // count of all active windows:
721   //   We rely on the c++ promise that
722   //   all otherwise uninitialized
723   //   static class vars are set to 0
724
725   WINDOW*        w;                // the curses WINDOW
726
727   bool           alloced;          // TRUE if we own the WINDOW
728
729   NCursesWindow* par;              // parent, if subwindow
730   NCursesWindow* subwins;          // head of subwindows list
731   NCursesWindow* sib;              // next subwindow of parent
732
733   void           kill_subwindows(); // disable all subwindows
734   // Destroy all subwindows.
735
736   /* Only for use by derived classes. They are then in charge to
737      fill the member variables correctly. */
738   NCursesWindow();
739
740 public:
741   NCursesWindow(WINDOW* window);   // useful only for stdscr
742
743   NCursesWindow(int nlines,        // number of lines
744                 int ncols,         // number of columns
745                 int begin_y,       // line origin
746                 int begin_x);      // col origin
747
748   NCursesWindow(NCursesWindow& par,// parent window
749                 int nlines,        // number of lines
750                 int ncols,         // number of columns
751                 int begin_y,       // absolute or relative
752                 int begin_x,       //   origins:
753                 char absrel = 'a');// if `a', begin_y & begin_x are
754   // absolute screen pos, else if `r', they are relative to par origin
755
756   NCursesWindow(NCursesWindow& par,// parent window
757                 bool do_box = TRUE);
758   // this is the very common case that we want to create the subwindow that
759   // is two lines and two columns smaller and begins at (1,1).
760   // We may automatically request the box around it.
761
762   NCursesWindow& operator=(const NCursesWindow& rhs)
763   {
764     if (this != &rhs)
765       *this = rhs;
766     return *this;
767   }
768
769   NCursesWindow(const NCursesWindow& rhs)
770     : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
771   {
772   }
773
774   virtual ~NCursesWindow();
775
776   NCursesWindow Clone();
777   // Make an exact copy of the window.
778
779   // Initialization.
780   static void    useColors(void);
781   // Call this routine very early if you want to have colors.
782
783   static int ripoffline(int ripoff_lines,
784                         int (*init)(NCursesWindow& win));
785   // This function is used to generate a window of ripped-of lines.
786   // If the argument is positive, lines are removed from the top, if it
787   // is negative lines are removed from the bottom. This enhances the
788   // lowlevel ripoffline() function because it uses the internal
789   // implementation that allows to remove more than just a single line.
790   // This function must be called before any other ncurses function. The
791   // creation of the window is deferred until ncurses gets initialized.
792   // The initialization function is then called.
793
794   // -------------------------------------------------------------------------
795   // terminal status
796   // -------------------------------------------------------------------------
797   int            lines() const { initialize(); return LINES; }
798   // Number of lines on terminal, *not* window
799
800   int            cols() const { initialize(); return COLS; }
801   // Number of cols  on terminal, *not* window
802
803   int            tabsize() const { initialize(); return TABSIZE; }
804   // Size of a tab on terminal, *not* window
805
806   static int     NumberOfColors();
807   // Number of available colors
808
809   int            colors() const { return NumberOfColors(); }
810   // Number of available colors
811
812   // -------------------------------------------------------------------------
813   // window status
814   // -------------------------------------------------------------------------
815   int            height() const { return maxy() + 1; }
816   // Number of lines in this window
817
818   int            width() const { return maxx() + 1; }
819   // Number of columns in this window
820
821   int            begx() const { return getbegx(w); }
822   // Column of top left corner relative to stdscr
823
824   int            begy() const { return getbegy(w); }
825   // Line of top left corner relative to stdscr
826
827   int            maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
828   // Largest x coord in window
829
830   int            maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
831   // Largest y coord in window
832
833   short          getcolor() const;
834   // Actual color pair
835
836   short          foreground() const { return getcolor(0); }
837   // Actual foreground color
838
839   short          background() const { return getcolor(1); }
840   // Actual background color
841
842   int            setpalette(short fore, short back);
843   // Set color palette entry
844
845   int            setcolor(short pair);
846   // Set actually used palette entry
847
848   // -------------------------------------------------------------------------
849   // window positioning
850   // -------------------------------------------------------------------------
851   virtual int    mvwin(int begin_y, int begin_x) {
852     return ::mvwin(w, begin_y, begin_x); }
853   // Move window to new position with the new position as top left corner.
854   // This is virtual because it is redefined in NCursesPanel.
855
856   // -------------------------------------------------------------------------
857   // coordinate positioning
858   // -------------------------------------------------------------------------
859   int            move(int y, int x) { return ::wmove(w, y, x); }
860   // Move cursor the this position
861
862   void           getyx(int& y, int& x) const { ::getyx(w, y, x); }
863   // Get current position of the cursor
864
865   int            mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
866     return ::mvcur(oldrow, oldcol, newrow, newcol); }
867   // Perform lowlevel cursor motion that takes effect immediately.
868
869   // -------------------------------------------------------------------------
870   // input
871   // -------------------------------------------------------------------------
872   int            getch() { return ::wgetch(w); }
873   // Get a keystroke from the window.
874
875   int            getch(int y, int x) { return ::mvwgetch(w, y, x); }
876   // Move cursor to position and get a keystroke from the window
877
878   int            getstr(char* str, int n=-1) {
879     return ::wgetnstr(w, str, n); }
880   // Read a series of characters into str until a newline or carriage return
881   // is received. Read at most n characters. If n is negative, the limit is
882   // ignored.
883
884   int            getstr(int y, int x, char* str, int n=-1) {
885     return ::mvwgetnstr(w, y, x, str, n); }
886   // Move the cursor to the requested position and then perform the getstr()
887   // as described above.
888
889   int            instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
890   // Get a string of characters from the window into the buffer s. Retrieve
891   // at most n characters, if n is negative retrieve all characters up to the
892   // end of the current line. Attributes are stripped from the characters.
893
894   int            instr(int y, int x, char *s, int n=-1) {
895     return ::mvwinnstr(w, y, x, s, n); }
896   // Move the cursor to the requested position and then perform the instr()
897   // as described above.
898
899   int            scanw(const char* fmt, ...)
900     // Perform a scanw function from the window.
901 #if __GNUG__ >= 2
902     __attribute__ ((format (scanf, 2, 3)));
903 #else
904   ;
905 #endif
906
907   int            scanw(int y, int x, const char* fmt, ...)
908     // Move the cursor to the requested position and then perform a scanw
909     // from the window.
910 #if __GNUG__ >= 2
911     __attribute__ ((format (scanf, 4, 5)));
912 #else
913   ;
914 #endif
915
916   // -------------------------------------------------------------------------
917   // output
918   // -------------------------------------------------------------------------
919   int            addch(const chtype ch) { return ::waddch(w, ch); }
920   // Put attributed character to the window.
921
922   int            addch(int y, int x, const chtype ch) {
923     return ::mvwaddch(w, y, x, ch); }
924   // Move cursor to the requested position and then put attributed character
925   // to the window.
926
927   int            echochar(const chtype ch) { return ::wechochar(w, ch); }
928   // Put attributed character to the window and refresh it immediately.
929
930   int            addstr(const char* str, int n=-1) {
931     return ::waddnstr(w, str, n); }
932   // Write the string str to the window, stop writing if the terminating
933   // NUL or the limit n is reached. If n is negative, it is ignored.
934
935   int            addstr(int y, int x, const char * str, int n=-1) {
936     return ::mvwaddnstr(w, y, x, str, n); }
937   // Move the cursor to the requested position and then perform the addstr
938   // as described above.
939
940   int            printw(const char* fmt, ...)
941     // Do a formatted print to the window.
942 #if (__GNUG__ >= 2) && !defined(printf)
943     __attribute__ ((format (printf, 2, 3)));
944 #else
945   ;
946 #endif
947
948   int            printw(int y, int x, const char * fmt, ...)
949     // Move the cursor and then do a formatted print to the window.
950 #if (__GNUG__ >= 2) && !defined(printf)
951     __attribute__ ((format (printf, 4, 5)));
952 #else
953   ;
954 #endif
955
956   chtype         inch() const { return ::winch(w); }
957   // Retrieve attributed character under the current cursor position.
958
959   chtype         inch(int y, int x) { return ::mvwinch(w, y, x); }
960   // Move cursor to requested position and then retrieve attributed character
961   // at this position.
962
963   int            insch(chtype ch) { return ::winsch(w, ch); }
964   // Insert attributed character into the window before current cursor
965   // position.
966
967   int            insch(int y, int x, chtype ch) {
968     return ::mvwinsch(w, y, x, ch); }
969   // Move cursor to requested position and then insert the attributed
970   // character before that position.
971
972   int            insertln() { return ::winsdelln(w, 1); }
973   // Insert an empty line above the current line.
974
975   int            insdelln(int n=1) { return ::winsdelln(w, n); }
976   // If n>0 insert that many lines above the current line. If n<0 delete
977   // that many lines beginning with the current line.
978
979   int            insstr(const char *s, int n=-1) {
980     return ::winsnstr(w, s, n); }
981   // Insert the string into the window before the current cursor position.
982   // Insert stops at end of string or when the limit n is reached. If n is
983   // negative, it is ignored.
984
985   int            insstr(int y, int x, const char *s, int n=-1) {
986     return ::mvwinsnstr(w, y, x, s, n); }
987   // Move the cursor to the requested position and then perform the insstr()
988   // as described above.
989
990   int            attron (chtype at) { return ::wattron (w, at); }
991   // Switch on the window attributes;
992
993   int            attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
994   // Switch off the window attributes;
995
996   int            attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
997   // Set the window attributes;
998
999   int            color_set(short color_pair_number, void* opts=NULL) {
1000     return ::wcolor_set(w, color_pair_number, opts); }
1001   // Set the window color attribute;
1002
1003   int            chgat(int n, attr_t attr, short color, const void *opts=NULL) {
1004     return ::wchgat(w, n, attr, color, opts); }
1005   // Change the attributes of the next n characters in the current line. If
1006   // n is negative or greater than the number of remaining characters in the
1007   // line, the attributes will be changed up to the end of the line.
1008
1009   int            chgat(int y, int x,
1010                        int n, attr_t attr, short color, const void *opts=NULL) {
1011     return ::mvwchgat(w, y, x, n, attr, color, opts); }
1012   // Move the cursor to the requested position and then perform chgat() as
1013   // described above.
1014
1015   // -------------------------------------------------------------------------
1016   // background
1017   // -------------------------------------------------------------------------
1018   chtype         getbkgd() const { return ::getbkgd(w); }
1019   // Get current background setting.
1020
1021   int            bkgd(const chtype ch) { return ::wbkgd(w, ch); }
1022   // Set the background property and apply it to the window.
1023
1024   void           bkgdset(chtype ch) { ::wbkgdset(w, ch); }
1025   // Set the background property.
1026
1027   // -------------------------------------------------------------------------
1028   // borders
1029   // -------------------------------------------------------------------------
1030   int            box(chtype vert=0, chtype  hor=0) {
1031     return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
1032   // Draw a box around the window with the given vertical and horizontal
1033   // drawing characters. If you specify a zero as character, curses will try
1034   // to find a "nice" character.
1035
1036   int            border(chtype left=0, chtype right=0,
1037                         chtype top =0, chtype bottom=0,
1038                         chtype top_left =0, chtype top_right=0,
1039                         chtype bottom_left =0, chtype bottom_right=0) {
1040     return ::wborder(w, left, right, top, bottom, top_left, top_right,
1041                      bottom_left, bottom_right); }
1042   // Draw a border around the window with the given characters for the
1043   // various parts of the border. If you pass zero for a character, curses
1044   // will try to find "nice" characters.
1045
1046   // -------------------------------------------------------------------------
1047   // lines and boxes
1048   // -------------------------------------------------------------------------
1049   int            hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
1050   // Draw a horizontal line of len characters with the given character. If
1051   // you pass zero for the character, curses will try to find a "nice" one.
1052
1053   int            hline(int y, int x, int len, chtype ch=0) {
1054     return ::mvwhline(w, y, x, ch, len); }
1055   // Move the cursor to the requested position and then draw a horizontal line.
1056
1057   int            vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
1058   // Draw a vertical line of len characters with the given character. If
1059   // you pass zero for the character, curses will try to find a "nice" one.
1060
1061   int            vline(int y, int x, int len, chtype ch=0) {
1062     return ::mvwvline(w, y, x, ch, len); }
1063   // Move the cursor to the requested position and then draw a vertical line.
1064
1065   // -------------------------------------------------------------------------
1066   // erasure
1067   // -------------------------------------------------------------------------
1068   int            erase() { return ::werase(w); }
1069   // Erase the window.
1070
1071   int            clear() { return ::wclear(w); }
1072   // Clear the window.
1073
1074   int            clearok(bool bf) { return ::clearok(w, bf); }
1075   // Set/Reset the clear flag. If set, the next refresh() will clear the
1076   // screen.
1077
1078   int            clrtobot() { return ::wclrtobot(w); }
1079   // Clear to the end of the window.
1080
1081   int            clrtoeol() { return ::wclrtoeol(w); }
1082   // Clear to the end of the line.
1083
1084   int            delch() { return ::wdelch(w); }
1085   // Delete character under the cursor.
1086
1087   int            delch(int y, int x) { return ::mvwdelch(w, y, x); }
1088   // Move cursor to requested position and delete the character under the
1089   // cursor.
1090
1091   int            deleteln() { return ::winsdelln(w, -1); }
1092   // Delete the current line.
1093
1094   // -------------------------------------------------------------------------
1095   // screen control
1096   // -------------------------------------------------------------------------
1097   int            scroll(int amount=1) { return ::wscrl(w, amount); }
1098   // Scroll amount lines. If amount is positive, scroll up, otherwise
1099   // scroll down.
1100
1101   int            scrollok(bool bf) { return ::scrollok(w, bf); }
1102   // If bf is TRUE, window scrolls if cursor is moved off the bottom
1103   // edge of the window or a scrolling region, otherwise the cursor is left
1104   // at the bottom line.
1105
1106   int            setscrreg(int from, int to) {
1107     return ::wsetscrreg(w, from, to); }
1108   // Define a soft scrolling region.
1109
1110   int            idlok(bool bf) { return ::idlok(w, bf); }
1111   // If bf is TRUE, use insert/delete line hardware support if possible.
1112   // Otherwise do it in software.
1113
1114
1115   void           idcok(bool bf) { ::idcok(w, bf); }
1116   // If bf is TRUE, use insert/delete character hardware support if possible.
1117   // Otherwise do it in software.
1118
1119   int            touchwin()   { return ::wtouchln(w, 0, height(), 1); }
1120   // Mark the whole window as modified.
1121
1122   int            untouchwin() { return ::wtouchln(w, 0, height(), 0); }
1123   // Mark the whole window as unmodified.
1124
1125   int            touchln(int s, int cnt, bool changed=TRUE) {
1126     return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
1127   // Mark cnt lines beginning from line s as changed or unchanged, depending
1128   // on the value of the changed flag.
1129
1130   bool           is_linetouched(int line) const {
1131     return (::is_linetouched(w, line) ? TRUE:FALSE); }
1132   // Return TRUE if line is marked as changed, FALSE otherwise
1133
1134   bool           is_wintouched() const {
1135     return (::is_wintouched(w) ? TRUE:FALSE); }
1136   // Return TRUE if window is marked as changed, FALSE otherwise
1137
1138   int            leaveok(bool bf) { return ::leaveok(w, bf); }
1139   // If bf is TRUE, curses will leave the cursor after an update whereever
1140   // it is after the update.
1141
1142   int            redrawln(int from, int n) { return ::wredrawln(w, from, n); }
1143   // Redraw n lines starting from the requested line
1144
1145   int            redrawwin() { return ::wredrawln(w, 0, height()); }
1146   // Redraw the whole window
1147
1148   int            doupdate()  { return ::doupdate(); }
1149   // Do all outputs to make the physical screen looking like the virtual one
1150
1151   void           syncdown()  { ::wsyncdown(w); }
1152   // Propagate the changes down to all descendant windows
1153
1154   void           syncup()    { ::wsyncup(w); }
1155   // Propagate the changes up in the hierarchy
1156
1157   void           cursyncup() { ::wcursyncup(w); }
1158   // Position the cursor in all ancestor windows corresponding to our setting
1159
1160   int            syncok(bool bf) { return ::syncok(w, bf); }
1161   // If called with bf=TRUE, syncup() is called whenever the window is changed
1162
1163 #ifndef _no_flushok
1164   int            flushok(bool bf) { return ::flushok(w, bf); }
1165 #endif
1166
1167   void           immedok(bool bf) { ::immedok(w, bf); }
1168   // If called with bf=TRUE, any change in the window will cause an
1169   // automatic immediate refresh()
1170
1171   int            keypad(bool bf) { return ::keypad(w, bf); }
1172   // If called with bf=TRUE, the application will interpret function keys.
1173
1174   int            meta(bool bf) { return ::meta(w, bf); }
1175   // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
1176   // 7-Bit characters are generated.
1177
1178   int            standout() { return ::wstandout(w); }
1179   // Enable "standout" attributes
1180
1181   int            standend() { return ::wstandend(w); }
1182   // Disable "standout" attributes
1183
1184   // -------------------------------------------------------------------------
1185   // The next two are virtual, because we redefine them in the
1186   // NCursesPanel class.
1187   // -------------------------------------------------------------------------
1188   virtual int    refresh() { return ::wrefresh(w); }
1189   // Propagate the changes in this window to the virtual screen and call
1190   // doupdate(). This is redefined in NCursesPanel.
1191
1192   virtual int    noutrefresh() { return ::wnoutrefresh(w); }
1193   // Propagate the changes in this window to the virtual screen. This is
1194   // redefined in NCursesPanel.
1195
1196   // -------------------------------------------------------------------------
1197   // multiple window control
1198   // -------------------------------------------------------------------------
1199   int            overlay(NCursesWindow& win) {
1200     return ::overlay(w, win.w); }
1201   // Overlay this window over win.
1202
1203   int            overwrite(NCursesWindow& win) {
1204     return ::overwrite(w, win.w); }
1205   // Overwrite win with this window.
1206
1207   int            copywin(NCursesWindow& win,
1208                          int sminrow, int smincol,
1209                          int dminrow, int dmincol,
1210                          int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
1211     return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
1212                      dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
1213   // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
1214   // dmaxrow,dmaxcol with the rectangle in this window beginning at
1215   // sminrow,smincol.
1216
1217   // -------------------------------------------------------------------------
1218   // Mouse related
1219   // -------------------------------------------------------------------------
1220   bool has_mouse() const;
1221   // Return TRUE if terminal supports a mouse, FALSE otherwise
1222
1223   // -------------------------------------------------------------------------
1224   // traversal support
1225   // -------------------------------------------------------------------------
1226   NCursesWindow*  child() { return subwins; }
1227   // Get the first child window.
1228
1229   NCursesWindow*  sibling() { return sib; }
1230   // Get the next child of my parent.
1231
1232   NCursesWindow*  parent() { return par; }
1233   // Get my parent.
1234
1235   bool isDescendant(NCursesWindow& win);
1236   // Return TRUE if win is a descendant of this.
1237 };
1238
1239 // -------------------------------------------------------------------------
1240 // We leave this here for compatibility reasons.
1241 // -------------------------------------------------------------------------
1242 class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
1243 {
1244 public:
1245   NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
1246     : NCursesWindow(window) {
1247       useColors(); }
1248
1249   NCursesColorWindow(int nlines,        // number of lines
1250                      int ncols,         // number of columns
1251                      int begin_y,       // line origin
1252                      int begin_x)       // col origin
1253     : NCursesWindow(nlines, ncols, begin_y, begin_x) {
1254       useColors(); }
1255
1256   NCursesColorWindow(NCursesWindow& parentWin,// parent window
1257                      int nlines,        // number of lines
1258                      int ncols,         // number of columns
1259                      int begin_y,       // absolute or relative
1260                      int begin_x,       //   origins:
1261                      char absrel = 'a') // if `a', by & bx are
1262     : NCursesWindow(parentWin,
1263                     nlines, ncols,      // absolute screen pos,
1264                     begin_y, begin_x,   // else if `r', they are
1265                     absrel ) {          // relative to par origin
1266       useColors(); }
1267 };
1268
1269 // These enum definitions really belong inside the NCursesPad class, but only
1270 // recent compilers support that feature.
1271
1272   typedef enum {
1273     REQ_PAD_REFRESH = KEY_MAX + 1,
1274     REQ_PAD_UP,
1275     REQ_PAD_DOWN,
1276     REQ_PAD_LEFT,
1277     REQ_PAD_RIGHT,
1278     REQ_PAD_EXIT
1279   } Pad_Request;
1280
1281   const Pad_Request PAD_LOW  = REQ_PAD_REFRESH;   // lowest  op-code
1282   const Pad_Request PAD_HIGH = REQ_PAD_EXIT;      // highest op-code
1283
1284 // -------------------------------------------------------------------------
1285 // Pad Support. We allow an association of a pad with a "real" window
1286 // through which the pad may be viewed.
1287 // -------------------------------------------------------------------------
1288 class NCURSES_IMPEXP NCursesPad : public NCursesWindow
1289 {
1290 private:
1291   NCursesWindow* viewWin;       // the "viewport" window
1292   NCursesWindow* viewSub;       // the "viewport" subwindow
1293
1294   int h_gridsize, v_gridsize;
1295
1296 protected:
1297   int min_row, min_col;         // top left row/col of the pads display area
1298
1299   NCursesWindow* Win(void) const {
1300     // Get the window into which the pad should be copied (if any)
1301     return (viewSub?viewSub:(viewWin?viewWin:0));
1302   }
1303
1304   NCursesWindow* getWindow(void) const {
1305     return viewWin;
1306   }
1307
1308   NCursesWindow* getSubWindow(void) const {
1309     return viewSub;
1310   }
1311
1312   virtual int driver (int key);      // Virtualize keystroke key
1313   // The driver translates the keystroke c into an Pad_Request
1314
1315   virtual void OnUnknownOperation(int pad_req) {
1316     ::beep();
1317   }
1318   // This is called if the driver returns an unknown op-code
1319
1320   virtual void OnNavigationError(int pad_req) {
1321     ::beep();
1322   }
1323   // This is called if a navigation request couldn't be satisfied
1324
1325   virtual void OnOperation(int pad_req) {
1326   };
1327   // OnOperation is called if a Pad_Operation was executed and just before
1328   // the refresh() operation is done.
1329
1330 public:
1331   NCursesPad(int nlines, int ncols);
1332   // create a pad with the given size
1333
1334   NCursesPad& operator=(const NCursesPad& rhs)
1335   {
1336     if (this != &rhs) {
1337       *this = rhs;
1338       NCursesWindow::operator=(rhs);
1339     }
1340     return *this;
1341   }
1342
1343   NCursesPad(const NCursesPad& rhs)
1344     : NCursesWindow(rhs),
1345       viewWin(rhs.viewWin),
1346       viewSub(rhs.viewSub),
1347       h_gridsize(rhs.h_gridsize),
1348       v_gridsize(rhs.v_gridsize),
1349       min_row(rhs.min_row),
1350       min_col(rhs.min_col)
1351   {
1352   }
1353
1354   virtual ~NCursesPad() {}
1355
1356   int echochar(const chtype ch) { return ::pechochar(w, ch); }
1357   // Put the attributed character onto the pad and immediately do a
1358   // prefresh().
1359
1360   int refresh();
1361   // If a viewport is defined the pad is displayed in this window, otherwise
1362   // this is a noop.
1363
1364   int refresh(int pminrow, int pmincol,
1365               int sminrow, int smincol,
1366               int smaxrow, int smaxcol) {
1367     return ::prefresh(w, pminrow, pmincol,
1368                       sminrow, smincol, smaxrow, smaxcol);
1369   }
1370   // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
1371   // on the screen. <b>refresh</b> copies a rectangle of this size beginning
1372   // with top left corner pminrow,pmincol onto the screen and calls doupdate().
1373
1374   int noutrefresh();
1375   // If a viewport is defined the pad is displayed in this window, otherwise
1376   // this is a noop.
1377
1378   int noutrefresh(int pminrow, int pmincol,
1379                   int sminrow, int smincol,
1380                   int smaxrow, int smaxcol) {
1381     return ::pnoutrefresh(w, pminrow, pmincol,
1382                           sminrow, smincol, smaxrow, smaxcol);
1383   }
1384   // Does the same as refresh() but without calling doupdate().
1385
1386   virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
1387   // Add the window "view" as viewing window to the pad.
1388
1389   virtual void setSubWindow(NCursesWindow& sub);
1390   // Use the subwindow "sub" of the viewport window for the actual viewing.
1391   // The full viewport window is usually used to provide some decorations
1392   // like frames, titles etc.
1393
1394   virtual void operator() (void);
1395   // Perform Pad's operation
1396 };
1397
1398 // A FramedPad is constructed always with a viewport window. This viewport
1399 // will be framed (by a box() command) and the interior of the box is the
1400 // viewport subwindow. On the frame we display scrollbar sliders.
1401 class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
1402 {
1403 protected:
1404   virtual void OnOperation(int pad_req);
1405
1406 public:
1407   NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
1408                    int v_grid = 1, int h_grid = 1)
1409     : NCursesPad(nlines, ncols) {
1410     NCursesPad::setWindow(win, v_grid, h_grid);
1411     NCursesPad::setSubWindow(*(new NCursesWindow(win)));
1412   }
1413   // Construct the FramedPad with the given Window win as viewport.
1414
1415   virtual ~NCursesFramedPad() {
1416     delete getSubWindow();
1417   }
1418
1419   void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
1420     err_handler("Operation not allowed");
1421   }
1422   // Disable this call; the viewport is already defined
1423
1424   void setSubWindow(NCursesWindow& sub) {
1425     err_handler("Operation not allowed");
1426   }
1427   // Disable this call; the viewport subwindow is already defined
1428
1429 };
1430
1431 #endif /* NCURSES_CURSESW_H_incl */