home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Virtual Reality Zone
/
VRZONE.ISO
/
mac
/
PC
/
PCGLOVE
/
GLOVE
/
OBJGLV.ZIP
/
SRC
/
WINGEST.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-11
|
3KB
|
130 lines
//
// WinGest.cpp:
// Implementation of classes TGestureDialog and winGestureActor.
// Example use of Object Glove and Court Jesture.
//
// Purpose:
// Outputs the names of Gestures into a Windows window (actually
// a dialog box).
//
// Compatibility:
// Windows only!
//
// Copyright 1993 Mark Thomas Pflaging
//
// Date: 3/22/93 (Release 3.0)
//
#include "wingest.hpp"
#include "winglove.hpp"
#include <mmsystem.h>
#include <strng.h>
#include <assoc.h>
size_t InstanceCounter<NamedGestSet>::total = 0;
HashTable * winNameGest::table;
TGestureDialog::TGestureDialog(PTWindowsObject AParent, int ResourceID, PTModule AModule, winGestureActor * where_arg) :
where(where_arg), TDialog(AParent, ID_GLOVE_GEST_1 + ResourceID * 100, AModule)
{
for (int i = 0; i < NUM_GEST_SPOTS; i ++) {
Spots[i] = new TStatic(this, ID_GS_1 + (ResourceID * 100) + i, 25);
}
}
TGestureDialog::~TGestureDialog()
{
for (int i = 0; i < NUM_GEST_SPOTS; i ++) delete Spots[i];
}
void TGestureDialog::draw(char ** strings)
{
for (int i = 0; i < NUM_GEST_SPOTS; i ++) {
(Spots[i])->SetText(strings[i]);
}
}
void TGestureDialog::infoDisplay(char * name, Boolean onOrOff)
{
char **strings = where->infoDisplay(name, onOrOff);
draw(strings);
}
char ** winGestureActor::infoDisplay(char * name, Boolean onOrOff)
{
// Make a kind of scrolling display
char * temp = new char[80], * temp2;
strcpy(temp, name);
strcat(temp, (onOrOff ? " On" : " Off"));
temp2 = strings[0];
for (int i = 1; (i < NUM_GEST_SPOTS); i ++) {
if (i != 0) strings[i-1] = strings[i];
}
if (strlen(temp2)) {
delete temp2;
}
strings[NUM_GEST_SPOTS - 1] = temp;
return strings;
}
void winNameGest::Register(Boolean onOrOff)
{
if (onOrOff) {
Association key(
*(new String(getName())),
*(new String(getName()))
);
Association & found = (Association &)(table->findMember(key));
if (found != NOOBJECT) {
sndPlaySound((const char *)((String &)(found.value())), SND_ASYNC);
}
}
}
Boolean winGestureActor::addSound(Key & which, void * gset)
{
winGestureActor & set = *((winGestureActor *)gset);
set.HashTable::add(*(new Association(
*(new String(which.getName())),
*(new String(which.valueOf()))
)));
return True;
}
void winGestureActor::InitTable(InitFile & ini, char * gest_section, char * sound_section)
{
Section * sndlist = ini.find(sound_section);
if (sndlist) {
sndlist->doAll(addSound, this);
}
CntNamedGestAct::Init(ini, gest_section);
}
void winGestureActor::displayDataBox()
{
if (DataPlace1) return;
DataPlace1 = new TGestureDialog(where, getInstance(), where->GetModule(), this);
(where->GetModule())->MakeWindow(DataPlace1);
DataPlace1->draw(strings);
}
void winGestureActor::closeDataBox()
{
DataPlace1->CloseWindow();
DataPlace1 = NULL;
}
winGestureActor::winGestureActor(InitFile & ini, char * gest_section, char * sound_section, TDemoWindow & arg) :
HashTable(MAX_NUM_SOUNDS), where(&arg), DataPlace1(NULL)
{
InitTable(ini, gest_section, sound_section);
for (int i = 0; i < NUM_GEST_SPOTS; i ++) strings[i] = "";
}
winGestureActor::winGestureActor(InitFile & ini, char * gest_section, char * sound_section) :
HashTable(MAX_NUM_SOUNDS), DataPlace1(NULL)
{
InitTable(ini, gest_section, sound_section);
for (int i = 0; i < NUM_GEST_SPOTS; i ++) strings[i] = "";
}