// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
- * Copyright (c) 1998-2001,2004 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
#ifndef NCURSES_CURSESW_H_incl
#define NCURSES_CURSESW_H_incl 1
-// $Id: cursesw.h,v 1.30 2004/02/08 00:11:54 tom Exp $
+// $Id: cursesw.h,v 1.44 2007/04/07 18:42:04 tom Exp $
#include <etip.h>
-#include <stdarg.h>
-#include <stdio.h>
-
-#if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST)
-#include <strstream.h>
-#endif
extern "C" {
# include <curses.h>
#endif
#ifdef insch
-inline int UNDEF(insch)(char c) { return insch(c); }
+inline int UNDEF(insch)(chtype c) { return insch(c); }
#undef insch
#define insch UNDEF(insch)
#endif
#endif
#ifdef mvwinsch
-inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, char c)
+inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
{ return mvwinsch(win, y, x, c); }
#undef mvwinsch
#define mvwinsch UNDEF(mvwinsch)
#endif
#ifdef mvinsch
-inline int UNDEF(mvinsch)(int y, int x, char c)
+inline int UNDEF(mvinsch)(int y, int x, chtype c)
{ return mvinsch(y, x, c); }
#undef mvinsch
#define mvinsch UNDEF(mvinsch)
*
* C++ class for windows.
*
- *
*/
+extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));
+extern "C" int _nc_xx_ripoff_init(WINDOW *, int);
+extern "C" int _nc_has_mouse(void);
+
class NCURSES_IMPEXP NCursesWindow
{
friend class NCursesMenu;
private:
static bool b_initialized;
static void initialize();
- static int ripoff_init(WINDOW *, int);
+ void constructing();
+ friend int _nc_xx_ripoff_init(WINDOW *, int);
- void init();
+ void set_keyboard();
short getcolor(int getback) const;
+ short getPair() const;
static int setpalette(short fore, short back, short pair);
static int colorInitialized;
// This private constructor is only used during the initialization
// of windows generated by ripoffline() calls.
- NCursesWindow(WINDOW* win, int cols);
+ NCursesWindow(WINDOW* win, int ncols);
protected:
- void err_handler(const char *) const THROWS(NCursesException);
+ virtual void err_handler(const char *) const THROWS(NCursesException);
// Signal an error with the given message text.
static long count; // count of all active windows:
NCursesWindow();
public:
- NCursesWindow(WINDOW* &window); // useful only for stdscr
+ NCursesWindow(WINDOW* window); // useful only for stdscr
- NCursesWindow(int lines, // number of lines
- int cols, // number of columns
+ NCursesWindow(int nlines, // number of lines
+ int ncols, // number of columns
int begin_y, // line origin
int begin_x); // col origin
NCursesWindow(NCursesWindow& par,// parent window
- int lines, // number of lines
- int cols, // number of columns
+ int nlines, // number of lines
+ int ncols, // number of columns
int begin_y, // absolute or relative
int begin_x, // origins:
char absrel = 'a');// if `a', begin_y & begin_x are
// is two lines and two columns smaller and begins at (1,1).
// We may automatically request the box around it.
+ NCursesWindow& operator=(const NCursesWindow& rhs)
+ {
+ if (this != &rhs)
+ *this = rhs;
+ return *this;
+ }
+
+ NCursesWindow(const NCursesWindow& rhs)
+ : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
+ {
+ }
+
virtual ~NCursesWindow();
NCursesWindow Clone();
int width() const { return maxx() + 1; }
// Number of columns in this window
- int begx() const { return w->_begx; }
+ int begx() const { return getbegx(w); }
// Column of top left corner relative to stdscr
- int begy() const { return w->_begy; }
+ int begy() const { return getbegy(w); }
// Line of top left corner relative to stdscr
- int maxx() const { return w->_maxx; }
+ int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
// Largest x coord in window
- int maxy() const { return w->_maxy; }
+ int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
// Largest y coord in window
short getcolor() const;
int attron (chtype at) { return ::wattron (w, at); }
// Switch on the window attributes;
- int attroff(chtype at) { return ::wattroff(w, (int) at); }
+ int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
// Switch off the window attributes;
- int attrset(chtype at) { return ::wattrset(w, (int) at); }
+ int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
// Set the window attributes;
int color_set(short color_pair_number, void* opts=NULL) {
// Mark the whole window as unmodified.
int touchln(int s, int cnt, bool changed=TRUE) {
- return ::wtouchln(w, s, cnt, (int)(changed?1:0)); }
+ return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
// Mark cnt lines beginning from line s as changed or unchanged, depending
// on the value of the changed flag.
int copywin(NCursesWindow& win,
int sminrow, int smincol,
int dminrow, int dmincol,
- int dmaxrow, int dmaxcol, bool overlay=TRUE) {
+ int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
- dmaxrow, dmaxcol, (int)(overlay?1:0)); }
+ dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
// Overlay or overwrite the rectangle in win given by dminrow,dmincol,
// dmaxrow,dmaxcol with the rectangle in this window beginning at
// sminrow,smincol.
// -------------------------------------------------------------------------
// We leave this here for compatibility reasons.
// -------------------------------------------------------------------------
-class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow {
+class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
+{
public:
NCursesColorWindow(WINDOW* &window) // useful only for stdscr
: NCursesWindow(window) {
useColors(); }
- NCursesColorWindow(int lines, // number of lines
- int cols, // number of columns
+ NCursesColorWindow(int nlines, // number of lines
+ int ncols, // number of columns
int begin_y, // line origin
int begin_x) // col origin
- : NCursesWindow(lines, cols, begin_y, begin_x) {
+ : NCursesWindow(nlines, ncols, begin_y, begin_x) {
useColors(); }
- NCursesColorWindow(NCursesWindow& par,// parent window
- int lines, // number of lines
- int cols, // number of columns
+ NCursesColorWindow(NCursesWindow& parentWin,// parent window
+ int nlines, // number of lines
+ int ncols, // number of columns
int begin_y, // absolute or relative
int begin_x, // origins:
char absrel = 'a') // if `a', by & bx are
- : NCursesWindow(par, lines, cols, // absolute screen pos,
+ : NCursesWindow(parentWin,
+ nlines, ncols, // absolute screen pos,
begin_y, begin_x, // else if `r', they are
absrel ) { // relative to par origin
useColors(); }
// 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 {
+class NCURSES_IMPEXP NCursesPad : public NCursesWindow
+{
private:
NCursesWindow* viewWin; // the "viewport" window
NCursesWindow* viewSub; // the "viewport" subwindow
// the refresh() operation is done.
public:
- NCursesPad(int lines, int cols);
+ 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); }
// 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 {
+class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
+{
protected:
virtual void OnOperation(int pad_req);
public:
- NCursesFramedPad(NCursesWindow& win, int lines, int cols,
+ NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
int v_grid = 1, int h_grid = 1)
- : NCursesPad(lines, cols) {
+ : NCursesPad(nlines, ncols) {
NCursesPad::setWindow(win, v_grid, h_grid);
NCursesPad::setSubWindow(*(new NCursesWindow(win)));
}
};
-#endif // NCURSES_CURSESW_H_incl
+#endif /* NCURSES_CURSESW_H_incl */