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 "support/filetools.h"
50 #include "LyXView.h" // just because of form_main
53 #include "LaTeXFeatures.h"
56 #include "lyx_gui_misc.h" // CancelCloseBoxCB
57 #include "support/FileInfo.h"
59 extern BufferView *current_view;
60 static volatile bool alarmed;
62 extern FL_OBJECT *figinset_canvas;
69 extern char **environ; // is this only redundtant on linux systems? Lgb.
70 extern void UpdateInset(Inset* inset, bool mark_dirty = true);
71 // better for asyncron updating:
72 void PutInsetIntoInsetUpdateList(Inset* inset);
73 extern void ProhibitInput();
74 extern void AllowInput();
76 #define DEG2PI 57.295779513
77 #define figallocchunk 32
79 static int figinsref = 0; /* number of figures */
80 static int figarrsize = 0; /* current max number of figures */
81 static int bmpinsref = 0; /* number of bitmaps */
82 static int bmparrsize = 0; /* current max number of bitmaps */
85 float rx, ry; /* resolution x and y */
86 int ofsx, ofsy; /* x and y translation */
87 figdata *data; /* we are doing it for this data */
88 queue *next; /* next item in queue */
92 int pid; /* pid to wait for */
93 pidwait *next; /* next */
96 #define MAXGS 3 /* maximum 3 gs's at a time */
98 static Figref **figures; /* all the figures */
99 static figdata **bitmaps; /* all the bitmaps */
100 static queue *gsqueue = 0; /* queue for ghostscripting */
101 static int gsrunning = 0; /* currently so many gs's are running */
102 static bool bitmap_waiting = false; /* bitmaps are waiting finished */
103 static char bittable[256]; /* bit reversion table */
105 static bool gs_color; // do we allocate colors for gs?
106 static bool color_visual; // is the visual color?
107 static bool gs_xcolor = false; // allocated extended colors
108 static unsigned long gs_pixels[128]; // allocated pixels
109 static int gs_num_pixels; // number of pixels allocated
110 static int gs_spc; // shades per color
111 static bool gs_gray; // is grayscale?
112 static int gs_allcolors; // number of all colors
114 static pidwait *pw = 0; // pid wait list
117 extern FD_form_main *fd_form_main;
118 extern Colormap color_map;
120 void addpidwait(int pid)
122 // adds pid to pid wait list
123 register pidwait *p = new pidwait;
129 if (lyxerr.debugging()) {
130 lyxerr.print(string("Pids to wait for: ") + tostr(p->pid));
133 lyxerr.print(string() + tostr(p->pid));
139 int GhostscriptMsg(FL_OBJECT *, Window, int, int,
145 XClientMessageEvent *e = (XClientMessageEvent*) ev;
147 if(lyxerr.debugging()) {
149 "ClientMessage, win:[xx] gs:[%ld] pm:[%ld]\n",
150 e->data.l[0], e->data.l[1]);
153 // just kill gs, that way it will work for sure
154 for (i = 0; i < bmpinsref; ++i)
155 if ((long)bitmaps[i]->bitmap == (long)e->data.l[1]) {
157 figdata *p = bitmaps[i];
160 // first update p->bitmap, if necessary
161 if (p->bitmap != None && p->flags > (1|8) && gs_color && p->wid) {
162 // query current colormap and re-render
163 // the pixmap with proper colors
165 XWindowAttributes wa;
167 int i, y, wid1, spc1 = gs_spc-1,
168 spc2 = gs_spc*gs_spc, wid = p->wid,
171 GC gc = getGC(gc_copy);
173 XGetWindowAttributes(fl_display, fl_get_canvas_id(
174 figinset_canvas), &wa);
176 if (lyxerr.debugging()) {
178 "Starting image translation %ld %d %dx%d %d %d\n",
179 p->bitmap, p->flags, p->wid, p->hgh, wa.depth,
182 // now fork rendering process
184 if (forkstat == -1) {
185 lyxerr.debug("Cannot fork, using slow "
186 "method for pixmap translation.");
187 tmpdisp = fl_display;
188 } else if (forkstat > 0) {
190 if (lyxerr.debugging()) {
192 string("Spawned child ")
195 addpidwait(forkstat);
196 break; // in parent process
198 tmpdisp = XOpenDisplay(XDisplayName(0));
201 im = XGetImage(tmpdisp, p->bitmap, 0, 0,
202 p->wid, p->hgh, (1<<wa.depth)-1, XYPixmap);
204 if (lyxerr.debugging()) {
205 lyxerr.print("Got the image");
208 if (lyxerr.debugging()) {
209 lyxerr.print("Error getting the image");
213 // query current colormap
214 cmap = (XColor *) malloc(gs_allcolors*sizeof(XColor));
215 for (i = 0; i < gs_allcolors; ++i) cmap[i].pixel = i;
216 XQueryColors(tmpdisp, color_map, cmap, gs_allcolors);
219 // now we process all the image
220 for (y = 0; y < p->hgh; ++y) {
222 for (x = 0; x < wid; ++x) {
224 pc = cmap + XGetPixel(im, x, y);
226 XPutPixel(im, x, y, gs_pixels[((pc->red+6553)*
227 spc1/65535)*spc2+((pc->green+6553)*
228 spc1/65535)*gs_spc+((pc->blue+6553)*
233 if (lyxerr.debugging()) {
234 lyxerr.print("Putting image back");
236 XPutImage(tmpdisp, p->bitmap, gc, im, 0, 0,
237 0, 0, p->wid, p->hgh);
239 if (lyxerr.debugging()) {
240 lyxerr.print("Done translation");
243 if (lyxerr.debugging()) {
244 lyxerr.print(string("Killing gs ")
247 kill(p->gspid, SIGHUP);
249 sprintf(tmp, "%s/~lyxgs%d.ps",
250 system_tempdir.c_str(),
254 XCloseDisplay(tmpdisp);
258 if (lyxerr.debugging()) {
259 lyxerr.print(string("Killing gs ")
262 kill(p->gspid, SIGHUP);
264 sprintf(tmp, "%s/~lyxgs%d.ps",
265 system_tempdir.c_str(),
275 static void AllocColors(int num)
276 // allocate color cube numxnumxnum, if possible
281 if (lyxerr.debugging()) {
282 printf("Allocating color cube %dx%dx%d\n", num, num, num);
286 lyxerr.print("Error allocating color colormap.");
290 if (num > 5) num = 5;
291 for (i = 0; i < num*num*num; ++i) {
292 xcol.red = 65535*(i/(num*num))/(num-1);
293 xcol.green = 65535*((i/num) % num)/(num-1);
294 xcol.blue = 65535*(i % num)/(num-1);
295 xcol.flags = DoRed | DoGreen | DoBlue;
296 if (!XAllocColor(fl_display, color_map, &xcol)) {
297 if (i) XFreeColors(fl_display, color_map,
299 if(lyxerr.debugging()) {
300 lyxerr.print(string("Cannot allocate color cube " )
306 gs_pixels[i] = xcol.pixel;
311 gs_num_pixels = num*num*num;
315 static void AllocGrays(int num)
316 // allocate grayscale ramp
321 if (lyxerr.debugging()) {
322 lyxerr.print(string("Allocating grayscale ramp ")
327 lyxerr.print("Error allocating grayscale colormap.");
331 if (num > 128) num = 128;
332 for (i = 0; i < num; ++i) {
333 xcol.red = xcol.green = xcol.blue = 65535*i/(num-1);
334 xcol.flags = DoRed | DoGreen | DoBlue;
335 if (!XAllocColor(fl_display, color_map, &xcol)) {
336 if (i) XFreeColors(fl_display, color_map,
338 if (lyxerr.debugging()) {
339 lyxerr.print(string("Cannot allocate grayscale ")
345 gs_pixels[i] = xcol.pixel;
355 unsigned int i, j, k;
358 bmparrsize = figarrsize = figallocchunk;
359 figures = (Figref**) malloc(sizeof(Figref*)*figallocchunk);
360 bitmaps = (figdata**) malloc(sizeof(figdata*)*figallocchunk);
362 for (i = 0; i < 256; ++i) {
364 for (j = 0; j < 8; ++j)
365 if (i & (1 << (7-j))) k |= 1 << j;
366 bittable[i] = (char) ~k;
369 fl_add_canvas_handler(figinset_canvas, ClientMessage,
370 GhostscriptMsg, fd_form_main);
372 // now we have to init color_map
373 if (!color_map) color_map = DefaultColormap(fl_display,
374 DefaultScreen(fl_display));
375 // allocate color cube on pseudo-color display
379 vi = DefaultVisual(fl_display, DefaultScreen(fl_display));
380 if (lyxerr.debugging()) {
381 printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
382 vi->visualid, vi->c_class,
383 vi->bits_per_rgb, vi->map_entries);
385 color_visual = ( (vi->c_class == StaticColor) ||
386 (vi->c_class == PseudoColor) ||
387 (vi->c_class == TrueColor) ||
388 (vi->c_class == DirectColor) );
389 if ((vi->c_class & 1) == 0) return;
390 // now allocate colors
391 if (vi->c_class == GrayScale) {
392 // allocate grayscale
393 AllocGrays(vi->map_entries/2);
395 // allocate normal color
397 while (i*i*i*2 > vi->map_entries) --i;
400 gs_allcolors = vi->map_entries;
411 lyxerr.debug("Unregistering figures...");
413 fl_remove_canvas_handler(figinset_canvas, ClientMessage,
417 lyxerr.debug("Freeing up the colors...");
418 XFreeColors(fl_display, color_map, gs_pixels,
420 /******????????????????? what's planes in this case ??????***/
425 int FindBmpIndex(figdata *tmpdata)
428 while (i < bmpinsref) {
429 if (bitmaps[i] == tmpdata) return i;
436 static void chpixmap(Pixmap, int, int)
438 Display* tempdisp = XOpenDisplay(XDisplayName(0));
440 // here read the pixmap and change all colors to those we
443 XCloseDisplay(tempdisp);
447 static void freefigdata(figdata *tmpdata)
452 if (tmpdata->ref) return;
454 if (tmpdata->gspid > 0) {
455 int pid = tmpdata->gspid;
457 // change Pixmap according to our allocated colormap
458 chpixmap(tmpdata->bitmap, tmpdata->wid, tmpdata->hgh);
459 // kill ghostscript and unlink it's files
462 sprintf(buf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), pid);
466 if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
468 i = FindBmpIndex(tmpdata);
470 while (i < bmpinsref) {
471 bitmaps[i] = bitmaps[i+1];
477 static void runqueue()
479 // run queued requests for ghostscript, if any
480 if (!gsrunning && gs_color && !gs_xcolor) {
481 // here alloc all colors, so that gs will use only
482 // those we allocated for it
487 while (gsrunning < MAXGS) {
490 char tbuf[384], tbuf2[80];
495 if (!gsrunning && gs_xcolor) {
496 // de-allocate rest of colors
512 if (lyxerr.debugging()) {
513 lyxerr.print("GS start error! Cannot fork.");
515 p->data->broken = true;
516 p->data->reading = false;
519 if (pid == 0) { // child
520 char **env, rbuf[80], gbuf[40];
522 Display* tempdisp = XOpenDisplay(XDisplayName(0));
524 // create translation file
525 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
528 FilePtr f(tbuf, FilePtr::write);
529 fprintf(f, "gsave clippath pathbbox grestore\n"
531 "/ury exch def /urx exch def /lly exch def "
537 "%d %d translate\nend\n",
538 p->data->wid / 2.0, p->data->hgh / 2.0,
540 - (p->data->raw_wid / 2.0), -(p->data->raw_hgh / 2.0),
541 p->rx / 72.0, p->ry / 72.0,
545 // DON'T EVER remove this!!
546 f.close(); // was this all? (Lgb)
548 // gs process - set ghostview environment first
549 sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
550 figinset_canvas), p->data->bitmap);
552 // now set up ghostview property on a window
553 sprintf(tbuf, "0 0 0 0 %d %d 72 72 0 0 0 0",
554 p->data->wid, p->data->hgh);
555 //#warning BUG seems that the only bug here might be the hardcoded dpi.. Bummer!
557 if (lyxerr.debugging()) {
558 lyxerr.print(string("Will set GHOSTVIEW"
562 // wait until property is deleted if executing multiple
565 // grab server to prevent other child interfering
566 // with setting GHOSTVIEW property
567 if (lyxerr.debugging()) {
568 lyxerr.print("Grabbing the server");
570 XGrabServer(tempdisp);
571 prop = XListProperties(tempdisp, fl_get_canvas_id(
572 figinset_canvas), &nprop);
576 for (i = 0; i < nprop; ++i) {
577 char *p = XGetAtomName(tempdisp, prop[i]);
578 if (strcmp(p, "GHOSTVIEW") == 0) {
584 XFree((char *)prop); /* jc: */
586 // release the server
587 XUngrabServer(tempdisp);
589 // ok, property found, we must wait until ghostscript
591 if (lyxerr.debugging()) {
592 lyxerr.print("Releasing the server");
593 lyxerr.print(string("[") +
595 "] GHOSTVIEW property"
599 #warning What is this doing? (wouldn't a sleep(1); work too?')
603 signal(SIGALRM, waitalarm);
604 while (!alarmed) pause();
607 XChangeProperty(tempdisp,
608 fl_get_canvas_id(figinset_canvas),
609 XInternAtom(tempdisp, "GHOSTVIEW", false),
610 XInternAtom(tempdisp, "STRING", false),
612 (unsigned char *) tbuf,
615 switch (p->data->flags & 3) {
616 case 0: tbuf[0] = 'H'; break; // Hidden
617 case 1: tbuf[0] = 'M'; break; // Mono
618 case 2: tbuf[0] = 'G'; break; // Gray
621 tbuf[0] = 'C'; // Color
623 tbuf[0] = 'G'; // Gray
628 sprintf(tbuf+1, " %ld %ld", WhitePixelOfScreen(
629 DefaultScreenOfDisplay(fl_display)),
632 sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
633 DefaultScreenOfDisplay(fl_display)),
637 XChangeProperty(tempdisp,
638 fl_get_canvas_id(figinset_canvas),
639 XInternAtom(tempdisp, "GHOSTVIEW_COLORS", false),
640 XInternAtom(tempdisp, "STRING", false),
642 (unsigned char *) tbuf,
644 XUngrabServer(tempdisp);
646 if (lyxerr.debugging()) {
647 lyxerr.print("Releasing the server");
649 XCloseDisplay(tempdisp);
651 // set up environment
652 while (environ[ne]) ++ne;
653 env = (char **) malloc(sizeof(char*)*(ne+2));
655 memcpy(&env[1], environ, sizeof(char*)*(ne+1));
658 // now make gs command
660 // close(1); do NOT close. If GS writes out
661 // errors it would hang. (Matthias 290596)
662 sprintf(rbuf, "-r%gx%g", p->rx, p->ry);
663 sprintf(gbuf, "-g%dx%d", p->data->wid, p->data->hgh);
664 // now chdir into dir with .eps file, to be on the safe
666 chdir(OnlyPath(p->data->fname).c_str());
667 // make temp file name
668 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
670 if (lyxerr.debugging()) {
671 printf("starting gs %s %s, pid: %d\n", tbuf,
672 p->data->fname.c_str(), int(getpid()));
675 int err = execlp(lyxrc->ps_command.c_str(),
676 lyxrc->ps_command.c_str(),
678 "-dNOPAUSE", "-dQUIET",
681 p->data->fname.c_str(),
682 "showpage.ps", "quit.ps", "-", 0);
683 // if we are still there, an error occurred.
684 lyxerr.print(string("Error executing ghostscript. ")
685 + "Code: " + tostr(err));
693 // normal process (parent)
694 if (lyxerr.debugging()) {
695 lyxerr.print(string("GS [") + tostr(pid) + "] started");
697 gsqueue = gsqueue->next;
699 p->data->gspid = pid;
705 static void addwait(int psx, int psy, int pswid, int pshgh, figdata *data)
707 // recompute the stuff and put in the queue
712 p->rx = ((float)data->raw_wid*72)/pswid;
713 p->ry = ((float)data->raw_hgh*72)/pshgh;
718 // now put into queue
720 if (!gsqueue) gsqueue = p;
722 while (p2->next) p2 = p2->next;
726 // if possible, run the queue
731 static figdata *getfigdata(int wid, int hgh, string const & fname,
732 int psx, int psy, int pswid, int pshgh,
733 int raw_wid, int raw_hgh, float angle, char flags)
735 /* first search for an exact match with fname and width/height */
738 XWindowAttributes wa;
740 if (fname.empty()) return 0;
742 while (i < bmpinsref) {
743 if (bitmaps[i]->wid == wid && bitmaps[i]->hgh == hgh &&
744 bitmaps[i]->flags == flags && bitmaps[i]->fname==fname &&
745 bitmaps[i]->angle == angle) {
751 /* not found -> create new record or return 0 if no record */
753 if (bmpinsref > bmparrsize) {
754 // allocate more space
755 bmparrsize += figallocchunk;
756 figdata **tmp = (figdata**) malloc(sizeof(figdata*)*bmparrsize);
757 memcpy(tmp, bitmaps, sizeof(figdata*)*(bmparrsize-figallocchunk));
762 bitmaps[bmpinsref-1] = p;
765 p->raw_wid = raw_wid;
766 p->raw_hgh = raw_hgh;
770 XGetWindowAttributes(fl_display, fl_get_canvas_id(
771 figinset_canvas), &wa);
773 if (lyxerr.debugging()) {
774 printf("Create pixmap disp:%d scr:%d w:%d h:%d depth:%d\n",
775 PTR_AS_INT(fl_display), DefaultScreen(fl_display),
784 p->bitmap = XCreatePixmap(fl_display, fl_get_canvas_id(
785 figinset_canvas), wid, hgh, wa.depth);
787 // initialize reading of .eps file with correct sizes and stuff
788 addwait(psx, psy, pswid, pshgh, p);
799 static void getbitmap(figdata *p)
805 static void makeupdatelist(figdata *p)
809 for (i = 0; i < figinsref; ++i) if (figures[i]->data == p) {
810 if (lyxerr.debugging()) {
811 printf("Updating inset %d\n",
812 PTR_AS_INT(figures[i]->inset));
814 //UpdateInset(figures[i]->inset);
815 // add inset figures[i]->inset into to_update list
816 PutInsetIntoInsetUpdateList(figures[i]->inset);
821 void sigchldchecker(pid_t pid, int *status)
826 bool pid_handled = false;
828 lyxerr.debug(string("Got pid = ") + tostr(pid));
830 for (i = bmpinsref - 1; i >= 0; --i) {
831 if (bitmaps[i]->reading && pid == bitmaps[i]->gspid) {
832 lyxerr.debug("Found pid in bitmaps");
833 // now read the file and remove it from disk
836 if (bitmaps[i]->gsdone) *status = 0;
838 lyxerr.debug(string("GS [") + tostr(pid) +
841 fprintf(stderr, "GS [%ld] error %d E:%d %d S:%d %d\n", long(pid),
842 *status, WIFEXITED(*status), WEXITSTATUS(*status),
843 WIFSIGNALED(*status), WTERMSIG(*status));
846 bitmap_waiting = true;
849 // remove temporary files
851 sprintf(tmp, "%s/~lyxgs%d.ps",
852 system_tempdir.c_str(),
858 makeupdatelist(bitmaps[i]);
865 lyxerr.debug("Checking pid in pidwait");
866 pidwait *p = pw, *prev = 0;
869 lyxerr.debug("Found pid in pidwait");
870 lyxerr.debug(string("Caught child pid of recompute routine ") + tostr(pid));
872 prev->next = p->next;
884 lyxerr.debug("waitpid error");
888 "The process or process group specified by pid "
889 "does not exist or is not a child of the cal-"
890 "ling process or can never be in the states "
891 "specified by options.");
895 "waitpid() was interrupted due to the receipt "
896 "of a signal sent by the calling process.");
900 "An invalid value was specified for options.");
903 lyxerr.print("Unknown error from waitpid");
906 } else if (pid == 0) {
907 lyxerr.print("waitpid nohang");
909 lyxerr.debug("normal exit from childhandler");
914 static void getbitmaps()
917 bitmap_waiting = false;
918 for (i = 0; i < bmpinsref; ++i)
919 if (bitmaps[i]->gspid > 0 && !bitmaps[i]->reading)
920 getbitmap(bitmaps[i]);
924 static void RegisterFigure(InsetFig *fi)
928 if (figinsref == 0) InitFigures();
931 if (figinsref > figarrsize) {
932 // allocate more space
933 figarrsize += figallocchunk;
934 Figref **tmp = (Figref**) malloc(sizeof(Figref*)*figarrsize);
935 memcpy(tmp, figures, sizeof(Figref*)*(figarrsize-figallocchunk));
942 figures[figinsref-1] = tmpfig;
945 if (lyxerr.debugging()) {
946 lyxerr.print(string("Register Figure: buffer:[") +
947 tostr(current_view->currentBuffer()) + "]");
952 int FindFigIndex(Figref *tmpfig)
955 while (i < figinsref) {
956 if (figures[i] == tmpfig) return i;
963 static void UnregisterFigure(InsetFig *fi)
965 Figref *tmpfig = fi->figure;
968 if (tmpfig->data) freefigdata(tmpfig->data);
969 if (tmpfig->inset->form) {
970 if (tmpfig->inset->form->Figure->visible)
971 fl_hide_form(tmpfig->inset->form->Figure);
972 fl_free_form(tmpfig->inset->form->Figure);
973 free(tmpfig->inset->form);
974 tmpfig->inset->form = 0;
976 i = FindFigIndex(tmpfig);
978 while (i < figinsref) {
979 figures[i] = figures[i+1];
984 if (figinsref == 0) DoneFigures();
988 static char* NextToken(FILE *myfile)
995 token = new char[256];
999 } while (!feof(myfile) && !isspace(c));
1001 token[i-1]='\0'; /* just the end of a command */
1007 InsetFig::InsetFig(int tmpx, int tmpy, Buffer *o)
1017 psubfigure = subfigure = false;
1018 xwid = xhgh = angle = 0;
1019 raw_wid = raw_hgh = 0;
1020 changedfname = false;
1021 RegisterFigure(this);
1025 InsetFig::~InsetFig()
1027 if (lyxerr.debugging()) {
1028 lyxerr.print("Figure destructor called");
1030 UnregisterFigure(this);
1034 int InsetFig::Ascent(LyXFont const&) const
1040 int InsetFig::Descent(LyXFont const&) const
1046 int InsetFig::Width(LyXFont const&) const
1052 void InsetFig::Draw(LyXFont font, LyXScreen &scr, int baseline, float &x)
1054 if (bitmap_waiting) getbitmaps();
1056 // I wish that I didn't have to use this
1057 // but the figinset code is so complicated so
1058 // I don't want to fiddle with it now.
1059 unsigned long pm = scr.getForeground();
1061 if (figure && figure->data && figure->data->bitmap &&
1062 !figure->data->reading && !figure->data->broken) {
1064 XCopyArea(fl_display, figure->data->bitmap, pm, getGC(gc_copy),
1065 0, 0, wid, hgh, int(x+1), baseline-hgh);
1067 if (flags & 4) XDrawRectangle(fl_display, pm, getGC(gc_copy),
1068 int(x), baseline - hgh - 1,
1073 XDrawRectangle(fl_display, pm, getGC(gc_copy),
1075 baseline - hgh - 1, wid+1, hgh+1);
1076 if (figure && figure->data) {
1077 if (figure->data->broken) msg = _("[render error]");
1078 else if (figure->data->reading) msg = _("[rendering ... ]");
1080 if (fname.empty()) msg = _("[no file]");
1081 else if ((flags & 3) == 0) msg = _("[not displayed]");
1082 else if (lyxrc->ps_command.empty()) msg = _("[no ghostscript]");
1084 if (!msg) msg = _("[unknown error]");
1086 font.setFamily (LyXFont::SANS_FAMILY);
1087 font.setSize (LyXFont::SIZE_FOOTNOTE);
1088 string justname = OnlyFilename (fname);
1089 font.drawString(justname,pm,
1090 baseline - font.maxAscent() - 4,
1092 font.setSize (LyXFont::SIZE_TINY);
1093 font.drawText (msg, strlen(msg),pm,
1098 x += Width(font); // ?
1102 void InsetFig::Write(FILE *file)
1105 fprintf(file, "Figure size %d %d\n", wid, hgh);
1106 if (!fname.empty()) {
1107 string buf1 = OnlyPath(owner->getFileName());
1108 string fname2 = MakeRelPath(fname, buf1);
1109 fprintf(file, "file %s\n", fname2.c_str());
1111 if (!subcaption.empty())
1112 fprintf(file, "subcaption %s\n", subcaption.c_str());
1113 if (wtype) fprintf(file, "width %d %g\n", wtype, xwid);
1114 if (htype) fprintf(file, "height %d %g\n", htype, xhgh);
1115 if (angle != 0) fprintf(file, "angle %g\n", angle);
1116 fprintf(file, "flags %d\n", flags);
1117 if (subfigure) fprintf(file, "subfigure\n");
1121 void InsetFig::Read(LyXLex &lex)
1124 bool finished = false;
1126 while (lex.IsOK() && !finished) {
1129 string const token = lex.GetString();
1130 lyxerr.debug("Token: " + token);
1134 else if (token == "\\end_inset") {
1136 } else if (token == "file") {
1138 buf = lex.GetString();
1139 string buf1 = OnlyPath(owner->getFileName());
1140 fname = MakeAbsPath(buf, buf1);
1141 changedfname = true;
1143 } else if (token == "extra") {
1145 // kept for backwards compability. Delete in 0.13.x
1146 } else if (token == "subcaption") {
1148 subcaption = lex.GetString();
1149 } else if (token == "label") {
1151 // kept for backwards compability. Delete in 0.13.x
1152 } else if (token == "angle") {
1154 angle = lex.GetFloat();
1155 } else if (token == "size") {
1157 wid = lex.GetInteger();
1159 hgh = lex.GetInteger();
1160 } else if (token == "flags") {
1162 flags = pflags = lex.GetInteger();
1163 } else if (token == "subfigure") {
1164 subfigure = psubfigure = true;
1165 } else if (token == "width") {
1168 typ = lex.GetInteger();
1170 xwid = lex.GetFloat();
1172 case DEF: wtype = DEF; break;
1173 case CM: wtype = CM; break;
1174 case IN: wtype = IN; break;
1175 case PER_PAGE: wtype = PER_PAGE; break;
1176 case PER_COL: wtype = PER_COL; break;
1178 lyxerr.debug("Unknown type!");
1182 } else if (token == "height") {
1185 typ = lex.GetInteger();
1187 xhgh = lex.GetFloat();
1189 case DEF: htype = DEF; break;
1190 case CM: htype = CM; break;
1191 case IN: htype = IN; break;
1192 case PER_PAGE: htype = PER_PAGE; break;
1194 lyxerr.debug("Unknown type!");
1205 int InsetFig::Latex(FILE *file, signed char /* fragile*/ )
1208 if (!cmd.empty()) fprintf(file, "%s ", cmd.c_str());
1213 int InsetFig::Latex(string &file, signed char /* fragile*/ )
1221 int InsetFig::Linuxdoc(string &/*file*/)
1227 int InsetFig::DocBook(string &file)
1229 string figurename=fname;
1231 if(suffixIs(figurename, ".eps"))
1232 figurename.erase(fname.length() - 5);
1234 file += "@<graphic fileref=\"" + figurename + "\"></graphic>";
1239 void InsetFig::Validate(LaTeXFeatures &features) const
1241 features.graphics = true;
1242 if (subfigure) features.subfigure = true;
1246 unsigned char InsetFig::Editable() const
1252 bool InsetFig::Deletable() const
1258 void InsetFig::Edit(int, int)
1260 lyxerr.debug("Editing InsetFig.");
1263 // We should have RO-versions of the form instead.
1264 // The actual prevention of altering a readonly doc
1265 // is done in CallbackFig()
1266 if(current_view->currentBuffer()->isReadonly())
1270 form = create_form_Figure();
1271 fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0);
1272 fl_set_object_return(form->Angle,FL_RETURN_ALWAYS);
1273 fl_set_object_return(form->Width,FL_RETURN_ALWAYS);
1274 fl_set_object_return(form->Height,FL_RETURN_ALWAYS);
1277 if (form->Figure->visible) {
1278 fl_raise_form(form->Figure);
1280 fl_show_form(form->Figure, FL_PLACE_MOUSE | FL_PLACE_SIZE,
1281 FL_FULLBORDER, _("Figure"));
1286 Inset *InsetFig::Clone()
1288 InsetFig *tmp = new InsetFig(100, 100, owner);
1290 if (lyxerr.debugging()) {
1291 fprintf(stderr, "Clone Figure: buffer:[%d], cbuffer:[xx]\n",
1292 PTR_AS_INT(current_view->currentBuffer()));
1297 tmp->raw_wid = raw_wid;
1298 tmp->raw_hgh = raw_hgh;
1303 tmp->pflags = pflags;
1304 tmp->subfigure = subfigure;
1305 tmp->psubfigure = psubfigure;
1313 if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
1314 // do not display if there is "do not display" chosen (Matthias 260696)
1315 tmp->figure->data = getfigdata(wid, hgh, fname, psx, psy,
1316 pswid, pshgh, raw_wid, raw_hgh,
1317 angle, flags & (3|8));
1318 } else tmp->figure->data = 0;
1319 tmp->subcaption = subcaption;
1320 tmp->changedfname = false;
1327 Inset::Code InsetFig::LyxCode() const
1329 return Inset::GRAPHICS_CODE;
1333 void InsetFig::Regenerate()
1337 string resizeW, resizeH;
1338 string rotate, recmd;
1340 if (fname.empty()) {
1341 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1342 cmd += _("empty figure path");
1344 //if (form) fl_set_object_label(form->cmd, "");
1348 string buf1 = OnlyPath(owner->getFileName());
1349 string fname2 = MakeRelPath(fname, buf1);
1351 gcmd = "\\includegraphics{" + fname2 + '}';
1356 case CM:{// \resizebox*{h-length}{v-length}{text}
1358 sprintf(buf, "%g", xwid); // should find better
1365 sprintf(buf, "%g", xwid);
1372 sprintf(buf, "%g", xwid/100);
1374 resizeW += "\\textwidth";
1379 sprintf(buf, "%g", xwid/100);
1381 resizeW += "\\columnwidth";
1391 sprintf(buf, "%g", xhgh);
1398 sprintf(buf, "%g", xhgh);
1405 sprintf(buf, "%g", xhgh/100);
1407 resizeH += "\\textheight";
1411 // Doesn't occur; case exists to suppress compiler warnings.
1416 if (!resizeW.empty() || !resizeH.empty()) {
1417 recmd = "\\resizebox*{";
1418 if (!resizeW.empty())
1423 if (!resizeH.empty())
1433 sprintf(buf, "%g", angle);
1434 // \rotatebox{angle}{text}
1435 rotate = "\\rotatebox{";
1443 if (!rotate.empty()) cmdbuf += '}';
1444 if (!recmd.empty()) cmdbuf += '}';
1446 if (!subcaption.empty())
1447 cmdbuf = "\\subfigure[" + subcaption +
1448 "]{" + cmdbuf + "}";
1450 cmdbuf = "\\subfigure{" + cmdbuf + "}";
1455 //if (form) fl_set_object_label(form->cmd, cmd.c_str());
1459 void InsetFig::TempRegenerate()
1463 string resizeW, resizeH;
1464 string rotate, recmd;
1467 char const *tfname; // *textra;
1468 float tangle, txwid, txhgh;
1470 tfname = fl_get_input(form->EpsFile);
1471 tsubcap = fl_get_input(form->Subcaption);
1472 tangle = atof(fl_get_input(form->Angle));
1473 txwid = atof(fl_get_input(form->Width));
1474 txhgh = atof(fl_get_input(form->Height));
1476 if (!tfname || !*tfname) {
1477 //fl_set_object_label(form->cmd, "");
1478 //fl_redraw_object(form->cmd);
1479 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1480 cmd += _("empty figure path");
1485 string buf1 = OnlyPath(owner->getFileName());
1486 string fname2 = MakeRelPath(tfname, buf1);
1487 // \includegraphics*[<llx,lly>][<urx,ury>]{file}
1488 gcmd = "\\includegraphics{" + fname2 + '}';
1493 case CM: {// \resizebox*{h-length}{v-length}{text}
1495 sprintf(buf, "%g", txwid); // should find better
1502 sprintf(buf, "%g", txwid);
1509 sprintf(buf, "%g", txwid/100);
1511 resizeW += "\\textwidth";
1516 sprintf(buf, "%g", txwid/100);
1518 resizeW += "\\columnwidth";
1528 sprintf(buf, "%g", txhgh);
1535 sprintf(buf, "%g", txhgh);
1542 sprintf(buf, "%g", txhgh/100);
1544 resizeH += "\\textheight";
1548 // Doesn't occur; case exists to suppress compiler warnings.
1553 // \resizebox*{h-length}{v-length}{text}
1554 if (!resizeW.empty() || !resizeH.empty()) {
1555 recmd = "\\resizebox*{";
1556 if (!resizeW.empty())
1561 if (!resizeH.empty())
1570 sprintf(buf, "%g", tangle);
1571 // \rotatebox{angle}{text}
1572 rotate = "\\rotatebox{";
1580 if (!rotate.empty()) cmdbuf += '}';
1581 if (!recmd.empty()) cmdbuf += '}';
1582 if (psubfigure && !tsubcap.empty()) {
1583 cmdbuf = string("\\subfigure{") + tsubcap
1584 + string("}{") + cmdbuf + "}";
1588 //fl_set_object_label(form->cmd, cmdbuf.c_str());
1589 //fl_redraw_object(form->cmd);
1593 void InsetFig::Recompute()
1595 bool changed = changedfname;
1596 int newx, newy, nraw_x, nraw_y, frame_wid, frame_hgh;
1599 if (changed) GetPSSizes();
1601 sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
1602 cos_a = cos (angle / DEG2PI);
1603 frame_wid = (int) ceil (fabs(cos_a * pswid) + fabs(sin_a * pshgh));
1604 frame_hgh= (int) ceil (fabs(cos_a * pshgh) + fabs(sin_a * pswid));
1606 /* now recompute wid and hgh, and if that is changed, set changed */
1607 /* this depends on chosen size of the picture and its bbox */
1608 // This will be redone in 0.13 ... (hen)
1609 if (!fname.empty()) {
1610 // say, total width is 595 pts, as A4 in TeX, thats in 1/72" */
1618 newx = (int) (28.346*xwid);
1621 newx = (int) (72*xwid);
1623 case PER_PAGE: /* % of page */
1624 newx = (int) (5.95*xwid);
1626 case PER_COL: /* % of col */
1627 newx = (int) (2.975*xwid);
1631 if (wtype && frame_wid) newy = newx*frame_hgh/frame_wid;
1635 //fprintf(stderr, "This should not happen!\n");
1638 newy = (int) (28.346*xhgh);
1641 newy = (int) (72*xhgh);
1643 case PER_PAGE: /* % of page */
1644 newy = (int) (8.42*xhgh);
1647 // Doesn't occur; case exists to suppress
1648 // compiler warnings.
1651 if (htype && !wtype && frame_hgh) newx = newy*frame_wid/frame_hgh;
1660 nraw_x = (int) ((1.0 * pswid * newx)/frame_wid);
1665 nraw_y = (int) ((1.0 * pshgh * newy)/frame_hgh);
1667 // cannot be zero, actually, set it to some minimum, so its clickable
1668 if (newx < 5) newx = 5;
1669 if (newy < 5) newy = 5;
1671 if (newx != wid || newy != hgh ||
1672 nraw_x != raw_wid || nraw_y != raw_hgh ||
1673 flags != pflags || subfigure != psubfigure)
1681 subfigure = psubfigure;
1684 figdata *pf = figure->data;
1687 if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
1688 // do not display if there is "do not display"
1689 // chosen (Matthias 260696)
1690 figure->data = getfigdata(wid, hgh, fname,
1691 psx, psy, pswid, pshgh,
1693 angle, flags & (3|8));
1694 } else figure->data = 0;
1696 // free the old data
1697 if (pf) freefigdata(pf);
1700 changedfname = false;
1704 void InsetFig::GetPSSizes()
1706 /* get %%BoundingBox: from postscript file */
1710 /* defaults to associated size
1711 * ..just in case the PS-file is not readable (Henner,24-Aug-97)
1718 if (fname.empty()) return;
1720 FilePtr f(fname, FilePtr::read);
1722 if (!f()) return; // file not found !!!!
1724 /* defaults to A4 page */
1730 lastchar = fgetc(f);
1734 lyxerr.debug("End of (E)PS file reached and"
1735 " no BoundingBox!");
1738 if (c == '%' && lastchar == '%') {
1741 if (strcmp(p, "EndComments") == 0) break;
1742 if (strcmp(p, "BoundingBox:") == 0) {
1743 float fpsx, fpsy, fpswid, fpshgh;
1744 if (fscanf(f, "%f %f %f %f", &fpsx, &fpsy,
1745 &fpswid, &fpshgh) == 4) {
1748 pswid = (int) fpswid;
1749 pshgh = (int) fpshgh;
1752 if (lyxerr.debugging()) {
1753 fprintf(stderr, "%%%%BoundingBox:"
1755 psx, psy, pswid, pshgh);
1772 void InsetFig::CallbackFig(long arg)
1777 if (lyxerr.debugging()) {
1778 printf("Figure callback, arg %ld\n", arg);
1784 case 12: /* width type */
1791 fl_deactivate_object(form->Width);
1796 fl_activate_object(form->Width);
1801 fl_activate_object(form->Width);
1806 fl_activate_object(form->Width);
1811 fl_activate_object(form->Width);
1814 lyxerr.debug("Unknown type!");
1821 case 22: /* height type */
1827 fl_deactivate_object(form->Height);
1832 fl_activate_object(form->Height);
1837 fl_activate_object(form->Height);
1842 fl_activate_object(form->Height);
1845 lyxerr.debug("Unknown type!");
1851 pflags = pflags & ~3; /* wysiwyg0 */
1854 pflags = (pflags & ~3) | 1; /* wysiwyg1 */
1857 pflags = (pflags & ~3) | 2; /* wysiwyg2 */
1860 pflags = (pflags & ~3) | 3; /* wysiwyg3 */
1863 pflags ^= 4; /* frame */
1866 pflags ^= 8; /* do translations */
1869 psubfigure = !psubfigure; /* This is a subfigure */
1872 regen = true; /* regenerate command */
1874 case 0: /* browse file */
1878 case 1: /* preview */
1879 p = fl_get_input(form->EpsFile);
1883 case 8: /* ok (apply and close) */
1884 if(!current_view->currentBuffer()->isReadonly())
1888 xwid = atof(fl_get_input(form->Width));
1889 xhgh = atof(fl_get_input(form->Height));
1890 angle = atof(fl_get_input(form->Angle));
1891 p = fl_get_input(form->EpsFile);
1893 string buf1 = OnlyPath(owner->getFileName());
1894 fname = MakeAbsPath(p, buf1);
1895 changedfname = true;
1897 if (!fname.empty()) {
1898 changedfname = true;
1902 subcaption = fl_get_input(form->Subcaption);
1906 /* now update inset */
1907 if (lyxerr.debugging()) {
1908 fprintf(stderr, "Update: [%dx%d]\n", wid, hgh);
1912 fl_hide_form(form->Figure);
1913 fl_free_form(form->Figure);
1919 // The user has already been informed about RO in ::Edit
1920 if(arg == 7) // if 'Apply'
1923 case 9: /* cancel = restore and close */
1924 fl_hide_form(form->Figure);
1925 fl_free_form(form->Figure);
1931 if (regen) TempRegenerate();
1934 inline void DisableFigurePanel(FD_Figure * const form)
1936 fl_deactivate_object(form->EpsFile);
1937 fl_deactivate_object(form->Browse);
1938 fl_deactivate_object(form->Width);
1939 fl_deactivate_object(form->Height);
1940 fl_deactivate_object(form->Frame);
1941 fl_deactivate_object(form->Translations);
1942 fl_deactivate_object(form->Angle);
1943 fl_deactivate_object(form->HeightGrp);
1944 fl_deactivate_object(form->page2);
1945 fl_deactivate_object(form->Default2);
1946 fl_deactivate_object(form->cm2);
1947 fl_deactivate_object(form->in2);
1948 fl_deactivate_object(form->HeightLabel);
1949 fl_deactivate_object(form->WidthLabel);
1950 fl_deactivate_object(form->DisplayGrp);
1951 fl_deactivate_object(form->Wysiwyg3);
1952 fl_deactivate_object(form->Wysiwyg0);
1953 fl_deactivate_object(form->Wysiwyg2);
1954 fl_deactivate_object(form->Wysiwyg1);
1955 fl_deactivate_object(form->WidthGrp);
1956 fl_deactivate_object(form->Default1);
1957 fl_deactivate_object(form->cm1);
1958 fl_deactivate_object(form->in1);
1959 fl_deactivate_object(form->page1);
1960 fl_deactivate_object(form->column1);
1961 fl_deactivate_object(form->Subcaption);
1962 fl_deactivate_object(form->Subfigure);
1963 fl_deactivate_object (form->OkBtn);
1964 fl_deactivate_object (form->ApplyBtn);
1965 fl_set_object_lcol (form->OkBtn, FL_INACTIVE);
1966 fl_set_object_lcol (form->ApplyBtn, FL_INACTIVE);
1969 inline void EnableFigurePanel(FD_Figure * const form)
1971 fl_activate_object(form->EpsFile);
1972 fl_activate_object(form->Browse);
1973 fl_activate_object(form->Width);
1974 fl_activate_object(form->Height);
1975 fl_activate_object(form->Frame);
1976 fl_activate_object(form->Translations);
1977 fl_activate_object(form->Angle);
1978 fl_activate_object(form->HeightGrp);
1979 fl_activate_object(form->page2);
1980 fl_activate_object(form->Default2);
1981 fl_activate_object(form->cm2);
1982 fl_activate_object(form->in2);
1983 fl_activate_object(form->HeightLabel);
1984 fl_activate_object(form->WidthLabel);
1985 fl_activate_object(form->DisplayGrp);
1986 fl_activate_object(form->Wysiwyg3);
1987 fl_activate_object(form->Wysiwyg0);
1988 fl_activate_object(form->Wysiwyg2);
1989 fl_activate_object(form->Wysiwyg1);
1990 fl_activate_object(form->WidthGrp);
1991 fl_activate_object(form->Default1);
1992 fl_activate_object(form->cm1);
1993 fl_activate_object(form->in1);
1994 fl_activate_object(form->page1);
1995 fl_activate_object(form->column1);
1996 fl_activate_object(form->Subcaption);
1997 fl_activate_object(form->Subfigure);
1998 fl_activate_object (form->OkBtn);
1999 fl_activate_object (form->ApplyBtn);
2000 fl_set_object_lcol (form->OkBtn, FL_BLACK);
2001 fl_set_object_lcol (form->ApplyBtn, FL_BLACK);
2004 void InsetFig::RestoreForm()
2009 EnableFigurePanel(form);
2012 fl_set_button(form->Default1, (wtype == 0));
2013 fl_set_button(form->cm1, (wtype == 1));
2014 fl_set_button(form->in1, (wtype == 2));
2015 fl_set_button(form->page1, (wtype == 3));
2016 fl_set_button(form->column1, (wtype == 4));
2018 fl_deactivate_object(form->Width);
2020 fl_activate_object(form->Width);
2023 // enable and disable should be put here.
2025 fl_set_button(form->Default2, (htype == 0));
2026 fl_set_button(form->cm2, (htype == 1));
2027 fl_set_button(form->in2, (htype == 2));
2028 fl_set_button(form->page2, (htype == 3));
2029 // enable and disable should be put here.
2031 fl_deactivate_object(form->Height);
2033 fl_activate_object(form->Height);
2037 fl_set_button(form->Wysiwyg0, (pflags == 0));
2038 fl_set_button(form->Wysiwyg1, (pflags == 1));
2039 fl_set_button(form->Wysiwyg2, (pflags == 2));
2040 fl_set_button(form->Wysiwyg3, (pflags == 3));
2041 fl_set_button(form->Frame, ((flags & 4) != 0));
2042 fl_set_button(form->Translations, ((flags & 8) != 0));
2043 fl_set_button(form->Subfigure, (subfigure != 0));
2045 psubfigure = subfigure;
2046 sprintf(buf, "%g", xwid);
2047 fl_set_input(form->Width, buf);
2048 sprintf(buf, "%g", xhgh);
2049 fl_set_input(form->Height, buf);
2050 sprintf(buf, "%g", angle);
2051 fl_set_input(form->Angle, buf);
2052 if (!fname.empty()){
2053 string buf1 = OnlyPath(owner->getFileName());
2054 string fname2 = MakeRelPath(fname, buf1);
2055 fl_set_input(form->EpsFile, fname2.c_str());
2057 else fl_set_input(form->EpsFile, "");
2058 fl_set_input(form->Subcaption, subcaption.c_str());
2059 if(current_view->currentBuffer()->isReadonly())
2060 DisableFigurePanel(form);
2066 void InsetFig::Preview(char const *p)
2073 lyxerr.print("Cannot fork process!");
2078 return; // parent process
2081 string buf1 = OnlyPath(owner->getFileName());
2082 string buf2 = MakeAbsPath(p, buf1);
2084 lyxerr.print(string("Error during rendering ") +
2085 tostr(execlp(lyxrc->view_pspic_command.c_str(),
2086 lyxrc->view_pspic_command.c_str(),
2093 void InsetFig::BrowseFile()
2095 string buf, buf2, bufclip;
2096 static string current_figure_path;
2097 static int once = 0;
2100 if (lyxerr.debugging()) {
2101 fprintf(stderr, "Filename: %s\n", owner->getFileName().c_str());
2103 string p = fl_get_input(form->EpsFile);
2105 buf = MakeAbsPath(owner->getFileName());
2106 buf2 = OnlyPath(buf);
2108 buf = MakeAbsPath(p, buf2);
2109 buf = OnlyPath(buf);
2111 buf = OnlyPath(owner->getFileName().c_str());
2114 // Does user clipart directory exist?
2115 bufclip = AddName (user_lyxdir, "clipart");
2116 FileInfo fileInfo(bufclip);
2117 if (!(fileInfo.isOK() && fileInfo.isDir()))
2118 // No - bail out to system clipart directory
2119 bufclip = AddName (system_lyxdir, "clipart");
2122 fileDlg.SetButton(0, _("Clipart"), bufclip);
2123 fileDlg.SetButton(1, _("Document"), buf);
2129 p =fileDlg.Select(_("EPS Figure"), current_figure_path,
2132 p = fileDlg.Select(_("EPS Figure"), buf,
2137 if (p.empty()) return;
2139 buf = MakeRelPath(p, buf2);
2140 current_figure_path = OnlyPath(p);
2143 if (contains(p, "#") || contains(p, "~") || contains(p, "$")
2144 || contains(p, "%") || contains(p, " "))
2146 WriteAlert(_("Filename can't contain any of these characters:"), // xgettext:no-c-format
2147 _("space, '#', '~', '$' or '%'."));
2152 if (form) fl_set_input(form->EpsFile, buf.c_str());
2156 void GraphicsCB(FL_OBJECT *obj, long arg)
2158 /* obj->form contains the form */
2160 if (lyxerr.debugging()) {
2161 lyxerr.print(string("GraphicsCB callback: ") + tostr(arg));
2164 /* find inset we were reacting to */
2165 for (int i = 0; i < figinsref; ++i)
2166 if (figures[i]->inset->form && figures[i]->inset->form->Figure
2169 if (lyxerr.debugging()) {
2170 lyxerr.print(string("Calling back figure ")
2173 figures[i]->inset->CallbackFig(arg);
2179 void HideFiguresPopups()
2181 for (int i = 0; i < figinsref; ++i)
2182 if (figures[i]->inset->form
2183 && figures[i]->inset->form->Figure->visible) {
2184 if (lyxerr.debugging()) {
2185 lyxerr.print(string("Hiding figure ")
2188 // hide and free the form
2189 figures[i]->inset->CallbackFig(9);