-----------------------
+2010-07-03 Uwe Stöhr <uwestoehr@web.de>
+ * Format incremented to 394: support for makebox;
+ new box parameter \use_makebox
+
2010-06-07 Richard Heck <rgheck@comcast.net>
* Format incremented to 393 (r34619)
Renaming in LyX format: \begin_inset OptArg becomes
return
document.body[i] = "\\begin_inset OptArg"
i += 1
-
+
+
+def revert_makebox(document):
+ " Convert \\makebox to ERT "
+ i = 0
+ while 1:
+ # only revert frameless boxes without an inner box
+ i = find_token(document.body, '\\begin_inset Box Frameless', i)
+ if i == -1:
+ return
+ else:
+ z = find_end_of_inset(document.body, i)
+ if z == -1:
+ document.warning("Malformed LyX document: Can't find end of box inset.")
+ return
+ j = find_token(document.body, 'use_makebox 1', i)
+ # assure we found the makebox of the current box
+ if j > i + 7 or j == -1:
+ return
+ else:
+ # remove the \end_inset
+ document.body[z - 2:z + 1] = put_cmd_in_ert("}")
+ # determine the alignment
+ k = find_token(document.body, 'hor_pos', j - 4)
+ align = document.body[k][9]
+ # determine the width
+ l = find_token(document.body, 'width "', j + 1)
+ length = document.body[l][7:]
+ # remove trailing '"'
+ length = length[:-1]
+ # latex_length returns "bool,length"
+ length = latex_length(length).split(",")[1]
+ subst = "\\makebox[" + length + "][" \
+ + align + "]{"
+ document.body[i:i+13] = put_cmd_in_ert(subst)
+ i += 1
+
+
##
# Conversion hub
#
[390, []],
[391, []],
[392, [convert_beamer_args]],
- [393, [convert_optarg]]
+ [393, [convert_optarg]],
+ [394, []]
]
-revert = [[392, [revert_argument]],
+revert = [[393, [revert_makebox]],
+ [392, [revert_argument]],
[391, [revert_beamer_args]],
[390, [revert_align_decimal]],
[389, [revert_output_sync]],
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-int const LYX_FORMAT = 393; // rgh: rename OptArg to Argument in LyX format
+int const LYX_FORMAT = 394; // uwestoehr: support for \makebox
typedef map<string, bool> DepClean;
typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
void GuiBox::on_innerBoxCO_activated(int index)
{
+ QString itype =
+ innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
+ // handle parbox and minipage the same way
bool const ibox =
- (innerBoxCO->itemData(index).toString() != "none");
+ (itype != "none"
+ && itype != "makebox");
QString const outer =
typeCO->itemData(typeCO->currentIndex()).toString();
valignCO->setEnabled(ibox);
ialignCO->setEnabled(ibox);
+ if (heightCB->isChecked() && !ibox)
+ heightCB->setChecked(false);
heightCB->setEnabled(ibox);
// except for frameless and boxed, the width cannot be specified if
// there is no inner box
outer != "Boxed");
widthED->setEnabled(!width_disabled);
widthUnitsLC->setEnabled(!width_disabled);
- // halign and pagebreak are only allowed for Boxed without inner box
- halignCO->setEnabled(!ibox && outer == "Boxed");
+ // halign is only allowed for Boxed without inner box or for makebox
+ halignCO->setEnabled((!ibox && outer == "Boxed")
+ || (itype == "makebox"));
+ // pagebreak is only allowed for Boxed without inner box
pagebreakCB->setEnabled(!ibox && outer == "Boxed");
setSpecial(ibox);
changed();
QString const type =
typeCO->itemData(index).toString();
bool const frameless = (type == "Frameless");
- if (frameless) {
- valignCO->setEnabled(true);
- ialignCO->setEnabled(true);
- heightCB->setEnabled(true);
- setSpecial(true);
- }
- if (type != "Boxed")
- pagebreakCB->setChecked(false);
QString itype =
innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
+ setInnerType(frameless, itype);
+ // refresh itype because it might have been changed in setInnerType
+ itype =
+ innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
+ // handle parbox and minipage the same way
+ bool const ibox =
+ (itype != "none"
+ && itype != "makebox");
+ if (frameless && itype != "makebox") {
+ valignCO->setEnabled(ibox);
+ ialignCO->setEnabled(ibox);
+ if (heightCB->isChecked() && !ibox)
+ heightCB->setChecked(false);
+ heightCB->setEnabled(ibox);
+ setSpecial(ibox);
+ }
// except for frameless and boxed, the width cannot be specified if
// there is no inner box
bool const width_disabled = (itype == "none" && !frameless
&& type != "Boxed");
widthED->setEnabled(!width_disabled);
widthUnitsLC->setEnabled(!width_disabled);
- // halign and pagebreak are only allowed for Boxed without inner box
- halignCO->setEnabled(type == "Boxed" && itype == "none");
+ // halign is only allowed for Boxed without inner box or for makebox
+ halignCO->setEnabled((type == "Boxed" && itype == "none") || (itype == "makebox"));
+ // pagebreak is only allowed for Boxed without inner box
pagebreakCB->setEnabled(type == "Boxed" && itype == "none");
- setInnerType(frameless, itype);
changed();
}
inner_type = "none";
if (params.use_parbox)
inner_type = "parbox";
+ if (params.use_makebox)
+ inner_type = "makebox";
bool const frameless = (params.type == "Frameless");
setInnerType(frameless, inner_type);
c = params.hor_pos;
halignCO->setCurrentIndex(string("lcrs").find(c, 0));
- bool ibox = params.inner_box;
+ bool ibox = (params.inner_box && !params.use_makebox);
valignCO->setEnabled(ibox);
ialignCO->setEnabled(ibox);
setSpecial(ibox);
// halign and pagebreak are only allowed for Boxed without inner box
- halignCO->setEnabled(!ibox && type == "Boxed");
+ halignCO->setEnabled((!ibox && type == "Boxed") || (params.use_makebox));
+ // pagebreak is only allowed for Boxed without inner box
pagebreakCB->setEnabled(!ibox && type == "Boxed");
// except for frameless and boxed, the width cannot be specified if
(!pagebreak && innerBoxCO->currentText() != qt_("None"));
params.use_parbox =
(!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
+ params.use_makebox =
+ (!pagebreak && innerBoxCO->currentText() == qt_("Makebox"));
params.pos = "tcb"[valignCO->currentIndex()];
params.inner_pos = "tcbs"[ialignCO->currentIndex()];
innerBoxCO->clear();
if (!frameless)
innerBoxCO->addItem(qt_("None"), toqstr("none"));
+ else
+ innerBoxCO->addItem(qt_("Makebox"), toqstr("makebox"));
innerBoxCO->addItem(qt_("Parbox"), toqstr("parbox"));
innerBoxCO->addItem(qt_("Minipage"), toqstr("minipage"));
int i = (innerBoxCO->findData(type) != -1)
if (params_.inner_box) {
if (params_.use_parbox)
inner = _("Parbox");
+ else if (params_.use_makebox)
+ inner = _("Makebox");
else
inner = _("Minipage");
}
if (params_.hor_pos != 'c')
os << "[" << params_.hor_pos << "]";
}
-
os << "{";
break;
case ovalbox:
if (params_.inner_box) {
if (params_.use_parbox)
os << "\\parbox";
+ else if (params_.use_makebox) {
+ os << "\\makebox";
+ // FIXME UNICODE
+ // output the width and horizontal position
+ if (params_.special != "none") {
+ os << "[" << params_.width.value()
+ << '\\' << from_utf8(params_.special)
+ << ']';
+ } else
+ os << '[' << from_ascii(width_string)
+ << ']';
+ if (params_.hor_pos != 'c')
+ os << "[" << params_.hor_pos << "]";
+ os << "{";
+ }
else
os << "\\begin{minipage}";
- os << "[" << params_.pos << "]";
- if (params_.height_special == "none") {
- // FIXME UNICODE
- os << "[" << from_ascii(params_.height.asLatexString()) << "]";
- } else {
- // Special heights
- // set no optional argument when the value is the default "1\height"
- // (special units like \height are handled as "in")
- // but when the user has chosen a non-default inner_pos, the height
- // must be given: \minipage[pos][height][inner-pos]{width}
- if ((params_.height != Length("1in") ||
- params_.height_special != "totalheight") ||
- params_.inner_pos != params_.pos) {
+ // output parameters for parbox and minipage
+ if (!params_.use_makebox) {
+ os << "[" << params_.pos << "]";
+ if (params_.height_special == "none") {
// FIXME UNICODE
- os << "[" << params_.height.value()
- << "\\" << from_utf8(params_.height_special) << "]";
+ os << "[" << from_ascii(params_.height.asLatexString()) << "]";
+ } else {
+ // Special heights
+ // set no optional argument when the value is the default "1\height"
+ // (special units like \height are handled as "in")
+ // but when the user has chosen a non-default inner_pos, the height
+ // must be given: \minipage[pos][height][inner-pos]{width}
+ if ((params_.height != Length("1in") ||
+ params_.height_special != "totalheight") ||
+ params_.inner_pos != params_.pos) {
+ // FIXME UNICODE
+ os << "[" << params_.height.value()
+ << "\\" << from_utf8(params_.height_special) << "]";
+ }
}
+ if (params_.inner_pos != params_.pos)
+ os << "[" << params_.inner_pos << "]";
+ // FIXME UNICODE
+ os << '{' << from_ascii(width_string) << '}';
+ if (params_.use_parbox)
+ os << "{";
}
- if (params_.inner_pos != params_.pos)
- os << "[" << params_.inner_pos << "]";
-
- // FIXME UNICODE
- os << '{' << from_ascii(width_string) << '}';
- if (params_.use_parbox)
- os << "{";
os << "%\n";
++i;
- }
+ } // end if inner_box
+
if (btype == Shaded) {
os << "\\begin{shaded}%\n";
++i;
os << "\\end{shaded}";
if (params_.inner_box) {
- if (params_.use_parbox)
+ if (params_.use_parbox || params_.use_makebox)
os << "%\n}";
else
os << "%\n\\end{minipage}";
InsetBoxParams::InsetBoxParams(string const & label)
: type(label),
use_parbox(false),
+ use_makebox(false),
inner_box(true),
width(Length("100col%")),
special("none"),
os << "has_inner_box " << inner_box << "\n";
os << "inner_pos \"" << inner_pos << "\"\n";
os << "use_parbox " << use_parbox << "\n";
+ os << "use_makebox " << use_makebox << "\n";
os << "width \"" << width.asString() << "\"\n";
os << "special \"" << special << "\"\n";
os << "height \"" << height.asString() << "\"\n";
inner_box = false;
lex >> "inner_pos" >> inner_pos;
lex >> "use_parbox" >> use_parbox;
+ lex >> "use_makebox" >> use_makebox;
lex >> "width" >> width;
lex >> "special" >> special;
lex >> "height" >> height;
///
std::string type;
- /// Use a parbox (true) or minipage (false)
+ /// Is there a parbox?
bool use_parbox;
+ /// Is there a makebox?
+ bool use_makebox;
/// Do we have an inner parbox or minipage to format paragraphs to
/// columnwidth?
bool inner_box;