void medmInit(char *displayFont)
{
    XmFontListEntry entry;
    int i;
    char dashList[2];
    Boolean useDefaultFont;
    char *sizePosition;

#if 0
  /* KE: This doesn't appear in the Motif documentation.
   *   Assume it is not needed any more. */
    XmRegisterConverters();
#endif

#if 0
  /* Register action table */
    XtAppAddActions(appContext,actions,XtNumber(actions));
#endif

  /* Register a warning handler */
    XtSetWarningHandler((XtErrorHandler)trapExtraneousWarningsHandler);

  /* Initialize alarm color array */
    alarmColorPixel[NO_ALARM]=getPixelFromColormapByString(display,
      screenNum,cmap,alarmColorString[NO_ALARM]);
    alarmColorPixel[MINOR_ALARM]=getPixelFromColormapByString(display,
      screenNum,cmap,alarmColorString[MINOR_ALARM]);
    alarmColorPixel[MAJOR_ALARM]=getPixelFromColormapByString(display,
      screenNum,cmap,alarmColorString[MAJOR_ALARM]);
    alarmColorPixel[INVALID_ALARM]=getPixelFromColormapByString(display,
      screenNum,cmap,alarmColorString[INVALID_ALARM]);
    alarmColorPixel[ALARM_MAX-1]=getPixelFromColormapByString(display,
      screenNum,cmap,alarmColorString[ALARM_MAX-1]);

  /* Initialize Channel Access */
    medmCAInitialize();

  /* Initialize DisplayInfo structures list */
    displayInfoListHead = (DisplayInfo *)malloc(sizeof(DisplayInfo));
    displayInfoListHead->next = NULL;
    displayInfoListTail = displayInfoListHead;

  /* Initialize DisplayInfoSave structures list */
    displayInfoSaveListHead = (DisplayInfo *)malloc(sizeof(DisplayInfo));
    displayInfoSaveListHead->next = NULL;
    displayInfoSaveListTail = displayInfoSaveListHead;

  /* Initialize common XmStrings */
    dlXmStringMoreToComeSymbol = XmStringCreateLocalized(MORE_TO_COME_SYMBOL);

  /* Create the highlight GC */
    highlightGC = XCreateGC(display,rootWindow,0,NULL);
  /* Eliminate events that we do not handle anyway */
    XSetGraphicsExposures(display,highlightGC,False);
  /* Set the function to invert */
    XSetFunction(display,highlightGC,GXinvert);
  /* Pick a color which XOR-ing with makes reasonable sense for most
     colors */
  /* KE: Forground is irrelevant for GXinvert */
    XSetForeground(display,highlightGC,WhitePixel(display,screenNum));
#if 0
    XSetForeground(display,highlightGC,getPixelFromColormapByString(display,
      screenNum,cmap,"grey50"));
#endif
    XSetLineAttributes(display,highlightGC,HIGHLIGHT_LINE_THICKNESS,
      LineOnOffDash,CapButt,JoinMiter);
    dashList[0] = 3;
    dashList[1] = 3;
    XSetDashes(display,highlightGC,0,dashList,2);

/* Initialize the execute popup menu stuff for all shells.  Must be
   consistent with medmWidget.h definitions. */
    executePopupMenuButtonType[0] = XmPUSHBUTTON;
    executePopupMenuButtons[0] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_PRINT);

    executePopupMenuButtonType[1] = XmPUSHBUTTON;
    executePopupMenuButtons[1] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_CLOSE);

    executePopupMenuButtonType[2] = XmPUSHBUTTON;
    executePopupMenuButtons[2] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_PVINFO);

    executePopupMenuButtonType[3] = XmPUSHBUTTON;
    executePopupMenuButtons[3] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_PVLIMITS);

    executePopupMenuButtonType[4] = XmPUSHBUTTON;
    executePopupMenuButtons[4] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_MAIN);

    executePopupMenuButtonType[5] = XmPUSHBUTTON;
    executePopupMenuButtons[5] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_DISPLAY_LIST);

   executePopupMenuButtonType[6] = XmPUSHBUTTON;
    executePopupMenuButtons[6] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_FLASH_HIDDEN);

    executePopupMenuButtonType[7] = XmPUSHBUTTON;
    executePopupMenuButtons[7] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_REFRESH);

    executePopupMenuButtonType[8] = XmPUSHBUTTON;
    executePopupMenuButtons[8] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_RETRY);

  /* Note that the Execute Menu is a cascade button */
    executePopupMenuButtonType[9] = XmCASCADEBUTTON;
    executePopupMenuButtons[9] =
      XmStringCreateLocalized(EXECUTE_POPUP_MENU_EXECUTE);

  /* Load font and fontList tables (but only once) */
    if(!strcmp(displayFont,FONT_ALIASES_STRING)) {

      /* Use the ALIAS fonts if possible */
	strcpy(displayFont,ALIAS_FONT_PREFIX);
	sizePosition = strstr(displayFont,"_");
	printf("\n%s: Loading aliased fonts.",MEDM_VERSION_STRING);
	for(i = 0; i < MAX_FONTS; i++) {
	    sprintf(sizePosition,"_%d",fontSizeTable[i]);
	    fontTable[i] = XLoadQueryFont(display,displayFont);
	    printf(".");
	    if(fontTable[i] == NULL) {
		medmPrintf(1,"\nmedmInit: Unable to load font %s\n"
		  "  Trying default (fixed) instead\n",
		  displayFont);
	      /* one last attempt: try a common default font */
		fontTable[i] = XLoadQueryFont(display,LAST_CHANCE_FONT);
		if(fontTable[i] == NULL) {
		    medmCATerminate();
		    dmTerminateX();
		    exit(-1);
		}
	    }
	  /* Load the XmFontList table for Motif font sizing */
	    entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT,
	      (XtPointer)fontTable[i]);
	    fontListTable[i] = XmFontListAppendEntry(NULL, entry);
	    XmFontListEntryFree(&entry);
	}

    } else {
      /* Try using scalable font - either default or passed in one */
      /* User requested default scalable, copy that name into string
         and proceed */
	if(!strcmp(displayFont,DEFAULT_SCALABLE_STRING))
	  strcpy(displayFont,DEFAULT_SCALABLE_DISPLAY_FONT);

	useDefaultFont = !isScalableFont(displayFont);
	if(useDefaultFont) {
	  /* This name wasn't in XLFD format */
	    medmPrintf(1,"\nmedmInit:"
	      "  Invalid scalable display font selected  (Not in XLFD format)\n"
	      "    font: %s\n"
	      "  Using fixed font\n",displayFont);
	} else {
	    printf("\n%s: Loading scalable fonts.",MEDM_VERSION_STRING);
	}
	for(i = 0; i < MAX_FONTS; i++) {
	    if(!useDefaultFont) {
		fontTable[i] = loadQueryScalableFont(display, screenNum,
		  displayFont, fontSizeTable[i]);
		printf(".");
	    } else {
		fontTable[i] = XLoadQueryFont(display,LAST_CHANCE_FONT);
	    }
	    if(fontTable[i] == NULL) {
		medmCATerminate();
		dmTerminateX();
		exit(-1);
	    }
	  /* Load the XmFontList table for Motif font sizing */
	    entry = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT,
	      (XtPointer)fontTable[i]);
	    fontListTable[i] = XmFontListAppendEntry(NULL, entry);
	    XmFontListEntryFree(&entry);
	}
    }
    printf("\n");
}
Exemplo n.º 2
0
/*
** Motif still generates spurrious passive grab warnings on both IBM and SGI
** This routine suppresses them
*/
void SuppressPassiveGrabWarnings(void)
{
    XtSetWarningHandler(warnHandlerCB);
}