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.
72 extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
73 // better for asyncron updating:
74 void PutInsetIntoInsetUpdateList(Inset * inset);
75 extern void ProhibitInput();
76 extern void AllowInput();
78 static float const DEG2PI = 57.295779513;
79 static int const figallocchunk = 32;
81 static int figinsref = 0; /* number of figures */
82 static int figarrsize = 0; /* current max number of figures */
83 static int bmpinsref = 0; /* number of bitmaps */
84 static int bmparrsize = 0; /* current max number of bitmaps */
86 struct queue_element {
87 float rx, ry; // resolution x and y
88 int ofsx, ofsy; // x and y translation
89 figdata * data; // we are doing it for this data
92 static int const MAXGS = 3; /* maximum 3 gs's at a time */
94 static Figref ** figures; /* all the figures */
95 static figdata ** bitmaps; /* all the bitmaps */
97 static queue<queue_element> gsqueue; // queue for ghostscripting
99 static int gsrunning = 0; /* currently so many gs's are running */
100 static bool bitmap_waiting = false; /* bitmaps are waiting finished */
101 static char bittable[256]; /* bit reversion table */
103 static bool gs_color; // do we allocate colors for gs?
104 static bool color_visual; // is the visual color?
105 static bool gs_xcolor = false; // allocated extended colors
106 static unsigned long gs_pixels[128]; // allocated pixels
107 static int gs_num_pixels; // number of pixels allocated
108 static int gs_spc; // shades per color
109 static bool gs_gray; // is grayscale?
110 static int gs_allcolors; // number of all colors
112 static list<int> pidwaitlist; // pid wait list
114 //extern Colormap color_map;
122 val.foreground = BlackPixel(fl_display,
123 DefaultScreen(fl_display));
126 val.graphics_exposures = false;
127 val.line_style = LineSolid;
129 return XCreateGC(fl_display, RootWindow(fl_display, 0),
130 GCForeground | GCFunction | GCGraphicsExposures
131 | GCLineWidth | GCLineStyle , &val);
138 void addpidwait(int pid)
140 // adds pid to pid wait list
141 pidwaitlist.push_back(pid);
143 if (lyxerr.debugging()) {
144 lyxerr << "Pids to wait for: \n";
145 for (list<int>::const_iterator cit = pidwaitlist.begin();
146 cit != pidwaitlist.end(); ++cit) {
147 lyxerr << (*cit) << '\n';
154 extern "C" int GhostscriptMsg(FL_OBJECT *, Window, int, int,
159 XClientMessageEvent * e = reinterpret_cast<XClientMessageEvent*>(ev);
161 if(lyxerr.debugging()) {
162 lyxerr << "ClientMessage, win:[xx] gs:[" << e->data.l[0]
163 << "] pm:[" << e->data.l[1] << "]" << endl;
166 // just kill gs, that way it will work for sure
167 // This loop looks like S**T so it probably is...
168 for (int i = 0; i < bmpinsref; ++i)
169 if ((long)bitmaps[i]->bitmap == (long)e->data.l[1]) {
171 figdata * p = bitmaps[i];
174 // first update p->bitmap, if necessary
175 if (p->bitmap != None
176 && p->flags > (1|8) && gs_color && p->wid) {
177 // query current colormap and re-render
178 // the pixmap with proper colors
180 XWindowAttributes wa;
181 register XImage * im;
186 int spc2 = gs_spc * gs_spc;
190 GC gc = local_gc_copy;
192 XGetWindowAttributes(fl_display,
197 if (lyxerr.debugging()) {
198 lyxerr << "Starting image translation "
201 << p->wid << "x" << p->hgh
203 << " " << XYPixmap << endl;
205 // now fork rendering process
207 if (forkstat == -1) {
209 << "Cannot fork, using slow "
210 "method for pixmap translation." << endl;
211 tmpdisp = fl_display;
212 } else if (forkstat > 0) { // parent
214 if (lyxerr.debugging()) {
215 lyxerr << "Spawned child "
218 addpidwait(forkstat);
221 tmpdisp = XOpenDisplay(XDisplayName(0));
224 im = XGetImage(tmpdisp, p->bitmap, 0, 0,
225 p->wid, p->hgh, (1<<wa.depth)-1, XYPixmap);
227 if (lyxerr.debugging()) {
228 lyxerr << "Got the image" << endl;
231 if (lyxerr.debugging()) {
232 lyxerr << "Error getting the image" << endl;
237 // query current colormap
238 XColor * cmap = new XColor[gs_allcolors];
239 for (i = 0; i < gs_allcolors; ++i) cmap[i].pixel = i;
241 XQueryColors(tmpdisp, fl_state[fl_get_vclass()].colormap, cmap, gs_allcolors);
243 XQueryColors(tmpdisp, color_map, cmap, gs_allcolors);
247 // now we process all the image
248 for (y = 0; y < p->hgh; ++y) {
249 for (int x = 0; x < wid; ++x) {
254 gs_pixels[((pc->red+6553)*
255 spc1/65535)*spc2+((pc->green+6553)*
256 spc1/65535)*gs_spc+((pc->blue+6553)*
261 // This must be correct.
263 if (lyxerr.debugging()) {
264 lyxerr << "Putting image back"
267 XPutImage(tmpdisp, p->bitmap,
269 0, 0, p->wid, p->hgh);
271 if (lyxerr.debugging()) {
272 lyxerr << "Done translation"
277 if (lyxerr.debugging()) {
278 lyxerr << "Killing gs "
281 lyx::kill(p->gspid, SIGHUP);
283 sprintf(tmp, "%s/~lyxgs%d.ps",
284 system_tempdir.c_str(),
288 XCloseDisplay(tmpdisp);
292 if (lyxerr.debugging()) {
293 lyxerr << "Killing gs "
296 lyx::kill(p->gspid, SIGHUP);
298 sprintf(tmp, "%s/~lyxgs%d.ps",
299 system_tempdir.c_str(),
309 static void AllocColors(int num)
310 // allocate color cube numxnumxnum, if possible
312 if (lyxerr.debugging()) {
313 lyxerr << "Allocating color cube " << num
314 << 'x' << num << 'x' << num << endl;
318 lyxerr << "Error allocating color colormap." << endl;
322 if (num > 5) num = 5;
324 for (int i = 0; i < num * num * num; ++i) {
325 xcol.red = 65535 * (i / (num * num)) / (num - 1);
326 xcol.green = 65535 * ((i / num) % num) / (num - 1);
327 xcol.blue = 65535 * (i % num) / (num - 1);
328 xcol.flags = DoRed | DoGreen | DoBlue;
329 if (!XAllocColor(fl_display,
330 fl_state[fl_get_vclass()].colormap, &xcol)) {
331 if (i) XFreeColors(fl_display,
332 fl_state[fl_get_vclass()].colormap,
334 if(lyxerr.debugging()) {
335 lyxerr << "Cannot allocate color cube "
338 AllocColors(num - 1);
341 gs_pixels[i] = xcol.pixel;
346 gs_num_pixels = num * num * num;
350 // allocate grayscale ramp
352 void AllocGrays(int num)
354 if (lyxerr.debugging()) {
355 lyxerr << "Allocating grayscale colormap "
360 lyxerr << "Error allocating grayscale colormap." << endl;
364 if (num > 128) num = 128;
366 for (int i = 0; i < num; ++i) {
367 xcol.red = xcol.green = xcol.blue = 65535 * i / (num - 1);
368 xcol.flags = DoRed | DoGreen | DoBlue;
369 if (!XAllocColor(fl_display,
370 fl_state[fl_get_vclass()].colormap, &xcol)) {
371 if (i) XFreeColors(fl_display,
372 fl_state[fl_get_vclass()].colormap,
374 if (lyxerr.debugging()) {
375 lyxerr << "Cannot allocate grayscale "
381 gs_pixels[i] = xcol.pixel;
391 bmparrsize = figarrsize = figallocchunk;
392 typedef Figref * Figref_p;
393 figures = new Figref_p[figallocchunk];
394 typedef figdata * figdata_p;
395 bitmaps = new figdata_p[figallocchunk];
398 for (unsigned int i = 0; i < 256; ++i) {
400 for (unsigned int j = 0; j < 8; ++j)
401 if (i & (1 << (7-j))) k |= 1 << j;
402 bittable[i] = char(~k);
405 fl_add_canvas_handler(figinset_canvas, ClientMessage,
406 GhostscriptMsg, current_view->owner()->getMainForm());
409 // now we have to init color_map
410 if (!color_map) color_map = DefaultColormap(fl_display,
411 DefaultScreen(fl_display));
413 // allocate color cube on pseudo-color display
416 local_gc_copy = createGC();
418 Visual * vi = DefaultVisual(fl_display, DefaultScreen(fl_display));
419 if (lyxerr.debugging()) {
420 printf("Visual ID: %ld, class: %d, bprgb: %d, mapsz: %d\n",
421 vi->visualid, vi->c_class,
422 vi->bits_per_rgb, vi->map_entries);
424 color_visual = ( (vi->c_class == StaticColor) ||
425 (vi->c_class == PseudoColor) ||
426 (vi->c_class == TrueColor) ||
427 (vi->c_class == DirectColor) );
428 if ((vi->c_class & 1) == 0) return;
429 // now allocate colors
430 if (vi->c_class == GrayScale) {
431 // allocate grayscale
432 AllocGrays(vi->map_entries/2);
434 // allocate normal color
436 while (i * i * i * 2 > vi->map_entries) --i;
439 gs_allcolors = vi->map_entries;
450 lyxerr.debug() << "Unregistering figures..." << endl;
452 fl_remove_canvas_handler(figinset_canvas, ClientMessage,
457 lyxerr.debug() << "Freeing up the colors..." << endl;
458 XFreeColors(fl_display, color_map, gs_pixels,
460 /******????????????????? what's planes in this case ??????***/
466 int FindBmpIndex(figdata * tmpdata)
469 while (i < bmpinsref) {
470 if (bitmaps[i] == tmpdata) return i;
477 static void freefigdata(figdata * tmpdata)
480 if (tmpdata->ref) return;
482 if (tmpdata->gspid > 0) {
483 int pid = tmpdata->gspid;
485 // kill ghostscript and unlink it's files
487 lyx::kill(pid, SIGKILL);
488 sprintf(buf, "%s/~lyxgs%d.ps", system_tempdir.c_str(), pid);
492 if (tmpdata->bitmap) XFreePixmap(fl_display, tmpdata->bitmap);
494 int i = FindBmpIndex(tmpdata);
496 while (i < bmpinsref) {
497 bitmaps[i] = bitmaps[i + 1];
503 static void runqueue()
505 // run queued requests for ghostscript, if any
506 if (!gsrunning && gs_color && !gs_xcolor) {
507 // here alloc all colors, so that gs will use only
508 // those we allocated for it
513 while (gsrunning < MAXGS) {
514 char tbuf[384], tbuf2[80];
518 if (gsqueue.empty()) {
519 if (!gsrunning && gs_xcolor) {
520 // de-allocate rest of colors
526 queue_element * p = &gsqueue.front();
535 if (lyxerr.debugging()) {
536 lyxerr << "GS start error! Cannot fork."
539 p->data->broken = true;
540 p->data->reading = false;
543 if (pid == 0) { // child
544 char ** env, rbuf[80], gbuf[40];
546 Display * tempdisp = XOpenDisplay(XDisplayName(0));
548 // create translation file
549 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
553 ofs << "gsave clippath pathbbox grestore\n"
555 << "/ury exch def /urx exch def /lly exch def "
557 << p->data->wid / 2.0 << " "
558 << p->data->hgh / 2.0 << " translate\n"
559 << p->data->angle << " rotate\n"
560 << -(p->data->raw_wid / 2.0) << " "
561 << -(p->data->raw_hgh / 2.0) << " translate\n"
562 << p->rx / 72.0 << " " << p->ry / 72.0
564 << -p->ofsx << " " << -p->ofsy << " translate\n"
566 ofs.close(); // Don't remove this.
568 // gs process - set ghostview environment first
569 sprintf(tbuf2, "GHOSTVIEW=%ld %ld", fl_get_canvas_id(
570 figinset_canvas), p->data->bitmap);
572 // now set up ghostview property on a window
573 sprintf(tbuf, "0 0 0 0 %d %d 72 72 0 0 0 0",
574 p->data->wid, p->data->hgh);
575 // #warning BUG seems that the only bug here
576 // might be the hardcoded dpi.. Bummer!
578 if (lyxerr.debugging()) {
579 lyxerr << "Will set GHOSTVIEW property to ["
580 << tbuf << "]" << endl;
582 // wait until property is deleted if executing multiple
585 // grab server to prevent other child
586 // interfering with setting GHOSTVIEW property
587 if (lyxerr.debugging()) {
588 lyxerr << "Grabbing the server"
591 XGrabServer(tempdisp);
592 prop = XListProperties(tempdisp,
594 figinset_canvas), &nprop);
598 for (i = 0; i < nprop; ++i) {
599 char * p = XGetAtomName(tempdisp,
601 if (strcmp(p, "GHOSTVIEW") == 0) {
607 XFree(reinterpret_cast<char *>(prop)); // jc:
609 // release the server
610 XUngrabServer(tempdisp);
612 // ok, property found, we must wait until
613 // ghostscript deletes it
614 if (lyxerr.debugging()) {
615 lyxerr << "Releasing the server\n["
617 << "] GHOSTVIEW property"
618 " found. Waiting." << endl;
624 XChangeProperty(tempdisp,
625 fl_get_canvas_id(figinset_canvas),
626 XInternAtom(tempdisp, "GHOSTVIEW", false),
627 XInternAtom(tempdisp, "STRING", false),
629 reinterpret_cast<unsigned char*>(tbuf),
632 switch (p->data->flags & 3) {
633 case 0: tbuf[0] = 'H'; break; // Hidden
634 case 1: tbuf[0] = 'M'; break; // Mono
635 case 2: tbuf[0] = 'G'; break; // Gray
638 tbuf[0] = 'C'; // Color
640 tbuf[0] = 'G'; // Gray
644 sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
645 DefaultScreenOfDisplay(fl_display)),
646 fl_get_pixel(FL_WHITE));
648 XChangeProperty(tempdisp,
649 fl_get_canvas_id(figinset_canvas),
650 XInternAtom(tempdisp,
651 "GHOSTVIEW_COLORS", false),
652 XInternAtom(tempdisp, "STRING", false),
654 reinterpret_cast<unsigned char*>(tbuf),
656 XUngrabServer(tempdisp);
658 if (lyxerr.debugging()) {
659 lyxerr << "Releasing the server" << endl;
661 XCloseDisplay(tempdisp);
663 // set up environment
664 while (environ[ne]) ++ne;
665 typedef char * char_p;
666 env = new char_p[ne + 2];
668 memcpy(&env[1], environ, sizeof(char*) * (ne + 1));
671 // now make gs command
673 // close(1); do NOT close. If GS writes out
674 // errors it would hang. (Matthias 290596)
675 sprintf(rbuf, "-r%gx%g", p->rx, p->ry);
676 sprintf(gbuf, "-g%dx%d", p->data->wid, p->data->hgh);
677 // now chdir into dir with .eps file, to be on the safe
679 chdir(OnlyPath(p->data->fname).c_str());
680 // make temp file name
681 sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
683 if (lyxerr.debugging()) {
684 lyxerr << "starting gs " << tbuf << " "
686 << ", pid: " << getpid() << endl;
689 int err = execlp(lyxrc->ps_command.c_str(),
690 lyxrc->ps_command.c_str(),
692 "-dNOPAUSE", "-dQUIET",
695 p->data->fname.c_str(),
696 "showpage.ps", "quit.ps", "-", 0);
697 // if we are still there, an error occurred.
698 lyxerr << "Error executing ghostscript. "
699 << "Code: " << err << endl;
700 lyxerr.debug() << "Cmd: "
704 << p->data->fname << endl;
707 // normal process (parent)
708 if (lyxerr.debugging()) {
709 lyxerr << "GS [" << pid << "] started" << endl;
712 p->data->gspid = pid;
719 static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
721 // recompute the stuff and put in the queue
725 p.rx = (float(data->raw_wid) * 72.0) / pswid;
726 p.ry = (float(data->raw_hgh) * 72.0) / pshgh;
732 // if possible, run the queue
737 static figdata * getfigdata(int wid, int hgh, string 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 */
743 if (fname.empty()) return 0;
746 while (i < bmpinsref) {
747 if (bitmaps[i]->wid == wid && bitmaps[i]->hgh == hgh &&
748 bitmaps[i]->flags == flags && bitmaps[i]->fname == fname &&
749 bitmaps[i]->angle == angle) {
755 /* not found -> create new record or return 0 if no record */
757 if (bmpinsref > bmparrsize) {
758 // allocate more space
759 bmparrsize += figallocchunk;
760 typedef figdata * figdata_p;
761 figdata ** tmp = new figdata_p[bmparrsize];
763 sizeof(figdata*) * (bmparrsize - figallocchunk));
767 figdata * p = new figdata;
768 bitmaps[bmpinsref-1] = p;
771 p->raw_wid = raw_wid;
772 p->raw_hgh = raw_hgh;
776 XWindowAttributes wa;
777 XGetWindowAttributes(fl_display, fl_get_canvas_id(
778 figinset_canvas), &wa);
780 if (lyxerr.debugging()) {
781 lyxerr << "Create pixmap disp:" << fl_display
782 << " scr:" << DefaultScreen(fl_display)
785 << " depth:" << wa.depth << endl;
793 p->bitmap = XCreatePixmap(fl_display, fl_get_canvas_id(
794 figinset_canvas), wid, hgh, wa.depth);
796 // initialize reading of .eps file with correct sizes and stuff
797 addwait(psx, psy, pswid, pshgh, p);
808 static void getbitmap(figdata * p)
814 static void makeupdatelist(figdata * p)
816 for (int i = 0; i < figinsref; ++i)
817 if (figures[i]->data == p) {
818 if (lyxerr.debugging()) {
819 lyxerr << "Updating inset "
823 // add inset figures[i]->inset into to_update list
824 PutInsetIntoInsetUpdateList(figures[i]->inset);
829 void sigchldchecker(pid_t pid, int * status)
831 lyxerr.debug() << "Got pid = " << pid << endl;
832 bool pid_handled = false;
833 for (int i = bmpinsref - 1; i >= 0; --i) {
834 if (bitmaps[i]->reading && pid == bitmaps[i]->gspid) {
835 lyxerr.debug() << "Found pid in bitmaps" << endl;
836 // now read the file and remove it from disk
837 figdata * p = bitmaps[i];
839 if (bitmaps[i]->gsdone) *status = 0;
841 lyxerr.debug() << "GS [" << pid
842 << "] exit OK." << endl;
844 lyxerr << "GS [" << pid << "] error "
846 << WIFEXITED(*status)
847 << " " << WEXITSTATUS(*status)
848 << " S:" << WIFSIGNALED(*status)
849 << " " << WTERMSIG(*status) << endl;
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" << endl;
872 list<int>::iterator it = find(pidwaitlist.begin(),
873 pidwaitlist.end(), pid);
874 if (it != pidwaitlist.end()) {
875 lyxerr.debug() << "Found pid in pidwait\n"
876 << "Caught child pid of recompute "
877 "routine" << pid << endl;
878 pidwaitlist.erase(it);
882 lyxerr.debug() << "waitpid error" << endl;
885 lyxerr << "The process or process group specified by "
886 "pid does not exist or is not a child of "
887 "the calling process or can never be in the "
888 "states specified by options." << endl;
891 lyxerr << "waitpid() was interrupted due to the "
892 "receipt of a signal sent by the calling "
896 lyxerr << "An invalid value was specified for "
900 lyxerr << "Unknown error from waitpid" << endl;
903 } else if (pid == 0) {
904 lyxerr << "waitpid nohang" << endl;;
906 lyxerr.debug() << "normal exit from childhandler" << endl;
911 static void getbitmaps()
913 bitmap_waiting = false;
914 for (int i = 0; i < bmpinsref; ++i)
915 if (bitmaps[i]->gspid > 0 && !bitmaps[i]->reading)
916 getbitmap(bitmaps[i]);
920 static void RegisterFigure(InsetFig * fi)
922 if (figinsref == 0) InitFigures();
925 if (figinsref > figarrsize) {
926 // allocate more space
927 figarrsize += figallocchunk;
928 typedef Figref * Figref_p;
929 Figref ** tmp = new Figref_p[figarrsize];
931 sizeof(Figref*)*(figarrsize-figallocchunk));
935 Figref * tmpfig = new Figref;
938 figures[figinsref-1] = tmpfig;
941 if (lyxerr.debugging()) {
942 lyxerr << "Register Figure: buffer:["
943 << current_view->buffer() << "]" << endl;
948 int FindFigIndex(Figref * tmpfig)
951 while (i < figinsref) {
952 if (figures[i] == tmpfig) return i;
959 static void UnregisterFigure(InsetFig * fi)
961 Figref * tmpfig = fi->figure;
963 if (tmpfig->data) freefigdata(tmpfig->data);
964 if (tmpfig->inset->form) {
965 if (tmpfig->inset->form->Figure->visible) {
966 fl_set_focus_object(tmpfig->inset->form->Figure,
967 tmpfig->inset->form->OkBtn);
968 fl_hide_form(tmpfig->inset->form->Figure);
970 #if FL_REVISION == 89
971 #warning Reactivate this free_form calls
973 fl_free_form(tmpfig->inset->form->Figure);
974 free(tmpfig->inset->form); // Why free?
975 tmpfig->inset->form = 0;
978 int i = FindFigIndex(tmpfig);
980 while (i < figinsref) {
981 figures[i] = figures[i+1];
986 if (figinsref == 0) DoneFigures();
990 static string NextToken(istream & is)
998 } while (!is.eof() && !isspace(c));
999 token.erase(token.length() - 1); // remove the isspace
1005 InsetFig::InsetFig(int tmpx, int tmpy, Buffer * o)
1015 psubfigure = subfigure = false;
1016 xwid = xhgh = angle = 0;
1018 raw_wid = raw_hgh = 0;
1019 changedfname = false;
1020 RegisterFigure(this);
1024 InsetFig::~InsetFig()
1026 if (lyxerr.debugging()) {
1027 lyxerr << "Figure destructor called" << endl;
1029 UnregisterFigure(this);
1033 int InsetFig::ascent(Painter &, LyXFont const &) const
1039 int InsetFig::descent(Painter &, LyXFont const &) const
1045 int InsetFig::width(Painter &, LyXFont const &) const
1051 void InsetFig::draw(Painter & pain, LyXFont const & f,
1052 int baseline, float & x) const
1056 if (bitmap_waiting) getbitmaps();
1058 // I wish that I didn't have to use this
1059 // but the figinset code is so complicated so
1060 // I don't want to fiddle with it now.
1062 if (figure && figure->data && figure->data->bitmap &&
1063 !figure->data->reading && !figure->data->broken) {
1065 pain.pixmap(int(x + 1), baseline - hgh,
1066 wid, hgh, figure->data->bitmap);
1069 pain.rectangle(int(x), baseline - hgh - 1,
1075 pain.rectangle(x, baseline - hgh - 1, wid + 1, hgh + 1);
1077 if (figure && figure->data) {
1078 if (figure->data->broken) msg = _("[render error]");
1079 else if (figure->data->reading) msg = _("[rendering ... ]");
1081 if (fname.empty()) msg = _("[no file]");
1082 else if ((flags & 3) == 0) msg = _("[not displayed]");
1083 else if (lyxrc->ps_command.empty()) msg = _("[no ghostscript]");
1085 if (!msg) msg = _("[unknown error]");
1087 font.setFamily(LyXFont::SANS_FAMILY);
1088 font.setSize(LyXFont::SIZE_FOOTNOTE);
1089 string justname = OnlyFilename (fname);
1090 pain.text(int(x + 8), baseline - font.maxAscent() - 4,
1093 font.setSize(LyXFont::SIZE_TINY);
1094 pain.text(int(x + 8), baseline - 4, msg, strlen(msg), font);
1096 x += width(pain, font); // ?
1100 void InsetFig::Write(ostream & os)
1103 os << "Figure size " << wid << " " << hgh << "\n";
1104 if (!fname.empty()) {
1105 string buf1 = OnlyPath(owner->fileName());
1106 string fname2 = MakeRelPath(fname, buf1);
1107 os << "file " << fname2 << "\n";
1109 if (!subcaption.empty())
1110 os << "subcaption " << subcaption << "\n";
1111 if (wtype) os << "width " << static_cast<int>(wtype) << " " << xwid << "\n";
1112 if (htype) os << "height " << static_cast<int>(htype) << " " << xhgh << "\n";
1113 if (angle != 0) os << "angle " << angle << "\n";
1114 os << "flags " << flags << "\n";
1115 if (subfigure) os << "subfigure\n";
1119 void InsetFig::Read(LyXLex & lex)
1122 bool finished = false;
1124 while (lex.IsOK() && !finished) {
1127 string const token = lex.GetString();
1128 lyxerr.debug() << "Token: " << token << endl;
1132 else if (token == "\\end_inset") {
1134 } else if (token == "file") {
1136 buf = lex.GetString();
1137 string buf1 = OnlyPath(owner->fileName());
1138 fname = MakeAbsPath(buf, buf1);
1139 changedfname = true;
1141 } else if (token == "extra") {
1143 // kept for backwards compability. Delete in 0.13.x
1144 } else if (token == "subcaption") {
1146 subcaption = lex.GetString();
1147 } else if (token == "label") {
1149 // kept for backwards compability. Delete in 0.13.x
1150 } else if (token == "angle") {
1152 angle = lex.GetFloat();
1153 } else if (token == "size") {
1155 wid = lex.GetInteger();
1157 hgh = lex.GetInteger();
1158 } else if (token == "flags") {
1160 flags = pflags = lex.GetInteger();
1161 } else if (token == "subfigure") {
1162 subfigure = psubfigure = true;
1163 } else if (token == "width") {
1166 typ = lex.GetInteger();
1168 xwid = lex.GetFloat();
1170 case DEF: wtype = DEF; break;
1171 case CM: wtype = CM; break;
1172 case IN: wtype = IN; break;
1173 case PER_PAGE: wtype = PER_PAGE; break;
1174 case PER_COL: wtype = PER_COL; break;
1176 lyxerr.debug() << "Unknown type!" << endl;
1180 } else if (token == "height") {
1183 typ = lex.GetInteger();
1185 xhgh = lex.GetFloat();
1187 case DEF: htype = DEF; break;
1188 case CM: htype = CM; break;
1189 case IN: htype = IN; break;
1190 case PER_PAGE: htype = PER_PAGE; break;
1192 lyxerr.debug() << "Unknown type!" << endl;
1203 int InsetFig::Latex(ostream & os, signed char /* fragile*/ )
1206 if (!cmd.empty()) os << cmd << " ";
1211 int InsetFig::Latex(string & file, signed char /* fragile*/ )
1219 int InsetFig::Linuxdoc(string &/*file*/)
1225 int InsetFig::DocBook(string & file)
1227 string figurename = fname;
1229 if(suffixIs(figurename, ".eps"))
1230 figurename.erase(fname.length() - 5);
1232 file += "@<graphic fileref=\"" + figurename + "\"></graphic>";
1237 void InsetFig::Validate(LaTeXFeatures & features) const
1239 features.graphics = true;
1240 if (subfigure) features.subfigure = true;
1244 unsigned char InsetFig::Editable() const
1250 bool InsetFig::Deletable() const
1256 void InsetFig::Edit(int, int)
1258 lyxerr.debug() << "Editing InsetFig." << endl;
1261 // We should have RO-versions of the form instead.
1262 // The actual prevention of altering a readonly doc
1263 // is done in CallbackFig()
1264 if(current_view->buffer()->isReadonly())
1265 WarnReadonly(current_view->buffer()->fileName());
1268 form = create_form_Figure();
1269 fl_set_form_atclose(form->Figure, CancelCloseBoxCB, 0);
1270 fl_set_object_return(form->Angle, FL_RETURN_ALWAYS);
1271 fl_set_object_return(form->Width, FL_RETURN_ALWAYS);
1272 fl_set_object_return(form->Height, FL_RETURN_ALWAYS);
1275 if (form->Figure->visible) {
1276 fl_raise_form(form->Figure);
1278 fl_show_form(form->Figure, FL_PLACE_MOUSE | FL_PLACE_SIZE,
1279 FL_FULLBORDER, _("Figure"));
1284 Inset * InsetFig::Clone() const
1286 InsetFig * tmp = new InsetFig(100, 100, owner);
1288 if (lyxerr.debugging()) {
1289 lyxerr << "Clone Figure: buffer:["
1290 << current_view->buffer()
1291 << "], cbuffer:[xx]" << endl;
1296 tmp->raw_wid = raw_wid;
1297 tmp->raw_hgh = raw_hgh;
1302 tmp->pflags = pflags;
1303 tmp->subfigure = subfigure;
1304 tmp->psubfigure = psubfigure;
1312 if (!fname.empty() && (flags & 3) && !lyxrc->ps_command.empty()) {
1313 // do not display if there is
1314 // "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()
1336 string resizeW, resizeH;
1337 string rotate, recmd;
1339 if (fname.empty()) {
1340 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1341 cmd += _("empty figure path");
1346 string buf1 = OnlyPath(owner->fileName());
1347 string fname2 = MakeRelPath(fname, buf1);
1349 string gcmd = "\\includegraphics{" + fname2 + '}';
1354 case CM:{// \resizebox*{h-length}{v-length}{text}
1356 sprintf(buf, "%g", xwid); // should find better
1363 sprintf(buf, "%g", xwid);
1370 sprintf(buf, "%g", xwid/100);
1372 resizeW += "\\textwidth";
1377 sprintf(buf, "%g", xwid/100);
1379 resizeW += "\\columnwidth";
1389 sprintf(buf, "%g", xhgh);
1396 sprintf(buf, "%g", xhgh);
1403 sprintf(buf, "%g", xhgh/100);
1405 resizeH += "\\textheight";
1409 // Doesn't occur; case exists to suppress compiler warnings.
1414 if (!resizeW.empty() || !resizeH.empty()) {
1415 recmd = "\\resizebox*{";
1416 if (!resizeW.empty())
1421 if (!resizeH.empty())
1431 sprintf(buf, "%g", angle);
1432 // \rotatebox{angle}{text}
1433 rotate = "\\rotatebox{";
1441 if (!rotate.empty()) cmdbuf += '}';
1442 if (!recmd.empty()) cmdbuf += '}';
1444 if (!subcaption.empty())
1445 cmdbuf = "\\subfigure[" + subcaption +
1446 "]{" + cmdbuf + "}";
1448 cmdbuf = "\\subfigure{" + cmdbuf + "}";
1455 void InsetFig::TempRegenerate()
1458 string resizeW, resizeH;
1459 string rotate, recmd;
1461 char const * tfname = fl_get_input(form->EpsFile);
1462 string tsubcap = fl_get_input(form->Subcaption);
1463 float tangle = atof(fl_get_input(form->Angle));
1464 float txwid = atof(fl_get_input(form->Width));
1465 float txhgh = atof(fl_get_input(form->Height));
1467 if (!tfname || !*tfname) {
1468 cmd = "\\fbox{\\rule[-0.5in]{0pt}{1in}";
1469 cmd += _("empty figure path");
1474 string buf1 = OnlyPath(owner->fileName());
1475 string fname2 = MakeRelPath(tfname, buf1);
1476 // \includegraphics*[<llx,lly>][<urx,ury>]{file}
1477 string gcmd = "\\includegraphics{" + fname2 + '}';
1482 case CM: {// \resizebox*{h-length}{v-length}{text}
1484 sprintf(buf, "%g", txwid); // should find better
1491 sprintf(buf, "%g", txwid);
1498 sprintf(buf, "%g", txwid/100);
1500 resizeW += "\\textwidth";
1505 sprintf(buf, "%g", txwid/100);
1507 resizeW += "\\columnwidth";
1517 sprintf(buf, "%g", txhgh);
1524 sprintf(buf, "%g", txhgh);
1531 sprintf(buf, "%g", txhgh/100);
1533 resizeH += "\\textheight";
1537 // Doesn't occur; case exists to suppress compiler warnings.
1542 // \resizebox*{h-length}{v-length}{text}
1543 if (!resizeW.empty() || !resizeH.empty()) {
1544 recmd = "\\resizebox*{";
1545 if (!resizeW.empty())
1550 if (!resizeH.empty())
1559 sprintf(buf, "%g", tangle);
1560 // \rotatebox{angle}{text}
1561 rotate = "\\rotatebox{";
1569 if (!rotate.empty()) cmdbuf += '}';
1570 if (!recmd.empty()) cmdbuf += '}';
1571 if (psubfigure && !tsubcap.empty()) {
1572 cmdbuf = string("\\subfigure{") + tsubcap
1573 + string("}{") + cmdbuf + "}";
1578 void InsetFig::Recompute()
1580 bool changed = changedfname;
1581 int newx, newy, nraw_x, nraw_y;
1583 if (changed) GetPSSizes();
1585 float sin_a = sin (angle / DEG2PI); /* rotation; H. Zeller 021296 */
1586 float cos_a = cos (angle / DEG2PI);
1587 int frame_wid = int(ceil(fabs(cos_a * pswid) + fabs(sin_a * pshgh)));
1588 int frame_hgh= int(ceil(fabs(cos_a * pshgh) + fabs(sin_a * pswid)));
1590 /* now recompute wid and hgh, and if that is changed, set changed */
1591 /* this depends on chosen size of the picture and its bbox */
1592 // This will be redone in 0.13 ... (hen)
1593 if (!fname.empty()) {
1594 // say, total width is 595 pts, as A4 in TeX, thats in 1/72" */
1602 newx = int(28.346 * xwid);
1605 newx = int(72 * xwid);
1607 case PER_PAGE: /* % of page */
1608 newx = int(5.95 * xwid);
1610 case PER_COL: /* % of col */
1611 newx = int(2.975 * xwid);
1615 if (wtype && frame_wid) newy = newx*frame_hgh/frame_wid;
1619 //lyxerr << "This should not happen!" << endl;
1622 newy = int(28.346 * xhgh);
1625 newy = int(72 * xhgh);
1627 case PER_PAGE: /* % of page */
1628 newy = int(8.42 * xhgh);
1631 // Doesn't occur; case exists to suppress
1632 // compiler warnings.
1635 if (htype && !wtype && frame_hgh)
1636 newx = newy*frame_wid/frame_hgh;
1645 nraw_x = int((1.0 * pswid * newx)/frame_wid);
1650 nraw_y = int((1.0 * pshgh * newy)/frame_hgh);
1652 // cannot be zero, actually, set it to some minimum, so its clickable
1653 if (newx < 5) newx = 5;
1654 if (newy < 5) newy = 5;
1656 if (newx != wid || newy != hgh ||
1657 nraw_x != raw_wid || nraw_y != raw_hgh ||
1658 flags != pflags || subfigure != psubfigure)
1666 subfigure = psubfigure;
1669 figdata * pf = figure->data;
1672 if (!fname.empty() && (flags & 3)
1673 && !lyxrc->ps_command.empty()) {
1674 // do not display if there is "do not display"
1675 // chosen (Matthias 260696)
1676 figure->data = getfigdata(wid, hgh, fname,
1677 psx, psy, pswid, pshgh,
1679 angle, flags & (3|8));
1680 } else figure->data = 0;
1682 // free the old data
1683 if (pf) freefigdata(pf);
1686 changedfname = false;
1690 void InsetFig::GetPSSizes()
1692 /* get %%BoundingBox: from postscript file */
1694 /* defaults to associated size
1695 * ..just in case the PS-file is not readable (Henner, 24-Aug-97)
1702 if (fname.empty()) return;
1704 ifstream ifs(fname.c_str());
1706 if (!ifs) return; // file not found !!!!
1708 /* defaults to A4 page */
1714 char lastchar = 0; ifs.get(lastchar);
1716 char c = 0; ifs.get(c);
1718 lyxerr.debug() << "End of (E)PS file reached and"
1719 " no BoundingBox!" << endl;
1722 if (c == '%' && lastchar == '%') {
1724 if (p.empty()) break;
1725 // we should not use this, with it we cannot
1726 // discover bounding box and end of file.
1727 //if (strcmp(p, "EndComments") == 0) break;
1728 lyxerr.debug() << "Token: `" << p << "'" << endl;
1729 if (p == "BoundingBox:") {
1730 float fpsx, fpsy, fpswid, fpshgh;
1731 if (ifs >> fpsx >> fpsy >> fpswid >> fpshgh) {
1734 pswid = int(fpswid);
1735 pshgh = int(fpshgh);
1737 if (lyxerr.debugging()) {
1738 lyxerr << "%%%%BoundingBox:"
1756 void InsetFig::CallbackFig(long arg)
1761 if (lyxerr.debugging()) {
1762 lyxerr << "Figure callback, arg " << arg << endl;
1768 case 12: /* width type */
1775 fl_deactivate_object(form->Width);
1780 fl_activate_object(form->Width);
1785 fl_activate_object(form->Width);
1790 fl_activate_object(form->Width);
1795 fl_activate_object(form->Width);
1798 lyxerr.debug() << "Unknown type!" << endl;
1805 case 22: /* height type */
1811 fl_deactivate_object(form->Height);
1816 fl_activate_object(form->Height);
1821 fl_activate_object(form->Height);
1826 fl_activate_object(form->Height);
1829 lyxerr.debug() << "Unknown type!" << endl;
1835 pflags = pflags & ~3; /* wysiwyg0 */
1838 pflags = (pflags & ~3) | 1; /* wysiwyg1 */
1841 pflags = (pflags & ~3) | 2; /* wysiwyg2 */
1844 pflags = (pflags & ~3) | 3; /* wysiwyg3 */
1847 pflags ^= 4; /* frame */
1850 pflags ^= 8; /* do translations */
1853 psubfigure = !psubfigure; /* This is a subfigure */
1856 regen = true; /* regenerate command */
1858 case 0: /* browse file */
1862 case 1: /* preview */
1863 p = fl_get_input(form->EpsFile);
1867 case 8: /* ok (apply and close) */
1868 if(!current_view->buffer()->isReadonly()) {
1871 xwid = atof(fl_get_input(form->Width));
1872 xhgh = atof(fl_get_input(form->Height));
1873 angle = atof(fl_get_input(form->Angle));
1874 p = fl_get_input(form->EpsFile);
1876 string buf1 = OnlyPath(owner->fileName());
1877 fname = MakeAbsPath(p, buf1);
1878 changedfname = true;
1880 if (!fname.empty()) {
1881 changedfname = true;
1885 subcaption = fl_get_input(form->Subcaption);
1889 /* now update inset */
1890 if (lyxerr.debugging()) {
1891 lyxerr << "Update: ["
1892 << wid << 'x' << hgh << ']' << endl;
1894 UpdateInset(current_view, this);
1896 fl_set_focus_object(form->Figure, form->OkBtn);
1897 fl_hide_form(form->Figure);
1898 #if FL_REVISION == 89
1899 #warning Reactivate this free_form calls
1901 fl_free_form(form->Figure);
1902 free(form); // Why free?
1908 // The user has already been informed about RO in ::Edit
1909 if(arg == 7) // if 'Apply'
1912 case 9: /* cancel = restore and close */
1913 fl_set_focus_object(form->Figure, form->OkBtn);
1914 fl_hide_form(form->Figure);
1915 #if FL_REVISION == 89
1916 #warning Reactivate this free_form calls
1917 #warning Jug, is this still a problem?
1919 fl_free_form(form->Figure);
1920 free(form); // Why free?
1926 if (regen) TempRegenerate();
1930 inline void DisableFigurePanel(FD_Figure * const form)
1932 fl_deactivate_object(form->EpsFile);
1933 fl_deactivate_object(form->Browse);
1934 fl_deactivate_object(form->Width);
1935 fl_deactivate_object(form->Height);
1936 fl_deactivate_object(form->Frame);
1937 fl_deactivate_object(form->Translations);
1938 fl_deactivate_object(form->Angle);
1939 fl_deactivate_object(form->HeightGrp);
1940 fl_deactivate_object(form->page2);
1941 fl_deactivate_object(form->Default2);
1942 fl_deactivate_object(form->cm2);
1943 fl_deactivate_object(form->in2);
1944 fl_deactivate_object(form->HeightLabel);
1945 fl_deactivate_object(form->WidthLabel);
1946 fl_deactivate_object(form->DisplayGrp);
1947 fl_deactivate_object(form->Wysiwyg3);
1948 fl_deactivate_object(form->Wysiwyg0);
1949 fl_deactivate_object(form->Wysiwyg2);
1950 fl_deactivate_object(form->Wysiwyg1);
1951 fl_deactivate_object(form->WidthGrp);
1952 fl_deactivate_object(form->Default1);
1953 fl_deactivate_object(form->cm1);
1954 fl_deactivate_object(form->in1);
1955 fl_deactivate_object(form->page1);
1956 fl_deactivate_object(form->column1);
1957 fl_deactivate_object(form->Subcaption);
1958 fl_deactivate_object(form->Subfigure);
1959 fl_deactivate_object (form->OkBtn);
1960 fl_deactivate_object (form->ApplyBtn);
1961 fl_set_object_lcol (form->OkBtn, FL_INACTIVE);
1962 fl_set_object_lcol (form->ApplyBtn, FL_INACTIVE);
1966 inline void EnableFigurePanel(FD_Figure * const form)
1968 fl_activate_object(form->EpsFile);
1969 fl_activate_object(form->Browse);
1970 fl_activate_object(form->Width);
1971 fl_activate_object(form->Height);
1972 fl_activate_object(form->Frame);
1973 fl_activate_object(form->Translations);
1974 fl_activate_object(form->Angle);
1975 fl_activate_object(form->HeightGrp);
1976 fl_activate_object(form->page2);
1977 fl_activate_object(form->Default2);
1978 fl_activate_object(form->cm2);
1979 fl_activate_object(form->in2);
1980 fl_activate_object(form->HeightLabel);
1981 fl_activate_object(form->WidthLabel);
1982 fl_activate_object(form->DisplayGrp);
1983 fl_activate_object(form->Wysiwyg3);
1984 fl_activate_object(form->Wysiwyg0);
1985 fl_activate_object(form->Wysiwyg2);
1986 fl_activate_object(form->Wysiwyg1);
1987 fl_activate_object(form->WidthGrp);
1988 fl_activate_object(form->Default1);
1989 fl_activate_object(form->cm1);
1990 fl_activate_object(form->in1);
1991 fl_activate_object(form->page1);
1992 fl_activate_object(form->column1);
1993 fl_activate_object(form->Subcaption);
1994 fl_activate_object(form->Subfigure);
1995 fl_activate_object (form->OkBtn);
1996 fl_activate_object (form->ApplyBtn);
1997 fl_set_object_lcol (form->OkBtn, FL_BLACK);
1998 fl_set_object_lcol (form->ApplyBtn, FL_BLACK);
2002 void InsetFig::RestoreForm()
2006 EnableFigurePanel(form);
2009 fl_set_button(form->Default1, (wtype == 0));
2010 fl_set_button(form->cm1, (wtype == 1));
2011 fl_set_button(form->in1, (wtype == 2));
2012 fl_set_button(form->page1, (wtype == 3));
2013 fl_set_button(form->column1, (wtype == 4));
2015 fl_deactivate_object(form->Width);
2017 fl_activate_object(form->Width);
2020 // enable and disable should be put here.
2022 fl_set_button(form->Default2, (htype == 0));
2023 fl_set_button(form->cm2, (htype == 1));
2024 fl_set_button(form->in2, (htype == 2));
2025 fl_set_button(form->page2, (htype == 3));
2026 // enable and disable should be put here.
2028 fl_deactivate_object(form->Height);
2030 fl_activate_object(form->Height);
2033 int pflags = flags & 3;
2034 fl_set_button(form->Wysiwyg0, (pflags == 0));
2035 fl_set_button(form->Wysiwyg1, (pflags == 1));
2036 fl_set_button(form->Wysiwyg2, (pflags == 2));
2037 fl_set_button(form->Wysiwyg3, (pflags == 3));
2038 fl_set_button(form->Frame, ((flags & 4) != 0));
2039 fl_set_button(form->Translations, ((flags & 8) != 0));
2040 fl_set_button(form->Subfigure, (subfigure != 0));
2042 psubfigure = subfigure;
2043 sprintf(buf, "%g", xwid);
2044 fl_set_input(form->Width, buf);
2045 sprintf(buf, "%g", xhgh);
2046 fl_set_input(form->Height, buf);
2047 sprintf(buf, "%g", angle);
2048 fl_set_input(form->Angle, buf);
2049 if (!fname.empty()){
2050 string buf1 = OnlyPath(owner->fileName());
2051 string fname2 = MakeRelPath(fname, buf1);
2052 fl_set_input(form->EpsFile, fname2.c_str());
2054 else fl_set_input(form->EpsFile, "");
2055 fl_set_input(form->Subcaption, subcaption.c_str());
2056 if(current_view->buffer()->isReadonly())
2057 DisableFigurePanel(form);
2063 void InsetFig::Preview(char const * p)
2068 lyxerr << "Cannot fork process!" << endl;
2073 return; // parent process
2076 string buf1 = OnlyPath(owner->fileName());
2077 string buf2 = MakeAbsPath(p, buf1);
2079 lyxerr << "Error during rendering "
2080 << execlp(lyxrc->view_pspic_command.c_str(),
2081 lyxrc->view_pspic_command.c_str(),
2088 void InsetFig::BrowseFile()
2090 static string current_figure_path;
2091 static int once = 0;
2094 if (lyxerr.debugging()) {
2095 lyxerr << "Filename: "
2096 << owner->fileName() << endl;
2098 string p = fl_get_input(form->EpsFile);
2100 string buf = MakeAbsPath(owner->fileName());
2101 string buf2 = OnlyPath(buf);
2103 buf = MakeAbsPath(p, buf2);
2104 buf = OnlyPath(buf);
2106 buf = OnlyPath(owner->fileName().c_str());
2109 // Does user clipart directory exist?
2110 string bufclip = AddName (user_lyxdir, "clipart");
2111 FileInfo fileInfo(bufclip);
2112 if (!(fileInfo.isOK() && fileInfo.isDir()))
2113 // No - bail out to system clipart directory
2114 bufclip = AddName (system_lyxdir, "clipart");
2117 fileDlg.SetButton(0, _("Clipart"), bufclip);
2118 fileDlg.SetButton(1, _("Document"), buf);
2124 p = fileDlg.Select(_("EPS Figure"),
2125 current_figure_path,
2128 p = fileDlg.Select(_("EPS Figure"), buf,
2133 if (p.empty()) return;
2135 buf = MakeRelPath(p, buf2);
2136 current_figure_path = OnlyPath(p);
2139 if (contains(p, "#") || contains(p, "~") || contains(p, "$")
2140 || contains(p, "%") || contains(p, " "))
2142 WriteAlert(_("Filename can't contain any "
2143 "of these characters:"),
2144 // xgettext:no-c-format
2145 _("space, '#', '~', '$' or '%'."));
2150 if (form) fl_set_input(form->EpsFile, buf.c_str());
2154 void GraphicsCB(FL_OBJECT * obj, long arg)
2156 /* obj->form contains the form */
2158 if (lyxerr.debugging()) {
2159 lyxerr << "GraphicsCB callback: " << arg << endl;
2162 /* find inset we were reacting to */
2163 for (int i = 0; i < figinsref; ++i)
2164 if (figures[i]->inset->form && figures[i]->inset->form->Figure
2167 if (lyxerr.debugging()) {
2168 lyxerr << "Calling back figure " << i << endl;
2170 figures[i]->inset->CallbackFig(arg);
2176 void HideFiguresPopups()
2178 for (int i = 0; i < figinsref; ++i)
2179 if (figures[i]->inset->form
2180 && figures[i]->inset->form->Figure->visible) {
2181 if (lyxerr.debugging()) {
2182 lyxerr << "Hiding figure " << i << endl;
2184 // hide and free the form
2185 figures[i]->inset->CallbackFig(9);