2 * figinset.C - part of LyX project
5 extern int reverse_video;
6 extern long int background_pixels;
8 /* Rework of path-handling (Matthias 04.07.1996 )
9 * ------------------------------------------------
10 * figinsets keep an absolute path to the eps-file.
11 * For the user alway a relative path appears
12 * (in lyx-file, latex-file and edit-popup).
13 * To calculate this relative path the path to the
14 * document where the figinset is in is needed.
15 * This is done by a reference to the buffer, called
16 * figinset::cbuffer. To be up to date the cbuffer
17 * is sometimes set to the current buffer
18 * bufferlist.current(), when it can be assumed that
19 * this operation happens in the current buffer.
20 * This is true for InsetFig::Edit(...),
21 * InsetFig::InsetFig(...), InsetFig::Read(...),
22 * InsetFig::Write and InsetFig::Latex(...).
23 * Therefore the bufferlist has to make sure that
24 * during these operations bufferlist.current()
25 * returns the buffer where the figinsets are in.
26 * This made few changes in buffer.C necessary.
28 * The above is not totally valid anymore. (Lgb)
38 #include FORMS_H_LOCATION
49 #include "filetools.h"
50 #include "LyXView.h" // just because of form_main
53 #include "LaTeXFeatures.h"
56 #include "lyx_gui_misc.h" // CancelCloseBoxCB
59 // $Id: figinset.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $
61 #if !defined(lint) && !defined(WITH_WARNINGS)
62 static char vcid[] = "$Id: figinset.C,v 1.1 1999/09/27 18:44:38 larsbj Exp $";
65 extern BufferView *current_view;
66 static volatile bool alarmed;
68 extern FL_OBJECT *figinset_canvas;
75 extern char **environ; // is this only redundtant on linux systems? Lgb.
76 extern void UpdateInset(Inset* inset, bool mark_dirty = true);
77 // better for asyncron updating:
78 void PutInsetIntoInsetUpdateList(Inset* inset);
79 extern void ProhibitInput();
80 extern void AllowInput();
82 #define DEG2PI 57.295779513
83 #define figallocchunk 32
85 static int figinsref = 0; /* number of figures */
86 static int figarrsize = 0; /* current max number of figures */
87 static int bmpinsref = 0; /* number of bitmaps */
88 static int bmparrsize = 0; /* current max number of bitmaps */
91 float rx, ry; /* resolution x and y */
92 int ofsx, ofsy; /* x and y translation */
93 figdata *data; /* we are doing it for this data */
94 queue *next; /* next item in queue */
98 int pid; /* pid to wait for */
99 pidwait *next; /* next */
102 #define MAXGS 3 /* maximum 3 gs's at a time */
104 static Figref **figures; /* all the figures */
105 static figdata **bitmaps; /* all the bitmaps */
106 static queue *gsqueue = NULL; /* queue for ghostscripting */
107 static int gsrunning = 0; /* currently so many gs's are running */
108 static bool bitmap_waiting = false; /* bitmaps are waiting finished */
109 static char bittable[256]; /* bit reversion table */
111 static bool gs_color; // do we allocate colors for gs?
112 static bool color_visual; // is the visual color?
113 static bool gs_xcolor = false; // allocated extended colors
114 static unsigned long gs_pixels[128]; // allocated pixels
115 static int gs_num_pixels; // number of pixels allocated
116 static int gs_spc; // shades per color
117 static bool gs_gray; // is grayscale?
118 static int gs_allcolors; // number of all colors
120 static pidwait *pw = NULL; // pid wait list
123 extern FD_form_main *fd_form_main;
124 extern Colormap color_map;
126 void addpidwait(int pid)
128 // adds pid to pid wait list
129 register pidwait *p = new pidwait;
135 if (lyxerr.debugging()) {
136 lyxerr.print(LString("Pids to wait for: ") + int(p->pid));
139 lyxerr.print(LString() + int(p->pid));
145 int GhostscriptMsg(FL_OBJECT *, Window, int, int,
151 XClientMessageEvent *e = (XClientMessageEvent*) ev;
153 if(lyxerr.debugging()) {
155 "ClientMessage, win:[xx] gs:[%ld] pm:[%ld]\n",
156 e->data.l[0], e->data.l[1]);
159 // just kill gs, that way it will work for sure
160 for (i = 0; i < bmpinsref; ++i)
161 if ((long)bitmaps[i]->bitmap == (long)e->data.l[1]) {
163 figdata *p = bitmaps[i];
166 // first update p->bitmap, if necessary
167 if (p->bitmap != None && p->flags > (1|8) && gs_color && p->wid) {
168 // query current colormap and re-render
169 // the pixmap with proper colors
171 XWindowAttributes wa;
173 int i, y, wid1, spc1 = gs_spc-1,
174 spc2 = gs_spc*gs_spc, wid = p->wid,
177 GC gc = getGC(gc_copy);
179 XGetWindowAttributes(fl_display, fl_get_canvas_id(
180 figinset_canvas), &wa);
182 if (lyxerr.debugging()) {
184 "Starting image translation %ld %d %dx%d %d %d\n",
185 p->bitmap, p->flags, p->wid, p->hgh, wa.depth,
188 // now fork rendering process
190 if (forkstat == -1) {
191 lyxerr.debug("Cannot fork, using slow "
192 "method for pixmap translation.");
193 tmpdisp = fl_display;
194 } else if (forkstat > 0) {
196 if (lyxerr.debugging()) {
198 LString("Spawned child ")
201 addpidwait(forkstat);
202 break; // in parent process
204 tmpdisp = XOpenDisplay(XDisplayName(NULL));
207 im = XGetImage(tmpdisp, p->bitmap, 0, 0,
208 p->wid, p->hgh, (1<<wa.depth)-1, XYPixmap);
210 if (lyxerr.debugging()) {
211 lyxerr.print("Got the image");
214 if (lyxerr.debugging()) {
215 lyxerr.print("Error getting the image");
219 // query current colormap
220 cmap = (XColor *) malloc(gs_allcolors*sizeof(XColor));
221 for (i = 0; i < gs_allcolors; ++i) cmap[i].pixel = i;
222 XQueryColors(tmpdisp, color_map, cmap, gs_allcolors);
225 // now we process all the image
226 for (y = 0; y < p->hgh; ++y) {
228 for (x = 0; x < wid; ++x) {
230 pc = cmap + XGetPixel(im, x, y);
232 XPutPixel(im, x, y, gs_pixels[((pc->red+6553)*
233 spc1/65535)*spc2+((pc->green+6553)*
234 spc1/65535)*gs_spc+((pc->blue+6553)*
239 if (lyxerr.debugging()) {
240 lyxerr.print("Putting image back");
242 XPutImage(tmpdisp, p->bitmap, gc, im, 0, 0,
243 0, 0, p->wid, p->hgh);
245 if (lyxerr.debugging()) {
246 lyxerr.print("Done translation");
249 if (lyxerr.debugging()) {
250 lyxerr.print(LString("Killing gs ")
253 kill(p->gspid, SIGHUP);
255 sprintf(tmp, "%s/~lyxgs%d.ps",
256 system_tempdir.c_str(),
260 XCloseDisplay(tmpdisp);
264 if (lyxerr.debugging()) {
265 lyxerr.print(LString("Killing gs ")
268 kill(p->gspid, SIGHUP);
270 sprintf(tmp, "%s/~lyxgs%d.ps",
271 system_tempdir.c_str(),
281 static void AllocColors(int num)
282 // allocate color cube numxnumxnum, if possible
287 if (lyxerr.debugging()) {
288 printf("Allocating color cube %dx%dx%d\n", num, num, num);
292 lyxerr.print("Error allocating color colormap.");
296 if (num > 5) num = 5;
297 for (i = 0; i < num*num*num; ++i) {
298 xcol.red = 65535*(i/(num*num))/(num-1);
299 xcol.green = 65535*((i/num) % num)/(num-1);
300 xcol.blue = 65535*(i % num)/(num-1);
301 xcol.flags = DoRed | DoGreen | DoBlue;
302 if (!XAllocColor(fl_display, color_map, &xcol)) {
303 if (i) XFreeColors(fl_display, color_map,
305 if(lyxerr.debugging()) {
306 lyxerr.print(LString("Cannot allocate color cube " )
312 gs_pixels[i] = xcol.pixel;
317 gs_num_pixels = num*num*num;
321 static void AllocGrays(int num)
322 // allocate grayscale ramp
327 if (lyxerr.debugging()) {
328 lyxerr.print(LString("Allocating grayscale ramp ")
333 lyxerr.print("Error allocating grayscale colormap.");
337 if (num > 128) num = 128;
338 for (i = 0; i < num; ++i) {
339 xcol.red = xcol.green = xcol.blue = 65535*i/(num-1);
340 xcol.flags = DoRed | DoGreen | DoBlue;
341 if (!XAllocColor(fl_display, color_map, &xcol)) {
342 if (i) XFreeColors(fl_display, color_map,
344 if (lyxerr.debugging()) {
345 lyxerr.print(LString("Cannot allocate grayscale ")
351 gs_pixels[i] = xcol.pixel;
361 unsigned int i, j, k;
364 bmparrsize = figarrsize = figallocchunk;
365 figures = (Figref**) malloc(sizeof(Figref*)*figallocchunk);
366 bitmaps = (figdata**) malloc(sizeof(figdata*)*figallocchunk);
368 for (i = 0; i < 256; ++i) {
370 for (j = 0; j < 8; ++j)
371 if (i & (1 << (7-j))) k |= 1 << j;
372 bittable[i] = (char) ~k;
375 fl_add_canvas_handler(figinset_canvas, ClientMessage,
376 GhostscriptMsg, fd_form_main);
378 // now we have to init color_map
379 if (!color_map) color_map = DefaultColormap(fl_display,
380 DefaultScreen(fl_display));
381 // allocate color cube on pseudo-color display
385 vi = DefaultVisual(fl_display, DefaultScreen(fl_display));
386 if (lyxerr.debugging()) {
387 printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
388 vi->visualid, vi->c_class,
389 vi->bits_per_rgb, vi->map_entries);
391 color_visual = ( (vi->c_class == StaticColor) ||
392 (vi->c_class == PseudoColor) ||
393 (vi->c_class == TrueColor) ||
394 (vi->c_class == DirectColor) );
395 if ((vi->c_class & 1) == 0) return;
396 // now allocate colors
397 if (vi->c_class == GrayScale) {
398 // allocate grayscale
399 AllocGrays(vi->map_entries/2);
401 // allocate normal color
403 while (i*i*i*2 > vi->map_entries) --i;
406 gs_allcolors = vi->map_entries;
417 lyxerr.debug("Unregistering figures...");
419 fl_remove_canvas_handler(figinset_canvas, ClientMessage,
423 lyxerr.debug("Freeing up the colors...");
424 XFreeColors(fl_display, color_map, gs_pixels,
426 /******????????????????? what's planes in this case ??????***/
431 int FindBmpIndex(figdata *tmpdata)
434 while (i < bmpinsref) {
435 if (bitmaps[i] == tmpdata) return i;
442 static void chpixmap(Pixmap, int, int)
444 Display* tempdisp = XOpenDisplay(XDisplayName(NULL));
446 // here read the pixmap and change all colors to those we
449 XCloseDisplay(tempdisp);
453 static void freefigdata(figdata *tmpdata)
458 if (tmpdata->ref) return;
460 if (tmpdata->gspid > 0) {
461 int pid = tmpdata->gspid;
463 // change Pixmap according to our allocated colormap
464 chpixmap(tmpdata->bitmap, tmpdata->wid, tmpdata->hgh);
465 // kill ghostscript and unlink it's files
468 sprintf(buf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), pid);
472 if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
474 i = FindBmpIndex(tmpdata);
476 while (i < bmpinsref) {
477 bitmaps[i] = bitmaps[i+1];
483 static void runqueue()
485 // run queued requests for ghostscript, if any
486 if (!gsrunning && gs_color && !gs_xcolor) {
487 // here alloc all colors, so that gs will use only
488 // those we allocated for it
493 while (gsrunning < MAXGS) {
496 char tbuf[384], tbuf2[80];
501 if (!gsrunning && gs_xcolor) {
502 // de-allocate rest of colors
518 if (lyxerr.debugging()) {
519 lyxerr.print("GS start error! Cannot fork.");
521 p->data->broken = true;
522 p->data->reading = false;
525 if (pid == 0) { // child
526 char **env, rbuf[80], gbuf[40];
528 Display* tempdisp = XOpenDisplay(XDisplayName(NULL));
530 // create translation file
531 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
534 FilePtr f(tbuf, FilePtr::write);
535 fprintf(f, "gsave clippath pathbbox grestore\n"
537 "/ury exch def /urx exch def /lly exch def "
543 "%d %d translate\nend\n",
544 p->data->wid / 2.0, p->data->hgh / 2.0,
546 - (p->data->raw_wid / 2.0), -(p->data->raw_hgh / 2.0),
547 p->rx / 72.0, p->ry / 72.0,
551 // DON'T EVER remove this!!
552 f.close(); // was this all? (Lgb)
554 // gs process - set ghostview environment first
555 sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
556 figinset_canvas), p->data->bitmap);
558 // now set up ghostview property on a window
559 sprintf(tbuf, "0 0 0 0 %d %d 72 72 0 0 0 0",
560 p->data->wid, p->data->hgh);
561 //#warning BUG seems that the only bug here might be the hardcoded dpi.. Bummer!
563 if (lyxerr.debugging()) {
564 lyxerr.print(LString("Will set GHOSTVIEW"
568 // wait until property is deleted if executing multiple
571 // grab server to prevent other child interfering
572 // with setting GHOSTVIEW property
573 if (lyxerr.debugging()) {
574 lyxerr.print("Grabbing the server");
576 XGrabServer(tempdisp);
577 prop = XListProperties(tempdisp, fl_get_canvas_id(
578 figinset_canvas), &nprop);
582 for (i = 0; i < nprop; ++i) {
583 char *p = XGetAtomName(tempdisp, prop[i]);
584 if (strcmp(p, "GHOSTVIEW") == 0) {
590 XFree((char *)prop); /* jc: */
592 // release the server
593 XUngrabServer(tempdisp);
595 // ok, property found, we must wait until ghostscript
597 if (lyxerr.debugging()) {
598 lyxerr.print("Releasing the server");
599 lyxerr.print(LString('[') +
601 "] GHOSTVIEW property"
605 #warning What is this doing? (wouldn't a sleep(1); work too?')
609 signal(SIGALRM, waitalarm);
610 while (!alarmed) pause();
613 XChangeProperty(tempdisp,
614 fl_get_canvas_id(figinset_canvas),
615 XInternAtom(tempdisp, "GHOSTVIEW", false),
616 XInternAtom(tempdisp, "STRING", false),
618 (unsigned char *) tbuf,
621 switch (p->data->flags & 3) {
622 case 0: tbuf[0] = 'H'; break; // Hidden
623 case 1: tbuf[0] = 'M'; break; // Mono
624 case 2: tbuf[0] = 'G'; break; // Gray
627 tbuf[0] = 'C'; // Color
629 tbuf[0] = 'G'; // Gray
634 sprintf(tbuf+1, " %ld %ld", WhitePixelOfScreen(
635 DefaultScreenOfDisplay(fl_display)),
638 sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
639 DefaultScreenOfDisplay(fl_display)),
643 XChangeProperty(tempdisp,
644 fl_get_canvas_id(figinset_canvas),
645 XInternAtom(tempdisp, "GHOSTVIEW_COLORS", false),
646 XInternAtom(tempdisp, "STRING", false),
648 (unsigned char *) tbuf,
650 XUngrabServer(tempdisp);
652 if (lyxerr.debugging()) {
653 lyxerr.print("Releasing the server");
655 XCloseDisplay(tempdisp);
657 // set up environment
658 while (environ[ne]) ++ne;
659 env = (char **) malloc(sizeof(char*)*(ne+2));
661 memcpy(&env[1], environ, sizeof(char*)*(ne+1));
664 // now make gs command
666 // close(1); do NOT close. If GS writes out
667 // errors it would hang. (Matthias 290596)
668 sprintf(rbuf, "-r%gx%g", p->rx, p->ry);
669 sprintf(gbuf, "-g%dx%d", p->data->wid, p->data->hgh);
670 // now chdir into dir with .eps file, to be on the safe
672 chdir(OnlyPath(p->data->fname).c_str());
673 // make temp file name
674 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
676 if (lyxerr.debugging()) {
677 printf("starting gs %s %s, pid: %d\n", tbuf,
678 p->data->fname.c_str(), int(getpid()));
681 int err = execlp(lyxrc->ps_command.c_str(),
682 lyxrc->ps_command.c_str(),
684 "-dNOPAUSE", "-dQUIET",
687 p->data->fname.c_str(),
688 "showpage.ps", "quit.ps", "-", NULL);
689 // if we are still there, an error occurred.
690 lyxerr.print(LString("Error executing ghostscript. ")
695 + tbuf + LString(' ')
699 // normal process (parent)
700 if (lyxerr.debugging()) {
701 lyxerr.print(LString("GS [") + int(pid) + "] started");
703 gsqueue = gsqueue->next;
705 p->data->gspid = pid;
711 static void addwait(int psx, int psy, int pswid, int pshgh, figdata *data)
713 // recompute the stuff and put in the queue
718 p->rx = ((float)data->raw_wid*72)/pswid;
719 p->ry = ((float)data->raw_hgh*72)/pshgh;
724 // now put into queue
726 if (!gsqueue) gsqueue = p;
728 while (p2->next) p2 = p2->next;
732 // if possible, run the queue
737 static figdata *getfigdata(int wid, int hgh, LString const & fname,
738 int psx, int psy, int pswid, int pshgh,
739 int raw_wid, int raw_hgh, float angle, char flags)
741 /* first search for an exact match with fname and width/height */
744 XWindowAttributes wa;
746 if (fname.empty()) return NULL;
748 while (i < bmpinsref) {
749 if (bitmaps[i]->wid == wid && bitmaps[i]->hgh == hgh &&
750 bitmaps[i]->flags == flags && bitmaps[i]->fname==fname &&
751 bitmaps[i]->angle == angle) {
757 /* not found -> create new record or return NULL if no record */
759 if (bmpinsref > bmparrsize) {
760 // allocate more space
761 bmparrsize += figallocchunk;
762 figdata **tmp = (figdata**) malloc(sizeof(figdata*)*bmparrsize);
763 memcpy(tmp, bitmaps, sizeof(figdata*)*(bmparrsize-figallocchunk));
768 bitmaps[bmpinsref-1] = p;
771 p->raw_wid = raw_wid;
772 p->raw_hgh = raw_hgh;
776 XGetWindowAttributes(fl_display, fl_get_canvas_id(
777 figinset_canvas), &wa);
779 if (lyxerr.debugging()) {
780 printf("Create pixmap disp:%d scr:%d w:%d h:%d depth:%d\n",
781 PTR_AS_INT(fl_display), DefaultScreen(fl_display),
790 p->bitmap = XCreatePixmap(fl_display, fl_get_canvas_id(
791 figinset_canvas), wid, hgh, wa.depth);
793 // initialize reading of .eps file with correct sizes and stuff
794 addwait(psx, psy, pswid, pshgh, p);
805 static void getbitmap(figdata *p)
811 static void makeupdatelist(figdata *p)
815 for (i = 0; i < figinsref; ++i) if (figures[i]->data == p) {
816 if (lyxerr.debugging()) {
817 printf("Updating inset %d\n",
818 PTR_AS_INT(figures[i]->inset));
820 //UpdateInset(figures[i]->inset);
821 // add inset figures[i]->inset into to_update list
822 PutInsetIntoInsetUpdateList(figures[i]->inset);
827 void sigchldchecker(pid_t pid, int *status)
832 bool pid_handled = false;
834 lyxerr.debug(LString("Got pid = ") + long (pid));
836 for (i = bmpinsref - 1; i >= 0; --i) {
837 if (bitmaps[i]->reading && pid == bitmaps[i]->gspid) {
838 lyxerr.debug("Found pid in bitmaps");
839 // now read the file and remove it from disk
842 if (bitmaps[i]->gsdone) *status = 0;
844 lyxerr.debug(LString("GS [") + int(pid) +
847 fprintf(stderr, "GS [%ld] error %d E:%d %d S:%d %d\n", long(pid),
848 *status, WIFEXITED(*status), WEXITSTATUS(*status),
849 WIFSIGNALED(*status), WTERMSIG(*status));
852 bitmap_waiting = true;
855 // remove temporary files
857 sprintf(tmp, "%s/~lyxgs%d.ps",
858 system_tempdir.c_str(),
864 makeupdatelist(bitmaps[i]);
871 lyxerr.debug("Checking pid in pidwait");
872 pidwait *p = pw, *prev = NULL;
875 lyxerr.debug("Found pid in pidwait");
876 lyxerr.debug(LString("Caught child pid of recompute routine ") + int(pid));
878 prev->next = p->next;
890 lyxerr.debug("waitpid error");
894 "The process or process group specified by pid "
895 "does not exist or is not a child of the cal-"
896 "ling process or can never be in the states "
897 "specified by options.");
901 "waitpid() was interrupted due to the receipt "
902 "of a signal sent by the calling process.");
906 "An invalid value was specified for options.");
909 lyxerr.print("Unknown error from waitpid");
912 } else if (pid == 0) {
913 lyxerr.print("waitpid nohang");
915 lyxerr.debug("normal exit from childhandler");
920 static void getbitmaps()
923 bitmap_waiting = false;
924 for (i = 0; i < bmpinsref; ++i)
925 if (bitmaps[i]->gspid > 0 && !bitmaps[i]->reading)
926 getbitmap(bitmaps[i]);
930 static void RegisterFigure(InsetFig *fi)
934 if (figinsref == 0) InitFigures();
937 if (figinsref > figarrsize) {
938 // allocate more space
939 figarrsize += figallocchunk;
940 Figref **tmp = (Figref**) malloc(sizeof(Figref*)*figarrsize);
941 memcpy(tmp, figures, sizeof(Figref*)*(figarrsize-figallocchunk));
948 figures[figinsref-1] = tmpfig;
951 if (lyxerr.debugging()) {
952 lyxerr.print(LString("Register Figure: buffer:[") +
953 long(current_view->currentBuffer()) + "]");
958 int FindFigIndex(Figref *tmpfig)
961 while (i < figinsref) {
962 if (figures[i] == tmpfig) return i;
969 static void UnregisterFigure(InsetFig *fi)
971 Figref *tmpfig = fi->figure;
974 if (tmpfig->data) freefigdata(tmpfig->data);
975 if (tmpfig->inset->form) {
976 if (tmpfig->inset->form->Figure->visible)
977 fl_hide_form(tmpfig->inset->form->Figure);
978 fl_free_form(tmpfig->inset->form->Figure);
979 free(tmpfig->inset->form);
980 tmpfig->inset->form = NULL;
982 i = FindFigIndex(tmpfig);
984 while (i < figinsref) {
985 figures[i] = figures[i+1];
990 if (figinsref == 0) DoneFigures();
994 static char* NextToken(FILE *myfile)
1000 if (!feof(myfile)) {
1001 token = new char[256];
1005 } while (!feof(myfile) && !isspace(c));
1007 token[i-1]='\0'; /* just the end of a command */
1013 InsetFig::InsetFig(int tmpx, int tmpy, Buffer *o)
1023 psubfigure = subfigure = false;
1024 xwid = xhgh = angle = 0;
1025 raw_wid = raw_hgh = 0;
1026 changedfname = false;
1027 RegisterFigure(this);
1031 InsetFig::~InsetFig()
1033 if (lyxerr.debugging()) {
1034 lyxerr.print("Figure destructor called");
1036 UnregisterFigure(this);
1040 int InsetFig::Ascent(LyXFont const&) const
1046 int InsetFig::Descent(LyXFont const&) const
1052 int InsetFig::Width(LyXFont const&) const
1058 void InsetFig::Draw(LyXFont font, LyXScreen &scr, int baseline, float &x)
1060 if (bitmap_waiting) getbitmaps();
1062 // I wish that I didn't have to use this
1063 // but the figinset code is so complicated so
1064 // I don't want to fiddle with it now.
1065 unsigned long pm = scr.getForeground();
1067 if (figure && figure->data && figure->data->bitmap &&
1068 !figure->data->reading && !figure->data->broken) {
1070 XCopyArea(fl_display, figure->data->bitmap, pm, getGC(gc_copy),
1071 0, 0, wid, hgh, int(x+1), baseline-hgh);
1073 if (flags & 4) XDrawRectangle(fl_display, pm, getGC(gc_copy),
1074 int(x), baseline - hgh - 1,
1079 XDrawRectangle(fl_display, pm, getGC(gc_copy),
1081 baseline - hgh - 1, wid+1, hgh+1);
1082 if (figure && figure->data) {
1083 if (figure->data->broken) msg = _("[render error]");
1084 else if (figure->data->reading) msg = _("[rendering ... ]");
1086 if (fname.empty()) msg = _("[no file]");
1087 else if ((flags & 3) == 0) msg = _("[not displayed]");
1088 else if (lyxrc->ps_command.empty()) msg = _("[no ghostscript]");
1090 if (!msg) msg = _("[unknown error]");
1092 font.setFamily (LyXFont::SANS_FAMILY);
1093 font.setSize (LyXFont::SIZE_FOOTNOTE);
1094 LString justname = OnlyFilename (fname);
1095 font.drawString(justname,pm,
1096 baseline - font.maxAscent() - 4,
1098 font.setSize (LyXFont::SIZE_TINY);
1099 font.drawText (msg, strlen(msg),pm,
1104 x += Width(font); // ?
1108 void InsetFig::Write(FILE *file)
1111 fprintf(file, "Figure size %d %d\n", wid, hgh);
1112 if (!fname.empty()) {
1113 LString buf1 = OnlyPath(owner->getFileName());
1114 LString fname2 = MakeRelPath(fname, buf1);
1115 fprintf(file, "file %s\n", fname2.c_str());
1117 if (!subcaption.empty())
1118 fprintf(file, "subcaption %s\n", subcaption.c_str());
1119 if (wtype) fprintf(file, "width %d %g\n", wtype, xwid);
1120 if (htype) fprintf(file, "height %d %g\n", htype, xhgh);
1121 if (angle != 0) fprintf(file, "angle %g\n", angle);
1122 fprintf(file, "flags %d\n", flags);
1123 if (subfigure) fprintf(file, "subfigure\n");
1127 void InsetFig::Read(LyXLex &lex)
1130 bool finished = false;
1132 while (lex.IsOK() && !finished) {
1135 LString const token = lex.GetString();
1136 lyxerr.debug("Token: " + token);
1140 else if (token == "\\end_inset") {
1142 } else if (token == "file") {
1144 buf = lex.GetString();
1145 LString buf1 = OnlyPath(owner->getFileName());
1146 fname = MakeAbsPath(buf, buf1);
1147 changedfname = true;
1149 } else if (token == "extra") {
1151 // kept for backwards compability. Delete in 0.13.x
1152 } else if (token == "subcaption") {
1154 subcaption = lex.GetString();
1155 } else if (token == "label") {
1157 // kept for backwards compability. Delete in 0.13.x
1158 } else if (token == "angle") {
1160 angle = lex.GetFloat();
1161 } else if (token == "size") {
1163 wid = lex.GetInteger();
1165 hgh = lex.GetInteger();
1166 } else if (token == "flags") {
1168 flags = pflags = lex.GetInteger();
1169 } else if (token == "subfigure") {
1170 subfigure = psubfigure = true;
1171 } else if (token == "width") {
1174 typ = lex.GetInteger();
1176 xwid = lex.GetFloat();
1178 case DEF: wtype = DEF; break;
1179 case CM: wtype = CM; break;
1180 case IN: wtype = IN; break;
1181 case PER_PAGE: wtype = PER_PAGE; break;
1182 case PER_COL: wtype = PER_COL; break;
1184 lyxerr.debug("Unknown type!");
1188 } else if (token == "height") {
1191 typ = lex.GetInteger();
1193 xhgh = lex.GetFloat();
1195 case DEF: htype = DEF; break;
1196 case CM: htype = CM; break;
1197 case IN: htype = IN; break;
1198 case PER_PAGE: htype = PER_PAGE; break;
1200 lyxerr.debug("Unknown type!");
1211 int InsetFig::Latex(FILE *file, signed char /* fragile*/ )
1214 if (!cmd.empty()) fprintf(file, "%s ", cmd.c_str());
1219 int InsetFig::Latex(LString &file, signed char /* fragile*/ )
1227 int InsetFig::Linuxdoc(LString &/*file*/)
1233 int InsetFig::DocBook(LString &file)
1235 LString figurename=fname;
1237 if(figurename.suffixIs(".eps"))
1238 figurename=figurename.substring(0,fname.length()-5);
1240 file += "@<graphic fileref=\"" + figurename + "\"></graphic>";
1245 void InsetFig::Validate(LaTeXFeatures &features) const
1247 features.graphics = true;
1248 if (subfigure) features.subfigure = true;
1252 unsigned char InsetFig::Editable() const
1258 bool InsetFig::Deletable() const
1264 void InsetFig::Edit(int, int)
1266 lyxerr.debug("Editing InsetFig.");
1269 // We should have RO-versions of the form instead.
1270 // The actual prevention of altering a readonly doc
1271 // is done in CallbackFig()
1272 if(current_view->currentBuffer()->isReadonly())
1276 form = create_form_Figure();
1277 fl_set_form_atclose(form->Figure, CancelCloseBoxCB, NULL);
1278 fl_set_object_return(form->Angle,FL_RETURN_ALWAYS);
1279 fl_set_object_return(form->Width,FL_RETURN_ALWAYS);
1280 fl_set_object_return(form->Height,FL_RETURN_ALWAYS);
1283 if (form->Figure->visible) {
1284 fl_raise_form(form->Figure);
1286 fl_show_form(form->Figure, FL_PLACE_MOUSE | FL_PLACE_SIZE,
1287 FL_FULLBORDER, _("Figure"));
1292 Inset *InsetFig::Clone()
1294 InsetFig *tmp = new InsetFig(100, 100, owner);
1296 if (lyxerr.debugging()) {
1297 fprintf(stderr, "Clone Figure: buffer:[%d], cbuffer:[xx]\n",
1298 PTR_AS_INT(current_view->currentBuffer()));
1303 tmp->raw_wid = raw_wid;
1304 tmp->raw_hgh = raw_hgh;
1309 tmp->pflags = pflags;
1310 tmp->subfigure = subfigure;
1311 tmp->psubfigure = psubfigure;
1319 if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
1320 // do not display if there is "do not display" chosen (Matthias 260696)
1321 tmp->figure->data = getfigdata(wid, hgh, fname, psx, psy,
1322 pswid, pshgh, raw_wid, raw_hgh,
1323 angle, flags & (3|8));
1324 } else tmp->figure->data = NULL;
1325 tmp->subcaption = subcaption;
1326 tmp->changedfname = false;
1333 Inset::Code InsetFig::LyxCode() const
1335 return Inset::GRAPHICS_CODE;
1339 void InsetFig::Regenerate()
1343 LString resizeW, resizeH;
1344 LString rotate, recmd;
1346 if (fname.empty()) {
1347 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1348 cmd += _("empty figure path");
1350 //if (form) fl_set_object_label(form->cmd, "");
1354 LString buf1 = OnlyPath(owner->getFileName());
1355 LString fname2 = MakeRelPath(fname, buf1);
1357 gcmd = "\\includegraphics{" + fname2 + '}';
1362 case CM:{// \resizebox*{h-length}{v-length}{text}
1364 sprintf(buf, "%g", xwid); // should find better
1371 sprintf(buf, "%g", xwid);
1378 sprintf(buf, "%g", xwid/100);
1380 resizeW += "\\textwidth";
1385 sprintf(buf, "%g", xwid/100);
1387 resizeW += "\\columnwidth";
1397 sprintf(buf, "%g", xhgh);
1404 sprintf(buf, "%g", xhgh);
1411 sprintf(buf, "%g", xhgh/100);
1413 resizeH += "\\textheight";
1417 // Doesn't occur; case exists to suppress compiler warnings.
1422 if (!resizeW.empty() || !resizeH.empty()) {
1423 recmd = "\\resizebox*{";
1424 if (!resizeW.empty())
1429 if (!resizeH.empty())
1439 sprintf(buf, "%g", angle);
1440 // \rotatebox{angle}{text}
1441 rotate = "\\rotatebox{";
1449 if (!rotate.empty()) cmdbuf += '}';
1450 if (!recmd.empty()) cmdbuf += '}';
1452 if (!subcaption.empty())
1453 cmdbuf = "\\subfigure[" + subcaption +
1454 "]{" + cmdbuf + "}";
1456 cmdbuf = "\\subfigure{" + cmdbuf + "}";
1461 //if (form) fl_set_object_label(form->cmd, cmd.c_str());
1465 void InsetFig::TempRegenerate()
1469 LString resizeW, resizeH;
1470 LString rotate, recmd;
1473 char const *tfname; // *textra;
1474 float tangle, txwid, txhgh;
1476 tfname = fl_get_input(form->EpsFile);
1477 tsubcap = fl_get_input(form->Subcaption);
1478 tangle = atof(fl_get_input(form->Angle));
1479 txwid = atof(fl_get_input(form->Width));
1480 txhgh = atof(fl_get_input(form->Height));
1482 if (!tfname || !*tfname) {
1483 //fl_set_object_label(form->cmd, "");
1484 //fl_redraw_object(form->cmd);
1485 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1486 cmd += _("empty figure path");
1491 LString buf1 = OnlyPath(owner->getFileName());
1492 LString fname2 = MakeRelPath(tfname, buf1);
1493 // \includegraphics*[<llx,lly>][<urx,ury>]{file}
1494 gcmd = "\\includegraphics{" + fname2 + '}';
1499 case CM: {// \resizebox*{h-length}{v-length}{text}
1501 sprintf(buf, "%g", txwid); // should find better
1508 sprintf(buf, "%g", txwid);
1515 sprintf(buf, "%g", txwid/100);
1517 resizeW += "\\textwidth";
1522 sprintf(buf, "%g", txwid/100);
1524 resizeW += "\\columnwidth";
1534 sprintf(buf, "%g", txhgh);
1541 sprintf(buf, "%g", txhgh);
1548 sprintf(buf, "%g", txhgh/100);
1550 resizeH += "\\textheight";
1554 // Doesn't occur; case exists to suppress compiler warnings.
1559 // \resizebox*{h-length}{v-length}{text}
1560 if (!resizeW.empty() || !resizeH.empty()) {
1561 recmd = "\\resizebox*{";
1562 if (!resizeW.empty())
1567 if (!resizeH.empty())
1576 sprintf(buf, "%g", tangle);
1577 // \rotatebox{angle}{text}
1578 rotate = "\\rotatebox{";
1586 if (!rotate.empty()) cmdbuf += '}';
1587 if (!recmd.empty()) cmdbuf += '}';
1588 if (psubfigure && !tsubcap.empty()) {
1589 cmdbuf = LString("\\subfigure{") + tsubcap
1590 + LString("}{") + cmdbuf + "}";
1594 //fl_set_object_label(form->cmd, cmdbuf.c_str());
1595 //fl_redraw_object(form->cmd);
1599 void InsetFig::Recompute()
1601 bool changed = changedfname;
1602 int newx, newy, nraw_x, nraw_y, frame_wid, frame_hgh;
1605 if (changed) GetPSSizes();
1607 sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
1608 cos_a = cos (angle / DEG2PI);
1609 frame_wid = (int) ceil (fabs(cos_a * pswid) + fabs(sin_a * pshgh));
1610 frame_hgh= (int) ceil (fabs(cos_a * pshgh) + fabs(sin_a * pswid));
1612 /* now recompute wid and hgh, and if that is changed, set changed */
1613 /* this depends on chosen size of the picture and its bbox */
1614 // This will be redone in 0.13 ... (hen)
1615 if (!fname.empty()) {
1616 // say, total width is 595 pts, as A4 in TeX, thats in 1/72" */
1624 newx = (int) (28.346*xwid);
1627 newx = (int) (72*xwid);
1629 case PER_PAGE: /* % of page */
1630 newx = (int) (5.95*xwid);
1632 case PER_COL: /* % of col */
1633 newx = (int) (2.975*xwid);
1637 if (wtype && frame_wid) newy = newx*frame_hgh/frame_wid;
1641 //fprintf(stderr, "This should not happen!\n");
1644 newy = (int) (28.346*xhgh);
1647 newy = (int) (72*xhgh);
1649 case PER_PAGE: /* % of page */
1650 newy = (int) (8.42*xhgh);
1653 // Doesn't occur; case exists to suppress
1654 // compiler warnings.
1657 if (htype && !wtype && frame_hgh) newx = newy*frame_wid/frame_hgh;
1666 nraw_x = (int) ((1.0 * pswid * newx)/frame_wid);
1671 nraw_y = (int) ((1.0 * pshgh * newy)/frame_hgh);
1673 // cannot be zero, actually, set it to some minimum, so its clickable
1674 if (newx < 5) newx = 5;
1675 if (newy < 5) newy = 5;
1677 if (newx != wid || newy != hgh ||
1678 nraw_x != raw_wid || nraw_y != raw_hgh ||
1679 flags != pflags || subfigure != psubfigure)
1687 subfigure = psubfigure;
1690 figdata *pf = figure->data;
1693 if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
1694 // do not display if there is "do not display"
1695 // chosen (Matthias 260696)
1696 figure->data = getfigdata(wid, hgh, fname,
1697 psx, psy, pswid, pshgh,
1699 angle, flags & (3|8));
1700 } else figure->data = NULL;
1702 // free the old data
1703 if (pf) freefigdata(pf);
1706 changedfname = false;
1710 void InsetFig::GetPSSizes()
1712 /* get %%BoundingBox: from postscript file */
1716 /* defaults to associated size
1717 * ..just in case the PS-file is not readable (Henner,24-Aug-97)
1724 if (fname.empty()) return;
1726 FilePtr f(fname, FilePtr::read);
1728 if (!f()) return; // file not found !!!!
1730 /* defaults to A4 page */
1736 lastchar = fgetc(f);
1740 lyxerr.debug("End of (E)PS file reached and"
1741 " no BoundingBox!");
1744 if (c == '%' && lastchar == '%') {
1747 if (strcmp(p, "EndComments") == 0) break;
1748 if (strcmp(p, "BoundingBox:") == 0) {
1749 float fpsx, fpsy, fpswid, fpshgh;
1750 if (fscanf(f, "%f %f %f %f", &fpsx, &fpsy,
1751 &fpswid, &fpshgh) == 4) {
1754 pswid = (int) fpswid;
1755 pshgh = (int) fpshgh;
1758 if (lyxerr.debugging()) {
1759 fprintf(stderr, "%%%%BoundingBox:"
1761 psx, psy, pswid, pshgh);
1778 void InsetFig::CallbackFig(long arg)
1783 if (lyxerr.debugging()) {
1784 printf("Figure callback, arg %ld\n", arg);
1790 case 12: /* width type */
1797 fl_deactivate_object(form->Width);
1802 fl_activate_object(form->Width);
1807 fl_activate_object(form->Width);
1812 fl_activate_object(form->Width);
1817 fl_activate_object(form->Width);
1820 lyxerr.debug("Unknown type!");
1827 case 22: /* height type */
1833 fl_deactivate_object(form->Height);
1838 fl_activate_object(form->Height);
1843 fl_activate_object(form->Height);
1848 fl_activate_object(form->Height);
1851 lyxerr.debug("Unknown type!");
1857 pflags = pflags & ~3; /* wysiwyg0 */
1860 pflags = (pflags & ~3) | 1; /* wysiwyg1 */
1863 pflags = (pflags & ~3) | 2; /* wysiwyg2 */
1866 pflags = (pflags & ~3) | 3; /* wysiwyg3 */
1869 pflags ^= 4; /* frame */
1872 pflags ^= 8; /* do translations */
1875 psubfigure = !psubfigure; /* This is a subfigure */
1878 regen = true; /* regenerate command */
1880 case 0: /* browse file */
1884 case 1: /* preview */
1885 p = fl_get_input(form->EpsFile);
1889 case 8: /* ok (apply and close) */
1890 if(!current_view->currentBuffer()->isReadonly())
1894 xwid = atof(fl_get_input(form->Width));
1895 xhgh = atof(fl_get_input(form->Height));
1896 angle = atof(fl_get_input(form->Angle));
1897 p = fl_get_input(form->EpsFile);
1899 LString buf1 = OnlyPath(owner->getFileName());
1900 fname = MakeAbsPath(p, buf1);
1901 changedfname = true;
1903 if (!fname.empty()) {
1904 changedfname = true;
1908 subcaption = fl_get_input(form->Subcaption);
1912 /* now update inset */
1913 if (lyxerr.debugging()) {
1914 fprintf(stderr, "Update: [%dx%d]\n", wid, hgh);
1918 fl_hide_form(form->Figure);
1919 fl_free_form(form->Figure);
1925 // The user has already been informed about RO in ::Edit
1926 if(arg == 7) // if 'Apply'
1929 case 9: /* cancel = restore and close */
1930 fl_hide_form(form->Figure);
1931 fl_free_form(form->Figure);
1937 if (regen) TempRegenerate();
1940 inline void DisableFigurePanel(FD_Figure * const form)
1942 fl_deactivate_object(form->EpsFile);
1943 fl_deactivate_object(form->Browse);
1944 fl_deactivate_object(form->Width);
1945 fl_deactivate_object(form->Height);
1946 fl_deactivate_object(form->Frame);
1947 fl_deactivate_object(form->Translations);
1948 fl_deactivate_object(form->Angle);
1949 fl_deactivate_object(form->HeightGrp);
1950 fl_deactivate_object(form->page2);
1951 fl_deactivate_object(form->Default2);
1952 fl_deactivate_object(form->cm2);
1953 fl_deactivate_object(form->in2);
1954 fl_deactivate_object(form->HeightLabel);
1955 fl_deactivate_object(form->WidthLabel);
1956 fl_deactivate_object(form->DisplayGrp);
1957 fl_deactivate_object(form->Wysiwyg3);
1958 fl_deactivate_object(form->Wysiwyg0);
1959 fl_deactivate_object(form->Wysiwyg2);
1960 fl_deactivate_object(form->Wysiwyg1);
1961 fl_deactivate_object(form->WidthGrp);
1962 fl_deactivate_object(form->Default1);
1963 fl_deactivate_object(form->cm1);
1964 fl_deactivate_object(form->in1);
1965 fl_deactivate_object(form->page1);
1966 fl_deactivate_object(form->column1);
1967 fl_deactivate_object(form->Subcaption);
1968 fl_deactivate_object(form->Subfigure);
1969 fl_deactivate_object (form->OkBtn);
1970 fl_deactivate_object (form->ApplyBtn);
1971 fl_set_object_lcol (form->OkBtn, FL_INACTIVE);
1972 fl_set_object_lcol (form->ApplyBtn, FL_INACTIVE);
1975 inline void EnableFigurePanel(FD_Figure * const form)
1977 fl_activate_object(form->EpsFile);
1978 fl_activate_object(form->Browse);
1979 fl_activate_object(form->Width);
1980 fl_activate_object(form->Height);
1981 fl_activate_object(form->Frame);
1982 fl_activate_object(form->Translations);
1983 fl_activate_object(form->Angle);
1984 fl_activate_object(form->HeightGrp);
1985 fl_activate_object(form->page2);
1986 fl_activate_object(form->Default2);
1987 fl_activate_object(form->cm2);
1988 fl_activate_object(form->in2);
1989 fl_activate_object(form->HeightLabel);
1990 fl_activate_object(form->WidthLabel);
1991 fl_activate_object(form->DisplayGrp);
1992 fl_activate_object(form->Wysiwyg3);
1993 fl_activate_object(form->Wysiwyg0);
1994 fl_activate_object(form->Wysiwyg2);
1995 fl_activate_object(form->Wysiwyg1);
1996 fl_activate_object(form->WidthGrp);
1997 fl_activate_object(form->Default1);
1998 fl_activate_object(form->cm1);
1999 fl_activate_object(form->in1);
2000 fl_activate_object(form->page1);
2001 fl_activate_object(form->column1);
2002 fl_activate_object(form->Subcaption);
2003 fl_activate_object(form->Subfigure);
2004 fl_activate_object (form->OkBtn);
2005 fl_activate_object (form->ApplyBtn);
2006 fl_set_object_lcol (form->OkBtn, FL_BLACK);
2007 fl_set_object_lcol (form->ApplyBtn, FL_BLACK);
2010 void InsetFig::RestoreForm()
2015 EnableFigurePanel(form);
2018 fl_set_button(form->Default1, (wtype == 0));
2019 fl_set_button(form->cm1, (wtype == 1));
2020 fl_set_button(form->in1, (wtype == 2));
2021 fl_set_button(form->page1, (wtype == 3));
2022 fl_set_button(form->column1, (wtype == 4));
2024 fl_deactivate_object(form->Width);
2026 fl_activate_object(form->Width);
2029 // enable and disable should be put here.
2031 fl_set_button(form->Default2, (htype == 0));
2032 fl_set_button(form->cm2, (htype == 1));
2033 fl_set_button(form->in2, (htype == 2));
2034 fl_set_button(form->page2, (htype == 3));
2035 // enable and disable should be put here.
2037 fl_deactivate_object(form->Height);
2039 fl_activate_object(form->Height);
2043 fl_set_button(form->Wysiwyg0, (pflags == 0));
2044 fl_set_button(form->Wysiwyg1, (pflags == 1));
2045 fl_set_button(form->Wysiwyg2, (pflags == 2));
2046 fl_set_button(form->Wysiwyg3, (pflags == 3));
2047 fl_set_button(form->Frame, ((flags & 4) != 0));
2048 fl_set_button(form->Translations, ((flags & 8) != 0));
2049 fl_set_button(form->Subfigure, (subfigure != 0));
2051 psubfigure = subfigure;
2052 sprintf(buf, "%g", xwid);
2053 fl_set_input(form->Width, buf);
2054 sprintf(buf, "%g", xhgh);
2055 fl_set_input(form->Height, buf);
2056 sprintf(buf, "%g", angle);
2057 fl_set_input(form->Angle, buf);
2058 if (!fname.empty()){
2059 LString buf1 = OnlyPath(owner->getFileName());
2060 LString fname2 = MakeRelPath(fname, buf1);
2061 fl_set_input(form->EpsFile, fname2.c_str());
2063 else fl_set_input(form->EpsFile, "");
2064 fl_set_input(form->Subcaption, subcaption.c_str());
2065 if(current_view->currentBuffer()->isReadonly())
2066 DisableFigurePanel(form);
2072 void InsetFig::Preview(char const *p)
2079 lyxerr.print("Cannot fork process!");
2084 return; // parent process
2087 LString buf1 = OnlyPath(owner->getFileName());
2088 LString buf2 = MakeAbsPath(p, buf1);
2090 lyxerr.print(LString("Error during rendering ") +
2091 int(execlp(lyxrc->view_pspic_command.c_str(),
2092 lyxrc->view_pspic_command.c_str(),
2099 void InsetFig::BrowseFile()
2101 LString buf, buf2, bufclip;
2102 static LString current_figure_path;
2103 static int once = 0;
2106 if (lyxerr.debugging()) {
2107 fprintf(stderr, "Filename: %s\n", owner->getFileName().c_str());
2109 LString p = fl_get_input(form->EpsFile);
2111 buf = MakeAbsPath(owner->getFileName());
2112 buf2 = OnlyPath(buf);
2114 buf = MakeAbsPath(p, buf2);
2115 buf = OnlyPath(buf);
2117 buf = OnlyPath(owner->getFileName().c_str());
2120 // Does user clipart directory exist?
2121 bufclip = AddName (user_lyxdir, "clipart");
2122 FileInfo fileInfo(bufclip);
2123 if (!(fileInfo.isOK() && fileInfo.isDir()))
2124 // No - bail out to system clipart directory
2125 bufclip = AddName (system_lyxdir, "clipart");
2128 fileDlg.SetButton(0, _("Clipart"), bufclip);
2129 fileDlg.SetButton(1, _("Document"), buf);
2135 p =fileDlg.Select(_("EPS Figure"), current_figure_path,
2138 p = fileDlg.Select(_("EPS Figure"), buf,
2143 if (p.empty()) return;
2145 buf = MakeRelPath(p, buf2);
2146 current_figure_path = OnlyPath(p);
2149 if (p.contains("#") || p.contains("~") || p.contains("$")
2150 || p.contains("%") || p.contains(" "))
2152 WriteAlert(_("Filename can't contain any of these characters:"), // xgettext:no-c-format
2153 _("space, '#', '~', '$' or '%'."));
2158 if (form) fl_set_input(form->EpsFile, buf.c_str());
2162 void GraphicsCB(FL_OBJECT *obj, long arg)
2164 /* obj->form contains the form */
2166 if (lyxerr.debugging()) {
2167 lyxerr.print(LString("GraphicsCB callback: ") + long(arg));
2170 /* find inset we were reacting to */
2171 for (int i = 0; i < figinsref; ++i)
2172 if (figures[i]->inset->form && figures[i]->inset->form->Figure
2175 if (lyxerr.debugging()) {
2176 lyxerr.print(LString("Calling back figure ")
2179 figures[i]->inset->CallbackFig(arg);
2185 void HideFiguresPopups()
2187 for (int i = 0; i < figinsref; ++i)
2188 if (figures[i]->inset->form
2189 && figures[i]->inset->form->Figure->visible) {
2190 if (lyxerr.debugging()) {
2191 lyxerr.print(LString("Hiding figure ")
2194 // hide and free the form
2195 figures[i]->inset->CallbackFig(9);