merge booktabs branch

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14319 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-07-03 19:13:56 +00:00
parent d17833b8d0
commit 0c0c43b8eb
32 changed files with 2976 additions and 1302 deletions

View File

@ -1,6 +1,19 @@
LyX file-format changes
-----------------------
2006-07-03 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* format incremented to 248: Basic booktabs support
The <features> tag has a new switch: booktabs="true|false".
An absent switch is equivalent to booktabs="false".
Horizontal lines are set with the booktabs package if this switch
is on.
The <row> tag of tabulars has the following new attributes:
topspace, bottomspace and interlinespace. All take a LyXLength
as value, or the special keyword "default".
2006-06-10 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* format incremented to 247. The Grand Font Interface Rewrite.

View File

@ -614,6 +614,10 @@
* configure.m4: check for more viewers and editors
2004-11-11 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* chkconfig.ltx: check package booktabs
2004-11-05 Bennett Helm <bennett.helm@fandm.edu>
* bind/mac.bind: use <cmd>-Tab and <cmd>-backtab as shortcuts for

View File

@ -219,6 +219,7 @@
\TestPackage{array}
\TestPackage{babel}
\TestPackage{bibtopic}
\TestPackage{booktabs}
\TestPackage{color} % this one should be there if graphics.sty is there.
\TestPackage{dvipost}
\TestPackage{fancybox}

View File

@ -202,6 +202,10 @@
* Customization.lyx: document OptionalArgs
2004-11-11 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* LaTeXConfig.lyx.in, LyXConfig.lyx.in: add booktabs package
2004-11-04 Christian Ridderström <chr@home.se>
* LaTeXConfig.lyx.in: remove "supported" and "other" from CTAN

View File

@ -2447,6 +2447,31 @@ longtable
is needed by LyX to be able to output correctly multipage tables.
\end_layout
\begin_layout Subsection
booktabs
\end_layout
\begin_layout Description
Found: @chk_booktabs@
\end_layout
\begin_layout Description
CTAN:
\family typewriter
macros/latex/contrib/booktabs/
\end_layout
\begin_layout Description
Notes: The package
\family sans
booktabs
\family default
is needed by LyX to be able to output correctly formal tables.
\end_layout
\begin_layout Subsection
varioref
\end_layout

View File

@ -1135,6 +1135,24 @@ Table of contents
if you want to use non-English quotes.
\layout Subsection
booktabs
\layout Description
Found: @chk_booktabs@
\layout Description
CTAN:
\family typewriter
macros/latex/contrib/booktabs/
\layout Description
Notes: The package
\family sans
booktabs
\family default
is needed by LyX to be able to output correctly formal tables.
\layout Subsection
color
\layout Description

View File

@ -1,3 +1,9 @@
2006-03-14 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* lyx_1_5.py: new file, handle new format 246
* LyX.py: handle new format 246
* lyx_1_4.py (revert_booktabs): move to lyx_1_5.py
2006-03-06 José Matos <jamatos@lyx.org>
* lyx_1_4.py (remove_paperpackage): Only reset the papersize for
@ -332,6 +338,11 @@
* lyx_1_4.py: unify the call convention of convertion
functions. Now they all accept a file.
2004-12-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* lyx_1_4.py, LyX.py: handle new format 239
* lyx_1_4.py (revert_booktabs): move to 239 -> 238 conversion
2004-12-03 José Matos <jamatos@lyx.org>
* LyX.py: format up to 238.
@ -351,6 +362,11 @@
* lyx_1_2.py (convert): rename opt to file, as in all other files.
2004-12-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* lyx_1_4.py, LyX.py: handle new format 238
* lyx_1_4.py (revert_booktabs): new
2004-10-28 José Matos <jamatos@lyx.org>
* LyX.pm: add internal documentation.

View File

@ -47,9 +47,9 @@ format_relation = [("0_10", [210], ["0.10.7","0.10"]),
("1_1_6", [217], ["1.1.6","1.1.6fix1","1.1.6fix2","1.1"]),
("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3"]),
("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3"]),
("1_4", range(222,246), ["1.4.0", "1.4.1", "1.4.2svn"]),
("1_5", range(246,248), ["1.5.0svn"])]
("1_5", range(246,249), ["1.5.0svn","1.5"])]
def formats_list():

View File

@ -1,6 +1,7 @@
# This file is part of lyx2lyx
# -*- coding: iso-8859-1 -*-
# Copyright (C) 2006 José Matos <jamatos@lyx.org>
# Copyright (C) 2004-2006 Georg Baum <Georg.Baum@post.rwth-aachen.de>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@ -16,7 +17,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
from parser_tools import find_token_exact, find_tokens, get_value
import re
from parser_tools import find_token, find_token_exact, find_tokens, find_end_of_inset, get_value
from string import replace
##
# Notes: Framed/Shaded
@ -170,16 +174,46 @@ def revert_font_settings(file):
file.warning("Ignoring `\\font_osf = true'")
def revert_booktabs(file):
# we just remove the booktabs flag, everything else will become a mess.
re_row = re.compile(r'^<row.*space="[^"]+".*>$')
re_tspace = re.compile(r'\s+topspace="[^"]+"')
re_bspace = re.compile(r'\s+bottomspace="[^"]+"')
re_ispace = re.compile(r'\s+interlinespace="[^"]+"')
i = 0
while 1:
i = find_token(file.body, "\\begin_inset Tabular", i)
if i == -1:
return
j = find_end_of_inset(file.body, i + 1)
if j == -1:
file.warning("Malformed LyX file: Could not find end of tabular.")
continue
for k in range(i, j):
if re.search('^<features.* booktabs="true".*>$', file.body[k]):
file.warning("Converting 'booktabs' table to normal table.")
file.body[k] = replace(file.body[k], ' booktabs="true"', '')
if re.search(re_row, file.body[k]):
file.warning("Removing extra row space.")
file.body[k] = re_tspace.sub('', file.body[k])
file.body[k] = re_bspace.sub('', file.body[k])
file.body[k] = re_ispace.sub('', file.body[k])
i = i + 1
##
# Conversion hub
#
convert = [[246, []],
[247, [convert_font_settings]]]
[247, [convert_font_settings]],
[248, []]]
revert = [[246, [revert_font_settings]],
revert = [[247, [revert_booktabs]],
[246, [revert_font_settings]],
[245, [revert_framed]]]
if __name__ == "__main__":
pass

View File

@ -38,6 +38,10 @@
* MenuBackend.h (clear): new method.
2006-03-14 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* buffer.C: format up to 246.
2006-03-13 Martin Vermeer <martin.vermeer@hut.fi>
* rowpainter.C (paintChangeBar): fix painting of change bar with
@ -2247,6 +2251,10 @@
* main.C: (main): no longer pass pointers to os::init.
2004-12-06 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* buffer.C: format up to 239.
2004-12-06 Alfredo Braunstein <abraunst@lyx.org>
* undo.C (textUndoOrRedo): simplify logic, fix a crash
@ -2493,6 +2501,16 @@
* vspace.C: fix off-by-one-error, related to fix #1682
2004-11-11 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* buffer.C: format up to 238.
2004-11-11 Edwin Leuven
* LaTeXFeatures.C: add booktabs package
* tabular.[Ch] (use_booktabs, setBookTabs, useBookTabs): new members,
use them in several places
2004-11-11 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* lengthcommon.C: a more general fix for bug 1682

View File

@ -241,6 +241,7 @@ char const * simplefeatures[] = {
"varioref",
"prettyref",
"float",
"booktabs",
"dvipost",
"fancybox",
"calc",

View File

@ -146,7 +146,7 @@ extern BufferList bufferlist;
namespace {
int const LYX_FORMAT = 247;
int const LYX_FORMAT = 248;
} // namespace anon

View File

@ -267,6 +267,10 @@
* ControlTabular.C (initialiseParams): Compute the active cell
2004-11-11 Edwin Leuven
* ControlTabular.[Ch] (booktabs): new
2004-11-09 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* ControlInclude.C (browse): Use GetExtension() instead of

View File

@ -222,6 +222,15 @@ void ControlTabular::valign(ControlTabular::VALIGN v)
}
void ControlTabular::booktabs(bool yes)
{
if (yes)
set(LyXTabular::SET_BOOKTABS);
else
set(LyXTabular::UNSET_BOOKTABS);
}
void ControlTabular::longTabular(bool yes)
{
if (yes)

View File

@ -69,6 +69,8 @@ public:
void valign(VALIGN h);
void booktabs(bool yes);
void longTabular(bool yes);
private:

View File

@ -31,6 +31,10 @@ using std::string;
using std::vector;
#ifdef WITH_WARNINGS
#warning Implement booktabs settings
#endif
namespace lyx {
namespace frontend {

View File

@ -697,6 +697,13 @@
* QPrefsDialog.h: include LColor.h to satisfy concept checks.
* lcolorcache.h: ditto
2004-11-16 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* QTabular.C (update_borders): disable vertical rules if using
booktabs
* QTabularDialog.C (booktabs_clicked): add a missing call to
form_->changed() and update the borders
2004-11-15 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QtView.C (hasFocus): new method
@ -704,6 +711,12 @@
* QLPopupMenu.C (populate): remove a Qt/Mac hack to disable some
menu entries when the main window does not have focus
2004-11-11 Edwin Leuven
* QTabular.C (build_dialog, update_contents): handle booktabsCB
* QTabularDialog.[Ch] (booktabs_clicked): new
* ui/QTabularDialogBase.ui (booktabsCB): new checkbox
2004-11-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* QLToolbar.C (selected): use layoutSelected

View File

@ -28,6 +28,7 @@
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include "qsetborder.h"
using std::string;
@ -60,6 +61,8 @@ void QTabular::build_dialog()
bcview().addReadOnly(dialog_->borderSetPB);
bcview().addReadOnly(dialog_->borderUnsetPB);
bcview().addReadOnly(dialog_->borders);
bcview().addReadOnly(dialog_->booktabsRB);
bcview().addReadOnly(dialog_->borderDefaultRB);
bcview().addReadOnly(dialog_->longTabularCB);
bcview().addReadOnly(dialog_->headerStatusCB);
bcview().addReadOnly(dialog_->headerBorderAboveCB);
@ -76,10 +79,25 @@ void QTabular::build_dialog()
bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
bcview().addReadOnly(dialog_->newpageCB);
bcview().addReadOnly(dialog_->topspaceED);
bcview().addReadOnly(dialog_->topspaceUnit);
bcview().addReadOnly(dialog_->topspaceCO);
bcview().addReadOnly(dialog_->bottomspaceED);
bcview().addReadOnly(dialog_->bottomspaceUnit);
bcview().addReadOnly(dialog_->bottomspaceCO);
bcview().addReadOnly(dialog_->interlinespaceED);
bcview().addReadOnly(dialog_->interlinespaceUnit);
bcview().addReadOnly(dialog_->interlinespaceCO);
// initialize the length validator
addCheckedLineEdit(bcview(), dialog_->widthED,
dialog_->fixedWidthColLA);
addCheckedLineEdit(bcview(), dialog_->topspaceED,
dialog_->topspaceLA);
addCheckedLineEdit(bcview(), dialog_->bottomspaceED,
dialog_->bottomspaceLA);
addCheckedLineEdit(bcview(), dialog_->interlinespaceED,
dialog_->interlinespaceLA);
}
@ -94,10 +112,11 @@ void QTabular::update_borders()
LyXTabular const & tabular = controller().tabular();
LyXTabular::idx_type const cell = controller().getActiveCell();
bool const isMulticolumnCell = tabular.isMultiColumn(cell);
bool const useBookTabs = tabular.useBookTabs();
if (!isMulticolumnCell) {
dialog_->borders->setLeftEnabled(true);
dialog_->borders->setRightEnabled(true);
dialog_->borders->setLeftEnabled(!useBookTabs);
dialog_->borders->setRightEnabled(!useBookTabs);
dialog_->borders->setTop(tabular.topLine(cell, true));
dialog_->borders->setBottom(tabular.bottomLine(cell, true));
dialog_->borders->setLeft(tabular.leftLine(cell, true));
@ -109,18 +128,18 @@ void QTabular::update_borders()
dialog_->borders->setTop(tabular.topLine(cell));
dialog_->borders->setBottom(tabular.bottomLine(cell));
// pay attention to left/right lines: they are only allowed
// to set if we are in first/last cell of row or if the left/right
// cell is also a multicolumn.
// pay attention to left/right lines: they are only allowed to set
// if we don't use booktabs and if we are in first/last cell of row
// or if the left/right cell is also a multicolumn.
if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
dialog_->borders->setLeftEnabled(true);
dialog_->borders->setLeftEnabled(!useBookTabs);
dialog_->borders->setLeft(tabular.leftLine(cell));
} else {
dialog_->borders->setLeft(false);
dialog_->borders->setLeftEnabled(false);
}
if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
dialog_->borders->setRightEnabled(true);
dialog_->borders->setRightEnabled(!useBookTabs);
dialog_->borders->setRight(tabular.rightLine(cell));
} else {
dialog_->borders->setRight(false);
@ -151,6 +170,10 @@ void QTabular::update_contents()
dialog_->longTabularCB->setChecked(tabular.isLongTabular());
dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
dialog_->booktabsRB->setChecked(tabular.useBookTabs());
update_borders();
LyXLength pwidth;
@ -232,6 +255,60 @@ void QTabular::update_contents()
dialog_->hAlignCB->setEnabled(true);
dialog_->vAlignCB->setEnabled(!pwidth.zero());
if (tabular.row_info[row].top_space.empty()
&& !tabular.row_info[row].top_space_default) {
dialog_->topspaceCO->setCurrentItem(0);
} else if (tabular.row_info[row].top_space_default) {
dialog_->topspaceCO->setCurrentItem(1);
} else {
dialog_->topspaceCO->setCurrentItem(2);
lengthToWidgets(dialog_->topspaceED,
dialog_->topspaceUnit,
tabular.row_info[row].top_space.asString(),
default_unit);
}
dialog_->topspaceED->setEnabled(!isReadonly
&& (dialog_->topspaceCO->currentItem() == 2));
dialog_->topspaceUnit->setEnabled(!isReadonly
&& (dialog_->topspaceCO->currentItem() == 2));
dialog_->topspaceCO->setEnabled(!isReadonly);
if (tabular.row_info[row].bottom_space.empty()
&& !tabular.row_info[row].bottom_space_default) {
dialog_->bottomspaceCO->setCurrentItem(0);
} else if (tabular.row_info[row].bottom_space_default) {
dialog_->bottomspaceCO->setCurrentItem(1);
} else {
dialog_->bottomspaceCO->setCurrentItem(2);
lengthToWidgets(dialog_->bottomspaceED,
dialog_->bottomspaceUnit,
tabular.row_info[row].bottom_space.asString(),
default_unit);
}
dialog_->bottomspaceED->setEnabled(!isReadonly
&& (dialog_->bottomspaceCO->currentItem() == 2));
dialog_->bottomspaceUnit->setEnabled(!isReadonly
&& (dialog_->bottomspaceCO->currentItem() == 2));
dialog_->bottomspaceCO->setEnabled(!isReadonly);
if (tabular.row_info[row].interline_space.empty()
&& !tabular.row_info[row].interline_space_default) {
dialog_->interlinespaceCO->setCurrentItem(0);
} else if (tabular.row_info[row].interline_space_default) {
dialog_->interlinespaceCO->setCurrentItem(1);
} else {
dialog_->interlinespaceCO->setCurrentItem(2);
lengthToWidgets(dialog_->interlinespaceED,
dialog_->interlinespaceUnit,
tabular.row_info[row].interline_space.asString(),
default_unit);
}
dialog_->interlinespaceED->setEnabled(!isReadonly
&& (dialog_->interlinespaceCO->currentItem() == 2));
dialog_->interlinespaceUnit->setEnabled(!isReadonly
&& (dialog_->interlinespaceCO->currentItem() == 2));
dialog_->interlinespaceCO->setEnabled(!isReadonly);
if (!tabular.isLongTabular()) {
dialog_->headerStatusCB->setChecked(false);
dialog_->headerBorderAboveCB->setChecked(false);
@ -369,6 +446,48 @@ void QTabular::closeGUI()
else
controller().set(LyXTabular::SET_PWIDTH, width);
}
switch (dialog_->topspaceCO->currentItem()) {
case 0:
controller().set(LyXTabular::SET_TOP_SPACE, "");
break;
case 1:
controller().set(LyXTabular::SET_TOP_SPACE, "default");
break;
case 2:
controller().set(LyXTabular::SET_TOP_SPACE,
widgetsToLength(dialog_->topspaceED,
dialog_->topspaceUnit));
break;
}
switch (dialog_->bottomspaceCO->currentItem()) {
case 0:
controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
break;
case 1:
controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
break;
case 2:
controller().set(LyXTabular::SET_BOTTOM_SPACE,
widgetsToLength(dialog_->bottomspaceED,
dialog_->bottomspaceUnit));
break;
}
switch (dialog_->interlinespaceCO->currentItem()) {
case 0:
controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
break;
case 1:
controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
break;
case 2:
controller().set(LyXTabular::SET_INTERLINE_SPACE,
widgetsToLength(dialog_->interlinespaceED,
dialog_->interlinespaceUnit));
break;
}
}
} // namespace frontend

View File

@ -14,13 +14,16 @@
#include "QTabularDialog.h"
#include "QTabular.h"
#include "lengthcombo.h"
#include "validators.h"
#include "qt_helpers.h"
#include "controllers/ButtonController.h"
#include "controllers/ControlTabular.h"
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include <qlineedit.h>
using std::string;
@ -37,6 +40,9 @@ QTabularDialog::QTabularDialog(QTabular * form)
form, SLOT(slotClose()));
widthED->setValidator(unsignedLengthValidator(widthED));
topspaceED->setValidator(new LengthValidator(topspaceED));
bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
}
@ -119,6 +125,96 @@ void QTabularDialog::width_changed()
}
void QTabularDialog::topspace_changed()
{
switch(topspaceCO->currentItem()) {
case 0: {
form_->controller().set(LyXTabular::SET_TOP_SPACE, "");
topspaceED->setEnabled(false);
topspaceUnit->setEnabled(false);
break;
}
case 1: {
form_->controller().set(LyXTabular::SET_TOP_SPACE, "default");
topspaceED->setEnabled(false);
topspaceUnit->setEnabled(false);
break;
}
case 2: {
if (!topspaceED->text().isEmpty())
form_->controller().set(LyXTabular::SET_TOP_SPACE,
widgetsToLength(topspaceED, topspaceUnit));
if (!form_->bc().bp().isReadOnly()) {
topspaceED->setEnabled(true);
topspaceUnit->setEnabled(true);
}
break;
}
}
form_->changed();
}
void QTabularDialog::bottomspace_changed()
{
switch(bottomspaceCO->currentItem()) {
case 0: {
form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
bottomspaceED->setEnabled(false);
bottomspaceUnit->setEnabled(false);
break;
}
case 1: {
form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
bottomspaceED->setEnabled(false);
bottomspaceUnit->setEnabled(false);
break;
}
case 2: {
if (!bottomspaceED->text().isEmpty())
form_->controller().set(LyXTabular::SET_BOTTOM_SPACE,
widgetsToLength(bottomspaceED, bottomspaceUnit));
if (!form_->bc().bp().isReadOnly()) {
bottomspaceED->setEnabled(true);
bottomspaceUnit->setEnabled(true);
}
break;
}
}
form_->changed();
}
void QTabularDialog::interlinespace_changed()
{
switch(interlinespaceCO->currentItem()) {
case 0: {
form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
interlinespaceED->setEnabled(false);
interlinespaceUnit->setEnabled(false);
break;
}
case 1: {
form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
interlinespaceED->setEnabled(false);
interlinespaceUnit->setEnabled(false);
break;
}
case 2: {
if (!interlinespaceED->text().isEmpty())
form_->controller().set(LyXTabular::SET_INTERLINE_SPACE,
widgetsToLength(interlinespaceED, interlinespaceUnit));
if (!form_->bc().bp().isReadOnly()) {
interlinespaceED->setEnabled(true);
interlinespaceUnit->setEnabled(true);
}
break;
}
}
form_->changed();
}
void QTabularDialog::multicolumn_clicked()
{
form_->controller().toggleMultiColumn();
@ -344,5 +440,16 @@ void QTabularDialog::ltLastFooterEmpty_clicked()
form_->changed();
}
void QTabularDialog::booktabs_clicked()
{
if (booktabsRB->isChecked())
form_->controller().set(LyXTabular::SET_BOOKTABS);
else
form_->controller().set(LyXTabular::UNSET_BOOKTABS);
form_->update_borders();
form_->changed();
}
} // namespace frontend
} // namespace lyx

View File

@ -43,6 +43,9 @@ protected slots:
virtual void vAlign_changed(int align);
virtual void specialAlignment_changed();
virtual void width_changed();
virtual void topspace_changed();
virtual void bottomspace_changed();
virtual void interlinespace_changed();
virtual void longTabular();
virtual void ltNewpage_clicked();
virtual void ltHeaderStatus_clicked();
@ -59,6 +62,7 @@ protected slots:
virtual void ltLastFooterBorderAbove_clicked();
virtual void ltLastFooterBorderBelow_clicked();
virtual void ltLastFooterEmpty_clicked();
virtual void booktabs_clicked();
protected:
virtual void closeEvent(QCloseEvent * e);

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
#include <qcheckbox.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
#include "qsetborder.h"
using std::string;
@ -49,6 +50,18 @@ void QTabular::build_dialog()
bcview().setCancel(dialog_->closePB);
bcview().addReadOnly(dialog_->topspaceED);
bcview().addReadOnly(dialog_->topspaceUnit);
bcview().addReadOnly(dialog_->topspaceCO);
bcview().addReadOnly(dialog_->bottomspaceED);
bcview().addReadOnly(dialog_->bottomspaceUnit);
bcview().addReadOnly(dialog_->bottomspaceCO);
bcview().addReadOnly(dialog_->interlinespaceED);
bcview().addReadOnly(dialog_->interlinespaceUnit);
bcview().addReadOnly(dialog_->interlinespaceCO);
bcview().addReadOnly(dialog_->borderDefaultRB);
bcview().addReadOnly(dialog_->booktabsRB);
bcview().addReadOnly(dialog_->multicolumnCB);
bcview().addReadOnly(dialog_->rotateCellCB);
bcview().addReadOnly(dialog_->rotateTabularCB);
@ -80,6 +93,12 @@ void QTabular::build_dialog()
// initialize the length validator
addCheckedLineEdit(bcview(), dialog_->widthED,
dialog_->fixedWidthColLA);
addCheckedLineEdit(bcview(), dialog_->topspaceED,
dialog_->topspaceLA);
addCheckedLineEdit(bcview(), dialog_->bottomspaceED,
dialog_->bottomspaceLA);
addCheckedLineEdit(bcview(), dialog_->interlinespaceED,
dialog_->interlinespaceLA);
}
@ -171,6 +190,63 @@ void QTabular::update_contents()
LyXLength::UNIT default_unit = controller().useMetricUnits() ? LyXLength::CM : LyXLength::IN;
dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
dialog_->booktabsRB->setChecked(tabular.useBookTabs());
if (tabular.row_info[row].top_space.empty()
&& !tabular.row_info[row].top_space_default) {
dialog_->topspaceCO->setCurrentItem(0);
} else if (tabular.row_info[row].top_space_default) {
dialog_->topspaceCO->setCurrentItem(1);
} else {
dialog_->topspaceCO->setCurrentItem(2);
lengthToWidgets(dialog_->topspaceED,
dialog_->topspaceUnit,
tabular.row_info[row].top_space.asString(),
default_unit);
}
dialog_->topspaceED->setEnabled(!isReadonly
&& (dialog_->topspaceCO->currentItem() == 2));
dialog_->topspaceUnit->setEnabled(!isReadonly
&& (dialog_->topspaceCO->currentItem() == 2));
dialog_->topspaceCO->setEnabled(!isReadonly);
if (tabular.row_info[row].bottom_space.empty()
&& !tabular.row_info[row].bottom_space_default) {
dialog_->bottomspaceCO->setCurrentItem(0);
} else if (tabular.row_info[row].bottom_space_default) {
dialog_->bottomspaceCO->setCurrentItem(1);
} else {
dialog_->bottomspaceCO->setCurrentItem(2);
lengthToWidgets(dialog_->bottomspaceED,
dialog_->bottomspaceUnit,
tabular.row_info[row].bottom_space.asString(),
default_unit);
}
dialog_->bottomspaceED->setEnabled(!isReadonly
&& (dialog_->bottomspaceCO->currentItem() == 2));
dialog_->bottomspaceUnit->setEnabled(!isReadonly
&& (dialog_->bottomspaceCO->currentItem() == 2));
dialog_->bottomspaceCO->setEnabled(!isReadonly);
if (tabular.row_info[row].interline_space.empty()
&& !tabular.row_info[row].interline_space_default) {
dialog_->interlinespaceCO->setCurrentItem(0);
} else if (tabular.row_info[row].interline_space_default) {
dialog_->interlinespaceCO->setCurrentItem(1);
} else {
dialog_->interlinespaceCO->setCurrentItem(2);
lengthToWidgets(dialog_->interlinespaceED,
dialog_->interlinespaceUnit,
tabular.row_info[row].interline_space.asString(),
default_unit);
}
dialog_->interlinespaceED->setEnabled(!isReadonly
&& (dialog_->interlinespaceCO->currentItem() == 2));
dialog_->interlinespaceUnit->setEnabled(!isReadonly
&& (dialog_->interlinespaceCO->currentItem() == 2));
dialog_->interlinespaceCO->setEnabled(!isReadonly);
string colwidth;
if (!pwidth.zero())
colwidth = pwidth.asString();
@ -369,6 +445,50 @@ void QTabular::closeGUI()
else
controller().set(LyXTabular::SET_PWIDTH, width);
}
/* DO WE NEED THIS?
switch (dialog_->topspaceCO->currentItem()) {
case 0:
controller().set(LyXTabular::SET_TOP_SPACE, "");
break;
case 1:
controller().set(LyXTabular::SET_TOP_SPACE, "default");
break;
case 2:
controller().set(LyXTabular::SET_TOP_SPACE,
widgetsToLength(dialog_->topspaceED,
dialog_->topspaceUnit));
break;
}
switch (dialog_->bottomspaceCO->currentItem()) {
case 0:
controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
break;
case 1:
controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
break;
case 2:
controller().set(LyXTabular::SET_BOTTOM_SPACE,
widgetsToLength(dialog_->bottomspaceED,
dialog_->bottomspaceUnit));
break;
}
switch (dialog_->interlinespaceCO->currentItem()) {
case 0:
controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
break;
case 1:
controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
break;
case 2:
controller().set(LyXTabular::SET_INTERLINE_SPACE,
widgetsToLength(dialog_->interlinespaceED,
dialog_->interlinespaceUnit));
break;
}
*/
}
} // namespace frontend

View File

@ -17,11 +17,13 @@
#include "validators.h"
#include "qt_helpers.h"
#include "controllers/ButtonController.h"
#include "controllers/ControlTabular.h"
#include <QCloseEvent>
#include <QCheckBox>
#include <QPushButton>
#include <QRadioButton>
#include <QLineEdit>
using std::string;
@ -36,40 +38,59 @@ QTabularDialog::QTabularDialog(QTabular * form)
setupUi(this);
widthED->setValidator(unsignedLengthValidator(widthED));
topspaceED->setValidator(new LengthValidator(topspaceED));
bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
connect( borderSetPB, SIGNAL( clicked() ), this, SLOT( borderSet_clicked() ) );
connect( borderUnsetPB, SIGNAL( clicked() ), this, SLOT( borderUnset_clicked() ) );
connect( longTabularCB, SIGNAL( toggled(bool) ), longtableGB, SLOT( setEnabled(bool) ) );
connect( longTabularCB, SIGNAL( toggled(bool) ), newpageCB, SLOT( setEnabled(bool) ) );
connect( hAlignCB, SIGNAL( activated(int) ), this, SLOT( hAlign_changed(int) ) );
connect( vAlignCB, SIGNAL( activated(int) ), this, SLOT( vAlign_changed(int) ) );
connect( multicolumnCB, SIGNAL( clicked() ), this, SLOT( multicolumn_clicked() ) );
connect( newpageCB, SIGNAL( clicked() ), this, SLOT( ltNewpage_clicked() ) );
connect( headerStatusCB, SIGNAL( clicked() ), this, SLOT( ltHeaderStatus_clicked() ) );
connect( headerBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltHeaderBorderAbove_clicked() ) );
connect( headerBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltHeaderBorderBelow_clicked() ) );
connect( firstheaderStatusCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderStatus_clicked() ) );
connect( firstheaderBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderBorderAbove_clicked() ) );
connect( firstheaderBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderBorderBelow_clicked() ) );
connect( firstheaderNoContentsCB, SIGNAL( clicked() ), this, SLOT( ltFirstHeaderEmpty_clicked() ) );
connect( footerStatusCB, SIGNAL( clicked() ), this, SLOT( ltFooterStatus_clicked() ) );
connect( footerBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltFooterBorderAbove_clicked() ) );
connect( footerBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltFooterBorderBelow_clicked() ) );
connect( lastfooterStatusCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterStatus_clicked() ) );
connect( lastfooterBorderAboveCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterBorderAbove_clicked() ) );
connect( lastfooterBorderBelowCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterBorderBelow_clicked() ) );
connect( lastfooterNoContentsCB, SIGNAL( clicked() ), this, SLOT( ltLastFooterEmpty_clicked() ) );
connect( specialAlignmentED, SIGNAL( returnPressed() ), this, SLOT( specialAlignment_changed() ) );
connect( widthED, SIGNAL( returnPressed() ), this, SLOT( width_changed() ) );
connect( widthUnit, SIGNAL( selectionChanged(LyXLength::UNIT) ), this, SLOT( width_changed() ) );
connect( closePB, SIGNAL( clicked() ), this, SLOT( close_clicked() ) );
connect( borders, SIGNAL( topSet(bool) ), this, SLOT( topBorder_changed() ) );
connect( borders, SIGNAL( bottomSet(bool) ), this, SLOT( bottomBorder_changed() ) );
connect( borders, SIGNAL( rightSet(bool) ), this, SLOT( rightBorder_changed() ) );
connect( borders, SIGNAL( leftSet(bool) ), this, SLOT( leftBorder_changed() ) );
connect( rotateTabularCB, SIGNAL( clicked() ), this, SLOT( rotateTabular() ) );
connect( rotateCellCB, SIGNAL( clicked() ), this, SLOT( rotateCell() ) );
connect( longTabularCB, SIGNAL( clicked() ), this, SLOT( longTabular() ) );
connect(topspaceED, SIGNAL(returnPressed()),
this, SLOT(topspace_changed()));
connect(topspaceUnit, SIGNAL(selectionChanged(LyXLength::UNIT)),
this, SLOT(topspace_changed()));
connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
connect(bottomspaceED, SIGNAL(returnPressed()),
this, SLOT(bottomspace_changed()));
connect(bottomspaceUnit, SIGNAL(selectionChanged(LyXLength::UNIT)),
this, SLOT(bottomspace_changed()));
connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
connect(interlinespaceED, SIGNAL(returnPressed()),
this, SLOT(interlinespace_changed()));
connect(interlinespaceUnit, SIGNAL(selectionChanged(LyXLength::UNIT)),
this, SLOT(interlinespace_changed()));
connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
connect(booktabsRB, SIGNAL(clicked()), this, SLOT(on_booktabsRB_toggled()));
connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
connect(widthUnit, SIGNAL(selectionChanged(LyXLength::UNIT)), this, SLOT(width_changed()));
connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
}
@ -86,6 +107,104 @@ void QTabularDialog::closeEvent(QCloseEvent * e)
}
void QTabularDialog::on_booktabsRB_toggled()
{
form_->changed();
form_->controller().booktabs(booktabsRB->isChecked());
form_->update_borders();
}
void QTabularDialog::topspace_changed()
{
switch(topspaceCO->currentItem()) {
case 0: {
form_->controller().set(LyXTabular::SET_TOP_SPACE, "");
topspaceED->setEnabled(false);
topspaceUnit->setEnabled(false);
break;
}
case 1: {
form_->controller().set(LyXTabular::SET_TOP_SPACE, "default");
topspaceED->setEnabled(false);
topspaceUnit->setEnabled(false);
break;
}
case 2: {
if (!topspaceED->text().isEmpty())
form_->controller().set(LyXTabular::SET_TOP_SPACE,
widgetsToLength(topspaceED, topspaceUnit));
if (!form_->bc().bp().isReadOnly()) {
topspaceED->setEnabled(true);
topspaceUnit->setEnabled(true);
}
break;
}
}
form_->changed();
}
void QTabularDialog::bottomspace_changed()
{
switch(bottomspaceCO->currentItem()) {
case 0: {
form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "");
bottomspaceED->setEnabled(false);
bottomspaceUnit->setEnabled(false);
break;
}
case 1: {
form_->controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
bottomspaceED->setEnabled(false);
bottomspaceUnit->setEnabled(false);
break;
}
case 2: {
if (!bottomspaceED->text().isEmpty())
form_->controller().set(LyXTabular::SET_BOTTOM_SPACE,
widgetsToLength(bottomspaceED, bottomspaceUnit));
if (!form_->bc().bp().isReadOnly()) {
bottomspaceED->setEnabled(true);
bottomspaceUnit->setEnabled(true);
}
break;
}
}
form_->changed();
}
void QTabularDialog::interlinespace_changed()
{
switch(interlinespaceCO->currentItem()) {
case 0: {
form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "");
interlinespaceED->setEnabled(false);
interlinespaceUnit->setEnabled(false);
break;
}
case 1: {
form_->controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
interlinespaceED->setEnabled(false);
interlinespaceUnit->setEnabled(false);
break;
}
case 2: {
if (!interlinespaceED->text().isEmpty())
form_->controller().set(LyXTabular::SET_INTERLINE_SPACE,
widgetsToLength(interlinespaceED, interlinespaceUnit));
if (!form_->bc().bp().isReadOnly()) {
interlinespaceED->setEnabled(true);
interlinespaceUnit->setEnabled(true);
}
break;
}
}
form_->changed();
}
void QTabularDialog::close_clicked()
{
form_->closeGUI();

View File

@ -32,6 +32,10 @@ public:
protected Q_SLOTS:
virtual void change_adaptor();
virtual void topspace_changed();
virtual void bottomspace_changed();
virtual void interlinespace_changed();
virtual void on_booktabsRB_toggled();
virtual void close_clicked();
virtual void borderSet_clicked();
virtual void borderUnset_clicked();

File diff suppressed because it is too large Load Diff

View File

@ -358,6 +358,11 @@
* FormFileDialog.C: add #include "filefilterlist.h"
* FormBibtex.C: remove #include "globbing.h".
2004-11-16 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* FormTabular.C (update): disable vertical rules if using
booktabs
2004-11-16 Lars Gullik Bjonnes <larsbj@gullik.net>
* Layoutengine.[Ch]: Break up circular dependency between Box and
@ -382,6 +387,11 @@
* XFormsView.C (hasFocus): new method, always returns true for now
2004-11-11 Edwin Leuven
* FormTabular.C (update, input): handle check_booktabs
* forms/form_tabular.fd (check_booktabs): new checkbox
2004-11-08 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* XFormsToolbar.C (selected): use layoutSelected

View File

@ -100,15 +100,30 @@ void FormTabular::build()
fl_set_input_return(column_options_->input_column_width,
FL_RETURN_END);
fl_set_input_return(column_options_->input_topspace,
FL_RETURN_END);
fl_set_input_return(column_options_->input_bottomspace,
FL_RETURN_END);
fl_set_input_return(column_options_->input_interlinespace,
FL_RETURN_END);
fl_set_input_return(column_options_->input_special_alignment,
FL_RETURN_END);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(column_options_->input_column_width);
setPrehandler(column_options_->input_topspace);
setPrehandler(column_options_->input_bottomspace);
setPrehandler(column_options_->input_interlinespace);
setPrehandler(column_options_->input_special_alignment);
fl_addto_choice(column_options_->choice_value_column_width,
units.c_str());
fl_addto_choice(column_options_->choice_value_topspace,
units.c_str());
fl_addto_choice(column_options_->choice_value_bottomspace,
units.c_str());
fl_addto_choice(column_options_->choice_value_interlinespace,
units.c_str());
// cell options form
cell_options_.reset(build_tabular_cell(this));
@ -164,6 +179,12 @@ void FormTabular::update()
fl_activate_object(cell_options_->input_special_multialign);
fl_activate_object(column_options_->input_column_width);
fl_activate_object(column_options_->choice_value_column_width);
fl_activate_object(column_options_->input_topspace);
fl_activate_object(column_options_->choice_value_topspace);
fl_activate_object(column_options_->input_bottomspace);
fl_activate_object(column_options_->choice_value_bottomspace);
fl_activate_object(column_options_->input_interlinespace);
fl_activate_object(column_options_->choice_value_interlinespace);
fl_set_input(dialog_->input_tabular_column,
convert<string>(column).c_str());
fl_deactivate_object(dialog_->input_tabular_column);
@ -180,13 +201,15 @@ void FormTabular::update()
tabular.bottomLine(cell)?1:0);
setEnabled(cell_options_->check_border_bottom, true);
// pay attention to left/right lines they are only allowed
// to set if we are in first/last cell of row or if the left/right
// cell is also a multicolumn.
// to set if we don't use booktabs and if we are in
// first/last cell of row or if the left/right cell is also a
// multicolumn.
if (tabular.isFirstCellInRow(cell) ||
tabular.isMultiColumn(cell-1)) {
fl_set_button(cell_options_->check_border_left,
tabular.leftLine(cell)?1:0);
setEnabled(cell_options_->check_border_left, true);
setEnabled(cell_options_->check_border_left,
!tabular.useBookTabs());
} else {
fl_set_button(cell_options_->check_border_left, 0);
setEnabled(cell_options_->check_border_left, false);
@ -195,7 +218,8 @@ void FormTabular::update()
tabular.isMultiColumn(cell+1)) {
fl_set_button(cell_options_->check_border_right,
tabular.rightLine(cell)?1:0);
setEnabled(cell_options_->check_border_right, true);
setEnabled(cell_options_->check_border_right,
!tabular.useBookTabs());
} else {
fl_set_button(cell_options_->check_border_right, 0);
setEnabled(cell_options_->check_border_right, false);
@ -320,6 +344,39 @@ void FormTabular::update()
setEnabled(column_options_->input_column_width, !isReadonly);
setEnabled(column_options_->choice_value_column_width, !isReadonly);
if (tabular.row_info[row].top_space_default)
fl_set_input(column_options_->input_topspace, "default");
else {
updateWidgetsFromLength(column_options_->input_topspace,
column_options_->choice_value_topspace,
tabular.row_info[row].top_space,
default_unit);
}
setEnabled(column_options_->input_topspace, !isReadonly);
setEnabled(column_options_->choice_value_topspace, !isReadonly);
if (tabular.row_info[row].bottom_space_default)
fl_set_input(column_options_->input_bottomspace, "default");
else {
updateWidgetsFromLength(column_options_->input_bottomspace,
column_options_->choice_value_bottomspace,
tabular.row_info[row].bottom_space,
default_unit);
}
setEnabled(column_options_->input_bottomspace, !isReadonly);
setEnabled(column_options_->choice_value_bottomspace, !isReadonly);
if (tabular.row_info[row].interline_space_default)
fl_set_input(column_options_->input_interlinespace, "default");
else {
updateWidgetsFromLength(column_options_->input_interlinespace,
column_options_->choice_value_interlinespace,
tabular.row_info[row].interline_space,
default_unit);
}
setEnabled(column_options_->input_interlinespace, !isReadonly);
setEnabled(column_options_->choice_value_interlinespace, !isReadonly);
setEnabled(cell_options_->check_useminipage, !pwidth.zero());
if (!pwidth.zero()) {
if (tabular.getUsebox(cell) == 2)
@ -361,6 +418,9 @@ void FormTabular::update()
setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
setEnabled(column_options_->radio_valign_middle, !pwidth.zero());
fl_set_button(tabular_options_->check_booktabs,
tabular.useBookTabs());
fl_set_button(tabular_options_->check_longtable,
tabular.isLongTabular());
@ -564,6 +624,72 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
return ButtonPolicy::SMI_VALID;
}
if ((ob == column_options_->input_topspace) ||
(ob == column_options_->choice_value_topspace)) {
string const input = getString(column_options_->input_topspace);
if (input == "default")
controller().set(LyXTabular::SET_TOP_SPACE, "default");
else {
string const str = getLengthFromWidgets(
column_options_->input_topspace,
column_options_->choice_value_topspace);
controller().set(LyXTabular::SET_TOP_SPACE, str);
//check if the input is valid
if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
postWarning(_("Invalid Length (valid example: 10mm)"));
return ButtonPolicy::SMI_INVALID;
}
}
update(); // update for alignment
return ButtonPolicy::SMI_VALID;
}
if ((ob == column_options_->input_bottomspace) ||
(ob == column_options_->choice_value_bottomspace)) {
string const input = getString(column_options_->input_bottomspace);
if (input == "default")
controller().set(LyXTabular::SET_BOTTOM_SPACE, "default");
else {
string const str = getLengthFromWidgets(
column_options_->input_bottomspace,
column_options_->choice_value_bottomspace);
controller().set(LyXTabular::SET_BOTTOM_SPACE, str);
//check if the input is valid
if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
postWarning(_("Invalid Length (valid example: 10mm)"));
return ButtonPolicy::SMI_INVALID;
}
}
update(); // update for alignment
return ButtonPolicy::SMI_VALID;
}
if ((ob == column_options_->input_interlinespace) ||
(ob == column_options_->choice_value_interlinespace)) {
string const input = getString(column_options_->input_interlinespace);
if (input == "default")
controller().set(LyXTabular::SET_INTERLINE_SPACE, "default");
else {
string const str = getLengthFromWidgets(
column_options_->input_interlinespace,
column_options_->choice_value_interlinespace);
controller().set(LyXTabular::SET_INTERLINE_SPACE, str);
//check if the input is valid
if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
postWarning(_("Invalid Length (valid example: 10mm)"));
return ButtonPolicy::SMI_INVALID;
}
}
update(); // update for alignment
return ButtonPolicy::SMI_VALID;
}
if ((ob == cell_options_->input_mcolumn_width) ||
(ob == cell_options_->choice_value_mcolumn_width)) {
string const str =
@ -622,6 +748,11 @@ ButtonPolicy::SMInput FormTabular::input(FL_OBJECT * ob, long)
num = LyXTabular::SET_LONGTABULAR;
else
num = LyXTabular::UNSET_LONGTABULAR;
} else if (ob == tabular_options_->check_booktabs) {
if (fl_get_button(tabular_options_->check_booktabs))
num = LyXTabular::SET_BOOKTABS;
else
num = LyXTabular::UNSET_BOOKTABS;
} else if (ob == tabular_options_->check_rotate_tabular) {
s = fl_get_button(tabular_options_->check_rotate_tabular);
if (s)

View File

@ -10,13 +10,13 @@ SnapGrid: 5
=============== FORM ===============
Name: form_tabular
Width: 510
Height: 325
Height: 400
Number of Objects: 6
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 510 325
box: 0 0 510 400
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -34,7 +34,7 @@ argument:
--------------------
class: FL_TABFOLDER
type: TOP_TABFOLDER
box: 0 0 505 250
box: 0 0 505 335
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_TOP_LEFT
@ -52,7 +52,7 @@ argument:
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 415 290 90 30
box: 415 365 90 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -70,7 +70,7 @@ argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 65 290 60 30
box: 65 365 60 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_TOP_LEFT
@ -88,7 +88,7 @@ argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 5 290 60 30
box: 5 365 60 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_TOP_LEFT
@ -125,7 +125,7 @@ argument:
Name: form_tabular_options
Width: 505
Height: 225
Number of Objects: 10
Number of Objects: 11
--------------------
class: FL_BOX
@ -292,7 +292,7 @@ argument: 0
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 280 20 120 75
box: 280 20 120 90
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
@ -307,16 +307,34 @@ name:
callback:
argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 280 80 95 25
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: Formal table|#F
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_booktabs
callback: C_FormDialogView_InputCB
argument: 0
=============== FORM ===============
Name: form_tabular_column
Width: 505
Height: 225
Number of Objects: 24
Height: 315
Number of Objects: 31
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 505 225
box: 0 0 505 315
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -349,6 +367,24 @@ name:
callback:
argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 20 230 475 75
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
style: FL_BOLD_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Vertical Space
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
@ -747,6 +783,114 @@ name: radio_align_block
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 30 270 75 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Top|#T
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: input_topspace
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 110 270 60 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: |#L
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_value_topspace
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 190 270 75 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Bottom|#B
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: input_bottomspace
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 270 270 60 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: |#L
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_value_bottomspace
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 350 270 75 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Interline|#I
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: input_interlinespace
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 430 270 60 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: |#L
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_value_interlinespace
callback: C_FormDialogView_InputCB
argument: 0
=============== FORM ===============
Name: form_tabular_cell
Width: 505

View File

@ -799,6 +799,10 @@
* insettabular.[Ch] (string2params): Don't pretend to return the
active cell anymore and simplify keyword parsing.
2004-11-11 Edwin Leuven
* insettabular.C (getStatus, tabularFeatures): handle booktabs feature
2004-11-10 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetlatexaccent.h (isLetter): implement, so that word selection

View File

@ -72,6 +72,7 @@ namespace {
int const ADD_TO_HEIGHT = 2;
int const ADD_TO_TABULAR_WIDTH = 2;
int const default_line_space = 10;
///
boost::scoped_ptr<LyXTabular> paste_tabular;
@ -133,6 +134,11 @@ TabularFeature tabularFeature[] =
{ LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
{ LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
{ LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
{ LyXTabular::SET_BOOKTABS, "set-booktabs" },
{ LyXTabular::UNSET_BOOKTABS, "unset-booktabs" },
{ LyXTabular::SET_TOP_SPACE, "set-top-space" },
{ LyXTabular::SET_BOTTOM_SPACE, "set-bottom-space" },
{ LyXTabular::SET_INTERLINE_SPACE, "set-interline-space" },
{ LyXTabular::LAST_ACTION, "" }
};
@ -268,8 +274,14 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
tabular.setWidthOfCell(cell, dim.wid);
++cell;
}
tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
int const top_space = tabular.row_info[i].top_space_default ?
default_line_space :
tabular.row_info[i].top_space.inPixels(mi.base.textwidth);
tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT + top_space);
int const bottom_space = tabular.row_info[i].bottom_space_default ?
default_line_space :
tabular.row_info[i].bottom_space.inPixels(mi.base.textwidth);
tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT + bottom_space);
}
dim.asc = tabular.getAscentOfRow(0);
@ -808,6 +820,9 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
case LyXTabular::DELETE_COLUMN:
case LyXTabular::SET_ALL_LINES:
case LyXTabular::UNSET_ALL_LINES:
case LyXTabular::SET_TOP_SPACE:
case LyXTabular::SET_BOTTOM_SPACE:
case LyXTabular::SET_INTERLINE_SPACE:
status.clear();
return true;
@ -946,6 +961,14 @@ bool InsetTabular::getStatus(LCursor & cur, FuncRequest const & cmd,
case LyXTabular::SET_LTNEWPAGE:
status.setOnOff(tabular.getLTNewPage(sel_row_start));
break;
case LyXTabular::SET_BOOKTABS:
status.setOnOff(tabular.useBookTabs());
break;
case LyXTabular::UNSET_BOOKTABS:
status.setOnOff(!tabular.useBookTabs());
break;
default:
status.clear();
@ -1127,11 +1150,10 @@ int InsetTabular::dist(idx_type const cell, int x, int y) const
Point o = theCoords.getInsets().xy(&inset);
int const xbeg = o.x_ - tabular.getBeginningOfTextInCell(cell);
int const xend = xbeg + tabular.getWidthOfColumn(cell);
int const ybeg = o.y_ - inset.ascent();
row_type const row = tabular.row_of_cell(cell);
int const rowheight = tabular.getAscentOfRow(row)
+ tabular.getDescentOfRow(row);
int const yend = ybeg + rowheight;
int const ybeg = o.y_ - tabular.getAscentOfRow(row) -
tabular.getAdditionalHeight(row);
int const yend = o.y_ + tabular.getDescentOfRow(row);
if (x < xbeg)
xx = xbeg - x;
@ -1634,6 +1656,68 @@ void InsetTabular::tabularFeatures(LCursor & cur,
tabular.setLTNewPage(row, !tabular.getLTNewPage(row));
break;
case LyXTabular::SET_BOOKTABS:
tabular.setBookTabs(true);
break;
case LyXTabular::UNSET_BOOKTABS:
tabular.setBookTabs(false);
break;
case LyXTabular::SET_TOP_SPACE: {
LyXLength len;
if (value == "default")
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
tabular.row_info[i].top_space_default = true;
else if (isValidLength(value, &len))
for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
tabular.row_info[i].top_space_default = false;
tabular.row_info[i].top_space = len;
}
else
for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
tabular.row_info[i].top_space_default = false;
tabular.row_info[i].top_space = len;
}
break;
}
case LyXTabular::SET_BOTTOM_SPACE: {
LyXLength len;
if (value == "default")
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
tabular.row_info[i].bottom_space_default = true;
else if (isValidLength(value, &len))
for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
tabular.row_info[i].bottom_space_default = false;
tabular.row_info[i].bottom_space = len;
}
else
for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
tabular.row_info[i].bottom_space_default = false;
tabular.row_info[i].bottom_space = len;
}
break;
}
case LyXTabular::SET_INTERLINE_SPACE: {
LyXLength len;
if (value == "default")
for (row_type i = sel_row_start; i <= sel_row_end; ++i)
tabular.row_info[i].interline_space_default = true;
else if (isValidLength(value, &len))
for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
tabular.row_info[i].interline_space_default = false;
tabular.row_info[i].interline_space = len;
}
else
for (row_type i = sel_row_start; i <= sel_row_end; ++i) {
tabular.row_info[i].interline_space_default = false;
tabular.row_info[i].interline_space = len;
}
break;
}
// dummy stuff just to avoid warnings
case LyXTabular::LAST_ACTION:
break;

View File

@ -64,6 +64,8 @@ using std::strlen;
namespace {
int const WIDTH_OF_LINE = 5;
int const default_line_space = 10;
template <class T>
string const write_attribute(string const & name, T const & t)
@ -299,6 +301,21 @@ bool getTokenValue(string const & str, char const * token, LyXLength & len)
}
bool getTokenValue(string const & str, char const * token, LyXLength & len, bool & flag)
{
len = LyXLength();
flag = false;
string tmp;
if (!getTokenValue(str, token, tmp))
return false;
if (tmp == "default") {
flag = true;
return true;
}
return isValidLength(tmp, &len);
}
void l_getline(istream & is, string & str)
{
str.erase();
@ -380,6 +397,9 @@ LyXTabular::rowstruct::rowstruct()
descent_of_row(0),
top_line(true),
bottom_line(false),
top_space_default(false),
bottom_space_default(false),
interline_space_default(false),
endhead(false),
endfirsthead(false),
endfoot(false),
@ -432,6 +452,7 @@ void LyXTabular::init(BufferParams const & bp, row_type rows_arg,
column_info.back().right_line = true;
is_long_tabular = false;
rotate = false;
use_booktabs = false;
}
@ -607,10 +628,10 @@ LyXTabular::idx_type LyXTabular::numberOfCellsInRow(idx_type const cell) const
}
// returns 1 if there is a topline, returns 0 if not
bool LyXTabular::topLine(idx_type const cell, bool const onlycolumn) const
{
if (!onlycolumn && isMultiColumn(cell))
if (!onlycolumn && isMultiColumn(cell) &&
!(use_booktabs && row_of_cell(cell) == 0))
return cellinfo_of_cell(cell).top_line;
return row_info[row_of_cell(cell)].top_line;
}
@ -618,7 +639,8 @@ bool LyXTabular::topLine(idx_type const cell, bool const onlycolumn) const
bool LyXTabular::bottomLine(idx_type const cell, bool onlycolumn) const
{
if (!onlycolumn && isMultiColumn(cell))
if (!onlycolumn && isMultiColumn(cell) &&
!(use_booktabs && isLastRow(cell)))
return cellinfo_of_cell(cell).bottom_line;
return row_info[row_of_cell(cell)].bottom_line;
}
@ -626,6 +648,8 @@ bool LyXTabular::bottomLine(idx_type const cell, bool onlycolumn) const
bool LyXTabular::leftLine(idx_type cell, bool onlycolumn) const
{
if (use_booktabs)
return false;
if (!onlycolumn && isMultiColumn(cell) &&
(isFirstCellInRow(cell) || isMultiColumn(cell-1)))
{
@ -641,6 +665,8 @@ bool LyXTabular::leftLine(idx_type cell, bool onlycolumn) const
bool LyXTabular::rightLine(idx_type cell, bool onlycolumn) const
{
if (use_booktabs)
return false;
if (!onlycolumn && isMultiColumn(cell) &&
(isLastCellInRow(cell) || isMultiColumn(cell + 1)))
{
@ -721,9 +747,12 @@ int LyXTabular::getAdditionalHeight(row_type row) const
top = row_info[row].top_line;
}
}
int const interline_space = row_info[row - 1].interline_space_default ?
default_line_space :
row_info[row - 1].interline_space.inPixels(width_of_tabular);
if (top && bottom)
return WIDTH_OF_LINE;
return 0;
return interline_space + WIDTH_OF_LINE;
return interline_space;
}
@ -1193,6 +1222,7 @@ void LyXTabular::write(Buffer const & buf, ostream & os) const
// global longtable options
os << "<features"
<< write_attribute("rotate", rotate)
<< write_attribute("booktabs", use_booktabs)
<< write_attribute("islongtable", is_long_tabular)
<< write_attribute("firstHeadTopDL", endfirsthead.topDL)
<< write_attribute("firstHeadBottomDL", endfirsthead.bottomDL)
@ -1218,8 +1248,21 @@ void LyXTabular::write(Buffer const & buf, ostream & os) const
for (row_type i = 0; i < rows_; ++i) {
os << "<row"
<< write_attribute("topline", row_info[i].top_line)
<< write_attribute("bottomline", row_info[i].bottom_line)
<< write_attribute("endhead", row_info[i].endhead)
<< write_attribute("bottomline", row_info[i].bottom_line);
static const string def("default");
if (row_info[i].top_space_default)
os << write_attribute("topspace", def);
else
os << write_attribute("topspace", row_info[i].top_space);
if (row_info[i].bottom_space_default)
os << write_attribute("bottomspace", def);
else
os << write_attribute("bottomspace", row_info[i].bottom_space);
if (row_info[i].interline_space_default)
os << write_attribute("interlinespace", def);
else
os << write_attribute("interlinespace", row_info[i].interline_space);
os << write_attribute("endhead", row_info[i].endhead)
<< write_attribute("endfirsthead", row_info[i].endfirsthead)
<< write_attribute("endfoot", row_info[i].endfoot)
<< write_attribute("endlastfoot", row_info[i].endlastfoot)
@ -1281,6 +1324,7 @@ void LyXTabular::read(Buffer const & buf, LyXLex & lex)
return;
}
getTokenValue(line, "rotate", rotate);
getTokenValue(line, "booktabs", use_booktabs);
getTokenValue(line, "islongtable", is_long_tabular);
getTokenValue(line, "firstHeadTopDL", endfirsthead.topDL);
getTokenValue(line, "firstHeadBottomDL", endfirsthead.bottomDL);
@ -1317,6 +1361,12 @@ void LyXTabular::read(Buffer const & buf, LyXLex & lex)
}
getTokenValue(line, "topline", row_info[i].top_line);
getTokenValue(line, "bottomline", row_info[i].bottom_line);
getTokenValue(line, "topspace", row_info[i].top_space,
row_info[i].top_space_default);
getTokenValue(line, "bottomspace", row_info[i].bottom_space,
row_info[i].bottom_space_default);
getTokenValue(line, "interlinespace", row_info[i].interline_space,
row_info[i].interline_space_default);
getTokenValue(line, "endfirsthead", row_info[i].endfirsthead);
getTokenValue(line, "endhead", row_info[i].endhead);
getTokenValue(line, "endfoot", row_info[i].endfoot);
@ -1443,6 +1493,18 @@ LyXTabular::idx_type LyXTabular::unsetMultiColumn(idx_type cell)
}
void LyXTabular::setBookTabs(bool what)
{
use_booktabs = what;
}
bool LyXTabular::useBookTabs() const
{
return use_booktabs;
}
void LyXTabular::setLongTabular(bool what)
{
is_long_tabular = what;
@ -1743,12 +1805,14 @@ int LyXTabular::TeXTopHLine(ostream & os, row_type row) const
if (topLine(i))
++tmp;
}
if (tmp == n - fcell) {
os << "\\hline ";
if (use_booktabs && row == 0) {
os << "\\toprule ";
} else if (tmp == n - fcell) {
os << (use_booktabs ? "\\midrule " : "\\hline ");
} else if (tmp) {
for (idx_type i = fcell; i < n; ++i) {
if (topLine(i)) {
os << "\\cline{"
os << (use_booktabs ? "\\cmidrule{" : "\\cline{")
<< column_of_cell(i) + 1
<< '-'
<< right_column_of_cell(i) + 1
@ -1777,12 +1841,14 @@ int LyXTabular::TeXBottomHLine(ostream & os, row_type row) const
if (bottomLine(i))
++tmp;
}
if (tmp == n - fcell) {
os << "\\hline";
if (use_booktabs && row == rows_ - 1) {
os << "\\bottomrule";
} else if (tmp == n - fcell) {
os << (use_booktabs ? "\\midrule" : "\\hline");
} else if (tmp) {
for (idx_type i = fcell; i < n; ++i) {
if (bottomLine(i)) {
os << "\\cline{"
os << (use_booktabs ? "\\cmidrule{" : "\\cline{")
<< column_of_cell(i) + 1
<< '-'
<< right_column_of_cell(i) + 1
@ -2013,8 +2079,23 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
OutputParams const & runparams) const
{
idx_type cell = getCellNumber(i, 0);
int ret = TeXTopHLine(os, i);
if (row_info[i].top_space_default) {
if (use_booktabs)
os << "\\addlinespace\n";
else
os << "\\noalign{\\vskip\\doublerulesep}\n";
} else if(!row_info[i].top_space.zero()) {
if (use_booktabs)
os << "\\addlinespace["
<< row_info[i].top_space.asLatexString() << "]\n";
else {
os << "\\noalign{\\vskip"
<< row_info[i].top_space.asLatexString() << "}\n";
}
++ret;
}
for (col_type j = 0; j < columns_; ++j) {
if (isPartOfMultiColumn(i, j))
continue;
@ -2039,9 +2120,36 @@ int LyXTabular::TeXRow(ostream & os, row_type i, Buffer const & buf,
}
++cell;
}
os << "\\tabularnewline\n";
os << "\\tabularnewline";
if (row_info[i].bottom_space_default) {
if (use_booktabs)
os << "\\addlinespace";
else
os << "[\\doublerulesep]";
} else if (!row_info[i].bottom_space.zero()) {
if (use_booktabs)
os << "\\addlinespace";
os << '[' << row_info[i].bottom_space.asLatexString() << ']';
}
os << '\n';
++ret;
ret += TeXBottomHLine(os, i);
if (row_info[i].interline_space_default) {
if (use_booktabs)
os << "\\addlinespace\n";
else
os << "\\noalign{\\vskip\\doublerulesep}\n";
} else if (!row_info[i].interline_space.zero()) {
if (use_booktabs)
os << "\\addlinespace["
<< row_info[i].interline_space.asLatexString()
<< "]\n";
else
os << "\\noalign{\\vskip"
<< row_info[i].interline_space.asLatexString()
<< "}\n";
++ret;
}
return ret;
}
@ -2067,7 +2175,7 @@ int LyXTabular::latex(Buffer const & buf, ostream & os,
if (!column_info[i].align_special.empty()) {
os << column_info[i].align_special;
} else {
if (column_info[i].left_line)
if (!use_booktabs && column_info[i].left_line)
os << '|';
if (!column_info[i].p_width.zero()) {
switch (column_info[i].alignment) {
@ -2114,7 +2222,7 @@ int LyXTabular::latex(Buffer const & buf, ostream & os,
break;
}
}
if (column_info[i].right_line)
if (!use_booktabs && column_info[i].right_line)
os << '|';
}
}
@ -2594,6 +2702,8 @@ LyXTabular::getCellFromInset(InsetBase const * inset) const
void LyXTabular::validate(LaTeXFeatures & features) const
{
features.require("NeedTabularnewline");
if (useBookTabs())
features.require("booktabs");
if (isLongTabular())
features.require("longtable");
if (needRotating())

View File

@ -127,6 +127,16 @@ public:
///
SET_SPECIAL_MULTI,
///
SET_BOOKTABS,
///
UNSET_BOOKTABS,
///
SET_TOP_SPACE,
///
SET_BOTTOM_SPACE,
///
SET_INTERLINE_SPACE,
///
LAST_ACTION
};
///
@ -203,7 +213,8 @@ public:
///
bool isLastRow(idx_type cell) const;
///
/// return space occupied by the second horizontal line and
/// interline space above row \p row in pixels
int getAdditionalHeight(row_type row) const;
///
int getAdditionalWidth(idx_type cell) const;
@ -321,6 +332,10 @@ public:
///
col_type right_column_of_cell(idx_type cell) const;
///
void setBookTabs(bool);
///
bool useBookTabs() const;
///
void setLongTabular(bool);
///
bool isLongTabular() const;
@ -458,6 +473,18 @@ public:
bool top_line;
///
bool bottom_line;
/// Extra space between the top line and this row
LyXLength top_space;
/// Ignore top_space if true and use the default top space
bool top_space_default;
/// Extra space between this row and the bottom line
LyXLength bottom_space;
/// Ignore bottom_space if true and use the default bottom space
bool bottom_space_default;
/// Extra space between the bottom line and the next top line
LyXLength interline_space;
/// Ignore interline_space if true and use the default interline space
bool interline_space_default;
/// This are for longtabulars only
/// a row of endhead
bool endhead;
@ -515,6 +542,8 @@ public:
///
int width_of_tabular;
///
bool use_booktabs;
///
bool rotate;
//
// for long tabulars