--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1998-2000 The LyX Team
+ *
+ *======================================================*/
+
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include <cmath>
+
+#include FORMS_H_LOCATION
+#include "debug.h"
+
+#include "ColorHandler.h"
+#include "gettext.h"
+
+using std::endl;
+
+LyXColorHandler::LyXColorHandler()
+{
+ display = fl_display;
+ drawable = XCreatePixmap(display, fl_root, 10, 10,
+ fl_get_visual_depth());
+
+ colormap = fl_state[fl_get_vclass()].colormap;
+ // Clear the GC cache
+ for (int i = 0; i <= LColor::ignore; ++i) {
+ colorGCcache[i] = 0;
+ }
+}
+
+
+LyXColorHandler::~LyXColorHandler()
+{
+ // Release all the registered GCs
+ for (int i = 0; i <= LColor::ignore; ++i) {
+ if (colorGCcache[i] != 0) {
+ XFreeGC(display, colorGCcache[i]);
+ }
+ }
+ // Iterate over the line cache and Free the GCs
+ for (LineGCCache::iterator lit = lineGCcache.begin();
+ lit != lineGCcache.end(); ++lit) {
+ XFreeGC(display, (*lit).second);
+ }
+}
+
+
+unsigned long LyXColorHandler::colorPixel(LColor::color c)
+{
+ XGCValues val;
+ XGetGCValues(display, getGCForeground(c), GCForeground, &val);
+ return val.foreground;
+}
+
+
+// Gets GC according to color
+// Uses caching
+GC LyXColorHandler::getGCForeground(LColor::color c)
+{
+ //if (lyxerr.debugging()) {
+ // lyxerr << "Painter drawable: " << drawable() << endl;
+ //}
+
+ if (colorGCcache[c] != 0) return colorGCcache[c];
+
+ XColor xcol, ccol;
+ string s = lcolor.getX11Name(c);
+ XGCValues val;
+
+ // Look up the RGB values for the color, and an approximate
+ // color that we can hope to get on this display.
+ if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) {
+ lyxerr << _("LyX: Unknown X11 color ") << s
+ << _(" for ") << lcolor.getGUIName(c) << '\n'
+ << _(" Using black instead, sorry!.") << endl;
+ unsigned long bla = BlackPixel(display,
+ DefaultScreen(display));
+ val.foreground = bla;
+ // Try the exact RGB values first, then the approximate.
+ } else if (XAllocColor(display, colormap, &xcol) != 0) {
+ if (lyxerr.debugging()) {
+ lyxerr << _("LyX: X11 color ") << s
+ << _(" allocated for ")
+ << lcolor.getGUIName(c) << endl;
+ }
+ val.foreground = xcol.pixel;
+ } else if (XAllocColor(display, colormap, &ccol)) {
+ lyxerr << _("LyX: Using approximated X11 color ") << s
+ << _(" allocated for ")
+ << lcolor.getGUIName(c) << endl;
+ val.foreground = xcol.pixel;
+ } else {
+ // Here we are traversing the current colormap to find
+ // the color closest to the one we want.
+ Visual * vi = DefaultVisual(display, DefaultScreen(display));
+
+ XColor * cmap = new XColor[vi->map_entries];
+
+ for(int i = 0; i < vi->map_entries; ++i) {
+ cmap[i].pixel = i;
+ }
+ XQueryColors(display, colormap, cmap, vi->map_entries);
+
+ // Walk through the cmap and look for close colors.
+ int closest_pixel = 0;
+ double closest_distance = 1e20; // we want to minimize this
+ double distance = 0;
+ for(int t = 0; t < vi->map_entries; ++t) {
+ // The Euclidean distance between two points in
+ // a three-dimensional space, the RGB color-cube,
+ // is used as the distance measurement between two
+ // colors.
+
+ // Since square-root is monotonous, we don't have to
+ // take the square-root to find the minimum, and thus
+ // we use the squared distance instead to be faster.
+
+ // If we want to get fancy, we could convert the RGB
+ // coordinates to a different color-cube, maybe HSV,
+ // but the RGB cube seems to work great. (Asger)
+ distance = pow(cmap[t].red - xcol.red, 2.0) +
+ pow(cmap[t].green - xcol.green, 2.0) +
+ pow(cmap[t].blue - xcol.blue, 2.0);
+ if (distance < closest_distance) {
+ closest_distance = distance;
+ closest_pixel = t;
+ }
+ }
+ lyxerr << _("LyX: Couldn't allocate '") << s
+ << _("' for ") << lcolor.getGUIName(c)
+ << _(" with (r,g,b)=(")
+ << xcol.red << "," << xcol.green << ","
+ << xcol.blue << ").\n"
+ << _(" Using closest allocated "
+ "color with (r,g,b)=(")
+ << cmap[closest_pixel].red << ","
+ << cmap[closest_pixel].green << ","
+ << cmap[closest_pixel].blue << ") instead.\n"
+ << "Pixel [" << closest_pixel << "] is used." << endl;
+ val.foreground = cmap[closest_pixel].pixel;
+ delete[] cmap;
+ }
+
+ val.function = GXcopy;
+ return colorGCcache[c] = XCreateGC(display, drawable,
+ GCForeground | GCFunction, &val);
+}
+
+
+// Gets GC for line
+GC LyXColorHandler::getGCLinepars(PainterBase::line_style ls,
+ PainterBase::line_width lw, LColor::color c)
+{
+ //if (lyxerr.debugging()) {
+ // lyxerr << "Painter drawable: " << drawable() << endl;
+ //}
+
+ int index = lw + (ls << 1) + (c << 3);
+
+ if (lineGCcache.find(index) != lineGCcache.end())
+ return lineGCcache[index];
+
+ XGCValues val;
+ XGetGCValues(display, getGCForeground(c), GCForeground, &val);
+
+ switch (lw) {
+ case PainterBase::line_thin: val.line_width = 0; break;
+ case PainterBase::line_thick: val.line_width = 2; break;
+ }
+
+ switch (ls) {
+ case PainterBase::line_solid: val.line_style = LineSolid; break;
+ case PainterBase::line_onoffdash: val.line_style = LineOnOffDash; break;
+ case PainterBase::line_doubledash: val.line_style = LineDoubleDash; break;
+ }
+
+
+ val.cap_style = CapRound;
+ val.join_style = JoinRound;
+ val.function = GXcopy;
+
+ return lineGCcache[index] =
+ XCreateGC(display, drawable,
+ GCForeground | GCLineStyle | GCLineWidth |
+ GCCapStyle | GCJoinStyle | GCFunction, &val);
+}
+
+//
+LyXColorHandler * lyxColorHandler;
--- /dev/null
+// -*- C++ -*-
+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995-2000 The LyX Team
+ *
+ * ======================================================*/
+
+#ifndef COLOR_HANDLER_H
+#define COLOR_HANDLER_H
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+//#include "config.h"
+//#include "LString.h"
+
+// This is only included to provide stuff for the non-public sections
+#include <X11/Xlib.h>
+
+#include <map>
+#include "PainterBase.h"
+#include "LColor.h"
+
+class LyXFont;
+class WorkArea;
+
+///
+class LyXColorHandler {
+public:
+ ///
+ LyXColorHandler();
+ ///
+ ~LyXColorHandler();
+ ///
+ unsigned long colorPixel(LColor::color c);
+ ///
+ GC getGCForeground(LColor::color c);
+ ///
+ GC getGCLinepars(PainterBase::line_style,
+ PainterBase::line_width, LColor::color c);
+private:
+ ///
+ Display * display;
+ ///
+ Colormap colormap;
+ ///
+ GC colorGCcache[LColor::ignore + 1];
+ ///
+ typedef std::map<int, GC> LineGCCache;
+ ///
+ LineGCCache lineGCcache;
+ ///
+ Pixmap drawable;
+};
+
+extern LyXColorHandler * lyxColorHandler;
+
+#endif
Bullet.h \
Chktex.C \
Chktex.h \
+ ColorHandler.C \
+ ColorHandler.h \
CutAndPaste.C \
CutAndPaste.h \
DepTable.C \
#include "support/lstrings.h"
#include "WorkArea.h"
#include "font.h"
+#include "ColorHandler.h"
using std::endl;
using std::max;
Painter::Painter(WorkArea & wa)
: PainterBase(wa)
{
- colormap = fl_state[fl_get_vclass()].colormap;
- // Clear the GC cache
- for (int i = 0; i <= LColor::ignore; ++i) {
- colorGCcache[i] = 0;
- }
-}
-
-
-Painter::~Painter() {
- // Release all the registered GCs
- for (int i = 0; i <= LColor::ignore; ++i) {
- if (colorGCcache[i] != 0) {
- XFreeGC(display, colorGCcache[i]);
- }
- }
- // Iterate over the line cache and Free the GCs
- for (LineGCCache::iterator lit = lineGCcache.begin();
- lit != lineGCcache.end(); ++lit) {
- XFreeGC(display, (*lit).second);
- }
+ display = fl_display;
}
-Drawable Painter::drawable() const
-{
- return owner.getPixmap();
-}
+Painter::~Painter() {}
/* Basic drawing routines */
if (!Lgb_bug_find_hack)
lyxerr << "point not called from "
"workarea::workhandler\n";
- lyxerr.debug() << "Painter drawable: " << drawable() << endl;
+ lyxerr.debug() << "Painter drawable: "
+ << owner.getPixmap() << endl;
}
- XDrawPoint(display, drawable(), getGCForeground(c), x, y);
+ XDrawPoint(display, owner.getPixmap(),
+ lyxColorHandler->getGCForeground(c), x, y);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "line not called from "
"workarea::workhandler\n";
- lyxerr.debug() << "Painter drawable: " << drawable() << endl;
+ lyxerr.debug() << "Painter drawable: "
+ << owner.getPixmap() << endl;
}
- XDrawLine(display, drawable(),
- getGCLinepars(ls, lw, col), x1, y1, x2, y2);
+ XDrawLine(display, owner.getPixmap(),
+ lyxColorHandler->getGCLinepars(ls, lw, col),
+ x1, y1, x2, y2);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "lines not called from "
"workarea::workhandler\n";
- lyxerr.debug() << "Painter drawable: " << drawable() << endl;
+ lyxerr.debug() << "Painter drawable: "
+ << owner.getPixmap() << endl;
}
#ifndef HAVE_AUTO_PTR
points[i].y = yp[i];
}
- XDrawLines(display, drawable(), getGCLinepars(ls, lw, col),
+ XDrawLines(display, owner.getPixmap(),
+ lyxColorHandler->getGCLinepars(ls, lw, col),
points, np, CoordModeOrigin);
#ifndef HAVE_AUTO_PTR
if (!Lgb_bug_find_hack)
lyxerr << "rectangle not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: "
+ << owner.getPixmap() << endl;
}
- XDrawRectangle(display, drawable(), getGCLinepars(ls, lw, col),
+ XDrawRectangle(display, owner.getPixmap(),
+ lyxColorHandler->getGCLinepars(ls, lw, col),
x, y, w, h);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "fillrectangle not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: "
+ << owner.getPixmap() << endl;
}
- XFillRectangle(display, drawable(), getGCForeground(col), x, y, w, h);
+ XFillRectangle(display, owner.getPixmap(),
+ lyxColorHandler->getGCForeground(col), x, y, w, h);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr <<"fillpolygon not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: " << owner.getPixmap() << endl;
}
#ifndef HAVE_AUTO_PTR
points[i].y = yp[i];
}
- XFillPolygon(display, drawable(), getGCForeground(col), points, np,
+ XFillPolygon(display, owner.getPixmap(),
+ lyxColorHandler->getGCForeground(col), points, np,
Nonconvex, CoordModeOrigin);
#ifndef HAVE_AUTO_PTR
delete[] points;
if (!Lgb_bug_find_hack)
lyxerr << "arc not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: " << owner.getPixmap() << endl;
}
- XDrawArc(display, drawable(), getGCForeground(col),
+ XDrawArc(display, owner.getPixmap(),
+ lyxColorHandler->getGCForeground(col),
x, y, w, h, a1, a2);
return *this;
}
if (!Lgb_bug_find_hack)
lyxerr << "segments not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: " << owner.getPixmap() << endl;
}
#ifndef HAVE_AUTO_PTR
s[i].x2 = x2[i];
s[i].y2 = y2[i];
}
- XDrawSegments(display, drawable(), getGCLinepars(ls, lw, col), s, ns);
+ XDrawSegments(display, owner.getPixmap(),
+ lyxColorHandler->getGCLinepars(ls, lw, col), s, ns);
#ifndef HAVE_AUTO_PTR
delete [] s;
if (!Lgb_bug_find_hack)
lyxerr << "workAreaExpose not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: " << owner.getPixmap() << endl;
}
XGCValues val;
val.function = GXcopy;
- GC gc = XCreateGC(display, drawable(),
+ GC gc = XCreateGC(display, owner.getPixmap(),
GCFunction, &val);
- XCopyArea(display, bitmap, drawable(), gc,
+ XCopyArea(display, bitmap, owner.getPixmap(), gc,
0, 0, w, h, x, y);
XFreeGC(display, gc);
return *this;
if (!Lgb_bug_find_hack)
lyxerr << "text not called from "
"workarea::workhandler\n";
- lyxerr << "Painter drawable: " << drawable() << endl;
+ lyxerr << "Painter drawable: " << owner.getPixmap() << endl;
}
- GC gc = getGCForeground(f.realColor());
+ GC gc = lyxColorHandler->getGCForeground(f.realColor());
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
lyxfont::XSetFont(display, gc, f);
- XDrawString(display, drawable(), gc, x, y, s, ls);
+ XDrawString(display, owner.getPixmap(), gc, x, y, s, ls);
} else {
LyXFont smallfont(f);
smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
if (islower(static_cast<unsigned char>(c))) {
c = toupper(c);
lyxfont::XSetFont(display, gc, smallfont);
- XDrawString(display, drawable(),
+ XDrawString(display, owner.getPixmap(),
gc, tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth(smallfont, &c, 1);
//tmpx += lyxfont::width(c, f);
} else {
lyxfont::XSetFont(display, gc, f);
- XDrawString(display, drawable(),
+ XDrawString(display, owner.getPixmap(),
gc, tmpx, y, &c, 1);
tmpx += lyxfont::XTextWidth(f, &c, 1);
//tmpx += lyxfont::width(c, f);
f.color());
}
}
-
-
-// Gets GC according to color
-// Uses caching
-GC Painter::getGCForeground(LColor::color c)
-{
- if (lyxerr.debugging()) {
- lyxerr << "Painter drawable: " << drawable() << endl;
- }
-
- if (colorGCcache[c] != 0) return colorGCcache[c];
-
- XColor xcol, ccol;
- string s = lcolor.getX11Name(c);
- XGCValues val;
-
- // Look up the RGB values for the color, and an approximate
- // color that we can hope to get on this display.
- if (XLookupColor(display, colormap, s.c_str(), &xcol, &ccol) == 0) {
- lyxerr << _("LyX: Unknown X11 color ") << s
- << _(" for ") << lcolor.getGUIName(c) << '\n'
- << _(" Using black instead, sorry!.") << endl;
- unsigned long bla = BlackPixel(display,
- DefaultScreen(display));
- val.foreground = bla;
- // Try the exact RGB values first, then the approximate.
- } else if (XAllocColor(display, colormap, &xcol) != 0) {
- if (lyxerr.debugging()) {
- lyxerr << _("LyX: X11 color ") << s
- << _(" allocated for ")
- << lcolor.getGUIName(c) << endl;
- }
- val.foreground = xcol.pixel;
- } else if (XAllocColor(display, colormap, &ccol)) {
- lyxerr << _("LyX: Using approximated X11 color ") << s
- << _(" allocated for ")
- << lcolor.getGUIName(c) << endl;
- val.foreground = xcol.pixel;
- } else {
- // Here we are traversing the current colormap to find
- // the color closest to the one we want.
- Visual * vi = DefaultVisual(display, DefaultScreen(display));
-
- XColor * cmap = new XColor[vi->map_entries];
-
- for(int i = 0; i < vi->map_entries; ++i) {
- cmap[i].pixel = i;
- }
- XQueryColors(display, colormap, cmap, vi->map_entries);
-
- // Walk through the cmap and look for close colors.
- int closest_pixel = 0;
- double closest_distance = 1e20; // we want to minimize this
- double distance = 0;
- for(int t = 0; t < vi->map_entries; ++t) {
- // The Euclidean distance between two points in
- // a three-dimensional space, the RGB color-cube,
- // is used as the distance measurement between two
- // colors.
-
- // Since square-root is monotonous, we don't have to
- // take the square-root to find the minimum, and thus
- // we use the squared distance instead to be faster.
-
- // If we want to get fancy, we could convert the RGB
- // coordinates to a different color-cube, maybe HSV,
- // but the RGB cube seems to work great. (Asger)
- distance = pow(cmap[t].red - xcol.red, 2.0) +
- pow(cmap[t].green - xcol.green, 2.0) +
- pow(cmap[t].blue - xcol.blue, 2.0);
- if (distance < closest_distance) {
- closest_distance = distance;
- closest_pixel = t;
- }
- }
- lyxerr << _("LyX: Couldn't allocate '") << s
- << _("' for ") << lcolor.getGUIName(c)
- << _(" with (r,g,b)=(")
- << xcol.red << "," << xcol.green << ","
- << xcol.blue << ").\n"
- << _(" Using closest allocated "
- "color with (r,g,b)=(")
- << cmap[closest_pixel].red << ","
- << cmap[closest_pixel].green << ","
- << cmap[closest_pixel].blue << ") instead.\n"
- << "Pixel [" << closest_pixel << "] is used." << endl;
- val.foreground = cmap[closest_pixel].pixel;
- delete[] cmap;
- }
-
- val.function = GXcopy;
- return colorGCcache[c] = XCreateGC(display, drawable(),
- GCForeground | GCFunction, &val);
-}
-
-
-// Gets GC for line
-GC Painter::getGCLinepars(enum line_style ls,
- enum line_width lw, LColor::color c)
-{
- if (lyxerr.debugging()) {
- lyxerr << "Painter drawable: " << drawable() << endl;
- }
-
- int index = lw + (ls << 1) + (c << 3);
-
- if (lineGCcache.find(index) != lineGCcache.end())
- return lineGCcache[index];
-
- XGCValues val;
- XGetGCValues(display, getGCForeground(c), GCForeground, &val);
-
- switch (lw) {
- case line_thin: val.line_width = 0; break;
- case line_thick: val.line_width = 2; break;
- }
-
- switch (ls) {
- case line_solid: val.line_style = LineSolid; break;
- case line_onoffdash: val.line_style = LineOnOffDash; break;
- case line_doubledash: val.line_style = LineDoubleDash; break;
- }
-
-
- val.cap_style = CapRound;
- val.join_style = JoinRound;
- val.function = GXcopy;
-
- return lineGCcache[index] =
- XCreateGC(display, drawable(),
- GCForeground | GCLineStyle | GCLineWidth |
- GCCapStyle | GCJoinStyle | GCFunction, &val);
-}
// This is only included to provide stuff for the non-public sections
#include <X11/Xlib.h>
-#include <map>
#include "PainterBase.h"
#include "LColor.h"
/// Draw a char at position x, y (y is the baseline)
PainterBase & text(int x, int y, char c, LyXFont const & f);
-protected:
- /**@Support for X only, by now */
- friend class WorkArea;
- ///
- PainterBase & setDisplay(Display * d) { display = d; return *this; }
-
- /// Get foreground color in ordinary GC
- GC getGCForeground(LColor::color c);
-
- /// Set up GC according to line style
- GC getGCLinepars(enum line_style, enum line_width, LColor::color c);
-
+private:
/// Check the font, and if set, draw an underline
void underline(LyXFont const & f, int x, int y, int width);
/**@Low level X parameters */
///
Display * display;
-
- ///
- Drawable drawable() const;
-
- ///
- Colormap colormap;
-
- /// Caching of ordinary color GCs
- GC colorGCcache[LColor::ignore + 1];
- /// Caching of GCs used for lines
- typedef std::map<int, GC> LineGCCache;
- ///
- LineGCCache lineGCcache;
};
+
#endif
createPixmap(width - 15 - 2 * bw, height - 2 * bw);
// setup the painter
- painter_.setDisplay(fl_display);
+ //painter_.setDisplay(fl_display);
// We add this object as late as possible to avoit problems
// with drawing.
case LyXParagraph::META_HFILL:
ofs << "\t";
break;
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
- ofs << " ";
- break;
-#endif
case '\\':
ofs << "\\";
break;
break;
case LyXParagraph::META_HFILL:
break;
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
- break;
-#endif
case '\\':
ofs << "\\\\";
break;
#include "font.h"
//#include "lyx_cb.h"
#include "bufferview_funcs.h"
+#include "ColorHandler.h"
using std::ostream;
using std::istream;
static list<int> pidwaitlist; // pid wait list
-
static
GC createGC()
{
static
void runqueue()
{
+ // This _have_ to be set before the fork!
+ unsigned long background_pixel =
+ lyxColorHandler->colorPixel(LColor::background);
+
// run queued requests for ghostscript, if any
if (!gsrunning && gs_color && !gs_xcolor) {
// here alloc all colors, so that gs will use only
continue;
}
- int pid = fork();
+ int pid = ::fork();
if (pid == -1) {
if (lyxerr.debugging()) {
}
// wait until property is deleted if executing multiple
// ghostscripts
+ XGrabServer(tempdisp);
for (;;) {
// grab server to prevent other child
// interfering with setting GHOSTVIEW property
+ // The grabbing goes on for too long, is it
+ // really needed? (Lgb)
+ // I moved most of the grabs... (Lgb)
if (lyxerr.debugging()) {
lyxerr << "Grabbing the server"
<< endl;
}
- XGrabServer(tempdisp);
prop = XListProperties(tempdisp,
fl_get_canvas_id(
figinset_canvas), &nprop);
XFree(reinterpret_cast<char *>(prop)); // jc:
if (err) break;
// release the server
- XUngrabServer(tempdisp);
- XFlush(tempdisp);
+ //XUngrabServer(tempdisp);
+ //XFlush(tempdisp);
// ok, property found, we must wait until
// ghostscript deletes it
if (lyxerr.debugging()) {
<< "] GHOSTVIEW property"
" found. Waiting." << endl;
}
-
- sleep(1);
+ XUngrabServer(tempdisp);
+ XFlush(tempdisp);
+ ::sleep(1);
+ XGrabServer(tempdisp);
}
-
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
XInternAtom(tempdisp, "GHOSTVIEW", false),
8, PropModeAppend,
reinterpret_cast<unsigned char*>(tbuf),
strlen(tbuf));
+ XUngrabServer(tempdisp);
+ XFlush(tempdisp);
switch (p->data->flags & 3) {
case 0: tbuf[0] = 'H'; break; // Hidden
tbuf[0] = 'G'; // Gray
break;
}
+
+ sprintf(tbuf + 1, " %ld %ld",
+ BlackPixelOfScreen(
+ DefaultScreenOfDisplay(tempdisp)),
+ background_pixel);
- sprintf(tbuf+1, " %ld %ld", BlackPixelOfScreen(
- DefaultScreenOfDisplay(fl_display)),
- fl_get_pixel(FL_WHITE));
-
+ XGrabServer(tempdisp);
XChangeProperty(tempdisp,
fl_get_canvas_id(figinset_canvas),
XInternAtom(tempdisp,
strlen(tbuf));
XUngrabServer(tempdisp);
XFlush(tempdisp);
+
if (lyxerr.debugging()) {
lyxerr << "Releasing the server" << endl;
}
typedef char * char_p;
env = new char_p[ne + 2];
env[0] = tbuf2;
- memcpy(&env[1], environ, sizeof(char*) * (ne + 1));
+ ::memcpy(&env[1], environ, sizeof(char*) * (ne + 1));
environ = env;
// now make gs command
sprintf(gbuf, "-g%dx%d", p->data->wid, p->data->hgh);
// now chdir into dir with .eps file, to be on the safe
// side
- chdir(OnlyPath(p->data->fname).c_str());
+ ::chdir(OnlyPath(p->data->fname).c_str());
// make temp file name
sprintf(tbuf, "%s/~lyxgs%d.ps", system_tempdir.c_str(),
- int(getpid()));
+ int(::getpid()));
if (lyxerr.debugging()) {
lyxerr << "starting gs " << tbuf << " "
<< p->data->fname
<< ", pid: " << getpid() << endl;
}
- int err = execlp(lyxrc.ps_command.c_str(),
+ int err = ::execlp(lyxrc.ps_command.c_str(),
lyxrc.ps_command.c_str(),
"-sDEVICE=x11",
"-dNOPAUSE", "-dQUIET",
}
-static
-string NextToken(istream & is)
-{
- string token;
- char c;
- if (!is.eof()) {
- do {
- is.get(c);
- token += c;
- } while (!is.eof() && !isspace(c));
- token.erase(token.length() - 1); // remove the isspace
- }
- return token;
-}
-
-
InsetFig::InsetFig(int tmpx, int tmpy, Buffer * o)
: owner(o)
{
break;
}
if (c == '%' && lastchar == '%') {
- p = NextToken(ifs);
+ ifs >> p;
if (p.empty()) break;
// we should not use this, with it we cannot
// discover bounding box and end of file.
switch (modtype) {
case ACUTE: // acute 0xB4
{
-#if 0
- pain.line(int(x2), int(y + hg),
- int(x2 + hg35), y + hg35);
-#else
pain.text(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(0xB4, font)) / 2,
char(0xB4), font);
-#endif
break;
}
case GRAVE: // grave 0x60
{
-#if 0
- pain.line(int(x2), int(y + hg),
- int(x2 - hg35), y + hg35);
-#else
pain.text(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0,
char(0x60), font);
-#endif
break;
}
case MACRON: // macron
{
-#if 0
- pain.line(int(x2 - wid * 0.4),
- int(y + hg),
- int(x2 + wid * 0.4),
- int(y + hg));
-#else
pain.text(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xAF, font) - (lyxfont::ascent(0xAF, font) + lyxfont::descent(0xAF, font)),
char(0xAF), font);
-#endif
break;
}
case TILDE: // tilde
{
-#if 0
- if (hg35 > 2.0) hg35 -= 1.0;
- x2 += (hg35 / 2.0);
- int xp[4], yp[4];
-
- xp[0] = int(x2 - 2.0 * hg35);
- yp[0] = int(y + hg);
-
- xp[1] = int(x2 - hg35);
- yp[1] = int(y + hg35);
-
- xp[2] = int(x2);
- yp[2] = int(y + hg);
-
- xp[3] = int(x2 + hg35);
- yp[3] = int(y + hg35);
-
- pain.lines(xp, yp, 4);
-#else
pain.text(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('~', font) - (lyxfont::ascent('~', font) + lyxfont::descent('~', font)) / 2,
'~', font);
-#endif
break;
}
case UNDERBAR: // underbar 0x5F
{
-#if 0
- pain.line(int(x2 - wid * 0.4),
- y + hg / 2.0,
- int(x2 + wid * 0.4),
- y + hg / 2.0);
-#else
pain.text(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2, baseline,
char(0x5F), font);
-#endif
break;
}
case CEDILLA: // cedilla
{
-#if 0
- int xp[4], yp[4];
-
- xp[0] = int(x2);
- yp[0] = y;
-
- xp[1] = int(x2);
- yp[1] = y + int(hg / 3.0);
-
- xp[2] = int(x2 + (hg / 3.0));
- yp[2] = y + int(hg / 2.0);
-
- xp[3] = int(x2 - (hg / 4.0));
- yp[3] = y + int(hg);
-
- pain.lines(xp, yp, 4);
-#else
pain.text(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2, baseline,
char(0xB8), font);
-#endif
break;
}
case UNDERDOT: // underdot
{
-#if 0
- pain.arc(int(x2), y + hg35,
- 3, 3, 0, 360 * 64);
-#else
pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font)),
'.', font);
-#endif
break;
}
case DOT: // dot
{
-#if 0
- pain.arc(int(x2), y + hg * 0.5,
- (hg + 3.0)/5.0,
- (hg + 3.0)/5.0,
- 0, 360 * 64);
-#else
pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('.', font) - (lyxfont::ascent('.', font) + lyxfont::descent('.', font)) / 2,
'.', font);
-#endif
break;
}
case CIRCLE: // circle
{
-#if 0
- pain.arc(int(x2 - (hg / 2.0)),
- y + (hg / 2.0), hg, hg , 0,
- 360 * 64);
-#else
LyXFont tmpf(font);
tmpf.decSize().decSize();
pain.text(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0,
char(0xB0), tmpf);
-#endif
break;
}
case TIE: // tie
}
case HUNGARIAN_UMLAUT: // hung. umlaut
{
-#if 0
- int xs1[2], xs2[2], ys1[2], ys2[2];
-
- xs1[0] = int(x2 - (hg / 2.0));
- ys1[0] = int(y + hg);
-
- xs2[0] = int(x2 + hg35 - (hg / 2.0));
- ys2[0] = int(y + hg35);
-
- xs1[1] = int(x2 + (hg / 2.0));
- ys1[1] = int(y + hg);
-
- xs2[1] = int(x2 + hg35 + (hg / 2.0));
- ys2[1] = int(y + hg35);
-
- pain.segments(xs1, ys1, xs2, ys2, 2);
-#else
pain.text(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font)),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
'´', font);
pain.text(x2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
'´', font);
-#endif
break;
}
case UMLAUT: // umlaut
{
-#if 0
- float rad = hg / 2.0;
- if (rad <= 1.0) {
- pain.point(int(x2 - 4.0 * hg / 7.0),
- y + hg35);
- pain.point(int(x2 + 4.0 * hg / 7.0),
- y + hg35);
- } else {
- rad += .5; // this ensures that f.ex. 1.5 will
- // not be rounded down to .5 and then
- // converted to int = 0
- pain.arc(int(x2 - 2.0 * hg / 4.0),
- y + hg35,
- rad, rad,
- 0, 360 * 64);
- pain.arc(int(x2 + 2.0 * hg / 4.0),
- y + hg35,
- rad, rad, 0, 360*64);
- }
-#else
pain.text(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - ( lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2,
'¨', font);
-#endif
break;
}
case CIRCUMFLEX: // circumflex
{
-#if 0
- int xp[3], yp[3];
-
- xp[0] = int(x2 - hg35); yp[0] = y + int(hg);
- xp[1] = int(x2); yp[1] = int(y + hg35);
- xp[2] = int(x2 + hg35); yp[2] = y + int(hg);
- pain.lines(xp, yp, 3);
-#else
LyXFont tmpf(font);
tmpf.decSize().decSize().decSize();
pain.text(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2,
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0,
char(0x5E), tmpf);
-#endif
break;
}
case OGONEK: // ogonek
switch(c) {
case ' ': case '(': case '{': case '[': case '-': case ':':
case LyXParagraph::META_HFILL:
-#warning think about this
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
-#endif
case LyXParagraph::META_NEWLINE:
side = InsetQuotes::LeftQ; // left quote
break;
{
return lyxfont::width(" x ", font);
}
-#if 0
- case NEWLINE:
- {
- }
-#endif
case PROTECTED_SEPARATOR:
{
return lyxfont::width('x', font);
x += width(pain, font);
break;
}
-#if 0
- case NEWLINE:
- {
- }
-#endif
case PROTECTED_SEPARATOR:
{
float w = width(pain, font);
case END_OF_SENTENCE: command = "\\@."; break;
case LDOTS: command = "\\ldots{}"; break;
case MENU_SEPARATOR: command = "\\menuseparator"; break;
-#if 0
- case NEWLINE: command = "\\newline"; break;
-#endif
case PROTECTED_SEPARATOR:
command = "\\protected_separator"; break;
}
END_OF_SENTENCE,
/// Menu separator
MENU_SEPARATOR,
-#if 0
- /// Newline
- NEWLINE,
-#endif
/// Protected Separator
PROTECTED_SEPARATOR
};
/* read text from choice */
int i = Language->get();
-#if 0
- if (lyxerr.debugging(Debug::KBMAP))
- lyxerr << "Table: " << tex_babel[i-1] << endl;
-#endif
string p;
if (i == otherkeymap)
p = fl_get_input(fd_form_keymap->OtherKeymap);
/* read text from choice */
int i = Language2->get();
-#if 0
- if (lyxerr.debugging(Debug::KBMAP))
- lyxerr << "Table: " << tex_babel[i-1] << endl;
-#endif
string p;
if (i == otherkeymap)
p = fl_get_input(fd_form_keymap->OtherKeymap2);
Language2->add(120, 110, 160, 30, 300); // Secondary
fl_end_form();
-#if 0
- int n = 0;
- while (true)
- if (!strlen(tex_babel[n]))
- break;
- else {
- Language->addto(tex_babel[n]);
- Language2->addto(tex_babel[n]);
- ++n;
- }
-#else
int n = 1;
// Default is not in the language map
Language->addto("default");
Language2->addto((*cit).second.lang.c_str());
++n;
}
-#endif
+
Language->addto(_("other..."));
Language2->addto(_("other..."));
otherkeymap = n + 1;
};
-#if 0
-// This table is sorted alphabetically [asierra 30March96]
-static keyword_item layoutTags[] = {
- { "align", LT_ALIGN },
- { "alignpossible", LT_ALIGNPOSSIBLE },
- { "bottomsep", LT_BOTTOMSEP },
- { "copystyle", LT_COPYSTYLE },
- { "end", LT_END },
- { "endlabeltype", LT_ENDLABELTYPE },
- { "fill_bottom", LT_FILL_BOTTOM },
- { "fill_top", LT_FILL_TOP },
- { "font", LT_FONT },
- { "freespacing", LT_FREE_SPACING },
- { "intitle", LT_INTITLE },
- { "itemsep", LT_ITEMSEP },
- { "keepempty", LT_KEEPEMPTY },
- { "labelbottomsep", LT_LABEL_BOTTOMSEP },
- { "labelfont", LT_LABELFONT },
- { "labelindent", LT_LABELINDENT },
- { "labelsep", LT_LABELSEP },
- { "labelstring", LT_LABELSTRING },
- { "labelstringappendix", LT_LABELSTRING_APPENDIX },
- { "labeltype", LT_LABELTYPE },
- { "latexname", LT_LATEXNAME },
- { "latexparam", LT_LATEXPARAM },
- { "latextype", LT_LATEXTYPE },
- { "leftmargin", LT_LEFTMARGIN },
- { "margin", LT_MARGIN },
- { "needprotect", LT_NEED_PROTECT },
- { "newline", LT_NEWLINE },
- { "nextnoindent", LT_NEXTNOINDENT },
- { "obsoletedby", LT_OBSOLETEDBY },
- { "parindent", LT_PARINDENT },
- { "parsep", LT_PARSEP },
- { "parskip", LT_PARSKIP },
- { "preamble", LT_PREAMBLE },
- { "rightmargin", LT_RIGHTMARGIN },
- { "spacing", LT_SPACING },
- { "textfont", LT_TEXTFONT },
- { "topsep", LT_TOPSEP }
-};
-#endif
-
-
/////////////////////
// Constructor for layout
};
-#if 0
-static keyword_item alignTags[] = {
- { "block", AT_BLOCK },
- { "center", AT_CENTER },
- { "layout", AT_LAYOUT },
- { "left", AT_LEFT },
- { "right", AT_RIGHT }
-};
-#endif
-
void LyXLayout::readAlign(LyXLex & lexrc)
{
#if 1
static
bool stringOnlyContains (string const & LStr, char const * cset)
{
-#if 0
- char const * cstr = LStr.c_str();
-
- return strspn(cstr, cset) == strlen(cstr);
-#else
return LStr.find_first_not_of(cset) == string::npos;
-#endif
}
#include "lyxlookup.h"
#include "bufferlist.h"
#include "language.h"
+#include "ColorHandler.h"
#ifdef TWO_COLOR_ICONS
#include "banner_bw.xbm"
width = WidthOfScreen(scr) - 8;
}
+ // Initialize the LyXColorHandler
+ lyxColorHandler = new LyXColorHandler;
}
combo_language->add(ob->x, ob->y, ob->w, ob->h, 250);
combo_language->shortcut("#G", 1);
fl_end_form();
-#if 0
- int n; // declared here because DEC cxx does not like multiple
- // declarations of variables in for() loops (JMarc)
- for (n = 0; tex_babel[n][0]; ++n) {
- combo_language->addto(tex_babel[n]);
- }
-#else
+
// "default" is not part of the languages array any more.
combo_language->addto("default");
for(Languages::const_iterator cit = languages.begin();
cit != languages.end(); ++cit) {
combo_language->addto((*cit).second.lang.c_str());
}
-#endif
// not really necessary, but we can do it anyway.
fl_addto_choice(fd_form_document->choice_fontsize, "default|10|11|12");
os << "\n\\hfill \n";
column = 0;
break;
-#if 0
- case META_PROTECTED_SEPARATOR:
- os << "\n\\protected_separator \n";
- column = 0;
- break;
-#endif
case '\\':
os << "\n\\backslash \n";
column = 0;
case LyXParagraph::META_HFILL:
sgml_string.clear();
break;
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
- sgml_string = ' ';
- break;
-#endif
case LyXParagraph::META_NEWLINE:
sgml_string = '\n';
break;
// but I'll leave it as a switch statement
// so its simpler to extend. (ARRae)
switch (c) {
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
- os << ' ';
- break;
-#endif
default:
// make sure that we will not print
// error generating chars to the tex
} else {
// Plain mode (i.e. not LaTeX)
switch (c) {
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
- os << '~';
- break;
-#endif
case '\\':
os << "\\textbackslash{}";
column += 15;
break;
case LyXParagraph::META_HFILL:
break;
-#if 0
- case LyXParagraph::META_PROTECTED_SEPARATOR:
- break;
-#endif
case '\\':
os << "\\\\";
break;
///
-#if 0
-inline
-bool IsSeparatorChar(char c) {
- return (c == ' ' || c == LyXParagraph::META_PROTECTED_SEPARATOR);
-}
-#else
inline
bool IsSeparatorChar(char c) {
return (c == ' ');
}
-#endif
///
|| c == '/'
|| c == '\\'
|| c == LyXParagraph::META_NEWLINE
-#if 0
- || c == LyXParagraph::META_PROTECTED_SEPARATOR
-#endif
);
}
// used all over. As it happens, that meant that these strings were included
// 27 times in the object file. (Asger)
-#if 0
-///
-char const * tex_babel[] = {
- "default", "afrikaans", "american", "arabic",
- "austrian", "bahasa", "brazil", "breton",
- "catalan", "croatian", "czech", "danish", "dutch",
- "english", "esperanto", "estonian",
- "finnish", "francais", "french", "frenchb",
- "galician",
- "german", "greek", "hebrew", "hungarian", "irish",
- "italian", "lsorbian", "magyar", "norsk",
- "polish", "portuges", "romanian",
- "russian", "scottish",
- "spanish", "slovak", "slovene", "swedish",
- "turkish", "usorbian", "welsh",
- ""};
-#endif
-
-
char const * tex_graphics[] = {"default", "dvips", "dvitops", "emtex",
"ln", "oztex", "textures", "none", ""};
y_top += LYX_PAPER_MARGIN;
if (row_ptr->par->pagebreak_top){ /* draw a top pagebreak */
-#if 0
- pain.line(0, offset + y_top + 2 * DefaultHeight(),
- paperwidth,
- offset + y_top + 2 * DefaultHeight(),
- LColor::pagebreak, Painter::line_onoffdash);
-#else
LyXFont pb_font;
pb_font.setColor(LColor::pagebreak).decSize();
int w = 0, a = 0, d = 0;
pb_font,
LColor::background,
LColor::background);
-#endif
y_top += 3 * DefaultHeight();
}
/* draw a bottom pagebreak */
if (firstpar->pagebreak_bottom) {
-#if 0
- pain.line(0, offset + y_bottom - 2 * DefaultHeight(),
- paperwidth,
- offset + y_bottom - 2 * DefaultHeight(),
- LColor::pagebreak, Painter::line_onoffdash);
-#else
LyXFont pb_font;
pb_font.setColor(LColor::pagebreak).decSize();
int w = 0, a = 0, d = 0;
pb_font,
LColor::background,
LColor::background);
-#endif
y_bottom -= 3 * DefaultHeight();
}