+ : NCursesWindow(parentWin,
+ nlines, ncols, // absolute screen pos,
+ begin_y, begin_x, // else if `r', they are
+ absrel ) { // relative to par origin
+ useColors(); }
+};
+
+// These enum definitions really belong inside the NCursesPad class, but only
+// recent compilers support that feature.
+
+ typedef enum {
+ REQ_PAD_REFRESH = KEY_MAX + 1,
+ REQ_PAD_UP,
+ REQ_PAD_DOWN,
+ REQ_PAD_LEFT,
+ REQ_PAD_RIGHT,
+ REQ_PAD_EXIT
+ } Pad_Request;
+
+ const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code
+ const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code
+
+// -------------------------------------------------------------------------
+// Pad Support. We allow an association of a pad with a "real" window
+// through which the pad may be viewed.
+// -------------------------------------------------------------------------
+class NCURSES_IMPEXP NCursesPad : public NCursesWindow
+{
+private:
+ NCursesWindow* viewWin; // the "viewport" window
+ NCursesWindow* viewSub; // the "viewport" subwindow
+
+ int h_gridsize, v_gridsize;
+
+protected:
+ int min_row, min_col; // top left row/col of the pads display area
+
+ NCursesWindow* Win(void) const {
+ // Get the window into which the pad should be copied (if any)
+ return (viewSub?viewSub:(viewWin?viewWin:0));
+ }
+
+ NCursesWindow* getWindow(void) const {
+ return viewWin;
+ }
+
+ NCursesWindow* getSubWindow(void) const {
+ return viewSub;
+ }
+
+ virtual int driver (int key); // Virtualize keystroke key
+ // The driver translates the keystroke c into an Pad_Request
+
+ virtual void OnUnknownOperation(int pad_req) {
+ (void) pad_req;
+ ::beep();
+ }
+ // This is called if the driver returns an unknown op-code
+
+ virtual void OnNavigationError(int pad_req) {
+ (void) pad_req;
+ ::beep();
+ }
+ // This is called if a navigation request couldn't be satisfied
+
+ virtual void OnOperation(int pad_req) {
+ (void) pad_req;
+ };
+ // OnOperation is called if a Pad_Operation was executed and just before
+ // the refresh() operation is done.
+
+public:
+ NCursesPad(int nlines, int ncols);
+ // create a pad with the given size
+
+ NCursesPad& operator=(const NCursesPad& rhs)
+ {
+ if (this != &rhs) {
+ *this = rhs;
+ NCursesWindow::operator=(rhs);
+ }
+ return *this;
+ }
+
+ NCursesPad(const NCursesPad& rhs)
+ : NCursesWindow(rhs),
+ viewWin(rhs.viewWin),
+ viewSub(rhs.viewSub),
+ h_gridsize(rhs.h_gridsize),
+ v_gridsize(rhs.v_gridsize),
+ min_row(rhs.min_row),
+ min_col(rhs.min_col)
+ {
+ }
+
+ virtual ~NCursesPad() {}
+
+ int echochar(const chtype ch) { return ::pechochar(w, ch); }
+ // Put the attributed character onto the pad and immediately do a
+ // prefresh().
+
+ int refresh();
+ // If a viewport is defined the pad is displayed in this window, otherwise
+ // this is a noop.
+
+ int refresh(int pminrow, int pmincol,
+ int sminrow, int smincol,
+ int smaxrow, int smaxcol) {
+ return ::prefresh(w, pminrow, pmincol,
+ sminrow, smincol, smaxrow, smaxcol);
+ }
+ // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
+ // on the screen. <b>refresh</b> copies a rectangle of this size beginning
+ // with top left corner pminrow,pmincol onto the screen and calls doupdate().
+
+ int noutrefresh();
+ // If a viewport is defined the pad is displayed in this window, otherwise
+ // this is a noop.
+
+ int noutrefresh(int pminrow, int pmincol,
+ int sminrow, int smincol,
+ int smaxrow, int smaxcol) {
+ return ::pnoutrefresh(w, pminrow, pmincol,
+ sminrow, smincol, smaxrow, smaxcol);
+ }
+ // Does the same as refresh() but without calling doupdate().
+
+ virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
+ // Add the window "view" as viewing window to the pad.
+
+ virtual void setSubWindow(NCursesWindow& sub);
+ // Use the subwindow "sub" of the viewport window for the actual viewing.
+ // The full viewport window is usually used to provide some decorations
+ // like frames, titles etc.
+
+ virtual void operator() (void);
+ // Perform Pad's operation
+};
+
+// A FramedPad is constructed always with a viewport window. This viewport
+// will be framed (by a box() command) and the interior of the box is the
+// viewport subwindow. On the frame we display scrollbar sliders.
+class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
+{
+protected:
+ virtual void OnOperation(int pad_req);
+
+public:
+ NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
+ int v_grid = 1, int h_grid = 1)
+ : NCursesPad(nlines, ncols) {
+ NCursesPad::setWindow(win, v_grid, h_grid);
+ NCursesPad::setSubWindow(*(new NCursesWindow(win)));
+ }
+ // Construct the FramedPad with the given Window win as viewport.
+
+ virtual ~NCursesFramedPad() {
+ delete getSubWindow();
+ }
+
+ void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
+ (void) view;
+ (void) v_grid;
+ (void) h_grid;
+ err_handler("Operation not allowed");
+ }
+ // Disable this call; the viewport is already defined
+
+ void setSubWindow(NCursesWindow& sub) {
+ (void) sub;
+ err_handler("Operation not allowed");
+ }
+ // Disable this call; the viewport subwindow is already defined
+