case LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS:
case LyXRC::RC_LANGUAGE_PACKAGE:
case LyXRC::RC_LANGUAGE_USE_BABEL:
+ case LyXRC::RC_MACRO_EDIT_STYLE:
case LyXRC::RC_MAKE_BACKUP:
case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
case LyXRC::RC_NUMLASTFILES:
case LyXRC::RC_SERVERPIPE:
case LyXRC::RC_SET_COLOR:
case LyXRC::RC_SHOW_BANNER:
- case LyXRC::RC_SHOW_MACRO_LABEL:
case LyXRC::RC_SPELL_COMMAND:
case LyXRC::RC_TEMPDIRPATH:
case LyXRC::RC_TEMPLATEPATH:
{ "\\serverpipe", LyXRC::RC_SERVERPIPE },
{ "\\set_color", LyXRC::RC_SET_COLOR },
{ "\\show_banner", LyXRC::RC_SHOW_BANNER },
- { "\\show_macro_label", LyXRC::RC_SHOW_MACRO_LABEL },
+ { "\\macro_edit_style", LyXRC::RC_MACRO_EDIT_STYLE },
{ "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
{ "\\spell_command", LyXRC::RC_SPELL_COMMAND },
{ "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
tex_allows_spaces = false;
date_insert_format = "%x";
cursor_follows_scrollbar = false;
- show_macro_label = true;
+ macro_edit_style = MACRO_EDIT_INLINE_BOX;
dialogs_iconify_with_main = false;
label_init_length = 3;
preview = PREVIEW_OFF;
}
break;
- case RC_SHOW_MACRO_LABEL:
+ case RC_MACRO_EDIT_STYLE:
if (lexrc.next()) {
- show_macro_label = lexrc.getBool();
+ switch (lexrc.getInteger()) {
+ case 0: macro_edit_style = MACRO_EDIT_INLINE_BOX; break;
+ case 1: macro_edit_style = MACRO_EDIT_INLINE; break;
+ case 2: macro_edit_style = MACRO_EDIT_LIST; break;
+ }
}
break;
}
if (tag != RC_LAST)
break;
- case RC_SHOW_MACRO_LABEL:
+ case RC_MACRO_EDIT_STYLE:
if (ignore_system_lyxrc ||
- show_macro_label
- != system_lyxrc.show_macro_label) {
- os << "\\show_macro_label "
- << convert<string>(show_macro_label) << '\n';
+ macro_edit_style
+ != system_lyxrc.macro_edit_style) {
+ os << "\\macro_edit_style ";
+ switch (macro_edit_style) {
+ case MACRO_EDIT_INLINE_BOX: os << "0\n"; break;
+ case MACRO_EDIT_INLINE: os << "1\n"; break;
+ case MACRO_EDIT_LIST: os << "2\n"; break;
+ }
}
if (tag != RC_LAST)
break;
RC_SORT_LAYOUTS,
RC_USELASTFILEPOS,
RC_LOADSESSION,
+ RC_MACRO_EDIT_STYLE,
RC_MAKE_BACKUP,
RC_MARK_FOREIGN_LANGUAGE,
RC_NUMLASTFILES,
RC_SERVERPIPE,
RC_SET_COLOR,
RC_SHOW_BANNER,
- RC_SHOW_MACRO_LABEL,
RC_SPELL_COMMAND,
RC_TEMPDIRPATH,
RC_TEMPLATEPATH,
///
bool cursor_follows_scrollbar;
///
- bool show_macro_label;
+ enum MacroEditStyle {
+ MACRO_EDIT_INLINE_BOX = 0,
+ MACRO_EDIT_INLINE,
+ MACRO_EDIT_LIST
+ };
+ ///
+ MacroEditStyle macro_edit_style;
///
bool dialogs_iconify_with_main;
///
this, SIGNAL(changed()));
connect(sortEnvironmentsCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
- connect(showMacroLabelCB, SIGNAL(clicked()),
+ connect(macroEditStyleCO, SIGNAL(activated(int)),
this, SIGNAL(changed()));
connect(autoSaveSB, SIGNAL(valueChanged(int)),
this, SIGNAL(changed()));
rc.allow_geometry_session = allowGeometrySessionCB->isChecked();
rc.cursor_follows_scrollbar = cursorFollowsCB->isChecked();
rc.sort_layouts = sortEnvironmentsCB->isChecked();
- rc.show_macro_label = showMacroLabelCB->isChecked();
+ switch (macroEditStyleCO->currentIndex()) {
+ case 0: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE_BOX; break;
+ case 1: rc.macro_edit_style = LyXRC::MACRO_EDIT_INLINE; break;
+ case 2: rc.macro_edit_style = LyXRC::MACRO_EDIT_LIST; break;
+ }
rc.autosave = autoSaveSB->value() * 60;
rc.make_backup = autoSaveCB->isChecked();
rc.num_lastfiles = lastfilesSB->value();
allowGeometrySessionCB->setChecked(rc.allow_geometry_session);
cursorFollowsCB->setChecked(rc.cursor_follows_scrollbar);
sortEnvironmentsCB->setChecked(rc.sort_layouts);
- showMacroLabelCB->setChecked(rc.show_macro_label);
+ macroEditStyleCO->setCurrentIndex(rc.macro_edit_style);
// convert to minutes
int mins(rc.autosave / 60);
if (rc.autosave && !mins)
</widget>
</item>
<item row="2" column="0" >
- <widget class="QCheckBox" name="showMacroLabelCB" >
- <property name="text" >
- <string>Show a box with the macro name around Math Macros</string>
- </property>
+ <widget class="QComboBox" name="macroEditStyleCO" >
+ <item>
+ <property name="text" >
+ <string>Edit Math Macros inline with a box around</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Edit Math Macros inline with the name in the status bar</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Edit Math Macros with a parameter list (like in LyX < 1.6)</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
<tabstop>uiFileED</tabstop>
<tabstop>uiFilePB</tabstop>
<tabstop>tooltipCB</tabstop>
- <tabstop>allowGeometrySessionCB</tabstop>
<tabstop>restoreCursorCB</tabstop>
+ <tabstop>allowGeometrySessionCB</tabstop>
<tabstop>loadSessionCB</tabstop>
<tabstop>autoSaveCB</tabstop>
<tabstop>autoSaveSB</tabstop>
<tabstop>lastfilesSB</tabstop>
<tabstop>cursorFollowsCB</tabstop>
<tabstop>sortEnvironmentsCB</tabstop>
- <tabstop>showMacroLabelCB</tabstop>
+ <tabstop>macroEditStyleCO</tabstop>
<tabstop>pixmapCacheCB</tabstop>
</tabstops>
<includes>
dim.asc = max(bsdim.ascent(), dim.ascent());
dim.des = max(bsdim.descent(), dim.descent());
metricsMarkers(dim);
+ } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST
+ && editing_[mi.base.bv]) {
+ // Macro will be edited in a old-style list mode here:
+
+ BOOST_ASSERT(macro_ != 0);
+ Dimension fontDim;
+ FontInfo labelFont = sane_font;
+ math_font_max_dim(labelFont, fontDim.asc, fontDim.des);
+
+ // get dimension of components of list view
+ Dimension nameDim;
+ nameDim.wid = mathed_string_width(mi.base.font, from_ascii("Macro \\") + name() + ": ");
+ nameDim.asc = fontDim.asc;
+ nameDim.des = fontDim.des;
+
+ Dimension argDim;
+ argDim.wid = mathed_string_width(labelFont, from_ascii("#9: "));
+ argDim.asc = fontDim.asc;
+ argDim.des = fontDim.des;
+
+ Dimension defDim;
+ definition_.metrics(mi, defDim);
+
+ // add them up
+ dim.wid = nameDim.wid + defDim.wid;
+ dim.asc = max(nameDim.asc, defDim.asc);
+ dim.des = max(nameDim.des, defDim.des);
+
+ for (idx_type i = 0; i < nargs(); ++i) {
+ Dimension cdim;
+ cell(i).metrics(mi, cdim);
+ dim.des += max(argDim.height(), cdim.height()) + 1;
+ dim.wid = max(dim.wid, argDim.wid + cdim.wid);
+ }
+
+ // make space for box and markers, 2 pixels
+ dim.asc += 1;
+ dim.des += 1;
+ dim.wid += 2;
+ metricsMarkers2(dim);
} else {
BOOST_ASSERT(macro_ != 0);
macro_->unlock();
// calculate dimension with label while editing
- if (lyxrc.show_macro_label && editing_[mi.base.bv]) {
+ if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX
+ && editing_[mi.base.bv]) {
FontInfo font = mi.base.font;
augmentFont(font, from_ascii("lyxtex"));
Dimension namedim;
dim.asc += 1 + namedim.height() + 1;
dim.des += 2;
}
+
}
}
// expanding macro with the values
macro_->expand(values, expanded_.cell(0));
+
+ // get definition for list edit mode
+ docstring const & display = macro_->display();
+ asArray(display.empty() ? macro_->definition() : display, definition_);
}
}
x += mathed_string_width(pi2.base.font, from_ascii("\\")) + 1;
cell(0).draw(pi2, x, y);
drawMarkers(pi2, expx, expy);
+ } else if (lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_LIST
+ && editing_[pi.base.bv]) {
+ // Macro will be edited in a old-style list mode here:
+
+ CoordCache & coords = pi.base.bv->coordCache();
+ FontInfo const & labelFont = sane_font;
+
+ // markers and box needs two pixels
+ x += 2;
+
+ // get maximal font height
+ Dimension fontDim;
+ math_font_max_dim(pi.base.font, fontDim.asc, fontDim.des);
+
+ // draw label
+ docstring label = from_ascii("Macro \\") + name() + from_ascii(": ");
+ pi.pain.text(x, y, label, labelFont);
+ x += mathed_string_width(labelFont, label);
+
+ // draw definition
+ definition_.draw(pi, x, y);
+ Dimension defDim
+ = coords.arrays().dim(&definition_);
+ y += max(fontDim.des, defDim.des);
+
+ // draw parameters
+ docstring str = from_ascii("#9");
+ int strw1 = mathed_string_width(labelFont, from_ascii("#9"));
+ int strw2 = mathed_string_width(labelFont, from_ascii(": "));
+
+ for (idx_type i = 0; i < nargs(); ++i) {
+ // position of label
+ Dimension cdim
+ = coords.arrays().dim(&cell(i));
+ x = expx + 2;
+ y += max(fontDim.asc, cdim.asc) + 1;
+
+ // draw label
+ str[1] = '1' + i;
+ pi.pain.text(x, y, str, labelFont);
+ x += strw1;
+ pi.pain.text(x, y, from_ascii(":"), labelFont);
+ x += strw2;
+
+ // draw paramter
+ cell(i).draw(pi, x, y);
+
+ // next line
+ y += max(fontDim.des, cdim.des);
+ }
+
+ pi.pain.rectangle(expx + 1, expy - dim.asc + 1, dim.wid - 3,
+ dim.height() - 2, Color_mathmacroframe);
+ drawMarkers2(pi, expx, expy);
} else {
+ bool drawBox = lyxrc.macro_edit_style == LyXRC::MACRO_EDIT_INLINE_BOX;
+
// warm up cells
for (size_t i = 0; i < nargs(); ++i)
cell(i).setXY(*pi.base.bv, x, y);
- if (lyxrc.show_macro_label && editing_[pi.base.bv]) {
+ if (drawBox && editing_[pi.base.bv]) {
// draw header and rectangle around
FontInfo font = pi.base.font;
augmentFont(font, from_ascii("lyxtex"));
expanded_.cell(0).draw(pi, expx, expy);
pi.pain.leaveMonochromeMode();
- if (lyxrc.show_macro_label)
+ if (drawBox)
pi.pain.rectangle(x, y - dim.asc, dim.wid,
dim.height(), Color_mathmacroframe);
} else
expanded_.cell(0).draw(pi, expx, expy);
- if (!lyxrc.show_macro_label)
+ if (!drawBox)
drawMarkers(pi, x, y);
}
DisplayMode displayMode_;
/// expanded macro with ArgumentProxies
InsetMathSqrt expanded_;
+ /// editing look of macro
+ MathData definition_;
/// number of arguments that were really attached
size_t attachedArgsNum_;
/// optional argument attached? (only in DISPLAY_NORMAL mode)