2 * figinset.C - part of LyX project
5 extern long int background_pixels;
7 /* Rework of path-handling (Matthias 04.07.1996 )
8 * ------------------------------------------------
9 * figinsets keep an absolute path to the eps-file.
10 * For the user alway a relative path appears
11 * (in lyx-file, latex-file and edit-popup).
12 * To calculate this relative path the path to the
13 * document where the figinset is in is needed.
14 * This is done by a reference to the buffer, called
15 * figinset::cbuffer. To be up to date the cbuffer
16 * is sometimes set to the current buffer
17 * bufferlist.current(), when it can be assumed that
18 * this operation happens in the current buffer.
19 * This is true for InsetFig::Edit(...),
20 * InsetFig::InsetFig(...), InsetFig::Read(...),
21 * InsetFig::Write and InsetFig::Latex(...).
22 * Therefore the bufferlist has to make sure that
23 * during these operations bufferlist.current()
24 * returns the buffer where the figinsets are in.
25 * This made few changes in buffer.C necessary.
27 * The above is not totally valid anymore. (Lgb)
37 #include FORMS_H_LOCATION
57 #include "support/filetools.h"
58 #include "LyXView.h" // just because of form_main
60 #include "LaTeXFeatures.h"
63 #include "lyx_gui_misc.h" // CancelCloseBoxCB
64 #include "support/FileInfo.h"
65 #include "support/lyxlib.h"
68 extern BufferView * current_view;
69 extern FL_OBJECT * figinset_canvas;
71 extern char ** environ; // is this only redundtant on linux systems? Lgb.
73 extern void ProhibitInput();
74 extern void AllowInput();
76 static float const DEG2PI = 57.295779513;
77 static int const 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 */
84 struct queue_element {
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
90 static int const MAXGS = 3; /* maximum 3 gs's at a time */
92 static Figref ** figures; /* all the figures */
93 static figdata ** bitmaps; /* all the bitmaps */
95 static queue<queue_element> gsqueue; // queue for ghostscripting
97 static int gsrunning = 0; /* currently so many gs's are running */
98 static bool bitmap_waiting = false; /* bitmaps are waiting finished */
99 static char bittable[256]; /* bit reversion table */
101 static bool gs_color; // do we allocate colors for gs?
102 static bool color_visual; // is the visual color?
103 static bool gs_xcolor = false; // allocated extended colors
104 static unsigned long gs_pixels[128]; // allocated pixels
105 static int gs_num_pixels; // number of pixels allocated
106 static int gs_spc; // shades per color
107 static bool gs_gray; // is grayscale?
108 static int gs_allcolors; // number of all colors
110 static list<int> pidwaitlist; // pid wait list
117 val.foreground = BlackPixel(fl_display,
118 DefaultScreen(fl_display));
121 val.graphics_exposures = false;
122 val.line_style = LineSolid;
124 return XCreateGC(fl_display, RootWindow(fl_display, 0),
125 GCForeground | GCFunction | GCGraphicsExposures
126 | GCLineWidth | GCLineStyle , &val);
133 void addpidwait(int pid)
135 // adds pid to pid wait list
136 pidwaitlist.push_back(pid);
138 if (lyxerr.debugging()) {
139 lyxerr << "Pids to wait for: \n";
140 for (list<int>::const_iterator cit = pidwaitlist.begin();
141 cit != pidwaitlist.end(); ++cit) {
142 lyxerr << (*cit) << '\n';
150 int GhostscriptMsg(FL_OBJECT *, Window, int, int,
155 XClientMessageEvent * e = reinterpret_cast<XClientMessageEvent*>(ev);
157 if(lyxerr.debugging()) {
158 lyxerr << "ClientMessage, win:[xx] gs:[" << e->data.l[0]
159 << "] pm:[" << e->data.l[1] << "]" << endl;
162 // just kill gs, that way it will work for sure
163 // This loop looks like S**T so it probably is...
164 for (int i = 0; i < bmpinsref; ++i)
165 if ((long)bitmaps[i]->bitmap == (long)e->data.l[1]) {
167 figdata * p = bitmaps[i];
170 // first update p->bitmap, if necessary
171 if (p->bitmap != None
172 && p->flags > (1|8) && gs_color && p->wid) {
173 // query current colormap and re-render
174 // the pixmap with proper colors
176 XWindowAttributes wa;
177 register XImage * im;
182 int spc2 = gs_spc * gs_spc;
186 GC gc = local_gc_copy;
188 XGetWindowAttributes(fl_display,
193 if (lyxerr.debugging()) {
194 lyxerr << "Starting image translation "
197 << p->wid << "x" << p->hgh
199 << " " << XYPixmap << endl;
201 // now fork rendering process
203 if (forkstat == -1) {
205 << "Cannot fork, using slow "
206 "method for pixmap translation." << endl;
207 tmpdisp = fl_display;
208 } else if (forkstat > 0) { // parent
210 if (lyxerr.debugging()) {
211 lyxerr << "Spawned child "
214 addpidwait(forkstat);
217 tmpdisp = XOpenDisplay(XDisplayName(0));
220 im = XGetImage(tmpdisp, p->bitmap, 0, 0,
221 p->wid, p->hgh, (1<<wa.depth)-1, XYPixmap);
223 if (lyxerr.debugging()) {
224 lyxerr << "Got the image" << endl;
227 if (lyxerr.debugging()) {
228 lyxerr << "Error getting the image" << endl;
233 // query current colormap
234 XColor * cmap = new XColor[gs_allcolors];
235 for (i = 0; i < gs_allcolors; ++i) cmap[i].pixel = i;
236 XQueryColors(tmpdisp,
237 fl_state[fl_get_vclass()]
242 // now we process all the image
243 for (y = 0; y < p->hgh; ++y) {
244 for (int x = 0; x < wid; ++x) {
249 gs_pixels[((pc->red+6553)*
250 spc1/65535)*spc2+((pc->green+6553)*
251 spc1/65535)*gs_spc+((pc->blue+6553)*
256 // This must be correct.
258 if (lyxerr.debugging()) {
259 lyxerr << "Putting image back"
262 XPutImage(tmpdisp, p->bitmap,
264 0, 0, p->wid, p->hgh);
266 if (lyxerr.debugging()) {
267 lyxerr << "Done translation"
272 if (lyxerr.debugging()) {
273 lyxerr << "Killing gs "
276 lyx::kill(p->gspid, SIGHUP);
278 sprintf(tmp, "%s/~lyxgs%d.ps",
279 system_tempdir.c_str(),
283 XCloseDisplay(tmpdisp);
287 if (lyxerr.debugging()) {
288 lyxerr << "Killing gs "
291 lyx::kill(p->gspid, SIGHUP);
293 sprintf(tmp, "%s/~lyxgs%d.ps",
294 system_tempdir.c_str(),
305 void AllocColors(int num)
306 // allocate color cube numxnumxnum, if possible
308 if (lyxerr.debugging()) {
309 lyxerr << "Allocating color cube " << num
310 << 'x' << num << 'x' << num << endl;
314 lyxerr << "Error allocating color colormap." << endl;
318 if (num > 5) num = 5;
320 for (int i = 0; i < num * num * num; ++i) {
321 xcol.red = 65535 * (i / (num * num)) / (num - 1);
322 xcol.green = 65535 * ((i / num) % num) / (num - 1);
323 xcol.blue = 65535 * (i % num) / (num - 1);
324 xcol.flags = DoRed | DoGreen | DoBlue;
325 if (!XAllocColor(fl_display,
326 fl_state[fl_get_vclass()].colormap, &xcol)) {
327 if (i) XFreeColors(fl_display,
328 fl_state[fl_get_vclass()].colormap,
330 if(lyxerr.debugging()) {
331 lyxerr << "Cannot allocate color cube "
334 AllocColors(num - 1);
337 gs_pixels[i] = xcol.pixel;
342 gs_num_pixels = num * num * num;
346 // allocate grayscale ramp
348 void AllocGrays(int num)
350 if (lyxerr.debugging()) {
351 lyxerr << "Allocating grayscale colormap "
356 lyxerr << "Error allocating grayscale colormap." << endl;
360 if (num > 128) num = 128;
362 for (int i = 0; i < num; ++i) {
363 xcol.red = xcol.green = xcol.blue = 65535 * i / (num - 1);
364 xcol.flags = DoRed | DoGreen | DoBlue;
365 if (!XAllocColor(fl_display,
366 fl_state[fl_get_vclass()].colormap, &xcol)) {
367 if (i) XFreeColors(fl_display,
368 fl_state[fl_get_vclass()].colormap,
370 if (lyxerr.debugging()) {
371 lyxerr << "Cannot allocate grayscale "
377 gs_pixels[i] = xcol.pixel;
387 bmparrsize = figarrsize = figallocchunk;
388 typedef Figref * Figref_p;
389 figures = new Figref_p[figallocchunk];
390 typedef figdata * figdata_p;
391 bitmaps = new figdata_p[figallocchunk];
394 for (unsigned int i = 0; i < 256; ++i) {
396 for (unsigned int j = 0; j < 8; ++j)
397 if (i & (1 << (7-j))) k |= 1 << j;
398 bittable[i] = char(~k);
401 fl_add_canvas_handler(figinset_canvas, ClientMessage,
402 GhostscriptMsg, current_view->owner()->getMainForm());
404 // allocate color cube on pseudo-color display
407 local_gc_copy = createGC();
409 Visual * vi = DefaultVisual(fl_display, DefaultScreen(fl_display));
410 if (lyxerr.debugging()) {
411 printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
412 vi->visualid, vi->c_class,
413 vi->bits_per_rgb, vi->map_entries);
415 color_visual = ( (vi->c_class == StaticColor) ||
416 (vi->c_class == PseudoColor) ||
417 (vi->c_class == TrueColor) ||
418 (vi->c_class == DirectColor) );
419 if ((vi->c_class & 1) == 0) return;
420 // now allocate colors
421 if (vi->c_class == GrayScale) {
422 // allocate grayscale
423 AllocGrays(vi->map_entries/2);
425 // allocate normal color
427 while (i * i * i * 2 > vi->map_entries) --i;
430 gs_allcolors = vi->map_entries;
441 lyxerr.debug() << "Unregistering figures..." << endl;
443 fl_remove_canvas_handler(figinset_canvas, ClientMessage,
448 int FindBmpIndex(figdata * tmpdata)
451 while (i < bmpinsref) {
452 if (bitmaps[i] == tmpdata) return i;
460 void freefigdata(figdata * tmpdata)
463 if (tmpdata->ref) return;
465 if (tmpdata->gspid > 0) {
466 int pid = tmpdata->gspid;
468 // kill ghostscript and unlink it's files
470 lyx::kill(pid, SIGKILL);
471 sprintf(buf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), pid);
475 if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
477 int i = FindBmpIndex(tmpdata);
479 while (i < bmpinsref) {
480 bitmaps[i] = bitmaps[i + 1];
489 // run queued requests for ghostscript, if any
490 if (!gsrunning && gs_color && !gs_xcolor) {
491 // here alloc all colors, so that gs will use only
492 // those we allocated for it
497 while (gsrunning < MAXGS) {
498 char tbuf[384], tbuf2[80];
502 if (gsqueue.empty()) {
503 if (!gsrunning && gs_xcolor) {
504 // de-allocate rest of colors
510 queue_element * p = &gsqueue.front();
519 if (lyxerr.debugging()) {
520 lyxerr << "GS start error! Cannot fork."
523 p->data->broken = true;
524 p->data->reading = false;
527 if (pid == 0) { // child
528 char ** env, rbuf[80], gbuf[40];
530 Display * tempdisp = XOpenDisplay(XDisplayName(0));
532 // create translation file
533 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
537 ofs << "gsave clippath pathbbox grestore\n"
539 << "/ury exch def /urx exch def /lly exch def "
541 << p->data->wid / 2.0 << " "
542 << p->data->hgh / 2.0 << " translate\n"
543 << p->data->angle << " rotate\n"
544 << -(p->data->raw_wid / 2.0) << " "
545 << -(p->data->raw_hgh / 2.0) << " translate\n"
546 << p->rx / 72.0 << " " << p->ry / 72.0
548 << -p->ofsx << " " << -p->ofsy << " translate\n"
550 ofs.close(); // Don't remove this.
552 // gs process - set ghostview environment first
553 sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
554 figinset_canvas), p->data->bitmap);
556 // now set up ghostview property on a window
557 sprintf(tbuf, "0 0 0 0 %d %d 72 72 0 0 0 0",
558 p->data->wid, p->data->hgh);
559 // #warning BUG seems that the only bug here
560 // might be the hardcoded dpi.. Bummer!
562 if (lyxerr.debugging()) {
563 lyxerr << "Will set GHOSTVIEW property to ["
564 << tbuf << "]" << endl;
566 // wait until property is deleted if executing multiple
569 // grab server to prevent other child
570 // interfering with setting GHOSTVIEW property
571 if (lyxerr.debugging()) {
572 lyxerr << "Grabbing the server"
575 XGrabServer(tempdisp);
576 prop = XListProperties(tempdisp,
578 figinset_canvas), &nprop);
582 for (i = 0; i < nprop; ++i) {
583 char * p = XGetAtomName(tempdisp,
585 if (strcmp(p, "GHOSTVIEW") == 0) {
591 XFree(reinterpret_cast<char *>(prop)); // jc:
593 // release the server
594 XUngrabServer(tempdisp);
596 // ok, property found, we must wait until
597 // ghostscript deletes it
598 if (lyxerr.debugging()) {
599 lyxerr << "Releasing the server\n["
601 << "] GHOSTVIEW property"
602 " found. Waiting." << endl;
608 XChangeProperty(tempdisp,
609 fl_get_canvas_id(figinset_canvas),
610 XInternAtom(tempdisp, "GHOSTVIEW", false),
611 XInternAtom(tempdisp, "STRING", false),
613 reinterpret_cast<unsigned char*>(tbuf),
616 switch (p->data->flags & 3) {
617 case 0: tbuf[0] = 'H'; break; // Hidden
618 case 1: tbuf[0] = 'M'; break; // Mono
619 case 2: tbuf[0] = 'G'; break; // Gray
622 tbuf[0] = 'C'; // Color
624 tbuf[0] = 'G'; // Gray
628 sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
629 DefaultScreenOfDisplay(fl_display)),
630 fl_get_pixel(FL_WHITE));
632 XChangeProperty(tempdisp,
633 fl_get_canvas_id(figinset_canvas),
634 XInternAtom(tempdisp,
635 "GHOSTVIEW_COLORS", false),
636 XInternAtom(tempdisp, "STRING", false),
638 reinterpret_cast<unsigned char*>(tbuf),
640 XUngrabServer(tempdisp);
642 if (lyxerr.debugging()) {
643 lyxerr << "Releasing the server" << endl;
645 XCloseDisplay(tempdisp);
647 // set up environment
648 while (environ[ne]) ++ne;
649 typedef char * char_p;
650 env = new char_p[ne + 2];
652 memcpy(&env[1], environ, sizeof(char*) * (ne + 1));
655 // now make gs command
657 // close(1); do NOT close. If GS writes out
658 // errors it would hang. (Matthias 290596)
659 sprintf(rbuf, "-r%gx%g", p->rx, p->ry);
660 sprintf(gbuf, "-g%dx%d", p->data->wid, p->data->hgh);
661 // now chdir into dir with .eps file, to be on the safe
663 chdir(OnlyPath(p->data->fname).c_str());
664 // make temp file name
665 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
667 if (lyxerr.debugging()) {
668 lyxerr << "starting gs " << tbuf << " "
670 << ", pid: " << getpid() << endl;
673 int err = execlp(lyxrc->ps_command.c_str(),
674 lyxrc->ps_command.c_str(),
676 "-dNOPAUSE", "-dQUIET",
679 p->data->fname.c_str(),
680 "showpage.ps", "quit.ps", "-", 0);
681 // if we are still there, an error occurred.
682 lyxerr << "Error executing ghostscript. "
683 << "Code: " << err << endl;
684 lyxerr.debug() << "Cmd: "
688 << p->data->fname << endl;
691 // normal process (parent)
692 if (lyxerr.debugging()) {
693 lyxerr << "GS [" << pid << "] started" << endl;
696 p->data->gspid = pid;
704 void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
706 // recompute the stuff and put in the queue
710 p.rx = (float(data->raw_wid) * 72.0) / pswid;
711 p.ry = (float(data->raw_hgh) * 72.0) / pshgh;
717 // if possible, run the queue
723 figdata * getfigdata(int wid, int hgh, string const & fname,
724 int psx, int psy, int pswid, int pshgh,
725 int raw_wid, int raw_hgh, float angle, char flags)
727 /* first search for an exact match with fname and width/height */
729 if (fname.empty()) return 0;
732 while (i < bmpinsref) {
733 if (bitmaps[i]->wid == wid && bitmaps[i]->hgh == hgh &&
734 bitmaps[i]->flags == flags && bitmaps[i]->fname == fname &&
735 bitmaps[i]->angle == angle) {
741 /* not found -> create new record or return 0 if no record */
743 if (bmpinsref > bmparrsize) {
744 // allocate more space
745 bmparrsize += figallocchunk;
746 typedef figdata * figdata_p;
747 figdata ** tmp = new figdata_p[bmparrsize];
749 sizeof(figdata*) * (bmparrsize - figallocchunk));
753 figdata * p = new figdata;
754 bitmaps[bmpinsref-1] = p;
757 p->raw_wid = raw_wid;
758 p->raw_hgh = raw_hgh;
762 XWindowAttributes wa;
763 XGetWindowAttributes(fl_display, fl_get_canvas_id(
764 figinset_canvas), &wa);
766 if (lyxerr.debugging()) {
767 lyxerr << "Create pixmap disp:" << fl_display
768 << " scr:" << DefaultScreen(fl_display)
771 << " depth:" << wa.depth << endl;
779 p->bitmap = XCreatePixmap(fl_display, fl_get_canvas_id(
780 figinset_canvas), wid, hgh, wa.depth);
782 // initialize reading of .eps file with correct sizes and stuff
783 addwait(psx, psy, pswid, pshgh, p);
795 void getbitmap(figdata * p)
802 void makeupdatelist(figdata * p)
804 for (int i = 0; i < figinsref; ++i)
805 if (figures[i]->data == p) {
806 if (lyxerr.debugging()) {
807 lyxerr << "Updating inset "
811 // add inset figures[i]->inset into to_update list
812 current_view->pushIntoUpdateList(figures[i]->inset);
817 void sigchldchecker(pid_t pid, int * status)
819 lyxerr.debug() << "Got pid = " << pid << endl;
820 bool pid_handled = false;
821 for (int i = bmpinsref - 1; i >= 0; --i) {
822 if (bitmaps[i]->reading && pid == bitmaps[i]->gspid) {
823 lyxerr.debug() << "Found pid in bitmaps" << endl;
824 // now read the file and remove it from disk
825 figdata * p = bitmaps[i];
827 if (bitmaps[i]->gsdone) *status = 0;
829 lyxerr.debug() << "GS [" << pid
830 << "] exit OK." << endl;
832 lyxerr << "GS [" << pid << "] error "
834 << WIFEXITED(*status)
835 << " " << WEXITSTATUS(*status)
836 << " S:" << WIFSIGNALED(*status)
837 << " " << WTERMSIG(*status) << endl;
840 bitmap_waiting = true;
843 // remove temporary files
845 sprintf(tmp, "%s/~lyxgs%d.ps",
846 system_tempdir.c_str(),
852 makeupdatelist(bitmaps[i]);
859 lyxerr.debug() << "Checking pid in pidwait" << endl;
860 list<int>::iterator it = find(pidwaitlist.begin(),
861 pidwaitlist.end(), pid);
862 if (it != pidwaitlist.end()) {
863 lyxerr.debug() << "Found pid in pidwait\n"
864 << "Caught child pid of recompute "
865 "routine" << pid << endl;
866 pidwaitlist.erase(it);
870 lyxerr.debug() << "waitpid error" << endl;
873 lyxerr << "The process or process group specified by "
874 "pid does not exist or is not a child of "
875 "the calling process or can never be in the "
876 "states specified by options." << endl;
879 lyxerr << "waitpid() was interrupted due to the "
880 "receipt of a signal sent by the calling "
884 lyxerr << "An invalid value was specified for "
888 lyxerr << "Unknown error from waitpid" << endl;
891 } else if (pid == 0) {
892 lyxerr << "waitpid nohang" << endl;;
894 lyxerr.debug() << "normal exit from childhandler" << endl;
902 bitmap_waiting = false;
903 for (int i = 0; i < bmpinsref; ++i)
904 if (bitmaps[i]->gspid > 0 && !bitmaps[i]->reading)
905 getbitmap(bitmaps[i]);
910 void RegisterFigure(InsetFig * fi)
912 if (figinsref == 0) InitFigures();
915 if (figinsref > figarrsize) {
916 // allocate more space
917 figarrsize += figallocchunk;
918 typedef Figref * Figref_p;
919 Figref ** tmp = new Figref_p[figarrsize];
921 sizeof(Figref*) * (figarrsize-figallocchunk));
925 Figref * tmpfig = new Figref;
928 figures[figinsref-1] = tmpfig;
931 if (lyxerr.debugging()) {
932 lyxerr << "Register Figure: buffer:["
933 << current_view->buffer() << "]" << endl;
938 int FindFigIndex(Figref * tmpfig)
941 while (i < figinsref) {
942 if (figures[i] == tmpfig) return i;
950 void UnregisterFigure(InsetFig * fi)
952 Figref * tmpfig = fi->figure;
954 if (tmpfig->data) freefigdata(tmpfig->data);
955 if (tmpfig->inset->form) {
956 if (tmpfig->inset->form->Figure->visible) {
957 fl_set_focus_object(tmpfig->inset->form->Figure,
958 tmpfig->inset->form->OkBtn);
959 fl_hide_form(tmpfig->inset->form->Figure);
961 #if FL_REVISION == 89
962 #warning Reactivate this free_form calls
964 fl_free_form(tmpfig->inset->form->Figure);
965 free(tmpfig->inset->form); // Why free?
966 tmpfig->inset->form = 0;
969 int i = FindFigIndex(tmpfig);
971 while (i < figinsref) {
972 figures[i] = figures[i+1];
977 if (figinsref == 0) DoneFigures();
982 string NextToken(istream & is)
990 } while (!is.eof() && !isspace(c));
991 token.erase(token.length() - 1); // remove the isspace
997 InsetFig::InsetFig(int tmpx, int tmpy, Buffer * o)
1007 psubfigure = subfigure = false;
1008 xwid = xhgh = angle = 0;
1010 raw_wid = raw_hgh = 0;
1011 changedfname = false;
1012 RegisterFigure(this);
1016 InsetFig::~InsetFig()
1018 if (lyxerr.debugging()) {
1019 lyxerr << "Figure destructor called" << endl;
1021 UnregisterFigure(this);
1025 int InsetFig::ascent(Painter &, LyXFont const &) const
1031 int InsetFig::descent(Painter &, LyXFont const &) const
1037 int InsetFig::width(Painter &, LyXFont const &) const
1043 void InsetFig::draw(Painter & pain, LyXFont const & f,
1044 int baseline, float & x) const
1048 if (bitmap_waiting) getbitmaps();
1050 // I wish that I didn't have to use this
1051 // but the figinset code is so complicated so
1052 // I don't want to fiddle with it now.
1054 if (figure && figure->data && figure->data->bitmap &&
1055 !figure->data->reading && !figure->data->broken) {
1057 pain.pixmap(int(x + 1), baseline - hgh,
1058 wid, hgh, figure->data->bitmap);
1061 pain.rectangle(int(x), baseline - hgh - 1,
1067 pain.rectangle(x, baseline - hgh - 1, wid + 1, hgh + 1);
1069 if (figure && figure->data) {
1070 if (figure->data->broken) msg = _("[render error]");
1071 else if (figure->data->reading) msg = _("[rendering ... ]");
1073 if (fname.empty()) msg = _("[no file]");
1074 else if ((flags & 3) == 0) msg = _("[not displayed]");
1075 else if (lyxrc->ps_command.empty()) msg = _("[no ghostscript]");
1077 if (!msg) msg = _("[unknown error]");
1079 font.setFamily(LyXFont::SANS_FAMILY);
1080 font.setSize(LyXFont::SIZE_FOOTNOTE);
1081 string justname = OnlyFilename (fname);
1082 pain.text(int(x + 8), baseline - font.maxAscent() - 4,
1085 font.setSize(LyXFont::SIZE_TINY);
1086 pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
1088 x += width(pain, font); // ?
1092 void InsetFig::Write(ostream & os) const
1095 os << "Figure size " << wid << " " << hgh << "\n";
1096 if (!fname.empty()) {
1097 string buf1 = OnlyPath(owner->fileName());
1098 string fname2 = MakeRelPath(fname, buf1);
1099 os << "file " << fname2 << "\n";
1101 if (!subcaption.empty())
1102 os << "subcaption " << subcaption << "\n";
1103 if (wtype) os << "width " << static_cast<int>(wtype) << " " << xwid << "\n";
1104 if (htype) os << "height " << static_cast<int>(htype) << " " << xhgh << "\n";
1105 if (angle != 0) os << "angle " << angle << "\n";
1106 os << "flags " << flags << "\n";
1107 if (subfigure) os << "subfigure\n";
1111 void InsetFig::Read(LyXLex & lex)
1114 bool finished = false;
1116 while (lex.IsOK() && !finished) {
1119 string const token = lex.GetString();
1120 lyxerr.debug() << "Token: " << token << endl;
1124 else if (token == "\\end_inset") {
1126 } else if (token == "file") {
1128 buf = lex.GetString();
1129 string buf1 = OnlyPath(owner->fileName());
1130 fname = MakeAbsPath(buf, buf1);
1131 changedfname = true;
1133 } else if (token == "extra") {
1135 // kept for backwards compability. Delete in 0.13.x
1136 } else if (token == "subcaption") {
1138 subcaption = lex.GetString();
1139 } else if (token == "label") {
1141 // kept for backwards compability. Delete in 0.13.x
1142 } else if (token == "angle") {
1144 angle = lex.GetFloat();
1145 } else if (token == "size") {
1147 wid = lex.GetInteger();
1149 hgh = lex.GetInteger();
1150 } else if (token == "flags") {
1152 flags = pflags = lex.GetInteger();
1153 } else if (token == "subfigure") {
1154 subfigure = psubfigure = true;
1155 } else if (token == "width") {
1158 typ = lex.GetInteger();
1160 xwid = lex.GetFloat();
1162 case DEF: wtype = DEF; break;
1163 case CM: wtype = CM; break;
1164 case IN: wtype = IN; break;
1165 case PER_PAGE: wtype = PER_PAGE; break;
1166 case PER_COL: wtype = PER_COL; break;
1168 lyxerr.debug() << "Unknown type!" << endl;
1172 } else if (token == "height") {
1175 typ = lex.GetInteger();
1177 xhgh = lex.GetFloat();
1179 case DEF: htype = DEF; break;
1180 case CM: htype = CM; break;
1181 case IN: htype = IN; break;
1182 case PER_PAGE: htype = PER_PAGE; break;
1184 lyxerr.debug() << "Unknown type!" << endl;
1195 int InsetFig::Latex(ostream & os, signed char /* fragile*/, bool /* fs*/) const
1198 if (!cmd.empty()) os << cmd << " ";
1203 int InsetFig::Linuxdoc(ostream &) const
1209 int InsetFig::DocBook(ostream & os) const
1211 string figurename = fname;
1213 if(suffixIs(figurename, ".eps"))
1214 figurename.erase(fname.length() - 5);
1216 os << "@<graphic fileref=\"" << figurename << "\"></graphic>";
1221 void InsetFig::Validate(LaTeXFeatures & features) const
1223 features.graphics = true;
1224 if (subfigure) features.subfigure = true;
1228 Inset::EDITABLE InsetFig::Editable() const
1234 bool InsetFig::Deletable() const
1240 void InsetFig::Edit(BufferView * bv, int, int, unsigned int)
1242 lyxerr.debug() << "Editing InsetFig." << endl;
1245 // We should have RO-versions of the form instead.
1246 // The actual prevention of altering a readonly doc
1247 // is done in CallbackFig()
1248 if(bv->buffer()->isReadonly())
1249 WarnReadonly(bv->buffer()->fileName());
1252 form = create_form_Figure();
1253 fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0);
1254 fl_set_object_return(form->Angle, FL_RETURN_ALWAYS);
1255 fl_set_object_return(form->Width, FL_RETURN_ALWAYS);
1256 fl_set_object_return(form->Height, FL_RETURN_ALWAYS);
1259 if (form->Figure->visible) {
1260 fl_raise_form(form->Figure);
1262 fl_show_form(form->Figure, FL_PLACE_MOUSE | FL_PLACE_SIZE,
1263 FL_FULLBORDER, _("Figure"));
1268 Inset * InsetFig::Clone() const
1270 InsetFig * tmp = new InsetFig(100, 100, owner);
1272 if (lyxerr.debugging()) {
1273 lyxerr << "Clone Figure: buffer:["
1274 << current_view->buffer()
1275 << "], cbuffer:[xx]" << endl;
1280 tmp->raw_wid = raw_wid;
1281 tmp->raw_hgh = raw_hgh;
1286 tmp->pflags = pflags;
1287 tmp->subfigure = subfigure;
1288 tmp->psubfigure = psubfigure;
1296 if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
1297 // do not display if there is
1298 // "do not display" chosen (Matthias 260696)
1299 tmp->figure->data = getfigdata(wid, hgh, fname, psx, psy,
1300 pswid, pshgh, raw_wid, raw_hgh,
1301 angle, flags & (3|8));
1302 } else tmp->figure->data = 0;
1303 tmp->subcaption = subcaption;
1304 tmp->changedfname = false;
1311 Inset::Code InsetFig::LyxCode() const
1313 return Inset::GRAPHICS_CODE;
1317 void InsetFig::Regenerate() const
1320 string resizeW, resizeH;
1321 string rotate, recmd;
1323 if (fname.empty()) {
1324 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1325 cmd += _("empty figure path");
1330 string buf1 = OnlyPath(owner->fileName());
1331 string fname2 = MakeRelPath(fname, buf1);
1333 string gcmd = "\\includegraphics{" + fname2 + '}';
1338 case CM:{// \resizebox*{h-length}{v-length}{text}
1340 sprintf(buf, "%g", xwid); // should find better
1347 sprintf(buf, "%g", xwid);
1354 sprintf(buf, "%g", xwid/100);
1356 resizeW += "\\textwidth";
1361 sprintf(buf, "%g", xwid/100);
1363 resizeW += "\\columnwidth";
1373 sprintf(buf, "%g", xhgh);
1380 sprintf(buf, "%g", xhgh);
1387 sprintf(buf, "%g", xhgh/100);
1389 resizeH += "\\textheight";
1393 // Doesn't occur; case exists to suppress compiler warnings.
1398 if (!resizeW.empty() || !resizeH.empty()) {
1399 recmd = "\\resizebox*{";
1400 if (!resizeW.empty())
1405 if (!resizeH.empty())
1415 sprintf(buf, "%g", angle);
1416 // \rotatebox{angle}{text}
1417 rotate = "\\rotatebox{";
1425 if (!rotate.empty()) cmdbuf += '}';
1426 if (!recmd.empty()) cmdbuf += '}';
1428 if (!subcaption.empty())
1429 cmdbuf = "\\subfigure[" + subcaption +
1430 "]{" + cmdbuf + "}";
1432 cmdbuf = "\\subfigure{" + cmdbuf + "}";
1439 void InsetFig::TempRegenerate()
1442 string resizeW, resizeH;
1443 string rotate, recmd;
1445 char const * tfname = fl_get_input(form->EpsFile);
1446 string tsubcap = fl_get_input(form->Subcaption);
1447 float tangle = atof(fl_get_input(form->Angle));
1448 float txwid = atof(fl_get_input(form->Width));
1449 float txhgh = atof(fl_get_input(form->Height));
1451 if (!tfname || !*tfname) {
1452 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1453 cmd += _("empty figure path");
1458 string buf1 = OnlyPath(owner->fileName());
1459 string fname2 = MakeRelPath(tfname, buf1);
1460 // \includegraphics*[<llx,lly>][<urx,ury>]{file}
1461 string gcmd = "\\includegraphics{" + fname2 + '}';
1466 case CM: {// \resizebox*{h-length}{v-length}{text}
1468 sprintf(buf, "%g", txwid); // should find better
1475 sprintf(buf, "%g", txwid);
1482 sprintf(buf, "%g", txwid/100);
1484 resizeW += "\\textwidth";
1489 sprintf(buf, "%g", txwid/100);
1491 resizeW += "\\columnwidth";
1501 sprintf(buf, "%g", txhgh);
1508 sprintf(buf, "%g", txhgh);
1515 sprintf(buf, "%g", txhgh/100);
1517 resizeH += "\\textheight";
1521 // Doesn't occur; case exists to suppress compiler warnings.
1526 // \resizebox*{h-length}{v-length}{text}
1527 if (!resizeW.empty() || !resizeH.empty()) {
1528 recmd = "\\resizebox*{";
1529 if (!resizeW.empty())
1534 if (!resizeH.empty())
1543 sprintf(buf, "%g", tangle);
1544 // \rotatebox{angle}{text}
1545 rotate = "\\rotatebox{";
1553 if (!rotate.empty()) cmdbuf += '}';
1554 if (!recmd.empty()) cmdbuf += '}';
1555 if (psubfigure && !tsubcap.empty()) {
1556 cmdbuf = string("\\subfigure{") + tsubcap
1557 + string("}{") + cmdbuf + "}";
1562 void InsetFig::Recompute()
1564 bool changed = changedfname;
1565 int newx, newy, nraw_x, nraw_y;
1567 if (changed) GetPSSizes();
1569 float sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
1570 float cos_a = cos (angle / DEG2PI);
1571 int frame_wid = int(ceil(fabs(cos_a * pswid) + fabs(sin_a * pshgh)));
1572 int frame_hgh= int(ceil(fabs(cos_a * pshgh) + fabs(sin_a * pswid)));
1574 /* now recompute wid and hgh, and if that is changed, set changed */
1575 /* this depends on chosen size of the picture and its bbox */
1576 // This will be redone in 0.13 ... (hen)
1577 if (!fname.empty()) {
1578 // say, total width is 595 pts, as A4 in TeX, thats in 1/72" */
1586 newx = int(28.346 * xwid);
1589 newx = int(72 * xwid);
1591 case PER_PAGE: /* % of page */
1592 newx = int(5.95 * xwid);
1594 case PER_COL: /* % of col */
1595 newx = int(2.975 * xwid);
1599 if (wtype && frame_wid) newy = newx*frame_hgh/frame_wid;
1603 //lyxerr << "This should not happen!" << endl;
1606 newy = int(28.346 * xhgh);
1609 newy = int(72 * xhgh);
1611 case PER_PAGE: /* % of page */
1612 newy = int(8.42 * xhgh);
1615 // Doesn't occur; case exists to suppress
1616 // compiler warnings.
1619 if (htype && !wtype && frame_hgh)
1620 newx = newy*frame_wid/frame_hgh;
1629 nraw_x = int((1.0 * pswid * newx)/frame_wid);
1634 nraw_y = int((1.0 * pshgh * newy)/frame_hgh);
1636 // cannot be zero, actually, set it to some minimum, so its clickable
1637 if (newx < 5) newx = 5;
1638 if (newy < 5) newy = 5;
1640 if (newx != wid || newy != hgh ||
1641 nraw_x != raw_wid || nraw_y != raw_hgh ||
1642 flags != pflags || subfigure != psubfigure)
1650 subfigure = psubfigure;
1653 figdata * pf = figure->data;
1656 if (!fname.empty() && (flags & 3)
1657 && !lyxrc->ps_command.empty()) {
1658 // do not display if there is "do not display"
1659 // chosen (Matthias 260696)
1660 figure->data = getfigdata(wid, hgh, fname,
1661 psx, psy, pswid, pshgh,
1663 angle, flags & (3|8));
1664 } else figure->data = 0;
1666 // free the old data
1667 if (pf) freefigdata(pf);
1670 changedfname = false;
1674 void InsetFig::GetPSSizes()
1676 /* get %%BoundingBox: from postscript file */
1678 /* defaults to associated size
1679 * ..just in case the PS-file is not readable (Henner, 24-Aug-97)
1686 if (fname.empty()) return;
1688 ifstream ifs(fname.c_str());
1690 if (!ifs) return; // file not found !!!!
1692 /* defaults to A4 page */
1698 char lastchar = 0; ifs.get(lastchar);
1700 char c = 0; ifs.get(c);
1702 lyxerr.debug() << "End of (E)PS file reached and"
1703 " no BoundingBox!" << endl;
1706 if (c == '%' && lastchar == '%') {
1708 if (p.empty()) break;
1709 // we should not use this, with it we cannot
1710 // discover bounding box and end of file.
1711 //if (strcmp(p, "EndComments") == 0) break;
1712 lyxerr.debug() << "Token: `" << p << "'" << endl;
1713 if (p == "BoundingBox:") {
1714 float fpsx, fpsy, fpswid, fpshgh;
1715 if (ifs >> fpsx >> fpsy >> fpswid >> fpshgh) {
1718 pswid = int(fpswid);
1719 pshgh = int(fpshgh);
1721 if (lyxerr.debugging()) {
1722 lyxerr << "%%%%BoundingBox:"
1740 void InsetFig::CallbackFig(long arg)
1745 if (lyxerr.debugging()) {
1746 lyxerr << "Figure callback, arg " << arg << endl;
1752 case 12: /* width type */
1759 fl_deactivate_object(form->Width);
1764 fl_activate_object(form->Width);
1769 fl_activate_object(form->Width);
1774 fl_activate_object(form->Width);
1779 fl_activate_object(form->Width);
1782 lyxerr.debug() << "Unknown type!" << endl;
1789 case 22: /* height type */
1795 fl_deactivate_object(form->Height);
1800 fl_activate_object(form->Height);
1805 fl_activate_object(form->Height);
1810 fl_activate_object(form->Height);
1813 lyxerr.debug() << "Unknown type!" << endl;
1819 pflags = pflags & ~3; /* wysiwyg0 */
1822 pflags = (pflags & ~3) | 1; /* wysiwyg1 */
1825 pflags = (pflags & ~3) | 2; /* wysiwyg2 */
1828 pflags = (pflags & ~3) | 3; /* wysiwyg3 */
1831 pflags ^= 4; /* frame */
1834 pflags ^= 8; /* do translations */
1837 psubfigure = !psubfigure; /* This is a subfigure */
1840 regen = true; /* regenerate command */
1842 case 0: /* browse file */
1846 case 1: /* preview */
1847 p = fl_get_input(form->EpsFile);
1851 case 8: /* ok (apply and close) */
1852 if(!current_view->buffer()->isReadonly()) {
1855 xwid = atof(fl_get_input(form->Width));
1856 xhgh = atof(fl_get_input(form->Height));
1857 angle = atof(fl_get_input(form->Angle));
1858 p = fl_get_input(form->EpsFile);
1860 string buf1 = OnlyPath(owner->fileName());
1861 fname = MakeAbsPath(p, buf1);
1862 changedfname = true;
1864 if (!fname.empty()) {
1865 changedfname = true;
1869 subcaption = fl_get_input(form->Subcaption);
1873 /* now update inset */
1874 if (lyxerr.debugging()) {
1875 lyxerr << "Update: ["
1876 << wid << 'x' << hgh << ']' << endl;
1878 current_view->updateInset(this, true);
1880 fl_set_focus_object(form->Figure, form->OkBtn);
1881 fl_hide_form(form->Figure);
1882 #if FL_REVISION == 89
1883 #warning Reactivate this free_form calls
1885 fl_free_form(form->Figure);
1886 free(form); // Why free?
1892 // The user has already been informed about RO in ::Edit
1893 if(arg == 7) // if 'Apply'
1896 case 9: /* cancel = restore and close */
1897 fl_set_focus_object(form->Figure, form->OkBtn);
1898 fl_hide_form(form->Figure);
1899 #if FL_REVISION == 89
1900 #warning Reactivate this free_form calls
1901 #warning Jug, is this still a problem?
1903 fl_free_form(form->Figure);
1904 free(form); // Why free?
1910 if (regen) TempRegenerate();
1915 void DisableFigurePanel(FD_Figure * const form)
1917 fl_deactivate_object(form->EpsFile);
1918 fl_deactivate_object(form->Browse);
1919 fl_deactivate_object(form->Width);
1920 fl_deactivate_object(form->Height);
1921 fl_deactivate_object(form->Frame);
1922 fl_deactivate_object(form->Translations);
1923 fl_deactivate_object(form->Angle);
1924 fl_deactivate_object(form->HeightGrp);
1925 fl_deactivate_object(form->page2);
1926 fl_deactivate_object(form->Default2);
1927 fl_deactivate_object(form->cm2);
1928 fl_deactivate_object(form->in2);
1929 fl_deactivate_object(form->HeightLabel);
1930 fl_deactivate_object(form->WidthLabel);
1931 fl_deactivate_object(form->DisplayGrp);
1932 fl_deactivate_object(form->Wysiwyg3);
1933 fl_deactivate_object(form->Wysiwyg0);
1934 fl_deactivate_object(form->Wysiwyg2);
1935 fl_deactivate_object(form->Wysiwyg1);
1936 fl_deactivate_object(form->WidthGrp);
1937 fl_deactivate_object(form->Default1);
1938 fl_deactivate_object(form->cm1);
1939 fl_deactivate_object(form->in1);
1940 fl_deactivate_object(form->page1);
1941 fl_deactivate_object(form->column1);
1942 fl_deactivate_object(form->Subcaption);
1943 fl_deactivate_object(form->Subfigure);
1944 fl_deactivate_object (form->OkBtn);
1945 fl_deactivate_object (form->ApplyBtn);
1946 fl_set_object_lcol (form->OkBtn, FL_INACTIVE);
1947 fl_set_object_lcol (form->ApplyBtn, FL_INACTIVE);
1952 void EnableFigurePanel(FD_Figure * const form)
1954 fl_activate_object(form->EpsFile);
1955 fl_activate_object(form->Browse);
1956 fl_activate_object(form->Width);
1957 fl_activate_object(form->Height);
1958 fl_activate_object(form->Frame);
1959 fl_activate_object(form->Translations);
1960 fl_activate_object(form->Angle);
1961 fl_activate_object(form->HeightGrp);
1962 fl_activate_object(form->page2);
1963 fl_activate_object(form->Default2);
1964 fl_activate_object(form->cm2);
1965 fl_activate_object(form->in2);
1966 fl_activate_object(form->HeightLabel);
1967 fl_activate_object(form->WidthLabel);
1968 fl_activate_object(form->DisplayGrp);
1969 fl_activate_object(form->Wysiwyg3);
1970 fl_activate_object(form->Wysiwyg0);
1971 fl_activate_object(form->Wysiwyg2);
1972 fl_activate_object(form->Wysiwyg1);
1973 fl_activate_object(form->WidthGrp);
1974 fl_activate_object(form->Default1);
1975 fl_activate_object(form->cm1);
1976 fl_activate_object(form->in1);
1977 fl_activate_object(form->page1);
1978 fl_activate_object(form->column1);
1979 fl_activate_object(form->Subcaption);
1980 fl_activate_object(form->Subfigure);
1981 fl_activate_object (form->OkBtn);
1982 fl_activate_object (form->ApplyBtn);
1983 fl_set_object_lcol (form->OkBtn, FL_BLACK);
1984 fl_set_object_lcol (form->ApplyBtn, FL_BLACK);
1988 void InsetFig::RestoreForm()
1992 EnableFigurePanel(form);
1995 fl_set_button(form->Default1, (wtype == 0));
1996 fl_set_button(form->cm1, (wtype == 1));
1997 fl_set_button(form->in1, (wtype == 2));
1998 fl_set_button(form->page1, (wtype == 3));
1999 fl_set_button(form->column1, (wtype == 4));
2001 fl_deactivate_object(form->Width);
2003 fl_activate_object(form->Width);
2006 // enable and disable should be put here.
2008 fl_set_button(form->Default2, (htype == 0));
2009 fl_set_button(form->cm2, (htype == 1));
2010 fl_set_button(form->in2, (htype == 2));
2011 fl_set_button(form->page2, (htype == 3));
2012 // enable and disable should be put here.
2014 fl_deactivate_object(form->Height);
2016 fl_activate_object(form->Height);
2019 int pflags = flags & 3;
2020 fl_set_button(form->Wysiwyg0, (pflags == 0));
2021 fl_set_button(form->Wysiwyg1, (pflags == 1));
2022 fl_set_button(form->Wysiwyg2, (pflags == 2));
2023 fl_set_button(form->Wysiwyg3, (pflags == 3));
2024 fl_set_button(form->Frame, ((flags & 4) != 0));
2025 fl_set_button(form->Translations, ((flags & 8) != 0));
2026 fl_set_button(form->Subfigure, (subfigure != 0));
2028 psubfigure = subfigure;
2029 sprintf(buf, "%g", xwid);
2030 fl_set_input(form->Width, buf);
2031 sprintf(buf, "%g", xhgh);
2032 fl_set_input(form->Height, buf);
2033 sprintf(buf, "%g", angle);
2034 fl_set_input(form->Angle, buf);
2035 if (!fname.empty()){
2036 string buf1 = OnlyPath(owner->fileName());
2037 string fname2 = MakeRelPath(fname, buf1);
2038 fl_set_input(form->EpsFile, fname2.c_str());
2040 else fl_set_input(form->EpsFile, "");
2041 fl_set_input(form->Subcaption, subcaption.c_str());
2042 if(current_view->buffer()->isReadonly())
2043 DisableFigurePanel(form);
2049 void InsetFig::Preview(char const * p)
2054 lyxerr << "Cannot fork process!" << endl;
2059 return; // parent process
2062 string buf1 = OnlyPath(owner->fileName());
2063 string buf2 = MakeAbsPath(p, buf1);
2065 lyxerr << "Error during rendering "
2066 << execlp(lyxrc->view_pspic_command.c_str(),
2067 lyxrc->view_pspic_command.c_str(),
2074 void InsetFig::BrowseFile()
2076 static string current_figure_path;
2077 static int once = 0;
2080 if (lyxerr.debugging()) {
2081 lyxerr << "Filename: "
2082 << owner->fileName() << endl;
2084 string p = fl_get_input(form->EpsFile);
2086 string buf = MakeAbsPath(owner->fileName());
2087 string buf2 = OnlyPath(buf);
2089 buf = MakeAbsPath(p, buf2);
2090 buf = OnlyPath(buf);
2092 buf = OnlyPath(owner->fileName().c_str());
2095 // Does user clipart directory exist?
2096 string bufclip = AddName (user_lyxdir, "clipart");
2097 FileInfo fileInfo(bufclip);
2098 if (!(fileInfo.isOK() && fileInfo.isDir()))
2099 // No - bail out to system clipart directory
2100 bufclip = AddName (system_lyxdir, "clipart");
2103 fileDlg.SetButton(0, _("Clipart"), bufclip);
2104 fileDlg.SetButton(1, _("Document"), buf);
2110 p = fileDlg.Select(_("EPS Figure"),
2111 current_figure_path,
2114 p = fileDlg.Select(_("EPS Figure"), buf,
2119 if (p.empty()) return;
2121 buf = MakeRelPath(p, buf2);
2122 current_figure_path = OnlyPath(p);
2125 if (contains(p, "#") || contains(p, "~") || contains(p, "$")
2126 || contains(p, "%") || contains(p, " "))
2128 WriteAlert(_("Filename can't contain any "
2129 "of these characters:"),
2130 // xgettext:no-c-format
2131 _("space, '#', '~', '$' or '%'."));
2136 if (form) fl_set_input(form->EpsFile, buf.c_str());
2140 void GraphicsCB(FL_OBJECT * obj, long arg)
2142 /* obj->form contains the form */
2144 if (lyxerr.debugging()) {
2145 lyxerr << "GraphicsCB callback: " << arg << endl;
2148 /* find inset we were reacting to */
2149 for (int i = 0; i < figinsref; ++i)
2150 if (figures[i]->inset->form && figures[i]->inset->form->Figure
2153 if (lyxerr.debugging()) {
2154 lyxerr << "Calling back figure " << i << endl;
2156 figures[i]->inset->CallbackFig(arg);
2162 void HideFiguresPopups()
2164 for (int i = 0; i < figinsref; ++i)
2165 if (figures[i]->inset->form
2166 && figures[i]->inset->form->Figure->visible) {
2167 if (lyxerr.debugging()) {
2168 lyxerr << "Hiding figure " << i << endl;
2170 // hide and free the form
2171 figures[i]->inset->CallbackFig(9);