From 54ca84e09477d60c745b493ad034ce8166ff1f44 Mon Sep 17 00:00:00 2001 From: Yves Rizoud Date: Mon, 17 Nov 2008 23:44:19 +0000 Subject: [PATCH] Text: Implemented Bold and Italic, redid the screen layout. GUI: Generalized the system that right-clicking an input area empties it while entering edit mode, since it was indeed a very good idea, it saves a lot of time once you do it intuitively. (Esc still cancels and restores) Added a bitmap font, GrafX2_Classic.gif. Helpful for prototyping GUI screens. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@353 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- boutons.c | 96 +++++++++++++++++++++------------------ fonts/GrafX2_Classic.gif | Bin 0 -> 1716 bytes readline.c | 6 ++- texte.c | 26 +++++++---- texte.h | 2 +- 5 files changed, 73 insertions(+), 57 deletions(-) create mode 100644 fonts/GrafX2_Classic.gif diff --git a/boutons.c b/boutons.c index 45ff4c03..8607ba23 100644 --- a/boutons.c +++ b/boutons.c @@ -2720,12 +2720,6 @@ byte Bouton_Load_ou_Save(byte Load, byte Image) // Save the filename strcpy(Nom_fichier_Save, Principal_Nom_fichier); - // Erase the content when the right mouse button is used. - - if (Mouse_K==2) - { - Principal_Nom_fichier[0] = '\0'; - } if (Readline(13+9*8,90,Principal_Nom_fichier,27,2)) { // On regarde s'il faut rajouter une extension. C'est-à-dire s'il @@ -5818,6 +5812,8 @@ void Bouton_Texte() static int AntiAlias=1; static short Debut_liste=0; // Indice de le premiere fonte dans le selector static short Position_curseur=0; // Indice de la ligne active dans le selector + static short Style_Bold=0; + static short Style_Italic=0; byte * Nouvelle_Brosse=NULL; int Nouvelle_Largeur; @@ -5836,40 +5832,43 @@ void Bouton_Texte() Ouvrir_fenetre(288,180,"Text"); // Texte saisi - Print_dans_fenetre(6,19,"Txt:",CM_Fonce,CM_Clair); - Fenetre_Definir_bouton_saisie(41,18,30); // 1 + Print_dans_fenetre(6,20,"Text:",CM_Fonce,CM_Clair); + Fenetre_Definir_bouton_saisie(48,18,29); // 1 Bouton_texte=Fenetre_Liste_boutons_special; - // Bouton 'Clear Text' - Fenetre_Definir_bouton_normal(9,33,80,14,"Clear Txt",0,1,SDLK_LAST); // 2 - + // TrueType options + Fenetre_Afficher_cadre_creux(182,34,100,68); + Print_dans_fenetre(199,31,"TrueType", CM_Fonce, CM_Clair); // AA - Fenetre_Definir_bouton_normal(9,51,80,14,"",0,1,SDLK_LAST); // 3 - Print_dans_fenetre(13,54,AntiAlias?" No AA ":"AntiAlias", CM_Noir, CM_Clair); + Fenetre_Definir_bouton_normal(188,58,13,11,AntiAlias?"X":" ",0,1,SDLK_a); // 2 + Print_dans_fenetre(206,60,"AntiAlias", CM_Fonce, CM_Clair); + // Bold + Fenetre_Definir_bouton_normal(188,72,13,11,Style_Bold?"X":" ",0,1,SDLK_b); // 3 + Print_dans_fenetre(206,75,"Bold", CM_Fonce, CM_Clair); + // Italic + Fenetre_Definir_bouton_normal(188,86,13,11,Style_Italic?"X":" ",0,1,SDLK_i); // 4 + Print_dans_fenetre(206,89,"Italic", CM_Fonce, CM_Clair); // Scroller des fontes - Fenetre_Definir_bouton_scroller(94,33,NB_FONTES*8,Fonte_nombre,NB_FONTES,Debut_liste); // 4 + Fenetre_Definir_bouton_scroller(165,35,NB_FONTES*8,Fonte_nombre,NB_FONTES,Debut_liste); // 5 Scroller_de_fontes=Fenetre_Liste_boutons_scroller; // Liste des fontes disponibles - Fenetre_Definir_bouton_special(111,32,168,NB_FONTES*8); // 5 - Fenetre_Afficher_cadre_creux(110, 31, 170, NB_FONTES*8+4); + Fenetre_Definir_bouton_special(8,34,152,NB_FONTES*8); // 6 + Fenetre_Afficher_cadre_creux(7, 33, 154, NB_FONTES*8+4); // Taille texte - Print_dans_fenetre(32,71,"Size:",CM_Fonce,CM_Clair); - Fenetre_Definir_bouton_saisie(35,84,3); // 6 + Fenetre_Definir_bouton_saisie(220,43,3); // 7 Bouton_taille_texte=Fenetre_Liste_boutons_special; - Fenetre_Definir_bouton_normal(18,84,14,11,"-",0,1,SDLK_LAST); // 7 - Fenetre_Definir_bouton_normal(64,84,14,11,"+",0,1,SDLK_LAST); // 8 + Fenetre_Definir_bouton_normal(202,43,13,11,"-",0,1,SDLK_LAST); // 8 + Fenetre_Definir_bouton_normal(251,43,13,11,"+",0,1,SDLK_LAST); // 9 // Preview - Fenetre_Definir_bouton_special(7,105,276,50); // 9 + Fenetre_Definir_bouton_special(8,106,273,50); // 10 Bouton_preview=Fenetre_Liste_boutons_special; - Fenetre_Afficher_cadre_creux(6, 104, 278, 52); + Fenetre_Afficher_cadre_creux(7, 105, 275, 52); - Fenetre_Definir_bouton_special(0,0,1,1); // 10 ??? - - Fenetre_Definir_bouton_normal(7,161,40,14,"OK",0,1,SDLK_RETURN); // 11 - Fenetre_Definir_bouton_normal(53,161,60,14,"Cancel",0,1,SDLK_ESCAPE); // 12 + Fenetre_Definir_bouton_normal(8,160,40,14,"OK",0,1,SDLK_RETURN); // 11 + Fenetre_Definir_bouton_normal(54,160,60,14,"Cancel",0,1,SDLK_ESCAPE); // 12 Display_Window(288,180); // Chaine texte @@ -5886,7 +5885,7 @@ void Bouton_Texte() Num2str(Taille_police,Buffer_taille,3); Fenetre_Contenu_bouton_saisie(Bouton_taille_texte,Buffer_taille); // Selecteur de fonte - Dessiner_selecteur_fontes(111, 33, Debut_liste, Position_curseur, NB_FONTES); + Dessiner_selecteur_fontes(8, 35, Debut_liste, Position_curseur, NB_FONTES); } if (A_previsionner) { @@ -5903,7 +5902,7 @@ void Bouton_Texte() Bouton_preview->Largeur*Menu_Facteur_X, Bouton_preview->Hauteur*Menu_Facteur_Y, CM_Clair); - Nouvelle_Brosse = Rendu_Texte(Chaine_preview, Position_curseur+Debut_liste, Taille_police, AntiAlias, &Nouvelle_Largeur, &Nouvelle_Hauteur); + Nouvelle_Brosse = Rendu_Texte(Chaine_preview, Position_curseur+Debut_liste, Taille_police, AntiAlias, Style_Bold, Style_Italic, &Nouvelle_Largeur, &Nouvelle_Hauteur); if (Nouvelle_Brosse) { Affiche_brosse_SDL( @@ -6048,25 +6047,32 @@ void Bouton_Texte() { case 1: // Texte saisi Effacer_curseur(); - Readline_ex(43,20,Chaine,30,250,0); + Readline_ex(50,20,Chaine,29,250,0); A_previsionner=1; break; - - case 2: // Clear - Chaine[0]='\0'; - Effacer_curseur(); - Fenetre_Effacer_bouton_saisie(Bouton_texte); - A_previsionner=1; - break; - - case 3: // AA + + case 2: // AA AntiAlias = (AntiAlias==0); Effacer_curseur(); - Print_dans_fenetre(13,54,AntiAlias?" No AA ":"AntiAlias", CM_Noir, CM_Clair); + Print_dans_fenetre(191,60,AntiAlias?"X":" ", CM_Noir, CM_Clair); + A_previsionner=1; + break; + + case 3: // Bold + Style_Bold = (Style_Bold==0); + Effacer_curseur(); + Print_dans_fenetre(191,74,Style_Bold?"X":" ", CM_Noir, CM_Clair); + A_previsionner=1; + break; + + case 4: // Italic + Style_Italic = (Style_Italic==0); + Effacer_curseur(); + Print_dans_fenetre(191,88,Style_Italic?"X":" ", CM_Noir, CM_Clair); A_previsionner=1; break; - case 4: // Scroller des fontes + case 5: // Scroller des fontes if (Debut_liste!=Fenetre_Attribut2) { Position_curseur+=Debut_liste; @@ -6078,7 +6084,7 @@ void Bouton_Texte() } break; - case 5: // Selecteur de fonte + case 6: // Selecteur de fonte Temp=(((Mouse_Y-Fenetre_Pos_Y)/Menu_Facteur_Y)-32)>>3; if (Temp!=Position_curseur && Temp < Fonte_nombre) { @@ -6090,9 +6096,9 @@ void Bouton_Texte() } break; - case 6: // Taille du texte (nombre) + case 7: // Taille du texte (nombre) Effacer_curseur(); - Readline(37,86,Buffer_taille,3,1); + Readline(222,45,Buffer_taille,3,1); Taille_police=atoi(Buffer_taille); // On corrige les dimensions if (Taille_police < 1) @@ -6107,7 +6113,7 @@ void Bouton_Texte() A_previsionner=1; break; - case 7: // Taille - + case 8: // Taille - if (Taille_police > 1) { Taille_police--; @@ -6117,7 +6123,7 @@ void Bouton_Texte() } break; - case 8: // Taille + + case 9: // Taille + if (Taille_police < 255) { Taille_police++; diff --git a/fonts/GrafX2_Classic.gif b/fonts/GrafX2_Classic.gif new file mode 100644 index 0000000000000000000000000000000000000000..8ecfa8d770700657d178307a61a40c909a2ae3ec GIT binary patch literal 1716 zcmd5*TToM16x}|?XVi?vBK0~3ihv~wwG0nUHMS}~;sXgPB{F~!BgBXrh2Q}Zqb8E# zqk({gx55PjC@KWJDC!_VQXCO5%0(VkjF5sTg2)vc>~H<=Ix~CkkG0mB*=HTkwX5CT z0ymDE3@Z2+IN$&{K3dF;J34YlL75MiqDIS?W**HjnM@=}>h*epAT%0{TCG+n6bK=q zP{`x)I2;a(#bPp<7>3bkGz!23KmzCi2mlR$8bASn0E7TM01f~PfC+#B&;Te3OeP>n z(CdL9K%)V*8WajZ2!ul5@qoht77Lh6z%ZbV3jSXgP(Yc$L;|S?JpqIUG-^;QK!E@W zLC6Ch2RJNXF@cEzMuRW=q0>nQL+|WNu-WFlC-M0*u{c616)2Tl9ABx`y6AMa27`ss zIJzAQ=q5UYWH{@c*#w)5bNNYpu}mzDkSYaAoQrE$YIQC;gRQ}6VH{-xMW>q>4AR+I z&t?-`F3#sCiN!LhG(xEqnBQ5eU8&Q#7!0;Xqs13{vj(GpMFEcjM1h(Df&$WP)do~0 zP#HkQ02Kff8z{yX|F6)$s=)r!{cCh0qyLK1cv04tgc=lK`WSwtc>8q$2j{VqHoGWR zIv{r}j7bl`V6z3V&3Qn`0U>^vgRbL!S=I3jOA$8Y#b0~M z-a1D)d*-h72~NHj6v_K@HmKYJJC*Wlxf|12N2g3%cinDt_OIu@eW~@%^Um?iv`Z*g z+HT0-RNz|mz$cVjf`Ck_4I`;CE?wj?*~h=T5rdU zD{TyQ>)CPh#4DSeX3O57yHS>&t4-RgZKo4|>`l;=^zE!tTK_bnR~_6_k9%%&r4AQ& z$P3qZ&sz8~%=lQo;+5-MzkzN;g(Bida1zJaO&03<)6xXpSLWm#-a~Ro8TYy zWK8Ze$v}J6+!)%kQvuRkA3?ixcGqBA?AVXtZL!4*95PRKNY(@%KRdZ8Q2w;Q$cSpX zF*`f%UE`$e-`xkQTjS;w>(WH>vRT`tkGvcLf>)&_WyeYmX?anNf9uj^cFW41CahZG zLGBybB?wa47JqnoDk!$hKRVs3bAGaLi$_Ls@PyJt3C%__|5*E@?XULcjPZTS_jOIS z+cS9R{!V3lRK%Rf8=vy54@Bi`WvE4kYq2xCR(tGDuJ^G_O-*_3Fh4V@L-iuXx~Jws zMxms9PNvVI&%foLixo`_Io5Y#0hT^I-=Vwcg#YQ+ndv>2A(F%cxJhSD{>$$w+%EOsf+1VRPJeuLF3hdVE~3XV@VF$=sy;__6ooFk%QqGQ6vLv72b=DSw*wB97T zU$Y>kq34INs_sZXwQexqO;qOc`HAT2>m`P+Wbs>d@6B~}gWpGD4_MX#o=uKDI%*_z zzue_8ixIO$MZ2Ex*Pl~WsAf9qZ>(Li<6v!HQ1@c>)+3YJFCSb-GRpDuOtHcB$lOkR zTHMclE#qsG6$dH{qbqhcj@&1^YUyKBOK>-vviCgs+o|tJgAZw?jXCM+`0#9@!ntF4 zI=;KUuBNQ7BzK>Fu!b96w^+BLK2=hBZav}AxoH{U+VLpsv{Qw1$i}WBA~Jq=_aD8{ zf;;DJDwaIbWQsEC_`_2inNaiU!wc2Eks)Jl(a8C++eU_myh1B( Mz3V+Qj}EZ(AM!gc!vFvP literal 0 HcmV?d00001 diff --git a/readline.c b/readline.c index 1566891c..0e961041 100644 --- a/readline.c +++ b/readline.c @@ -153,9 +153,11 @@ byte Readline_ex(word Pos_X,word Pos_Y,char * Chaine,byte Taille_affichee,byte T // Mise à jour des variables se rapportant à la chaîne en fonction de la chaîne initiale strcpy(Chaine_initiale,Chaine); - if (Type_saisie==1) + // Si on a commencé à editer par un clic-droit, on vide la chaine. + if (Mouse_K==A_DROITE) + Chaine[0]='\0'; + else if (Type_saisie==1) snprintf(Chaine,10,"%d",atoi(Chaine)); // On tasse la chaine à gauche - // Chaine[0]='\0'; // On efface la chaîne si c'est valeur numérique Taille=strlen(Chaine); diff --git a/texte.c b/texte.c index aa434065..c400c174 100644 --- a/texte.c +++ b/texte.c @@ -155,15 +155,15 @@ void Ajout_fonte(const char *Nom) Fonte->Nom = (char *)malloc(Taille); strcpy(Fonte->Nom, Nom); // Libelle - strcpy(Fonte->Libelle, " "); + strcpy(Fonte->Libelle, " "); if (Fonte->EstTrueType) - Fonte->Libelle[19]=Fonte->Libelle[20]='T'; // Logo TT + Fonte->Libelle[17]=Fonte->Libelle[18]='T'; // Logo TT Nom_fonte=Position_dernier_slash(Fonte->Nom); if (Nom_fonte==NULL) Nom_fonte=Fonte->Nom; else Nom_fonte++; - for (Indice=0; Indice < 19 && Nom_fonte[Indice]!='\0' && Nom_fonte[Indice]!='.'; Indice++) + for (Indice=0; Indice < 17 && Nom_fonte[Indice]!='\0' && Nom_fonte[Indice]!='.'; Indice++) Fonte->Libelle[Indice]=Nom_fonte[Indice]; // Gestion Liste @@ -228,13 +228,13 @@ char * Nom_fonte(int Indice) // Trouve le libellé d'affichage d'une fonte par son numéro -// Renvoie un pointeur sur un buffer statique de 22 caracteres. +// Renvoie un pointeur sur un buffer statique de 20 caracteres. char * Libelle_fonte(int Indice) { T_FONTE *Fonte; - static char Libelle[22]; + static char Libelle[20]; - strcpy(Libelle, " "); + strcpy(Libelle, " "); // Recherche de la fonte Fonte = Liste_fontes_debut; @@ -352,13 +352,14 @@ int Support_TrueType() #ifndef NOTTF -byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int Taille, int AntiAlias, int *Largeur, int *Hauteur) +byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int Taille, int AntiAlias, int Bold, int Italic, int *Largeur, int *Hauteur) { TTF_Font *Fonte; SDL_Surface * TexteColore; SDL_Surface * Texte8Bit; byte * BrosseRetour; int Indice; + int Style; SDL_Color Couleur_Avant; SDL_Color Couleur_Arriere; @@ -369,6 +370,13 @@ byte *Rendu_Texte_TTF(const char *Chaine, int Numero_fonte, int Taille, int Anti { return NULL; } + // Style + Style=0; + if (Italic) + Style|=TTF_STYLE_ITALIC; + if (Bold) + Style|=TTF_STYLE_BOLD; + TTF_SetFontStyle(Fonte, Style); // Couleurs if (AntiAlias) { @@ -477,7 +485,7 @@ byte *Rendu_Texte_SFont(const char *Chaine, int Numero_fonte, int *Largeur, int // Crée une brosse à partir des paramètres de texte demandés. // Si cela réussit, la fonction place les dimensions dans Largeur et Hauteur, // et retourne l'adresse du bloc d'octets. -byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int Taille, int AntiAlias, int *Largeur, int *Hauteur) +byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int Taille, int AntiAlias, int Bold, int Italic, int *Largeur, int *Hauteur) { T_FONTE *Fonte = Liste_fontes_debut; int Indice=Numero_fonte; @@ -491,7 +499,7 @@ byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int Taille, int AntiAlia if (Fonte->EstTrueType) { #ifndef NOTTF - return Rendu_Texte_TTF(Chaine, Numero_fonte, Taille, AntiAlias, Largeur, Hauteur); + return Rendu_Texte_TTF(Chaine, Numero_fonte, Taille, AntiAlias, Bold, Italic, Largeur, Hauteur); #else return NULL; #endif diff --git a/texte.h b/texte.h index 6561982a..024c0307 100644 --- a/texte.h +++ b/texte.h @@ -27,7 +27,7 @@ int Support_TrueType(void); // Ajout d'une fonte à la liste. void Ajout_fonte(char *Nom); // Crée une brosse à partir des paramètres de texte demandés. -byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int Taille, int AntiAlias, int *Largeur, int *Hauteur); +byte *Rendu_Texte(const char *Chaine, int Numero_fonte, int Taille, int AntiAlias, int Bold, int Italic, int *Largeur, int *Hauteur); // Trouve le libellé d'affichage d'une fonte par son numéro char * Libelle_fonte(int Indice); // Trouve le nom d'une fonte par son numéro