Documentation de la bibliothèque MLV-3.1.0

medium/09_keyboard_accents.c

Ce programme montre comment il est possible de récupéré les caractères accentués provenant d'une entree clavier.

#include <MLV/MLV_all.h>
#include <stdlib.h>
//
// Attention !
// Pour pouvoir compiler ce programme sous windows et sous macintosh,
// il faut, pour la déclaration du main, respecter strictement la syntaxe
// suivante :
//
int main(int argc, char *argv[]){
//
// Déclaration de la variable qui représentera le code de la touche qui
// sera appuyée par l'utilisateur.
//
int unicode;
MLV_Keyboard_button touche = MLV_KEYBOARD_NONE;
char* text;
int width, height;
width = 640;
height = 480;
//
// Créé et affiche la fenêtre
//
"medium - 9 - keyboard accents", "keyboard accents", width, height
);
//
// Affiche la consigne
//
10, 10,
"Vous pouvez faire apparaitre les caractères accentué !",
);
//
// Attendre que l'utilisateur appuie sur une touche du clavier
//
while( touche != MLV_KEYBOARD_ESCAPE ){
MLV_wait_keyboard( &touche, NULL, &unicode );
// On efface l'écran
MLV_draw_filled_rectangle( 0, 50, width, height, MLV_COLOR_BLACK );
// On impime le caractère avec les accents
text = MLV_convert_unicode_to_string( unicode );
MLV_draw_text( 10, 100, text, MLV_COLOR_GREEN );
free( text );
}
//
// Attend 2 seconde avant la fin du programme.
//
//
// Ferme la fenêtre
//
return 0;
}
/*
* This file is part of the MLV Library.
*
* Copyright (C) 2010,2011,2012,2013 Adrien Boussicault, Marc Zipstein
*
*
* This Library 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, either version 3 of the License, or
* (at your option) any later version.
*
* This Library 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 this Library. If not, see <http://www.gnu.org/licenses/>.
*/
MLV_create_window
void MLV_create_window(const char *window_name, const char *icone_name, unsigned int width, unsigned int height)
Créé une fenêtre dont la taille, et les différents noms sont passés en paramètres.
MLV_Keyboard_button
MLV_Keyboard_button
Énumère l'ensemble des codes des touches du clavier.
Definition: MLV_keyboard.h:50
MLV_free_window
void MLV_free_window()
Ferme la fenêtre de la bibliothèque MLV.
MLV_update_window
void MLV_update_window()
Met à jour l'affichage de la fenêtre.
MLV_wait_seconds
void MLV_wait_seconds(int seconds)
Le programme s'intérompt pendant un nombre de secondes.
MLV_draw_filled_rectangle
void MLV_draw_filled_rectangle(int x, int y, int width, int height, MLV_Color color)
Dessine un rectangle plein dont la taille, la couleur et la position du sommet Nord-Ouest sont donnée...
MLV_draw_text
void MLV_draw_text(int x, int y, const char *text, MLV_Color color,...)
Imprime un texte donné à une position et une couleur données.
MLV_COLOR_GREEN
#define MLV_COLOR_GREEN
Definition: MLV_color.h:931
MLV_all.h
Fichier d'entête principal incluant tous les autres fichiers entêtes de la bibliothèque MLV.
MLV_convert_unicode_to_string
char * MLV_convert_unicode_to_string(int unicode)
Transforme un caractère en format unicode en chaîne de caractères compatible avec le codage local (co...
MLV_COLOR_BLACK
#define MLV_COLOR_BLACK
Definition: MLV_color.h:379
MLV_wait_keyboard
void MLV_wait_keyboard(MLV_Keyboard_button *sym, MLV_Keyboard_modifier *mod, int *unicode)
Suspend l'exécution jusqu'à ce que l'utilisateur appuie sur une touche du clavier.