home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Kyūkyoku!! X68000 Emulator
/
X68000Book.dat
/
mac
/
OLS
/
X68000
/
Ko-Window
/
kow142s.lzh
/
wsrv
/
stack.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-11-25
|
4KB
|
184 lines
#include <stdio.h>
#include <iocslib.h>
#include <microstr.h>
#include "clip.h"
#include "slider.h"
#include "window.h"
#include "simple.h"
#include "title.h"
#include "manager.h"
#include "stack.h"
#include "wopen.h"
#define MAX_EVENT_STACK 100
#define STACK_FONT 12
struct {
EventType type;
int id;
char *name; /* 1992 10/6 COR.*/
void *buf;
} EventStack[MAX_EVENT_STACK];
int EventSP;
int OpenFlag;
TitleClass StackWP;
static char *Format[] = {
"Request : ",
"Event : ",
"Signal : ",
"Exec : ",
} ;
/*
proto -s stack.c > temp
*/
static void TraceWait( void );
static int EventStackEvent( WindowClass*, EventInfo* );
/* 1991 COR. */
static void
typeset( type, str, id, name, buf )
EventType type;
int id,
buf;
char *str,
*name;
{
s_strcpy( str, Format[type] );
itoa2( id, str+10 );
s_strcat( str, type == TypeRequest ? " Window" : " " );
s_strcat( str, name );
if( type == TypeSignal ){
char obuf[80];
htoa2( buf, obuf+1 );
*obuf= ' ';
s_strcat( str, obuf );
}
}
void
_EventStackPush( type, id, name, buf )
EventType type ;
int id ;
char *name ;
void *buf ;
{
EventStack[EventSP].type= type;
EventStack[EventSP].id= id;
EventStack[EventSP].name= name;
EventStack[EventSP].buf= buf;
if( OpenFlag ){
DrawBuf dbuf[1];
char str[100];
typeset( type, str, id, name, buf ); /* 1991 COR. */
DrawSetSymbol( dbuf, 8, EventSP*STACK_FONT, str, AttrDefault,
STACK_FONT );
WindowDraw( (WindowClass*)&StackWP, dbuf, 1 );
}
EventSP++;
if( DebugMode & DebugTraceOn )
TraceWait();
}
void
_EventStackPop()
{
EventSP--;
if( OpenFlag ){
DrawBuf buf[1];
DrawSetLine( buf, 0, EventSP*STACK_FONT, 300,
EventSP*STACK_FONT+STACK_FONT-1, 1, OptionFill );
WindowDraw( (WindowClass*)&StackWP, buf, 1 );
}
if( DebugMode & DebugTraceOn )
TraceWait();
}
static void
TraceWait()
{
if( B_SFTSNS() & 0x80 ) /* CAPS */
return;
while( ( B_SFTSNS() & 0x81 ) == 0 ); /* CAPS or SHIFT */
while( B_SFTSNS() & 1 ); /* SHIFT */
}
void
EventStackOpen( x, y, h, v )
int x, y, h, v;
{
if( OpenFlag == 0 ){
(*systemfunc[TitleType].setfunc)(
&StackWP, x, y, h, v, &RootWindow, "Event Stack",
Close|Push|Resize, -1, EventStackEvent );
WindowSetEventAttr( (WindowClass*)&StackWP,
EventRedrawON|
EventCloseON|
EventMouseSwitchON
);
WindowRedraw( (WindowClass*)&StackWP );
}else{
WindowMove( (WindowClass*)&StackWP, x, y );
}
OpenFlag++;
}
void
EventStackClose()
{
OpenFlag--;
if( OpenFlag == 0 ){
OpenFlag= FALSE;
WindowClose( (WindowClass*)&StackWP );
}else if( OpenFlag < 0 )
OpenFlag= 0;
}
void
EventStackClear()
{
DrawBuf buf[1];
EventSP= 0;
if( OpenFlag ){
DrawSetClear( buf, 1 );
WindowDraw( (WindowClass*)&StackWP, buf, 1 );
}
}
static int
EventStackEvent( wp, info )
WindowClass *wp;
EventInfo *info;
{
int i;
DrawBuf buf[1];
char str[100];
switch( info->option ){
case EventRedraw:
DrawSetClear( buf, 1 );
WindowDraw( (WindowClass*)&StackWP, buf, 1 );
for( i = 0 ; i < EventSP ; ++i ){
typeset( EventStack[i].type, str,
EventStack[i].id, EventStack[i].name,
EventStack[i].buf );
DrawSetSymbol( buf, 8, i*STACK_FONT, str, AttrDefault,
STACK_FONT );
WindowDraw( (WindowClass*)&StackWP, buf, 1 );
}
return TRUE;
case EventClose:
EventStackClose();
return TRUE;
default:
break;
}
return FALSE;
}
/* :vi:se ts=4 sw=4: */