Dear LyXers,
attached is a patch that
- redesigns the box dialog (better logic and necessary to expand it with
features)
- adds support to change the line thickness, box separation and shadow
size (fixes bug #2598)
- makes it possible to set a horizontal alignment for all box types
(fixes bug #9522)
- calculates and outputs the correct width for all box types
OK to go on?
(I am aware that tex2lyx is still missing - I will do this before
committing.)
regards Uwe
development/FORMAT | 8 +
lib/lyx2lyx/LyX.py | 2 +-
lib/lyx2lyx/lyx_2_2.py | 28 ++-
src/frontends/qt4/GuiBox.cpp | 166 ++++++++++++++--
src/frontends/qt4/ui/BoxUi.ui | 432 +++++++++++++++++++++++++-----------------
src/insets/InsetBox.cpp | 98 +++++++++-
src/insets/InsetBox.h | 7 +
src/version.h | 4 +-
8 files changed, 540 insertions(+), 205 deletions(-)
diff --git a/development/FORMAT b/development/FORMAT
index a0bf4fa..058e382 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -11,6 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in
lyx2lyx.
-----------------------
+2015-05-xx Uwe Stöhr <uwesto...@web.de>
+ * Format incremented to 489: support to set line thickness, box
separation
+ and shadow size in the box dialog
+ New box parameters:
+ - thickness
+ - separation
+ - shadowsize
+
2015-04-21 Jürgen Spitzmüller <sp...@lyx.org>
* Format incremented to 488: Rewrite the Glosse insets (Glosse and
Tri-Glosse).
These insets now do not any longer use PassThru. Instead, they use
an optional
diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py
index f5e6e40..934f995 100644
--- a/lib/lyx2lyx/LyX.py
+++ b/lib/lyx2lyx/LyX.py
@@ -85,7 +85,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" ,
4)),
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
- ("2_2", list(range(475,489)), minor_versions("2.2" , 0))
+ ("2_2", list(range(475,490)), minor_versions("2.2" , 0))
]
####################################################################
diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py
index 68545dd..8316722 100644
--- a/lib/lyx2lyx/lyx_2_2.py
+++ b/lib/lyx2lyx/lyx_2_2.py
@@ -956,6 +956,30 @@ def convert_newgloss(document):
i = endPlain + 1
+def convert_BoxFeatures(document):
+ " adds new box features "
+
+ i = 0
+ while True:
+ i = find_token(document.body, "height_special", i)
+ if i == -1:
+ return
+ document.body.insert(i + 1, 'thickness "0.4pt"\nseparation
"3pt"\nshadowsize "4pt"\n')
+ i = i + 1
+
+
+def revert_BoxFeatures(document):
+ " deletes new box features "
+
+ i = 0
+ while True:
+ i = find_token(document.body, "height_special", i)
+ if i == -1:
+ return
+ del document.body[i+1:i+4]
+ i = i + 1
+
+
##
# Conversion hub
#
@@ -978,10 +1002,12 @@ convert = [
[485, []],
[486, []],
[487, []],
- [488, [convert_newgloss]]
+ [488, [convert_newgloss]],
+ [489, [convert_BoxFeatures]]
]
revert = [
+ [488, [revert_BoxFeatures]],
[487, [revert_newgloss, revert_glossgroup]],
[486, [revert_forest]],
[485, [revert_ex_itemargs]],
diff --git a/src/frontends/qt4/GuiBox.cpp b/src/frontends/qt4/GuiBox.cpp
index affc6cf..ca017f1 100644
--- a/src/frontends/qt4/GuiBox.cpp
+++ b/src/frontends/qt4/GuiBox.cpp
@@ -6,6 +6,7 @@
* \author Jürgen Vigna (Minipage stuff)
* \author Martin Vermeer
* \author Jürgen Spitzmüller
+ * \author Uwe Stöhr
*
* Full author contact details are available in file CREDITS.
*/
@@ -98,13 +99,28 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
this, SIGNAL(changed()));
connect(halignCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
connect(ialignCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
+ connect(thicknessED, SIGNAL(textChanged(QString)), this,
SIGNAL(changed()));
+ connect(thicknessUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SIGNAL(changed()));
+ connect(separationED, SIGNAL(textChanged(QString)), this,
SIGNAL(changed()));
+ connect(separationUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SIGNAL(changed()));
+ connect(shadowsizeED, SIGNAL(textChanged(QString)), this,
SIGNAL(changed()));
+ connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
+ this, SIGNAL(changed()));
heightED->setValidator(unsignedLengthValidator(heightED));
widthED->setValidator(unsignedLengthValidator(widthED));
+ thicknessED->setValidator(unsignedLengthValidator(thicknessED));
+ separationED->setValidator(unsignedLengthValidator(separationED));
+ shadowsizeED->setValidator(unsignedLengthValidator(shadowsizeED));
// initialize the length validator
addCheckedWidget(widthED, widthCB);
addCheckedWidget(heightED, heightCB);
+ addCheckedWidget(thicknessED, thicknessLA);
+ addCheckedWidget(separationED, separationLA);
+ addCheckedWidget(shadowsizeED, shadowsizeLA);
initDialog();
}
@@ -129,24 +145,55 @@ void GuiBox::on_innerBoxCO_activated(int /* index */)
widthCB->setEnabled(itype == "makebox"
|| (outer == "Boxed" && itype == "none"));
widthCB->setChecked(!widthED->text().isEmpty());
- // except for frameless and boxed, the width cannot be specified if
+ // except for Frameless and Boxed, the width cannot be specified if
// there is no inner box
bool const width_enabled =
ibox || outer == "Frameless" || outer == "Boxed";
- // enable if width_enabled, except if checkbaox is active but unset
- widthED->setEnabled(width_enabled || (widthCB->isEnabled() &&
widthCB->isChecked()));
- widthUnitsLC->setEnabled(width_enabled || (widthCB->isEnabled() &&
widthCB->isChecked()));
+ // enable if width_enabled
+ widthED->setEnabled(width_enabled);
+ widthUnitsLC->setEnabled(width_enabled);
if (!widthCB->isChecked() && widthCB->isEnabled()) {
widthED->setEnabled(false);
widthUnitsLC->setEnabled(false);
}
- // halign is only allowed without inner box and if a width is used and
if
- // pagebreak is not used
- halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
- && ((!ibox && outer == "Boxed") || itype ==
"makebox"));
+ // halign is only allowed if a width is used
+ halignCO->setEnabled(widthCB->isChecked());
+ halignCO->setEnabled(false);
+ // add the entry "Stretch" if the box is \makebox or \framebox
+ if (itype == "makebox" || (outer == "Boxed" && itype == "none"))
+ halignCO->addItem(toqstr("Stretch"));
+ else
+ halignCO->removeItem(3);
// pagebreak is only allowed for Boxed without inner box
pagebreakCB->setEnabled(!ibox && outer == "Boxed");
setSpecial(ibox);
+ // enable line thickness for the rectangular frame types and drop shadow
+ thicknessED->setEnabled(outer == "Boxed" || outer == "Doublebox" ||
outer == "Shadowbox");
+ thicknessUnitsLC->setEnabled(outer == "Boxed" || outer == "Doublebox"
|| outer == "Shadowbox");
+ // set default values if empty
+ if (thicknessED->text().isEmpty() && thicknessED->isEnabled()) {
+ thicknessED->setText("0.4");
+ thicknessUnitsLC->setCurrentItem(Length::PT);
+ }
+ // enable line separation for the allowed frame types
+ separationED->setEnabled(outer == "Boxed" || outer == "ovalbox" ||
outer == "Ovalbox"
+ || outer == "Doublebox" || outer == "Shadowbox");
+ separationUnitsLC->setEnabled(outer == "Boxed" || outer == "ovalbox" ||
outer == "Ovalbox"
+ || outer == "Doublebox" || outer == "Shadowbox");
+ // set default values if empty
+ if (separationED->text().isEmpty() && separationED->isEnabled()) {
+ separationED->setText("3");
+ separationUnitsLC->setCurrentItem(Length::PT);
+ }
+ // enable shadow size for drop shadow
+ shadowsizeED->setEnabled(outer == "Shadowbox");
+ shadowsizeUnitsLC->setEnabled(outer == "Shadowbox");
+ // set default values if empty
+ if (shadowsizeED->text().isEmpty() && shadowsizeED->isEnabled()) {
+ shadowsizeED->setText("4");
+ shadowsizeUnitsLC->setCurrentItem(Length::PT);
+ }
+
changed();
}
@@ -182,21 +229,51 @@ void GuiBox::on_typeCO_activated(int index)
// there is no inner box
bool const width_enabled =
itype != "none" || frameless || type == "Boxed";
- // enable if width_enabled, except if checkbaox is active but unset
- widthED->setEnabled(width_enabled || (widthCB->isEnabled() &&
widthCB->isChecked()));
- widthUnitsLC->setEnabled(width_enabled || (widthCB->isEnabled() &&
widthCB->isChecked()));
+ // enable if width_enabled
+ widthED->setEnabled(width_enabled);
+ widthUnitsLC->setEnabled(width_enabled);
if (!widthCB->isChecked() && widthCB->isEnabled()) {
widthED->setEnabled(false);
widthUnitsLC->setEnabled(false);
}
- // halign is only allowed without inner box and if a width is used and
if
- // pagebreak is not used
- halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
- && ((itype == "none" && type == "Boxed") || itype
== "makebox"));
+ // halign is only allowed if a width is used
+ halignCO->setEnabled(widthCB->isChecked());
+ // add the entry "Stretch" if the box is \makebox or \framebox
+ if (itype == "makebox" || (type == "Boxed" && itype == "none"))
+ halignCO->addItem(toqstr("Stretch"));
+ else
+ halignCO->removeItem(3);
// pagebreak is only allowed for Boxed without inner box
pagebreakCB->setEnabled(type == "Boxed" && itype == "none");
if (type != "Boxed")
pagebreakCB->setChecked(false);
+ // enable line thickness for the rectangular frame types and drop shadow
+ thicknessED->setEnabled(type == "Boxed" || type == "Doublebox" || type
== "Shadowbox");
+ thicknessUnitsLC->setEnabled(type == "Boxed" || type == "Doublebox" ||
type == "Shadowbox");
+ // set default values if empty
+ if (thicknessED->text().isEmpty() && thicknessED->isEnabled()) {
+ thicknessED->setText("0.4");
+ thicknessUnitsLC->setCurrentItem(Length::PT);
+ }
+ // enable line separation for the allowed frame types
+ separationED->setEnabled(type == "Boxed" || type == "ovalbox" || type
== "Ovalbox"
+ || type == "Doublebox" || type == "Shadowbox");
+ separationUnitsLC->setEnabled(type == "Boxed" || type == "ovalbox" ||
type == "Ovalbox"
+ || type == "Doublebox" || type == "Shadowbox");
+ // set default values if empty
+ if (separationED->text().isEmpty() && separationED->isEnabled()) {
+ separationED->setText("3");
+ separationUnitsLC->setCurrentItem(Length::PT);
+ }
+ // enable shadow size for drop shadow
+ shadowsizeED->setEnabled(type == "Shadowbox");
+ shadowsizeUnitsLC->setEnabled(type == "Shadowbox");
+ // set default values if empty
+ if (shadowsizeED->text().isEmpty() && shadowsizeED->isEnabled()) {
+ shadowsizeED->setText("4");
+ shadowsizeUnitsLC->setCurrentItem(Length::PT);
+ }
+
changed();
}
@@ -210,6 +287,15 @@ void GuiBox::initDialog()
widthUnitsLC->setCurrentItem(Length::PCW);
heightED->setText("1");
heightUnitsLC->setCurrentItem("totalheight");
+ // LaTeX's default for \fboxrule is 0.4 pt
+ thicknessED->setText("0.4");
+ thicknessUnitsLC->setCurrentItem(Length::PT);
+ // LaTeX's default for \fboxsep is 3 pt
+ separationED->setText("3");
+ separationUnitsLC->setCurrentItem(Length::PT);
+ // LaTeX's default for \shadowsize is 4 pt
+ shadowsizeED->setText("4");
+ shadowsizeUnitsLC->setCurrentItem(Length::PT);
}
@@ -295,10 +381,13 @@ void GuiBox::paramsToDialog(Inset const * inset)
ialignCO->setEnabled(ibox);
setSpecial(ibox);
- // halign is only allowed without inner box and if a width is used and
if
- // pagebreak is not used
- halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
- && ((!ibox && type == "Boxed") ||
params.use_makebox));
+ // halign is only allowed if a width is used
+ halignCO->setEnabled(widthCB->isChecked());
+ // add the entry "Stretch" if the box is \makebox or \framebox
+ if (inner_type == "makebox" || (type == "Boxed" && inner_type ==
"none"))
+ halignCO->addItem(toqstr("Stretch"));
+ else
+ halignCO->removeItem(3);
// pagebreak is only allowed for Boxed without inner box
pagebreakCB->setEnabled(!ibox && type == "Boxed");
@@ -340,6 +429,24 @@ void GuiBox::paramsToDialog(Inset const * inset)
heightCB->setCheckState(Qt::Checked);
heightCB->setEnabled(ibox);
+
+ // enable line thickness only for the rectangular frame types and drop
shadow
+ thicknessED->setEnabled(type == "Boxed" || type == "Doublebox" || type
== "Shadowbox");
+ thicknessUnitsLC->setEnabled(type == "Boxed" || type == "Doublebox" ||
type == "Shadowbox");
+ lengthToWidgets(thicknessED, thicknessUnitsLC,
+ (params.thickness).asString(), default_unit);
+ // enable line separation for the allowed frame types
+ separationED->setEnabled(type == "Boxed" || type == "ovalbox" || type
== "Ovalbox"
+ || type == "Doublebox" || type == "Shadowbox");
+ separationUnitsLC->setEnabled(type == "Boxed" || type == "ovalbox" ||
type == "Ovalbox"
+ || type == "Doublebox" || type == "Shadowbox");
+ lengthToWidgets(separationED, separationUnitsLC,
+ (params.separation).asString(), default_unit);
+ // enable shadow size for drop shadow
+ shadowsizeED->setEnabled(type == "Shadowbox");
+ shadowsizeUnitsLC->setEnabled(type == "Shadowbox");
+ lengthToWidgets(shadowsizeED, shadowsizeUnitsLC,
+ (params.shadowsize).asString(), default_unit);
}
@@ -407,6 +514,21 @@ docstring GuiBox::dialogToParams() const
Length(widgetsToLength(heightED,
heightUnitsLC));
}
}
+
+ // handle the line thickness, line separation and shadow size
+ if (thicknessED->isEnabled())
+ params.thickness = Length(widgetsToLength(thicknessED,
thicknessUnitsLC));
+ else
+ params.thickness = Length();
+ if (separationED->isEnabled())
+ params.separation = Length(widgetsToLength(separationED,
separationUnitsLC));
+ else
+ params.separation = Length();
+ if (separationED->isEnabled())
+ params.shadowsize = Length(widgetsToLength(shadowsizeED,
shadowsizeUnitsLC));
+ else
+ params.shadowsize = Length();
+
return from_ascii(InsetBox::params2string(params));
}
@@ -427,6 +549,12 @@ bool GuiBox::checkWidgets(bool readonly) const
heightED->setReadOnly(readonly);
heightUnitsLC->setEnabled(!readonly);
heightCB->setEnabled(!readonly);
+ thicknessED->setReadOnly(readonly);
+ thicknessUnitsLC->setEnabled(!readonly);
+ separationED->setReadOnly(readonly);
+ separationUnitsLC->setEnabled(!readonly);
+ shadowsizeED->setReadOnly(readonly);
+ shadowsizeUnitsLC->setEnabled(!readonly);
return InsetParamsWidget::checkWidgets();
}
diff --git a/src/frontends/qt4/ui/BoxUi.ui b/src/frontends/qt4/ui/BoxUi.ui
index 982b077..bd530c2 100644
--- a/src/frontends/qt4/ui/BoxUi.ui
+++ b/src/frontends/qt4/ui/BoxUi.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>261</width>
- <height>245</height>
+ <width>262</width>
+ <height>411</height>
</rect>
</property>
<property name="windowTitle">
@@ -16,40 +16,137 @@
<property name="sizeGripEnabled" stdset="0">
<bool>true</bool>
</property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>9</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
- <item row="4" column="0" colspan="2">
- <widget class="QCheckBox" name="pagebreakCB">
- <property name="toolTip">
- <string>Check this if the box should break across pages</string>
+ <layout class="QGridLayout" name="gridLayout_4">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="TypesizeGB">
+ <property name="title">
+ <string>Type and size</string>
</property>
- <property name="text">
- <string>Allow &page breaks</string>
+ <property name="flat">
+ <bool>true</bool>
</property>
+ <layout class="QGridLayout" name="gridLayout_3">
+ <item row="0" column="0">
+ <widget class="QLabel" name="innerBoxLA">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="text">
+ <string>Inner Bo&x:</string>
+ </property>
+ <property name="buddy">
+ <cstring>innerBoxCO</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="widthCB">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="text">
+ <string>&Width:</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="widthED">
+ <property name="toolTip">
+ <string>Width value</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="lyx::frontend::LengthCombo" name="widthUnitsLC"/>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="heightCB">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="text">
+ <string>&Height:</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="heightED">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Height value</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="lyx::frontend::LengthCombo" name="heightUnitsLC">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QCheckBox" name="pagebreakCB">
+ <property name="toolTip">
+ <string>Check this if the box should break across pages</string>
+ </property>
+ <property name="text">
+ <string>Allow &page breaks</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QComboBox" name="innerBoxCO">
+ <property name="toolTip">
+ <string>Inner box -- needed for fixed width & line breaks</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>None</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Parbox</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minipage</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="5" column="0" colspan="3">
- <widget class="QGroupBox" name="groupBox_2">
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="AlignmentGB">
<property name="title">
<string>Alignment</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>9</number>
- </property>
- <property name="spacing">
- <number>6</number>
- </property>
+ <layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="2">
<widget class="QComboBox" name="halignCO">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -74,15 +171,58 @@
<string>Right</string>
</property>
</item>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="ialignLA">
+ <property name="toolTip">
+ <string>Vertical alignment of the content inside the box</string>
+ </property>
+ <property name="text">
+ <string>Vertical</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="halignLA">
+ <property name="toolTip">
+ <string>Horizontal alignment of the content inside the box</string>
+ </property>
+ <property name="text">
+ <string>Horizontal</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="valignCO">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>Vertical alignment of the box (with regard to
baseline)</string>
+ </property>
<item>
<property name="text">
- <string>Stretch</string>
+ <string>Top</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Middle</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Bottom</string>
</property>
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="ialignCO">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -114,26 +254,14 @@
</item>
</widget>
</item>
- <item row="2" column="1">
- <widget class="QComboBox" name="valignCO">
- <property name="toolTip">
- <string>Vertical alignment of the box (with regard to
baseline)</string>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Co&ntent:</string>
+ </property>
+ <property name="buddy">
+ <cstring>ialignCO</cstring>
</property>
- <item>
- <property name="text">
- <string>Top</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Middle</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Bottom</string>
- </property>
- </item>
</widget>
</item>
<item row="2" column="0">
@@ -149,153 +277,113 @@
</property>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="DecorationGB">
+ <property name="title">
+ <string>Decoration</string>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="typeLA">
+ <property name="toolTip">
+ <string/>
+ </property>
<property name="text">
- <string>Co&ntent:</string>
+ <string>&Decoration:</string>
</property>
<property name="buddy">
- <cstring>ialignCO</cstring>
+ <cstring>typeCO</cstring>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QLabel" name="ialignLA">
+ <item row="0" column="1" colspan="2">
+ <widget class="QComboBox" name="typeCO">
<property name="toolTip">
- <string>Vertical alignment of the content inside the box</string>
+ <string>Supported box types</string>
</property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="thicknessLA">
<property name="text">
- <string>Vertical</string>
+ <string>Line thickness:</string>
</property>
</widget>
</item>
- <item row="0" column="2">
- <widget class="QLabel" name="halignLA">
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="thicknessED">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="toolTip">
- <string>Horizontal alignment of the content inside the box</string>
+ <string>Width value</string>
</property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="lyx::frontend::LengthCombo" name="thicknessUnitsLC">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="separationLA">
<property name="text">
- <string>Horizontal</string>
+ <string>Box separation:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="separationED">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Width value</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="lyx::frontend::LengthCombo" name="separationUnitsLC">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="shadowsizeLA">
+ <property name="text">
+ <string>Shadow size:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="shadowsizeED">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Width value</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="lyx::frontend::LengthCombo" name="shadowsizeUnitsLC">
+ <property name="enabled">
+ <bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
- <item row="3" column="2">
- <widget class="lyx::frontend::LengthCombo" name="heightUnitsLC">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="heightCB">
- <property name="toolTip">
- <string/>
- </property>
- <property name="text">
- <string>&Height:</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="innerBoxLA">
- <property name="toolTip">
- <string/>
- </property>
- <property name="text">
- <string>Inner Bo&x:</string>
- </property>
- <property name="buddy">
- <cstring>innerBoxCO</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="lyx::frontend::LengthCombo" name="widthUnitsLC"/>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="typeLA">
- <property name="toolTip">
- <string/>
- </property>
- <property name="text">
- <string>&Decoration:</string>
- </property>
- <property name="buddy">
- <cstring>typeCO</cstring>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="widthCB">
- <property name="toolTip">
- <string/>
- </property>
- <property name="text">
- <string>&Width:</string>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <property name="tristate">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLineEdit" name="heightED">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Height value</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="widthED">
- <property name="toolTip">
- <string>Width value</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1" colspan="2">
- <widget class="QComboBox" name="innerBoxCO">
- <property name="toolTip">
- <string>Inner box -- needed for fixed width & line breaks</string>
- </property>
- <item>
- <property name="text">
- <string>None</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Parbox</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Minipage</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="0" column="1" colspan="2">
- <widget class="QComboBox" name="typeCO">
- <property name="toolTip">
- <string>Supported box types</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
<customwidgets>
@@ -308,11 +396,7 @@
<tabstops>
<tabstop>typeCO</tabstop>
<tabstop>innerBoxCO</tabstop>
- <tabstop>widthED</tabstop>
- <tabstop>widthUnitsLC</tabstop>
<tabstop>heightCB</tabstop>
- <tabstop>heightED</tabstop>
- <tabstop>heightUnitsLC</tabstop>
<tabstop>ialignCO</tabstop>
<tabstop>halignCO</tabstop>
<tabstop>valignCO</tabstop>
diff --git a/src/insets/InsetBox.cpp b/src/insets/InsetBox.cpp
index ddb1dce..87d5005 100644
--- a/src/insets/InsetBox.cpp
+++ b/src/insets/InsetBox.cpp
@@ -6,6 +6,7 @@
* \author Angus Leeming
* \author Martin Vermeer
* \author Jürgen Spitzmüller
+ * \author Uwe Stöhr
*
* Full author contact details are available in file CREDITS.
*/
@@ -272,20 +273,26 @@ void InsetBox::latex(otexstream & os, OutputParams const
& runparams) const
BoxType btype = boxtranslator().find(params_.type);
string width_string = params_.width.asLatexString();
+ string thickness_string = params_.thickness.asLatexString();
+ string separation_string = params_.separation.asLatexString();
+ string shadowsize_string = params_.shadowsize.asLatexString();
bool stdwidth = false;
- // FIXME: do not test explicitely values of width_string
- if (params_.inner_box &&
- (width_string.find("1.0\\columnwidth") != string::npos
- || width_string.find("1.0\\textwidth") !=
string::npos)) {
+ // in general the overall width of some decorated boxes is wider thean
the inner box
+ // therefore calculate the real width so that if the user wants e.g.
0.1\columnwidth
+ // he will get exactly this without the need to a LaTeX expert
+ if (params_.inner_box) {
stdwidth = true;
switch (btype) {
case Frameless:
+ break;
case Framed:
+ width_string += " - 2\\FrameSep - 2\\FrameRule";
break;
case Boxed:
- case Shaded:
width_string += " - 2\\fboxsep - 2\\fboxrule";
break;
+ case Shaded:
+ break;
case ovalbox:
width_string += " - 2\\fboxsep - 0.8pt";
break;
@@ -293,8 +300,7 @@ void InsetBox::latex(otexstream & os, OutputParams const &
runparams) const
width_string += " - 2\\fboxsep - 1.6pt";
break;
case Shadowbox:
- // Shadow falls outside right margin... opinions?
- width_string += " - 2\\fboxsep - 2\\fboxrule"/*
"-\\shadowsize"*/;
+ width_string += " - 2\\fboxsep - 2\\fboxrule -
\\shadowsize";
break;
case Doublebox:
width_string += " - 2\\fboxsep - 7.5\\fboxrule - 1pt";
@@ -314,9 +320,17 @@ void InsetBox::latex(otexstream & os, OutputParams const &
runparams) const
case Frameless:
break;
case Framed:
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "{\\FrameRule " << from_ascii(thickness_string);
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "{\\FrameSep " << from_ascii(separation_string);
os << "\\begin{framed}%\n";
break;
case Boxed:
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "{\\fboxrule " << from_ascii(thickness_string);
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "{\\fboxsep " << from_ascii(separation_string);
if (!width_string.empty()) {
if (!params_.inner_box) {
os << "\\framebox";
@@ -338,12 +352,22 @@ void InsetBox::latex(otexstream & os, OutputParams const
& runparams) const
os << "{";
break;
case ovalbox:
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "{\\fboxsep " << from_ascii(separation_string);
os << "\\ovalbox{";
break;
case Ovalbox:
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "{\\fboxsep " << from_ascii(separation_string);
os << "\\Ovalbox{";
break;
case Shadowbox:
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "{\\fboxrule " << from_ascii(thickness_string);
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "{\\fboxsep " << from_ascii(separation_string);
+ if (!shadowsize_string.empty() && shadowsize_string.find("4pt")
== string::npos)
+ os << "{\\shadowsize " << from_ascii(shadowsize_string);
os << "\\shadowbox{";
break;
case Shaded:
@@ -351,6 +375,10 @@ void InsetBox::latex(otexstream & os, OutputParams const &
runparams) const
// it is inside a minipage or parbox
break;
case Doublebox:
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "{\\fboxrule " << from_ascii(thickness_string);
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "{\\fboxsep " << from_ascii(separation_string);
os << "\\doublebox{";
break;
}
@@ -414,6 +442,23 @@ void InsetBox::latex(otexstream & os, OutputParams const &
runparams) const
os << "\\begin{shaded}%\n";
}
+ // \framebox and \makebox handle hor_pos their own way
+ // hor_pos is senseless for \mbox and \fbox
+ if (!(params_.use_makebox)
+ && !(btype == Boxed && !params_.inner_box)) {
+ switch (params_.hor_pos) {
+ case 'l':
+ // do nothing because this is LaTeX's default
+ break;
+ case 'c':
+ os << "\\centering ";
+ break;
+ case 'r':
+ os << "\\raggedleft ";
+ break;
+ }
+ }
+
InsetText::latex(os, runparams);
if (btype == Shaded)
@@ -431,15 +476,43 @@ void InsetBox::latex(otexstream & os, OutputParams const
& runparams) const
break;
case Framed:
os << "\\end{framed}";
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "}";
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "}";
break;
case Boxed:
os << "}";
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "}";
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "}";
break;
case ovalbox:
+ os << "}";
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "}";
+ break;
case Ovalbox:
+ os << "}";
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "}";
+ break;
case Doublebox:
+ os << "}";
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "}";
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "}";
+ break;
case Shadowbox:
os << "}";
+ if (!shadowsize_string.empty() && shadowsize_string.find("4pt")
== string::npos)
+ os << "}";
+ if (!separation_string.empty() && separation_string.find("3pt")
== string::npos)
+ os << "}";
+ if (!thickness_string.empty() && thickness_string.find("0.4pt")
== string::npos)
+ os << "}";
break;
case Shaded:
// already done
@@ -632,7 +705,10 @@ InsetBoxParams::InsetBoxParams(string const & label)
hor_pos('c'),
inner_pos('t'),
height(Length("1in")),
- height_special("totalheight") // default is 1\\totalheight
+ height_special("totalheight"), // default is 1\\totalheight
+ thickness(Length("0.4pt")),
+ separation(Length("3pt")),
+ shadowsize(Length("4pt"))
{}
@@ -649,6 +725,9 @@ void InsetBoxParams::write(ostream & os) const
os << "special \"" << special << "\"\n";
os << "height \"" << height.asString() << "\"\n";
os << "height_special \"" << height_special << "\"\n";
+ os << "thickness \"" << thickness.asString() << "\"\n";
+ os << "separation \"" << separation.asString() << "\"\n";
+ os << "shadowsize \"" << shadowsize.asString() << "\"\n";
}
@@ -668,6 +747,9 @@ void InsetBoxParams::read(Lexer & lex)
lex >> "special" >> special;
lex >> "height" >> height;
lex >> "height_special" >> height_special;
+ lex >> "thickness" >> thickness;
+ lex >> "separation" >> separation;
+ lex >> "shadowsize" >> shadowsize;
}
diff --git a/src/insets/InsetBox.h b/src/insets/InsetBox.h
index 76b11f6..e8ea613 100644
--- a/src/insets/InsetBox.h
+++ b/src/insets/InsetBox.h
@@ -6,6 +6,7 @@
*
* \author Angus Leeming
* \author Martin Vermeer
+ * \author Uwe Stöhr
*
* Full author contact details are available in file CREDITS.
*/
@@ -52,6 +53,12 @@ public:
Length height;
///
std::string height_special;
+ ///
+ Length thickness;
+ ///
+ Length separation;
+ ///
+ Length shadowsize;
};
diff --git a/src/version.h b/src/version.h
index e52d96b..8407528 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 488 // spitz: rework the Glosse insets
-#define LYX_FORMAT_TEX2LYX 488
+#define LYX_FORMAT_LYX 489 // uwestoehr: new box features
+#define LYX_FORMAT_TEX2LYX 489
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER