home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Vectronix 2
/
VECTRONIX2.iso
/
FILES_01
/
MIDICOM.LZH
/
MC_UTILS
/
MC_CONTR
/
MC_CONTR.C
next >
Wrap
C/C++ Source or Header
|
1993-10-18
|
5KB
|
271 lines
#include <portab.h> /* Standard-Definitionen */
#include <aes.h> /* AES */
#include <ext.h> /* Timeraufrufe */
#include <string.h> /* Timeraufrufe */
#include <stddef.h> /* Standard-Definitionen */
#include <tos.h>
#include <cpxdata.h> /* CPX-Datenstrukturen */
#include <gemst2.h>
#include "..\MC_LIB\mc_LIB.h"
#include "mccontr.h"
#include "mccontr.c"
#define WM_CLOSE 22
#define AC_CLOSE 41
static boolean color;
void init_dia(OBJECT *tree)
{
int i,fo_cx,fo_cy,fo_cw,fo_ch;
for (i = 0; i < rs_numobs; i++)
rsrc_obfix(tree,i);
i=form_center(tree,&fo_cx,&fo_cy,&fo_cw,&fo_ch );
}
void name_buttons(int index,char *name)
{
char *hlp;
switch(color) {
case TRUE:{
switch(index)
{
case R1: hlp=string_58;break;
case R2: hlp=string_59;break;
case R3: hlp=string_60;break;
case R4: hlp=string_61;break;
case R5: hlp=string_62;break;
case R6: hlp=string_63;break;
default: hlp=string_57;
}
};break;
case FALSE:{
switch(index)
{
case R1: hlp=string_25;break;
case R2: hlp=string_26;break;
case R3: hlp=string_27;break;
case R4: hlp=string_28;break;
case R5: hlp=string_29;break;
case R6: hlp=string_30;break;
default: hlp=string_24;
}
};break;
}
strcpy(hlp,name);
}
void init_buttons(OBJECT *tree,syspar sys,all_proc apc)
{
int i,j;
for (j=R0;j<=R6;j++) Disable(j);
i=sys->my_num;
j=0;
if (i==7)
{
name_buttons(R0,(*apc)[i].r_name);
Enable(R0);
if (sys->prconf & 1)
{
Select(R0);
}
}
else
{
do
{
if ((*apc)[i].status.bits.rtw==7)
{
name_buttons(j+R0,(*apc)[i].r_name);
Enable(j+R0);
if (sys->prconf & (1<<j))
{
Select(j+R0);
}
else
{
Deselect(j+R0);
};
j++;
};
if (i++==6) i=0;
} while (i!=sys->my_num);
};
}
void set_dialog(OBJECT *tree, syspar sys,all_proc allprocs)
{
struct time tim;
struct date date;
init_buttons(tree,sys,allprocs);
gettime( &tim );
getdate( &date );
switch(color)
{
case TRUE: {
itoa(date.da_day,string_35,10);
itoa(date.da_mon,string_39,10);
itoa(date.da_year,string_43,10);
itoa(tim.ti_hour,string_47,10);
itoa(tim.ti_min,string_51,10);
};break;
case FALSE: {
itoa(date.da_day,string_2,10);
itoa(date.da_mon,string_6,10);
itoa(date.da_year,string_10,10);
itoa(tim.ti_hour,string_14,10);
itoa(tim.ti_min,string_18,10);
};break;
};
}
void set_time(void)
{
struct time tim;
struct date date;
switch(color)
{
case TRUE: {
date.da_day=atoi(string_35);
date.da_mon=atoi(string_39);
date.da_year=atoi(string_43);
tim.ti_hour=atoi(string_47);
tim.ti_min=atoi(string_51);
};break;
case FALSE: {
date.da_day=atoi(string_2);
date.da_mon=atoi(string_6);
date.da_year=atoi(string_10);
tim.ti_hour=atoi(string_14);
tim.ti_min=atoi(string_18);
};break;
};
settime(&tim);
setdate(&date);
}
void send_time(void)
{
msg_typ mc_msg;
set_time();
mc_msg.what = 6007;
mc_message(&mc_msg);
}
void setPrnt(OBJECT *tree,syspar sys)
{
int erg=0;
if (IsSelected(R0)) erg|=1;
if (IsSelected(R1)) erg|=2;
if (IsSelected(R2)) erg|=4;
if (IsSelected(R3)) erg|=8;
if (IsSelected(R4)) erg|=16;
if (IsSelected(R5)) erg|=32;
if (IsSelected(R6)) erg|=64;
sys->prconf=erg;
}
void app_dialog(OBJECT *tree, syspar sys,all_proc allprocs)
{
int i;
form_dial(FMD_START,tree[ROOT].ob_x,tree[ROOT].ob_y,
tree[ROOT].ob_width,tree[ROOT].ob_height,
tree[ROOT].ob_x,tree[ROOT].ob_y,
tree[ROOT].ob_width,tree[ROOT].ob_height);
do
{
set_dialog(tree,sys,allprocs);
objc_draw(tree,ROOT,MAX_DEPTH,0,0,0,0);
i=form_do(tree,0);
SetNormal(i);
switch(i)
{
case LOKAL: set_time();break;
case GLOBAL: send_time();break;
case DOIT: setPrnt(tree,sys);break;
}
} while (i!=XEXIT);
form_dial(FMD_FINISH,tree[ROOT].ob_x,tree[ROOT].ob_y,
tree[ROOT].ob_width,tree[ROOT].ob_height,
tree[ROOT].ob_x,tree[ROOT].ob_y,
tree[ROOT].ob_width,tree[ROOT].ob_height);
}
void wait_loop(void)
{
syspar sys;
all_proc allprocs;
OBJECT *tree;
WORD msg[8];
if (Getrez()>=2)
{
tree=( OBJECT *)rs_trindex[ PRWAHL ];
rs_numobs = 28;
color = FALSE;
}
else
{
tree=( OBJECT *)rs_trindex[ PRWAHLC ];
rs_numobs = 28;
color = TRUE;
};
init_dia(tree);/* location and center */
if (_app==0) /* ACC */
{
menu_register( gl_apid," MC_CONTR");
do
{
evnt_mesag(msg);
if (msg[0]==AC_OPEN)
{
if (get_mc_sys(&sys,&allprocs))
{
app_dialog(tree,sys,allprocs);
}
else
{
form_alert(1,string_66);
};
};
}while (1);
}
else
{
if (get_mc_sys(&sys,&allprocs))
{
app_dialog(tree,sys,allprocs);
}
else
{
form_alert(1,string_66);
};
};
}
int main( void )
{
wait_loop();
return 0;
}