home *** CD-ROM | disk | FTP | other *** search
- /*
- * FIG : Facility for Interactive Generation of figures
- *
- * Added by Brian V. Smith
- *
- * %W% %G%
- */
- #include "fig.h"
- #include "const.h"
- #include "resources.h"
- #include "func.h"
- #include "psfonts.h" /* printer font names */
-
- /******************** global variables ***************************/
-
- extern int font_button; /* font number */
- extern char *font_menu_bits[];
- extern Pixmap font_menu_bitmaps[];
- extern struct _fstruct fontnames[]; /* font names */
-
- /* GLOBAL */
-
- int *font_sel; /* pointer to store font selected from popup */
- TOOL image_widget; /* which widget to store image of font in */
-
- /******************** local variables ***************************/
-
- static MENUITEM fontmenu_items[NUMFONTS];
-
- static Arg fontmenu_args[] =
- {
- { XtNvSpace, (XtArgVal) 1 },
- };
-
- extern void fontpane_select();
-
- static XtCallbackRec pane_callbacks[] =
- {
- { fontpane_select, NULL },
- { NULL, NULL },
- };
-
- static Arg main_pane_args[] =
- {
- /* 0 */ { XtNlabel, (XtArgVal)" " },
- /* 1 */ { XtNwidth, (XtArgVal) FONT_PANE_WIDTH },
- };
-
- static Arg pane_args[] =
- {
- /* 0 */ { XtNwidth, (XtArgVal) FONT_PANE_WIDTH },
- /* 1 */ { XtNheight, (XtArgVal) 20 },
- /* 2 */ { XtNcallback, (XtArgVal)pane_callbacks },
- /* 3 */ { XtNbitmap, (XtArgVal) NULL },
- /* 4 */ { XtNinternalWidth, (XtArgVal) 0 }, /* space between pixmap and edge */
- /* 5 */ { XtNinternalHeight, (XtArgVal) 0 },
- /* 6 */ { XtNresize, (XtArgVal) FALSE }, /* don't allow resize */
- };
-
- static Arg psfont_args[] =
- {
- /* 0 */ { XtNwidth, (XtArgVal) FONT_PANE_WIDTH },
- /* 1 */ { XtNheight, (XtArgVal) MSG_HEIGHT }, /* same height as message panel */
- /* 2 */ { XtNfromHoriz, (XtArgVal) NULL }, /* left side of main form */
- /* 3 */ { XtNhorizDistance, (XtArgVal) 1 },
- /* 4 */ { XtNfromVert, (XtArgVal) NULL },
- /* 5 */ { XtNvertDistance, (XtArgVal) -1 }, /* dist from canvas_sw window */
- /* 6 */ { XtNbitmap, (XtArgVal) NULL },
- /* 8 */ { XtNinternalWidth, (XtArgVal) 0 }, /* space between pixmap and edge */
- /* 8 */ { XtNinternalHeight, (XtArgVal) 0 },
- /* 9 */ { XtNleft, (XtArgVal) XtChainLeft },
- /*10 */ { XtNright, (XtArgVal) XtChainLeft },
- };
-
- static TOOL fontpanes;
- static TOOL fontpane[NUMFONTS];
-
- init_fontmenu(tool)
- TOOL tool;
- {
- TOOL title;
- register int i;
- register MENUITEM *mi;
- XtTranslations popdown_actions, pane_actions;
-
- fontmenu = XtCreatePopupShell("font_menu", overrideShellWidgetClass, tool,
- fontmenu_args, XtNumber(fontmenu_args));
- popdown_actions = XtParseTranslationTable(
- "<Btn1Up>:MenuPopdown()\n");
- XtOverrideTranslations(fontmenu, popdown_actions);
-
- fontpanes = XtCreateManagedWidget("menu", boxWidgetClass, fontmenu, fontmenu_args,
- XtNumber(fontmenu_args));
- pane_actions = XtParseTranslationTable(
- "<EnterWindow>:set()\n\
- <Btn1Up>:notify()unset()\n");
- for (i = 0; i < NUMFONTS; i++)
- {
- fontmenu_items[i].type = MENU_IMAGESTRING; /* put the fontnames in menu */
- fontmenu_items[i].label = fontnames[i].psfont;
- fontmenu_items[i].info = (caddr_t) i; /* index for font # */
- }
-
- main_pane_args[0].value = (XtArgVal)"Printer Fonts";
- title = XtCreateManagedWidget("title", labelWidgetClass,
- fontpanes, main_pane_args, XtNumber(main_pane_args));
-
- /* create the first pane */
- mi = &fontmenu_items[0];
- pane_callbacks[0].closure = (caddr_t)mi;
-
- fontpane[0] = XtCreateManagedWidget("pane", commandWidgetClass,
- fontpanes, pane_args, XtNumber(pane_args));
- XtOverrideTranslations(fontpane[0], pane_actions);
-
-
- for (i = 1; i < NUMFONTS; ++i)
- {
- mi = &fontmenu_items[i];
- pane_callbacks[0].closure = (caddr_t)mi;
- fontpane[i] = XtCreateManagedWidget("pane", commandWidgetClass,
- fontpanes, pane_args, XtNumber(pane_args));
- XtOverrideTranslations(fontpane[i], pane_actions);
- }
-
- /* Now set up the font indicator window */
-
- /* position */
- psfont_args[4].value = (XtArgVal)canvas_sw; /* just below the canvas window */
- psfont = XtCreateManagedWidget("font_indicator", labelWidgetClass, tool,
- psfont_args, XtNumber(psfont_args));
- return (1);
- }
-
- /* create the bitmaps for the font menu */
-
- setup_fontmenu()
- {
- register int i;
-
- /* Create the bitmaps */
-
- for (i=0; i<NUMFONTS; i++)
- font_menu_bitmaps[i] = XCreateBitmapFromData(tool_d,XtWindow(psfont),
- font_menu_bits[i], FONT_PANE_WIDTH, FONT_PANE_HEIGHT);
- psfont_args[6].value = (XtArgVal) font_menu_bitmaps[0];
- XtSetValues(psfont, &psfont_args[6], 1); /* show default font in window */
-
- /* Store the bitmaps in the menu panes */
- for (i=0; i< NUMFONTS; i++)
- {
- pane_args[3].value = (XtArgVal) font_menu_bitmaps[i];
- XtSetValues(fontpane[i], &pane_args[3], 1); /* bitmap */
- }
- }
-
- /* At this point (called from popup_fonts()), we have the font menu windows
- to work with so we can define the cursor */
-
- static int cursinit = 0;
-
- setup_fontmenu_cursor()
- {
- if (cursinit) /* already defined */
- return;
- cursinit = 1;
- /* Define the cursor for the main menu form */
- XDefineCursor(tool_d, XtWindow(fontpanes), (Cursor)arrow_cursor.bitmap);
- }
-
- void fontpane_select(widget, mi)
- TOOL widget;
- MENUITEM *mi;
- {
- char * font_name = mi->label;
- Arg args[1];
-
- *font_sel = (int) mi->info; /* set current font to one selected */
- put_msg("Font: %s",font_name);
- /* put image of font in indicator window */
- XtSetArg(args[0], XtNbitmap, font_menu_bitmaps[*font_sel]);
- XtSetValues(image_widget, args, ONE);
- XtPopdown(fontmenu);
- }
-