Accueil > > > SIMULATION D'ECRAN BOURSIER TURBOC++ MODE GRAPHIQUE
SIMULATION D'ECRAN BOURSIER TURBOC++ MODE GRAPHIQUE
Information sur la source
Description
generation de chiffres dans un tableau avec des graphiques
Source
- /* PROGRAMME EN C SOUS DOS TURBO C++2 BORLAND
- ecrit le 01-02-2003 par cmarsc
- ECRAN DE COTATIONS BOURSIERES : MODE GRAPHIQUE */
-
- #include <graphics.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <conio.h>
- #include <time.h>
- #include <dos.h>
-
-
- #define NBRE_LIGNES_MAXI 15
- #define NBRE_COLONNES_MAXI 30
-
- #define COUL_ECRAN LIGHTBLUE
- #define COUL_CHIFFRES LIGHTGREEN
- #define COUL_CHIFFRES_FOND LIGHTBLUE
- #define COUL_CURSEUR BLUE
- #define COUL_TEXTES_FOND RED
- #define COUL_BARRE CYAN
- #define COUL_COURBE LIGHTRED
-
- void bouton_3D(int x1, int y1, int x2, int y2, int coul,int relief,int clic);
- void box(int x1, int y1, int x2, int y2, int coul_box,int coul_fond,int effet);
- void generer_afficher_chiffres(void);
-
- enum etats_boutons { NON_CLIQUE, CLIQUE };
- enum effets_cadre { PAS_D_OMBRE, OMBRE };
-
- int main(void)
- {
- int i1,milieu_y;
-
- // teste pour passer en mode graphique
- int gdriver = DETECT, gmode, errorcode;
- initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
-
- errorcode = graphresult();
- if (errorcode != grOk)
- {
- printf("Graphics error: %s\n", grapherrormsg(errorcode));
- printf("Press any key to halt:");
- getch();
-
- exit(1);
- }
-
- sleep(1);
-
- settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 4);
-
- milieu_y = getmaxy()/2;
-
- // afficher le fond d'ecran
- setcolor(COUL_ECRAN);
- for (i1 = 0; i1 <= milieu_y; i1++) {
- rectangle (1, (milieu_y-3)-i1, getmaxx() ,(milieu_y-3) + i1);
- delay(1);
- }
-
- // cadre principal
- // x1 = 1 y1 = 1 x2 = 639 y2 = 480 coul = LIGHTBLUE relief = 4 clic = 0
- bouton_3D(1,1,getmaxx(),getmaxy(),COUL_ECRAN,4,NON_CLIQUE);
-
- generer_afficher_chiffres();
-
- // effacer l'ecran
-
- milieu_y = getmaxy() / 2;
- setcolor(BLACK);
-
- for (i1 = 0; i1 <= milieu_y; i1++) {
- rectangle (0+i1,i1,getmaxx()-i1,getmaxy()-i1);
- delay(2);
- }
- delay(500);
-
- // fermer le mode graphique
- closegraph();
- return EXIT_SUCCESS;
- } // fin de main
-
-
- void bouton_3D(int x1, int y1, int x2, int y2, int coul,int relief,int clic){
- int i1;
-
- // dessiner le bouton avec un relief
- for (i1 = 0; i1 < relief; i1++) {
-
- setcolor(WHITE);
- // trait blanc haut
- line (x1 + i1, y1 + i1, x2 - i1, y1 + i1);
- // trait blanc gauche
- line (x1 + i1, y1 + i1, x1 + i1, y2 - i1);
-
- setcolor(DARKGRAY);
- // trait gris bas
- line (x1 + i1, y2 - i1, x2 - i1, y2 - i1);
- // trait gris droit
- line (x2 - i1, y1 + i1, x2 - i1, y2 - i1);
-
- }
-
- // simuler le clique
- if (clic == CLIQUE) {
- setcolor(BLACK);
- for (i1 = 1; i1 < 3; i1++) {
- rectangle (x1 + i1, y1 + i1, x2 - i1, y2 - i1);
- }
-
- setcolor(WHITE);
- // cadre blanc exterieur
- rectangle (x1 , y1 , x2 , y2 );
- } else {
- // dessiner le fond du bouton en couleur
- setfillstyle(SOLID_FILL,coul);
- bar (x1 +i1 , y1 +i1, x2-i1 , y2-i1 );
- }
-
- return ;
- } // fin de la fonction bouton_3D
-
-
- void box(int x1, int y1, int x2, int y2, int coul_box,int coul_fond,int effet){
-
- // dessiner l'ombre avec un decalage de 5
- if (effet == OMBRE) {
- setfillstyle(SOLID_FILL,BLACK);
- bar (x1 + 5 , y1 + 5 , x2 + 5 , y2 + 5 );
- }
-
- setfillstyle(SOLID_FILL,coul_fond);
- bar (x1 , y1 , x2 , y2 );
-
- setcolor(coul_box);
- rectangle (x1 , y1 , x2 , y2 );
- return ;
- } // fin de la fonction box
-
-
- void generer_afficher_chiffres(void) {
-
- int i1 = 0, i2;
- int chiffre,ligne_en_surbrillance;
- char texte1[NBRE_COLONNES_MAXI+1];
- static char texte_du_titre[50];
-
- static char *noms_des_teles[15] = {
- "TF1", "CBS","CANAL+","NET TV","ZDF","ARTE","M6","TV 5",
- "ABC","BBC","SKY","RTBF 1","CNN","FUN TV", "NHK TV"
- };
-
- time_t heure;
- int graphique[3][NBRE_COLONNES_MAXI] = { NULL };
-
- // initialiser le generateur de nombres pseudos-alatoires
- srand( (unsigned) time(NULL) );
-
- // x1 =10 y1 = 42 x2 = 76 y2 = 346 coul_cadre = jaune coul_fond = bleu
- // effet avec une ombre
- // cadre gauche avec les noms des teles
- box(10, 42, 76, 346, YELLOW, BLUE, OMBRE);
-
- // cadre avec les chiffres
- // x1 =77 y1 = 42 x2 =337 y2 = 346 coul_cadre = jaune coul_fond = noir
- box(77, 42, 337, 346, YELLOW, BLACK, OMBRE);
-
- // cadre a droite avec l'histogramme
- // x1 =345 y1 = 42 x2 =630 y2 = 346 coul_cadre = vert coul_fond = noir
- box(345, 42, 630, 346, LIGHTGREEN, BLACK, PAS_D_OMBRE);
-
- // cadre en bas a gauche : graphique en courbe
- // x1 =10 y1 =360 x2 =337 y2 =465 coul_cadre = blanc coul_fond = noir
- box(10, 360, 337, 465, WHITE,BLACK, PAS_D_OMBRE);
-
- // cadre en bas a droite : graphique barre horizontale
- // x1 =345 y1 =360 x2 =630 y2 =465 coul_cadre = blanc coul_fond = noir
- box(345, 360, 630, 465, YELLOW,BLACK, PAS_D_OMBRE);
-
- settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
- setcolor(LIGHTCYAN);
- outtextxy(360,5, "Bourse de PARIS");
- setcolor(BLACK);
- outtextxy(360,6, "Bourse de PARIS");
-
- // police de caractere
- settextstyle(SMALL_FONT, HORIZ_DIR, 5);
-
- while (!kbhit()) { // kbhit 1
-
- while (!kbhit()) { // kbhit 2
-
- if (i1 >= NBRE_LIGNES_MAXI) i1 = 0;
-
- // choisir la ligne a mettre en evidence
- ligne_en_surbrillance = (rand() % NBRE_LIGNES_MAXI);
-
- // afficher la date et l'heure
- time(&heure);
- box(10,10, 337,35,WHITE,MAGENTA,PAS_D_OMBRE);
-
- sprintf(texte_du_titre,"Cotations du %s",ctime(&heure) );
- outtextxy(15,15, texte_du_titre);
-
- if (i1 == ligne_en_surbrillance)
- setfillstyle(SOLID_FILL,COUL_CURSEUR);
- else
- setfillstyle(SOLID_FILL,COUL_TEXTES_FOND);
-
- // afficher les noms des teles
- bar(11, 45+(i1*20), 75, 63+(i1*20));
- outtextxy(20,45 + (i1*20), noms_des_teles[i1]);
-
- for (i2 = 0; i2 < NBRE_COLONNES_MAXI; i2++) {
-
- if (i2 < 8) { // tableau avec les chiffres
-
- chiffre = (rand() %100)+1 ;
-
- if (i1 == ligne_en_surbrillance)
- setfillstyle(SOLID_FILL,COUL_CURSEUR);
- else
- setfillstyle(SOLID_FILL,COUL_CHIFFRES_FOND);
-
- bar(80+(i2*32),45 + (i1*20),110+(i2*32),63 + (i1*20));
- sprintf(texte1,"%4d",chiffre);
- setcolor(COUL_CHIFFRES);
- outtextxy(75 + (i2*32),45 + (i1*20), texte1 );
-
- } // if (i2 < 8)
-
-
- if (i2 < 15) { // histogramme a droite
-
- setfillstyle(SOLID_FILL,BLACK);
- if (i2) { // effacer la barre precedente
- bar(350 + ((i2-1) * 20),43,360 + ((i2-1) * 20),340-graphique[1][i2-1]);
- } // fin de if(i2)
-
- graphique[0][i2] = (rand() % 290) +5;
- // garder les anciennes positions des barres pour effacer
- graphique[1][i2] = graphique[0][i2];
-
- setcolor(COUL_CHIFFRES);
-
- if (i2 < 14) { // afficher la barre en 3D
- bouton_3D(350 + (i2*20),340-graphique[0][i2],360 + (i2*20),340,COUL_BARRE,3,0);
- } // fin de if (i2 < 14)
-
- } // if (i2 < 15)
-
- if (i2 < 15) { // graphique en courbe bas
-
- graphique[2][i2] = (rand() % 99) + 1;
-
- // effacer la courbe precedente
- box(20 + (i2 * 20),361, 40 + (i2 * 20),460,BLACK,BLACK,PAS_D_OMBRE);
-
- setcolor(COUL_COURBE);
- if (i2 > 0) { // graphique en courbe : bas gauche
-
- line (20 + (i2 * 20),460-graphique[2][i2-1], 40 + (i2 * 20),460-graphique[2][i2]);
-
- } // fin de if (i2 > 0)
-
- // le graphique en barre horizontale : bas droite
- graphique[3][i2] = (rand() % 274) + 1;
-
- // effacer la barre horizontale precedente
- box(350, 365+(i2*6.5), 625 , 369+(i2*6.5), BLACK,BLACK, PAS_D_OMBRE);
-
- // dessiner la barre horizontale
- box(350, 365+(i2*6.5), 350 +graphique[3][i2], 369+(i2*6.5), LIGHTGREEN,BLACK, PAS_D_OMBRE);
-
- } // fin de if (i2 < 15)
-
- delay(1);
- } // fin de for (i2 = 0..)
-
- i1++;
- } // fin de while (!kbhit()) kbhit 2
-
-
- };// fin de while (!kbhit()) kbhit 1
- return ;
- } // fin de la fonction generer_afficher_chiffres
/* PROGRAMME EN C SOUS DOS TURBO C++2 BORLAND
ecrit le 01-02-2003 par cmarsc
ECRAN DE COTATIONS BOURSIERES : MODE GRAPHIQUE */
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <dos.h>
#define NBRE_LIGNES_MAXI 15
#define NBRE_COLONNES_MAXI 30
#define COUL_ECRAN LIGHTBLUE
#define COUL_CHIFFRES LIGHTGREEN
#define COUL_CHIFFRES_FOND LIGHTBLUE
#define COUL_CURSEUR BLUE
#define COUL_TEXTES_FOND RED
#define COUL_BARRE CYAN
#define COUL_COURBE LIGHTRED
void bouton_3D(int x1, int y1, int x2, int y2, int coul,int relief,int clic);
void box(int x1, int y1, int x2, int y2, int coul_box,int coul_fond,int effet);
void generer_afficher_chiffres(void);
enum etats_boutons { NON_CLIQUE, CLIQUE };
enum effets_cadre { PAS_D_OMBRE, OMBRE };
int main(void)
{
int i1,milieu_y;
// teste pour passer en mode graphique
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
sleep(1);
settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 4);
milieu_y = getmaxy()/2;
// afficher le fond d'ecran
setcolor(COUL_ECRAN);
for (i1 = 0; i1 <= milieu_y; i1++) {
rectangle (1, (milieu_y-3)-i1, getmaxx() ,(milieu_y-3) + i1);
delay(1);
}
// cadre principal
// x1 = 1 y1 = 1 x2 = 639 y2 = 480 coul = LIGHTBLUE relief = 4 clic = 0
bouton_3D(1,1,getmaxx(),getmaxy(),COUL_ECRAN,4,NON_CLIQUE);
generer_afficher_chiffres();
// effacer l'ecran
milieu_y = getmaxy() / 2;
setcolor(BLACK);
for (i1 = 0; i1 <= milieu_y; i1++) {
rectangle (0+i1,i1,getmaxx()-i1,getmaxy()-i1);
delay(2);
}
delay(500);
// fermer le mode graphique
closegraph();
return EXIT_SUCCESS;
} // fin de main
void bouton_3D(int x1, int y1, int x2, int y2, int coul,int relief,int clic){
int i1;
// dessiner le bouton avec un relief
for (i1 = 0; i1 < relief; i1++) {
setcolor(WHITE);
// trait blanc haut
line (x1 + i1, y1 + i1, x2 - i1, y1 + i1);
// trait blanc gauche
line (x1 + i1, y1 + i1, x1 + i1, y2 - i1);
setcolor(DARKGRAY);
// trait gris bas
line (x1 + i1, y2 - i1, x2 - i1, y2 - i1);
// trait gris droit
line (x2 - i1, y1 + i1, x2 - i1, y2 - i1);
}
// simuler le clique
if (clic == CLIQUE) {
setcolor(BLACK);
for (i1 = 1; i1 < 3; i1++) {
rectangle (x1 + i1, y1 + i1, x2 - i1, y2 - i1);
}
setcolor(WHITE);
// cadre blanc exterieur
rectangle (x1 , y1 , x2 , y2 );
} else {
// dessiner le fond du bouton en couleur
setfillstyle(SOLID_FILL,coul);
bar (x1 +i1 , y1 +i1, x2-i1 , y2-i1 );
}
return ;
} // fin de la fonction bouton_3D
void box(int x1, int y1, int x2, int y2, int coul_box,int coul_fond,int effet){
// dessiner l'ombre avec un decalage de 5
if (effet == OMBRE) {
setfillstyle(SOLID_FILL,BLACK);
bar (x1 + 5 , y1 + 5 , x2 + 5 , y2 + 5 );
}
setfillstyle(SOLID_FILL,coul_fond);
bar (x1 , y1 , x2 , y2 );
setcolor(coul_box);
rectangle (x1 , y1 , x2 , y2 );
return ;
} // fin de la fonction box
void generer_afficher_chiffres(void) {
int i1 = 0, i2;
int chiffre,ligne_en_surbrillance;
char texte1[NBRE_COLONNES_MAXI+1];
static char texte_du_titre[50];
static char *noms_des_teles[15] = {
"TF1", "CBS","CANAL+","NET TV","ZDF","ARTE","M6","TV 5",
"ABC","BBC","SKY","RTBF 1","CNN","FUN TV", "NHK TV"
};
time_t heure;
int graphique[3][NBRE_COLONNES_MAXI] = { NULL };
// initialiser le generateur de nombres pseudos-alatoires
srand( (unsigned) time(NULL) );
// x1 =10 y1 = 42 x2 = 76 y2 = 346 coul_cadre = jaune coul_fond = bleu
// effet avec une ombre
// cadre gauche avec les noms des teles
box(10, 42, 76, 346, YELLOW, BLUE, OMBRE);
// cadre avec les chiffres
// x1 =77 y1 = 42 x2 =337 y2 = 346 coul_cadre = jaune coul_fond = noir
box(77, 42, 337, 346, YELLOW, BLACK, OMBRE);
// cadre a droite avec l'histogramme
// x1 =345 y1 = 42 x2 =630 y2 = 346 coul_cadre = vert coul_fond = noir
box(345, 42, 630, 346, LIGHTGREEN, BLACK, PAS_D_OMBRE);
// cadre en bas a gauche : graphique en courbe
// x1 =10 y1 =360 x2 =337 y2 =465 coul_cadre = blanc coul_fond = noir
box(10, 360, 337, 465, WHITE,BLACK, PAS_D_OMBRE);
// cadre en bas a droite : graphique barre horizontale
// x1 =345 y1 =360 x2 =630 y2 =465 coul_cadre = blanc coul_fond = noir
box(345, 360, 630, 465, YELLOW,BLACK, PAS_D_OMBRE);
settextstyle(TRIPLEX_FONT, HORIZ_DIR, 4);
setcolor(LIGHTCYAN);
outtextxy(360,5, "Bourse de PARIS");
setcolor(BLACK);
outtextxy(360,6, "Bourse de PARIS");
// police de caractere
settextstyle(SMALL_FONT, HORIZ_DIR, 5);
while (!kbhit()) { // kbhit 1
while (!kbhit()) { // kbhit 2
if (i1 >= NBRE_LIGNES_MAXI) i1 = 0;
// choisir la ligne a mettre en evidence
ligne_en_surbrillance = (rand() % NBRE_LIGNES_MAXI);
// afficher la date et l'heure
time(&heure);
box(10,10, 337,35,WHITE,MAGENTA,PAS_D_OMBRE);
sprintf(texte_du_titre,"Cotations du %s",ctime(&heure) );
outtextxy(15,15, texte_du_titre);
if (i1 == ligne_en_surbrillance)
setfillstyle(SOLID_FILL,COUL_CURSEUR);
else
setfillstyle(SOLID_FILL,COUL_TEXTES_FOND);
// afficher les noms des teles
bar(11, 45+(i1*20), 75, 63+(i1*20));
outtextxy(20,45 + (i1*20), noms_des_teles[i1]);
for (i2 = 0; i2 < NBRE_COLONNES_MAXI; i2++) {
if (i2 < 8) { // tableau avec les chiffres
chiffre = (rand() %100)+1 ;
if (i1 == ligne_en_surbrillance)
setfillstyle(SOLID_FILL,COUL_CURSEUR);
else
setfillstyle(SOLID_FILL,COUL_CHIFFRES_FOND);
bar(80+(i2*32),45 + (i1*20),110+(i2*32),63 + (i1*20));
sprintf(texte1,"%4d",chiffre);
setcolor(COUL_CHIFFRES);
outtextxy(75 + (i2*32),45 + (i1*20), texte1 );
} // if (i2 < 8)
if (i2 < 15) { // histogramme a droite
setfillstyle(SOLID_FILL,BLACK);
if (i2) { // effacer la barre precedente
bar(350 + ((i2-1) * 20),43,360 + ((i2-1) * 20),340-graphique[1][i2-1]);
} // fin de if(i2)
graphique[0][i2] = (rand() % 290) +5;
// garder les anciennes positions des barres pour effacer
graphique[1][i2] = graphique[0][i2];
setcolor(COUL_CHIFFRES);
if (i2 < 14) { // afficher la barre en 3D
bouton_3D(350 + (i2*20),340-graphique[0][i2],360 + (i2*20),340,COUL_BARRE,3,0);
} // fin de if (i2 < 14)
} // if (i2 < 15)
if (i2 < 15) { // graphique en courbe bas
graphique[2][i2] = (rand() % 99) + 1;
// effacer la courbe precedente
box(20 + (i2 * 20),361, 40 + (i2 * 20),460,BLACK,BLACK,PAS_D_OMBRE);
setcolor(COUL_COURBE);
if (i2 > 0) { // graphique en courbe : bas gauche
line (20 + (i2 * 20),460-graphique[2][i2-1], 40 + (i2 * 20),460-graphique[2][i2]);
} // fin de if (i2 > 0)
// le graphique en barre horizontale : bas droite
graphique[3][i2] = (rand() % 274) + 1;
// effacer la barre horizontale precedente
box(350, 365+(i2*6.5), 625 , 369+(i2*6.5), BLACK,BLACK, PAS_D_OMBRE);
// dessiner la barre horizontale
box(350, 365+(i2*6.5), 350 +graphique[3][i2], 369+(i2*6.5), LIGHTGREEN,BLACK, PAS_D_OMBRE);
} // fin de if (i2 < 15)
delay(1);
} // fin de for (i2 = 0..)
i1++;
} // fin de while (!kbhit()) kbhit 2
};// fin de while (!kbhit()) kbhit 1
return ;
} // fin de la fonction generer_afficher_chiffres
Conclusion
/* PROGRAMME EN C SOUS DOS TURBO C++2 BORLAND ecrit le 01-02-2003 par cmarsc ECRAN DE COTATIONS BOURSIERES : MODE GRAPHIQUE */
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE?COMMENT MAPPER UNE VUE SQL SUR UNE COLLECTION DE COMPLEX TYPE? par Matthieu MEZIL
Avec EF, les vues doivent être mappées sur des entity types. Le problème c'est que les entity types doivent avoir une clé. Avec EF, nous avons les complex type qui n'ont pas de clé mais les vues ne peuvent pas être mappées dessus. Avec EF4, il est possibl...
Cliquez pour lire la suite de l'article par Matthieu MEZIL [WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL?[WF4] UN BINDING ACTIVITY/ACTIVITYDESIGNER QUI PASSE MAL? par JeremyJeanson
Certain d'entre vous on peut être vécu cette situation embarrassante après quelques temps passer avec WF4 : Au début avec mon " ActivityDesigner" , tout allait bien. Et puis un jour j'ai au des problèmes de " Binding" . Alors nous sommes allé sur le site ...
Cliquez pour lire la suite de l'article par JeremyJeanson MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ?MYTIC - SHAREPOINT 2010 : DéJà UN MYTHE MICROSOFT ? par junarnoalg
La prochaine session de MyTIC aura lieu à Namur, le 23 mars prochain. Pendant presque une heure, nous parlerons de SharePoint 2010. Voici un aperçu du programme.
Accueil : 17h30 Début de la session : 18h00 - Les nouvelles int...
Cliquez pour lire la suite de l'article par junarnoalg
Forum
ERREUR DE POINTEURERREUR DE POINTEUR par africanwinners
Cliquez pour lire la suite par africanwinners CLISTCTRLCLISTCTRL par dorras7
Cliquez pour lire la suite par dorras7
Logiciels
Academy System (10.9.4.0)ACADEMY SYSTEM (10.9.4.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods
|