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