mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 05:33:33 +00:00
cosmetics
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23759 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
5ffc0d19c1
commit
5e0121cf58
@ -39,12 +39,6 @@ InsetMathArray::InsetMathArray(docstring const & name, int m, int n,
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
InsetMathArray::InsetMathArray(docstring const & name, char valign,
|
|
||||||
docstring const & halign)
|
|
||||||
: InsetMathGrid(valign, halign), name_(name)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
|
InsetMathArray::InsetMathArray(docstring const & name, docstring const & str)
|
||||||
: InsetMathGrid(1, 1), name_(name)
|
: InsetMathGrid(1, 1), name_(name)
|
||||||
{
|
{
|
||||||
@ -105,9 +99,10 @@ void InsetMathArray::write(WriteStream & os) const
|
|||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << "\\begin{" << name_ << '}';
|
os << "\\begin{" << name_ << '}';
|
||||||
|
|
||||||
if (v_align_ == 't' || v_align_ == 'b')
|
char const v = verticalAlignment();
|
||||||
os << '[' << char(v_align_) << ']';
|
if (v == 't' || v == 'b')
|
||||||
os << '{' << halign() << "}\n";
|
os << '[' << v << ']';
|
||||||
|
os << '{' << horizontalAlignments() << "}\n";
|
||||||
|
|
||||||
InsetMathGrid::write(os);
|
InsetMathGrid::write(os);
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@ public:
|
|||||||
///
|
///
|
||||||
InsetMathArray(docstring const &, int m, int n,
|
InsetMathArray(docstring const &, int m, int n,
|
||||||
char valign, docstring const & halign);
|
char valign, docstring const & halign);
|
||||||
///
|
|
||||||
InsetMathArray(docstring const &, char valign, docstring const & halign);
|
|
||||||
/// convenience constructor from whitespace/newline separated data
|
/// convenience constructor from whitespace/newline separated data
|
||||||
InsetMathArray(docstring const &, docstring const & str);
|
InsetMathArray(docstring const &, docstring const & str);
|
||||||
///
|
///
|
||||||
|
@ -97,19 +97,6 @@ InsetMathGrid::ColInfo::ColInfo()
|
|||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
InsetMathGrid::InsetMathGrid(char v, docstring const & h)
|
|
||||||
: InsetMathNest(guessColumns(h)),
|
|
||||||
rowinfo_(2),
|
|
||||||
colinfo_(guessColumns(h) + 1),
|
|
||||||
cellinfo_(1 * guessColumns(h))
|
|
||||||
{
|
|
||||||
setDefaults();
|
|
||||||
valign(v);
|
|
||||||
halign(h);
|
|
||||||
//lyxerr << "created grid with " << ncols() << " columns" << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
InsetMathGrid::InsetMathGrid()
|
InsetMathGrid::InsetMathGrid()
|
||||||
: InsetMathNest(1),
|
: InsetMathNest(1),
|
||||||
rowinfo_(1 + 1),
|
rowinfo_(1 + 1),
|
||||||
@ -140,8 +127,8 @@ InsetMathGrid::InsetMathGrid(col_type m, row_type n, char v, docstring const & h
|
|||||||
v_align_(v)
|
v_align_(v)
|
||||||
{
|
{
|
||||||
setDefaults();
|
setDefaults();
|
||||||
valign(v);
|
setVerticalAlignment(v);
|
||||||
halign(h);
|
setHorizontalAlignments(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,7 +158,7 @@ void InsetMathGrid::setDefaults()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathGrid::halign(docstring const & hh)
|
void InsetMathGrid::setHorizontalAlignments(docstring const & hh)
|
||||||
{
|
{
|
||||||
col_type col = 0;
|
col_type col = 0;
|
||||||
for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it) {
|
for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it) {
|
||||||
@ -253,7 +240,7 @@ void InsetMathGrid::halign(docstring const & hh)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh) const
|
InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh)
|
||||||
{
|
{
|
||||||
col_type col = 0;
|
col_type col = 0;
|
||||||
for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it)
|
for (docstring::const_iterator it = hh.begin(); it != hh.end(); ++it)
|
||||||
@ -268,7 +255,7 @@ InsetMathGrid::col_type InsetMathGrid::guessColumns(docstring const & hh) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathGrid::halign(char h, col_type col)
|
void InsetMathGrid::setHorizontalAlignment(char h, col_type col)
|
||||||
{
|
{
|
||||||
colinfo_[col].align_ = h;
|
colinfo_[col].align_ = h;
|
||||||
if (!colinfo_[col].special_.empty()) {
|
if (!colinfo_[col].special_.empty()) {
|
||||||
@ -280,13 +267,13 @@ void InsetMathGrid::halign(char h, col_type col)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char InsetMathGrid::halign(col_type col) const
|
char InsetMathGrid::horizontalAlignment(col_type col) const
|
||||||
{
|
{
|
||||||
return colinfo_[col].align_;
|
return colinfo_[col].align_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
docstring InsetMathGrid::halign() const
|
docstring InsetMathGrid::horizontalAlignments() const
|
||||||
{
|
{
|
||||||
docstring res;
|
docstring res;
|
||||||
for (col_type col = 0; col < ncols(); ++col) {
|
for (col_type col = 0; col < ncols(); ++col) {
|
||||||
@ -302,13 +289,13 @@ docstring InsetMathGrid::halign() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathGrid::valign(char c)
|
void InsetMathGrid::setVerticalAlignment(char c)
|
||||||
{
|
{
|
||||||
v_align_ = c;
|
v_align_ = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char InsetMathGrid::valign() const
|
char InsetMathGrid::verticalAlignment() const
|
||||||
{
|
{
|
||||||
return v_align_;
|
return v_align_;
|
||||||
}
|
}
|
||||||
@ -1133,17 +1120,17 @@ void InsetMathGrid::doDispatch(Cursor & cur, FuncRequest & cmd)
|
|||||||
string s;
|
string s;
|
||||||
is >> s;
|
is >> s;
|
||||||
if (s == "valign-top")
|
if (s == "valign-top")
|
||||||
valign('t');
|
setVerticalAlignment('t');
|
||||||
else if (s == "valign-middle")
|
else if (s == "valign-middle")
|
||||||
valign('c');
|
setVerticalAlignment('c');
|
||||||
else if (s == "valign-bottom")
|
else if (s == "valign-bottom")
|
||||||
valign('b');
|
setVerticalAlignment('b');
|
||||||
else if (s == "align-left")
|
else if (s == "align-left")
|
||||||
halign('l', cur.col());
|
setHorizontalAlignment('l', cur.col());
|
||||||
else if (s == "align-right")
|
else if (s == "align-right")
|
||||||
halign('r', cur.col());
|
setHorizontalAlignment('r', cur.col());
|
||||||
else if (s == "align-center")
|
else if (s == "align-center")
|
||||||
halign('c', cur.col());
|
setHorizontalAlignment('c', cur.col());
|
||||||
else if (s == "append-row")
|
else if (s == "append-row")
|
||||||
for (int i = 0, n = extractInt(is); i < n; ++i)
|
for (int i = 0, n = extractInt(is); i < n; ++i)
|
||||||
addRow(cur.row());
|
addRow(cur.row());
|
||||||
@ -1398,12 +1385,14 @@ bool InsetMathGrid::getStatus(Cursor & cur, FuncRequest const & cmd,
|
|||||||
from_utf8(N_("Unknown tabular feature '%1$s'")), lyx::from_ascii(s)));
|
from_utf8(N_("Unknown tabular feature '%1$s'")), lyx::from_ascii(s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
status.setOnOff((s == "align-left" && halign(cur.col()) == 'l')
|
char const ha = horizontalAlignment(cur.col());
|
||||||
|| (s == "align-right" && halign(cur.col()) == 'r')
|
char const va = verticalAlignment();
|
||||||
|| (s == "align-center" && halign(cur.col()) == 'c')
|
status.setOnOff((s == "align-left" && ha == 'l')
|
||||||
|| (s == "valign-top" && valign() == 't')
|
|| (s == "align-right" && ha == 'r')
|
||||||
|| (s == "valign-bottom" && valign() == 'b')
|
|| (s == "align-center" && ha == 'c')
|
||||||
|| (s == "valign-middle" && valign() == 'm'));
|
|| (s == "valign-top" && va == 't')
|
||||||
|
|| (s == "valign-bottom" && va == 'b')
|
||||||
|
|| (s == "valign-middle" && va == 'm'));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// FIXME: What did this code do?
|
// FIXME: What did this code do?
|
||||||
|
@ -91,10 +91,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// sets nrows and ncols to 1
|
/// sets nrows and ncols to 1, vertical alingment to 'c'
|
||||||
InsetMathGrid();
|
InsetMathGrid();
|
||||||
/// constructor from columns description, creates one row
|
|
||||||
InsetMathGrid(char valign, docstring const & halign);
|
|
||||||
/// Note: columns first!
|
/// Note: columns first!
|
||||||
InsetMathGrid(col_type m, row_type n);
|
InsetMathGrid(col_type m, row_type n);
|
||||||
///
|
///
|
||||||
@ -113,18 +111,20 @@ public:
|
|||||||
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
||||||
///
|
///
|
||||||
void drawT(TextPainter & pi, int x, int y) const;
|
void drawT(TextPainter & pi, int x, int y) const;
|
||||||
|
/// extract number of columns from alignment string
|
||||||
|
static col_type guessColumns(docstring const & halign);
|
||||||
|
/// accepts some LaTeX column codes: p,m,!,@,M,<,>
|
||||||
|
void setHorizontalAlignments(docstring const & align);
|
||||||
///
|
///
|
||||||
void halign(docstring const & align);
|
void setHorizontalAlignment(char c, col_type col);
|
||||||
///
|
///
|
||||||
void halign(char c, col_type col);
|
char horizontalAlignment(col_type col) const;
|
||||||
///
|
///
|
||||||
char halign(col_type col) const;
|
docstring horizontalAlignments() const;
|
||||||
|
/// 't', 'b', or 'm'
|
||||||
|
void setVerticalAlignment(char c);
|
||||||
///
|
///
|
||||||
docstring halign() const;
|
char verticalAlignment() const;
|
||||||
///
|
|
||||||
void valign(char c);
|
|
||||||
///
|
|
||||||
char valign() const;
|
|
||||||
///
|
///
|
||||||
void vcrskip(Length const &, row_type row);
|
void vcrskip(Length const &, row_type row);
|
||||||
///
|
///
|
||||||
@ -219,7 +219,8 @@ public:
|
|||||||
//void octave(OctaveStream &) const;
|
//void octave(OctaveStream &) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
///
|
||||||
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
||||||
///
|
///
|
||||||
bool getStatus(Cursor & cur, FuncRequest const & cmd,
|
bool getStatus(Cursor & cur, FuncRequest const & cmd,
|
||||||
FuncStatus & flag) const;
|
FuncStatus & flag) const;
|
||||||
@ -232,8 +233,6 @@ protected:
|
|||||||
bool fragile) const;
|
bool fragile) const;
|
||||||
/// returns proper 'end of column' code for LaTeX
|
/// returns proper 'end of column' code for LaTeX
|
||||||
virtual docstring eocString(col_type col, col_type lastcol) const;
|
virtual docstring eocString(col_type col, col_type lastcol) const;
|
||||||
/// extract number of columns from alignment string
|
|
||||||
col_type guessColumns(docstring const & halign) const;
|
|
||||||
/// splits cells and shifts right part to the next cell
|
/// splits cells and shifts right part to the next cell
|
||||||
void splitCell(Cursor & cur);
|
void splitCell(Cursor & cur);
|
||||||
|
|
||||||
@ -245,13 +244,14 @@ protected:
|
|||||||
std::vector<ColInfo> colinfo_;
|
std::vector<ColInfo> colinfo_;
|
||||||
/// cell info
|
/// cell info
|
||||||
std::vector<CellInfo> cellinfo_;
|
std::vector<CellInfo> cellinfo_;
|
||||||
|
private:
|
||||||
///
|
///
|
||||||
char v_align_; // add approp. type
|
char v_align_; // add approp. type
|
||||||
private:
|
///
|
||||||
virtual Inset * clone() const;
|
Inset * clone() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,8 +90,8 @@ void InsetMathSplit::write(WriteStream & ws) const
|
|||||||
if (ws.fragile())
|
if (ws.fragile())
|
||||||
ws << "\\protect";
|
ws << "\\protect";
|
||||||
ws << "\\begin{" << name_ << '}';
|
ws << "\\begin{" << name_ << '}';
|
||||||
if (name_ != "split" && valign() != 'c')
|
if (name_ != "split" && verticalAlignment() != 'c')
|
||||||
ws << '[' << valign() << ']';
|
ws << '[' << verticalAlignment() << ']';
|
||||||
if (name_ == "alignedat")
|
if (name_ == "alignedat")
|
||||||
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
|
ws << '{' << static_cast<unsigned int>((ncols() + 1)/2) << '}';
|
||||||
InsetMathGrid::write(ws);
|
InsetMathGrid::write(ws);
|
||||||
|
@ -34,11 +34,6 @@ InsetMathTabular::InsetMathTabular(docstring const & name, int m, int n,
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
InsetMathTabular::InsetMathTabular(docstring const & name, char valign,
|
|
||||||
docstring const & halign)
|
|
||||||
: InsetMathGrid(valign, halign), name_(name)
|
|
||||||
{}
|
|
||||||
|
|
||||||
|
|
||||||
Inset * InsetMathTabular::clone() const
|
Inset * InsetMathTabular::clone() const
|
||||||
{
|
{
|
||||||
@ -75,9 +70,10 @@ void InsetMathTabular::write(WriteStream & os) const
|
|||||||
os << "\\protect";
|
os << "\\protect";
|
||||||
os << "\\begin{" << name_ << '}';
|
os << "\\begin{" << name_ << '}';
|
||||||
|
|
||||||
if (v_align_ == 't' || v_align_ == 'b')
|
char const v = verticalAlignment();
|
||||||
os << '[' << char(v_align_) << ']';
|
if (v == 't' || v == 'b')
|
||||||
os << '{' << halign() << "}\n";
|
os << '[' << v << ']';
|
||||||
|
os << '{' << horizontalAlignments() << "}\n";
|
||||||
|
|
||||||
InsetMathGrid::write(os);
|
InsetMathGrid::write(os);
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@ public:
|
|||||||
InsetMathTabular(docstring const &, int m, int n,
|
InsetMathTabular(docstring const &, int m, int n,
|
||||||
char valign, docstring const & halign);
|
char valign, docstring const & halign);
|
||||||
///
|
///
|
||||||
InsetMathTabular(docstring const &, char valign, docstring const & halign);
|
|
||||||
///
|
|
||||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||||
///
|
///
|
||||||
Dimension const dimension(BufferView const &) const;
|
Dimension const dimension(BufferView const &) const;
|
||||||
@ -49,7 +47,7 @@ public:
|
|||||||
void maple(MapleStream &) const;
|
void maple(MapleStream &) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual Inset * clone() const;
|
Inset * clone() const;
|
||||||
///
|
///
|
||||||
docstring name_;
|
docstring name_;
|
||||||
};
|
};
|
||||||
|
@ -1299,14 +1299,16 @@ void Parser::parse1(InsetMathGrid & grid, unsigned flags,
|
|||||||
if (name == "array" || name == "subarray") {
|
if (name == "array" || name == "subarray") {
|
||||||
docstring const valign = parse_verbatim_option() + 'c';
|
docstring const valign = parse_verbatim_option() + 'c';
|
||||||
docstring const halign = parse_verbatim_item();
|
docstring const halign = parse_verbatim_item();
|
||||||
cell->push_back(MathAtom(new InsetMathArray(name, (char)valign[0], halign)));
|
cell->push_back(MathAtom(new InsetMathArray(name,
|
||||||
|
InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
|
||||||
parse2(cell->back(), FLAG_END, mode, false);
|
parse2(cell->back(), FLAG_END, mode, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (name == "tabular") {
|
else if (name == "tabular") {
|
||||||
docstring const valign = parse_verbatim_option() + 'c';
|
docstring const valign = parse_verbatim_option() + 'c';
|
||||||
docstring const halign = parse_verbatim_item();
|
docstring const halign = parse_verbatim_item();
|
||||||
cell->push_back(MathAtom(new InsetMathTabular(name, (char)valign[0], halign)));
|
cell->push_back(MathAtom(new InsetMathTabular(name,
|
||||||
|
InsetMathGrid::guessColumns(halign), 1, (char)valign[0], halign)));
|
||||||
parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
|
parse2(cell->back(), FLAG_END, InsetMath::TEXT_MODE, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user