/* Grafx2 - The Ultimate 256-color bitmap paint program Copyright 2008 Yves Rizoud Copyright 2008 Franck Charlet Copyright 2007 Adrien Destugues Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Grafx2 is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. Grafx2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Grafx2; if not, see or write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include "const.h" #include "struct.h" #include "global.h" #include "divers.h" #include "graph.h" #include "moteur.h" #include "tables_aide.h" #include "aide.h" #include #ifdef __linux__ #ifdef __macosx__ #include #include #else #include #endif #else #ifndef __amigaos4__ #include #endif #endif // -- Menu d'aide ----------------------------------------------------------- void Afficher_aide(void) { short X; // Indices d'affichage d'un caractère short Y; short Position_X; // Parcours de remplissage du buffer de ligne short Indice_de_ligne; // 0-15 (16 lignes de textes) short Indice_de_caractere; // Parcours des caractères d'une ligne short Ligne_de_depart=Position_d_aide_en_cours; short Repeat_Menu_Facteur_X; short Repeat_Menu_Facteur_Y; short Pos_Reel_X; short Pos_Reel_Y; int Curseur; short Largeur; // Largeur physique d'une ligne de texte char TypeLigne; // N: Normale, T: Titre, S: Sous-titre // -: Ligne inférieur de sous-titre const unsigned char * Ligne; Pos_Reel_X=Fenetre_Pos_X+(13*Menu_Facteur_X); Pos_Reel_Y=Fenetre_Pos_Y+(19*Menu_Facteur_Y); for (Indice_de_ligne=0;Indice_de_ligne<16;Indice_de_ligne++) { // Raccourci au cas ou la section fait moins de 16 lignes if (Indice_de_ligne >= Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes) { Block (Pos_Reel_X, Pos_Reel_Y, 44*6*Menu_Facteur_X, // 44 = Nb max de char (+1 pour éviter les plantages en mode X // causés par une largeur = 0) (Menu_Facteur_Y<<3) * (16 - Indice_de_ligne), CM_Noir); break; } // On affiche la ligne Ligne = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne]; TypeLigne = Ligne[0]; // Si c'est une sous-ligne de titre, on utilise le texte de la ligne précédente if (TypeLigne == '-' && (Ligne_de_depart + Indice_de_ligne > 0)) Ligne = Table_d_aide[Section_d_aide_en_cours].Table_aide[Ligne_de_depart + Indice_de_ligne - 1]; // On ignore le premier caractère Ligne++; // Calcul de la taille Largeur=strlen(Ligne); // Les lignes de titres prennent plus de place if (TypeLigne == 'T' || TypeLigne == '-') Largeur = Largeur*2; // Pour chaque ligne dans la fenêtre: for (Y=0;Y<8;Y++) { Position_X=0; // On crée une nouvelle ligne à splotcher for (Indice_de_caractere=0;Indice_de_caractere 315) Curseur = 1; // '!' affiché pour les caractères non prévus for (X=0;X<6;X++) for (Repeat_Menu_Facteur_X=0;Repeat_Menu_Facteur_XPosition=Position_d_aide_en_cours; Calculer_hauteur_curseur_jauge(Fenetre_Liste_boutons_scroller); Fenetre_Dessiner_jauge(Fenetre_Liste_boutons_scroller); Afficher_aide(); Afficher_curseur(); } void Bouton_Aide(void) { short Numero_bouton; // Aide contextuelle if (Touche!=0) { Numero_bouton = Numero_bouton_sous_souris(); if (Numero_bouton != -1) { Fenetre_aide(Numero_bouton, NULL); return; } } Fenetre_aide(-1, NULL); } // Ouvre l'ecran d'aide. Passer -1 pour la section par défaut (ou derniere,) // Ou un nombre de l'enumération NUMEROS_DE_BOUTONS pour l'aide contextuelle. void Fenetre_aide(int Section, const char *Sous_section) { short Bouton_clicke; short Nb_lignes; if (Section!=-1) { Section_d_aide_en_cours = 4 + Section; Position_d_aide_en_cours = 0; } Nb_lignes=Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes; if (Section!=-1 && Sous_section!=NULL) { int Indice=0; for (Indice=0; Indice2) { Section_d_aide_en_cours=Bouton_clicke-3; Position_d_aide_en_cours=0; Nb_lignes=Table_d_aide[Section_d_aide_en_cours].Nombre_de_lignes; Fenetre_Liste_boutons_scroller->Position=0; Fenetre_Liste_boutons_scroller->Nb_elements=Nb_lignes; Calculer_hauteur_curseur_jauge(Fenetre_Liste_boutons_scroller); Fenetre_Dessiner_jauge(Fenetre_Liste_boutons_scroller); } else Position_d_aide_en_cours=Fenetre_Attribut2; Afficher_aide(); Afficher_curseur(); } // Gestion des touches de déplacement dans la liste switch (Touche) { case SDLK_UP : // Haut if (Position_d_aide_en_cours>0) Position_d_aide_en_cours--; Scroller_aide(); break; case SDLK_DOWN : // Bas if (Position_d_aide_en_cours15) Position_d_aide_en_cours-=15; else Position_d_aide_en_cours=0; Scroller_aide(); break; case SDLK_PAGEDOWN : // PageDown if (Position_d_aide_en_cours (100ULL*1024*1024*1024)) sprintf(Buffer,"%d Gigabytes",(unsigned int)(freeRam/(1024*1024*1024))); else if(freeRam > (100*1024*1024)) sprintf(Buffer,"%d Megabytes",(unsigned int)(freeRam/(1024*1024))); else if(freeRam > 100*1024) sprintf(Buffer,"%d Kilobytes",(unsigned int)(freeRam/1024)); else sprintf(Buffer,"%d bytes",(unsigned int)freeRam); Print_dans_fenetre(114,35,Buffer,STATS_COULEUR_DONNEES,CM_Noir); // Affichage de l'espace disque libre sprintf(Buffer,"Free space on %c:",Principal_Repertoire_courant[0]); Print_dans_fenetre(10,51,Buffer,STATS_COULEUR_TITRES,CM_Noir); #ifdef __linux__ statfs(Principal_Repertoire_courant,&Informations_Disque); Taille=Informations_Disque.f_bfree * Informations_Disque.f_bsize; #else #ifdef __amigaos4__ #else GetDiskFreeSpaceEx(Principal_Repertoire_courant,&tailleU,NULL,NULL); Taille = tailleU.QuadPart; #endif #endif if(Taille > (100ULL*1024*1024*1024)) sprintf(Buffer,"%d Gigabytes",(unsigned int)(Taille/(1024*1024*1024))); else if(Taille > (100*1024*1024)) sprintf(Buffer,"%d Megabytes",(unsigned int)(Taille/(1024*1024))); else if(Taille > (100*1024)) sprintf(Buffer,"%d Kilobytes",(unsigned int)(Taille/1024)); else sprintf(Buffer,"%d bytes",(unsigned int)Taille); Print_dans_fenetre(146,51,Buffer,STATS_COULEUR_DONNEES,CM_Noir); // Affichage des informations sur l'image Print_dans_fenetre(10,67,"Picture info.:",STATS_COULEUR_TITRES,CM_Noir); // Affichage des dimensions de l'image Print_dans_fenetre(18,75,"Dimensions :",STATS_COULEUR_TITRES,CM_Noir); sprintf(Buffer,"%dx%d",Principal_Largeur_image,Principal_Hauteur_image); Print_dans_fenetre(122,75,Buffer,STATS_COULEUR_DONNEES,CM_Noir); // Affichage du nombre de couleur utilisé Print_dans_fenetre(18,83,"Colors used:",STATS_COULEUR_TITRES,CM_Noir); bzero(Utilisation_couleur,256*sizeof(Utilisation_couleur[0])); sprintf(Buffer,"%d",Palette_Compter_nb_couleurs_utilisees(Utilisation_couleur)); Print_dans_fenetre(122,83,Buffer,STATS_COULEUR_DONNEES,CM_Noir); // Affichage des dimensions de l'écran Print_dans_fenetre(10,99,"Resolution:",STATS_COULEUR_TITRES,CM_Noir); sprintf(Buffer,"%dx%d",Largeur_ecran,Hauteur_ecran); Print_dans_fenetre(106,99,Buffer,STATS_COULEUR_DONNEES,CM_Noir); UpdateRect(Fenetre_Pos_X,Fenetre_Pos_Y,Menu_Facteur_X*310,Menu_Facteur_Y*174); Afficher_curseur(); do { Bouton_clicke=Fenetre_Bouton_clicke(); } while ( (Bouton_clicke!=1) && (Touche!=SDLK_RETURN) ); Fermer_fenetre(); Desenclencher_bouton(BOUTON_AIDE); Afficher_curseur(); }