Trusted Solaris Developer's Guide

Translate Label with Font List

This example gets the process sensitivity label and translates it to text using a font list and pixel width. A label widget is created with the string for its label. The process sensitivity label equals the window sensitivity label so no privileges are required.

When the final string is longer than the width, it is clipped and the clipped indicator is used. The clipped indicator for a clipped sensitivity label is described in "Sensitivity and Information Labels" and on the sbsltos(3TSOL) man page. Note that the X Window System label translation interfaces clip to the number of pixels specified, and the label clipping interfaces clip to the number of characters.

If your site uses a label_encodings file in a language other than English, the translation might not work on accent characters in the ISO standard above 128, and will not work on the Asian character set.

	retval = getcmwplabel(&cmwlabel);
	getcsl(&senslabel, &cmwlabel);

/* Create the font list and translate the label using it */
	italic = XLoadQueryFont(XtDisplay(topLevel),
		"-adobe-times-medium-i-*-*-14-*-*-*-*-*-iso8859-1");
	fontlist = XmFontListCreate(italic, "italic");
	xmstr = Xbsltos(XtDisplay(topLevel), &senslabel, width, fontlist, 
		LONG_WORDS);

/* Create a label widget using the font list and label text*/
	i=0;
	XtSetArg(args[i], XmNfontList, fontlist); i++;
	XtSetArg(args[i], XmNlabelString, xmstr); i++;
	label = XtCreateManagedWidget("label", xmLabelWidgetClass, 
		form, args, i);

The source code for the italicized sensitivity label string and the non-italicized "Launch and application" label is in "Code". Launch the application with any command line argument to see the italicized sensitivity label string in the label widget as shown in the following figure.

Figure 14-2 Italicized Label Text

Graphic