311 lines
9.2 KiB
C++
311 lines
9.2 KiB
C++
//////////////////////////////////////////////////////////////////////////
|
||
///// Nombre: CMensaje.CPP ///
|
||
///// Modulo: Perteneciente a Catalogo.C ///
|
||
//// Descripci¢n: M¢dulo para editar o modificar el mensaje ///
|
||
//// ///
|
||
//// Autor: Jos‚ David Guill‚n Dominguez ///
|
||
//// Fecha: 30 - 12 - 1994 ///
|
||
//// ///
|
||
//// Comentario: ///
|
||
//// ///
|
||
//// ///
|
||
//// Compilador Borland C++ 3.0 ///
|
||
///////////////////////////////////////////////////////////////////////////
|
||
|
||
#include <dos.h>
|
||
#include <conio.h>
|
||
#include <stdio.h>
|
||
#include <ctype.h>
|
||
#include <stdlib.h>
|
||
#include <string.h>
|
||
#include <graphics.h>
|
||
|
||
|
||
///////////////////////////////////////////////////////////////////////////
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ//
|
||
///////////////////////////////////////////////////////////////////////////
|
||
|
||
extern struct JD {
|
||
char esc;
|
||
char color[8];
|
||
char prog[14];
|
||
char nl; char rt;
|
||
char autor[36];
|
||
char pt; char ef;
|
||
};
|
||
|
||
extern struct caddviewComentario {
|
||
int record_zone_init; // Zona de grabaci¢n interna
|
||
char linea[10][32 + 1]; // 32 digitos * 10 lineas
|
||
};
|
||
|
||
extern struct JD cabecera;
|
||
extern struct caddviewComentario JD_comment;
|
||
|
||
extern union REGS ent, sal;
|
||
|
||
///////////////////////////////////////////////////////////////////////////
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ//
|
||
///////////////////////////////////////////////////////////////////////////
|
||
extern struct boton { int left; int up; int right; int down; };
|
||
extern int boton_izq; extern int boton_der;
|
||
extern int x_raton; extern int y_raton;
|
||
extern int raton;
|
||
extern int bpush;
|
||
extern int sb;
|
||
|
||
extern int InputCadenaG(char *s, int numalp, int lmax, int px, int py, int cc, int cf);
|
||
extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py);
|
||
extern void ImprimeBoton2 (int fill, int cdf, int cs1, int cs2, struct boton parm);
|
||
extern int CheckButon(int nb, struct boton menu[]);
|
||
extern void Sound_SN(char *headfile);
|
||
extern void BorraViewPort(int view);
|
||
extern void desactiva_raton(void);
|
||
extern void activa_raton(void);
|
||
|
||
void Modificar_Comentario(void);
|
||
extern void EditCursorC(int ShowHide, int y);
|
||
|
||
void Modificar_Comentario(void){
|
||
|
||
FILE *JDm_f; // Fichero Mensajes
|
||
char ArchivoMensaje[13]="CMensaje.dat";
|
||
|
||
int LSJ = sizeof(struct JD);
|
||
int LSC = sizeof(struct caddviewComentario);
|
||
int Linea_c=1, finc = 0, key, i;
|
||
|
||
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ//
|
||
//ÛÛ Comprueba apertura correcta de COMENTARIO o creaci¢n... ÛÛ//
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ//
|
||
|
||
if ( (JDm_f = fopen( ArchivoMensaje, "r+b"))==NULL) {
|
||
|
||
FILE *fa;
|
||
if ( (fa = fopen( ArchivoMensaje, "wb" ) )!=NULL ) {
|
||
auto int i;
|
||
|
||
|
||
|
||
JD_comment.record_zone_init = 0; // 0 => disponible para grabaci¢n
|
||
// 1 => datos importantes
|
||
cabecera.esc = 27;
|
||
strcpy(cabecera.color, "[31;40m");
|
||
strcpy(cabecera.prog, "Catalogo 4.0");
|
||
cabecera.nl = 13; cabecera.rt = 10;
|
||
strcpy(cabecera.autor, " Jos‚ David Guill‚n");
|
||
cabecera.pt = 7; cabecera.ef = 26;
|
||
|
||
rewind(fa);
|
||
fwrite(&cabecera, LSJ, 1, fa);
|
||
fseek(fa, (long)LSJ, SEEK_SET);
|
||
|
||
for(i=0; i<10; i++)
|
||
strcpy(JD_comment. linea[i], "\0");
|
||
fwrite(&JD_comment, LSC, 1, fa);
|
||
if (fclose(fa) == EOF ) exit(1);
|
||
}
|
||
if ( (JDm_f = fopen( ArchivoMensaje, "r+b"))==NULL) {
|
||
printf("NO SE PUDO ABRIR EL FICHERO COMENTARIO EN LA 2§ PASADA");
|
||
exit(1);
|
||
}
|
||
}
|
||
|
||
fseek(JDm_f, (long)LSJ, SEEK_SET);
|
||
if ( fread(&JD_comment, LSC, 1, JDm_f) != 1 ) {
|
||
printf("NO SE PUDO LEER EL FICHERO COMENTARIO");
|
||
exit(1);
|
||
}
|
||
|
||
BorraViewPort(1);
|
||
BorraViewPort(2);
|
||
BorraViewPort(3);
|
||
|
||
////////////////////////////// Ahora se abrir un nuevo men£ para el raton:
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||
struct boton comment[4];
|
||
comment[0]. left = 217; comment[0]. up = 34; comment[0]. right = 297; comment[0]. down = 75;
|
||
comment[1]. left = 217; comment[1]. up = 76; comment[1]. right = 297; comment[1]. down = 117;
|
||
comment[2]. left = 217; comment[2]. up = 118; comment[2]. right = 297; comment[2]. down = 159;
|
||
comment[3]. left = 217; comment[3]. up = 160; comment[3]. right = 297; comment[3]. down = 204;
|
||
|
||
for(i=0; i<4; i++) ImprimeBoton2 (1, 7, 63, 56, comment[i]);
|
||
|
||
setcolor(15);
|
||
|
||
outtextxy(222, 49 , " Supr. ");
|
||
outtextxy(222, 58, " Linea");
|
||
|
||
outtextxy(222, 96 , " UP ");
|
||
outtextxy(222, 138, " DOWN ");
|
||
|
||
outtextxy(224, 179, "Salir ");
|
||
outtextxy(222, 189, " F2");
|
||
|
||
setcolor(0);
|
||
|
||
outtextxy(221, 48 , " Supr. ");
|
||
outtextxy(221, 57, " Linea");
|
||
|
||
outtextxy(221, 95 , " UP ");
|
||
outtextxy(221, 137, " DOWN ");
|
||
|
||
outtextxy(223, 178, "Salir ");
|
||
outtextxy(221, 188, " F2");
|
||
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||
|
||
setcolor(14);
|
||
for(i=0; i<10; i++)
|
||
outtextxy( 42 * 8 - 7, (4 + i) * 16 - 16, JD_comment. linea[i]);
|
||
|
||
do{
|
||
|
||
EditCursorC(0, Linea_c);
|
||
|
||
if(raton) activa_raton();
|
||
/////////////////////// Aqui va una pausa de TECLADO y RATON al mismo TIEMPO
|
||
do{
|
||
if(raton){
|
||
ent.x.ax = 3;
|
||
int86(0x33, &ent, &sal); // lee posici¢n y estados del bot¢n
|
||
boton_izq = sal.x.bx & 1;
|
||
boton_der = (sal.x.bx >> 1) & 1;
|
||
x_raton = sal.x.cx;
|
||
y_raton = sal.x.dx;
|
||
} else boton_izq = 1;
|
||
}while( !boton_izq && !kbhit() );
|
||
if(raton) desactiva_raton();
|
||
|
||
if( kbhit() ) {
|
||
|
||
////////////////////////////////////////////////////////////////////////
|
||
///////////////////////////////////////// ¨ Hay una tecla en buffer ...
|
||
|
||
key = getch();
|
||
|
||
EditCursorC(1, Linea_c);
|
||
|
||
if( isprint(key) || isspace(key) ) {
|
||
|
||
if(key != 13) ungetch(key);
|
||
InputCadenaG( JD_comment. linea[Linea_c - 1], 0, 32, 42, Linea_c + 3, 63, 57);
|
||
|
||
} else {
|
||
|
||
if( key == 0 ) {
|
||
key = getch();
|
||
|
||
switch ( key ) {
|
||
// DEL --- Borra Linea
|
||
case 83:
|
||
strcpy(JD_comment. linea[Linea_c - 1], "\0");
|
||
break;
|
||
|
||
// FLECHA ARRIBA
|
||
case 72:
|
||
Linea_c--;
|
||
if (Linea_c < 1) Linea_c = 10;
|
||
break;
|
||
// FLECHA ABAJO
|
||
case 80:
|
||
Linea_c++;
|
||
if (Linea_c > 10) Linea_c = 1;
|
||
break;
|
||
|
||
// FLECHA IZQUIERDA
|
||
case 75:
|
||
case 15:
|
||
Linea_c--;
|
||
if (Linea_c < 1) Linea_c = 10;
|
||
break;
|
||
|
||
// FLECHA DERECHA
|
||
case 77:
|
||
case 9:
|
||
Linea_c++;
|
||
if (Linea_c > 10) Linea_c = 1;
|
||
break;
|
||
|
||
// F2 --> PARA SALIR
|
||
case 60:
|
||
finc = 1;
|
||
break;
|
||
|
||
default:
|
||
if (sb) Sound_SN("catalog3");
|
||
break;
|
||
} // Fin de Swicth
|
||
} // Fin Key = 0
|
||
} // Fin Is Print Key?
|
||
} // Fin Tecla en Buffer
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ//
|
||
////////////////////////// Comprueba con rat¢n ( SI ) ///////////////////////
|
||
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß//
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
////////////////////////////////////////////////// ... o es el RATON ?
|
||
|
||
if(raton && boton_izq==1 || boton_der==1) {
|
||
|
||
if( CheckButon(4, comment) ) {
|
||
|
||
EditCursorC(1, Linea_c);
|
||
switch ( bpush ) {
|
||
// Suprimir Linea
|
||
case 1:
|
||
strcpy(JD_comment. linea[Linea_c - 1], "\0");
|
||
break;
|
||
|
||
// FLECHA ARRIBA
|
||
case 72:
|
||
Linea_c--;
|
||
if (Linea_c < 1) Linea_c = 10;
|
||
break;
|
||
|
||
// FLECHA ABAJO
|
||
case 80:
|
||
Linea_c++;
|
||
if (Linea_c > 10) Linea_c = 1;
|
||
break;
|
||
|
||
// FLECHA IZQUIERDA
|
||
case 75:
|
||
case 15:
|
||
Linea_c--;
|
||
if (Linea_c < 1) Linea_c = 10;
|
||
break;
|
||
// FLECHA DERECHA
|
||
case 77:
|
||
case 9:
|
||
Linea_c++;
|
||
if (Linea_c > 10) Linea_c = 1;
|
||
break;
|
||
// F2 --> PARA SALIR
|
||
case 60:
|
||
finc = 1;
|
||
break;
|
||
|
||
default:
|
||
if (sb) Sound_SN("catalog3");
|
||
break;
|
||
} // Fin de Swicth
|
||
|
||
}
|
||
}
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
}while( !finc );
|
||
|
||
BorraViewPort(1);
|
||
BorraViewPort(2);
|
||
BorraViewPort(3);
|
||
|
||
fseek(JDm_f, (long)LSJ, SEEK_SET);
|
||
fwrite(&JD_comment, LSC, 1, JDm_f);
|
||
if (fclose(JDm_f) == EOF ) exit(1);
|
||
|
||
}
|