1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
/* window.cxx
$Id: window.cxx,v 1.7 1998/09/07 00:49:43 elf Exp $
written by Marc Singer
19 September 1996
This file is part of the project CurVeS. See the file README for
more information.
Copyright (C) 1996 Marc Singer
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
in a file called COPYING along with this program; if not, write to
the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
02139, USA.
-----------
DESCRIPTION
-----------
Implementation of window and screen classes.
*/
#include "std.h"
#include <stdarg.h>
#include "window.h"
int LScreen::_color_of (int color)
{
switch (color) {
case colorBlack:
return COLOR_BLACK;
case colorRed:
return COLOR_RED;
case colorGreen:
return COLOR_GREEN;
case colorYellow:
return COLOR_YELLOW;
case colorBlue:
return COLOR_BLUE;
case colorMagenta:
return COLOR_MAGENTA;
case colorCyan:
return COLOR_CYAN;
case colorWhite:
return COLOR_WHITE;
default:
return COLOR_BLACK;
}
}
void LScreen::init (void)
{
m_pWindowRoot = new LWindow (initscr ());
start_color ();
ESCDELAY = 50;
}
void LScreen::release_this (void)
{
if (m_pWindowRoot) {
delete m_pWindowRoot;
m_pWindowRoot = NULL;
endwin ();
}
}
LWindow* LWindow::create_child (int x, int y, int dx, int dy)
{
LWindow* pWindow;
if (m_pWindowParent)
pWindow = new LWindow (derwin (m_pWindow, dy, dx, y, x));
else
pWindow = new LWindow (newwin (dy, dx, y, x));
scrollok (pWindow->m_pWindow, true);
keypad (pWindow->m_pWindow, true);
// syncok (pWindow->m_pWindow, TRUE);
pWindow->m_pWindowParent = this;
return pWindow;
}
int LWindow::getstr (int x, int y, char* sz, int cch)
{
moveto (x, y);
return wgetnstr (m_pWindow, sz, cch);
}
void LWindow::init (WINDOW* pWindow)
{
m_pWindow = pWindow;
}
void LWindow::printfxy (int x, int y, const char* szFormat, ...)
{
va_list ap;
va_start (ap, szFormat);
moveto (x, y);
vwprintw (m_pWindow, szFormat, ap);
va_end (ap);
touch (y);
}
void LWindow::release_this (void)
{
if (m_pWindow) {
delwin (m_pWindow);
m_pWindow = NULL;
}
}
void LWindow::touch (int y)
{
if (m_pWindowParent) {
int xParent, yParent;
getparyx (m_pWindow, yParent, xParent);
m_pWindowParent->touch (y + yParent);
}
else
touchline (m_pWindow, y, 1);
}
|