framed.sty goes InsetBox:

* src/insets/InsetBox.{cpp,h}:
* src/frontends/qt4/GuiBox.{cpp,h}:
* src/frontends/qt4/ui/BoxUi.ui:
	- add and handle Framed and Shaded boxes
	- use more descriptive label names
	- implement name() function for Box:Shaded's sake

* src/insets/InsetNote.{cpp,h}:
* src/frontends/qt4/GuiNote.cpp:
* src/frontends/qt4/ui/NoteUi.ui:
	- remove Framed and Shaded.

* lib/layouts/stdinsets.inc:
	- remove Note:Framed and Note:Shaded
	- add Box:Shaded

* Buffer.cpp:
	- bump format to 304.

* lib/lyx2lyx/LyX.py:
* lib/lyx2lyx/lyx_1_6.py:
	- add conversion/reversion of framed/shaded notes to boxes.

* development/FORMAT:
	- document file format change.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21945 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2007-12-04 09:25:50 +00:00
parent aaa239be61
commit 3582be1441
14 changed files with 339 additions and 226 deletions

View File

@ -1,6 +1,10 @@
LyX file-format changes
-----------------------
2007-12-03 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* Format incremented to 304: framed and shaded boxes are now real boxes
(not notes).
2007-11-25 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 303: remove Serbocroatian as this was not a real
babel language (Croatian was used instead in the background)

View File

@ -1,5 +1,5 @@
# Textclass definition file for LaTeX.
# Author : Martin vermeer <amrtin.vermeer@hut.fi>
# Author : Martin vermeer <martin.vermeer@hut.fi>
# Inset layouts definition
#
#InsetLayout <string identifier used by LyX>
@ -118,30 +118,6 @@ InsetLayout Note:Greyedout
MultiPar true
End
InsetLayout Note:Framed
LabelString framed
LatexType environment
LatexName framed
BgColor greyedoutbg
LabelFont
Color greyedout
Size Small
EndFont
MultiPar true
End
InsetLayout Note:Shaded
LabelString shaded
LatexType environment
LatexName shaded
BgColor shaded
LabelFont
Color greyedout
Size Small
EndFont
MultiPar true
End
InsetLayout ERT
LabelString ERT
LatexType none
@ -219,6 +195,15 @@ InsetLayout Box
MultiPar true
End
InsetLayout Box:Shaded
BgColor shaded
LabelFont
Color foreground
Size Small
EndFont
MultiPar true
End
InsetLayout figure
LabelString Figure
LabelFont

View File

@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
("1_5", range(246,277), minor_versions("1.5" , 2)),
("1_6", range(277,304), minor_versions("1.6" , 0))] # Uwe: Serbocroatian
("1_6", range(277,305), minor_versions("1.6" , 0))]
def formats_list():

View File

@ -33,7 +33,7 @@ def find_end_of_inset(lines, i):
def wrap_into_ert(string, src, dst):
" Wrap a something into an ERT"
return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout standard\n'
return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout Standard\n'
+ dst + '\n\\end_layout\n\\end_inset\n')
@ -367,7 +367,7 @@ def convert_latexcommand_index(document):
fullcontent = document.body[i + 2][6:].strip('"')
document.body[i:i + 2] = ["\\begin_inset Index",
"status collapsed",
"\\begin_layout standard"]
"\\begin_layout Standard"]
# Put here the conversions needed from LaTeX string to LyXText.
# Here we do a minimal conversion to prevent crashes and data loss.
# Manual patch-up may be needed.
@ -425,7 +425,7 @@ def revert_latexcommand_index(document):
line = line[16:]
if line.startswith("\\begin_inset Formula"):
line = line[20:]
if line.startswith("\\begin_layout standard"):
if line.startswith("\\begin_layout Standard"):
line = line[22:]
if line.startswith("\\end_layout"):
line = line[11:]
@ -861,6 +861,58 @@ def convert_serbocroatian(document):
j = j + 1
def convert_framed_notes(document):
"Convert framed notes to boxes. "
i = 0
while 1:
i = find_tokens(document.body, ["\\begin_inset Note Framed", "\\begin_inset Note Shaded"], i)
if i == -1:
return
document.body[i] = document.body[i].replace("\\begin_inset Note", "\\begin_inset Box")
document.body.insert(i + 1, 'position "t"\nhor_pos "c"\nhas_inner_box 0\ninner_pos "t"\n' \
'use_parbox 0\nwidth "100col%"\nspecial "none"\nheight "1in"\n' \
'height_special "totalheight"')
i = i + 1
def revert_framed_notes(document):
"Revert framed boxes to notes. "
i = 0
while 1:
i = find_tokens(document.body, ["\\begin_inset Box Framed", "\\begin_inset Box Shaded"], i)
if i == -1:
return
j = find_end_of_inset(document.body, i + 1)
if j == -1:
# should not happen
document.warning("Malformed LyX document: Could not find end of Box inset.")
k = find_token(document.body, "status", i + 1, j)
if k == -1:
document.warning("Malformed LyX document: Missing `status' tag in Box inset.")
return
status = document.body[k]
l = find_token(document.body, "\\begin_layout Standard", i + 1, j)
if l == -1:
document.warning("Malformed LyX document: Missing `\\begin_layout Standard' in Box inset.")
return
m = find_token(document.body, "\\end_layout", i + 1, j)
if m == -1:
document.warning("Malformed LyX document: Missing `\\end_layout' in Box inset.")
return
ibox = find_token(document.body, "has_inner_box 1", i + 1, k)
pbox = find_token(document.body, "use_parbox 1", i + 1, k)
if ibox == -1 and pbox == -1:
document.body[i] = document.body[i].replace("\\begin_inset Box", "\\begin_inset Note")
del document.body[i+1:k]
else:
document.body[i] = document.body[i].replace("\\begin_inset Box Shaded", "\\begin_inset Box Frameless")
document.body.insert(l + 1, "\\begin_inset Note Shaded\n" + status + "\n\\begin_layout Standard\n")
document.body.insert(m + 1, "\\end_layout\n\\end_inset")
i = i + 1
##
# Conversion hub
#
@ -892,10 +944,12 @@ convert = [[277, [fix_wrong_tables]],
[300, []],
[301, []],
[302, []],
[303, [convert_serbocroatian]]
[303, [convert_serbocroatian]],
[304, [convert_framed_notes]]
]
revert = [[302, []],
revert = [[303, [revert_framed_notes]],
[302, []],
[301, [revert_latin, revert_samin]],
[300, [revert_linebreak]],
[299, [revert_pagebreak]],

View File

@ -153,7 +153,7 @@ namespace os = support::os;
namespace {
int const LYX_FORMAT = 303; // Uwe: Serbocroatian
int const LYX_FORMAT = 304; // JSpitzm: framed.sty goes InsetBox
} // namespace anon

View File

@ -43,16 +43,17 @@ void box_gui_tokens(vector<string> & ids, vector<docstring> & gui_names)
{
char const * const ids_[] = {
"Frameless", "Boxed", "ovalbox",
"Ovalbox", "Shadowbox", "Doublebox"};
"Ovalbox", "Shadowbox", "Shaded", "Doublebox"};
size_t const ids_size = sizeof(ids_) / sizeof(char *);
ids = vector<string>(ids_, ids_ + ids_size);
gui_names.clear();
gui_names.push_back(_("No frame drawn"));
gui_names.push_back(_("Rectangular box"));
gui_names.push_back(_("Oval box, thin"));
gui_names.push_back(_("Oval box, thick"));
gui_names.push_back(_("Shadow box"));
gui_names.push_back(_("Double box"));
gui_names.push_back(_("No frame"));
gui_names.push_back(_("Simple rectangular frame"));
gui_names.push_back(_("Oval frame, thin"));
gui_names.push_back(_("Oval frame, thick"));
gui_names.push_back(_("Drop shadow"));
gui_names.push_back(_("Shaded background"));
gui_names.push_back(_("Double rectangular frame"));
}
@ -115,6 +116,8 @@ GuiBox::GuiBox(GuiView & lv)
connect(innerBoxCO, SIGNAL(activated(const QString&)),
this, SLOT(innerBoxChanged(const QString &)));
connect(innerBoxCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(pagebreakCB, SIGNAL(stateChanged(int)),
this, SLOT(pagebreakClicked()));
heightED->setValidator(unsignedLengthValidator(heightED));
widthED->setValidator(unsignedLengthValidator(widthED));
@ -131,6 +134,7 @@ GuiBox::GuiBox(GuiView & lv)
bc().addReadOnly(heightCB);
bc().addReadOnly(heightED);
bc().addReadOnly(heightUnitsLC);
bc().addReadOnly(pagebreakCB);
bc().setRestore(restorePB);
bc().setOK(okPB);
@ -183,6 +187,9 @@ void GuiBox::typeChanged(int index)
heightUnitsLC->setEnabled(true);
setSpecial(true);
}
if (index != 1)
pagebreakCB->setChecked(false);
pagebreakCB->setEnabled(index == 1);
int itype = innerBoxCO->currentIndex();
setInnerType(frameless, itype);
}
@ -202,9 +209,34 @@ void GuiBox::restoreClicked()
}
void GuiBox::pagebreakClicked()
{
bool pbreak = (pagebreakCB->checkState() == Qt::Checked);
innerBoxCO->setEnabled(!pbreak);
if (pbreak) {
valignCO->setEnabled(false);
ialignCO->setEnabled(false);
halignCO->setEnabled(false);
heightCB->setEnabled(false);
heightED->setEnabled(false);
heightUnitsLC->setEnabled(false);
setSpecial(false);
} else
typeChanged(typeCO->currentIndex());
}
void GuiBox::updateContents()
{
string type = params_.type;
if (type == "Framed") {
pagebreakCB->setChecked(true);
type = "Boxed";
} else
pagebreakCB->setChecked(false);
pagebreakCB->setEnabled(type == "Boxed");
for (unsigned int i = 0; i < gui_names_.size(); ++i) {
if (type == ids_[i])
typeCO->setCurrentIndex(i);
@ -282,10 +314,14 @@ void GuiBox::updateContents()
void GuiBox::applyView()
{
params_.type = ids_[typeCO->currentIndex()];
bool pagebreak = pagebreakCB->isChecked();
if (pagebreak)
params_.type = "Framed";
else
params_.type = ids_[typeCO->currentIndex()];
params_.inner_box = innerBoxCO->currentText() != qt_("None");
params_.use_parbox = innerBoxCO->currentText() == qt_("Parbox");
params_.inner_box = (!pagebreak && innerBoxCO->currentText() != qt_("None"));
params_.use_parbox = (!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
params_.pos = "tcb"[valignCO->currentIndex()];
params_.inner_pos = "tcbs"[ialignCO->currentIndex()];

View File

@ -35,6 +35,7 @@ private Q_SLOTS:
void innerBoxChanged(const QString &);
void typeChanged(int);
void restoreClicked();
void pagebreakClicked();
private:
///

View File

@ -37,8 +37,6 @@ GuiNote::GuiNote(GuiView & lv)
connect(noteRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(greyedoutRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(commentRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(framedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
connect(shadedRB, SIGNAL(clicked()), this, SLOT(change_adaptor()));
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
bc().setOK(okPB);
@ -71,12 +69,6 @@ void GuiNote::updateContents()
case InsetNoteParams::Greyedout:
greyedoutRB->setChecked(true);
break;
case InsetNoteParams::Framed:
framedRB->setChecked(true);
break;
case InsetNoteParams::Shaded:
shadedRB->setChecked(true);
break;
}
}
@ -87,10 +79,6 @@ void GuiNote::applyView()
params_.type = InsetNoteParams::Greyedout;
else if (commentRB->isChecked())
params_.type = InsetNoteParams::Comment;
else if (framedRB->isChecked())
params_.type = InsetNoteParams::Framed;
else if (shadedRB->isChecked())
params_.type = InsetNoteParams::Shaded;
else
params_.type = InsetNoteParams::Note;
}

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>356</width>
<height>268</height>
<height>288</height>
</rect>
</property>
<property name="windowTitle" >
@ -22,7 +22,17 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="4" column="0" colspan="3" >
<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>
</property>
<property name="text" >
<string>Allow &amp;page breaks</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3" >
<widget class="QGroupBox" name="groupBox_2" >
<property name="title" >
<string>Alignment</string>
@ -175,95 +185,7 @@
</layout>
</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>
<item row="1" column="1" colspan="2" >
<widget class="QComboBox" name="innerBoxCO" >
<property name="toolTip" >
<string>Inner box -- needed for fixed width &amp; 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="2" column="1" >
<widget class="QLineEdit" name="widthED" >
<property name="toolTip" >
<string>Width value</string>
</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="0" >
<widget class="QLabel" name="widthLA" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>&amp;Width:</string>
</property>
<property name="buddy" >
<cstring>widthED</cstring>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="typeLA" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>&amp;Decoration:</string>
</property>
<property name="buddy" >
<cstring>typeCO</cstring>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="LengthCombo" name="widthUnitsLC" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="innerBoxLA" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>Inner Bo&amp;x:</string>
</property>
<property name="buddy" >
<cstring>innerBoxCO</cstring>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3" >
<item row="6" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
@ -347,6 +269,13 @@
</item>
</layout>
</item>
<item row="3" column="2" >
<widget class="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" >
@ -363,11 +292,92 @@
</property>
</widget>
</item>
<item row="3" column="2" >
<widget class="LengthCombo" name="heightUnitsLC" >
<item row="1" column="0" >
<widget class="QLabel" name="innerBoxLA" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>Inner Bo&amp;x:</string>
</property>
<property name="buddy" >
<cstring>innerBoxCO</cstring>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="LengthCombo" name="widthUnitsLC" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="typeLA" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>&amp;Decoration:</string>
</property>
<property name="buddy" >
<cstring>typeCO</cstring>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="widthLA" >
<property name="toolTip" >
<string/>
</property>
<property name="text" >
<string>&amp;Width:</string>
</property>
<property name="buddy" >
<cstring>widthED</cstring>
</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 &amp; 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>

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>202</width>
<height>208</height>
<height>184</height>
</rect>
</property>
<property name="windowTitle" >
@ -17,21 +17,11 @@
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>11</number>
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QPushButton" name="okPB" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QPushButton" name="closePB" >
<property name="text" >
@ -42,6 +32,16 @@
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QPushButton" name="okPB" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="default" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2" >
<widget class="QGroupBox" name="NoteBG" >
<property name="title" >
@ -84,44 +84,21 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="framedRB" >
<property name="toolTip" >
<string>Framed in box</string>
</property>
<property name="text" >
<string>&amp;Framed</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="shadedRB" >
<property name="toolTip" >
<string>Box with shaded background</string>
</property>
<property name="text" >
<string>&amp;Shaded</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<tabstops>
<tabstop>noteRB</tabstop>
<tabstop>commentRB</tabstop>
<tabstop>greyedoutRB</tabstop>
<tabstop>framedRB</tabstop>
<tabstop>shadedRB</tabstop>
<tabstop>okPB</tabstop>
<tabstop>closePB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<resources/>
<connections/>
</ui>

View File

@ -49,9 +49,11 @@ BoxTranslator const init_boxtranslator()
{
BoxTranslator translator("Boxed", InsetBox::Boxed);
translator.addPair("Frameless", InsetBox::Frameless);
translator.addPair("Framed", InsetBox::Framed);
translator.addPair("ovalbox", InsetBox::ovalbox);
translator.addPair("Ovalbox", InsetBox::Ovalbox);
translator.addPair("Shadowbox", InsetBox::Shadowbox);
translator.addPair("Shaded", InsetBox::Shaded);
translator.addPair("Doublebox",InsetBox::Doublebox);
return translator;
}
@ -59,12 +61,14 @@ BoxTranslator const init_boxtranslator()
BoxTranslatorLoc const init_boxtranslator_loc()
{
BoxTranslatorLoc translator(_("Boxed"), InsetBox::Boxed);
translator.addPair(_("Frameless"), InsetBox::Frameless);
translator.addPair(_("ovalbox"), InsetBox::ovalbox);
translator.addPair(_("Ovalbox"), InsetBox::Ovalbox);
translator.addPair(_("Shadowbox"), InsetBox::Shadowbox);
translator.addPair(_("Doublebox"), InsetBox::Doublebox);
BoxTranslatorLoc translator(_("simple frame"), InsetBox::Boxed);
translator.addPair(_("frameless"), InsetBox::Frameless);
translator.addPair(_("simple frame, page breaks"), InsetBox::Framed);
translator.addPair(_("oval, thin"), InsetBox::ovalbox);
translator.addPair(_("oval, thick"), InsetBox::Ovalbox);
translator.addPair(_("drop shadow"), InsetBox::Shadowbox);
translator.addPair(_("shaded background"), InsetBox::Shaded);
translator.addPair(_("double frame"), InsetBox::Doublebox);
return translator;
}
@ -113,6 +117,16 @@ docstring const InsetBox::editMessage() const
}
docstring InsetBox::name() const
{
// FIXME: UNICODE
string name = string("Box");
if (boxtranslator().find(params_.type) == Shaded)
name += string(":Shaded");
return from_ascii(name);
}
void InsetBox::write(Buffer const & buf, ostream & os) const
{
params_.write(os);
@ -244,8 +258,10 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
stdwidth = true;
switch (btype) {
case Frameless:
case Framed:
break;
case Boxed:
case Shaded:
width_string += " - 2\\fboxsep - 2\\fboxrule";
break;
case ovalbox:
@ -273,6 +289,10 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
switch (btype) {
case Frameless:
break;
case Framed:
os << "\\begin{framed}%\n";
i += 1;
break;
case Boxed:
os << "\\framebox";
if (!params_.inner_box) {
@ -301,6 +321,9 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
case Shadowbox:
os << "\\shadowbox{";
break;
case Shaded:
// later
break;
case Doublebox:
os << "\\doublebox{";
break;
@ -341,9 +364,15 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
os << "%\n";
i += 1;
}
if (btype == Shaded)
os << "\\begin{shaded}%\n";
i += 1;
i += InsetText::latex(buf, os, runparams);
if (btype == Shaded)
os << "\\end{shaded}";
if (params_.inner_box) {
if (params_.use_parbox)
os << "%\n}";
@ -354,6 +383,9 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
switch (btype) {
case Frameless:
break;
case Framed:
os << "\\end{framed}";
break;
case Boxed:
if (!params_.inner_box)
os << "}"; // for makebox
@ -365,6 +397,9 @@ int InsetBox::latex(Buffer const & buf, odocstream & os,
case Shadowbox:
os << "}";
break;
case Shaded:
// already done
break;
}
os << "%\n";
@ -380,24 +415,56 @@ int InsetBox::plaintext(Buffer const & buf, odocstream & os,
BoxType const btype = boxtranslator().find(params_.type);
switch (btype) {
case Frameless: break;
case Boxed: os << "[\n"; break;
case ovalbox: os << "(\n"; break;
case Ovalbox: os << "((\n"; break;
case Shadowbox: os << "[/\n"; break;
case Doublebox: os << "[[\n"; break;
case Frameless:
break;
case Framed:
case Boxed:
os << "[\n";
break;
case ovalbox:
os << "(\n";
break;
case Ovalbox:
os << "((\n";
break;
case Shadowbox:
case Shaded:
os << "[/\n";
break;
case Doublebox:
os << "[[\n";
break;
}
InsetText::plaintext(buf, os, runparams);
int len = 0;
switch (btype) {
case Frameless: os << "\n"; break;
case Boxed: os << "\n]"; len = 1; break;
case ovalbox: os << "\n)"; len = 1; break;
case Ovalbox: os << "\n))"; len = 2; break;
case Shadowbox: os << "\n/]"; len = 2; break;
case Doublebox: os << "\n]]"; len = 2; break;
case Frameless:
os << "\n";
break;
case Framed:
case Boxed:
os << "\n]";
len = 1;
break;
case ovalbox:
os << "\n)";
len = 1;
break;
case Ovalbox:
os << "\n))";
len = 2;
break;
case Shadowbox:
case Shaded:
os << "\n/]";
len = 2;
break;
case Doublebox:
os << "\n]]";
len = 2;
break;
}
return PLAINTEXT_NEWLINE + len; // len chars on a separate line
@ -417,6 +484,9 @@ void InsetBox::validate(LaTeXFeatures & features) const
switch (btype) {
case Frameless:
break;
case Framed:
features.require("framed");
break;
case Boxed:
features.require("calc");
break;
@ -427,6 +497,10 @@ void InsetBox::validate(LaTeXFeatures & features) const
features.require("calc");
features.require("fancybox");
break;
case Shaded:
features.require("color");
features.require("framed");
break;
}
InsetText::validate(features);
}

View File

@ -66,6 +66,8 @@ public:
///
InsetCode lyxCode() const { return BOX_CODE; }
///
docstring name() const;
///
void write(Buffer const &, std::ostream &) const;
///
void read(Buffer const & buf, Lexer & lex);
@ -99,9 +101,11 @@ public:
enum BoxType {
Frameless,
Boxed,
Framed,
ovalbox,
Ovalbox,
Shadowbox,
Shaded,
Doublebox
};
protected:
@ -109,8 +113,6 @@ protected:
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// Is the width forced to some value?
virtual bool hasFixedWidth() const;
///
virtual docstring name() const { return from_ascii("Box"); }
private:
friend class InsetBoxParams;

View File

@ -57,8 +57,6 @@ NoteTranslator const init_notetranslator()
NoteTranslator translator("Note", InsetNoteParams::Note);
translator.addPair("Comment", InsetNoteParams::Comment);
translator.addPair("Greyedout", InsetNoteParams::Greyedout);
translator.addPair("Framed", InsetNoteParams::Framed);
translator.addPair("Shaded", InsetNoteParams::Shaded);
return translator;
}
@ -68,8 +66,6 @@ NoteTranslatorLoc const init_notetranslator_loc()
NoteTranslatorLoc translator(_("Note"), InsetNoteParams::Note);
translator.addPair(_("Comment"), InsetNoteParams::Comment);
translator.addPair(_("Greyed out"), InsetNoteParams::Greyedout);
translator.addPair(_("Framed"), InsetNoteParams::Framed);
translator.addPair(_("Shaded"), InsetNoteParams::Shaded);
return translator;
}
@ -151,13 +147,7 @@ docstring InsetNote::name() const
Inset::DisplayType InsetNote::display() const
{
switch (params_.type) {
case InsetNoteParams::Framed:
case InsetNoteParams::Shaded:
return AlignLeft;
default:
return Inline;
}
return Inline;
}
@ -323,12 +313,6 @@ void InsetNote::validate(LaTeXFeatures & features) const
features.require("color");
features.require("lyxgreyedout");
}
if (params_.type == InsetNoteParams::Shaded) {
features.require("color");
features.require("framed");
}
if (params_.type == InsetNoteParams::Framed)
features.require("framed");
InsetText::validate(features);
}

View File

@ -23,9 +23,7 @@ public:
enum Type {
Note,
Comment,
Greyedout,
Framed,
Shaded
Greyedout
};
/// \c type defaults to Note
InsetNoteParams();
@ -53,7 +51,7 @@ public:
InsetCode lyxCode() const { return NOTE_CODE; }
///
docstring name() const;
/// framed and shaded notes are displayed
///
virtual DisplayType display() const;
///
void write(Buffer const &, std::ostream &) const;