Baruch's graphics patch + some small tweaks to the buttoncontroller stuff

Kayvan's footnote patch
Added a "Buffer const *" parameter to InsetButton::getScreenLabel and all
daughter classes. Labels can now be tuned to suit, although non are yet.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2375 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-07-28 12:24:16 +00:00
parent bf6257967e
commit 5f2e3c4c43
47 changed files with 291 additions and 154 deletions

View File

@ -203,7 +203,8 @@ Menuset
Separator
Item "TeX|T" "ert-insert"
Item "Minipage|p" "minipage-insert"
Item "Graphics...|G" "figure-insert"
Item "Old-Graphics..." "figure-insert"
Item "Graphics...|G" "graphics-insert"
Item "Tabular Material...|b" "dialog-tabular-insert"
Submenu "Floats|a" "insert_floats"
Separator

View File

@ -17,6 +17,11 @@
* text2.C (toggleFree): do selection with WHOLE_WORD_STRICT
scheme.
2001-07-26 Baruch Even <baruch@lyx.org>
* buffer.C (readInset): Changed to call up InsetGraphics when reading
an InsetFig figure, backwards compatible reading of old figure code.
2001-07-27 Juergen Vigna <jug@sad.it>
* text2.C: font.realize function adaption.

View File

@ -1453,8 +1453,11 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
inset = new InsetFormulaMacro;
} else if (tmptok == "Formula") {
inset = new InsetFormula;
} else if (tmptok == "Figure") {
inset = new InsetFig(100, 100, *this);
} else if (tmptok == "Figure") { // Backward compatibility
//inset = new InsetFig(100, 100, *this);
inset = new InsetGraphics;
} else if (tmptok == "GRAPHICS") {
inset = new InsetGraphics;
} else if (tmptok == "Info") {// backwards compatibility
inset = new InsetNote(this,
lex.getLongString("\\end_inset"),
@ -1489,8 +1492,6 @@ void Buffer::readInset(LyXLex & lex, Paragraph *& par,
#endif
} else if (tmptok == "Caption") {
inset = new InsetCaption;
} else if (tmptok == "GRAPHICS") {
inset = new InsetGraphics;
} else if (tmptok == "FloatList") {
inset = new InsetFloatList;
}

View File

@ -1,3 +1,8 @@
2001-07-26 Baruch Even <baruch@lyx.org>
* ControlGraphics.C: changed file search string to cover eps, jpeg, gif
and png.
2001-07-23 John Levon <moz@compsoc.man.ac.uk>
* ControlInclude.h:

View File

@ -79,7 +79,7 @@ string const ControlGraphics::Browse(string const & in_name)
{
string const title = N_("Graphics");
// FIXME: currently we need the second '|' to prevent mis-interpretation
string const pattern = "*.(ps|png)|";
string const pattern = "*.(eps|png|jpeg|gif)|";
// Does user clipart directory exist?
string clipdir = AddName (user_lyxdir, "clipart");

View File

@ -1,3 +1,23 @@
2001-07-26 Angus Leeming <a.leeming@ic.ac.uk>
* input_validators.[Ch] (fl_int_filter, fl_float_filter): new methods.
* FormGraphics.C (build): uncommented the fl_set_input_return call for
input_rotate_angle. Set input filter on rotate_angle to make it accept
only floating point numbers.
(input): Browse now activates the Ok button approriately.
2001-07-26 Baruch Even <baruch@lyx.org>
* FormGraphics.h:
* FormGraphics.C: Removed hide method since it was interfering with the
needed work, it cleared several vectors that were needed for proper
functioning. Also changed rotateAngle to float.
* FormGraphics.C:
* forms/form_graphics.fd: Removed inline option, all InsetGraphics figures
are inlined.
2001-07-23 John Levon <moz@compsoc.man.ac.uk>
* FormInclude.C: add load file facility back

View File

@ -41,17 +41,6 @@ FormGraphics::FormGraphics(ControlGraphics & c)
{}
void FormGraphics::hide()
{
// Remove all associations for the radio buttons
widthButtons.reset();
heightButtons.reset();
displayButtons.reset();
FormBase::hide();
}
void FormGraphics::build()
{
dialog_.reset(build_graphics());
@ -67,8 +56,8 @@ void FormGraphics::build()
FL_RETURN_CHANGED);
fl_set_input_return (dialog_->input_filename,
FL_RETURN_CHANGED);
// fl_set_input_return(dialog_->input_rotate_angle,
// FL_RETURN_CHANGED);
fl_set_input_return (dialog_->input_rotate_angle,
FL_RETURN_CHANGED);
// Set the maximum characters that can be written in the input texts.
fl_set_input_maxchars(dialog_->input_width, WIDTH_MAXDIGITS);
@ -83,6 +72,9 @@ void FormGraphics::build()
fl_set_input_filter(dialog_->input_height,
fl_unsigned_int_filter);
// Set input filter on rotate_angle to make it accept only
// floating point numbers.
fl_set_input_filter(dialog_->input_rotate_angle, fl_float_filter);
// Add the widgets of the width radio buttons to their group
widthButtons.reset();
@ -133,7 +125,6 @@ void FormGraphics::build()
bc().addReadOnly(dialog_->radio_button_group_height);
bc().addReadOnly(dialog_->radio_button_group_display);
bc().addReadOnly(dialog_->input_rotate_angle);
bc().addReadOnly(dialog_->check_inline);
bc().addReadOnly(dialog_->input_subcaption);
bc().addReadOnly(dialog_->check_subcaption);
}
@ -157,17 +148,17 @@ void FormGraphics::apply()
(heightButtons.getButton());
igp.heightSize = strToDbl(fl_get_input(dialog_->input_height));
igp.rotateAngle = strToInt(fl_get_input(dialog_->input_rotate_angle));
igp.rotateAngle = strToDbl(fl_get_input(dialog_->input_rotate_angle));
/* // Need to redo it for floats, but I'm lazy now - BE 20010725
if (igp.rotateAngle >= 360)
igp.rotateAngle = igp.rotateAngle % 360;
if (igp.rotateAngle <= -360)
igp.rotateAngle = - (( -igp.rotateAngle) % 360);
*/
igp.subcaption = fl_get_button(dialog_->check_subcaption);
igp.subcaptionText = fl_get_input(dialog_->input_subcaption);
igp.inlineFigure = fl_get_button(dialog_->check_inline);
igp.testInvariant();
}
@ -204,10 +195,6 @@ void FormGraphics::update()
fl_set_input(dialog_->input_subcaption,
igp.subcaptionText.c_str());
// Update the inline figure check button
fl_set_button(dialog_->check_inline,
igp.inlineFigure);
// Now make sure that the buttons are set correctly.
input(0, 0);
}
@ -231,7 +218,7 @@ ButtonPolicy::SMInput FormGraphics::input(FL_OBJECT *, long data)
if (out_name != in_name && !out_name.empty()) {
fl_set_input(dialog_->input_filename, out_name.c_str());
input(0, 0);
activate = input(0, CHECKINPUT);
}
break;
}

View File

@ -37,8 +37,6 @@ private:
virtual void apply();
/// Build the dialog.
virtual void build();
/// Hide the dialog.
virtual void hide();
/// Update dialog before/whilst showing it.
virtual void update();
/// Filter the inputs on callback from xforms

View File

@ -28,7 +28,6 @@ FD_form_graphics * FormGraphics::build_graphics()
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_NorthWest, FL_SouthEast);
obj = fl_add_frame(FL_ENGRAVED_FRAME, 20, 310, 138, 30, "");
obj = fl_add_frame(FL_ENGRAVED_FRAME, 279, 250, 201, 50, "");
{
char const * const dummy = N_("Graphics File|#F");
fdui->input_filename = obj = fl_add_input(FL_NORMAL_INPUT, 150, 20, 210, 30, idex(_(dummy)));
@ -109,19 +108,13 @@ FD_form_graphics * FormGraphics::build_graphics()
}
fl_end_group();
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 250, 236, 50, _("Rotate"));
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 250, 240, 50, _("Rotate"));
{
char const * const dummy = N_("Angle|#A");
fdui->input_rotate_angle = obj = fl_add_input(FL_INT_INPUT, 91, 260, 94, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
{
char const * const dummy = N_("Inline Figure|#I");
fdui->check_inline = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 279, 260, 201, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
fdui->input_subcaption = obj = fl_add_input(FL_NORMAL_INPUT, 158, 310, 322, 30, "");
fl_set_object_callback(obj, C_FormBaseInputCB, CHECKINPUT);
{

View File

@ -38,7 +38,6 @@ struct FD_form_graphics {
FL_OBJECT *radio_display_color;
FL_OBJECT *radio_no_display;
FL_OBJECT *input_rotate_angle;
FL_OBJECT *check_inline;
FL_OBJECT *input_subcaption;
FL_OBJECT *check_subcaption;
FL_OBJECT *button_restore;

View File

@ -10,7 +10,7 @@ Unit of measure: FL_COORD_PIXEL
Name: form_graphics
Width: 490
Height: 390
Number of Objects: 38
Number of Objects: 36
--------------------
class: FL_BOX
@ -48,24 +48,6 @@ name:
callback:
argument:
--------------------
class: FL_FRAME
type: ENGRAVED_FRAME
box: 279 250 201 50
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
@ -540,7 +522,7 @@ argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 20 250 236 50
box: 20 250 240 50
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
@ -573,24 +555,6 @@ name: input_rotate_angle
callback: C_FormBaseInputCB
argument: CHECKINPUT
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 279 260 201 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: Inline Figure|#I
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_inline
callback: C_FormBaseInputCB
argument: CHECKINPUT
--------------------
class: FL_INPUT
type: NORMAL_INPUT

View File

@ -14,10 +14,20 @@ extern "C"
{
#endif
int fl_int_filter(FL_OBJECT * ob,
char const *, char const *, int c)
{
if (c == 0 /* final test before handing contents to app */
|| strchr("0123456789+-", c)) {
if (isStrInt(fl_get_input(ob)))
return FL_VALID;
}
return FL_INVALID|FL_RINGBELL;
}
int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
char const * /*not_used*/,
char const * /*unused*/,
int c)
char const *, char const *, int c)
{
if (c == 0 /* final test before handing contents to app */
|| strchr("0123456789", c)) {
@ -28,6 +38,18 @@ int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
}
int fl_float_filter(FL_OBJECT * ob,
char const *, char const *, int c)
{
if (c == 0 /* final test before handing contents to app */
|| strchr("0123456789.+-", c)) {
if (isStrDbl(fl_get_input(ob)))
return FL_VALID;
}
return FL_INVALID|FL_RINGBELL;
}
int fl_unsigned_float_filter(FL_OBJECT * ob,
char const * /*not_used*/,
char const * /*unused*/,
@ -37,8 +59,6 @@ int fl_unsigned_float_filter(FL_OBJECT * ob,
|| strchr("0123456789.", c)) {
if (isStrDbl(fl_get_input(ob)))
return FL_VALID;
else
return FL_INVALID|FL_RINGBELL;
}
return FL_INVALID|FL_RINGBELL;
}

View File

@ -25,9 +25,15 @@ extern "C"
{
#endif
/** Only allow whole numbers no '+' or '-' signs or exponents. */
/** Only allow integer numbers,
possibly preceeded by a +' or '-' sign */
int fl_int_filter(FL_OBJECT *, char const *, char const *, int);
/** Only allow integer numbers. No '+' or '-' signs. */
int fl_unsigned_int_filter(FL_OBJECT *, char const *, char const *, int);
/** Only allow whole numbers no '+' or '-' signs or exponents. */
/** Only allow floating point numbers,
possibly preceeded by a +' or '-' sign */
int fl_float_filter(FL_OBJECT *, char const *, char const *, int);
/** Only allow floating point numbers. No '+' or '-' signs. */
int fl_unsigned_float_filter(FL_OBJECT *, char const *, char const *, int);
/** Only allow lowercase letters. */

View File

@ -1,3 +1,51 @@
2001-07-28 Angus Leeming <a.leeming@ic.ac.uk>
* insetert.C (get_new_label): int -> Paragraph::size_type to get
std::min working.
* insetgraphics.C: added a using std::endl directive.
* insetcommand.h (getScreenLabel): removed pure virtual function,
as it duplicates that in InsetButton.
* insetbib.[Ch] (getScreenLabel):
* insetbutton.[Ch] (getScreenLabel):
* insetcite.[Ch] (getScreenLabel):
* insetert.[Ch] (getScreenLabel):
* insetexternal.[Ch] (getScreenLabel):
* insetfloatlist.[Ch] (getScreenLabel):
* insetinclude.[Ch] (getScreenLabel):
* insetindex.[Ch] (getScreenLabel):
* insetlabel.h (getScreenLabel):
* insetparent.[Ch] (getScreenLabel):
* insetref.[Ch] (getScreenLabel):
* insettoc.[Ch] (getScreenLabel):
* inseturl.[Ch] (getScreenLabel): passed a Buffer const * parameter.
* insetcite.C (getScreenLabel): use this Buffer parameter in creating
the label.
(validate): remove check on "cite" when using natbib.
2001-07-26 Baruch Even <baruch@lyx.org>
* insetgraphics.C (draw): changed casting to be in one place rather than
all over the function.
* insetgraphics.h:
* insetgraphics.C (read): Added compatibility reads of InsetFig.
* insetgraphicsParams.h:
* insetgraphicsParams.C:
* insetgraphics.C: Removed inline option and changed rotateAngle to float.
2001-07-28 Kayvan A. Sylvan <kayvan@sylvan.com>
* insetfoot.C (validate): Added method to ensure that the
right bit of LaTeX is emitted.
* insetfoot.h: Added validate method to set the correct
LaTeXFeatures bit for the special footnote code.
2001-07-26 Yves Bastide <stid@libd-pc11.univ-bpclermont.fr>
* insetquotes.C (dispString): display the right ISO8859-{1,9,15}

View File

@ -100,7 +100,7 @@ string const InsetBibKey::getBibLabel() const
return tostr(counter);
}
string const InsetBibKey::getScreenLabel() const
string const InsetBibKey::getScreenLabel(Buffer const *) const
{
return getContents() + " [" + getBibLabel() + "]";
}
@ -128,7 +128,7 @@ InsetBibtex::~InsetBibtex()
}
string const InsetBibtex::getScreenLabel() const
string const InsetBibtex::getScreenLabel(Buffer const *) const
{
return _("BibTeX Generated References");
}

View File

@ -41,7 +41,7 @@ public:
///
void read(Buffer const *, LyXLex & lex);
///
virtual string const getScreenLabel() const;
virtual string const getScreenLabel(Buffer const *) const;
///
void edit(BufferView *, int x, int y, unsigned int button);
///
@ -87,7 +87,7 @@ public:
return new InsetBibtex(params(), same_id);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///

View File

@ -36,7 +36,7 @@ int InsetButton::ascent(BufferView * bv, LyXFont const &) const
int width;
int ascent;
int descent;
string const s = getScreenLabel();
string const s = getScreenLabel(bv->buffer());
#if 0
if (editable()) {
@ -68,7 +68,7 @@ int InsetButton::descent(BufferView * bv, LyXFont const &) const
int width;
int ascent;
int descent;
string const s = getScreenLabel();
string const s = getScreenLabel(bv->buffer());
#if 0
if (editable()) {
@ -100,7 +100,7 @@ int InsetButton::width(BufferView * bv, LyXFont const &) const
int width;
int ascent;
int descent;
string const s = getScreenLabel();
string const s = getScreenLabel(bv->buffer());
#if 0
if (editable()) {
@ -132,7 +132,7 @@ void InsetButton::draw(BufferView * bv, LyXFont const &,
LyXFont font(LyXFont::ALL_SANE);
font.setColor(LColor::command).decSize();
string const s = getScreenLabel();
string const s = getScreenLabel(bv->buffer());
#if 0
int width;

View File

@ -34,7 +34,7 @@ public:
protected:
/// This should provide the text for the button
virtual string const getScreenLabel() const = 0;
virtual string const getScreenLabel(Buffer const *) const = 0;
};
#endif

View File

@ -25,7 +25,7 @@ InsetCitation::InsetCitation(InsetCommandParams const & p, bool)
: InsetCommand(p)
{}
string const InsetCitation::getScreenLabel() const
string const InsetCitation::getScreenLabel(Buffer const *) const
{
string keys(getContents());
@ -98,6 +98,6 @@ int InsetCitation::latex(Buffer const * buffer, std::ostream & os,
void InsetCitation::validate(LaTeXFeatures & features) const
{
if (getCmdName() != "cite" && features.bufferParams().use_natbib)
if (features.bufferParams().use_natbib)
features.natbib = true;
}

View File

@ -28,7 +28,7 @@ public:
return new InsetCitation(params(), same_id);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///

View File

@ -101,13 +101,6 @@ public:
///
Inset::Code lyxCode() const { return Inset::NO_CODE; }
/** Get the label that appears at screen.
I thought it was enough to eliminate the argument to avoid
confusion with lyxinset::getLabel(int), but I've seen that
it wasn't. I hope you never confuse again both methods. (ale)
*/
virtual string const getScreenLabel() const = 0;
///
string const getCommand() const { return p_.getCommand(); }
///

View File

@ -222,8 +222,8 @@ string const InsetERT::get_new_label() const
string la;
Paragraph::size_type const max_length = 15;
int const p_siz = inset.paragraph()->size();
int const n = std::min(max_length, p_siz);
Paragraph::size_type const p_siz = inset.paragraph()->size();
Paragraph::size_type const n = std::min(max_length, p_siz);
int i = 0;
int j = 0;
for(; i < n && j < p_siz; ++j) {

View File

@ -202,7 +202,7 @@ Inset * InsetExternal::clone(Buffer const &, bool same_id) const
}
string const InsetExternal::getScreenLabel() const
string const InsetExternal::getScreenLabel(Buffer const *) const
{
ExternalTemplate const & et = params_.templ;
if (et.guiName.empty())

View File

@ -79,7 +79,7 @@ public:
virtual Inset * clone(Buffer const &, bool same_id = false) const;
/// returns the text of the button
virtual string const getScreenLabel() const;
virtual string const getScreenLabel(Buffer const *) const;
// The following public members are used from the frontends code

View File

@ -12,7 +12,7 @@
using std::endl;
string const InsetFloatList::getScreenLabel() const
string const InsetFloatList::getScreenLabel(Buffer const *) const
{
string const guiName = floatList[float_type]->second.name();
if (!guiName.empty()) {
@ -104,7 +104,7 @@ int InsetFloatList::latex(Buffer const *, std::ostream & os, bool, bool) const
int InsetFloatList::ascii(Buffer const * buffer, std::ostream & os, int) const
{
os << getScreenLabel() << "\n\n";
os << getScreenLabel(buffer) << "\n\n";
Buffer::Lists const toc_list = buffer->getLists();
Buffer::Lists::const_iterator cit =

View File

@ -32,7 +32,7 @@ public:
return new InsetFloatList(*this);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
void edit(BufferView * bv, int, int, unsigned int);
///

View File

@ -62,3 +62,8 @@ int InsetFoot::latex(Buffer const * buf,
return i + 2;
}
void InsetFoot::validate(LaTeXFeatures & features) const
{
features.NeedLyXFootnoteCode = true;
}

View File

@ -18,6 +18,7 @@
#pragma interface
#endif
#include "LaTeXFeatures.h"
#include "insetfootlike.h"
/** The footnote inset
@ -37,6 +38,8 @@ public:
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
///
string const editMessage() const;
///
void InsetFoot::validate(LaTeXFeatures & features) const;
};
#endif

View File

@ -150,6 +150,7 @@ TODO Extended features:
extern string system_tempdir;
using std::ostream;
using std::endl;
// This function is a utility function
inline
@ -337,6 +338,20 @@ void InsetGraphics::write(Buffer const * buf, ostream & os) const
void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
{
string const token = lex.GetString();
if (token == "GRAPHICS")
readInsetGraphics(buf, lex);
else if (token == "Figure") // Compatibility reading of FigInset figures.
readFigInset(buf, lex);
else
lyxerr[Debug::INFO] << "Not a GRAPHICS or Figure inset!\n";
updateInset();
}
void InsetGraphics::readInsetGraphics(Buffer const * buf, LyXLex & lex)
{
bool finished = false;
@ -368,8 +383,70 @@ void InsetGraphics::read(Buffer const * buf, LyXLex & lex)
<< std::endl;
}
}
}
updateInset();
void InsetGraphics::readFigInset(Buffer const * buf, LyXLex & lex)
{
bool finished = false;
while (lex.IsOK() && !finished) {
lex.next();
string const token = lex.GetString();
lyxerr[Debug::INFO] << "Token: " << token << endl;
if (token.empty())
continue;
else if (token == "\\end_inset") {
finished = true;
} else if (token == "file") {
if (lex.next()) {
string const name = lex.GetString();
string const path = OnlyPath(buf->fileName());
params.filename = MakeAbsPath(name, path);
}
} else if (token == "extra") {
if (lex.next());
// kept for backwards compability. Delete in 0.13.x
} else if (token == "subcaption") {
if (lex.EatLine())
params.subcaptionText = lex.GetString();
} else if (token == "label") {
if (lex.next());
// kept for backwards compability. Delete in 0.13.x
} else if (token == "angle") {
if (lex.next())
params.rotateAngle = lex.GetFloat();
} else if (token == "size") {
// Size of image on screen is ignored in InsetGraphics, just eat
// the input.
if (lex.next())
lex.GetInteger();
if (lex.next())
lex.GetInteger();
} else if (token == "flags") {
InsetGraphicsParams::DisplayType tmp = InsetGraphicsParams::COLOR;
if (lex.next())
switch (lex.GetInteger()) {
case 1: tmp = InsetGraphicsParams::MONOCHROME; break;
case 2: tmp = InsetGraphicsParams::GRAYSCALE; break;
}
params.display = tmp;
} else if (token == "subfigure") {
params.subcaption = true;
} else if (token == "width") {
if (lex.next())
params.widthResize = static_cast<InsetGraphicsParams::Resize>(lex.GetInteger());
if (lex.next())
params.widthSize = lex.GetFloat();
} else if (token == "height") {
if (lex.next())
params.heightResize = static_cast<InsetGraphicsParams::Resize>(lex.GetInteger());
if (lex.next())
params.heightSize = lex.GetFloat();
}
}
}
@ -415,7 +492,9 @@ InsetGraphics::createLatexOptions() const
formatResize(options, "width", params.widthResize, params.widthSize);
formatResize(options, "height", params.heightResize, params.heightSize);
if (params.rotateAngle != 0) {
// Make sure it's not very close to zero, a float can be effectively
// zero but not exactly zero.
if (lyx::float_equal(params.rotateAngle, 0, 0.001)) {
options << "angle="
<< params.rotateAngle << ',';
}
@ -511,13 +590,6 @@ int InsetGraphics::latex(Buffer const *buf, ostream & os,
string before;
string after;
// If it's not an inline image, surround it with the centering paragraph.
if (! params.inlineFigure) {
before += "\n" "\\vspace{0.3cm}\n" "{\\par\\centering ";
after = " \\par}\n" "\\vspace{0.3cm}\n" + after;
newlines += 4;
}
// Do we want subcaptions?
if (params.subcaption) {
before += "\\subfigure[" + params.subcaptionText + "]{";

View File

@ -98,6 +98,11 @@ public:
SigC::Signal0<void> hideDialog;
private:
/// Read the inset native format
void readInsetGraphics(Buffer const * buf, LyXLex & lex);
/// Read the FigInset file format
void readFigInset(Buffer const * buf, LyXLex & lex);
/// Update the inset after parameter change.
void updateInset() const;
/// Get the status message, depends on the image loading status.

View File

@ -18,6 +18,7 @@
#include "support/translator.h"
#include "support/filetools.h"
#include "support/lyxlib.h"
#include "support/LAssert.h"
@ -109,7 +110,6 @@ void InsetGraphicsParams::init()
{
subcaptionText = filename = string();
display = MONOCHROME;
inlineFigure = false;
subcaption = false;
keepAspectRatio = true;
widthResize = DEFAULT_SIZE;
@ -117,7 +117,7 @@ void InsetGraphicsParams::init()
heightResize = DEFAULT_SIZE;
heightSize = 0.0;
rotateOrigin = DEFAULT;
rotateAngle = 0;
rotateAngle = 0.0;
testInvariant();
}
@ -126,7 +126,6 @@ void InsetGraphicsParams::copy(InsetGraphicsParams const & igp)
{
filename = igp.filename;
display = igp.display;
inlineFigure = igp.inlineFigure;
subcaption = igp.subcaption;
subcaptionText = igp.subcaptionText;
keepAspectRatio = igp.keepAspectRatio;
@ -171,8 +170,8 @@ void InsetGraphicsParams::testInvariant() const
// The reason for this is that in latex there is a meaning for the
// different angles and they are not necessarliy interchangeable,
// it depends on the rotation origin.
lyx::Assert(rotateAngle < 360);
lyx::Assert(rotateAngle > -360);
lyx::Assert(rotateAngle < 360.0);
lyx::Assert(rotateAngle > -360.0);
}
@ -181,7 +180,6 @@ bool operator==(InsetGraphicsParams const & left,
{
if (left.filename == right.filename &&
left.display == right.display &&
left.inlineFigure == right.inlineFigure &&
left.subcaption == right.subcaption &&
left.subcaptionText == right.subcaptionText &&
left.keepAspectRatio == right.keepAspectRatio &&
@ -190,7 +188,7 @@ bool operator==(InsetGraphicsParams const & left,
left.heightResize == right.heightResize &&
left.heightSize == right.heightSize &&
left.rotateOrigin == right.rotateOrigin &&
left.rotateAngle == right.rotateAngle
lyx::float_equal(left.rotateAngle, right.rotateAngle, 0.001)
)
return true;
@ -237,10 +235,6 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
// Save the display type
os << " display " << displayTranslator.find(display) << '\n';
// Save the inline status
if (inlineFigure)
os << " inline";
// Save the subcaption status
if (subcaption)
os << " subcaption";
@ -252,7 +246,7 @@ void InsetGraphicsParams::Write(Buffer const * buf, ostream & os) const
writeResize(os, "height", heightResize, heightSize);
writeOrigin(os, rotateOrigin);
if (rotateAngle != 0)
if (lyx::float_equal(rotateAngle, 0.0, 0.001))
os << " rotateAngle " << rotateAngle << '\n';
}
@ -298,8 +292,6 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
string const type = lex.GetString();
display = displayTranslator.find(type);
} else if (token == "inline") {
inlineFigure = true;
} else if (token == "subcaption") {
subcaption = true;
} else if (token == "subcaptionText") {
@ -328,7 +320,7 @@ bool InsetGraphicsParams::Read(Buffer const * buf, LyXLex & lex,
readOrigin(this, token);
} else if (token == "rotateAngle") {
lex.next();
rotateAngle = lex.GetInteger();
rotateAngle = lex.GetFloat();
} else {
// If it's none of the above, its not ours.
return false;

View File

@ -44,9 +44,6 @@ struct InsetGraphicsParams
/// How to display the image
DisplayType display;
/// Is the figure inlined? (not in a paragraph of its own).
bool inlineFigure;
/// Do we have a subcaption?
bool subcaption;
@ -97,7 +94,7 @@ struct InsetGraphicsParams
/// Origin point of rotation
Origin rotateOrigin;
/// Rotation angle.
int rotateAngle;
float rotateAngle;
///
InsetGraphicsParams();
///

View File

@ -162,7 +162,7 @@ bool InsetInclude::display() const
}
string const InsetInclude::getScreenLabel() const
string const InsetInclude::getScreenLabel(Buffer const *) const
{
string temp;

View File

@ -119,7 +119,7 @@ public:
SigC::Signal0<void> hideDialog;
private:
/// get the text displayed on the button
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
/// is this a verbatim include ?
bool isVerbatim() const;
/// get the filename of the master buffer

View File

@ -16,7 +16,7 @@ InsetIndex::InsetIndex(InsetCommandParams const & p, bool)
{}
string const InsetIndex::getScreenLabel() const
string const InsetIndex::getScreenLabel(Buffer const *) const
{
return _("Idx");
}
@ -44,7 +44,7 @@ InsetPrintIndex::InsetPrintIndex(InsetCommandParams const & p, bool)
: InsetCommand(p)
{}
string const InsetPrintIndex::getScreenLabel() const
string const InsetPrintIndex::getScreenLabel(Buffer const *) const
{
return _("Index");
}

View File

@ -31,7 +31,7 @@ public:
return new InsetIndex(params(), same_id);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///
@ -64,7 +64,7 @@ public:
///
Inset::Code lyxCode() const;
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
};
#endif

View File

@ -27,7 +27,7 @@ public:
return new InsetLabel(params(), same_id);
}
///
string const getScreenLabel() const { return getContents(); }
string const getScreenLabel(Buffer const *) const { return getContents(); }
///
EDITABLE editable() const { return IS_EDITABLE; }
///

View File

@ -37,7 +37,7 @@ InsetParent::InsetParent(InsetCommandParams const & p, Buffer const & bf, bool)
}
string const InsetParent::getScreenLabel() const
string const InsetParent::getScreenLabel(Buffer const *) const
{
return string(_("Parent:")) + getContents();
}

View File

@ -33,7 +33,7 @@ public:
return new InsetParent(params(), buffer, same_id);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///

View File

@ -38,7 +38,7 @@ void InsetRef::edit(BufferView *, bool)
}
string const InsetRef::getScreenLabel() const
string const InsetRef::getScreenLabel(Buffer const *) const
{
string temp;
for (int i = 0; !types[i].latex_name.empty(); ++ i)

View File

@ -44,7 +44,7 @@ public:
return new InsetRef(params(), buffer, same_id);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///

View File

@ -14,7 +14,7 @@
using std::vector;
string const InsetTOC::getScreenLabel() const
string const InsetTOC::getScreenLabel(Buffer const *) const
{
string const cmdname(getCmdName());
@ -47,7 +47,7 @@ void InsetTOC::edit(BufferView * bv, bool)
int InsetTOC::ascii(Buffer const * buffer, std::ostream & os, int) const
{
os << getScreenLabel() << "\n\n";
os << getScreenLabel(buffer) << "\n\n";
string type;
string const cmdname = getCmdName();

View File

@ -30,7 +30,7 @@ public:
return new InsetTOC(params(), same_id);
}
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
void edit(BufferView * bv, int, int, unsigned int);
///

View File

@ -32,7 +32,7 @@ void InsetUrl::edit(BufferView * bv, bool)
}
string const InsetUrl::getScreenLabel() const
string const InsetUrl::getScreenLabel(Buffer const *) const
{
string temp;
if (getCmdName() == "url" )

View File

@ -35,7 +35,7 @@ public:
///
void validate(LaTeXFeatures &) const;
///
string const getScreenLabel() const;
string const getScreenLabel(Buffer const *) const;
///
EDITABLE editable() const { return IS_EDITABLE; }
///

View File

@ -1,3 +1,8 @@
2001-07-26 Baruch Even <baruch@lyx.org>
* lyxlib.h (float_equal): Added function to compare floats almost equal
(see function comment).
2001-07-13 Angus Leeming <a.leeming@ic.ac.uk>
Consistent use of Lsstream.h:

View File

@ -53,5 +53,23 @@ int atoi(string const & nstr);
string const tempName(string const & dir = string(),
string const & mask = string());
/** Returns true if var is approximately equal to number with allowed error
* of 'error'.
*
* Reason: A float can be very close to the number, yet still need not be
* exactly equal, you can have exp(-10) which is very close to zero but not
* zero. If you only need an approximate equality (you usually do), use this
* template.
*
* Usage: if (float_equal(var, number, 0.0001)) { }
*
* This will check if 'var' is approx. equal to 'number' with error of 1/1000
*/
inline bool float_equal(float var, float number, float error)
{
return (number - error <= var && var <= number + error);
}
} // namespace lyx
#endif /* LYX_LIB_H */