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