InsetMathHull::InsetMathHull(Buffer * buf)
: InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NUMBER),
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
- preview_(new RenderPreview(this)), use_preview_(false)
+ preview_(new RenderPreview(this))
{
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
: InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, NUMBER),
numbers_(1, empty_docstring()), label_(1, dummy_pointer),
- preview_(new RenderPreview(this)), use_preview_(false)
+ preview_(new RenderPreview(this))
{
buffer_ = buf;
initMath();
Inset * InsetMathHull::editXY(Cursor & cur, int x, int y)
{
- if (use_preview_) {
+ if (previewState(&cur.bv())) {
edit(cur, true);
return this;
}
}
-//FIXME: This has probably no effect and can be removed.\r
char InsetMathHull::defaultColAlign(col_type col)
{
- return colAlign(type_, col);\r
+ if (type_ == hullEqnArray)
+ return "rcl"[col];
+ if (type_ == hullMultline)
+ return 'c';
+ if (type_ == hullGather)
+ return 'c';
+ if (type_ >= hullAlign)
+ return "rl"[col & 1];
+ return 'c';
}
char InsetMathHull::displayColAlign(idx_type idx) const
{
- switch (type_) {\r
- case hullMultline: {\r
+ if (type_ == hullMultline) {
row_type const r = row(idx);
if (r == 0)
return 'l';
if (r == nrows() - 1)
return 'r';
- return 'c';\r
- }\r
- case hullEqnArray:\r
- case hullGather:\r
- case hullAlign:\r
- case hullAlignAt:\r
- case hullXAlignAt:\r
- case hullXXAlignAt:\r
- case hullFlAlign:\r
- return colAlign(type_, col(idx));\r
- default:\r
- break;\r
}
return InsetMathGrid::displayColAlign(idx);
}
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
{
BufferView const * const bv = pi.base.bv;
- use_preview_ = previewState(bv);
if (type_ == hullRegexp) {
Dimension const dim = dimension(*bv);
dim.width() - 2, dim.height() - 2, Color_regexpframe);
}
- if (use_preview_) {
+ if (previewState(bv)) {
Dimension const dim = dimension(*bv);
if (previewTooSmall(dim)) {
// we have an extra frame
}
+bool InsetMathHull::isTable() const
+{
+ switch (type_) {
+ case hullEqnArray:
+ case hullAlign:
+ case hullAlignAt:
+ case hullXAlignAt:
+ case hullXXAlignAt:
+ case hullFlAlign:
+ case hullMultline:
+ case hullGather:
+ return true;
+ case hullNone:
+ case hullSimple:
+ case hullEquation:
+ case hullRegexp:
+ break;
+ }
+ return false;
+}
+
+
bool InsetMathHull::rowChangeOK() const
{
return
}
-bool InsetMathHull::isMutable(HullType type)\r
-{\r
- switch (type) {\r
- case hullNone:\r
- case hullSimple:\r
- case hullEquation:\r
- case hullEqnArray:\r
- case hullAlign:\r
- case hullFlAlign:\r
- case hullAlignAt:\r
- case hullXAlignAt:\r
- case hullXXAlignAt:\r
- case hullMultline:\r
- case hullGather:\r
- return true;\r
- default:\r
- return false;\r
- }\r
-}\r
-\r
-\r
void InsetMathHull::mutate(HullType newtype)
{
//lyxerr << "mutating from '" << type_ << "' to '" << newtype << "'" << endl;
break;
}
+ case LFUN_TABULAR_FEATURE:
+ if (!isTable())
+ cur.undispatched();
+ else
+ InsetMathGrid::doDispatch(cur, cmd);
+ break;
+
default:
InsetMathGrid::doDispatch(cur, cmd);
break;
}
return InsetMathGrid::getStatus(cur, cmd, status);
- case LFUN_INSET_MODIFY: {
- istringstream is(to_utf8(cmd.argument()));
- string s;
- is >> s;
- if (s != "tabular")
- return InsetMathGrid::getStatus(cur, cmd, status);
- is >> s;
+ case LFUN_TABULAR_FEATURE: {
+ if (!isTable())
+ return false;
+ string s = cmd.getArg(0);
if (!rowChangeOK()
&& (s == "append-row"
|| s == "delete-row"
status.setEnabled(false);
return true;
}
- if ((type_ == hullSimple
- || type_ == hullEquation
- || type_ == hullNone) &&
- (s == "add-hline-above" || s == "add-hline-below")) {
- status.message(bformat(
- from_utf8(N_("Can't add horizontal grid lines in '%1$s'")),
- hullName(type_)));
- status.setEnabled(false);
- return true;
- }
if (s == "add-vline-left" || s == "add-vline-right") {
status.message(bformat(
from_utf8(N_("Can't add vertical grid lines in '%1$s'")),