question about cmov/getcpos
Tony Facca
fsfacca at AVELON.LERC.NASA.GOV
Sat Mar 3 03:14:08 AEST 1990
can someone please shed some light on the use of getcpos/cmov2i ?
I have a routine which allows the user to enter character data from a graphics
window. they type stuff from the keyboard, and it gets echoed back to the
screen. the problem occurs when a backspace is encountered in an unconstrained
window. here is a code section:
keybd_input (buff)
char *buff;
{
Screencoord xpos, ypos;
char *p, ch_temp[2];
short dev, ch;
int i=0;
devices (OFF);
qdevice (KEYBD);
cmov2i (50,50);
charstr ("enter string: ");
p = buff;
ch_temp[1] = '\0';
while ( dev = qread (&ch))
{
if (dev == KEYBD) {
if (ch == '\n' || ch == '\r') {
break;
}
if (ch == '\b') {
i--;
if (i < 0) { i = 0; break; }
ch_temp[0] = *--p;
getcpos (&xpos, &ypos);
xpos = xpos - strwidth(ch_temp);
cmov2i (xpos, ypos);
color (BLACK);
charstr (ch_temp);
color (WHITE);
cmov2i (xpos, ypos);
}
else {
*p++ = ch;
ch_temp[0] = ch;
charstr ( &buff[i++] );
}
}
}
*p = '\0';
devices (ON);
}
if i precede the winopen() call (not part of this routine) with one to
prefposition(0,XMAXSCREEN,0,YMAXSCREEN)
then all is well, getcpos returns nice values and everyone is happy. if I let
the user open an unconstrained window, the call to cmov2i(50,50) appears
relative to the lower left corner of the user-defined window. however, the
getcpos call returns something other than relative values and things get ugly.
is this indeed the case, that cmov is relative and getcpos is not? is there a
way to tell getcpos() to use relative coordinates? is there an altogether
better way to accomplish this?
--
-----------------------------------------------------------------------------
Tony Facca | phone: 216-433-8318
NASA Lewis Research Center |
Cleveland, Ohio 44135 | email: fsfacca at lerc08.lerc.nasa.gov
-----------------------------------------------------------------------------
More information about the Comp.sys.sgi
mailing list