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;
}
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
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'")),