1 /* $Header: /cvsroot/lesstif/lesstif/test/Xm/label/test1.c,v 1.10 2002/05/01 15:39:21 amai Exp $ */
2 /* test for multi font labels */
3 
4 #include <stdlib.h>
5 #include <stdio.h>
6 
7 #include <Xm/Label.h>
8 #include <Xm/LabelP.h>
9 
10 
11 #include "../../common/Test.h"
12 
13 
14 int
main(int argc,char ** argv)15 main(int argc, char **argv)
16 {
17   Widget toplevel, one;
18   XtAppContext app;
19   XmFontList fontlist;
20 #if 1
21   XmString xmstr1 = XmStringCreateLtoR("\n\nHere is a\n\n", "MY_FONT1");
22 #else
23   XmString xmstr1 = XmStringCreateLtoR("Here is a", "MY_FONT1");
24 #endif
25   XmString xmstr2 = XmStringCreate("different font", "MY_FONT");
26   XmString xmstr3 = XmStringCreate("accelerator", "MY_FONT");
27   XmStringContext context;
28   char *text;
29   XmStringCharSet tag;
30   XmStringDirection dir;
31   Boolean sep;
32 
33   XmString xmstr = XmStringConcat(xmstr1, xmstr2);
34 
35   XtSetLanguageProc(NULL, NULL, NULL);
36 
37   toplevel = XtVaAppInitialize(&app, "Label", NULL, 0, &argc, argv, NULL, NULL);
38 
39   XmStringInitContext(&context, xmstr);
40   while (XmStringGetNextSegment(context, &text, &tag, &dir, &sep)) {
41 	printf("Text: %s Tag: %s Dir: %d Sep: %d\n", text, tag, dir, sep);
42 	fflush(stdout);
43   }
44 
45   fontlist = XmFontListAppendEntry(NULL,
46 			   XmFontListEntryCreate("MY_FONT",
47 						 XmFONT_IS_FONT,
48 						 XLoadQueryFont(XtDisplay(toplevel),
49  	                                         "-adobe-helvetica-bold-o-normal--17-0-75-75-p-*-iso8859-1")));
50 
51   fontlist = XmFontListAppendEntry(fontlist,
52 			   XmFontListEntryCreate("MY_FONT1",
53 						 XmFONT_IS_FONT,
54 						 XLoadQueryFont(XtDisplay(toplevel),
55  	                                         "-adobe-helvetica-bold-r-normal--17-0-75-75-p-*-iso8859-1")));
56 
57   one = XtVaCreateManagedWidget("One", xmLabelWidgetClass, toplevel, XmNfontList, fontlist,
58 				XmNlabelString, xmstr,
59 				XmNacceleratorText, xmstr3, NULL);
60 
61   printf("xmstr: %p %p\n", xmstr, ((XmLabelRec*)one)->label._label);
62   XtRealizeWidget(toplevel);
63 /* Note: the following values are the result of
64  * querying the current geometry.
65  */
66 {
67 static XtWidgetGeometry Expected[] = {
68    {CWWidth | CWHeight            ,    0,    0,  112,   58, 0,0,0}, /* One */
69 };
70 /* toplevel should be replaced with to correct applicationShell */
71 PrintDetails(toplevel, Expected);
72 }
73 LessTifTestMainLoop(toplevel);
74 
75   exit(0);
76 }
77