]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - c++/cursesw.h
ncurses 5.5
[ncurses.git] / c++ / cursesw.h
index 8e86ff99f02fbbd9b5c061a22675e8c6314b0fec..13f87a6800d455791764fbcea0ea5d76357ca176 100644 (file)
@@ -1,6 +1,6 @@
 // * This makes emacs happy -*-Mode: C++;-*-
 /****************************************************************************
- * Copyright (c) 1998-2001,2004 Free Software Foundation, Inc.              *
+ * Copyright (c) 1998-2004,2005 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.38 2005/07/23 20:51:39 tom Exp $
 
-#include <etip.h>
 #include <stdarg.h>
 #include <stdio.h>
 
+#include <etip.h>
+
 #if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST)
 #include <strstream.h>
 #endif
@@ -307,7 +308,7 @@ inline chtype UNDEF(inch)()  { return inch(); }
 #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
@@ -567,7 +568,7 @@ inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
 #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)
@@ -626,7 +627,7 @@ inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
 #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)
@@ -690,9 +691,12 @@ inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
  *
  * 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;
@@ -701,7 +705,7 @@ class NCURSES_IMPEXP NCursesWindow
 private:
   static bool    b_initialized;
   static void    initialize();
-  static int     ripoff_init(WINDOW *, int);
+  friend int     _nc_xx_ripoff_init(WINDOW *, int);
 
   void           init();
 
@@ -712,10 +716,10 @@ private:
 
   // 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:
@@ -741,14 +745,14 @@ protected:
 public:
   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
@@ -760,6 +764,18 @@ public:
   // 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();
@@ -979,10 +995,10 @@ public:
   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) {
@@ -1112,7 +1128,7 @@ public:
   // 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.
 
@@ -1196,9 +1212,9 @@ public:
   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.
@@ -1228,26 +1244,28 @@ public:
 // -------------------------------------------------------------------------
 // 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(); }
@@ -1272,7 +1290,8 @@ public:
 // 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
@@ -1314,9 +1333,29 @@ protected:
   // 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); }
@@ -1364,14 +1403,15 @@ public:
 // 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)));
   }
@@ -1393,4 +1433,4 @@ public:
 
 };
 
-#endif // NCURSES_CURSESW_H_incl
+#endif /* NCURSES_CURSESW_H_incl */