5 int Couleur,Fond,CurX,CurY;
13 void mousenit(int mo,int ke)
17 evt=(MouseEvent *)malloc(sizeof(MouseEvent));
18 MouseEventEnable(ke,mo);
32 int mouse(v,p,h,l,r,c)
33 unsigned int *v,*p,*h,*l,*r,*c;
39 *v=0,*p=0,*h=0,*l=0,*r=0,*c=0;
42 evt=(MouseEvent *)calloc(1,sizeof(MouseEvent));
43 MouseGetEvent(M_EVENT | M_POLL | M_NOPAINT,evt);
44 *p=evt->kbstat; *l=evt->key;
46 *r=evt->flags; *c=evt->buttons;
47 if(ev1->kbstat!=evt->kbstat || ev1->key!=evt->key || ev1->x!=evt->x ||
48 ev1->y!=evt->y || ev1->flags!=evt->flags || ev1->buttons!=evt->buttons)
54 void afficheinteger(int x,int y,int valeur,int cf,int ce)
58 sprintf(tst,"%i",valeur);
59 GrTextXY(x,y,tst,ce,cf);
70 int readcara(int posx,int posy,int col_f,int col_e)
77 GrHLine(posx,posx+8,posy+13,col_f);
79 GrHLine(posx,posx+8,posy+13,col_e);
82 GrHLine(posx,posx+8,posy+13,col_f);
96 int affiche_chaine(int x,int y,int lg,char *txtd,char *txtf,int av,int *ll,int col_e,int col_f)
104 for(sprintf(&cara[0],"%c\0",*txtf),larg=0;txtf>=txtd;txtf--) /* affiche arriere */
106 GrTextXY(x+lg-larg,y,&cara[0],col_e,col_f);
108 sprintf(&cara[0],"%c\0",*(txtf-1));
122 for(sprintf(&cara[0],"%c\0",*txtd),larg=0;txtd<=txtf;txtd++) /* affiche avant */
124 GrTextXY(x+larg,y,&cara[0],col_e,col_f);
126 sprintf(&cara[0],"%c\0",*(txtd+1));
137 int gscanfnum(int x,int y,int lg,int min,int max,int deft,int col_f,int col_e,int col_c)
146 short signe=0; /* par defaut 0(+) sinon 1(-) */
149 GrFilledBox(x,y,x+lg,y+14,col_f);
150 sprintf(t,"%lu\0",deft);
151 while(*ptc!='\0') ptc++;
152 GrTextXY(x+lg-strlen(t)*8,y,t,col_e,col_f);
155 a=readcara(x+lg-8,y,col_f,col_c);
196 if((a<='9') && (a>='0'))
207 GrFilledBox(x,y,x+lg,y+14,col_f);
208 affiche_chaine(x,y,lg,ptd,ptc,flg,&larg,col_e,col_f);
211 GrTextXY(x,y,"-",col_e,col_f);
213 GrTextXY(x,y,"+",col_e,col_f);
215 while((a!=13) && (a!=27));
221 if((i<=max) && (i>=min))
226 return(gscanfnum(x,y,lg,min,max,deft,col_f,col_e,col_c));
230 return(gscanfnum(x,y,lg,min,max,deft,col_f,col_e,col_c));
234 /******************************************************************************/
235 char *gschar(int x,int y,int lg,int *lgmax,char *defaut,int col_f,int col_e,int col_c)
241 ptd=(char *)malloc(*lgmax);
243 GrFilledBox(x,y,x+lg*8,y+14,col_f);
244 GrTextXY(x,y,defaut,col_e,col_f);
247 a=readcara((larg<(lg-1)*8) ? (x+larg) : (x+(lg-1)*8),y,col_f,col_c);
255 larg=(larg-8)>0 ? larg-8 : 0;
268 if(((ptc-ptd)/sizeof(char))<=*lgmax)
278 GrFilledBox(x,y,x+lg*8,y+14,col_f);
279 flg=affiche_chaine(x,y,(lg-1)*8,ptd,ptc,flg,&larg,col_e,col_f);
281 while((a!=13) && (a!=27));
282 if((a==27) || (ptd==ptc))
285 while(*ptc!='\0') ptc++;
289 GrFilledBox(x,y,x+lg*8,y+14,col_f);
290 affiche_chaine(x,y,lg*8,ptd,ptc,1,&larg,col_e,col_f);
291 *lgmax=(ptc>ptd)? ptc-ptd+1 : 0;