X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=c%2B%2B%2Fcursesw.h;h=7e24c835f0929035ef6d0aff76a285dfa1813f75;hp=8e86ff99f02fbbd9b5c061a22675e8c6314b0fec;hb=7b2974498fac39a3ffde257c92f572234d529239;hpb=a8987e73ec254703634802b4f7ee30d3a485524d diff --git a/c++/cursesw.h b/c++/cursesw.h index 8e86ff99..7e24c835 100644 --- a/c++/cursesw.h +++ b/c++/cursesw.h @@ -1,6 +1,6 @@ // * 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 * @@ -30,15 +30,9 @@ #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 -#include -#include - -#if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST) -#include -#endif extern "C" { # include @@ -307,7 +301,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 +561,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 +620,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 +684,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,21 +698,23 @@ class NCURSES_IMPEXP NCursesWindow 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: @@ -739,16 +738,16 @@ protected: 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 @@ -760,6 +759,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(); @@ -807,16 +818,16 @@ public: 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; @@ -979,10 +990,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(at)); } // Switch off the window attributes; - int attrset(chtype at) { return ::wattrset(w, (int) at); } + int attrset(chtype at) { return ::wattrset(w, static_cast(at)); } // Set the window attributes; int color_set(short color_pair_number, void* opts=NULL) { @@ -1112,7 +1123,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(changed ? 1 : 0)); } // Mark cnt lines beginning from line s as changed or unchanged, depending // on the value of the changed flag. @@ -1196,9 +1207,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(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 +1239,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 +1285,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 +1328,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 +1398,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 +1428,4 @@ public: }; -#endif // NCURSES_CURSESW_H_incl +#endif /* NCURSES_CURSESW_H_incl */