Ce programme explique comment récupérer la taille des boîtes de textes avant de les afficher.
void print_cote(
int O,
int N,
int width,
int height,
MLV_Color color ){
int espace = 3;
int sizeLine = 10;
int S = N + height -1;
int E = O + width - 1;
}
int main( int argc, char *argv[] ){
int width = 640, height = 480;
"advanced - 1 - texts and boxes", "texts and boxes", width, height );
const char* text = "Voici une boite de texte, centré par rapport à la fenetre.";
int width_text, height_text;
int positionX = (width-width_text)/2, positionY = 100;
print_cote( positionX, positionY, width_text, height_text,
MLV_COLOR_GREEN );
const char *text_box = "Voici une boîte de texte.\nCette Boîte de texte est elle aussi centré horizontalement dans la fenetre.";
int width_box = 0 , height_box = 0, size_interligne = 9;
text_box,
size_interligne,
&width_box, &height_box
);
int positionBoxX = (width-width_box)/2, positionBoxY = 300;
positionBoxX, positionBoxY,
text_box,
size_interligne,
);
print_cote(
);
return 0;
}
Fichier d'entête principal incluant tous les autres fichiers entêtes de la bibliothèque MLV.
#define MLV_COLOR_GREEN
Definition: MLV_color.h:931
#define MLV_COLOR_BLACK
Definition: MLV_color.h:379
Uint32 MLV_Color
Définit un type couleur pour la bibliothèque MLV.
Definition: MLV_color.h:54
#define MLV_COLOR_RED
Definition: MLV_color.h:1297
void MLV_draw_line(int x1, int y1, int x2, int y2, MLV_Color color)
Dessine une ligne.
void MLV_get_size_of_text(const char *text, int *width, int *height,...)
Cette fonction calcule la taille du texte qui sera affiché sur l'écran à l'aide de la fonction MLV_dr...
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_TEXT_CENTER
Definition: MLV_text.h:45
int MLV_get_size_of_adapted_text_box(const char *message, int sizeInterligne, int *result_width, int *result_height,...)
Cette fonction calcule la taille de la boîte de texte qui serait obtenue si vous utilisez la fonction...
void MLV_draw_adapted_text_box(int x, int y, const char *message, int sizeInterligne, MLV_Color borderColor, MLV_Color textColor, MLV_Color backgroundColor, MLV_Text_justification text_justification,...)
Dessine une boîte contenant du texte.
void MLV_wait_seconds(int seconds)
Le programme s'intérompt pendant un nombre de secondes.
void MLV_free_window()
Ferme la fenêtre de la bibliothèque MLV.
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.
void MLV_update_window()
Met à jour l'affichage de la fenêtre.