#include <cmath>
#include "figinset.h"
-#include "lyx.h"
#include "lyx_main.h"
#include "buffer.h"
#include "frontends/FileDialog.h"
#include "converter.h"
#include "frontends/Dialogs.h" // redrawGUI
-#ifdef SIGC_CXX_NAMESPACES
-using SigC::slot;
-#endif
-
using std::ostream;
using std::istream;
using std::ofstream;
extern char ** environ; // is this only redundtant on linux systems? Lgb.
-static float const DEG2PI = 57.295779513;
+// xforms doesn't define this (but it should be in <forms.h>).
+extern "C"
+FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
+
+namespace {
+
+float const DEG2PI = 57.295779513;
struct queue_element {
float rx, ry; // resolution x and y
figdata * data; // we are doing it for this data
};
-static int const MAXGS = 3; /* maximum 3 gs's at a time */
+int const MAXGS = 3; /* maximum 3 gs's at a time */
typedef vector<Figref *> figures_type;
typedef vector<figdata *> bitmaps_type;
-static figures_type figures; // all figures
-static bitmaps_type bitmaps; // all bitmaps
+figures_type figures; // all figures
+bitmaps_type bitmaps; // all bitmaps
-static queue<queue_element> gsqueue; // queue for ghostscripting
+queue<queue_element> gsqueue; // queue for ghostscripting
-static int gsrunning = 0; /* currently so many gs's are running */
-static bool bitmap_waiting = false; /* bitmaps are waiting finished */
+int gsrunning = 0; /* currently so many gs's are running */
+bool bitmap_waiting = false; /* bitmaps are waiting finished */
-static bool gs_color; // do we allocate colors for gs?
-static bool color_visual; // is the visual color?
-static bool gs_xcolor = false; // allocated extended colors
-static unsigned long gs_pixels[128]; // allocated pixels
-static int gs_spc; // shades per color
-static int gs_allcolors; // number of all colors
+bool gs_color; // do we allocate colors for gs?
+bool color_visual; // is the visual color?
+bool gs_xcolor = false; // allocated extended colors
+unsigned long gs_pixels[128]; // allocated pixels
+int gs_spc; // shades per color
+int gs_allcolors; // number of all colors
-static list<int> pidwaitlist; // pid wait list
+list<int> pidwaitlist; // pid wait list
-static
GC createGC()
{
XGCValues val;
| GCLineWidth | GCLineStyle , &val);
}
-static
GC local_gc_copy;
-static
void addpidwait(int pid)
{
// adds pid to pid wait list
}
-static
string make_tmp(int pid)
{
return system_tempdir + "/~lyxgs" + tostr(pid) + ".ps";
}
-static
void kill_gs(int pid, int sig)
{
if (lyxerr.debugging())
}
-extern "C" {
-static
+extern "C"
int GhostscriptMsg(XEvent * ev, void *)
{
// bin all events not of interest
}
return FL_PREEMPT;
}
-}
-static
void AllocColors(int num)
// allocate color cube numxnumxnum, if possible
{
// allocate grayscale ramp
-static
void AllocGrays(int num)
{
if (lyxerr.debugging()) {
gs_color = true;
}
-
-// xforms doesn't define this
-extern "C" FL_APPEVENT_CB fl_set_preemptive_callback(Window, FL_APPEVENT_CB, void *);
-
-static
void InitFigures()
{
// if bitmaps and figures are not empty we will leak mem
}
-static
void DoneFigures()
{
// if bitmaps and figures are not empty we will leak mem
}
-static
void freefigdata(figdata * tmpdata)
{
tmpdata->ref--;
}
-static
void runqueue()
{
// This _have_ to be set before the fork!
}
-static
void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
{
// recompute the stuff and put in the queue
}
-static
figdata * getfigdata(int wid, int hgh, string const & fname,
int psx, int psy, int pswid, int pshgh,
int raw_wid, int raw_hgh, float angle, char flags)
}
-static
void getbitmap(figdata * p)
{
p->gspid = -1;
}
-static
void makeupdatelist(figdata * p)
{
for (figures_type::iterator it = figures.begin();
}
}
+} // namespace anon
+
// this func is only "called" in spellchecker.C
void sigchldchecker(pid_t pid, int * status)
}
-static
+namespace {
+
void getbitmaps()
{
bitmap_waiting = false;
}
-static
void RegisterFigure(InsetFig * fi)
{
if (figures.empty()) InitFigures();
}
-static
void UnregisterFigure(InsetFig * fi)
{
if (!lyxrc.use_gui)
if (figures.empty()) DoneFigures();
}
+} // namespace anon
+
InsetFig::InsetFig(int tmpx, int tmpy, Buffer const & o)
: owner(&o)
raw_wid = raw_hgh = 0;
changedfname = false;
RegisterFigure(this);
- r_ = Dialogs::redrawGUI.connect(slot(this, &InsetFig::redraw));
+ r_ = Dialogs::redrawGUI.connect(SigC::slot(this, &InsetFig::redraw));
}
tmp->pswid = pswid;
tmp->pshgh = pshgh;
tmp->fname = fname;
- if (!fname.empty() && IsFileReadable(fname)
+ string lfname = fname;
+ if (!fname.empty() && GetExtension(fname).empty())
+ lfname += ".eps";
+ if (!fname.empty() && IsFileReadable(lfname)
&& (flags & 3) && !lyxrc.ps_command.empty()
&& lyxrc.use_gui) {
// do not display if there is
// "do not display" chosen (Matthias 260696)
- tmp->figure->data = getfigdata(wid, hgh, fname, psx, psy,
+ tmp->figure->data = getfigdata(wid, hgh, lfname, psx, psy,
pswid, pshgh, raw_wid, raw_hgh,
angle, flags & (3|8));
} else tmp->figure->data = 0;
}
-static
-string stringify(InsetFig::HWTYPE hw, float f, string suffix)
+namespace {
+
+string const stringify(InsetFig::HWTYPE hw, float f, string suffix)
{
string res;
switch (hw) {
return res;
}
+} // namespace anon
+
void InsetFig::Regenerate() const
{
if (fname.empty()) return;
string p;
- ifstream ifs(fname.c_str());
+ string lfname = fname;
+ if (GetExtension(fname).empty())
+ lfname += ".eps";
+ ifstream ifs(lfname.c_str());
if (!ifs) return; // file not found !!!!