示例#1
0
/*
 * Show the currently selected font in the sample text label.
 */
    static void
display_sample(SharedFontSelData *data)
{
    Arg		    args[2];
    int		    n;
    XFontStruct	*   font;
    XmFontList	    font_list;
    Display *	    display;
    XmString	    str;

    display = XtDisplay(data->dialog);
    font = XLoadQueryFont(display, data->font_name);
    font_list = gui_motif_create_fontlist(font);

    n = 0;
    str = XmStringCreateLocalized("AaBbZzYy 0123456789");
    XtSetArg(args[n], XmNlabelString, str); n++;
    XtSetArg(args[n], XmNfontList, font_list); n++;

    XtSetValues(data->sample, args, n);
    XmStringFree(str);

    if (data->old)
    {
	XFreeFont(display, data->old);
	XmFontListFree(data->old_list);
    }
    data->old = font;
    data->old_list = font_list;
}
示例#2
0
static void
Realize(Widget aw, XtValueMask * value_mask, XSetWindowAttributes * attributes)
{
	XltFontChooserWidget	fc = (XltFontChooserWidget) aw;
	char			*f = XtMalloc(256), **list;
	int			i, j, nfonts;

#define	superclass	(&xmMessageBoxClassRec)
  (*superclass->core_class.realize) (aw, value_mask, attributes);
#undef	superclass

	if (! FC_ShowDemo(fc))
		return;

/* Show the right font initially */
	f[0] = '\0';
	for (j=0; j<14; j++) {
		strcat(f, "-");
		strcat(f, FC_Setting(fc)[j]);
	}

	if (FC_FontName(fc))
		XtFree(FC_FontName(fc));
	FC_FontName(fc) = f;

/* How many fonts ? */
	list = XListFonts(XtDisplay(fc), f, 4096, &nfonts);
	for (i=0; i<nfonts; i++)
		EnableMenu(aw, list[i]);
	XFreeFontNames(list);

	if (FC_DemoWidget(fc)) {
		XmFontList      fl;
		XmFontListEntry fle;
		XFontSet        fs;
		char            m1[2][80], **missing = (char **)&m1[0][0];
		char            m2[80], *def = &m2[0];
		int             nmissing = 0;

		fs = XCreateFontSet(XtDisplay(fc), f, &missing, &nmissing, &def);

		if (fs != NULL) {
                	fle = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
			         XmFONT_IS_FONTSET, (XtPointer)fs);
                	fl = XmFontListAppendEntry(NULL, fle);

			XtVaSetValues(FC_DemoWidget(fc), XmNfontList, fl, NULL);

			XmFontListEntryFree(&fle);
			XmFontListFree(fl);
#if 0
			/* Freeing the font set produces nice little core dumps */
			XFreeFontSet(XtDisplay(fc), fs);	/* FIX ME leak ?? */
#endif
        	}

	}

	ShowCount(aw, nfonts);
}
示例#3
0
static void font_box_show_font (font_box_data * client)
	/* Font-box datas					*/
{
	Display * display;
	XmFontList motif_font_list;
	XFontStruct *old_font;
	Window window;

/* Get the display */
	display = XtDisplay (client->text);

/* Store the old font */
	old_font = client->current_font;

/* Query the new font */
	client->current_font = XLoadQueryFont (display, client->current_font_name);

/* Set it in the text widget */
	motif_font_list = XmFontListCreate (client->current_font, XmSTRING_DEFAULT_CHARSET);
	XtVaSetValues (client->text, XmNfontList, motif_font_list, NULL);
	XmFontListFree (motif_font_list);

/* Free the old font if it's loaded (the first time it is not) */
	if (old_font != NULL) XFreeFont (display, old_font);

/* Clear the window and force an Expose event to redraw properly the text */
	if (window = XtWindow (client->text))
		XClearArea (display, XtWindow (client->text), 0, 0, 0, 0, True);
}
示例#4
0
    int
workshop_get_font_height()
{
    XmFontList	 fontList;	/* fontList made from gui.norm_font */
    XmString	 str;
    Dimension	 w;
    Dimension	 h;

#ifdef WSDEBUG_TRACE
    if (WSDLEVEL(WS_TRACE_VERBOSE | WS_TRACE))
	wstrace("workshop_get_font_height()\n");
#endif

    /* Pick the proper signs for this font size */
    fontList = gui_motif_create_fontlist((XFontStruct *)gui.norm_font);
    h = 0;
    if (fontList != NULL)
    {
	str = XmStringCreateLocalized("A");
	XmStringExtent(fontList, str, &w, &h);
	XmStringFree(str);
	XmFontListFree(fontList);
    }

    return (int)h;
}
示例#5
0
void CoWowMotif::DisplayQuestion( void *ctx, const char *title, const char *text,
				  void (* questionbox_ok) ( void *, void *),
				  void (* questionbox_cancel) ( void *, void *),
				  void *data)
{
    Arg	    arg[10];
    Widget  question_widget, w;
    XmString CStr2, TitleStr, okstr, cancelstr;
    wow_t_question_cb *cbdata;
    XmFontList fontlist;
    XFontStruct *font;
    XmFontListEntry fontentry;

    // Set default fontlist
    font = XLoadQueryFont( XtDisplay(m_parent),
	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
    fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
    fontlist = XmFontListAppendEntry( NULL, fontentry);
    XtFree( (char *)fontentry);

    CStr2 = XmStringCreateLtoR( (char*) text, XmSTRING_DEFAULT_CHARSET);
    TitleStr = XmStringCreateLtoR( (char*) title, XmSTRING_DEFAULT_CHARSET);    
    okstr = XmStringCreateLtoR( (char*) " Yes ", XmSTRING_DEFAULT_CHARSET );    
    cancelstr = XmStringCreateLtoR( (char*) " No  ", XmSTRING_DEFAULT_CHARSET );    
    XtSetArg(arg[0],XmNheight,75);
    XtSetArg(arg[1],XmNwidth,200);
    XtSetArg(arg[2],XmNmessageString, CStr2);
    XtSetArg(arg[3],XmNx,400);
    XtSetArg(arg[4],XmNy,300);
    XtSetArg(arg[5],XmNdialogTitle,TitleStr);
    XtSetArg(arg[6], XmNokLabelString, okstr);
    XtSetArg(arg[7], XmNcancelLabelString, cancelstr);
    XtSetArg(arg[8], XmNbuttonFontList, fontlist);
    XtSetArg(arg[9], XmNlabelFontList, fontlist);

    cbdata = (wow_t_question_cb *) XtCalloc( 1, sizeof(*cbdata));
    cbdata->questionbox_ok = questionbox_ok;
    cbdata->questionbox_cancel = questionbox_cancel;
    cbdata->questionbox_help = 0;
    cbdata->ctx = ctx;
    cbdata->data = data;

    question_widget = XmCreateQuestionDialog( m_parent,(char*) "questionDialog",arg,10);
    XtAddCallback( question_widget, XmNokCallback,
		(XtCallbackProc) question_ok_cb, cbdata);
    XtAddCallback( question_widget, XmNcancelCallback, 
		(XtCallbackProc) question_cancel_cb, cbdata);

    XmStringFree( CStr2);
    XmStringFree( TitleStr);
    XmStringFree( okstr);
    XmStringFree( cancelstr);
    XmFontListFree( fontlist);
    
    XtManageChild( question_widget);	       
    
    w = XmMessageBoxGetChild( question_widget, XmDIALOG_HELP_BUTTON);
    XtUnmanageChild(w);    

}
示例#6
0
//
//  Modifies the popupmenu.
//
int WFoeMotif::modify_popup( unsigned long popupmenu_mask, int x, int y)
{
  static char buttontext[][40] = { "ObjectEditor", "SubWindow", "Connect", "Delete",
				   "Paste", "Copy", "Cut", "PrintSelect", "HelpClass"};
  static XtCallbackProc callback[] = { (void (*)(Widget,void *,void*))activate_attribute,
				       (void (*)(Widget,void *,void*))activate_subwindow,
				       (void (*)(Widget,void *,void*))activate_getobj,
				       (void (*)(Widget,void *,void*))activate_delete,
				       (void (*)(Widget,void *,void*))activate_paste,
				       (void (*)(Widget,void *,void*))activate_copy,
				       (void (*)(Widget,void *,void*))activate_cut,
				       (void (*)(Widget,void *,void*))activate_printselect,
				       (void (*)(Widget,void *,void*))activate_helpclass};

  Widget Menu, w;
  XEvent event;
  int i;
  Arg ArgList[5]; 
  XmFontList fontlist;
  XFontStruct *font;
  XmFontListEntry fontentry;

  popupmenu_mask = popupmenu_mask;

  event.xbutton.x_root = x + 5;
  event.xbutton.y_root = y;
  event.xbutton.x = 0;
  event.xbutton.y = 0;

  // Set default fontlist
  font = XLoadQueryFont( flow_Display( widgets.pane),
			 "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
  fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
  fontlist = XmFontListAppendEntry( NULL, fontentry);
  XtFree( (char *)fontentry);

  i = 0;
  XtSetArg(ArgList[i], XmNbuttonFontList, fontlist); i++;
  XtSetArg(ArgList[i], XmNlabelFontList, fontlist); i++;
  Menu = XmCreatePopupMenu( widgets.pane, (char*) "_popup", ArgList, i);  
  XtAddCallback( Menu, XmNunmapCallback, 
		 (XtCallbackProc)popup_unmap_cb, this);

  XmFontListFree( fontlist);

  for ( i = 0; i < 9; i++) {
    if ( popupmenu_mask & (1 << i)) {
      w = XtVaCreateManagedWidget( buttontext[i], xmPushButtonGadgetClass, 
			       Menu, NULL);

      XtAddCallback( w, XmNactivateCallback, (XtCallbackProc) callback[i], 
		    (XtPointer) this);
    }
  }
  widgets.popupmenu = Menu;
  XmMenuPosition( widgets.popupmenu, &event.xbutton);
  XtManageChild( widgets.popupmenu);
  return FOE__SUCCESS ;
}
示例#7
0
void iupdrvFontFinish(void)
{
  int i, count = iupArrayCount(mot_fonts);
  ImotFont* fonts = (ImotFont*)iupArrayGetData(mot_fonts);
  for (i = 0; i < count; i++)
  {
    XmFontListFree(fonts[i].fontlist);
    fonts[i].fontlist = NULL;
    XFreeFont(iupmot_display, fonts[i].fontstruct);
    fonts[i].fontstruct = NULL;
  }
  iupArrayDestroy(mot_fonts);
}
示例#8
0
int video_close(PLOT *plot)
{
	struct videodata *plotdata = (struct videodata *)plot->plotdata;
	Widget w = (Widget)plot->plot_widget;

	if (plot->ticklblfont != NULL) XmFontListFree(plot->ticklblfont);
	if (plotdata->pixmapalloced) XFreePixmap(XtDisplay(w), plotdata->pixmap);
	if (plotdata->xcc) XCCFree(plotdata->xcc);
	if (plotdata->framedata) free(plotdata->framedata);
	XtReleaseGC(w, plotdata->drawing_GC);
	XtReleaseGC(w, plotdata->inverse_GC);
	XtReleaseGC(w, plotdata->mark_GC);
	XtDestroyWidget(plot->plot_widget);
	free(plotdata->image);
	free(plot->plotdata);
	plot->plotdata = NULL;
	return SUCCESS;
}
示例#9
0
void CoWowMotif::DisplayError( const char *title, const char *text)
{
    Arg	    arg[10];
    Widget  err_widget, w;
    XmString cstr, ctitle;
    XmFontList fontlist;
    XFontStruct *font;
    XmFontListEntry fontentry;

    // Set default fontlist
    font = XLoadQueryFont( XtDisplay(m_parent),
	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
    fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
    fontlist = XmFontListAppendEntry( NULL, fontentry);
    XtFree( (char *)fontentry);

    cstr = XmStringCreateLtoR( (char*) text, XmSTRING_DEFAULT_CHARSET);
    ctitle = XmStringCreateLtoR( (char*) title, XmSTRING_DEFAULT_CHARSET);    
    XtSetArg(arg[0],XmNheight,75);
    XtSetArg(arg[1],XmNwidth,200);
    XtSetArg(arg[2],XmNmessageString, cstr);
    XtSetArg(arg[3],XmNx,400);
    XtSetArg(arg[4],XmNy,300);
    XtSetArg(arg[5],XmNdialogTitle, ctitle);
    XtSetArg(arg[6], XmNbuttonFontList, fontlist);
    XtSetArg(arg[7], XmNlabelFontList, fontlist);

    err_widget = XmCreateErrorDialog( m_parent,(char*) "err_widget",arg,8);
    XtAddCallback(err_widget, XmNokCallback, 
		(XtCallbackProc) error_ok_cb, NULL);

    XmStringFree( cstr);
    XmStringFree( ctitle);
    XmFontListFree( fontlist);
      
    XtManageChild(err_widget);	       
    
    w = XmMessageBoxGetChild(err_widget, XmDIALOG_CANCEL_BUTTON);
    XtUnmanageChild( w);    
    
    w = XmMessageBoxGetChild(err_widget, XmDIALOG_HELP_BUTTON);
    XtUnmanageChild( w);    

} /* END DisplayErrorBox */
示例#10
0
wxXFont::~wxXFont()
{
#if !wxMOTIF_USE_RENDER_TABLE
    if (m_fontList)
        XmFontListFree ((XmFontList) m_fontList);
    m_fontList = NULL;
#else // if wxMOTIF_USE_RENDER_TABLE
    if (m_renderTable)
        XmRenderTableFree ((XmRenderTable) m_renderTable);
    m_renderTable = NULL;
#endif

    // TODO: why does freeing the font produce a segv???
    // Note that XFreeFont wasn't called in wxWin 1.68 either.
    // MBN: probably some interaction with fonts being still
    //      in use in some widgets...
    // XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
    //        XFreeFont((Display*) m_display, fontStruct);
}
示例#11
0
static void dispSample(xfselControlBlkType *ctrlBlk)
{
    XFontStruct     *font;
    XmFontList      fontList;
    Display         *display;

    display     = XtDisplay(ctrlBlk->form);
    font        = XLoadQueryFont(display, ctrlBlk->fontName);
    fontList    = XmFontListCreate(font, XmSTRING_DEFAULT_CHARSET);

    enableSample(ctrlBlk, True, &fontList);

    if (ctrlBlk->oldFont != NULL)
    {
        XFreeFont(display, ctrlBlk->oldFont);
        XmFontListFree(ctrlBlk->oldFontList);
    }
    ctrlBlk->oldFont    = font;
    ctrlBlk->oldFontList    = fontList;
}
示例#12
0
文件: test2.c 项目: melanj/lesstif
void activate_callback(Widget w, XtPointer client_data, XtPointer call_data)
{
	XmFontList	fl = NULL;
	XFontStruct	*f = NULL;
	Arg		al[1];

	f = XLoadQueryFont(XtDisplay(w), "-*-courier-*-o-*--24-*");
	if (f)
		fl = XmFontListCreate(f, XmSTRING_DEFAULT_CHARSET);
	else
		fprintf(stderr, "XLoadQueryFont => NULL\n");

	if (fl) {
		XtSetArg(al[0], XmNfontList, fl);
		XtSetValues(field, al, 1);
		XmFontListFree(fl);
	} else
		fprintf(stderr, "XmFontList => NULL\n");

	XmTextFieldSetString(field, "Hello");
}
示例#13
0
static void
FCFilter(Widget w, XtPointer client, XtPointer call)
{
	int				i = (int)client, j, nfonts;
	Widget				fc, b, demo;
	char				*f = XtMalloc(256), **list;
	XmRowColumnCallbackStruct	*cbs = (XmRowColumnCallbackStruct *)call;

/* Figure out who we are and who called us */
#if 0
	for (fc = w; fc && ! XltIsFontChooser(fc); fc = XtParent(fc)) ;
	if (fc == NULL) {
		/* Probably in a tearoff */
		abort();
	}
#endif

	b = cbs->widget;		/* This widget invoked us */
	XtVaGetValues(b, XmNuserData, &fc, NULL);

	demo = FC_DemoWidget(fc);

/* Store the setting */
	if (FC_Setting(fc)[i] != NULL)
		XtFree(FC_Setting(fc)[i]);

	FC_Setting(fc)[i] = XtNewString(XtName(b));

	f[0] = '\0';
	for (j=0; j<14; j++) {
		strcat(f, "-");
		strcat(f, FC_Setting(fc)[j]);
	}

	if (FC_FontName(fc))
		XtFree(FC_FontName(fc));
	FC_FontName(fc) = f;

/* How many fonts ? */
	DisableAllMenus(fc, i);
	list = XListFonts(XtDisplay(fc), f, 4096, &nfonts);
	for (i=0; i<nfonts; i++)
		EnableMenu(fc, list[i]);
	XFreeFontNames(list);

/* Change the display */
	if (FC_ShowDemo(fc)) {
	    if (demo) {
		XmFontList      fl;
		XmFontListEntry fle;
		XFontSet        fs;
		char            m1[2][80], **missing = (char **)&m1[0][0];
		char            m2[80], *def = &m2[0];
		int             nmissing = 0;

		fs = XCreateFontSet(XtDisplay(fc), f, &missing, &nmissing, &def);

		if (fs != NULL) {
                	fle = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG,
			         XmFONT_IS_FONTSET, (XtPointer)fs);
                	fl = XmFontListAppendEntry(NULL, fle);

			XtVaSetValues(demo, XmNfontList, fl, NULL);

			XmFontListEntryFree(&fle);
			XmFontListFree(fl);
#if 0
			/* Freeing the font set produces nice little core dumps */
			XFreeFontSet(XtDisplay(fc), fs);	/* FIX ME leak ?? */
#endif
        	}
	    }

	    ShowCount(fc, nfonts);
	}
}
示例#14
0
文件: mon_info.c 项目: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   int             i;
   char            window_title[100],
                   work_dir[MAX_PATH_LENGTH],
                   str_line[MAX_INFO_STRING_LENGTH],
                   tmp_str_line[MAX_INFO_STRING_LENGTH];
   static String   fallback_res[] =
                   {
                      "*mwmDecorations : 42",
                      "*mwmFunctions : 12",
                      ".mon_info.form*background : NavajoWhite2",
                      ".mon_info.form.msa_box.?.?.?.text_wl.background : NavajoWhite1",
                      ".mon_info.form.msa_box.?.?.?.text_wr.background : NavajoWhite1",
                      ".mon_info.form.host_infoSW.host_info.background : NavajoWhite1",
                      ".mon_info.form.buttonbox*background : PaleVioletRed2",
                      ".mon_info.form.buttonbox*foreground : Black",
                      ".mon_info.form.buttonbox*highlightColor : Black",
                      NULL
                   };
   Widget          form_w,
                   msa_box_w,
                   msa_box1_w,
                   msa_box2_w,
                   msa_text_w,
                   button_w,
                   buttonbox_w,
                   rowcol1_w,
                   rowcol2_w,
                   h_separator1_w,
                   h_separator2_w,
                   v_separator_w;
   XmFontListEntry entry;
   XmFontList      fontlist;
   Arg             args[MAXARGS];
   Cardinal        argcount;
   uid_t           euid, /* Effective user ID. */
                   ruid; /* Real user ID. */

   CHECK_FOR_VERSION(argc, argv);

   /* Initialise global values. */
   p_work_dir = work_dir;
   init_mon_info(&argc, argv);

   /*
    * SSH uses wants to look at .Xauthority and with setuid flag
    * set we cannot do that. So when we initialize X lets temporaly
    * disable it. After XtAppInitialize() we set it back.
    */
   euid = geteuid();
   ruid = getuid();
   if (euid != ruid)
   {
      if (seteuid(ruid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       ruid, strerror(errno));
      }
   }

   (void)strcpy(window_title, afd_name);
   (void)strcat(window_title, " Info");
   argcount = 0;
   XtSetArg(args[argcount], XmNtitle, window_title); argcount++;
   appshell = XtAppInitialize(&app, "AFD", NULL, 0,
                              &argc, argv, fallback_res, args, argcount);
   disable_drag_drop(appshell);

   if (euid != ruid)
   {
      if (seteuid(euid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       euid, strerror(errno));
      }
   }

   display = XtDisplay(appshell);

#ifdef HAVE_XPM
   /* Setup AFD logo as icon. */
   setup_icon(display, appshell);
#endif

   /* Create managing widget. */
   form_w = XmCreateForm(appshell, "form", NULL, 0);

   entry = XmFontListEntryLoad(XtDisplay(form_w), font_name,
                               XmFONT_IS_FONT, "TAG1");
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

   argcount = 0;
   XtSetArg(args[argcount], XmNtopAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   msa_box_w = XmCreateForm(form_w, "msa_box", args, argcount);
   XtManageChild(msa_box_w);

   argcount = 0;
   XtSetArg(args[argcount], XmNtopAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   msa_box1_w = XmCreateForm(msa_box_w, "msa_box1", args, argcount);
   XtManageChild(msa_box1_w);

   rowcol1_w = XtVaCreateWidget("rowcol1", xmRowColumnWidgetClass,
                                 msa_box1_w, NULL);
   for (i = 0; i < NO_OF_MSA_ROWS; i++)
   {
      msa_text_w = XtVaCreateWidget("msa_text", xmFormWidgetClass,
                                     rowcol1_w,
                                     XmNfractionBase, 41,
                                     NULL);
      label_l_widget[i] = XtVaCreateManagedWidget(label_l[i],
                              xmLabelGadgetClass,  msa_text_w,
                              XmNfontList,         fontlist,
                              XmNtopAttachment,    XmATTACH_POSITION,
                              XmNtopPosition,      1,
                              XmNbottomAttachment, XmATTACH_POSITION,
                              XmNbottomPosition,   40,
                              XmNleftAttachment,   XmATTACH_POSITION,
                              XmNleftPosition,     1,
                              XmNalignment,        XmALIGNMENT_END,
                              NULL);
      text_wl[i] = XtVaCreateManagedWidget("text_wl",
                              xmTextWidgetClass,        msa_text_w,
                              XmNfontList,              fontlist,
                              XmNcolumns,               MON_INFO_LENGTH,
                              XmNtraversalOn,           False,
                              XmNeditable,              False,
                              XmNcursorPositionVisible, False,
                              XmNmarginHeight,          1,
                              XmNmarginWidth,           1,
                              XmNshadowThickness,       1,
                              XmNhighlightThickness,    0,
                              XmNrightAttachment,       XmATTACH_FORM,
                              XmNleftAttachment,        XmATTACH_POSITION,
                              XmNleftPosition,          22,
                              NULL);
      XtManageChild(msa_text_w);
   }
   XtManageChild(rowcol1_w);

   /* Fill up the text widget with some values. */
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH,
                 prev.real_hostname[(int)prev.afd_toggle]);
   XmTextSetString(text_wl[0], str_line);
   (void)sprintf(str_line, "%*d",
                 MON_INFO_LENGTH, prev.port[(int)prev.afd_toggle]);
   XmTextSetString(text_wl[1], str_line);
   (void)strftime(tmp_str_line, MAX_INFO_STRING_LENGTH, "%d.%m.%Y  %H:%M:%S",
                  localtime(&prev.last_data_time));
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, tmp_str_line);
   XmTextSetString(text_wl[2], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.max_connections);
   XmTextSetString(text_wl[3], str_line);
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.afd_version);
   XmTextSetString(text_wl[4], str_line);
   if (prev.top_tr > 1048576)
   {
      (void)sprintf(str_line, "%*u MB/s",
                    MON_INFO_LENGTH - 5, prev.top_tr / 1048576);
   }
   else if (prev.top_tr > 1024)               
        {
           (void)sprintf(str_line, "%*u KB/s",
                         MON_INFO_LENGTH - 5, prev.top_tr / 1024);
        }
        else
        {
           (void)sprintf(str_line, "%*u Bytes/s",
                         MON_INFO_LENGTH - 8, prev.top_tr);
        }
   XmTextSetString(text_wl[5], str_line);

   /* Create the first horizontal separator. */
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,     XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNtopWidget,       msa_box_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   h_separator1_w = XmCreateSeparator(form_w, "h_separator1_w", args, argcount);
   XtManageChild(h_separator1_w);

   /* Create the vertical separator. */
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,      XmVERTICAL);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNleftWidget,       msa_box1_w);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,    XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   v_separator_w = XmCreateSeparator(msa_box_w, "v_separator", args, argcount);
   XtManageChild(v_separator_w);

   argcount = 0;
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNleftWidget,      v_separator_w);
   argcount++;
   msa_box2_w = XmCreateForm(msa_box_w, "msa_box2", args, argcount);
   XtManageChild(msa_box2_w);

   rowcol2_w = XtVaCreateWidget("rowcol2", xmRowColumnWidgetClass,
                                msa_box2_w, NULL);
   for (i = 0; i < NO_OF_MSA_ROWS; i++)
   {
      msa_text_w = XtVaCreateWidget("msa_text", xmFormWidgetClass,
                                    rowcol2_w,
                                    XmNfractionBase, 41,
                                    NULL);
      label_r_widget[i] = XtVaCreateManagedWidget(label_r[i],
                              xmLabelGadgetClass,  msa_text_w,
                              XmNfontList,         fontlist,
                              XmNtopAttachment,    XmATTACH_POSITION,
                              XmNtopPosition,      1,
                              XmNbottomAttachment, XmATTACH_POSITION,
                              XmNbottomPosition,   40,
                              XmNleftAttachment,   XmATTACH_POSITION,
                              XmNleftPosition,     1,
                              XmNalignment,        XmALIGNMENT_END,
                              NULL);
      text_wr[i] = XtVaCreateManagedWidget("text_wr",
                              xmTextWidgetClass,        msa_text_w,
                              XmNfontList,              fontlist,
                              XmNcolumns,               MON_INFO_LENGTH,
                              XmNtraversalOn,           False,
                              XmNeditable,              False,
                              XmNcursorPositionVisible, False,
                              XmNmarginHeight,          1,
                              XmNmarginWidth,           1,
                              XmNshadowThickness,       1,
                              XmNhighlightThickness,    0,
                              XmNrightAttachment,       XmATTACH_FORM,
                              XmNleftAttachment,        XmATTACH_POSITION,
                              XmNleftPosition,          20,
                              NULL);
      XtManageChild(msa_text_w);
   }
   XtManageChild(rowcol2_w);

   /* Fill up the text widget with some values. */
   get_ip_no(msa[afd_position].hostname[(int)prev.afd_toggle], tmp_str_line);
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, tmp_str_line);
   XmTextSetString(text_wr[0], str_line);
   (void)sprintf(str_line, "%*s", MON_INFO_LENGTH, prev.r_work_dir);
   XmTextSetString(text_wr[1], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.poll_interval);
   XmTextSetString(text_wr[2], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.top_not);
   XmTextSetString(text_wr[3], str_line);
   (void)sprintf(str_line, "%*d", MON_INFO_LENGTH, prev.no_of_hosts);
   XmTextSetString(text_wr[4], str_line);
   (void)sprintf(str_line, "%*u files/s", MON_INFO_LENGTH - 8, prev.top_fr);
   XmTextSetString(text_wr[5], str_line);

   argcount = 0;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNfractionBase,     21);
   argcount++;
   buttonbox_w = XmCreateForm(form_w, "buttonbox", args, argcount);

   /* Create the second horizontal separator. */
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,           XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment,      XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,          buttonbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,        XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,       XmATTACH_FORM);
   argcount++;
   h_separator2_w = XmCreateSeparator(form_w, "h_separator2", args, argcount);
   XtManageChild(h_separator2_w);

   if (editable == YES)
   {
      button_w = XtVaCreateManagedWidget("Save",
                                         xmPushButtonWidgetClass, buttonbox_w,
                                         XmNfontList,         fontlist,
                                         XmNtopAttachment,    XmATTACH_POSITION,
                                         XmNtopPosition,      2,
                                         XmNbottomAttachment, XmATTACH_POSITION,
                                         XmNbottomPosition,   19,
                                         XmNleftAttachment,   XmATTACH_POSITION,
                                         XmNleftPosition,     1,
                                         XmNrightAttachment,  XmATTACH_POSITION,
                                         XmNrightPosition,    9,
                                         NULL);
      XtAddCallback(button_w, XmNactivateCallback,
                    (XtCallbackProc)save_button, (XtPointer)0);
      button_w = XtVaCreateManagedWidget("Close",
                                         xmPushButtonWidgetClass, buttonbox_w,
                                         XmNfontList,         fontlist,     
                                         XmNtopAttachment,    XmATTACH_POSITION,
                                         XmNtopPosition,      2,                
                                         XmNbottomAttachment, XmATTACH_POSITION,
                                         XmNbottomPosition,   19,
                                         XmNleftAttachment,   XmATTACH_POSITION,
                                         XmNleftPosition,     10,
                                         XmNrightAttachment,  XmATTACH_POSITION,
                                         XmNrightPosition,    20,
                                         NULL);
      XtAddCallback(button_w, XmNactivateCallback,
                    (XtCallbackProc)close_button, (XtPointer)0);
   }
   else
   {
      button_w = XtVaCreateManagedWidget("Close",
                                         xmPushButtonWidgetClass, buttonbox_w,
                                         XmNfontList,         fontlist,
                                         XmNtopAttachment,    XmATTACH_POSITION,
                                         XmNtopPosition,      2,
                                         XmNbottomAttachment, XmATTACH_POSITION,
                                         XmNbottomPosition,   19,
                                         XmNleftAttachment,   XmATTACH_POSITION,
                                         XmNleftPosition,     1,
                                         XmNrightAttachment,  XmATTACH_POSITION,
                                         XmNrightPosition,    20,
                                         NULL);
      XtAddCallback(button_w, XmNactivateCallback,
                    (XtCallbackProc)close_button, (XtPointer)0);
   }
   XtManageChild(buttonbox_w);

   /* Create log_text as a ScrolledText window. */
   argcount = 0;
   XtSetArg(args[argcount], XmNfontList,               fontlist);
   argcount++;
   XtSetArg(args[argcount], XmNrows,                   10);
   argcount++;
   XtSetArg(args[argcount], XmNcolumns,                80);
   argcount++;
   if (editable == YES)
   {
      XtSetArg(args[argcount], XmNeditable,               True);
      argcount++;
      XtSetArg(args[argcount], XmNcursorPositionVisible,  True);
      argcount++;
      XtSetArg(args[argcount], XmNautoShowCursorPosition, True);
   }
   else
   {
      XtSetArg(args[argcount], XmNeditable,               False);
      argcount++;
      XtSetArg(args[argcount], XmNcursorPositionVisible,  False);
      argcount++;
      XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
   }
   argcount++;
   XtSetArg(args[argcount], XmNeditMode,               XmMULTI_LINE_EDIT);
   argcount++;
   XtSetArg(args[argcount], XmNwordWrap,               False);
   argcount++;
   XtSetArg(args[argcount], XmNscrollHorizontal,       False);
   argcount++;
   XtSetArg(args[argcount], XmNcursorPositionVisible,  False);
   argcount++;
   XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,          XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNtopWidget,              h_separator1_w);
   argcount++;
   XtSetArg(args[argcount], XmNtopOffset,              3);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftOffset,             3);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightOffset,            3);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,           h_separator2_w);
   argcount++;
   XtSetArg(args[argcount], XmNbottomOffset,           3);
   argcount++;
   info_w = XmCreateScrolledText(form_w, "host_info", args, argcount);
   XtManageChild(info_w);
   XtManageChild(form_w);

   /* Free font list. */
   XmFontListFree(fontlist);

#ifdef WITH_EDITRES
   XtAddEventHandler(appshell, (EventMask)0, True,
                     _XEditResCheckMessages, NULL);
#endif

   /* Realize all widgets. */
   XtRealizeWidget(appshell);
   wait_visible(appshell);

   /* Read and display the information file. */
   (void)check_info_file(afd_name, AFD_INFO_FILE, YES);
   XmTextSetString(info_w, NULL);  /* Clears old entry. */
   XmTextSetString(info_w, info_data);

   /* Call update_info() after UPDATE_INTERVAL ms. */
   interval_id_host = XtAppAddTimeOut(app, UPDATE_INTERVAL,
                                      (XtTimerCallbackProc)update_info,
                                      form_w);

   /* We want the keyboard focus on the Done button. */
   XmProcessTraversal(button_w, XmTRAVERSE_CURRENT);

   /* Write window ID, so mon_ctrl can set focus if it is called again. */
   write_window_id(XtWindow(appshell), getpid(), MON_INFO);

   /* Start the main event-handling loop. */
   XtAppMainLoop(app);

   exit(SUCCESS);
}
示例#15
0
void CoWowMotif::DisplayLicense()
{
    char text[20000];
    Arg	    arg[11];
    Widget  question_widget;
    XmString CStr2, TitleStr, cancelstr;
    XmFontList fontlist;
    XFontStruct *font;
    XmFontListEntry fontentry;
    char title[80];
    Widget w;
    FILE *fp;
    char fname[200];
    int i;
    Widget wcancel;

    strcpy( title, lng_translate("License"));

    sprintf( fname, "$pwr_exe/%s/license.txt", lng_get_language_str());
    dcli_translate_filename( fname, fname);

    fp = fopen( fname, "r");
    if ( !fp) {
      strcpy( fname, "$pwr_exe/en_us/lincense.txt");
      dcli_translate_filename( fname, fname);
      fp = fopen( fname, "r");
      if ( !fp)
	return;
    }

    for ( i = 0; i < (int)sizeof(text) - 1; i++) {
      text[i] = fgetc( fp);
      if ( text[i] == EOF)
	break;
    }
    fclose( fp);
    text[i] = 0;

    // Set default fontlist
    font = XLoadQueryFont( XtDisplay(m_parent),
	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
    fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
    fontlist = XmFontListAppendEntry( NULL, fontentry);
    XtFree( (char *)fontentry);

    CStr2 = XmStringCreateLtoR( (char*) "", XmSTRING_DEFAULT_CHARSET);
    TitleStr = XmStringCreateLtoR( title, XmSTRING_DEFAULT_CHARSET);    
    cancelstr = XmStringCreateLtoR( (char*) " Close ", XmSTRING_DEFAULT_CHARSET );    
    XtSetArg(arg[0],XmNheight,400);
    XtSetArg(arg[1],XmNwidth,600);
    XtSetArg(arg[2],XmNmessageString, CStr2);
    XtSetArg(arg[3],XmNx,400);
    XtSetArg(arg[4],XmNy,300);
    XtSetArg(arg[5],XmNdialogTitle,TitleStr);
    XtSetArg(arg[6], XmNcancelLabelString, cancelstr);
    XtSetArg(arg[7], XmNbuttonFontList, fontlist);
    XtSetArg(arg[8], XmNlabelFontList, fontlist);

    question_widget = XmCreateMessageDialog( m_parent,(char*) "questionDialog",arg,9);
    XmStringFree( CStr2);
    XmStringFree( TitleStr);
    XmStringFree( cancelstr);
    XmFontListFree( fontlist);
    wcancel = XmMessageBoxGetChild(question_widget, XmDIALOG_CANCEL_BUTTON);
   

    XtSetArg(arg[0], XmNscrollHorizontal, True);
    XtSetArg(arg[1], XmNscrollVertical, True);
    XtSetArg(arg[2], XmNeditMode, XmMULTI_LINE_EDIT);
    XtSetArg(arg[3], XmNeditable, False);
    XtSetArg(arg[4], XmNcursorPositionVisible, False);
    XtSetArg(arg[5], XmNrows, 30);
    XtSetArg(arg[6], XmNvalue, text);
    XtSetArg(arg[7], XmNfontList, fontlist);
    w = XmCreateScrolledText( question_widget, (char*) "text", arg, 7);
    XtVaSetValues( XtParent(w), 
		   XmNleftAttachment, XmATTACH_FORM,
		   XmNrightAttachment, XmATTACH_FORM,
		   XmNtopAttachment, XmATTACH_FORM,
		   XmNbottomAttachment, XmATTACH_WIDGET,
		   XmNbottomWidget, wcancel,
		   NULL);
    XtManageChild(w);

    w = XmMessageBoxGetChild(question_widget, XmDIALOG_OK_BUTTON);
    XtUnmanageChild( w);    
    
    w = XmMessageBoxGetChild(question_widget, XmDIALOG_HELP_BUTTON);
    XtUnmanageChild( w);    

    XtManageChild( question_widget);	       
}
示例#16
0
/* ARGSUSED */
void show_textCb ( Widget w, XtPointer clnt, 
					XmDrawingAreaCallbackStruct *call )
/********************************************************************************
*										*
**										*
*										*	
* T. Piper/SAIC          1/02   Freed xfle, xmfl, & text_font as necessary	*
* T. Piper/SAIC		 2/02	Added 2nd argument, XtPointer client_data	*
*										*
********************************************************************************/
{
static Widget textpane, textform, textdialog_cancel, textbutton_form, textdialog_save;
XmString tstr;
XmFontList xmfl;
XmFontListEntry xfle;
Arg args[10];
Cardinal argcnt;

/*----------------------------------------------------------------------------*/

if( ! text_dialog)
   {
   text_dialog = XmCreateBulletinBoardDialog(toplevel, "textdialog_panel", NULL, 0);

   tstr = XmStringCreateLocalized( "Sounding Text" );
   XtVaSetValues( text_dialog, XmNdialogTitle, tstr, NULL);
   XmStringFree(tstr);

   textpane = XtVaCreateManagedWidget("text_pane",
                                xmPanedWindowWidgetClass,
                                text_dialog,
                                XmNsashWidth, 1,
                                XmNsashHeight, 1,
                                NULL);


   textform = XtVaCreateWidget("textform", xmFormWidgetClass,
                                textpane, XmNwidth, 650, XmNheight, 800,
                                XmNfractionBase, 10, NULL );
   argcnt = 0;
   XtSetArg(args[argcnt],XmNscrollBarDisplayPolicy,XmAS_NEEDED); argcnt++;
   XtSetArg(args[argcnt],XmNscrollingPolicy,XmAUTOMATIC); argcnt++;
   XtSetArg(args[argcnt],XmNheight,800); argcnt++;
   XtSetArg(args[argcnt],XmNwidth,650); argcnt++;
   textfield = XmCreateScrolledText(textform,"textform_text",
				args, argcnt);
   if ( text_font ) XFreeFont ( XtDisplay(toplevel), text_font );
   text_font = XLoadQueryFont(XtDisplay(toplevel),"-adobe-courier-bold-r-normal--14-100-100-100-m-90-iso8859-1");
   xfle = XmFontListEntryCreate(XmFONTLIST_DEFAULT_TAG, XmFONT_IS_FONT, (XtPointer)text_font );
   xmfl = XmFontListAppendEntry(NULL, xfle);
   XtFree ( (XtPointer)xfle );
   XtVaSetValues(textfield, XmNeditMode, XmMULTI_LINE_EDIT,
                                XmNeditable, False,
				XmNfontList, xmfl,
                                NULL );
   XmFontListFree ( xmfl );
   XtManageChild ( textfield );
   XtManageChild ( textform );

   textbutton_form = XtVaCreateWidget("textbuttonform", xmFormWidgetClass,
                                textpane, XmNwidth, 650, XmNfractionBase, 10, NULL );

   textdialog_save = XtVaCreateManagedWidget ("SAVE",
                        xmPushButtonWidgetClass, textbutton_form,
                        XmNleftAttachment, XmATTACH_POSITION,
                        XmNleftPosition, 3,
                        XmNtopAttachment, XmATTACH_FORM,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNrightAttachment, XmATTACH_POSITION,
                        XmNrightPosition, 5,
                        NULL );
   XtAddCallback(textdialog_save, XmNactivateCallback,
                        (XtCallbackProc)textdialog_save_cb, NULL);

   textdialog_cancel = XtVaCreateManagedWidget ("CLOSE",
                        xmPushButtonWidgetClass, textbutton_form,
                        XmNleftAttachment, XmATTACH_POSITION,
                        XmNleftPosition, 5,
                        XmNtopAttachment, XmATTACH_FORM,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNrightAttachment, XmATTACH_POSITION,
                        XmNrightPosition, 7,
                        NULL );
   XtAddCallback(textdialog_cancel, XmNactivateCallback,
                        (XtCallbackProc)textdialog_cancel_cb, NULL);

   XtManageChild ( textbutton_form );

   XtManageChild ( textpane );
   XtManageChild ( text_dialog );
   
   }
else
   XtManageChild ( text_dialog );

update_text_values();

}
示例#17
0
/*
 * Returns pointer to an ASCII character string that contains the name of the
 * selected font (in X format for naming fonts); it is the users responsibility
 * to free the space allocated to this string.
 */
    char_u *
gui_xm_select_font(char_u *current)
{
    static SharedFontSelData	_data;

    Widget		parent;
    Widget		form;
    Widget		separator;
    Widget		sub_form;
    Widget		size_toggle;
    Widget		name;
    Widget		disp_frame;
    Widget		frame;
    Arg			args[64];
    int			n;
    XmString		str;
    char		big_font[MAX_FONT_NAME_LEN];
    SharedFontSelData	*data;

    data = &_data;

    parent = vimShell;
    data->names = XListFonts(XtDisplay(parent), "-*-*-*-*-*-*-*-*-*-*-*-*-*-*",
						       MAX_FONTS, &data->num);

    /*
     * Find the name of the biggest font less than the given limit
     * MAX_DISPLAY_SIZE used to set up the initial height of the display
     * widget.
     */

    {
	int	i;
	int	max;
	int	index = 0;
	int	size;
	char	str[128];

	for (i = 0, max = 0; i < data->num; i++)
	{
	    get_part(fn(data, i), 7, str);
	    size = atoi(str);
	    if ((size > max) && (size < MAX_DISPLAY_SIZE))
	    {
		index = i;
		max = size;
	    }
	}
	strcpy(big_font, fn(data, index));
    }
    data->old = XLoadQueryFont(XtDisplay(parent), big_font);
    data->old_list = gui_motif_create_fontlist(data->old);

    /* Set the title of the Dialog window. */
    data->dialog = XmCreateDialogShell(parent, "fontSelector", NULL, 0);
    str = XmStringCreateLocalized(_("Vim - Font Selector"));

    /* Create form popup dialog widget. */
    form = XtVaCreateWidget("form",
	    xmFormWidgetClass, data->dialog,
	    XmNdialogTitle, str,
	    XmNautoUnmanage, False,
	    XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL,
	    NULL);
    XmStringFree(str);

    sub_form = XtVaCreateManagedWidget("subForm",
	    xmFormWidgetClass, form,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNbottomOffset, 4,
	    XmNrightAttachment, XmATTACH_FORM,
	    XmNrightOffset, 4,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNtopOffset, 4,
	    XmNorientation, XmVERTICAL,
	    NULL);

    data->ok = XtVaCreateManagedWidget(_("OK"),
	    xmPushButtonGadgetClass, sub_form,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNrightAttachment, XmATTACH_FORM,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNtopOffset, 4,
	    NULL);
    apply_fontlist(data->ok);

    data->cancel = XtVaCreateManagedWidget(_("Cancel"),
	    xmPushButtonGadgetClass, sub_form,
	    XmNrightAttachment, XmATTACH_FORM,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNtopAttachment, XmATTACH_WIDGET,
	    XmNtopWidget, data->ok,
	    XmNtopOffset, 4,
	    XmNshowAsDefault, True,
	    NULL);
    apply_fontlist(data->cancel);

    /* Create the separator for beauty. */
    n = 0;
    XtSetArg(args[n], XmNorientation, XmVERTICAL); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightWidget, sub_form); n++;
    XtSetArg(args[n], XmNrightOffset, 4); n++;
    separator = XmCreateSeparatorGadget(form, "separator", args, n);
    XtManageChild(separator);

    /* Create font name text widget and the corresponding label. */
    data->name = XtVaCreateManagedWidget("fontName",
	    xmTextWidgetClass, form,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNbottomOffset, 4,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNleftOffset, 4,
	    XmNrightAttachment, XmATTACH_WIDGET,
	    XmNrightWidget, separator,
	    XmNrightOffset, 4,
	    XmNeditable, False,
	    XmNeditMode, XmSINGLE_LINE_EDIT,
	    XmNmaxLength, MAX_FONT_NAME_LEN,
	    XmNcolumns, 60,
	    NULL);

    str = XmStringCreateLocalized(_("Name:"));
    name = XtVaCreateManagedWidget("fontNameLabel",
	    xmLabelGadgetClass, form,
	    XmNlabelString, str,
	    XmNuserData, data->name,
	    XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET,
	    XmNleftWidget, data->name,
	    XmNbottomAttachment, XmATTACH_WIDGET,
	    XmNbottomWidget, data->name,
	    XmNtopOffset, 1,
	    NULL);
    XmStringFree(str);
    apply_fontlist(name);

    /* create sample display label widget */
    disp_frame = XtVaCreateManagedWidget("sampleFrame",
	    xmFrameWidgetClass, form,
	    XmNshadowType, XmSHADOW_ETCHED_IN,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNleftOffset, 4,
	    XmNbottomAttachment, XmATTACH_WIDGET,
	    XmNbottomWidget, name,
	    XmNrightAttachment, XmATTACH_WIDGET,
	    XmNrightWidget, separator,
	    XmNrightOffset, 4,
	    XmNalignment, XmALIGNMENT_BEGINNING,
	    NULL);

    data->sample = XtVaCreateManagedWidget("sampleLabel",
	    xmLabelWidgetClass, disp_frame,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNrightAttachment, XmATTACH_FORM,
	    XmNalignment, XmALIGNMENT_BEGINNING,
	    XmNrecomputeSize, False,
	    XmNfontList, data->old_list,
	    NULL);

    /* create toggle button */
    str = XmStringCreateLocalized(_("Show size in Points"));
    size_toggle = XtVaCreateManagedWidget("sizeToggle",
	    xmToggleButtonGadgetClass, form,
	    XmNlabelString, str,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNleftOffset, 4,
	    XmNbottomAttachment, XmATTACH_WIDGET,
	    XmNbottomWidget, disp_frame,
	    XmNbottomOffset, 4,
	    NULL);
    XmStringFree(str);
    apply_fontlist(size_toggle);
    XtManageChild(size_toggle);

    /* Encoding pulldown menu.
     */

    data->encoding_pulldown = XmCreatePulldownMenu(form,
						 "encodingPulldown", NULL, 0);
    str = XmStringCreateLocalized(_("Encoding:"));
    n = 0;
    XtSetArg(args[n], XmNsubMenuId, data->encoding_pulldown); ++n;
    XtSetArg(args[n], XmNlabelString, str); ++n;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); ++n;
    XtSetArg(args[n], XmNleftOffset, 4); ++n;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); ++n;
    XtSetArg(args[n], XmNbottomWidget, size_toggle); ++n;
    XtSetArg(args[n], XmNbottomOffset, 4); ++n;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); ++n;
    XtSetArg(args[n], XmNrightWidget, separator); ++n;
    XtSetArg(args[n], XmNrightOffset, 4); ++n;
    data->encoding_menu = XmCreateOptionMenu(form, "encodingMenu", args, n);
    XmStringFree(str);
    XmAddTabGroup(data->encoding_menu);

    /*
     * Create scroll list widgets in a separate subform used to manage the
     * different sizes of the lists.
     */

    sub_form = XtVaCreateManagedWidget("subForm",
	    xmFormWidgetClass, form,
	    XmNbottomAttachment, XmATTACH_WIDGET,
	    XmNbottomWidget, data->encoding_menu,
	    XmNbottomOffset, 4,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNleftOffset, 4,
	    XmNrightAttachment, XmATTACH_WIDGET,
	    XmNrightWidget, separator,
	    XmNrightOffset, 4,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNtopOffset, 2,
	    XmNorientation, XmVERTICAL,
	    NULL);

    /* font list */
    frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
	    XmNshadowThickness, 0,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNleftAttachment, XmATTACH_FORM,
	    XmNrightAttachment, XmATTACH_POSITION,
	    XmNrightPosition, 50,
	    NULL);

    str = XmStringCreateLocalized(_("Font:"));
    name = XtVaCreateManagedWidget("nameListLabel", xmLabelGadgetClass, frame,
	    XmNchildType, XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
	    XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
	    XmNlabelString, str,
	    NULL);
    XmStringFree(str);
    apply_fontlist(name);

    n = 0;
    XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
    XtSetArg(args[n], XmNresizable, True); ++n;
    XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
    XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
#ifdef LESSTIF_VERSION
    XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
#endif
    data->list[NAME] = XmCreateScrolledList(frame, "fontList", args, n);
    XtVaSetValues(name, XmNuserData, data->list[NAME], NULL);

    /* style list */
    frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
	    XmNshadowThickness, 0,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNleftAttachment, XmATTACH_POSITION,
	    XmNleftPosition, 50,
	    XmNleftOffset, 4,
	    XmNrightAttachment, XmATTACH_POSITION,
	    XmNrightPosition, 80,
	    NULL);

    str = XmStringCreateLocalized(_("Style:"));
    name = XtVaCreateManagedWidget("styleListLabel", xmLabelWidgetClass, frame,
	    XmNchildType, XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
	    XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
	    XmNlabelString, str,
	    NULL);
    XmStringFree(str);
    apply_fontlist(name);

    n = 0;
    XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
    XtSetArg(args[n], XmNresizable, True); ++n;
    XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
    XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
#ifdef LESSTIF_VERSION
    XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
#endif
    data->list[STYLE] = XmCreateScrolledList(frame, "styleList", args, n);
    XtVaSetValues(name, XmNuserData, data->list[STYLE], NULL);

    /* size list */
    frame = XtVaCreateManagedWidget("frame", xmFrameWidgetClass, sub_form,
	    XmNshadowThickness, 0,
	    XmNtopAttachment, XmATTACH_FORM,
	    XmNbottomAttachment, XmATTACH_FORM,
	    XmNleftAttachment, XmATTACH_POSITION,
	    XmNleftPosition, 80,
	    XmNleftOffset, 4,
	    XmNrightAttachment, XmATTACH_FORM,
	    NULL);

    str = XmStringCreateLocalized(_("Size:"));
    name = XtVaCreateManagedWidget("sizeListLabel", xmLabelGadgetClass, frame,
	    XmNchildType, XmFRAME_TITLE_CHILD,
	    XmNchildVerticalAlignment, XmALIGNMENT_CENTER,
	    XmNchildHorizontalAlignment, XmALIGNMENT_BEGINNING,
	    XmNlabelString, str,
	    NULL);
    XmStringFree(str);
    apply_fontlist(name);

    n = 0;
    XtSetArg(args[n], XmNvisibleItemCount, 8); ++n;
    XtSetArg(args[n], XmNresizable, True); ++n;
    XtSetArg(args[n], XmNlistSizePolicy, XmCONSTANT); ++n;
    XtSetArg(args[n], XmNvisualPolicy, XmVARIABLE); ++n;
#ifdef LESSTIF_VERSION
    XtSetArg(args[n], XmNscrollBarDisplayPolicy, XmSTATIC); ++n;
#endif
    data->list[SIZE] = XmCreateScrolledList(frame, "sizeList", args, n);
    XtVaSetValues(name, XmNuserData, data->list[SIZE], NULL);

    /* update form widgets cancel button */
    XtVaSetValues(form, XmNcancelButton, data->cancel, NULL);

    XtAddCallback(size_toggle, XmNvalueChangedCallback,
	    (XtCallbackProc)stoggle_callback, (XtPointer)data);
    XtAddCallback(data->list[NAME], XmNbrowseSelectionCallback,
	    (XtCallbackProc)name_callback, (XtPointer)data);
    XtAddCallback(data->list[STYLE], XmNbrowseSelectionCallback,
	    (XtCallbackProc)style_callback, (XtPointer)data);
    XtAddCallback(data->list[SIZE], XmNbrowseSelectionCallback,
	    (XtCallbackProc)size_callback, (XtPointer)data);
    XtAddCallback(data->ok, XmNactivateCallback,
	    (XtCallbackProc)ok_callback, (XtPointer)data);
    XtAddCallback(data->cancel, XmNactivateCallback,
	    (XtCallbackProc)cancel_callback, (XtPointer)data);

    XmProcessTraversal(data->list[NAME], XmTRAVERSE_CURRENT);

    /* setup tabgroups */

    XmAddTabGroup(data->list[NAME]);
    XmAddTabGroup(data->list[STYLE]);
    XmAddTabGroup(data->list[SIZE]);
    XmAddTabGroup(size_toggle);
    XmAddTabGroup(data->name);
    XmAddTabGroup(data->ok);
    XmAddTabGroup(data->cancel);

    add_cancel_action(data->dialog, (XtCallbackProc)cancel_callback, data);

    /* Preset selection data. */

    data->exit = False;
    data->in_pixels= True;
    data->sel[ENCODING] = NULL;
    data->sel[NAME] = NULL;
    data->sel[STYLE] = NULL;
    data->sel[SIZE] = NULL;
    data->font_name = NULL;

    /* set up current font parameters */
    if (current && current[0] != '\0')
    {
	int	    i;
	char	    **names;

	names = XListFonts(XtDisplay(form), (char *) current, 1, &i);

	if (i != 0)
	{
	    char name[TEMP_BUF_SIZE];
	    char style[TEMP_BUF_SIZE];
	    char size[TEMP_BUF_SIZE];
	    char encoding[TEMP_BUF_SIZE];
	    char *found;

	    found = names[0];

	    name_part(found, name);
	    style_part(found, style);
	    size_part(found, size, data->in_pixels);
	    encoding_part(found, encoding);

	    if (strlen(name) > 0
		    && strlen(style) > 0
		    && strlen(size) > 0
		    && strlen(encoding) > 0)
	    {
		data->sel[NAME] = XtNewString(name);
		data->sel[STYLE] = XtNewString(style);
		data->sel[SIZE] = XtNewString(size);
		data->sel[ENCODING] = XtNewString(encoding);
		data->font_name = XtNewString(names[0]);
		display_sample(data);
		XmTextSetString(data->name, data->font_name);
	    }
	    else
	    {
		/* We can't preset a symbolic name, which isn't a full font
		 * description. Therefore we just behave the same way as if the
		 * user didn't have selected anything thus far.
		 *
		 * Unfortunately there is no known way to expand an abbreviated
		 * font name.
		 */

		data->font_name = NULL;
	    }
	}
	XFreeFontNames(names);
    }

    fill_lists(NONE, data);

    /* Unfortunately LessTif doesn't align the list widget's properly.  I don't
     * have currently any idea how to fix this problem.
     */
    XtManageChild(data->list[NAME]);
    XtManageChild(data->list[STYLE]);
    XtManageChild(data->list[SIZE]);
    XtManageChild(data->encoding_menu);
    manage_centered(form);

    /* modal event loop */
    while (!data->exit)
	XtAppProcessEvent(XtWidgetToApplicationContext(data->dialog),
							(XtInputMask)XtIMAll);

    XtDestroyWidget(data->dialog);

    if (data->old)
    {
	XFreeFont(XtDisplay(data->dialog),  data->old);
	XmFontListFree(data->old_list);
    }

    gui_motif_synch_fonts();

    return (char_u *) data->font_name;
}
示例#18
0
文件: Format.c 项目: idunham/cdesktop
/******************************************************************************
 * Function:	int _DtHelpFormatIndexEntries (DtHelpDispAreaStruct *pDAS,
 *				_XvhVolume volume,
 *				XmString *ret_title, XmFontList *ret_list,
 *				Boolean *ret_mod)
 *
 * Parameters:
 *		volume		Specifies the Help Volume the information
 *				is associated with.
 *              ret_cnt         number of valid entries in the array
 *		ret_words	Returns NULL-termintaed array of 
 *                                XmStrings containing the words.
 *		ret_list	Specifies the current font list being used.
 *				Returns a new font list if new character
 *				sets are added to it.
 *		ret_mod		Returns True if fonts were added to the
 *				font list.
 *
 * Returns:	0 if successful, -1 if errors
 *
 * errno Values:
 *
 * Purpose:	_DtHelpFormatIndexEntries formats index entries and associates
 *		the correct font with it.
 *
 ******************************************************************************/
int
_DtHelpFormatIndexEntries(
    XtPointer		  client_data,
    _DtHelpVolumeHdl	  volume_handle,
    int			 *ret_cnt,
    XmString		**ret_words,
    XmFontList		 *ret_list,
    Boolean		 *ret_mod )
{
    int		  i;
    int		  result = -1;
    void	 *titleChunks[4];
    char	 *charSet;
    char	**keyWords;
    Boolean       myMod = False;
    XmFontList    oldList;
    DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) client_data;

    /*
     * Check the parameters
     */
    if (ret_words == NULL || ret_list == NULL || ret_mod == NULL)
      {
	errno = EINVAL;
	return -1;
      }

    *ret_mod = False;

    charSet = _DtHelpGetVolumeLocale(volume_handle);
    if (charSet != NULL)
      {
	*ret_cnt = _DtHelpCeGetKeywordList(volume_handle, &keyWords);
	if (*ret_cnt > 0)
	  {

	    *ret_words = (XmString *) malloc (sizeof(XmString) * (*ret_cnt+1));
	    if (*ret_words == NULL)
		return -1;

            /* the order of the string ptr and charset ptr in the titleChunks
               is determined by the order of the if(..) tests on the
               flags and subsequent processing in FormatChunksToXmString() */
	    titleChunks[0] = (void *) (DT_HELP_CE_STRING | DT_HELP_CE_CHARSET);
	    titleChunks[1] = (void *) charSet;
	    titleChunks[3] = (void *) DT_HELP_CE_END;
	    for (i = 0, result = 0; result == 0 && i < *ret_cnt; i++)
	      {
		oldList        = *ret_list;
		titleChunks[2] = (void *) keyWords[i];
		result = FormatChunksToXmString(pDAS, False, titleChunks,
				&(*ret_words)[i], ret_list, &myMod);
		if (myMod == True)
		  {
		    /*
		     * if the list has been modified before,
		     * free the previously modified list.
		     */
		    if (True == *ret_mod)
			XmFontListFree(oldList);

		    *ret_mod = True;
		  }
	      }
            (*ret_words)[i] = NULL;
	  }
	free(charSet);
      }

    return result;

}  /* End _DtHelpFormatIndexEntries */
示例#19
0
文件: afd_load.c 项目: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   char            font_name[256],
                   *heading_str[4] =
                   {
                      "FILE LOAD",
                      "KBYTE LOAD",
                      "CONNECTION LOAD",
                      "ACTIVE TRANSFERS",
                   },
                   *unit_str[4] =
                   {
                      "Files/s",
                      "KBytes/s",
                      "Connections/s",
                      " "
                   },
                   window_title[100],
                   work_dir[MAX_PATH_LENGTH];
   XtAppContext    app_context;
   Widget          appshell,
                   bottom_separator_w,
                   buttonbox_w,
                   button_w,
                   chart_w,
                   headingbox_w,
                   label_w,
                   mainform_w,
                   top_separator_w;
   static String   fallback_res[] =
                   {
                      ".afd_load*mwmDecorations : 110",
                      ".afd_load*mwmFunctions : 30",
                      ".afd_load.mainform*background : NavajoWhite2",
                      ".afd_load.mainform.headingbox.current_value*background : NavajoWhite1",
                      ".afd_load.mainform.chart*background : NavajoWhite1",
                      ".afd_load.mainform.buttonbox*background : PaleVioletRed2",
                      ".afd_load.mainform.buttonbox*foreground : Black",
                      ".afd_load.mainform.buttonbox*highlightColor : Black",
                      NULL
                   };
   Arg             args[MAXARGS];
   Cardinal        argcount;
   XmFontList      fontlist;
   XmFontListEntry entry;
   uid_t           euid, /* Effective user ID. */
                   ruid; /* Real user ID. */

   CHECK_FOR_VERSION(argc, argv);

   /* Initialize global variables. */
   p_work_dir = work_dir;
   init_afd_load(&argc, argv, font_name, window_title);

   /*
    * SSH uses wants to look at .Xauthority and with setuid flag
    * set we cannot do that. So when we initialize X lets temporaly
    * disable it. After XtAppInitialize() we set it back.
    */
   euid = geteuid();
   ruid = getuid();
   if (euid != ruid)
   {
      if (seteuid(ruid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       ruid, strerror(errno));
      }
   }

   argcount = 0;
   XtSetArg(args[argcount], XmNtitle, window_title); argcount++;
   appshell = XtAppInitialize(&app_context, "afd_load", NULL, 0,
                              &argc, argv, fallback_res, args, argcount);

   if (euid != ruid)
   {
      if (seteuid(euid) == -1)
      {
         (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                       euid, strerror(errno));
      }
   }

#ifdef HAVE_XPM
   /* Setup AFD logo as icon. */
   setup_icon(XtDisplay(appshell), appshell);
#endif

   /* Create managing widget. */
   mainform_w = XmCreateForm(appshell, "mainform", NULL, 0);

   /* Prepare font. */
   if ((entry = XmFontListEntryLoad(XtDisplay(mainform_w), font_name, XmFONT_IS_FONT, "TAG1")) == NULL)
   {
       if ((entry = XmFontListEntryLoad(XtDisplay(mainform_w), "fixed", XmFONT_IS_FONT, "TAG1")) == NULL)
       {
          (void)fprintf(stderr,
                        "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                        strerror(errno), __FILE__, __LINE__);
          exit(INCORRECT);
       }
   }
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

/*-----------------------------------------------------------------------*/
/*                             Heading Box                               */
/*                             -----------                               */
/*-----------------------------------------------------------------------*/
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   headingbox_w = XmCreateForm(mainform_w, "headingbox", args, argcount);

   label_w = XtVaCreateManagedWidget(heading_str[(int)chart_type],
                        xmLabelGadgetClass,  headingbox_w,
                        XmNtopAttachment,    XmATTACH_FORM,
                        XmNtopOffset,        5,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNbottomOffset,     5,
                        XmNleftAttachment,   XmATTACH_FORM,
                        XmNleftOffset,       5,
                        XmNfontList,         fontlist,
                        XmNalignment,        XmALIGNMENT_BEGINNING,
                        NULL);
   label_w = XtVaCreateManagedWidget(unit_str[(int)chart_type],
                        xmLabelGadgetClass,  headingbox_w,
                        XmNtopAttachment,    XmATTACH_FORM,
                        XmNtopOffset,        5,
                        XmNbottomAttachment, XmATTACH_FORM,
                        XmNbottomOffset,     5,
                        XmNrightAttachment,  XmATTACH_FORM,
                        XmNrightOffset,      5,
                        XmNfontList,         fontlist,
                        XmNalignment,        XmALIGNMENT_BEGINNING,
                        NULL);
   current_value_w = XtVaCreateWidget("current_value",
                        xmTextWidgetClass,        headingbox_w,
                        XmNtopAttachment,         XmATTACH_FORM,
                        XmNtopOffset,             5,
                        XmNrightAttachment,       XmATTACH_WIDGET,
                        XmNrightWidget,           label_w,
                        XmNrightOffset,           5,
                        XmNbottomAttachment,      XmATTACH_FORM,
                        XmNbottomOffset,          5,
                        XmNfontList,              fontlist,
                        XmNrows,                  1,
                        XmNcolumns,               MAX_CURRENT_VALUE_DIGIT,
                        XmNeditable,              False,
                        XmNcursorPositionVisible, False,
                        XmNmarginHeight,          1,
                        XmNmarginWidth,           1,
                        XmNshadowThickness,       1,
                        XmNhighlightThickness,    0,
                        NULL);
   XtManageChild(current_value_w);
   XtManageChild(headingbox_w);

/*-----------------------------------------------------------------------*/
/*                         Horizontal Separator                          */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,     XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNtopAttachment,   XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNtopWidget,       headingbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,  XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   top_separator_w = XmCreateSeparator(mainform_w, "top separator",
                                       args, argcount);
   XtManageChild(top_separator_w);

/*-----------------------------------------------------------------------*/
/*                             Button Box                                */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNleftAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment, XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
   argcount++;
   buttonbox_w = XmCreateForm(mainform_w, "buttonbox", args, argcount);
   button_w = XtVaCreateManagedWidget("Close",
                                     xmPushButtonWidgetClass, buttonbox_w,
                                     XmNfontList,         fontlist,
                                     XmNtopAttachment,    XmATTACH_FORM,
                                     XmNleftAttachment,   XmATTACH_FORM,
                                     XmNrightAttachment,  XmATTACH_FORM,
                                     XmNbottomAttachment, XmATTACH_FORM,
                                     NULL);
   XtAddCallback(button_w, XmNactivateCallback,
                 (XtCallbackProc)close_button, (XtPointer)0);
   XtManageChild(buttonbox_w);

/*-----------------------------------------------------------------------*/
/*                         Horizontal Separator                          */
/*-----------------------------------------------------------------------*/
   argcount = 0;
   XtSetArg(args[argcount], XmNorientation,      XmHORIZONTAL);
   argcount++;
   XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_WIDGET);
   argcount++;
   XtSetArg(args[argcount], XmNbottomWidget,     buttonbox_w);
   argcount++;
   XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
   argcount++;
   XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
   argcount++;
   bottom_separator_w = XmCreateSeparator(mainform_w, "bottom separator",
                                          args, argcount);
   XtManageChild(bottom_separator_w);

/*-----------------------------------------------------------------------*/
/*                             Chart Box                                 */
/*-----------------------------------------------------------------------*/
   chart_w = XtVaCreateManagedWidget("chart",
                                     stripChartWidgetClass, mainform_w,
                                     XmNtopAttachment,      XmATTACH_WIDGET,
                                     XmNtopWidget,          top_separator_w,
                                     XmNleftAttachment,     XmATTACH_FORM,
                                     XmNrightAttachment,    XmATTACH_FORM,
                                     XmNbottomAttachment,   XmATTACH_WIDGET,
                                     XmNbottomWidget,       bottom_separator_w,
                                     XtNupdate,             (int)update_interval,
                                     XtNjumpScroll,         1,
                                     XtNheight,             100,
                                     XtNwidth,              260,
                                     NULL);
   if (chart_type == FILE_CHART)
   {
      XtAddCallback(chart_w, XtNgetValue, get_file_value, (XtPointer)0);
   }
   else if (chart_type == KBYTE_CHART)
        {
           XtAddCallback(chart_w, XtNgetValue, get_kbyte_value, (XtPointer)0);
        }
   else if (chart_type == CONNECTION_CHART)
        {
           XtAddCallback(chart_w, XtNgetValue, get_connection_value,
                         (XtPointer)0);
        }
        else
        {
           XtAddCallback(chart_w, XtNgetValue, get_transfer_value,
                         (XtPointer)0);
        }

   XtManageChild(mainform_w);

   /* Free font list. */
   XmFontListFree(fontlist);

   /* Realize all widgets. */
   XtRealizeWidget(appshell);

   XmTextSetString(current_value_w, "      0.00");

   /* Start the main event-handling loop. */
   XtAppMainLoop(app_context);

   exit(SUCCESS);
}
示例#20
0
/*######################### setup_mon_window() #########################*/
void
setup_mon_window(char *font_name)
{
   int             i,
                   his_log_length,
                   led_width,
                   new_max_bar_length;
   XmFontListEntry entry;

   /* Get width and height of font and fid for the GC. */
   if (font_struct != NULL)
   {
      XFreeFont(display, font_struct);
      font_struct = NULL;
   }
   if (fontlist != NULL)
   {
      XmFontListFree(fontlist);
      fontlist = NULL;
   }
   if ((font_struct = XLoadQueryFont(display, font_name)) == NULL)
   {
      (void)fprintf(stderr, "Could not load %s font.\n", font_name);
      if ((font_struct = XLoadQueryFont(display, DEFAULT_FONT)) == NULL)
      {
         (void)fprintf(stderr, "Could not load %s font.\n", DEFAULT_FONT);
         exit(INCORRECT);
      }
      else
      {
         (void)strcpy(font_name, DEFAULT_FONT);
      }
   }
   if ((entry = XmFontListEntryLoad(display, font_name, XmFONT_IS_FONT, "TAG1")) == NULL)
   {
       (void)fprintf(stderr,
                     "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                     strerror(errno), __FILE__, __LINE__);
       exit(INCORRECT);
   }
   fontlist = XmFontListAppendEntry(NULL, entry);
   XmFontListEntryFree(&entry);

   if (line_height != 0)
   {
      /* Set the font for the monitor pulldown. */
      XtVaSetValues(mw[MON_W], XmNfontList, fontlist, NULL);
      if ((mcp.show_ms_log != NO_PERMISSION) ||
          (mcp.show_mon_log != NO_PERMISSION) ||
          (mcp.mon_info != NO_PERMISSION) ||
          (mcp.retry != NO_PERMISSION) ||
          (mcp.switch_afd != NO_PERMISSION) ||
          (mcp.disable != NO_PERMISSION))
      {
         if (mcp.show_ms_log != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_SYS_LOG_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[0], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_mon_log != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_LOG_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[1], XmNfontList, fontlist, NULL);
         }
         if (mcp.mon_info != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_INFO_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[4], XmNfontList, fontlist, NULL);
         }
         if (mcp.retry != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_RETRY_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[2], XmNfontList, fontlist, NULL);
         }
         if (mcp.switch_afd != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_SWITCH_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[3], XmNfontList, fontlist, NULL);
         }
         if (mcp.disable != NO_PERMISSION)
         {
            XtVaSetValues(ow[MON_DISABLE_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(pw[5], XmNfontList, fontlist, NULL);
         }
         if ((ping_cmd != NULL) || (traceroute_cmd != NULL))
         {
            XtVaSetValues(ow[MON_TEST_W], XmNfontList, fontlist, NULL);
            if (ping_cmd != NULL)
            {
               XtVaSetValues(tw[PING_W], XmNfontList, fontlist, NULL);
            }
            if (traceroute_cmd != NULL)
            {
               XtVaSetValues(tw[TRACEROUTE_W], XmNfontList, fontlist, NULL);
            }
         }
      }
      XtVaSetValues(ow[MON_SELECT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(ow[MON_EXIT_W], XmNfontList, fontlist, NULL);

      /* Set the font for the RAFD pulldown. */
      if ((mcp.afd_ctrl != NO_PERMISSION) ||
          (mcp.show_slog != NO_PERMISSION) ||
          (mcp.show_elog != NO_PERMISSION) ||
          (mcp.show_rlog != NO_PERMISSION) ||
          (mcp.show_tlog != NO_PERMISSION) ||
          (mcp.show_ilog != NO_PERMISSION) ||
          (mcp.show_plog != NO_PERMISSION) ||
          (mcp.show_olog != NO_PERMISSION) ||
          (mcp.show_dlog != NO_PERMISSION) ||
          (mcp.show_queue != NO_PERMISSION) ||
          (mcp.afd_load != NO_PERMISSION))
      {
         XtVaSetValues(mw[LOG_W], XmNfontList, fontlist, NULL);
         if (mcp.afd_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_AFD_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_slog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_SYSTEM_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_elog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_EVENT_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_rlog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_RECEIVE_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_tlog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_TRANS_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_ilog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_INPUT_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_plog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_PRODUCTION_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_olog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_OUTPUT_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_dlog != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_DELETE_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.show_queue != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_SHOW_QUEUE_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.afd_load != NO_PERMISSION)
         {
            XtVaSetValues(vw[MON_VIEW_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[FILE_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[KBYTE_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[CONNECTION_LOAD_W], XmNfontList, fontlist, NULL);
            XtVaSetValues(lw[TRANSFER_LOAD_W], XmNfontList, fontlist, NULL);
         }
      }

      /* Set the font for the Control pulldown. */
      if ((mcp.amg_ctrl != NO_PERMISSION) ||
          (mcp.fd_ctrl != NO_PERMISSION) ||
          (mcp.rr_dc != NO_PERMISSION) ||
          (mcp.rr_hc != NO_PERMISSION) ||
          (mcp.edit_hc != NO_PERMISSION) ||
          (mcp.dir_ctrl != NO_PERMISSION) ||
          (mcp.startup_afd != NO_PERMISSION) ||
          (mcp.shutdown_afd != NO_PERMISSION))
      {
         XtVaSetValues(mw[CONTROL_W], XmNfontList, fontlist, NULL);
         if (mcp.amg_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(cw[AMG_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.fd_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(cw[FD_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.rr_dc != NO_PERMISSION)
         {
            XtVaSetValues(cw[RR_DC_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.rr_hc != NO_PERMISSION)
         {
            XtVaSetValues(cw[RR_HC_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.edit_hc != NO_PERMISSION)
         {
            XtVaSetValues(cw[EDIT_HC_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.dir_ctrl != NO_PERMISSION)
         {
            XtVaSetValues(cw[DIR_CTRL_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.startup_afd != NO_PERMISSION)
         {
            XtVaSetValues(cw[STARTUP_AFD_W], XmNfontList, fontlist, NULL);
         }
         if (mcp.shutdown_afd != NO_PERMISSION)
         {
            XtVaSetValues(cw[SHUTDOWN_AFD_W], XmNfontList, fontlist, NULL);
         }
      }

      /* Set the font for the Setup pulldown. */
      XtVaSetValues(mw[CONFIG_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[FONT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[ROWS_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[STYLE_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[HISTORY_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(sw[MON_OTHER_W], XmNfontList, fontlist, NULL);
      if (have_groups == YES)
      {
         XtVaSetValues(sw[MON_OPEN_ALL_GROUPS_W], XmNfontList, fontlist, NULL);
         XtVaSetValues(sw[MON_CLOSE_ALL_GROUPS_W], XmNfontList, fontlist, NULL);
      }
      XtVaSetValues(sw[MON_SAVE_W], XmNfontList, fontlist, NULL);

      /* Set the font for the Help pulldown. */
#ifdef _WITH_HELP_PULLDOWN
      XtVaSetValues(mw[HELP_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(hw[ABOUT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(hw[HYPER_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(hw[VERSION_W], XmNfontList, fontlist, NULL);
#endif

      /* Set the font for the Row pulldown. */
      XtVaSetValues(rw[ROW_0_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_1_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_2_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_3_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_4_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_5_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_6_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_7_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_8_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_9_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_10_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_11_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_12_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_13_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_14_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_15_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_16_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_17_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_18_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_19_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(rw[ROW_20_W], XmNfontList, fontlist, NULL);

      /* Set the font for the Line Style pulldown. */
      XtVaSetValues(lsw[STYLE_0_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(lsw[STYLE_1_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(lsw[STYLE_2_W], XmNfontList, fontlist, NULL);

      /* Set the font for the history pulldown. */
      for (i = 0; i < NO_OF_HISTORY_LOGS; i++)
      {
         XtVaSetValues(hlw[i], XmNfontList, fontlist, NULL);
      }

      /* Set the font for the Other options pulldown. */
      XtVaSetValues(oow[FORCE_SHIFT_SELECT_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(oow[AUTO_SAVE_W], XmNfontList, fontlist, NULL);
      XtVaSetValues(oow[FRAMED_GROUPS_W], XmNfontList, fontlist, NULL);
   }

   glyph_height       = font_struct->ascent + font_struct->descent;
   glyph_width        = font_struct->per_char->width;
   new_max_bar_length = glyph_width * BAR_LENGTH_MODIFIER;

   /* We now have to recalculate the length of all */
   /* bars and the scale, because a font change    */
   /* might have occurred.                         */
   if (new_max_bar_length != max_bar_length)
   {
      unsigned int new_bar_length;

      max_bar_length = new_max_bar_length;
      step_size = MAX_INTENSITY / max_bar_length;

      /* NOTE: We do not care what the line style is because the */
      /*       following could happen: font size = 7x13 style =  */
      /*       chars + bars, the user now wants chars only and   */
      /*       then reduces the font to 5x7. After a while he    */
      /*       wants the bars again. Thus we always need to re-  */
      /*       calculate the bar length and queue scale!         */
      for (i = 0; i < no_of_afds; i++)
      {
         /* Calculate new scale for active transfers bar. */
         if (connect_data[i].max_connections < 1)
         {
            connect_data[i].scale[ACTIVE_TRANSFERS_BAR_NO - 1] = (double)max_bar_length;
         }
         else
         {
            connect_data[i].scale[ACTIVE_TRANSFERS_BAR_NO - 1] = max_bar_length / connect_data[i].max_connections;
         }
         if (connect_data[i].no_of_transfers == 0)
         {
            new_bar_length = 0;
         }
         else if (connect_data[i].no_of_transfers >= connect_data[i].max_connections)
              {
                 new_bar_length = max_bar_length;
              }
              else
              {
                 new_bar_length = connect_data[i].no_of_transfers * connect_data[i].scale[ACTIVE_TRANSFERS_BAR_NO - 1];
              }
         if (new_bar_length >= max_bar_length)
         {
            connect_data[i].bar_length[ACTIVE_TRANSFERS_BAR_NO] = max_bar_length;
            connect_data[i].blue_color_offset = MAX_INTENSITY;
            connect_data[i].green_color_offset = 0;
         }
         else
         {
            connect_data[i].bar_length[ACTIVE_TRANSFERS_BAR_NO] = new_bar_length;
            connect_data[i].blue_color_offset = new_bar_length * step_size;
            connect_data[i].green_color_offset = MAX_INTENSITY - connect_data[i].blue_color_offset;
         }

         /* Calculate new scale for error bar. */
         if (connect_data[i].no_of_hosts < 1)
         {
            connect_data[i].scale[HOST_ERROR_BAR_NO - 1] = (double)max_bar_length;
         }
         else
         {
            connect_data[i].scale[HOST_ERROR_BAR_NO - 1] = max_bar_length / connect_data[i].no_of_hosts;
         }
         if (connect_data[i].host_error_counter == 0)
         {
            connect_data[i].bar_length[HOST_ERROR_BAR_NO] = 0;
         }
         else if (connect_data[i].host_error_counter >= connect_data[i].no_of_hosts)
              {
                 connect_data[i].bar_length[HOST_ERROR_BAR_NO] = max_bar_length;
              }
              else
              {
                 connect_data[i].bar_length[HOST_ERROR_BAR_NO] = connect_data[i].host_error_counter *
                                                                 connect_data[i].scale[HOST_ERROR_BAR_NO - 1];
              }

         /* Calculate new bar length for the transfer rate. */
         if (connect_data[i].average_tr > 1.0)
         {
            /* First ensure we do not divide by zero. */
            if (connect_data[i].max_average_tr < 2.0)
            {
               connect_data[i].bar_length[MON_TR_BAR_NO] =
                 log10(connect_data[i].average_tr) *
                 max_bar_length /
                 log10((double) 2.0);
            }
            else
            {
               connect_data[i].bar_length[MON_TR_BAR_NO] =
                 log10(connect_data[i].average_tr) *
                 max_bar_length /
                 log10(connect_data[i].max_average_tr);
            }
         }
         else
         {
            connect_data[i].bar_length[MON_TR_BAR_NO] = 0;
         }
      } /* for (i = 0; i < no_of_afds; i++) */
   }

   text_offset     = font_struct->ascent;
   line_height     = SPACE_ABOVE_LINE + glyph_height + SPACE_BELOW_LINE;
   bar_thickness_3 = glyph_height / 3;
   y_offset_led    = (glyph_height - glyph_width) / 2;
   led_width       = glyph_height / 3;
   y_center_log    = SPACE_ABOVE_LINE + (glyph_height / 2);
   if (his_log_set > 0)
   {
      his_log_length  = (his_log_set * bar_thickness_3) + DEFAULT_FRAME_SPACE;
   }
   else
   {
      his_log_length  = 0;
   }
   line_length     = DEFAULT_FRAME_SPACE +
                     (MAX_AFDNAME_LENGTH * glyph_width) +
                     DEFAULT_FRAME_SPACE +
                     (3 * (led_width + PROC_LED_SPACING)) +
                     glyph_height + (glyph_height / 2) + DEFAULT_FRAME_SPACE +
                     his_log_length + DEFAULT_FRAME_SPACE;

   if (line_style == BARS_ONLY)
   {
      line_length += (int)max_bar_length + DEFAULT_FRAME_SPACE;
   }
   else  if (line_style == CHARACTERS_ONLY)
         {
            line_length += (32 * glyph_width) + DEFAULT_FRAME_SPACE;
         }
         else
         {
            line_length += (32 * glyph_width) + DEFAULT_FRAME_SPACE +
                           (int)max_bar_length + DEFAULT_FRAME_SPACE;
         }

   x_offset_led = DEFAULT_FRAME_SPACE + (MAX_AFDNAME_LENGTH * glyph_width) +
                  DEFAULT_FRAME_SPACE;
   x_offset_log_status = x_offset_led + (3 * (led_width + PROC_LED_SPACING)) +
                         (glyph_height / 2) + DEFAULT_FRAME_SPACE;
   x_center_log_status = x_offset_log_status + (glyph_height / 2);
   x_offset_log_history = x_offset_log_status + glyph_height +
                          DEFAULT_FRAME_SPACE;
   for (i = 0; i < LOG_FIFO_SIZE; i++)
   {
      coord[i].x = x_center_log_status +
                   (int)((glyph_height / 2) *
                   cos((double)((log_angle * i * PI) / 180)));
      coord[i].y = y_center_log -
                   (int)((glyph_height / 2) *
                   sin((double)((log_angle * i * PI) / 180)));
   }
   if (line_style == BARS_ONLY)
   {
      x_offset_bars = x_offset_log_history + his_log_length;
   }
   else  if (line_style == CHARACTERS_ONLY)
         {
            x_offset_characters = x_offset_log_history + his_log_length;
            x_offset_ec = x_offset_characters + (27 * glyph_width);
            x_offset_eh = x_offset_ec + (3 *glyph_width);
         }
         else
         {
            x_offset_characters = x_offset_log_history + his_log_length;
            x_offset_bars = x_offset_characters + (32 * glyph_width) +
                            DEFAULT_FRAME_SPACE;
            x_offset_ec = x_offset_characters + (27 * glyph_width);
            x_offset_eh = x_offset_ec + (3 *glyph_width);
         }

   return;
}
示例#21
0
void *CoWowMotif::CreateList( const char *title, const char *texts, int textsize,
			      void (action_cb)( void *, char *),
			      void (cancel_cb)( void *),
			      void *parent_ctx,
			      int show_apply_button)
{
  Arg	    args[15];
  XmString cstr;
  Widget mainwindow;
  Widget ok_button;
  Widget cancel_button;
  Widget form;
  char *name_p;
  int i;
  wow_tListCtx ctx;
  XmFontList fontlist;
  XFontStruct *font;
  XmFontListEntry fontentry;

  ctx = (wow_tListCtx) calloc( 1, sizeof(*ctx));
  ctx->action_cb = action_cb;
  ctx->cancel_cb = cancel_cb;
  ctx->parent_ctx = parent_ctx;
  
  i=0;
  XtSetArg( args[i], XmNiconName, title); i++;

  ctx->toplevel = XtCreatePopupShell (
        title, topLevelShellWidgetClass, m_parent, args, i);

  // Set default fontlist
  font = XLoadQueryFont( XtDisplay(ctx->toplevel),
	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
  fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
  fontlist = XmFontListAppendEntry( NULL, fontentry);
  XtFree( (char *)fontentry);

  i=0;
  XtSetArg( args[i], XmNbuttonFontList, fontlist); i++;
  XtSetArg( args[i], XtNallowShellResize, TRUE); i++;
  XtSetValues( ctx->toplevel, args, i);

  mainwindow = XmCreateMainWindow( ctx->toplevel, (char*) "mainWindow", NULL, 0);
  XtManageChild( mainwindow);

  i=0;
  XtSetArg(args[i],XmNwidth, 200);i++;
  XtSetArg(args[i],XmNheight, 400);i++;
  XtSetArg(args[i],XmNresizePolicy,XmRESIZE_NONE); i++;

  form = XmCreateForm( mainwindow, (char*) "form", args, i);
  XtManageChild( form);

  cstr = XmStringCreateLtoR( (char*) "Ok", XmSTRING_DEFAULT_CHARSET);

  i=0;
  XtSetArg( args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNbottomOffset, 20); i++;
  XtSetArg( args[i], XmNleftAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNleftOffset, 20); i++;
  XtSetArg( args[i], XmNwidth, 50); i++;
  XtSetArg( args[i], XmNlabelString, cstr); i++;

  ok_button = XmCreatePushButton( form, (char*) "okButton", args, i);
  XtAddCallback( ok_button, XmNactivateCallback,
		(XtCallbackProc) list_ok_cb, ctx);
  XtManageChild( ok_button);

  XmStringFree( cstr);

  cstr = XmStringCreateLtoR( (char*) "Cancel", XmSTRING_DEFAULT_CHARSET);

  i=0;
  XtSetArg( args[i], XmNbottomAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNbottomOffset, 20); i++;
  XtSetArg( args[i], XmNrightAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNrightOffset, 20); i++;
  XtSetArg( args[i], XmNwidth, 50); i++;
  XtSetArg( args[i], XmNlabelString, cstr); i++;

  cancel_button = XmCreatePushButton( form, (char*) "okButton", args, i);
  XtAddCallback( cancel_button, XmNactivateCallback,
		(XtCallbackProc) list_cancel_cb, ctx);
  XtManageChild( cancel_button);

  XmStringFree( cstr);

  i = 0;
  XtSetArg( args[i], XmNdefaultButton, ok_button); i++;
  XtSetArg( args[i], XmNcancelButton, cancel_button); i++;
  XtSetValues( form, args, i);

  i=0;
  XtSetArg( args[i], XmNbottomAttachment, XmATTACH_WIDGET); i++;
  XtSetArg( args[i], XmNbottomWidget, ok_button); i++;
  XtSetArg( args[i], XmNbottomOffset, 15); i++;
  XtSetArg( args[i], XmNrightAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNrightOffset, 15); i++;
  XtSetArg( args[i], XmNtopAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNtopOffset, 15); i++;
  XtSetArg( args[i], XmNleftAttachment, XmATTACH_FORM); i++;
  XtSetArg( args[i], XmNleftOffset, 15); i++;
  XtSetArg( args[i], XmNselectionPolicy, XmSINGLE_SELECT); i++;
  XtSetArg( args[i], XmNfontList, fontlist); i++;
  ctx->list = XmCreateScrolledList( form, (char*) "scrolledList", args, i);
  XtAddCallback( ctx->list, XmNdefaultActionCallback,
		(XtCallbackProc) list_action_cb, ctx);

  XmFontListFree( fontlist);
  XtManageChild( ctx->list);

  name_p = (char *)texts;
  i = 0;
  while ( strcmp( name_p, "") != 0) {
    cstr = XmStringCreateSimple( name_p);
    XmListAddItemUnselected( ctx->list, cstr, 0);
    XmStringFree(cstr);	  
    name_p += textsize;
    i++;
  }

  ctx->texts = (char *) calloc( i+1, textsize);
  ctx->textsize = textsize;
  memcpy( ctx->texts, texts, (i+1) * textsize); 
  XtPopup( ctx->toplevel, XtGrabNone);

  // Set input focus to the scrolled list widget
  XmProcessTraversal( ctx->list, XmTRAVERSE_CURRENT);


  return ctx;
}
示例#22
0
Widget XNavMotif::build_menu( Widget Parent,
			      int   MenuType,
			      const char *MenuTitle,
			      void *MenuUserData,
			      void (*Callback)( Widget, XNav *, XmAnyCallbackStruct *),
			      void *CallbackData,
			      xmenu_sMenuItem *Items,
			      int *idx)
{
  Widget Menu, Cascade, W;
  int i;
  unsigned int Level;
  XmString Str;
  WidgetClass Class;
  Arg ArgList[5]; 
  XmFontList fontlist;
  XFontStruct *font;
  XmFontListEntry fontentry;

  // Set default fontlist
  font = XLoadQueryFont( flow_Display(Parent),
  	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
  fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
  fontlist = XmFontListAppendEntry( NULL, fontentry);
  XtFree( (char *)fontentry);

  i = 0;
  XtSetArg(ArgList[i], XmNuserData, MenuUserData); i++;
  XtSetArg(ArgList[i], XmNbuttonFontList, fontlist); i++;
  XtSetArg(ArgList[i], XmNlabelFontList, fontlist); i++;
  if (MenuType == MENU_PULLDOWN || MenuType == MENU_OPTION)
    Menu = XmCreatePulldownMenu(Parent, (char*) "_pulldown", ArgList, i);
  else if (MenuType == MENU_POPUP)
    Menu = XmCreatePopupMenu(Parent, (char*) "_popup", ArgList, i);  
  else  {
    XtWarning("Invalid menu type passed to BuildMenu().");
    return NULL;
  }

  if (MenuType == MENU_PULLDOWN) {
    Str = XmStringCreateSimple((char*) MenuTitle);	
    Cascade = XtVaCreateManagedWidget(MenuTitle,
	    xmCascadeButtonGadgetClass, Parent,
	    XmNsubMenuId,   Menu,
	    XmNlabelString, Str,
	    NULL);
    XmStringFree(Str);
  } 
  else if (MenuType == MENU_OPTION) {
    Str = XmStringCreateSimple((char*) MenuTitle);
    XtSetArg(ArgList[0], XmNsubMenuId, Menu);
    XtSetArg(ArgList[1], XmNlabelString, Str);
    Cascade = XmCreateOptionMenu(Parent, (char*) MenuTitle, ArgList, 2);
    XmStringFree(Str);
  }

  XmFontListFree( fontlist);

  Level = Items[*idx].Level;

  for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
    if (Items[*idx].Item == xmenu_eMenuItem_Cascade ||
      Items[*idx].Item == xmenu_eMenuItem_Ref) {
      if (MenuType == MENU_OPTION) {
        XtWarning("You can't have submenus from option menu items.");
        return NULL;
      } 
      else {
        i = *idx;
        (*idx)++;	
        build_menu(Menu, MENU_PULLDOWN, 
		   Lng::translate( Items[i].Name), MenuUserData, 
		   Callback, CallbackData, Items, idx);
        (*idx)--;
      }
    }
    else {
      if (Items[*idx].Item == xmenu_eMenuItem_Separator)
        Class = xmSeparatorGadgetClass;
      else
        Class = xmPushButtonGadgetClass;
 
      W = XtVaCreateManagedWidget(Lng::translate( Items[*idx].Name), 
		    Class, Menu,
		    XmNuserData, *idx,
		    XmNsensitive, (Boolean)(Items[*idx].Flags.f.Sensitive == 1),
		    NULL);

      if (Callback && Class == xmPushButtonGadgetClass)
        XtAddCallback(W, XmNactivateCallback, (XtCallbackProc) Callback, 
		      (XtPointer) CallbackData);
    }
  }

  return MenuType == MENU_POPUP ? Menu : Cascade;
}
示例#23
0
int CoWowMotif::DisplayWarranty()
{
    char    text[4000];
    Arg	    arg[12];
    Widget  question_widget;
    XmString CStr2, TitleStr, okstr, cancelstr, helpstr;
    wow_t_question_cb *cbdata;
    XmFontList fontlist;
    XFontStruct *font;
    XmFontListEntry fontentry;
    char 	title[80];
    FILE 	*fp;
    int 	i;
    char 	fname[256];

    // Display only once
    if ( HideWarranty())
      return 1;

    sprintf( fname, "$pwr_exe/%s/acceptlicense.txt", lng_get_language_str());
    dcli_translate_filename( fname, fname);

    fp = fopen( fname, "r");
    if ( !fp) {
      strcpy( fname, "$pwr_exe/en_us/acceptlicense.txt");
      dcli_translate_filename( fname, fname);
      fp = fopen( fname, "r");
      if ( !fp) return 1;
    }

    for ( i = 0; i < (int)sizeof(text) - 1; i++) {
      text[i] = fgetc( fp);
      if ( text[i] == EOF)
	break;
    }
    text[i] = 0;
    fclose( fp);

    strcpy( title, lng_translate("Accept License Terms"));

    // Set default fontlist
    font = XLoadQueryFont( XtDisplay(m_parent),
	      "-*-Helvetica-Bold-R-Normal--12-*-*-*-P-*-ISO8859-1");
    fontentry = XmFontListEntryCreate( (char*) "tag1", XmFONT_IS_FONT, font);
    fontlist = XmFontListAppendEntry( NULL, fontentry);
    XtFree( (char *)fontentry);
    
    CStr2 = XmStringCreateLtoR( text, XmSTRING_DEFAULT_CHARSET);
    TitleStr = XmStringCreateLtoR( title, XmSTRING_DEFAULT_CHARSET);    
    okstr = XmStringCreateLtoR( lng_translate( "I Accept"), XmSTRING_DEFAULT_CHARSET );    
    cancelstr = XmStringCreateLtoR( lng_translate( "Quit"), XmSTRING_DEFAULT_CHARSET );    
    helpstr = XmStringCreateLtoR( lng_translate( "Show License"), XmSTRING_DEFAULT_CHARSET );    
    XtSetArg(arg[0],XmNheight,75);
    XtSetArg(arg[1],XmNwidth,700);
    XtSetArg(arg[2],XmNmessageString, CStr2);
    XtSetArg(arg[3],XmNx,400);
    XtSetArg(arg[4],XmNy,300);
    XtSetArg(arg[5],XmNdialogTitle,TitleStr);
    XtSetArg(arg[6], XmNokLabelString, okstr);
    XtSetArg(arg[7], XmNcancelLabelString, cancelstr);
    XtSetArg(arg[8], XmNhelpLabelString, helpstr);
    XtSetArg(arg[9], XmNbuttonFontList, fontlist);
    XtSetArg(arg[10], XmNlabelFontList, fontlist);
    XtSetArg(arg[11], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL);

    cbdata = (wow_t_question_cb *) XtCalloc( 1, sizeof(*cbdata));
    cbdata->questionbox_ok = warranty_ok_cb;
    cbdata->questionbox_cancel = warranty_cancel_cb;
    cbdata->questionbox_help = warranty_help_cb;
    cbdata->ctx = 0;
    cbdata->data = (void *)this;

    question_widget = XmCreateMessageDialog( m_parent,(char*) "questionDialog",arg, 12);
    XtAddCallback( question_widget, XmNokCallback,
		(XtCallbackProc) question_ok_cb, cbdata);
    XtAddCallback( question_widget, XmNcancelCallback, 
		(XtCallbackProc) question_cancel_cb, cbdata);
    XtAddCallback( question_widget, XmNhelpCallback, 
		(XtCallbackProc) question_help_cb, cbdata);

    XmStringFree( CStr2);
    XmStringFree( TitleStr);
    XmStringFree( okstr);
    XmStringFree( cancelstr);
    XmStringFree( helpstr);
    XmFontListFree( fontlist);
   
    XtManageChild( question_widget);	       
    return 1;
}
示例#24
0
文件: view_dc.c 项目: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ main() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
    int             glyph_height,
                    max_vertical_lines;
    char            window_title[100],
                    work_dir[MAX_PATH_LENGTH];
    static String   fallback_res[] =
    {
        "*mwmDecorations : 42",
        "*mwmFunctions : 12",
        ".view_dc.form*background : NavajoWhite2",
        ".view_dc.form.buttonbox2.searchbox*background : NavajoWhite1",
        ".view_dc.form.dc_textSW.dc_text.background : NavajoWhite1",
        ".view_dc.form.buttonbox*background : PaleVioletRed2",
        ".view_dc.form.buttonbox*foreground : Black",
        ".view_dc.form.buttonbox*highlightColor : Black",
        NULL
    };
    Widget          form_w,
                    button_w,
                    buttonbox_w,
                    h_separator_w;
    XmFontListEntry entry;
    XFontStruct     *font_struct;
    XmFontList      fontlist;
    XmFontType      dummy;
    Arg             args[MAXARGS];
    Cardinal        argcount;
    uid_t           euid, /* Effective user ID. */
                    ruid; /* Real user ID. */

    CHECK_FOR_VERSION(argc, argv);

    /* Initialise global values. */
    p_work_dir = work_dir;
    init_view_dc(&argc, argv);

    /*
     * SSH uses wants to look at .Xauthority and with setuid flag
     * set we cannot do that. So when we initialize X lets temporaly
     * disable it. After XtAppInitialize() we set it back.
     */
    euid = geteuid();
    ruid = getuid();
    if (euid != ruid)
    {
        if (seteuid(ruid) == -1)
        {
            (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                          ruid, strerror(errno));
        }
    }

    (void)strcpy(window_title, "DIR_CONFIG ");
    (void)strcat(window_title, p_title);
    argcount = 0;
    XtSetArg(args[argcount], XmNtitle, window_title);
    argcount++;
    appshell = XtAppInitialize(&app, "AFD", NULL, 0,
                               &argc, argv, fallback_res, args, argcount);
    disable_drag_drop(appshell);

    if (euid != ruid)
    {
        if (seteuid(euid) == -1)
        {
            (void)fprintf(stderr, "Failed to seteuid() to %d : %s\n",
                          euid, strerror(errno));
        }
    }

    /* Get display pointer. */
    if ((display = XtDisplay(appshell)) == NULL)
    {
        (void)fprintf(stderr,
                      "ERROR   : Could not open Display : %s (%s %d)\n",
                      strerror(errno), __FILE__, __LINE__);
        exit(INCORRECT);
    }

#ifdef HAVE_XPM
    /* Setup AFD logo as icon. */
    setup_icon(display, appshell);
#endif

    /* Create managing widget. */
    form_w = XmCreateForm(appshell, "form", NULL, 0);

    if ((entry = XmFontListEntryLoad(XtDisplay(form_w), font_name,
                                     XmFONT_IS_FONT, "TAG1")) == NULL)
    {
        if ((entry = XmFontListEntryLoad(XtDisplay(form_w), "fixed",
                                         XmFONT_IS_FONT, "TAG1")) == NULL)
        {
            (void)fprintf(stderr,
                          "Failed to load font with XmFontListEntryLoad() : %s (%s %d)\n",
                          strerror(errno), __FILE__, __LINE__);
            exit(INCORRECT);
        }
    }
    font_struct = (XFontStruct *)XmFontListEntryGetFont(entry, &dummy);
    glyph_height = font_struct->ascent + font_struct->descent;
    fontlist = XmFontListAppendEntry(NULL, entry);
    XmFontListEntryFree(&entry);

    /* Calculate the maximum lines to show. */
    max_vertical_lines = (8 * (DisplayHeight(display, DefaultScreen(display)) /
                               glyph_height)) / 10;
    if (max_y > max_vertical_lines)
    {
        max_y = max_vertical_lines;
    }

    argcount = 0;
    XtSetArg(args[argcount], XmNleftAttachment,   XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,  XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment, XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNfractionBase,     21);
    argcount++;
    buttonbox_w = XmCreateForm(form_w, "buttonbox", args, argcount);

    /* Create a horizontal separator. */
    argcount = 0;
    XtSetArg(args[argcount], XmNorientation,           XmHORIZONTAL);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,      XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,          buttonbox_w);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,       XmATTACH_FORM);
    argcount++;
    h_separator_w = XmCreateSeparator(form_w, "h_separator", args, argcount);
    XtManageChild(h_separator_w);

    button_w = XtVaCreateManagedWidget("Close",
                                       xmPushButtonWidgetClass, buttonbox_w,
                                       XmNfontList,         fontlist,
                                       XmNtopAttachment,    XmATTACH_POSITION,
                                       XmNtopPosition,      2,
                                       XmNbottomAttachment, XmATTACH_POSITION,
                                       XmNbottomPosition,   19,
                                       XmNleftAttachment,   XmATTACH_POSITION,
                                       XmNleftPosition,     1,
                                       XmNrightAttachment,  XmATTACH_POSITION,
                                       XmNrightPosition,    20,
                                       NULL);
    XtAddCallback(button_w, XmNactivateCallback,
                  (XtCallbackProc)close_button, (XtPointer)0);
    XtManageChild(buttonbox_w);

    /* Create DIR_CONFIG data as a ScrolledText window. */
    argcount = 0;
    XtSetArg(args[argcount], XmNfontList,               fontlist);
    argcount++;
    XtSetArg(args[argcount], XmNeditable,               False);
    argcount++;
    XtSetArg(args[argcount], XmNeditMode,               XmMULTI_LINE_EDIT);
    argcount++;
    XtSetArg(args[argcount], XmNwordWrap,               False);
    argcount++;
    XtSetArg(args[argcount], XmNscrollHorizontal,       False);
    argcount++;
    XtSetArg(args[argcount], XmNcursorPositionVisible,  False);
    argcount++;
    XtSetArg(args[argcount], XmNautoShowCursorPosition, False);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNleftOffset,             3);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightOffset,            3);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,           h_separator_w);
    argcount++;
    XtSetArg(args[argcount], XmNbottomOffset,           3);
    argcount++;
    XtSetArg(args[argcount], XmNrows,                   max_y);
    argcount++;
    XtSetArg(args[argcount], XmNcolumns,                max_x);
    argcount++;
    XtSetArg(args[argcount], XmNvalue,                  view_buffer);
    argcount++;
    text_w = XmCreateScrolledText(form_w, "dc_text", args, argcount);
    XtManageChild(text_w);

    /* Create a horizontal separator. */
    argcount = 0;
    XtSetArg(args[argcount], XmNorientation,           XmHORIZONTAL);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,      XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,          text_w);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,       XmATTACH_FORM);
    argcount++;
    h_separator_w = XmCreateSeparator(form_w, "h_separator", args, argcount);
    XtManageChild(h_separator_w);

    argcount = 0;
    XtSetArg(args[argcount], XmNtopAttachment,          XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNtopOffset,              1);
    argcount++;
    XtSetArg(args[argcount], XmNleftAttachment,         XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNrightAttachment,        XmATTACH_FORM);
    argcount++;
    XtSetArg(args[argcount], XmNbottomAttachment,       XmATTACH_WIDGET);
    argcount++;
    XtSetArg(args[argcount], XmNbottomWidget,           h_separator_w);
    argcount++;
    XtSetArg(args[argcount], XmNbottomOffset,           1);
    argcount++;
    XtSetArg(args[argcount], XmNfractionBase,           31);
    argcount++;
    buttonbox_w = XmCreateForm(form_w, "buttonbox2", args, argcount);

    searchbox_w = XtVaCreateWidget("searchbox",
                                   xmTextWidgetClass,        buttonbox_w,
                                   XmNtopAttachment,         XmATTACH_POSITION,
                                   XmNtopPosition,           5,
                                   XmNbottomAttachment,      XmATTACH_POSITION,
                                   XmNbottomPosition,        26,
                                   XmNleftAttachment,        XmATTACH_POSITION,
                                   XmNleftPosition,          1,
                                   XmNrightAttachment,       XmATTACH_POSITION,
                                   XmNrightPosition,         20,
                                   XmNfontList,              fontlist,
                                   XmNrows,                  1,
                                   XmNeditable,              True,
                                   XmNcursorPositionVisible, True,
                                   XmNmarginHeight,          1,
                                   XmNmarginWidth,           1,
                                   XmNshadowThickness,       1,
                                   XmNhighlightThickness,    0,
                                   NULL);
    XtManageChild(searchbox_w);
    button_w = XtVaCreateManagedWidget("Search",
                                       xmPushButtonWidgetClass, buttonbox_w,
                                       XmNleftAttachment,       XmATTACH_POSITION,
                                       XmNleftPosition,         22,
                                       XmNrightAttachment,      XmATTACH_POSITION,
                                       XmNrightPosition,        28,
                                       XmNtopAttachment,        XmATTACH_FORM,
                                       XmNfontList,             fontlist,
                                       NULL);
    XtAddCallback(button_w, XmNactivateCallback,
                  (XtCallbackProc)search_button, (XtPointer)0);
    XtManageChild(buttonbox_w);
    XtManageChild(form_w);

    /* Free font list. */
    XmFontListFree(fontlist);

#ifdef WITH_EDITRES
    XtAddEventHandler(appshell, (EventMask)0, True,
                      _XEditResCheckMessages, NULL);
#endif

    /* Realize all widgets. */
    XtRealizeWidget(appshell);

    /* We want the keyboard focus on the Close button. */
    XmProcessTraversal(button_w, XmTRAVERSE_CURRENT);

    /* Write window ID, so afd_ctrl can set focus if it is called again. */
    write_window_id(XtWindow(appshell), getpid(), VIEW_DC);

    /* Start the main event-handling loop. */
    XtAppMainLoop(app);

    exit(SUCCESS);
}
示例#25
0
char    *FontSel(Widget parent, int showPropFonts, const char *currFont,
            Pixel sampleFG, Pixel sampleBG)
{
    Widget          dialog, form, okButton, cancelButton;
    Widget          styleList, sizeList, fontName, fontList;
    Widget          sizeToggle, propFontToggle = NULL, dispField;
    Widget          nameLabel, sampleLabel;
    Arg             args[MAX_ARGS];
    int             n;
    XmString        tempStr;
    char            bigFont[MAX_FONT_NAME_LEN];
    xfselControlBlkType ctrlBlk;
    Display         *theDisplay;

    ctrlBlk.fontData    = XListFonts(XtDisplay(parent), 
                                     "-*-*-*-*-*-*-*-*-*-*-*-*-*-*", 
                                     MAX_NUM_FONTS, &ctrlBlk.numFonts);
    FindBigFont(&ctrlBlk, bigFont);
    ctrlBlk.oldFont = XLoadQueryFont(XtDisplay(parent), bigFont);
    ctrlBlk.oldFontList = XmFontListCreate(ctrlBlk.oldFont,
                                            XmSTRING_DEFAULT_CHARSET);
    ctrlBlk.sampleFG = sampleFG;
    ctrlBlk.sampleBG = sampleBG;

    dialog  = CreateDialogShell(parent, "Font Selector", args, 0);

    /*  Set up window sizes for form widget */

    n = 0;
    XtSetArg(args[n], XmNautoUnmanage, FALSE); n++;
    XtSetArg(args[n], XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL); n++;

    /*  Create form popup dialog widget */

    form    = XtCreateWidget ("Font Selector", xmFormWidgetClass, dialog, 
                              args, n);

    /*  Create pushbutton widgets */

    n = 0;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomOffset, 4); n++;
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    XtSetArg(args[n], XmNrightPosition, 45); n++;
    XtSetArg(args[n], XmNwidth, 110); n++;
    XtSetArg(args[n], XmNheight, 28); n++;
    XtSetArg(args[n], XmNshowAsDefault, TRUE); n++;
    okButton = XtCreateManagedWidget("OK", xmPushButtonWidgetClass, form,
                                      args, n);

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, okButton); n++;
    XtSetArg(args[n], XmNbottomWidget, okButton); n++;
    XtSetArg(args[n], XmNleftPosition, 55); n++;
    XtSetArg(args[n], XmNwidth, 110); n++;
    XtSetArg(args[n], XmNheight, 28); n++;
    cancelButton = XtCreateManagedWidget("Cancel", xmPushButtonWidgetClass,
                                         form, args, n);

    /*  create font name text widget and the corresponding label */

    n = 0; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNbottomWidget, okButton); n++; 
    XtSetArg(args[n], XmNleftPosition, 1); n++; 
    XtSetArg(args[n], XmNrightPosition, 99); n++; 
    XtSetArg(args[n], XmNeditable, True); n++;
    XtSetArg(args[n], XmNeditMode, XmSINGLE_LINE_EDIT); n++;
    XtSetArg(args[n], XmNmaxLength, MAX_FONT_NAME_LEN); n++;
    fontName = XtCreateManagedWidget("fontname", xmTextWidgetClass, form,
                                     args, n);
    RemapDeleteKey(fontName);   /* kludge to handle delete and BS */

    n = 0; 
    tempStr = XmStringCreate("Font Name:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'N'); n++;
    XtSetArg(args[n], XmNuserData, fontName); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftWidget, fontName); n++; 
    XtSetArg(args[n], XmNbottomWidget, fontName); n++;
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    nameLabel = XtCreateManagedWidget("Font Name:", xmLabelWidgetClass,
                                      form, args, n);
    XmStringFree(tempStr);

    /*  create sample display text field widget */

    n = 0;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNrightPosition, 99); n++;
    XtSetArg(args[n], XmNbottomWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftPosition, 1); n++; 
    XtSetArg(args[n], XmNalignment, XmALIGNMENT_BEGINNING); n++;
    XtSetArg(args[n], XmNvalue, 
            "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789");
            n++;
    XtSetArg(args[n], XmNforeground, sampleFG); n++;
    XtSetArg(args[n], XmNbackground, sampleBG); n++;
    dispField = XtCreateManagedWidget(" ", xmTextFieldWidgetClass, form, 
                                       args, n);

    n = 0; 
    tempStr = XmStringCreate("Sample:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'S'); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftWidget, dispField); n++; 
    XtSetArg(args[n], XmNbottomWidget, dispField); n++;
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    sampleLabel = XtCreateManagedWidget("Font Name:", xmLabelWidgetClass,
            form, args, n);
    XmStringFree(tempStr);

    /*  create toggle buttons */

    n = 0; 
    tempStr = XmStringCreate("Show Size in Points", 
                              XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'P'); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++; 
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; 
    XtSetArg(args[n], XmNleftPosition, 2); n++; 
    XtSetArg(args[n], XmNtopOffset, 1); n++;
    XtSetArg(args[n], XmNbottomWidget, sampleLabel); n++;
    sizeToggle = XtCreateManagedWidget("sizetoggle", 
                      xmToggleButtonWidgetClass, form, args, n);
    XmStringFree(tempStr);

    if (showPropFonts != ONLY_FIXED)
    {
        n = 0; 
        tempStr = XmStringCreate("Show Proportional Width Fonts", 
                                 XmSTRING_DEFAULT_CHARSET);
        XtSetArg(args[n], XmNlabelString, tempStr); n++;
        XtSetArg(args[n], XmNmnemonic, 'W'); n++;
        XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++; 
        XtSetArg(args[n], XmNtopAttachment, 
                        XmATTACH_OPPOSITE_WIDGET); n++; 
        XtSetArg(args[n], XmNbottomAttachment, 
                        XmATTACH_OPPOSITE_WIDGET); n++; 
        XtSetArg(args[n], XmNrightPosition, 98); n++; 
        XtSetArg(args[n], XmNtopWidget, sizeToggle); n++;
        XtSetArg(args[n], XmNbottomWidget, sizeToggle); n++;
        XtSetArg(args[n], XmNtopOffset, 1); n++;
        propFontToggle = XtCreateManagedWidget("propfonttoggle", 
                            xmToggleButtonWidgetClass, form, args, n);
        XmStringFree(tempStr);
    }

    /*  create scroll list widgets */
    /*  "Font" list */

    n = 0;
    tempStr = XmStringCreate("Font:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'F'); n++; 
    XtSetArg(args[n], XmNtopOffset, 2); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNleftPosition, 1); n++;
    nameLabel = XtCreateManagedWidget("Font:", xmLabelWidgetClass, form, 
                                      args, n);
    XmStringFree(tempStr);

    n = 0;
    XtSetArg(args[n], XmNvisibleItemCount, 15); n++;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomWidget, sizeToggle); n++;
    XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftWidget, nameLabel); n++;
    XtSetArg(args[n], XmNrightPosition, 52); n++;
    fontList = XmCreateScrolledList(form, "fontlist", args, n);
    AddMouseWheelSupport(fontList);
    XtManageChild(fontList);
    XtVaSetValues(nameLabel, XmNuserData, fontList, NULL);

    /* "Style" list */

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(fontList)); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(fontList)); n++;
    XtSetArg(args[n], XmNrightPosition, 85); n++;
    styleList = XmCreateScrolledList(form, "stylelist", args, n);
    AddMouseWheelSupport(styleList);
    XtManageChild(styleList);

    n = 0;
    tempStr = XmStringCreate("Style:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNmnemonic, 'y'); n++; 
    XtSetArg(args[n], XmNuserData, styleList); n++;
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(styleList)); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(styleList)); n++;
    XtCreateManagedWidget("Style:", xmLabelWidgetClass, form, args, n);
    XmStringFree(tempStr);

    /*  "Size" list */

    n = 0;
    XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNrightAttachment, XmATTACH_POSITION); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNtopWidget, nameLabel); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(styleList)); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(fontList)); n++;
    XtSetArg(args[n], XmNleftOffset, 5); n++;
    XtSetArg(args[n], XmNrightPosition, 99); n++;
    sizeList = XmCreateScrolledList(form, "sizelist", args, n);
    AddMouseWheelSupport(sizeList);
    XtManageChild(sizeList);

    n = 0;
    tempStr = XmStringCreate("Size:", XmSTRING_DEFAULT_CHARSET);
    XtSetArg(args[n], XmNlabelString, tempStr); n++;
    XtSetArg(args[n], XmNmnemonic, 'z'); n++; 
    XtSetArg(args[n], XmNuserData, sizeList); n++;
    XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++;
    XtSetArg(args[n], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
    XtSetArg(args[n], XmNbottomWidget, XtParent(sizeList)); n++;
    XtSetArg(args[n], XmNleftWidget, XtParent(sizeList)); n++;
    XtCreateManagedWidget("Size:", xmLabelWidgetClass, form, args, n);
    XmStringFree(tempStr);

    /*  update form widgets cancel button */

    n = 0;
    XtSetArg(args[n], XmNcancelButton, cancelButton); n++;
    XtSetValues(form, args, n);


    /*  update application's control block structure */

    ctrlBlk.form            = form;
    ctrlBlk.okButton        = okButton;
    ctrlBlk.cancelButton    = cancelButton;
    ctrlBlk.fontList        = fontList;
    ctrlBlk.styleList       = styleList;
    ctrlBlk.sizeList        = sizeList;
    ctrlBlk.fontNameField   = fontName;
    ctrlBlk.sizeToggle      = sizeToggle;
    if (showPropFonts != ONLY_FIXED)
        ctrlBlk.propFontToggle  = propFontToggle;
    ctrlBlk.dispField       = dispField;
    ctrlBlk.exitFlag        = FALSE;
    ctrlBlk.destroyedFlag   = FALSE;
    ctrlBlk.showPropFonts   = showPropFonts;
    ctrlBlk.showSizeInPixels = TRUE;
    ctrlBlk.sel1            = NULL;
    ctrlBlk.sel2            = NULL;
    ctrlBlk.sel3            = NULL;
    ctrlBlk.fontName        = NULL;

    setupScrollLists(NONE, ctrlBlk);    /* update scroll lists */ 

    if (showPropFonts == PREF_PROP)
        XmToggleButtonSetState(propFontToggle, TRUE, FALSE); 
        
    /*  Register callback functions */

    if (showPropFonts != ONLY_FIXED)
        XtAddCallback(propFontToggle, XmNvalueChangedCallback, 
                (XtCallbackProc)propFontToggleAction, (char *)&ctrlBlk);
    XtAddCallback(sizeToggle, XmNvalueChangedCallback,
            (XtCallbackProc)sizeToggleAction, (char *)&ctrlBlk);
    XtAddCallback(fontList, XmNbrowseSelectionCallback,
            (XtCallbackProc)fontAction, (char *)&ctrlBlk);
    XtAddCallback(styleList, XmNbrowseSelectionCallback,
            (XtCallbackProc)styleAction, (char *)&ctrlBlk);
    XtAddCallback(sizeList, XmNbrowseSelectionCallback,
            (XtCallbackProc)sizeAction, (char *)&ctrlBlk);
    XtAddCallback(okButton, XmNactivateCallback,
            (XtCallbackProc)okAction, (char *)&ctrlBlk);
    XtAddCallback(cancelButton, XmNactivateCallback,
            (XtCallbackProc)cancelAction, (char *)&ctrlBlk);

    /* add event handler to setup input focus at start to scroll list */

    XtAddEventHandler(fontList, FocusChangeMask, FALSE,
            (XtEventHandler)setFocus, (char *)&ctrlBlk);
    XmProcessTraversal(fontList, XmTRAVERSE_CURRENT);

    /*  setup tabgroups */

    XmAddTabGroup(fontList);
    XmAddTabGroup(styleList);
    XmAddTabGroup(sizeList);
    XmAddTabGroup(sizeToggle);
    if (showPropFonts != ONLY_FIXED)
        XmAddTabGroup(propFontToggle);
    XmAddTabGroup(fontName);
    XmAddTabGroup(okButton);
    XmAddTabGroup(cancelButton);

    /* Make sure that we don't try to access the dialog if the user
       destroyed it (possibly indirectly, by destroying the parent). */
    XtAddCallback(dialog, XmNdestroyCallback,
            (XtCallbackProc)destroyCB, (char *)&ctrlBlk);
        
    /*  Link Motif Close option to cancel action */

    AddMotifCloseCallback(dialog, (XtCallbackProc)cancelAction, &ctrlBlk);

    /*  Handle dialog mnemonics  */

    AddDialogMnemonicHandler(form, FALSE);

    /*  Realize Widgets  */

    ManageDialogCenteredOnPointer(form);

    /* set up current font parameters */

    if (currFont[0] != '\0')
        startupFont(&ctrlBlk, currFont); 

    /* Make sure that we can still access the display in case the form
       gets destroyed */
    theDisplay = XtDisplay(form);

    /*  enter event loop */

    while (! ctrlBlk.exitFlag && ! ctrlBlk.destroyedFlag)
        XtAppProcessEvent(XtWidgetToApplicationContext(form), XtIMAll);

    if (! ctrlBlk.destroyedFlag) {
        /* Don't let the callback destroy the font name */
        XtRemoveCallback(dialog, XmNdestroyCallback,
                (XtCallbackProc)destroyCB, (char *)&ctrlBlk);
        XtDestroyWidget(dialog);
    }

    if (ctrlBlk.oldFont != NULL)
    {
        XFreeFont(theDisplay, ctrlBlk.oldFont);
        XmFontListFree(ctrlBlk.oldFontList);
    }

    return(ctrlBlk.fontName);
}