Conversion de ressources
Exemple : comment spécifier une couleur par son nom (lightgray) dans un programme ?
- XmNbackground demande une valeur de pixel (Pixel).
- Il faut convertir la chaîne de caractères lightgray en un Pixel.
XtVaSetValues(w, XmNbackground, NumCoul("red"),NULL);
Voici une procédure NumCoul de conversion :
Pixel NumCoul(String nom)
Display *dpy = XtDisplay(racine);
Colormap cmap = DefaultColormapOfScreen(XtScreen(racine));
if (!XAllocNamedColor(dpy, cmap, nom, &col, &x)) {
sprintf(tamp, "Peux pas allouer le %s", nom);