* John's maths patch,

* Baruch's second graphics patch,
* A few things to get stuff to compile on my machine --- Lars see the ChangeLog
in controllers; how do you get things to compile without a != operator?
Surely compilation dies in ControlInset, included in ControlFloat,
ControlMinipage.

Angus


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2389 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-07-30 13:35:08 +00:00
parent e952d33e0b
commit 2e5de574e1
15 changed files with 161 additions and 27 deletions

View File

@ -1,3 +1,11 @@
2001-07-30 Angus Leeming <a.leeming@ic.ac.uk>
* ControlFloat.h: add a != operator for FloatParams.
Lars, how did you get this to compile!!!
* ControlMinipage.[Ch]: uncommented someone's commenting out of
operator != for MinipageParams. Who's changing stuff and not compiling?
2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com> 2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
* Makefile.am (libcontrollers_la_SOURCES): add ControlFloat.h and * Makefile.am (libcontrollers_la_SOURCES): add ControlFloat.h and

View File

@ -42,6 +42,13 @@ bool operator==(FloatParams const & p1, FloatParams const & p2)
} }
inline
bool operator!=(FloatParams const & p1, FloatParams const & p2)
{
return !(p1 == p2);
}
/** A controller for Minipage dialogs. /** A controller for Minipage dialogs.
*/ */
class ControlFloat : public ControlInset<InsetFloat, FloatParams> { class ControlFloat : public ControlInset<InsetFloat, FloatParams> {

View File

@ -78,10 +78,10 @@ bool operator==(MinipageParams const & p1, MinipageParams const & p2)
} }
//bool operator!=(MinipageParams const & p1, MinipageParams const & p2) bool operator!=(MinipageParams const & p1, MinipageParams const & p2)
//{ {
// return !(p1 == p2); return !(p1 == p2);
//} }
namespace minipage { namespace minipage {

View File

@ -43,7 +43,7 @@ struct MinipageParams {
/// ///
bool operator==(MinipageParams const &, MinipageParams const &); bool operator==(MinipageParams const &, MinipageParams const &);
/// ///
//bool operator!=(MinipageParams const &, MinipageParams const &); bool operator!=(MinipageParams const &, MinipageParams const &);
/** A controller for Minipage dialogs. /** A controller for Minipage dialogs.

View File

@ -1,3 +1,12 @@
2001-07-29 John Levon <moz@compsoc.man.ac.uk>
* FormMathsBitmap.C: initialise form_
2001-07-29 Baruch Even <baruch@lyx.org>
* src/forms/form_graphics.fd:
* src/FormGraphics.C: Added support for the new horizontal scale factor.
2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com> 2001-07-30 Lars Gullik Bjønnes <larsbj@birdstep.com>
* forms/makefile (SRCS): add form_float.fd * forms/makefile (SRCS): add form_float.fd

View File

@ -99,6 +99,8 @@ void FormGraphics::build()
InsetGraphicsParams::INCH); InsetGraphicsParams::INCH);
heightButtons.registerRadioButton(dialog_->radio_height_percent_page, heightButtons.registerRadioButton(dialog_->radio_height_percent_page,
InsetGraphicsParams::PERCENT_PAGE); InsetGraphicsParams::PERCENT_PAGE);
heightButtons.registerRadioButton(dialog_->radio_height_scale,
InsetGraphicsParams::SCALE);
// Add the widgets of the display radio buttons to their group // Add the widgets of the display radio buttons to their group
displayButtons.reset(); displayButtons.reset();

View File

@ -40,7 +40,7 @@ FormMathsBitmap::FormMathsBitmap(LyXView * lv, Dialogs * d,
FormMathsPanel const & p, FormMathsPanel const & p,
vector<string> const & l) vector<string> const & l)
: FormMathsSub(lv, d, p, _("Maths Bitmaps")), : FormMathsSub(lv, d, p, _("Maths Bitmaps")),
latex_(l), ww_(0), x_(0), y_(0), w_(0), h_(0) latex_(l), form_(0), ww_(0), x_(0), y_(0), w_(0), h_(0)
{ {
ww_ = 2 * FL_abs(FL_BOUND_WIDTH); ww_ = 2 * FL_abs(FL_BOUND_WIDTH);
x_ = y_ = ww_; x_ = y_ = ww_;

View File

@ -145,6 +145,8 @@ FD_form_graphics * FormGraphics::build_graphics()
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_callback(obj, C_FormBaseCancelCB, 0); fl_set_object_callback(obj, C_FormBaseCancelCB, 0);
fdui->radio_height_scale = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 140, 160, 96, 30, _("Scale"));
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
fl_end_form(); fl_end_form();
fdui->form->fdui = fdui; fdui->form->fdui = fdui;

View File

@ -44,6 +44,7 @@ struct FD_form_graphics {
FL_OBJECT *button_ok; FL_OBJECT *button_ok;
FL_OBJECT *button_apply; FL_OBJECT *button_apply;
FL_OBJECT *button_cancel; FL_OBJECT *button_cancel;
FL_OBJECT *radio_height_scale;
}; };
#endif /* FD_form_graphics_h_ */ #endif /* FD_form_graphics_h_ */

View File

@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
Name: form_graphics Name: form_graphics
Width: 490 Width: 490
Height: 390 Height: 390
Number of Objects: 36 Number of Objects: 37
-------------------- --------------------
class: FL_BOX class: FL_BOX
@ -663,5 +663,23 @@ name: button_cancel
callback: C_FormBaseCancelCB callback: C_FormBaseCancelCB
argument: 0 argument: 0
--------------------
class: FL_CHECKBUTTON
type: RADIO_BUTTON
box: 140 160 96 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label: Scale
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: radio_height_scale
callback: C_FormBaseInputCB
argument: CHECKINPUT
============================== ==============================
create_the_forms create_the_forms

View File

@ -8,14 +8,25 @@
* insetfoot.h: remove InsetFoot:: qualifier. * insetfoot.h: remove InsetFoot:: qualifier.
2001-07-30 Baruch Even <baruch@lyx.org> 2001-07-29 Baruch Even <baruch@lyx.org>
* ChangeLog: Hiding time travel evidence.
* insetgraphicsParams.h:
* insetgraphicsParams.C:
* insetgraphics.C: Added horizontal scale option, it actually scales both
directions since it keeps image proportions.
* insetgraphics.C: Fixed EPS detection to be non-hacky.
2001-07-29 Baruch Even <baruch@lyx.org>
* insetgraphics.C (decideOutputImageFormat): when doing postscript output * insetgraphics.C (decideOutputImageFormat): when doing postscript output
convert PNG/GIF/JPG to EPS, assume the rest are EPS already. convert PNG/GIF/JPG to EPS, assume the rest are EPS already.
HACKY! Will need to add an EPS detection routine like old InsetFig does! HACKY! Will need to add an EPS detection routine like old InsetFig does!
2001-07-30 Baruch Even <baruch@lyx.org> 2001-07-29 Baruch Even <baruch@lyx.org>
* insetgraphics.C: Added EPSI to be an alias of EPS. * insetgraphics.C: Added EPSI to be an alias of EPS.

View File

@ -42,6 +42,14 @@ Known BUGS:
its original size and color, resizing is done in the final output, its original size and color, resizing is done in the final output,
but not in the LyX window. but not in the LyX window.
* The scale option is only handled for the horizontal part, the vertical
part will not work. For now it is also shown only for horizontal
resizing on the form.
* EPS figures are not fully detected, they may have a lot of possible
suffixes so we need to read the file and detect if it's EPS or not.
[Implemented, need testing]
TODO Before initial production release: TODO Before initial production release:
* Replace insetfig everywhere * Replace insetfig everywhere
* Search for comments of the form * Search for comments of the form
@ -146,6 +154,7 @@ TODO Extended features:
#include "lyxtext.h" #include "lyxtext.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "font.h" // For the lyxfont class. #include "font.h" // For the lyxfont class.
#include "fstream" // for ifstream in isEPS
#include <algorithm> // For the std::max #include <algorithm> // For the std::max
#include "support/lyxmanip.h" #include "support/lyxmanip.h"
#include "debug.h" #include "debug.h"
@ -153,6 +162,7 @@ TODO Extended features:
extern string system_tempdir; extern string system_tempdir;
using std::ifstream;
using std::ostream; using std::ostream;
using std::endl; using std::endl;
@ -480,6 +490,8 @@ void formatResize(ostream & os, string const & key,
os << key << '=' << size / 100 << "\\column" << key << ','; os << key << '=' << size / 100 << "\\column" << key << ',';
break; break;
case InsetGraphicsParams::SCALE:
os << "scale" << '=' << size << ',';
} }
} }
@ -512,27 +524,84 @@ InsetGraphics::createLatexOptions() const
namespace { namespace {
string decideOutputImageFormat(string const & in_fmt) enum FileType {
EPS,
PNG,
JPEG,
GIF,
PDF,
UNKNOWN
};
bool isEPS(string const & filename)
{
if (filename.empty() || !IsFileReadable(filename)) return false;
ifstream ifs(filename.c_str());
if (!ifs) return false; // Couldn't open file...
bool is_eps = false; // Have we recognized the file as EPS?
string to_find = "%!PS-Adobe-"; // The string we use to recognize
int const max_attempts = 500; // Maximum strings to read to attempt recognition
int count = 0; // Counter of attempts.
string str;
for (; count < max_attempts; ++count) {
if (ifs.eof()) {
lyxerr[Debug::INFO] << "InsetGraphics (isEPS)"
" End of file reached and it wasn't found to be EPS!" << endl;
break;
}
ifs >> str;
if (str.find(to_find)) {
is_eps = true;
break;
}
}
return is_eps;
}
enum FileType classifyFileType(string const & filename, string const & suffix)
{
if (suffix == "png")
return PNG;
else if (suffix == "jpg" || suffix == "jpeg")
return JPEG;
else if (suffix == "gif")
return GIF;
else if (suffix == "pdf")
return PDF;
else if (isEPS(filename))
return EPS;
return UNKNOWN;
}
string decideOutputImageFormat(string const & suffix, enum FileType type)
{ {
// lyxrc.pdf_mode means: // lyxrc.pdf_mode means:
// Are we creating a PDF or a PS file? // Are we creating a PDF or a PS file?
// (Should actually mean, are we using latex or pdflatex). // (Should actually mean, are we using latex or pdflatex).
if (lyxrc.pdf_mode) { if (lyxrc.pdf_mode) {
if (in_fmt == "eps" || in_fmt == "epsi" || in_fmt == "pdf") if (type == EPS || type == EPS || type == PDF)
return "pdf"; return "pdf";
else if (in_fmt == "jpg" || in_fmt == "jpeg") else if (type == JPEG)
return in_fmt; return suffix;
else else
return "png"; return "png";
} }
// If it's postscript, we always do eps. // If it's postscript, we always do eps.
// Garst has many eps files with various extensions, we just assume // There are many suffixes that are actually EPS (ask Garst for example)
// whatever goes in (except those we know to be otherwise) is eps // so we detect if it's an EPS by looking in the file, if it is, we return
if (in_fmt == "gif" || in_fmt == "png" || in_fmt == "jpg") // the same suffix of the file so it won't be converted.
return "eps"; if (type == EPS)
return in_fmt; return suffix;
return "eps";
} }
} // Anon. namespace } // Anon. namespace
@ -559,10 +628,11 @@ InsetGraphics::prepareFile(Buffer const *buf) const
// Get the extension (format) of the original file. // Get the extension (format) of the original file.
string const extension = GetExtension(params.filename); string const extension = GetExtension(params.filename);
FileType type = classifyFileType(params.filename, extension);
// Are we creating a PDF or a PS file? // Are we creating a PDF or a PS file?
// (Should actually mean, are we usind latex or pdflatex). // (Should actually mean, are we usind latex or pdflatex).
string const image_target = decideOutputImageFormat(extension); string const image_target = decideOutputImageFormat(extension, type);
if (extension == image_target) if (extension == image_target)
return params.filename; return params.filename;

View File

@ -61,6 +61,7 @@ InsetGraphicsParams::InsetGraphicsParams()
resizeTranslator.addPair(INCH, "inch"); resizeTranslator.addPair(INCH, "inch");
resizeTranslator.addPair(PERCENT_PAGE, "percentOfPage"); resizeTranslator.addPair(PERCENT_PAGE, "percentOfPage");
resizeTranslator.addPair(PERCENT_COLUMN, "percentOfColumn"); resizeTranslator.addPair(PERCENT_COLUMN, "percentOfColumn");
resizeTranslator.addPair(SCALE, "scale");
// Fill the origin translator // Fill the origin translator
originTranslator.addPair(DEFAULT, "default"); originTranslator.addPair(DEFAULT, "default");
@ -155,17 +156,20 @@ void InsetGraphicsParams::testInvariant() const
widthResize == CM || widthResize == CM ||
widthResize == INCH || widthResize == INCH ||
widthResize == PERCENT_PAGE || widthResize == PERCENT_PAGE ||
widthResize == PERCENT_COLUMN widthResize == PERCENT_COLUMN ||
widthResize == SCALE
); );
lyx::Assert(heightResize == DEFAULT_SIZE || lyx::Assert(heightResize == DEFAULT_SIZE ||
heightResize == CM || heightResize == CM ||
heightResize == INCH || heightResize == INCH ||
heightResize == PERCENT_PAGE heightResize == PERCENT_PAGE ||
heightResize == SCALE
); );
lyx::Assert(widthSize >= 0.0); // For SCALE these can be negative.
lyx::Assert(heightSize >= 0.0); //lyx::Assert(widthSize >= 0.0);
//lyx::Assert(heightSize >= 0.0);
// Angle is in degrees and ranges -360 < angle < 360 // Angle is in degrees and ranges -360 < angle < 360
// The reason for this is that in latex there is a meaning for the // The reason for this is that in latex there is a meaning for the

View File

@ -75,7 +75,8 @@ struct InsetGraphicsParams
CM, CM,
INCH, INCH,
PERCENT_PAGE, PERCENT_PAGE,
PERCENT_COLUMN PERCENT_COLUMN,
SCALE
}; };

View File

@ -21,6 +21,7 @@
#include "support/filetools.h" #include "support/filetools.h"
#include "BufferView.h" #include "BufferView.h"
#include "LyXView.h" #include "LyXView.h"
#include "support/LOstream.h"
#include "commandtags.h" #include "commandtags.h"
#include "buffer.h" #include "buffer.h"
#include "gettext.h" #include "gettext.h"