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