mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
make the graphics backround render ok + other stuff more changes than Id like at this stage, please test
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@677 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f2044aeec7
commit
7f1be334f1
198
src/ColorHandler.C
Normal file
198
src/ColorHandler.C
Normal file
@ -0,0 +1,198 @@
|
||||
// -*- 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;
|
62
src/ColorHandler.h
Normal file
62
src/ColorHandler.h
Normal file
@ -0,0 +1,62 @@
|
||||
// -*- 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
|
@ -20,6 +20,8 @@ lyx_SOURCES = \
|
||||
Bullet.h \
|
||||
Chktex.C \
|
||||
Chktex.h \
|
||||
ColorHandler.C \
|
||||
ColorHandler.h \
|
||||
CutAndPaste.C \
|
||||
CutAndPaste.h \
|
||||
DepTable.C \
|
||||
|
223
src/Painter.C
223
src/Painter.C
@ -29,6 +29,7 @@
|
||||
#include "support/lstrings.h"
|
||||
#include "WorkArea.h"
|
||||
#include "font.h"
|
||||
#include "ColorHandler.h"
|
||||
|
||||
using std::endl;
|
||||
using std::max;
|
||||
@ -36,33 +37,11 @@ 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;
|
||||
}
|
||||
display = fl_display;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Drawable Painter::drawable() const
|
||||
{
|
||||
return owner.getPixmap();
|
||||
}
|
||||
Painter::~Painter() {}
|
||||
|
||||
|
||||
/* Basic drawing routines */
|
||||
@ -75,10 +54,12 @@ PainterBase & Painter::point(int x, int y, LColor::color c)
|
||||
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;
|
||||
}
|
||||
|
||||
@ -92,11 +73,13 @@ PainterBase & Painter::line(int x1, int y1, int x2, int y2,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -110,7 +93,8 @@ PainterBase & Painter::lines(int const * xp, int const * yp, int np,
|
||||
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
|
||||
@ -123,7 +107,8 @@ PainterBase & Painter::lines(int const * xp, int const * yp, int np,
|
||||
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
|
||||
@ -142,10 +127,12 @@ PainterBase & Painter::rectangle(int x, int y, int w, int h,
|
||||
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;
|
||||
}
|
||||
@ -158,10 +145,12 @@ PainterBase & Painter::fillRectangle(int x, int y, int w, int h,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -173,7 +162,7 @@ PainterBase & Painter::fillPolygon(int const * xp, int const * yp, int np,
|
||||
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
|
||||
@ -186,7 +175,8 @@ PainterBase & Painter::fillPolygon(int const * xp, int const * yp, int np,
|
||||
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;
|
||||
@ -203,10 +193,11 @@ PainterBase & Painter::arc(int x, int y,
|
||||
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;
|
||||
}
|
||||
@ -222,7 +213,7 @@ PainterBase & Painter::segments(int const * x1, int const * y1,
|
||||
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
|
||||
@ -236,7 +227,8 @@ PainterBase & Painter::segments(int const * x1, int const * y1,
|
||||
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;
|
||||
@ -251,14 +243,14 @@ PainterBase & Painter::pixmap(int x, int y, int w, int h, Pixmap bitmap)
|
||||
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;
|
||||
@ -285,12 +277,12 @@ PainterBase & Painter::text(int x, int y, char const * s, int ls,
|
||||
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);
|
||||
@ -301,13 +293,13 @@ PainterBase & Painter::text(int x, int y, char const * s, int ls,
|
||||
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);
|
||||
@ -332,136 +324,3 @@ void Painter::underline(LyXFont const & f, int x, int y, int width)
|
||||
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);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
// This is only included to provide stuff for the non-public sections
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include <map>
|
||||
#include "PainterBase.h"
|
||||
#include "LColor.h"
|
||||
|
||||
@ -101,36 +100,13 @@ public:
|
||||
/// 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
|
||||
|
@ -176,7 +176,7 @@ WorkArea::WorkArea(BufferView * o, int xpos, int ypos, int width, int height)
|
||||
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.
|
||||
|
@ -1591,11 +1591,6 @@ void Buffer::writeFileAscii(string const & fname, int linelen)
|
||||
case LyXParagraph::META_HFILL:
|
||||
ofs << "\t";
|
||||
break;
|
||||
#if 0
|
||||
case LyXParagraph::META_PROTECTED_SEPARATOR:
|
||||
ofs << " ";
|
||||
break;
|
||||
#endif
|
||||
case '\\':
|
||||
ofs << "\\";
|
||||
break;
|
||||
@ -3598,10 +3593,6 @@ void Buffer::RoffAsciiTable(ostream & os, LyXParagraph * par)
|
||||
break;
|
||||
case LyXParagraph::META_HFILL:
|
||||
break;
|
||||
#if 0
|
||||
case LyXParagraph::META_PROTECTED_SEPARATOR:
|
||||
break;
|
||||
#endif
|
||||
case '\\':
|
||||
ofs << "\\\\";
|
||||
break;
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "font.h"
|
||||
//#include "lyx_cb.h"
|
||||
#include "bufferview_funcs.h"
|
||||
#include "ColorHandler.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::istream;
|
||||
@ -109,7 +110,6 @@ static int gs_allcolors; // number of all colors
|
||||
|
||||
static list<int> pidwaitlist; // pid wait list
|
||||
|
||||
|
||||
static
|
||||
GC createGC()
|
||||
{
|
||||
@ -474,6 +474,10 @@ void freefigdata(figdata * tmpdata)
|
||||
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
|
||||
@ -501,7 +505,7 @@ void runqueue()
|
||||
continue;
|
||||
}
|
||||
|
||||
int pid = fork();
|
||||
int pid = ::fork();
|
||||
|
||||
if (pid == -1) {
|
||||
if (lyxerr.debugging()) {
|
||||
@ -553,14 +557,17 @@ void runqueue()
|
||||
}
|
||||
// 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);
|
||||
@ -579,8 +586,8 @@ void runqueue()
|
||||
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()) {
|
||||
@ -589,10 +596,11 @@ void runqueue()
|
||||
<< "] 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),
|
||||
@ -600,6 +608,8 @@ void runqueue()
|
||||
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
|
||||
@ -612,11 +622,13 @@ void runqueue()
|
||||
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,
|
||||
@ -627,6 +639,7 @@ void runqueue()
|
||||
strlen(tbuf));
|
||||
XUngrabServer(tempdisp);
|
||||
XFlush(tempdisp);
|
||||
|
||||
if (lyxerr.debugging()) {
|
||||
lyxerr << "Releasing the server" << endl;
|
||||
}
|
||||
@ -637,7 +650,7 @@ void runqueue()
|
||||
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
|
||||
@ -648,17 +661,17 @@ void runqueue()
|
||||
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",
|
||||
@ -930,22 +943,6 @@ void UnregisterFigure(InsetFig * fi)
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
@ -1664,7 +1661,7 @@ void InsetFig::GetPSSizes()
|
||||
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.
|
||||
|
@ -417,148 +417,68 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
|
||||
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
|
||||
@ -604,76 +524,28 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
|
||||
}
|
||||
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
|
||||
|
@ -84,10 +84,6 @@ InsetQuotes::InsetQuotes(char c, BufferParams const & params)
|
||||
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;
|
||||
|
@ -61,11 +61,6 @@ int InsetSpecialChar::width(Painter &, LyXFont const & font) const
|
||||
{
|
||||
return lyxfont::width(" x ", font);
|
||||
}
|
||||
#if 0
|
||||
case NEWLINE:
|
||||
{
|
||||
}
|
||||
#endif
|
||||
case PROTECTED_SEPARATOR:
|
||||
{
|
||||
return lyxfont::width('x', font);
|
||||
@ -119,11 +114,6 @@ void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
|
||||
x += width(pain, font);
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
case NEWLINE:
|
||||
{
|
||||
}
|
||||
#endif
|
||||
case PROTECTED_SEPARATOR:
|
||||
{
|
||||
float w = width(pain, font);
|
||||
@ -159,9 +149,6 @@ void InsetSpecialChar::Write(ostream & os) const
|
||||
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;
|
||||
}
|
||||
|
@ -34,10 +34,6 @@ public:
|
||||
END_OF_SENTENCE,
|
||||
/// Menu separator
|
||||
MENU_SEPARATOR,
|
||||
#if 0
|
||||
/// Newline
|
||||
NEWLINE,
|
||||
#endif
|
||||
/// Protected Separator
|
||||
PROTECTED_SEPARATOR
|
||||
};
|
||||
|
21
src/intl.C
21
src/intl.C
@ -132,10 +132,6 @@ void Intl::KeyMapPrim()
|
||||
/* 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);
|
||||
@ -167,10 +163,6 @@ void Intl::KeyMapSec()
|
||||
/* 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);
|
||||
@ -283,17 +275,6 @@ void Intl::InitKeyMapper(bool on)
|
||||
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");
|
||||
@ -304,7 +285,7 @@ void Intl::InitKeyMapper(bool on)
|
||||
Language2->addto((*cit).second.lang.c_str());
|
||||
++n;
|
||||
}
|
||||
#endif
|
||||
|
||||
Language->addto(_("other..."));
|
||||
Language2->addto(_("other..."));
|
||||
otherkeymap = n + 1;
|
||||
|
54
src/layout.C
54
src/layout.C
@ -97,50 +97,6 @@ enum LayoutTags {
|
||||
};
|
||||
|
||||
|
||||
#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
|
||||
@ -445,16 +401,6 @@ enum AlignTags {
|
||||
};
|
||||
|
||||
|
||||
#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
|
||||
|
@ -2736,13 +2736,7 @@ extern "C" void PrintCancelCB(FL_OBJECT *, long)
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "lyxlookup.h"
|
||||
#include "bufferlist.h"
|
||||
#include "language.h"
|
||||
#include "ColorHandler.h"
|
||||
|
||||
#ifdef TWO_COLOR_ICONS
|
||||
#include "banner_bw.xbm"
|
||||
@ -185,6 +186,8 @@ LyXGUI::LyXGUI(LyX * owner, int * argc, char * argv[], bool GUI)
|
||||
width = WidthOfScreen(scr) - 8;
|
||||
}
|
||||
|
||||
// Initialize the LyXColorHandler
|
||||
lyxColorHandler = new LyXColorHandler;
|
||||
}
|
||||
|
||||
|
||||
@ -410,20 +413,13 @@ void LyXGUI::create_forms()
|
||||
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");
|
||||
|
@ -287,12 +287,6 @@ void LyXParagraph::writeFile(ostream & os, BufferParams const & params,
|
||||
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;
|
||||
@ -2688,11 +2682,6 @@ bool LyXParagraph::linuxDocConvertChar(char c, string & sgml_string)
|
||||
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;
|
||||
@ -3190,11 +3179,6 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
|
||||
// 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
|
||||
@ -3209,11 +3193,6 @@ void LyXParagraph::SimpleTeXSpecialChars(ostream & os, TexRow & texrow,
|
||||
} else {
|
||||
// Plain mode (i.e. not LaTeX)
|
||||
switch (c) {
|
||||
#if 0
|
||||
case LyXParagraph::META_PROTECTED_SEPARATOR:
|
||||
os << '~';
|
||||
break;
|
||||
#endif
|
||||
case '\\':
|
||||
os << "\\textbackslash{}";
|
||||
column += 15;
|
||||
@ -3477,10 +3456,6 @@ bool LyXParagraph::RoffContTableRows(ostream & os,
|
||||
break;
|
||||
case LyXParagraph::META_HFILL:
|
||||
break;
|
||||
#if 0
|
||||
case LyXParagraph::META_PROTECTED_SEPARATOR:
|
||||
break;
|
||||
#endif
|
||||
case '\\':
|
||||
os << "\\\\";
|
||||
break;
|
||||
|
@ -22,17 +22,10 @@ bool IsNewlineChar(char c) {
|
||||
|
||||
|
||||
///
|
||||
#if 0
|
||||
inline
|
||||
bool IsSeparatorChar(char c) {
|
||||
return (c == ' ' || c == LyXParagraph::META_PROTECTED_SEPARATOR);
|
||||
}
|
||||
#else
|
||||
inline
|
||||
bool IsSeparatorChar(char c) {
|
||||
return (c == ' ');
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
///
|
||||
@ -96,9 +89,6 @@ bool IsKommaChar(char c) {
|
||||
|| c == '/'
|
||||
|| c == '\\'
|
||||
|| c == LyXParagraph::META_NEWLINE
|
||||
#if 0
|
||||
|| c == LyXParagraph::META_PROTECTED_SEPARATOR
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -43,25 +43,6 @@ char const * string_align[5] = {
|
||||
// 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", ""};
|
||||
|
||||
|
14
src/text.C
14
src/text.C
@ -3959,12 +3959,6 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
|
||||
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;
|
||||
@ -3985,7 +3979,6 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
|
||||
pb_font,
|
||||
LColor::background,
|
||||
LColor::background);
|
||||
#endif
|
||||
y_top += 3 * DefaultHeight();
|
||||
}
|
||||
|
||||
@ -4147,12 +4140,6 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
|
||||
|
||||
/* 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;
|
||||
@ -4174,7 +4161,6 @@ void LyXText::GetVisibleRow(int offset, Row * row_ptr, long y)
|
||||
pb_font,
|
||||
LColor::background,
|
||||
LColor::background);
|
||||
#endif
|
||||
y_bottom -= 3 * DefaultHeight();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user