示例#1
0
文件: test12.c 项目: melanj/lesstif
int
main(int argc, char **argv)
{
    XmRepTypeList rep_types;
    int i, j;

#ifdef LESSTIF
    XmRegisterConverters(); /* necessary with LessTif */
#endif
    rep_types = XmRepTypeGetRegistered();

    fprintf(stderr, "done calling XmRepTypeGetRegistered()\n");

    printf("Representation Type Converters installed (Motif %i.%i.%i)\n",
        XmVERSION, XmREVISION, XmUPDATE_LEVEL);

    printf("\n-----------------\n");
    for(i = 0; rep_types[i].rep_type_name != NULL; i++)
    {
        printf("(%i) name: %s\n", i+1, rep_types[i].rep_type_name);
        printf("values:\n");
        for(j = 0; j < (int)rep_types[i].num_values; j++)
        {
            printf("\t%s", rep_types[i].value_names[j]);
            if(!((j+1) % 2))
                printf("\n");
        }
        printf("\n-----------------\n");
    }
    printf("Number of converters installed: %i\n", i);
    XtFree((char*)rep_types);
    exit(EXIT_SUCCESS);
}
示例#2
0
/* Print version info to stdout */
void PrintVersion(void)
{
    const char *text;
  
#if XmVersion < 2001
    XmRegisterConverters();  /* see comment above */
#endif
    text = getBuildInfo();
    puts (text);
}
示例#3
0
文件: RepType.c 项目: att/uwin
XmRepTypeList
XmRepTypeGetRegistered(void)
{
    int i, strlens, num_values;
    char *cp;
    String *sp;
    XmRepTypeList list, lp;

    /* 14 Oct 1998: There used to be a test to only call XmRegisterConverters
     * if number_of_types was 0.  But this meant if an application installed
     * some converters, then called XmRepTypeGetRegistered, the "base"
     * converters wouldn't be registered.  XmRegisterConverters can handle
     * redundant calls, so let it worry about it.		- Jamie
     */

    XmRegisterConverters();

    /* Find the sizes of various parts of the records */

    strlens = num_values = 0;
    for (lp = rep_types; lp < rep_types + number_of_types; lp++)
    {
	strlens += strlen(lp->rep_type_name);
	for (i = 0; i < lp->num_values; i++)
	    strlens += strlen(lp->value_names[i]);
	if (lp->values)
	    strlens += lp->num_values;
	num_values += lp->num_values;
    }

    /* Allocate the memory to hold everything */

    list = (XmRepTypeList)
	XtMalloc(number_of_types * (sizeof(XmRepTypeListRec) + 1) +
		 num_values * (sizeof(String) + 1) + strlens +
		 sizeof(XmRepTypeListRec));

    /* Copy each entry */

    lp = list;
    sp = (String *)(list + number_of_types + 1);
    cp = (char *)(sp + num_values);
    for (i = 0; i < number_of_types; i++)
    {
	cp += __XmRepTypeCopyRecord(lp, rep_types + i, sp, cp);
	sp += rep_types[i].num_values;
	lp++;
    }
    memset(lp, 0, sizeof(XmRepTypeListRec));
    return list;
}
main(int argc, char **argv)
{
	Widget topLevel, shell;
	XtAppContext appContext;

	topLevel = XtAppInitialize(&appContext, "TEST", NULL, 0, &argc, argv,
	    fallbackResources, NULL, 0);
	XmRegisterConverters();
	shell = createAndPopupProductDescriptionShell(appContext,topLevel,
	    "MEDM", NULL,(Pixmap)NULL,
	    "Motif-based Editor & Display Manager", NULL,
	    "Version "VERSION,
	    "developed at Argonne National Laboratory, by Mark Anderson", NULL,
	    -1, -1, 3);


	XtRealizeWidget(topLevel);
	XtAppMainLoop(appContext);

}
示例#5
0
int main (unsigned int argc, char **argv)
{
  FILE *fp;
  
  /* check for existance of ARBOR_GUI_LANGUAGE, exit if absent */
  if (getenv("ARBOR_GUI_LANGUAGE") == NULL)
    {
      printf("Environment variable ARBOR_GUI_LANGUAGE not set.  Exiting...\n");
      exit(1) ;
    }

  /* Add Xt support for i18n: locale */
  XtSetLanguageProc(NULL, NULL, NULL);
  
  XtToolkitInitialize ();
  app_context = XtCreateApplicationContext ();
  display = XtOpenDisplay (app_context, 
			   NULL, 
			   argv[0], 
			   "SysAdmin",
			   NULL, 
			   0, 
			   (int *) &argc, 
			   argv);
  if (!display)
    {
      printf("%s: can't open display, exiting...\n", argv[0]);
      exit (-1);
    }
  
  if ( argc == 2)
    {
      fp = fopen(argv[1],"r");
      if ( fp == (FILE *) NULL)
	{
	  printf ("\007Unable to open password file \"%s\".\n", argv[1]);
	  exit(-1);
	}

      if (fgets(gsSybase_User,80,fp) != NULL)
	gsSybase_User[strlen(gsSybase_User)-1] = 0;
      else
	{
	  printf("\007\nERROR -- Unable to read password file; exiting.") ;
	  exit(1) ;
	}
      if (fgets(gsSybase_Pass,80,fp) != NULL)
	gsSybase_Pass[strlen(gsSybase_Pass)-1] = 0;
      else
	{
	  printf("\007\nERROR -- Unable to read password file; exiting.") ;
	  exit(1) ;
	}

      fclose(fp);
      if ( unlink(argv[1]) )
	{
	  printf("\007WARNING -- Unable to remove password file.\n");
	}
      gintAutoLogin = 1;
    }

  /* Register converters, just in case you are really unlucky !! */
  XmRegisterConverters();
  
  /* String to unit type doesn't get added !! */
  XtAddConverter ( XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0 );
  
  strcpy(gstrProcessname, "SysAdmin");
  gLoginMethod1 = GUI_DSQUERY_ONLY;
  create_gCIloginwindow ( display, "SysAdmin", argc, argv );

  XtRealizeWidget (gCIloginwindow);
  XmProcessTraversal(gCIpassword,XmTRAVERSE_CURRENT);
 
  if ( gintAutoLogin )
    {
      XWithdrawWindow(display, XtWindow(gCIloginwindow), 0);
      XmTextSetString(gCIusername,gsSybase_User);
      CI_sybase_login_cb(okloginbtn, NULL, NULL);
    }

  XtAppMainLoop (app_context);

  return(0);
}
示例#6
0
int main (unsigned int argc, char **argv)
{
  process_arguments(argc, argv); /* g_module, db_name side-effected */

#ifdef _DBG_PRINT
  dbrecftos("/tmp/msg");
#endif

  dbproc = mydblogin();		
  if (dbproc == NULL) {
    fprintf(stderr, "Unable to log into DB.  Exiting.\n");
    exit(1);
  }
  initialize_message_system("UTL", dbproc);	/* a lie, but... */
  if(em_initialize_severity_codes(dbproc) == FAILURE)
  {
	fprintf(stderr,"Severity codes initialization failed.  Exiting.\n");
	exit(1);
  }
  if((nmodule_names = initialize_module_names(dbproc, &module_names)) < 0)
  {
	fprintf(stderr,"Module names initialization failed.  Exiting.\n");
	exit(1);
  }
  if (!g_module[0])		/* No module given.  Select "All". */
    strcpy(g_module, ALL);
  else {			/* module name not specified */
    /* 
     * Check if module name given is legal.  
     * If not, issue a message and exit.
     */
    int i;
    for (i = 0; i < nmodule_names; i++)
      if (!strcmp(g_module, module_names[i])) break;
    if (i == nmodule_names) {	/* module not found */
      fprintf(stderr, "Unknown module name '%s.'  Allowed modules are:\n\t", 
	      g_module);
      for (i = 0; i < nmodule_names; i++) 
	if (strcmp(module_names[i], ALL))
	  fprintf(stderr, " %s ", module_names[i]);
      fputc('\n', stderr);
      exit(1);
    }
  }
  XtToolkitInitialize ();
  app_context = XtCreateApplicationContext();
  display = XtOpenDisplay(app_context, NULL, argv[0], "EditMessage",
			   NULL, 0, &argc, argv);
  if (!display) {
    fprintf(stderr, "%s: can't open display, exiting...\n", argv[0]);
    exit (1);
  }
  XmRegisterConverters();
  XtAddConverter (XmRString, XmRUnitType, XmCvtStringToUnitType, NULL, 0);
  create_appShell ( display, argv[0], argc, argv );
  /* Cache the chosen module, for callbacks. 
     We could just use the set_module() callback, but that swaps labels etc.
     and we're cheap. */
  initialize_default_module(g_module);
  XtRealizeWidget(appShell);
  XtAppMainLoop(app_context);
  exit(0);			/* never get here */
}
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");
}