home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MODEL
/
INPUTWIN.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-05
|
4KB
|
187 lines
#include <owl\owlpch.h>
#include <owl\applicat.h>
#include <owl\framewin.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
extern "C" {
#include "input.h"
#include "graph.h"
#include "view.h"
};
#define TRUE 1
#define FALSE 0
int MouseX = 0, MouseY = 0 ;
int MouseLeft = 0, MouseRight = 0 ;
int MouseMove = FALSE ;
int KeyCode = 0 ;
int ShiftStat = 0 ;
static int Cx, Cy ;
static int Cursor ;
//
// 外部参照
//
extern TFrameWindow *MainWindow ;
extern TApplication *Application ;
extern TDC *ModelDC ;
extern int QuitFlag ;
extern int GetKey();
extern int PeekKey();
extern int GetShift();
extern void GetMouseStat( int &, int & );
extern void GetMousePos( int &, int & );
extern "C" unsigned long WinGetTimer(void);
#define BLINKS 128
static int blink[BLINKS];
void InitInput()
{
int i;
double t;
for (i = 0; i < BLINKS; i++) {
t = (double)i / (double)BLINKS* 3.14159265358979 * 2.0;
blink[i] = (int)((127.0 - cos(t) * 127.0)/6.0 + 255.0*5.0/6.0);
}
}
void ExitInput()
{
}
void WaitInput()
{
unsigned long t, t2;
int x, y ;
int left, right ;
int col;
static int selectcol;
t = WinGetTimer();
do
{
Application->PumpWaitingMessages();
if ( QuitFlag )
return ;
KeyCode = GetKey();
GetMouseStat( left, right );
GetMousePos( x, y );
/* select color */
#if 0
selectcol = ( selectcol + 1 ) & 0xFFFF ;
col = ( selectcol >> 5 ) & 511 ;
if ( col >= 256 )
col = 511 - col ;
/* graph_palet( SELECT_COLOR, 255, 255-col, col );*/
graph_palet( SELECT_COLOR, col, 0, col );
#else
if (t + 5 < (t2 = WinGetTimer())) {
selectcol = (selectcol + (t2-t)/5) % BLINKS;
t = t2;
col = blink[selectcol];
/* graph_palet( SELECT_COLOR, 255, 0, col );*/
/* graph_palet( SELECT_COLOR, col, 0, col );*/
/*1 graph_palet( SELECT_COLOR, col, 0, 255); */
/*2 graph_palet( SELECT_COLOR, (128+col/2), 128, (128+col/2));*/
/*3 graph_palet( SELECT_COLOR, col, 255-col, 255);*/
/* graph_palet( SELECT_COLOR, 255, 255-col, 255);*/
/* graph_palet( SELECT_COLOR, col, 0, col);*/
/* graph_palet( SELECT_COLOR, 191, 255, 0);*/
graph_palet( SELECT_COLOR, col, 0, col);
}
#endif
}
while ( left == MouseLeft && right == MouseRight && KeyCode == 0
&& ( (!left && !right) || (x == MouseX && y == MouseY)));
#if 0
while ( (!left || MouseLeft) && (!right || MouseRight) && KeyCode == 0
&& ( (!left && !right) || (x == MouseX && y == MouseY)));
while ( left == MouseLeft && right == MouseRight && KeyCode == 0
&& ( (!left && !right) || (x == MouseX && y == MouseY)));
while( !left && !right && !MouseLeft && !MouseRight &&
x == MouseX && y == MouseY && KeyCode == 0 );
#endif
MouseMove = ( x != MouseX ) || ( y != MouseY );
MouseX = x ;
MouseY = y ;
MouseLeft = left ;
MouseRight = right ;
ShiftStat = GetShift();
}
void PeekInput( void )
{
int x, y ;
int left, right ;
int k;
Application->PumpWaitingMessages();
GetMouseStat( left, right );
GetMousePos( x, y );
MouseX = x ;
MouseY = y ;
MouseLeft = left ;
MouseRight = right ;
ShiftStat = GetShift();
k = PeekKey();
if (k) {
KeyCode = k;
}
}
void FlushKey()
{
}
void Locate( int x, int y )
{
Cx = x ;
Cy = y ;
if ( Cursor )
{
}
}
void CursorON()
{
Cursor = TRUE ;
Locate( Cx, Cy );
}
void CursorOFF()
{
Cursor = FALSE ;
}
void Bell()
{
MessageBeep(-1);
}
void GetCursorPosition( int *xp, int *yp )
{
*xp = Cx ;
*yp = Cy ;
}
extern "C" void GetDCParameter(char *dc);
void GetDCParameter(char *dc)
{
sprintf(dc, "--inline=%lu,%d,%d -c%dx%d", (unsigned long) ModelDC,
WinPers.x + FRAME_WIDTH, WinPers.y + FRAME_WIDTH,
WinPers.h - FRAME_WIDTH*2, WinPers.v - FRAME_WIDTH*2);
}