home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / 18555 < prev    next >
Encoding:
Internet Message Format  |  1993-01-07  |  3.3 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!emory!gatech!rutgers!cmcl2!adm!news
  2. From: beyer@bflsgu.fl.bs.dlr.de (Ralf Beyer DLR)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re:  Help needed(2): Xlib
  5. Message-ID: <34901@adm.brl.mil>
  6. Date: 7 Jan 93 11:47:49 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 108
  9.  
  10.  
  11.     
  12.     I tried this with various other applications (all XLib-based) with
  13.     the very same crash at the same point. In each case, XLoadFont() goes
  14.     through allright. XQueryFont() does not. XLoadQueryFont() does not.
  15.     
  16. The following code taken from one of my programs which runs on SGI with
  17. the display being the same SGI, on SGI with the display being another
  18. SGI and on SGI with the display being a SUN. SGI OS is 4.0.5, SUN OS
  19. is 4.1.1 (Open Windows). May be this is of any help.
  20.  
  21. Regards
  22.  
  23. Ralf Beyer
  24.  
  25. ----------------------------------------------------------------------
  26. typedef struct
  27.     {
  28.     short    number;
  29.     short    input;                /* input channel */
  30.     Widget    parent;
  31.     int    xrel;
  32.     int    yrel;
  33.     short    fontindx;
  34.     short    foreground;
  35.     short    background;
  36.     char    string[20];
  37.     Widget    widget;
  38.     short    fontsizeclass;
  39.     } LAbel;
  40.     
  41. char    *fontname[NO_OF_FONTS] = {
  42.         "*courier-bold-o-*-80-*",
  43.         "*courier-bold-o-*-100-*",
  44.         "*courier-bold-o-*-120-*",
  45.         "*courier-bold-o-*-140-*",
  46.         "*courier-bold-o-*-180-*",
  47.         "*courier-bold-o-*-240-*",
  48.         "*courier-bold-r-*-80-*",
  49.         "*courier-bold-r-*-100-*",
  50.         "*courier-bold-r-*-120-*",
  51.         "*courier-bold-r-*-140-*",
  52.         "*courier-bold-r-*-180-*",
  53.         "*courier-bold-r-*-240-*"};
  54.  
  55. void CreateLabel(llabel)
  56.  
  57. LAbel    *llabel;
  58.  
  59.     {
  60.     XmString    label_string;
  61.     XmFontList    fontlist = NULL;
  62.     XFontStruct    *lfont = NULL;
  63.     XmStringCharSet    charset = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
  64.     Arg        args[10];
  65.     Cardinal    n;
  66.  
  67.     /* Return if this widget is disabled by dummy parent (app_shell) */
  68.  
  69.     if (llabel->parent == app_shell)
  70.         {
  71.         if (debug > 0)
  72.             printf("CreateLabel: dummy parent\n");
  73.         return;
  74.         }
  75.  
  76.     /* Return if the widget has no parent (error) */
  77.  
  78.     if (llabel->parent == NULL)
  79.         {
  80.         if (debug > 0)
  81.             printf("CreateLabel: no parent\n");
  82.         return;
  83.         }
  84.  
  85.     lfont = XLoadQueryFont(XtDisplay(app_shell),fontname[llabel->fontindx]);
  86.     if (!lfont)
  87.         printf("CreateLabel: unable to load font %s\n",
  88.             fontname[llabel->fontindx]);
  89.         else
  90.         fontlist = XmFontListCreate(lfont,charset);
  91.  
  92.     label_string = XmStringCreateLtoR(llabel->string,charset);
  93.  
  94.     n = 0;
  95.     XtSetArg(args[n],XmNfontList,fontlist); n++;
  96.     XtSetArg(args[n],XmNleftAttachment,XmATTACH_POSITION); n++;
  97.     XtSetArg(args[n],XmNbottomAttachment, XmATTACH_POSITION); n++;
  98.     XtSetArg(args[n],XmNleftPosition,llabel->xrel); n++;
  99.     XtSetArg(args[n],XmNbottomPosition,llabel->yrel); n++;
  100.     XtSetArg(args[n],XmNlabelString,label_string); n++;
  101.     llabel->widget = XmCreateLabel(llabel->parent,llabel->string,args,n);
  102.     StoreWidgetColors(llabel->widget,llabel->foreground,llabel->background,0);
  103.     XtManageChild(llabel->widget);
  104.  
  105.     ichan[llabel->input] = llabel->widget;
  106.  
  107.     if (label_string) XmStringFree(label_string);
  108.     if (fontlist) XmFontListFree(fontlist);
  109.     return;
  110.     }
  111.  
  112. ----------------------------------------------------------------------
  113. Ralf Beyer
  114. German Aerospace Research Establishment (DLR), Institute for Flight
  115. Guidance, Flughafen, D-3300 Braunschweig, Fed. Rep. of Germany
  116. Internet: beyer@bflsgu.fl.bs.dlr.de (EARN/BITNET: fl17@dlrvmbs.bitnet) 
  117. ----------------------------------------------------------------------
  118.