}
+// static
+char InsetMathGrid::colAlign(HullType type, col_type col)
+{
+ switch (type) {
+ case hullEqnArray:
+ return "rcl"[col % 3];
+
+ case hullMultline:
+ case hullGather:
+ return 'c';
+
+ case hullAlign:
+ case hullAlignAt:
+ case hullXAlignAt:
+ case hullXXAlignAt:
+ case hullFlAlign:
+ return "rl"[col & 1];
+
+ default:
+ return 'c';
+ }
+}
+
+
+
} // namespace lyx
virtual docstring eocString(col_type col, col_type lastcol) const;
/// splits cells and shifts right part to the next cell
void splitCell(Cursor & cur);
- /// Column aligmment for display of cell \p idx.
+ /// Column alignment for display of cell \p idx.
/// Must not be written to file!
virtual char displayColAlign(idx_type idx) const;
-
+ /// The value of a fixed col align for a certain hull type
+ static char colAlign(HullType type, col_type col);
/// row info.
/// rowinfo_[nrows()] is a dummy row used only for hlines.
}
+// FIXME: InsetMathGrid should be changed to let the real column alignment be
+// given by a virtual method like displayColAlign, because the values produced
+// by defaultColAlign can be invalidated by lfuns such as add-column. I suspect
+// that for the moment the values produced by defaultColAlign are not used,
+// notably because alignment is not implemented in the LyXHTML output.
char InsetMathHull::defaultColAlign(col_type col)
{
- 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';
+ return colAlign(type_, col);
}
char InsetMathHull::displayColAlign(idx_type idx) const
{
- if (type_ == hullMultline) {
+ switch (type_) {
+ case hullMultline: {
row_type const r = row(idx);
if (r == 0)
return 'l';
if (r == nrows() - 1)
return 'r';
+ return 'c';
+ }
+ case hullEqnArray:
+ case hullGather:
+ case hullAlign:
+ case hullAlignAt:
+ case hullXAlignAt:
+ case hullXXAlignAt:
+ case hullFlAlign:
+ return colAlign(type_, col(idx));
+ default:
+ break;
}
return InsetMathGrid::displayColAlign(idx);
}
}
+// FIXME: InsetMathGrid should be changed to let the real column alignment be
+// given by a virtual method like displayColAlign, because the values produced
+// by defaultColAlign can be invalidated by lfuns such as add-column. I suspect
+// that for the moment the values produced by defaultColAlign are not used,
+// notably because alignment is not implemented in the LyXHTML output.
char InsetMathSplit::defaultColAlign(col_type col)
{
- if (name_ == "split")
- return 'l';
if (name_ == "gathered")
return 'c';
- if (name_ == "aligned" || name_ == "align")
- return (col & 1) ? 'l' : 'r';
- if (name_ == "alignedat")
- return (col & 1) ? 'l' : 'r';
+ if (name_ == "lgathered")
+ return 'l';
+ if (name_ == "rgathered")
+ return 'r';
+ if (name_ == "split"
+ || name_ == "aligned"
+ || name_ == "align"
+ || name_ == "alignedat")
+ return colAlign(hullAlign, col);
return 'l';
}
+char InsetMathSplit::displayColAlign(idx_type idx) const
+{
+ if (name_ == "gathered")
+ return 'c';
+ if (name_ == "lgathered")
+ return 'l';
+ if (name_ == "rgathered")
+ return 'r';
+ if (name_ == "split"
+ || name_ == "aligned"
+ || name_ == "align"
+ || name_ == "alignedat")
+ return colAlign(hullAlign, col(idx));
+ return InsetMathGrid::displayColAlign(idx);
+}
+
+
void InsetMathSplit::draw(PainterInfo & pi, int x, int y) const
{
InsetMathGrid::draw(pi, x, y);
flag.setEnabled(false);
return true;
}
+ if (s == "align-left" || s == "align-center" || s == "align-right") {
+ flag.setEnabled(false);
+ return true;
+ }
break;
}
default:
///
char defaultColAlign(col_type);
///
+ char displayColAlign(idx_type idx) const;
+ ///
InsetCode lyxCode() const { return MATH_SPLIT_CODE; }
private: