mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
move inset related stuff from src/graphics to src/inset/
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4247 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
0af1698d3b
commit
551e3864c6
@ -1,3 +1,9 @@
|
||||
|
||||
2002-05-28 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* GraphicsParam.[Ch]:
|
||||
move inset related stuff to inset/insetgraphics
|
||||
|
||||
2002-05-24 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* GraphicsImageXPM.C: ColorHandler moved
|
||||
|
@ -55,7 +55,7 @@ void GCache::update(InsetGraphics const & inset, string const & filepath)
|
||||
// A subset only of InsetGraphicsParams is needed for display purposes.
|
||||
// The GraphicsParams c-tor also interrogates lyxrc to ascertain whether
|
||||
// to display or not.
|
||||
GParams params(inset.params(), filepath);
|
||||
GParams params = inset.params().asGParams(filepath);
|
||||
|
||||
// Each inset can reference only one file, so check the cache for any
|
||||
// graphics files referenced by inset. If the name of this file is
|
||||
|
@ -631,7 +631,7 @@ struct Params_Changed {
|
||||
bool operator()(InsetGraphics const * inset)
|
||||
{
|
||||
string const path = OnlyPath(p_.filename);
|
||||
return GParams(inset->params(), path) != p_;
|
||||
return inset->params().asGParams(path) != p_;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -669,7 +669,7 @@ ModifiedItemPtr ModifiedItem::changeDisplay()
|
||||
|
||||
ModifiedItemPtr new_item(new ModifiedItem(*this));
|
||||
new_item->insets = new_insets;
|
||||
*(new_item->p_) = GParams((*new_insets.begin())->params(), path);
|
||||
*(new_item->p_) = (*new_insets.begin())->params().asGParams(path);
|
||||
|
||||
new_item->setPixmap();
|
||||
return new_item;
|
||||
|
@ -13,107 +13,17 @@
|
||||
#endif
|
||||
|
||||
#include "GraphicsParams.h"
|
||||
#include "insets/insetgraphicsParams.h"
|
||||
#include "lyxrc.h"
|
||||
#include "debug.h"
|
||||
#include "support/filetools.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "Lsstream.h"
|
||||
|
||||
|
||||
namespace grfx {
|
||||
|
||||
GParams::GParams(InsetGraphicsParams const & iparams, string const & filepath)
|
||||
GParams::GParams()
|
||||
: width(0),
|
||||
height(0),
|
||||
scale(0),
|
||||
angle(0)
|
||||
{
|
||||
filename = iparams.filename;
|
||||
if (!filepath.empty()) {
|
||||
filename = MakeAbsPath(filename, filepath);
|
||||
}
|
||||
|
||||
if (iparams.clip) {
|
||||
bb = iparams.bb;
|
||||
|
||||
// Get the original Bounding Box from the file
|
||||
string const tmp = readBB_from_PSFile(filename);
|
||||
lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
|
||||
if (!tmp.empty()) {
|
||||
int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
|
||||
int const bb_orig_yb = strToInt(token(tmp, ' ', 1));
|
||||
|
||||
bb.xl -= bb_orig_xl;
|
||||
bb.xr -= bb_orig_xl;
|
||||
bb.yb -= bb_orig_yb;
|
||||
bb.yt -= bb_orig_yb;
|
||||
}
|
||||
|
||||
bb.xl = std::max(0, bb.xl);
|
||||
bb.xr = std::max(0, bb.xr);
|
||||
bb.yb = std::max(0, bb.yb);
|
||||
bb.yt = std::max(0, bb.yt);
|
||||
|
||||
// Paranoia check.
|
||||
int const width = bb.xr - bb.xl;
|
||||
int const height = bb.yt - bb.yb;
|
||||
|
||||
if (width < 0 || height < 0) {
|
||||
bb.xl = 0;
|
||||
bb.xr = 0;
|
||||
bb.yb = 0;
|
||||
bb.yt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (iparams.rotate)
|
||||
angle = int(iparams.rotateAngle);
|
||||
|
||||
if (iparams.display == InsetGraphicsParams::DEFAULT) {
|
||||
|
||||
if (lyxrc.display_graphics == "mono")
|
||||
display = MONOCHROME;
|
||||
else if (lyxrc.display_graphics == "gray")
|
||||
display = GRAYSCALE;
|
||||
else if (lyxrc.display_graphics == "color")
|
||||
display = COLOR;
|
||||
else
|
||||
display = NONE;
|
||||
|
||||
} else if (iparams.display == InsetGraphicsParams::NONE) {
|
||||
display = NONE;
|
||||
|
||||
} else if (iparams.display == InsetGraphicsParams::MONOCHROME) {
|
||||
display = MONOCHROME;
|
||||
|
||||
} else if (iparams.display == InsetGraphicsParams::GRAYSCALE) {
|
||||
display = GRAYSCALE;
|
||||
|
||||
} else if (iparams.display == InsetGraphicsParams::COLOR) {
|
||||
display = COLOR;
|
||||
}
|
||||
|
||||
// Override the above if we're not using a gui
|
||||
if (!lyxrc.use_gui) {
|
||||
display = NONE;
|
||||
}
|
||||
|
||||
if (iparams.lyxsize_type == InsetGraphicsParams::SCALE) {
|
||||
scale = iparams.lyxscale;
|
||||
|
||||
} else if (iparams.lyxsize_type == InsetGraphicsParams::WH) {
|
||||
if (!iparams.lyxwidth.zero())
|
||||
width = iparams.lyxwidth.inPixels(1, 1);
|
||||
if (!iparams.lyxheight.zero())
|
||||
height = iparams.lyxheight.inPixels(1, 1);
|
||||
|
||||
// inPixels returns a value scaled by lyxrc.zoom.
|
||||
// We want, therefore, to undo this.
|
||||
double const scaling_factor = 100.0 / double(lyxrc.zoom);
|
||||
width = uint(scaling_factor * width);
|
||||
height = uint(scaling_factor * height);
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
bool operator==(GParams const & a, GParams const & b)
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "LString.h"
|
||||
#include "lyxlength.h"
|
||||
|
||||
class InsetGraphicsParams;
|
||||
|
||||
namespace grfx {
|
||||
|
||||
@ -49,7 +48,7 @@ bool operator!=(BoundingBox const &, BoundingBox const &);
|
||||
|
||||
struct GParams
|
||||
{
|
||||
GParams(InsetGraphicsParams const &, string const &);
|
||||
GParams();
|
||||
|
||||
/// How is the image to be displayed on the LyX screen?
|
||||
enum DisplayType {
|
||||
|
@ -1,3 +1,8 @@
|
||||
2002-05-28 André Pönitz <poenitz@gmx.net>
|
||||
|
||||
* insets/insetgraphicsParams.[Ch]:
|
||||
put in inset related stuff from src/graphic
|
||||
|
||||
2002-05-26 John Levon <moz@compsoc.man.ac.uk>
|
||||
|
||||
* inset.C:
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include "support/lyxlib.h"
|
||||
#include "support/LOstream.h"
|
||||
#include "support/LAssert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "lyxrc.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
using std::ostream;
|
||||
@ -302,3 +305,100 @@ bool InsetGraphicsParams::Read(LyXLex & lex, string const & token)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
grfx::GParams InsetGraphicsParams::asGParams(string const & filepath) const
|
||||
{
|
||||
grfx::GParams pars;
|
||||
pars.width = 0;
|
||||
pars.height = 0;
|
||||
pars.scale = 0;
|
||||
pars.angle = 0;
|
||||
pars.filename = filename;
|
||||
|
||||
if (!filepath.empty()) {
|
||||
pars.filename = MakeAbsPath(pars.filename, filepath);
|
||||
}
|
||||
|
||||
if (clip) {
|
||||
pars.bb = bb;
|
||||
|
||||
// Get the original Bounding Box from the file
|
||||
string const tmp = readBB_from_PSFile(filename);
|
||||
lyxerr[Debug::GRAPHICS] << "BB_from_File: " << tmp << std::endl;
|
||||
if (!tmp.empty()) {
|
||||
int const bb_orig_xl = strToInt(token(tmp, ' ', 0));
|
||||
int const bb_orig_yb = strToInt(token(tmp, ' ', 1));
|
||||
|
||||
pars.bb.xl -= bb_orig_xl;
|
||||
pars.bb.xr -= bb_orig_xl;
|
||||
pars.bb.yb -= bb_orig_yb;
|
||||
pars.bb.yt -= bb_orig_yb;
|
||||
}
|
||||
|
||||
pars.bb.xl = std::max(0, pars.bb.xl);
|
||||
pars.bb.xr = std::max(0, pars.bb.xr);
|
||||
pars.bb.yb = std::max(0, pars.bb.yb);
|
||||
pars.bb.yt = std::max(0, pars.bb.yt);
|
||||
|
||||
// Paranoia check.
|
||||
int const width = pars.bb.xr - pars.bb.xl;
|
||||
int const height = pars.bb.yt - pars.bb.yb;
|
||||
|
||||
if (width < 0 || height < 0) {
|
||||
pars.bb.xl = 0;
|
||||
pars.bb.xr = 0;
|
||||
pars.bb.yb = 0;
|
||||
pars.bb.yt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (rotate)
|
||||
pars.angle = int(rotateAngle);
|
||||
|
||||
if (display == InsetGraphicsParams::DEFAULT) {
|
||||
|
||||
if (lyxrc.display_graphics == "mono")
|
||||
pars.display = grfx::GParams::MONOCHROME;
|
||||
else if (lyxrc.display_graphics == "gray")
|
||||
pars.display = grfx::GParams::GRAYSCALE;
|
||||
else if (lyxrc.display_graphics == "color")
|
||||
pars.display = grfx::GParams::COLOR;
|
||||
else
|
||||
pars.display = grfx::GParams::NONE;
|
||||
|
||||
} else if (display == InsetGraphicsParams::NONE) {
|
||||
pars.display = grfx::GParams::NONE;
|
||||
|
||||
} else if (display == InsetGraphicsParams::MONOCHROME) {
|
||||
pars.display = grfx::GParams::MONOCHROME;
|
||||
|
||||
} else if (display == InsetGraphicsParams::GRAYSCALE) {
|
||||
pars.display = grfx::GParams::GRAYSCALE;
|
||||
|
||||
} else if (display == InsetGraphicsParams::COLOR) {
|
||||
pars.display = grfx::GParams::COLOR;
|
||||
}
|
||||
|
||||
// Override the above if we're not using a gui
|
||||
if (!lyxrc.use_gui) {
|
||||
pars.display = grfx::GParams::NONE;
|
||||
}
|
||||
|
||||
if (lyxsize_type == InsetGraphicsParams::SCALE) {
|
||||
pars.scale = lyxscale;
|
||||
|
||||
} else if (lyxsize_type == InsetGraphicsParams::WH) {
|
||||
if (!lyxwidth.zero())
|
||||
pars.width = lyxwidth.inPixels(1, 1);
|
||||
if (!lyxheight.zero())
|
||||
pars.height = lyxheight.inPixels(1, 1);
|
||||
|
||||
// inPixels returns a value scaled by lyxrc.zoom.
|
||||
// We want, therefore, to undo this.
|
||||
double const scaling_factor = 100.0 / double(lyxrc.zoom);
|
||||
pars.width = uint(scaling_factor * pars.width);
|
||||
pars.height = uint(scaling_factor * pars.height);
|
||||
}
|
||||
return pars;
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
#include "buffer.h"
|
||||
#include "lyxlex.h"
|
||||
|
||||
#include "graphics/GraphicsParams.h"
|
||||
|
||||
|
||||
/// This struct holds all the parameters needed by insetGraphics.
|
||||
struct InsetGraphicsParams
|
||||
{
|
||||
@ -91,6 +94,8 @@ struct InsetGraphicsParams
|
||||
void Write(std::ostream & os) const;
|
||||
/// If the token belongs to our parameters, read it.
|
||||
bool Read(LyXLex & lex, string const & token);
|
||||
/// convert
|
||||
grfx::GParams asGParams(string const & filepath) const;
|
||||
|
||||
private:
|
||||
/// Initialize the object to a default status.
|
||||
|
Loading…
Reference in New Issue
Block a user