Add LColor::graphicsbg and use it in the graphics and figure insets.

Ensures that a figure with a transparent colour can be viewed
easily if the LyX screen's background colour is dark.

Prevent deletion of the image file if no conversion is required.

This patch works like a charm with the (old) figinset. When testing
the graphics inset, however, I find that colour "None" in an XPM file
is displayed as black. I have no idea why. This appears to be true of
some other graphics viewers also. E.g., KDE 2's pixie displays "None"
as black but the venerable xv works fine.

Maybe it's my version of the xpm library, but v3.4.11 appears to be
right up to date.

Can people test on their machines and/or offer suggestions here?
Angus

p.s. You can test with the XPM files in lib/images. They will no longer
be deleted if you load them into LyX!

A.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2777 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-09-20 13:16:17 +00:00
parent eec568d870
commit 47b06816be
7 changed files with 30 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2001-09-18 Angus Leeming <a.leeming@ic.ac.uk>
* LColor.[Ch]: added graphicsbg to color enum and to ColorEntry.
2001-09-20 Michael Schmitt <Michael.Schmitt@teststep.org>
* several files: fix typos in user-visible strings

View File

@ -72,6 +72,7 @@ LColor::LColor()
{ special, N_("special character"), "special", "RoyalBlue", "special" },
{ math, N_("math"), "math", "DarkBlue", "math" },
{ mathbg, N_("math background"), "mathbg", "linen", "mathbg" },
{ graphicsbg, N_("graphics background"), "graphicsbg", "linen", "graphicsbg" },
{ mathmacrobg, N_("Math macro background"), "mathmacrobg", "linen", "mathmacrobg" },
{ mathframe, N_("math frame"), "mathframe", "Magenta", "mathframe" },
{ mathcursor, N_("math cursor"), "mathcursor", "black", "mathcursor" },

View File

@ -99,6 +99,8 @@ public:
/// Special chars text color
special,
/// Graphics inset background color
graphicsbg,
/// Math inset text color
math,
/// Math inset background color

View File

@ -130,6 +130,15 @@ GraphicsCacheItem::convertImage(string const & filename)
if (to.empty())
return false;
if (from == to) {
// No conversion needed!
// Saves more than just time: prevents the deletion of
// the "to" file after loading when it's the same as the "from"!
tempfile = filename;
loadImage();
return true;
}
// Take only the filename part of the file, without path or extension.
string temp = OnlyFilename(filename);
temp = ChangeExtension(filename, string());

View File

@ -1,3 +1,9 @@
2001-09-18 Angus Leeming <a.leeming@ic.ac.uk>
* figinset.C (runqueue):
* insetgraphics.C (draw): set background colour of inset from
background to the user-configurable graphicsbg.
2001-09-07 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* insetquotes.C (InsetQuotes): when trying to decide the side of

View File

@ -469,7 +469,7 @@ void runqueue()
{
// This _have_ to be set before the fork!
unsigned long background_pixel =
lyxColorHandler->colorPixel(LColor::background);
lyxColorHandler->colorPixel(LColor::graphicsbg);
// run queued requests for ghostscript, if any
if (!gsrunning && gs_color && !gs_xcolor) {

View File

@ -284,6 +284,12 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
// we draw just a rectangle.
if (imageLoaded) {
// Draw a ractangle with the specified color. If the image is
// transparent, this will shine through.
paint.fillRectangle(old_x + 2, baseline - lascent,
lwidth - 4, lascent + ldescent,
LColor::graphicsbg);
paint.image(old_x + 2, baseline - lascent,
lwidth - 4, lascent + ldescent,
cacheHandle->getImage());