support for sidewaysfloats and fix for bug 1016 (float placement allows impossible settings).

BTW: floats are still broken (dialogs do not get updated). No idea where this bug sits.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8557 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2004-03-29 11:38:39 +00:00
parent 374e280417
commit 4072a82b6e
19 changed files with 263 additions and 25 deletions

View File

@ -1,6 +1,19 @@
LyX file-format changes
-----------------------
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* format incremented to 231.
* Support for sidewaysfigure/sidewaystable (rotating package).
insetfloat has now a param \sideways [true|false] (default is false).
The param should be erased on downwards conversion, if it was true,
the inset should be replaced by
\begin{sidewaysfigure} <content> \end{sidewaysfigure}
resp.
\begin{sidewaystable} <content> \end{sidewaystable}
i.e. ERT.
2004-02-23 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* format incremented to 230.

View File

@ -1,3 +1,7 @@
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* lyx2lyx: up the format to 231.
2004-03-26 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* lyxrevert_225.py (convert_frameless_box): fix minipage ERT output

View File

@ -40,7 +40,8 @@ opt.quiet = 0
format = re.compile(r"(\d)[\.,]?(\d\d)")
fileformat = re.compile(r"\\lyxformat\s*(\S*)")
lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226, 227, 228, 229, 230]
lst_ft = [210, 215, 216, 217, 218, 220, 221, 223, 224, 225, 226, 227, 228, 229,
230, 231]
def usage():
print """Usage: lyx2lyx [options] [file]

View File

@ -0,0 +1,29 @@
# This file is part of lyx2lyx
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2003 José Matos <jamatos@fep.up.pt>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
from parser_tools import find_token
def convert(header, body):
pass
if __name__ == "__main__":
pass

View File

@ -0,0 +1,29 @@
# This file is part of lyx2lyx
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2003 José Matos <jamatos@fep.up.pt>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
import sys
from parser_tools import find_token
def convert(header, body):
pass
if __name__ == "__main__":
pass

View File

@ -190,6 +190,8 @@ src/output_plaintext.C
src/paragraph.C
src/rowpainter.C
src/support/globbing.C
src/support/path_defines.C
src/tex2lyx/lengthcommon.C
src/text.C
src/text2.C
src/text3.C

View File

@ -1,3 +1,6 @@
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* buffer.C: increment file format to 231.
2004-03-28 Alfredo Braunstein <abraunst@lyx.org>
@ -221,6 +224,7 @@
* lyxrc.C (setDefaults, getDescription, output, read):
* lyxrc.h: remove ps_command
>>>>>>> 1.1856
2004-03-22 Angus Leeming <leeming@lyx.org>
* lyx_main.C (error_handler, init): remove handler for SIGPIPE.

View File

@ -130,7 +130,7 @@ extern BufferList bufferlist;
namespace {
const int LYX_FORMAT = 230;
const int LYX_FORMAT = 231;
} // namespace anon

View File

@ -1,3 +1,10 @@
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* QFloat.C:
* QFloatDialog.C:
* floatplacement.[Ch]: add support for sidewaysfloats
fix enabling of placement values (bug 1016)
2004-03-28 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added print dialog.

View File

@ -53,5 +53,5 @@ void QFloat::apply()
{
InsetFloatParams & params = controller().params();
params.placement = dialog_->floatFP->get(params.wide);
params.placement = dialog_->floatFP->get(params.wide, params.sideways);
}

View File

@ -37,6 +37,9 @@ QFloatDialog::QFloatDialog(QFloat * form)
// enable span columns checkbox
floatFP->useWide();
// enable sideways checkbox
floatFP->useSideways();
connect(floatFP, SIGNAL(changed()),
this, SLOT(change_adaptor()));
}

View File

@ -27,6 +27,7 @@ using std::string;
// FIXME: set disabled doesn't work properly
// should be fixed now (jspitzm)
FloatPlacement::FloatPlacement(QWidget * parent, char * name)
: QWidget(parent, name)
{
@ -42,6 +43,7 @@ FloatPlacement::FloatPlacement(QWidget * parent, char * name)
heredefinitelyCB = new QCheckBox(qt_("Here definitely"), options);
ignoreCB = new QCheckBox(qt_("&Ignore LaTeX rules"), options);
spanCB = 0;
sidewaysCB = 0;
layout->addWidget(defaultsCB);
@ -93,6 +95,16 @@ void FloatPlacement::useWide()
}
void FloatPlacement::useSideways()
{
sidewaysCB = new QCheckBox(qt_("&Rotate sideways"), this);
layout->addWidget(sidewaysCB);
setTabOrder(spanCB, sidewaysCB);
connect(sidewaysCB, SIGNAL(clicked()), this, SLOT(sidewaysClicked()));
connect(sidewaysCB, SIGNAL(toggled(bool)), this, SLOT(changedSlot()));
}
void FloatPlacement::changedSlot()
{
emit changed();
@ -148,16 +160,21 @@ void FloatPlacement::set(InsetFloatParams const & params)
if (params.wide) {
herepossiblyCB->setChecked(false);
heredefinitelyCB->setChecked(false);
bottomCB->setChecked(false);
}
spanCB->setChecked(params.wide);
sidewaysCB->setChecked(params.sideways);
sidewaysCB->setEnabled(params.type == "figure"
|| params.type == "table");
}
string const FloatPlacement::get(bool & wide) const
string const FloatPlacement::get(bool & wide, bool & sideways) const
{
wide = spanCB->isChecked();
sideways = sidewaysCB->isChecked();
return get();
}
@ -224,6 +241,7 @@ void FloatPlacement::spanClicked()
if (!defaultsCB->isChecked()) {
herepossiblyCB->setEnabled(!span);
heredefinitelyCB->setEnabled(!span);
bottomCB->setEnabled(!span);
}
if (!span)
@ -231,4 +249,30 @@ void FloatPlacement::spanClicked()
herepossiblyCB->setChecked(false);
heredefinitelyCB->setChecked(false);
bottomCB->setChecked(false);
}
void FloatPlacement::sidewaysClicked()
{
bool const sideways(sidewaysCB->isChecked());
bool const span(spanCB->isChecked());
bool const defaults(defaultsCB->isChecked());
bool ignore(topCB->isChecked());
ignore |= bottomCB->isChecked();
ignore |= pageCB->isChecked();
ignore |= herepossiblyCB->isChecked();
defaultsCB->setEnabled(!sideways);
topCB->setEnabled(!sideways && !defaults);
bottomCB->setEnabled(!sideways && !defaults);
pageCB->setEnabled(!sideways && !defaults);
spanCB->setEnabled(!sideways);
ignoreCB->setEnabled(!sideways && !defaults && ignore);
herepossiblyCB->setEnabled(!sideways && !defaults);
heredefinitelyCB->setEnabled(!sideways && !defaults);
if (!sideways && !defaults) {
herepossiblyCB->setEnabled(!span);
heredefinitelyCB->setEnabled(!span);
}
}

View File

@ -24,17 +24,19 @@ public:
FloatPlacement(QWidget * parent, char * name);
void useWide();
void useSideways();
void set(InsetFloatParams const & params);
void set(std::string const & placement);
std::string const get(bool & wide) const;
std::string const get(bool & wide, bool & sideways) const;
std::string const get() const;
public slots:
void tbhpClicked();
void heredefinitelyClicked();
void spanClicked();
void sidewaysClicked();
void changedSlot();
signals:
@ -45,6 +47,7 @@ private:
QCheckBox * defaultsCB;
QCheckBox * spanCB;
QCheckBox * sidewaysCB;
QCheckBox * ignoreCB;
QCheckBox * pageCB;
QCheckBox * heredefinitelyCB;

View File

@ -1,3 +1,10 @@
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* FormFloat.C:
* forms/form_float.fd:
add support for sidewaysfloats
fix enabling of placement values (bug 1016)
2004-03-28 Angus Leeming <leeming@lyx.org>
* Dialogs.C (build): added print dialog.

View File

@ -69,6 +69,7 @@ void FormFloat::build()
bcview().addReadOnly(dialog_->check_here);
bcview().addReadOnly(dialog_->check_force);
bcview().addReadOnly(dialog_->check_wide);
bcview().addReadOnly(dialog_->check_sideways);
placement_.init(dialog_->radio_default, DOCUMENT_DEFAULTS);
placement_.init(dialog_->radio_here_definitely, HERE_DEFINITELY);
@ -93,12 +94,15 @@ void FormFloat::build()
tooltips().init(dialog_->check_force, str);
str = _("Span float over the columns.");
tooltips().init(dialog_->check_wide, str);
str = _("Rotate the float sideways by 90 degs.");
tooltips().init(dialog_->check_sideways, str);
}
void FormFloat::apply()
{
bool const wide = fl_get_button(dialog_->check_wide);
bool const sideways = fl_get_button(dialog_->check_sideways);
string placement;
switch (placement_.get()) {
@ -152,6 +156,7 @@ void FormFloat::apply()
controller().params().placement = placement;
controller().params().wide = wide;
controller().params().sideways = sideways;
}
@ -159,6 +164,9 @@ void FormFloat::update()
{
string placement(controller().params().placement);
bool const wide = controller().params().wide;
bool const sideways = controller().params().sideways;
bool const sideways_possible = (controller().params().type == "figure"
|| controller().params().type == "table");
bool const here_definitely = contains(placement, 'H');
@ -182,13 +190,18 @@ void FormFloat::update()
fl_set_button(dialog_->check_page, page);
fl_set_button(dialog_->check_here, here);
fl_set_button(dialog_->check_wide, wide);
fl_set_button(dialog_->check_sideways, sideways);
setEnabled(dialog_->radio_here_definitely, !wide);
setEnabled(dialog_->check_force, alternatives);
setEnabled(dialog_->check_top, alternatives);
setEnabled(dialog_->check_bottom, alternatives);
setEnabled(dialog_->check_page, alternatives);
setEnabled(dialog_->check_here, alternatives && !wide);
setEnabled(dialog_->radio_here_definitely, !wide && !sideways);
setEnabled(dialog_->check_force, alternatives && !sideways);
setEnabled(dialog_->check_top, alternatives && !sideways);
setEnabled(dialog_->check_bottom, alternatives && !sideways);
setEnabled(dialog_->check_page, alternatives && !sideways);
setEnabled(dialog_->check_here, alternatives && !wide && !sideways);
setEnabled(dialog_->check_wide, !sideways);
setEnabled(dialog_->radio_default, !sideways);
setEnabled(dialog_->radio_alternatives, !sideways);
setEnabled(dialog_->check_sideways, sideways_possible);
}
@ -196,16 +209,17 @@ ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
{
bool const alternatives = placement_.get() == ALTERNATIVES;
bool const wide = fl_get_button(dialog_->check_wide);
bool const sideways = fl_get_button(dialog_->check_sideways);
if (ob == dialog_->radio_default ||
ob == dialog_->radio_here_definitely ||
ob == dialog_->radio_alternatives) {
// enable check buttons only for Alternatives
setEnabled(dialog_->check_top, alternatives);
setEnabled(dialog_->check_bottom, alternatives);
setEnabled(dialog_->check_page, alternatives);
// wide float doesn't allow 'here' placement
// wide float doesn't allow 'here' or 'bottom' placement
setEnabled(dialog_->check_here, alternatives && !wide);
setEnabled(dialog_->check_bottom, alternatives && !wide);
} else if (ob == dialog_->check_wide) {
if (wide && placement_.get() == HERE_DEFINITELY) {
@ -215,11 +229,23 @@ ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
}
setEnabled(dialog_->check_here, alternatives && !wide);
setEnabled(dialog_->radio_here_definitely, !wide);
setEnabled(dialog_->check_bottom, alternatives && !wide);
} else if (ob == dialog_->check_sideways) {
setEnabled(dialog_->radio_default, !sideways);
setEnabled(dialog_->radio_alternatives, !sideways);
setEnabled(dialog_->radio_here_definitely, !wide && !sideways);
setEnabled(dialog_->check_top, alternatives && !sideways);
setEnabled(dialog_->check_bottom,
alternatives && !wide && !sideways);
setEnabled(dialog_->check_page, alternatives && !sideways);
setEnabled(dialog_->check_here, alternatives && !wide && !sideways);
setEnabled(dialog_->check_wide, !sideways);
}
// enable force button, if Alternatives is selected and at least
// one of its check buttons
bool const enable_force = alternatives &&
bool const enable_force = alternatives && !sideways &&
(fl_get_button(dialog_->check_top) ||
fl_get_button(dialog_->check_bottom) ||
fl_get_button(dialog_->check_page) ||

View File

@ -10,13 +10,13 @@ SnapGrid: 5
=============== FORM ===============
Name: form_float
Width: 395
Height: 260
Number of Objects: 17
Height: 290
Number of Objects: 18
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 395 260
box: 0 0 395 290
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -124,7 +124,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 5 230 90 25
box: 5 260 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -142,7 +142,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 110 230 90 25
box: 110 260 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -160,7 +160,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 205 230 90 25
box: 205 260 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -178,7 +178,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 300 230 90 25
box: 300 260 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -232,7 +232,7 @@ argument: 0
--------------------
class: FL_BEGIN_GROUP
type: 0
box: 0 10 10 0
box: 0 0 0 0
boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
@ -320,5 +320,23 @@ name:
callback:
argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 5 225 385 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Rotate sideways|#o
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: check_sideways
callback: C_FormDialogView_InputCB
argument: 0
==============================
create_the_forms

View File

@ -1,3 +1,7 @@
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetfloat.[Ch]: add param \sideways {true|false}
(support for sideways floats from rotating.sty).
2004-03-28 Alfredo Braunstein <abraunst@lyx.org>

View File

@ -162,7 +162,9 @@ void InsetFloat::priv_dispatch(LCursor & cur, FuncRequest & cmd)
InsetFloatMailer::string2params(cmd.argument, params);
params_.placement = params.placement;
params_.wide = params.wide;
params_.sideways = params.sideways;
wide(params_.wide, cur.bv().buffer()->params());
sideways(params_.sideways, cur.bv().buffer()->params());
cur.bv().update();
break;
}
@ -191,6 +193,11 @@ void InsetFloatParams::write(ostream & os) const
os << "wide true\n";
else
os << "wide false\n";
if (sideways)
os << "sideways true\n";
else
os << "sideways false\n";
}
@ -218,6 +225,18 @@ void InsetFloatParams::read(LyXLex & lex)
// take countermeasures
lex.pushToken(token);
}
lex.next();
token = lex.getString();
if (token == "sideways") {
lex.next();
string const tmptoken = lex.getString();
sideways = (tmptoken == "true");
} else {
lyxerr << "InsetFloat::Read:: Missing sideways!"
<< endl;
// take countermeasures
lex.pushToken(token);
}
}
}
@ -233,6 +252,7 @@ void InsetFloat::read(Buffer const & buf, LyXLex & lex)
{
params_.read(lex);
wide(params_.wide, buf.params());
sideways(params_.sideways, buf.params());
InsetCollapsable::read(buf, lex);
}
@ -243,6 +263,9 @@ void InsetFloat::validate(LaTeXFeatures & features) const
features.require("float");
}
if (params_.sideways)
features.require("rotating");
features.useFloat(params_.type);
InsetCollapsable::validate(features);
}
@ -264,7 +287,13 @@ int InsetFloat::latex(Buffer const & buf, ostream & os,
OutputParams const & runparams) const
{
FloatList const & floats = buf.params().getLyXTextClass().floats();
string const tmptype = (params_.wide ? params_.type + "*" : params_.type);
string tmptype = (params_.wide ? params_.type + "*" : params_.type);
if (params_.sideways) {
if (params_.type == "table")
tmptype = "sidewaystable";
else if (params_.type == "figure")
tmptype = "sidewaysfigure";
}
// Figure out the float placement to use.
// From lowest to highest:
// - float default placement
@ -287,7 +316,8 @@ int InsetFloat::latex(Buffer const & buf, ostream & os,
// when the current output line is empty.
os << "%\n\\begin{" << tmptype << '}';
// We only output placement if different from the def_placement.
if (!placement.empty()) {
// sidewaysfloats always use their own page
if (!placement.empty() && !params_.sideways) {
os << '[' << placement << ']';
}
os << '\n';
@ -377,6 +407,16 @@ void InsetFloat::wide(bool w, BufferParams const & bp)
}
void InsetFloat::sideways(bool s, BufferParams const & bp)
{
params_.sideways = s;
string lab = _("float: ") + floatname(params_.type, bp);
if (params_.sideways)
lab += _(" (sideways)");
setLabel(lab);
}
void InsetFloat::addToToc(lyx::toc::TocList & toclist, Buffer const & buf) const
{
ParConstIterator pit(*this, 0);

View File

@ -19,7 +19,7 @@
struct InsetFloatParams {
///
InsetFloatParams() : wide(false) {}
InsetFloatParams() : wide(false), sideways(false) {}
///
void write(std::ostream & os) const;
///
@ -30,6 +30,8 @@ struct InsetFloatParams {
std::string placement;
///
bool wide;
///
bool sideways;
};
@ -72,6 +74,8 @@ public:
///
void wide(bool w, BufferParams const &);
///
void sideways(bool s, BufferParams const &);
///
void addToToc(lyx::toc::TocList &, Buffer const &) const;
///
bool showInsetDialog(BufferView *) const;