home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Zone
/
VRZONE.ISO
/
mac
/
PC
/
PCGLOVE
/
GLOVE
/
OBJGLV.ZIP
/
SRC
/
BGIGEST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-12
|
2KB
|
86 lines
//
// BGIGest.cpp:
// Implementation of class BGIGestureActor.
// Example use of Object Glove and Court Jesture.
//
// Purpose:
// Outputs the names of Gestures onto a BGI window.
//
// Compatibility:
// DOS only!
//
// Copyright 1993 Mark Thomas Pflaging
//
// Date: 3/22/93 (Release 3.0)
//
#include "bgigest.hpp"
#include <graphics.h>
size_t InstanceCounter<NamedGestSet>::total = 0;
BGIGestureActor::BGIGestureActor(InitFile & ini, char * section)
{
Init(ini, section);
drawn = False;
for (int i = 0; i < NUM_STRINGS; i ++) strings[i] = "";
}
void BGIGestureActor::Register(Gesture & found, Boolean onOrOff)
{
char * temp = new char[80], * temp2;
char * name = ((NamedGesture &)found).getName();
strcpy(temp, name);
strcat(temp, (onOrOff ? " On" : " Off"));
temp2 = strings[0];
for (int i = 1; (i < NUM_STRINGS); i ++) {
if (i != 0) strings[i-1] = strings[i];
}
if (strlen(temp2)) {
delete temp2;
}
strings[NUM_STRINGS - 1] = temp;
drawn = False;
NamedGestSet::Register(found, onOrOff);
}
#define XOFF 20
#define YOFF 55
#define NUMSTART 1
int BGIGestureActor::set_view()
{
int unit_wid = textwidth("W");
static char hightxt[] = "Tq";
int height = textheight(hightxt), start = NUMSTART;
int yoff = YOFF + (getInstance() * height * (NUM_STRINGS + 2));
int x = XOFF + unit_wid * start, y = yoff + (height * NUM_STRINGS + 1);
int width = unit_wid * (25 - start);
setviewport(x, y, width + x, height * NUM_STRINGS + y, 1);
return height;
}
void BGIGestureActor::draw()
{
if (drawn) return; // Prevent unnecessary redraws.
int height = set_view();
clearviewport();
setcolor(EGA_LIGHTGRAY);
int y = 0;
for (int i = 0; i < NUM_STRINGS; i ++) {
moveto(0,y);
y+=height;
outtext(strings[i]);
}
drawn = True;
setviewport(0, 0, getmaxx(), getmaxy(), 0);
}
void BGIGestureActor::clear()
{
set_view();
clearviewport();
setviewport(0, 0, getmaxx(), getmaxy(), 0);
drawn = False;
}