home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MODEL
/
CTRL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-03-28
|
10KB
|
419 lines
/*
* コントロールパネル制御
*
* 1994.8.13
*/
#include <stdio.h>
#include <string.h>
#include "poly.h"
#include "view.h"
#include "menu.h"
#include "event.h"
#include "ml.h"
#include "graph.h"
#include "input.h"
#include "model.h"
#ifndef WINDOWS
#define ATTR_START 3
#else
#define ATTR_START 2
#endif
#define ATTR_LINES (DISPLAY_Y/FontV-(OBJ_LINES+CURSOR_LINES+ATTR_START+4))
#define OBJ_START (ATTR_START+ATTR_LINES+2+1)
#define OBJ_LINES 6
#define CURSOR_START (OBJ_START+OBJ_LINES+1)
#define CURSOR_LINES 5
#define SEL_START (DISPLAY_X - CTRL_WIDTH + FontH) /* 選択ウインドウの開始位置 */
#define SEL_WIDTH 8 /* 選択ウインドウの幅 */
static int AttrScroll = 0 ;
static int ObjScroll = 0 ;
static short UpArrow[] = {
0xCC00, 0xCC00, 0x8400, 0x8400, 0x0000, 0x0000,
};
static short DownArrow[] = {
0x0000, 0x0000, 0x8400, 0x8400, 0xCC00, 0xCC00,
};
static void AttrSelect( int );
static void ObjSelect( int );
static void DrawFrame( int, int, int, int );
static void DrawItem( int, char*, int );
static void CallAttrSelect(int n);
static void CallObjSelect(int n);
int IdentControl;
int IdentAttrSelect;
int IdentObjSelect;
char StatusText[MAXSTATUS][STATUSTEXTLENGTH+1];
int StatusWidth[MAXSTATUS];
/* コントロールパネルの表示 */
void DrawControlPanel()
{
int x1, y1, x2, y2 ;
x1 = DISPLAY_X - CTRL_WIDTH ;
y1 = MENU_WIDTH ;
x2 = DISPLAY_X - 1 ;
y2 = DISPLAY_Y - STATUS_WIDTH - 1 ;
/* graph_line( x1, y1, x2, y1, 7 );
graph_fill( x1, y1, x1+1, y2, 7 );*/
graph_fill( x1+1, y1+1, x2-1, y2-1, FRAME_COLOR );
graph_box(x1, y1, x2, y2, TRUE);
DrawAttrSelect();
DrawObjSelect();
DrawCursorPos();
DrawStatusBar(-1);
}
/* コントロールパネルのマウス制御 */
void ControlSelect( x, y )
int x, y ;
{
int yo;
yo = y;
y /= FontV ;
if ( y >= CURSOR_START ) {
WaitMouseOff();
if ( IdentControl >= 0 )
{
DataStruct *top = StackTop();
StackPushInt( y - CURSOR_START );
CallFunction( IdentControl, 1, top+1 );
StackRelease( top );
}
} else if ( y >= OBJ_START-1 )
ObjSelect( y );
else if ( y >= ATTR_START-1 )
AttrSelect( y );
else
WaitMouseOff();
}
/* アトリビュート選択ウインドウの表示 */
void DrawAttrSelect()
{
int i, n ;
if (AttrCurrent < AttrScroll) {
AttrScroll = AttrCurrent;
} else if (AttrCurrent >= AttrScroll + ATTR_LINES) {
AttrScroll = AttrCurrent - ATTR_LINES + 1;
}
DrawFrame( ATTR_START, ATTR_LINES, AttrScroll>0, AttrLast >= AttrScroll+ATTR_LINES-1 );
graph_puts( "アトリビュート", SEL_START, (ATTR_START-1) * FontV - 12, FRAME_COLOR << 4);
for( i = 0 ; i < ATTR_LINES ; i++ )
{
n = i + AttrScroll ;
if ( n <= AttrLast && AttrData[n].flag )
DrawItem( ATTR_START+i, AttrData[n].name, ( n == AttrCurrent ) );
else
DrawItem( ATTR_START+i, "", FALSE );
}
}
/* オブジェクト選択ウインドウの表示 */
void DrawObjSelect()
{
int i, n ;
char objname[OBJ_NAME_LEN+2] ;
if (ObjCurrent < ObjScroll) {
ObjScroll = ObjCurrent;
} else if (ObjCurrent >= ObjScroll + OBJ_LINES) {
ObjScroll = ObjCurrent - OBJ_LINES + 1;
}
DrawFrame( OBJ_START, OBJ_LINES, ObjScroll>0, ObjLast >= ObjScroll+OBJ_LINES-1 );
graph_puts( "オブジェクト", SEL_START, (OBJ_START-1) * FontV - 12, FRAME_COLOR << 4);
for( i = 0 ; i < OBJ_LINES ; i++ )
{
n = i + ObjScroll ;
if ( n <= ObjLast && ObjData[n].flag )
{
strcpy( objname+1, ObjData[n].name );
objname[0] = ObjData[n].edit ? '*' : ' ' ;
}
else
strcpy( objname, "" );
DrawItem( OBJ_START+i, objname, ( n == ObjCurrent ) );
}
}
static void CallAttrSelect(int n)
{
if (IdentAttrSelect >= 0) {
DataStruct *top ;
top = StackTop();
StackPushInt( n );
CallFunction( IdentAttrSelect, 1, top+1 );
StackRelease( top );
} else if (n >= 0) {
AttrCurrent = n;
}
}
static void AttrSelect( y )
int y ;
{
int n ;
n = y - ATTR_START ;
if ( 0 <= n && n < ATTR_LINES) {
WaitMouseOff();
if (n+AttrScroll <= AttrLast ) {
CallAttrSelect(AttrScroll + n);
} else {
CallAttrSelect(-1);
}
} else if ( n < 0 && AttrScroll > 0 ) {
#ifdef WINDOWS
extern unsigned long WinGetTimer(void);
unsigned long lasttime = WinGetTimer();
do {
AttrScroll -- ;
if (AttrCurrent >= AttrScroll + ATTR_LINES) {
CallAttrSelect(AttrScroll + ATTR_LINES - 1);
}
DrawAttrSelect();
do {
PeekInput();
} while (lasttime + 200 > WinGetTimer()
&& !QuitFlag && (MouseRight || MouseLeft));
} while (AttrScroll > 0
&& ! QuitFlag && (MouseLeft || MouseRight));
WaitMouseOff();
#else
WaitMouseOff();
AttrScroll -- ;
if (AttrCurrent >= AttrScroll + ATTR_LINES) {
CallAttrSelect(AttrScroll + ATTR_LINES - 1);
}
#endif
} else if ( n >= ATTR_LINES && AttrScroll + ATTR_LINES <= AttrLast+1 ) {
#ifdef WINDOWS
extern unsigned long WinGetTimer(void);
unsigned long lasttime = WinGetTimer();
do {
AttrScroll ++ ;
if (AttrCurrent < AttrScroll) {
CallAttrSelect(AttrScroll);
}
DrawAttrSelect();
do {
PeekInput();
} while (lasttime + 200 > WinGetTimer()
&& !QuitFlag && (MouseRight || MouseLeft));
} while (AttrScroll + ATTR_LINES <= AttrLast+1
&& ! QuitFlag && (MouseLeft || MouseRight));
WaitMouseOff();
#else
WaitMouseOff();
AttrScroll ++ ;
if (AttrCurrent < AttrScroll) {
CallAttrSelect(AttrScroll);
}
#endif
} else {
WaitMouseOff();
}
DrawAttrSelect();
}
static void CallObjSelect(int n)
{
if (IdentObjSelect >= 0) {
DataStruct *top ;
top = StackTop();
StackPushInt( n );
CallFunction( IdentObjSelect, 1, top+1 );
StackRelease( top );
} else if (n >= 0) {
ObjCurrent = n;
}
}
static void ObjSelect( y )
int y ;
{
int n ;
n = y - OBJ_START ;
if ( 0 <= n && n < OBJ_LINES) {
WaitMouseOff();
if (n+ObjScroll <= ObjLast ) {
CallObjSelect(ObjScroll + n) ;
} else {
CallObjSelect(-1);
}
} else if ( n < 0 && ObjScroll > 0 ) {
#ifdef WINDOWS
extern unsigned long WinGetTimer(void);
unsigned long lasttime = WinGetTimer();
do {
ObjScroll -- ;
if (ObjCurrent >= ObjScroll + OBJ_LINES) {
CallObjSelect(ObjScroll + OBJ_LINES - 1);
}
DrawObjSelect();
do {
PeekInput();
} while (lasttime + 200 > WinGetTimer()
&& !QuitFlag && (MouseRight || MouseLeft));
} while (ObjScroll > 0
&& ! QuitFlag && (MouseLeft || MouseRight));
WaitMouseOff();
#else
WaitMouseOff();
ObjScroll -- ;
if (ObjCurrent >= ObjScroll + OBJ_LINES) {
CallObjSelect(ObjScroll + OBJ_LINES - 1);
}
#endif
} else if ( n >= OBJ_LINES && ObjScroll + OBJ_LINES <= ObjLast+1 ) {
#ifdef WINDOWS
extern unsigned long WinGetTimer(void);
unsigned long lasttime = WinGetTimer();
do {
ObjScroll ++ ;
if (ObjCurrent < ObjScroll) {
CallObjSelect(ObjScroll);
}
DrawObjSelect();
do {
PeekInput();
} while (lasttime + 200 > WinGetTimer()
&& !QuitFlag && (MouseRight || MouseLeft));
} while (ObjScroll + OBJ_LINES <= ObjLast+1
&& ! QuitFlag && (MouseLeft || MouseRight));
WaitMouseOff();
#else
WaitMouseOff();
ObjScroll ++ ;
if (ObjCurrent < ObjScroll) {
CallObjSelect(ObjScroll);
}
#endif
} else {
WaitMouseOff();
}
DrawObjSelect();
}
static void DrawFrame( start, lines, upflag, downflag )
int start, lines, upflag, downflag ;
{
int x1, y1, x2, y2 ;
x1 = SEL_START - 2 ;
y1 = start * FontV - 1 ;
x2 = SEL_START + SEL_WIDTH * FontH ;
y2 = ( start + lines ) * FontV ;
graph_box( x1, y1, x2, y2, FALSE );
x1 = ( x1 + x2 - FontH ) / 2 ;
if (upflag) {
graph_pattern( x1, y1 - 9, FRAME_COLOR, UpArrow, 6, 6 );
} else {
graph_fill( x1, y1-9, x1+5, y1-4, FRAME_COLOR );
}
if (downflag) {
graph_pattern( x1, y2 + 3, FRAME_COLOR, DownArrow, 6, 6 );
} else {
graph_fill( x1, y2+3, x1+5, y2+8, FRAME_COLOR );
}
}
static void DrawItem( y, str, flag )
int y ;
char *str ;
int flag ;
{
int code ;
char buf[256] ;
sprintf( buf, "%-10s", str );
buf[SEL_WIDTH] = '\0' ;
code = flag ? FRAME_COLOR : FRAME_COLOR << 4 ;
graph_puts( buf, SEL_START, y*FontV, code );
}
/* カーソル位置の表示 */
void DrawCursorPos()
{
int x, y ;
int mx, my, mz ;
char str[80] ;
Get3DCursor( &mx, &my, &mz );
x = SEL_START ;
y = CURSOR_START * FontV ;
sprintf( str, "X:%6d", mx );
graph_puts( str, x, y, FRAME_COLOR<<4 );
sprintf( str, "Y:%6d", my );
graph_puts( str, x, y+FontV, FRAME_COLOR<<4 );
sprintf( str, "Z:%6d", mz );
graph_puts( str, x, y+FontV*2, FRAME_COLOR<<4 );
}
void DrawStatusBar(int pos)
{
int i;
int x, x2, y;
y = DISPLAY_Y - STATUS_WIDTH;
#if 0
if (pos < 0) {
#endif
graph_line( 0, y, DISPLAY_X-1, y, 7 );
graph_fill( 0, y+1, DISPLAY_X-1, DISPLAY_Y-1, FRAME_COLOR );
graph_puts(StatusText[0], FontH, y+3, FRAME_COLOR<<4);
x = DISPLAY_X - (FontH-2);
graph_fill( x, y+1, DISPLAY_X-1, DISPLAY_Y-1, FRAME_COLOR );
for (i = MAXSTATUS-1; i > 0; i--) {
if (StatusWidth[i] > 0) {
x2 = x - FontH * StatusWidth[i] - 3;
graph_box( x2, y+1, x, DISPLAY_Y-2, FALSE);
graph_puts(StatusText[i], x2+2, y+3, FRAME_COLOR<<4);
x = x2 - 2;
graph_fill( x, y+1, x2-1, DISPLAY_Y-1, FRAME_COLOR );
}
}
graph_box( FontH-2, y+1, x, DISPLAY_Y-2, FALSE);
#if 0
} else if (pos < MAXSTATUS && (pos == 0 || StatusWidth[pos] > 0)) {
x = DISPLAY_X - (FontH-2);
for (i = MAXSTATUS-1; i > pos; i--) {
if (StatusWidth[i] > 0) {
x = x - FontH * StatusWidth[i] - 3 - 2;
}
}
if (pos > 0) {
x2 = x - FontH * StatusWidth[pos] - 3;
} else {
x2 = FontH-2;
}
graph_fill( x2+1, y+2, x-1, DISPLAY_Y-3, FRAME_COLOR );
graph_puts(StatusText[pos], x2+2, y+3, FRAME_COLOR<<4);
}
#endif
}