* figinset.C - part of LyX project
*/
-#ifdef MONO
-extern int reverse_video;
-#endif
extern long int background_pixels;
/* Rework of path-handling (Matthias 04.07.1996 )
#include "support/filetools.h"
#include "LyXView.h" // just because of form_main
#include "debug.h"
-#ifndef USE_PAINTER
-#include "lyxdraw.h"
-#endif
#include "LaTeXFeatures.h"
#include "lyxrc.h"
#include "gettext.h"
extern FL_OBJECT * figinset_canvas;
extern char ** environ; // is this only redundtant on linux systems? Lgb.
-extern void UpdateInset(BufferView *, Inset * inset, bool mark_dirty = true);
-// better for asyncron updating:
-void PutInsetIntoInsetUpdateList(Inset * inset);
+
extern void ProhibitInput();
extern void AllowInput();
// query current colormap
XColor * cmap = new XColor[gs_allcolors];
for (i = 0; i < gs_allcolors; ++i) cmap[i].pixel = i;
-#if 1
- XQueryColors(tmpdisp, fl_state[fl_get_vclass()].colormap, cmap, gs_allcolors);
-#else
- XQueryColors(tmpdisp, color_map, cmap, gs_allcolors);
-#endif
+ XQueryColors(tmpdisp,
+ fl_state[fl_get_vclass()]
+ .colormap, cmap,
+ gs_allcolors);
XFlush(tmpdisp);
wid1 = p->wid - 1;
// now we process all the image
}
-static void AllocColors(int num)
+static
+void AllocColors(int num)
// allocate color cube numxnumxnum, if possible
{
if (lyxerr.debugging()) {
fl_add_canvas_handler(figinset_canvas, ClientMessage,
GhostscriptMsg, current_view->owner()->getMainForm());
-#if 0
- // now we have to init color_map
- if (!color_map) color_map = DefaultColormap(fl_display,
- DefaultScreen(fl_display));
-#endif
// allocate color cube on pseudo-color display
// first get visual
gs_color = false;
fl_remove_canvas_handler(figinset_canvas, ClientMessage,
GhostscriptMsg);
-
-#if 0
- if (gs_color) {
- lyxerr.debug() << "Freeing up the colors..." << endl;
- XFreeColors(fl_display, color_map, gs_pixels,
- gs_num_pixels, 0);
- /******????????????????? what's planes in this case ??????***/
- }
-#endif
}
}
-static void freefigdata(figdata * tmpdata)
+static
+void freefigdata(figdata * tmpdata)
{
tmpdata->ref--;
if (tmpdata->ref) return;
}
-static void runqueue()
+static
+void runqueue()
{
// run queued requests for ghostscript, if any
if (!gsrunning && gs_color && !gs_xcolor) {
break;
}
-#ifdef USE_PAINTER
-#ifdef MONO
- if (reverse_video) {
- sprintf(tbuf+1, " %ld %ld", WhitePixelOfScreen(
- DefaultScreenOfDisplay(fl_display)),
- fl_get_pixel(FL_BLACK));
- } else {
-#endif
- sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
- DefaultScreenOfDisplay(fl_display)),
- fl_get_pixel(FL_WHITE));
-#ifdef MONO
- }
-#endif
-#else
- if (reverse_video) {
- sprintf(tbuf+1, " %ld %ld", WhitePixelOfScreen(
- DefaultScreenOfDisplay(fl_display)),
- background_pixels);
- } else {
- sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
- DefaultScreenOfDisplay(fl_display)),
- background_pixels);
- }
-#endif
+ sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
+ DefaultScreenOfDisplay(fl_display)),
+ fl_get_pixel(FL_WHITE));
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
}
-static void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
+static
+void addwait(int psx, int psy, int pswid, int pshgh, figdata * data)
{
// recompute the stuff and put in the queue
queue_element p;
}
-static figdata * getfigdata(int wid, int hgh, string const & fname,
+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)
+static
+void getbitmap(figdata * p)
{
p->gspid = -1;
}
-static void makeupdatelist(figdata * p)
+static
+void makeupdatelist(figdata * p)
{
for (int i = 0; i < figinsref; ++i)
if (figures[i]->data == p) {
<< endl;
}
// add inset figures[i]->inset into to_update list
- PutInsetIntoInsetUpdateList(figures[i]->inset);
+ current_view->pushIntoUpdateList(figures[i]->inset);
}
}
}
-static void getbitmaps()
+static
+void getbitmaps()
{
bitmap_waiting = false;
for (int i = 0; i < bmpinsref; ++i)
}
-static void RegisterFigure(InsetFig * fi)
+static
+void RegisterFigure(InsetFig * fi)
{
if (figinsref == 0) InitFigures();
fi->form = 0;
typedef Figref * Figref_p;
Figref ** tmp = new Figref_p[figarrsize];
memcpy(tmp, figures,
- sizeof(Figref*)*(figarrsize-figallocchunk));
+ sizeof(Figref*) * (figarrsize-figallocchunk));
delete[] figures;
figures = tmp;
}
}
-static void UnregisterFigure(InsetFig * fi)
+static
+void UnregisterFigure(InsetFig * fi)
{
Figref * tmpfig = fi->figure;
}
-static string NextToken(istream & is)
+static
+string NextToken(istream & is)
{
string token;
char c;
}
-#ifdef USE_PAINTER
int InsetFig::ascent(Painter &, LyXFont const &) const
{
return hgh + 3;
}
-#else
-int InsetFig::Ascent(LyXFont const &) const
-{
- return hgh + 3;
-}
-#endif
-#ifdef USE_PAINTER
int InsetFig::descent(Painter &, LyXFont const &) const
{
return 1;
}
-#else
-int InsetFig::Descent(LyXFont const &) const
-{
- return 1;
-}
-#endif
-#ifdef USE_PAINTER
int InsetFig::width(Painter &, LyXFont const &) const
{
return wid + 2;
}
-#else
-int InsetFig::Width(LyXFont const &) const
-{
- return wid + 2;
-}
-#endif
-#ifdef USE_PAINTER
void InsetFig::draw(Painter & pain, LyXFont const & f,
int baseline, float & x) const
{
}
x += width(pain, font); // ?
}
-#else
-void InsetFig::Draw(LyXFont font, LyXScreen & scr, int baseline, float & x)
-{
- if (bitmap_waiting) getbitmaps();
-
- // I wish that I didn't have to use this
- // but the figinset code is so complicated so
- // I don't want to fiddle with it now.
- unsigned long pm = scr.getForeground();
-
- if (figure && figure->data && figure->data->bitmap &&
- !figure->data->reading && !figure->data->broken) {
- // draw the bitmap
- XCopyArea(fl_display, figure->data->bitmap, pm, local_gc_copy,
- 0, 0, wid, hgh, int(x+1), baseline-hgh);
- XFlush(fl_display);
- if (flags & 4) XDrawRectangle(fl_display, pm, local_gc_copy,
- int(x), baseline - hgh - 1,
- wid+1, hgh+1);
- } else {
- char * msg = 0;
- // draw frame
- XDrawRectangle(fl_display, pm, local_gc_copy,
- int(x),
- baseline - hgh - 1, wid+1, hgh+1);
- if (figure && figure->data) {
- if (figure->data->broken) msg = _("[render error]");
- else if (figure->data->reading) msg = _("[rendering ... ]");
- } else
- if (fname.empty()) msg = _("[no file]");
- else if ((flags & 3) == 0) msg = _("[not displayed]");
- else if (lyxrc->ps_command.empty()) msg = _("[no ghostscript]");
-
- if (!msg) msg = _("[unknown error]");
-
- font.setFamily (LyXFont::SANS_FAMILY);
- font.setSize (LyXFont::SIZE_FOOTNOTE);
- string justname = OnlyFilename (fname);
- font.drawString(justname, pm,
- baseline - font.maxAscent() - 4,
- int(x) + 8);
- font.setSize (LyXFont::SIZE_TINY);
- font.drawText (msg, strlen(msg), pm,
- baseline - 4,
- int(x) + 8);
-
- }
- x += Width(font); // ?
-}
-#endif
-void InsetFig::Write(ostream & os)
+void InsetFig::Write(ostream & os) const
{
Regenerate();
os << "Figure size " << wid << " " << hgh << "\n";
}
-int InsetFig::Latex(ostream & os, signed char /* fragile*/ )
+int InsetFig::Latex(ostream & os, signed char /* fragile*/ ) const
{
Regenerate();
if (!cmd.empty()) os << cmd << " ";
}
-int InsetFig::Latex(string & file, signed char /* fragile*/ )
+#ifndef USE_OSTREAM_ONLY
+int InsetFig::Latex(string & file, signed char /* fragile*/ ) const
{
Regenerate();
file += cmd + ' ';
}
-int InsetFig::Linuxdoc(string &/*file*/)
+int InsetFig::Linuxdoc(string &/*file*/) const
{
return 0;
}
-int InsetFig::DocBook(string & file)
+int InsetFig::DocBook(string & file) const
{
string figurename = fname;
return 0;
}
+#else
+
+int InsetFig::Linuxdoc(ostream &) const
+{
+ return 0;
+}
+
+
+int InsetFig::DocBook(ostream & os) const
+{
+ string figurename = fname;
+
+ if(suffixIs(figurename, ".eps"))
+ figurename.erase(fname.length() - 5);
+
+ os << "@<graphic fileref=\"" << figurename << "\"></graphic>";
+ return 0;
+}
+#endif
+
void InsetFig::Validate(LaTeXFeatures & features) const
{
}
-void InsetFig::Edit(int, int)
+void InsetFig::Edit(BufferView * bv, int, int, unsigned int)
{
lyxerr.debug() << "Editing InsetFig." << endl;
Regenerate();
// We should have RO-versions of the form instead.
// The actual prevention of altering a readonly doc
// is done in CallbackFig()
- if(current_view->buffer()->isReadonly())
- WarnReadonly(current_view->buffer()->fileName());
+ if(bv->buffer()->isReadonly())
+ WarnReadonly(bv->buffer()->fileName());
if (!form) {
form = create_form_Figure();
}
-void InsetFig::Regenerate()
+void InsetFig::Regenerate() const
{
string cmdbuf;
string resizeW, resizeH;
lyxerr << "Update: ["
<< wid << 'x' << hgh << ']' << endl;
}
- UpdateInset(current_view, this);
+ current_view->updateInset(this, true);
if (arg == 8) {
fl_set_focus_object(form->Figure, form->OkBtn);
fl_hide_form(form->Figure);
}
-inline void DisableFigurePanel(FD_Figure * const form)
+inline
+void DisableFigurePanel(FD_Figure * const form)
{
fl_deactivate_object(form->EpsFile);
fl_deactivate_object(form->Browse);
}
-inline void EnableFigurePanel(FD_Figure * const form)
+inline
+void EnableFigurePanel(FD_Figure * const form)
{
fl_activate_object(form->EpsFile);
fl_activate_object(form->Browse);