Files
Borland-C/CPP/VIDEO2.CPP

308 lines
9.5 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <time.h>
#include "d:\progs_c\lib\gui.h"
char titulo[80]={"Programa Gesti¢n del VideoClub Alfa. Juan L¢pez Fern ndez"};
int estoy_en=1;// Indica el men£ en el que me encuentro.
int select_actual=1; // Indica que opci¢n est  seleccionada actualmente.
int n_op_menu=5; // N£mero de opciones del menu. (default menu1=5)
int refresco=1; // Para el calor... Refresca la pantalla :-).
int *p_estoy_en=&estoy_en;// -- Punteros a sus respectivas variables. --
int *p_select_actual=&select_actual;
int *p_n_op_menu=&n_op_menu;
int *p_refresco=&refresco;
struct peliculas {
char titulo[20];
char tema[10];
int duracion;
int alquileres;
};
struct clientes {
int codigo;
char nombre[25];
};
struct alquileres {
struct peliculas lista_pelis[5];
struct clientes socio;
float fecha_dev;
char finalizado;
};
void modo_grafico();
void menu(int, int);
void miga(int*, int*);
void localizacion(int, int, int);
void reloj(int, int);
// ***********************************************************************
// PROGRAMA PRINCIPAL
// ***********************************************************************
void main() {
modo_grafico();
//presentacion(); // Me pregunto si llegar a hacerla... ;-).
menu(estoy_en, select_actual);
int tecla1, tecla12, sw=1;
while(sw==1){
reloj(423,100);
tecla1=getch();
if(tecla1==0) // leemos tecla especial.
{
tecla12=getch();
switch(tecla12) {
case 72: // Flecha arriba
if (select_actual<=1)
select_actual=1;
else {
select_actual--;
menu(estoy_en, select_actual);
}
break;
case 80: // Flecha abajo
if (select_actual>=n_op_menu)
select_actual=n_op_menu;
else{
select_actual++;
menu(estoy_en, select_actual);
}
break;
} // fin del switch-case
}// fin del if
else
if (tecla1==13) // MIGA DEL ASUNTO
{
miga(p_estoy_en, p_select_actual);
menu(estoy_en, select_actual);
}
else
if (tecla1==27)
if (estoy_en==1) // Se acab¢ la funci¢n...
sw=0;
else // Navegaci¢n descendente por men£s.
{
*p_estoy_en/=10;
*p_n_op_menu=5;
*p_select_actual=1;
*p_refresco=1;
menu(estoy_en,select_actual);
}
} // fin del while
// getch();
closegraph();
}
// ***********************************************************************
// --- FUNCIONES DEL PROGRAMA ---
// ***********************************************************************
// ------------------------------------------------------------------------
// FUNCIàN MIGA (MIGA DEL ASUNTO)
// (con punteros!, como mola...)
// ------------------------------------------------------------------------
void miga(int *p_estoy_en,int *p_select_actual) {
*p_refresco=1; // antes de nada tomemos una coca-cola... ;-)
switch (*p_estoy_en) // veamos que hay que hacer:
{
case 1: // naveguemos por los men£s: ir a menu 1.x
switch (*p_select_actual)
{
case 1:
*p_estoy_en=11;
*p_select_actual=1;
*p_n_op_menu=5;
break;
case 2:
*p_estoy_en=12;
*p_select_actual=1;
*p_n_op_menu=5;
break;
case 3:
*p_estoy_en=13;
*p_select_actual=1;
*p_n_op_menu=3;
break;
case 4:
*p_estoy_en=14;
*p_select_actual=1;
*p_n_op_menu=3;
break;
} // fin del switch-case de navegaci¢n de men£s.
break;//fin del case 1 general.
} // fin del switch-case general.
} // fin de la funci¢n miga
// -----------------------------------------------------------------------
// FUNCIàN QUE INICIA EL MODO GRµFICO
// -----------------------------------------------------------------------
void modo_grafico(){
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "d:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk){
printf("Error al iniciar el modo gr fico: %s\n",
grapherrormsg(errorcode));
printf("Pulse cualquier tecla1 para finalizar...");
getch();
exit(1);
}
}
// -----------------------------------------------------------------------
// FUNCION MENU
// -----------------------------------------------------------------------
void menu(int estoy_en, int select_actual) {
//-------------------- CABECERA DE LA PANTALLA -----------------------
if (*p_refresco) // tomamos otro refresco... (ahora una fanta lim¢n).
{
setviewport(0, 0, getmaxx(), getmaxy(), 0);
settextstyle(2, 0, 5);
ventana(1, 1, getmaxx(), getmaxy(), 1, 9, titulo);
boton(5, 30, getmaxx()-5, 80, 3, 0, "", 9);
setcolor(8); line(5, 90, getmaxx()-5, 90); // dibujamos una doble
setcolor(15); line(5, 91, getmaxx()-5, 91); // l¡nea.
settextstyle(7,0,6); setcolor (1); // caja central con nuestro
outtextxy(110,23,"Video Club ALFA"); // logo del videoclub.
setcolor(8); line(5, 134, getmaxx()-5, 134); // dibujamos otra doble
setcolor(15); line(5, 135, getmaxx()-5, 135); // l¡nea.
localizacion(estoy_en,125,105); // mostramos en una barra donde estamos
*p_refresco=0; // demasiadas burbujas...
}
//----------------- fin de la cabecera de la pantalla ------------------
setviewport(110, 180, 600, 300, 0); // zona de los botones.
switch (estoy_en) // Mostramos un men£ seg£n donde estemos.
{
case 1: // ------------- MENU PRINCIPAL ------------------------------
settextstyle(2,0,6);
boton(0, 5, 250, 30, 7, 0, "1.- Gesti¢n de Clientes", 16);
boton(0, 45, 250, 70, 7, 0, "2.- Gesti¢n de Pedidos", 16);
boton(0, 85, 250, 110, 7, 0, "3.- Alquileres", 16);
boton(0, 125, 250, 150, 7, 0, "4.- Devoluciones", 16);
boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16);
break;
case 11: // ---------------- MENU CLIENTES ---------------------------
settextstyle(2,0,6);
boton(0, 5, 250, 30, 7, 0, "1.- Altas de Clientes", 16);
boton(0, 45, 250, 70, 7, 0, "2.- Bajas de Clientes", 16);
boton(0, 85, 250, 110, 7, 0, "3.- Modificaciones", 16);
boton(0, 125, 250, 150, 7, 0, "4.- Listado de clientes", 16);
boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16);
break;
case 12: // ------------- MENU GESTION DE PEDIDOS ---------------------
settextstyle(2,0,6);
boton(0, 5, 250, 30, 7, 0, "1.- Altas de Pel¡culas", 16);
boton(0, 45, 250, 70, 7, 0, "2.- Bajas de Pel¡culas", 16);
boton(0, 85, 250, 110, 7, 0, "3.- Modificaciones", 16);
boton(0, 125, 250, 150, 7, 0, "4.- Listado de datos", 16);
boton(0, 165, 250, 190, 7, 0, "5.- Salir", 16);
break;
case 13: //------------------ MENU 3: ALQUILERES --------------------
settextstyle(2,0,6);
boton(0, 5, 250, 30, 7, 0, "1.- Altas de Alquiler", 16);
boton(0, 45, 250, 70, 7, 0, "2.- Modificar", 16);
boton(0, 85, 250, 110, 7, 0, "3.- Volver", 16);
break;
case 14:// ------------------- MENU 4: DEVOLUCIONES ------------------
settextstyle(2,0,6);
boton(0, 5, 250, 30, 7, 0, "1.- Devoluciones", 16);
boton(0, 45, 250, 70, 7, 0, "2.- Modificaciones", 16);
boton(0, 85, 250, 110, 7, 0, "3.- Volver", 16);
break;
} //fin del switch-case(estoy_en).
setlinestyle(3,0,2);
switch (select_actual)// Ahora pintamos un recuadro al bot¢n seleccionado.
{
case 1:
rectangle(5,9,245,26);
setlinestyle(0,0,2);rectangle(0,5,250,30);
break;
case 2:
rectangle(5,49,245,66);
setlinestyle(0,0,2);rectangle(0,45,250,70);
break;
case 3:
rectangle(5, 89, 245, 106);
setlinestyle(0,0,2);rectangle(0,85,250,110);
break;
case 4:
rectangle(5, 129, 245, 146);
setlinestyle(0,0,2);rectangle(0,125,250,150);
break;
case 5:
rectangle(5,169, 245, 186);
setlinestyle(0,0,2);rectangle(0,165,250,190);
break;
} // fin del switch-case(select_actual).
setlinestyle(0,0,0); // volvemos a poner el estilo de l¡nea normal.
} // fin de la funci¢n men£.
// ------------------------------------------------------------------------
// FUNCIàN LOCALIZACIàN
// ------------------------------------------------------------------------
void localizacion(int estoy_en, int x, int y) {
settextstyle(2,0,5);
boton(5,100,getmaxx()-225,124,7,1,"Localizaci¢n:",8);
setcolor(1);
switch (estoy_en) {
case 1:
outtextxy(x,y,"Men£ General");
break;
case 11:
outtextxy(x,y, "Men£ General / Gesti¢n de Clientes");
break;
case 12:
outtextxy(x,y, "Men£ General / Gesti¢n de Pedidos");
break;
case 13:
outtextxy(x,y, "Men£ General / Alquileres");
break;
case 14:
outtextxy(x,y, "Men£ General / Devoluciones");
break;
} // fin del switch-case
} // fin de la funci¢n.
// ------------------------------------------------------------------------
// FUNCIàN RELOJ
// ------------------------------------------------------------------------
void reloj (int x, int y) {
setviewport(0,0,getmaxx(),getmaxy(),1);
time_t t;
time(&t);
settextstyle(2,0,5);
boton (x,y,x+210,y+25,7,0,ctime(&t),1);
}