int InsetFormulaMacro::latex(Buffer const &, ostream & os,
OutputParams const & runparams) const
{
- lyxerr << "InsetFormulaMacro::latex" << endl;
+ //lyxerr << "InsetFormulaMacro::latex" << endl;
WriteStream wi(os, runparams.moving_arg, true);
tmpl()->write(wi);
return 2;
void InsetFormulaMacro::metrics(MetricsInfo & mi, Dimension & dim) const
{
+ //lyxerr << "InsetFormulaMacro: " << this << " -- " << &tmpl() << endl;
tmpl()->metrics(mi, dim);
dim.asc += 5;
dim.des += 5;
MetricsInfo m = mi;
if (m.base.style == LM_ST_DISPLAY)
m.base.style = LM_ST_TEXT;
- MathGridInset::metrics(m);
- dim_.wid += 12;
- dim = dim_;
+ MathGridInset::metrics(m, dim);
+ dim.wid += 12;
+ dim_ = dim;
}
void MathArrayInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
ArrayChanger dummy(mi.base);
- MathGridInset::metrics(mi);
- metricsMarkers2(dim_);
- dim = dim_;
+ MathGridInset::metrics(mi, dim);
}
{
ArrayChanger dummy(pi.base);
MathGridInset::draw(pi, x + 1, y);
- drawMarkers2(pi, x, y);
}
void MathCommentInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
- cell(0).metrics(mi);
- metricsMarkers(dim_);
- dim = dim_;
+ cell(0).metrics(mi, dim);
+ metricsMarkers(dim);
+ dim_ = dim;
}
for (const_iterator it = begin(), et = end(); it != et; ++it) {
//pi.width = it->width_;
+ (*it)->drawSelection(pi, x, y);
(*it)->draw(pi, x, y);
x += (*it)->width();
}
xo_ = x;
yo_ = y;
}
-
-
-void MathArray::notifyCursorLeaves()
-{
- // do not recurse!
-
-/*
- // remove base-only "scripts"
- for (pos_type i = 0; i + 1 < size(); ++i) {
- MathScriptInset * p = operator[](i).nucleus()->asScriptInset();
- if (p && p->cell(0).empty() && p->cell(1).empty()) {
- MathArray ar = p->nuc();
- erase(i);
- insert(i, ar);
- mathcursor->adjust(i, ar.size() - 1);
- }
- }
-
- // glue adjacent font insets of the same kind
- for (pos_type i = 0; i + 1 < size(); ++i) {
- MathFontInset * p = operator[](i).nucleus()->asFontInset();
- MathFontInset const * q = operator[](i + 1)->asFontInset();
- if (p && q && p->name() == q->name()) {
- p->cell(0).append(q->cell(0));
- erase(i + 1);
- mathcursor->adjust(i, -1);
- }
- }
-*/
-}
void center(int & x, int & y) const;
/// adjust (x,y) to point on boundary on a straight line from the center
void towards(int & x, int & y) const;
- /// clean up if necessary
- void notifyCursorLeaves();
private:
/// is this an exact match at this position?
#include "debug.h"
#include "math_support.h"
+
#include "support/std_sstream.h"
#include "support/filetools.h" // LibFileSearch
#include "support/lstrings.h"
+
#include "frontends/lyx_gui.h"
#include <fstream>
#ifndef MATH_FACTORY_H
#define MATH_FACTORY_H
-
#include <string>
-
class MathAtom;
class MathArray;
+
MathAtom createMathInset(std::string const &);
/** Fills ar with the contents of str.
cxrow->setBaseline(cxrow->getBaseline() - ascent);
}
*/
+ metricsMarkers2(dim_);
}
xx, y + dim_.descent() - 1,
LColor::foreground);
}
+ drawMarkers2(pi, x, y);
}
dim.asc = max(dim.asc, asc);
dim.des = max(dim.des, des);
- // for markers
- metricsMarkers2(dim);
dim_ = dim;
}
drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
}
}
-
- drawMarkers2(pi, x, y);
}
void MathHullInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
- //lyxerr << "*** MathHullInset: request: " << cmd << endl;
+ lyxerr << "*** MathHullInset: request: " << cmd << endl;
switch (cmd.action) {
case LFUN_BREAKLINE:
cur.idx() = 1;
cur.pos() = 0;
//cur.dispatched(FINISHED);
- return;
+ break;
}
MathGridInset::priv_dispatch(cur, cmd);
- return;
+ break;
case LFUN_MATH_NUMBER:
//lyxerr << "toggling all numbers" << endl;
numbered(row, !old);
cur.message(old ? _("No number") : _("Number"));
}
- return;
+ break;
case LFUN_MATH_NONUMBER:
if (display()) {
cur.message(old ? _("No number") : _("Number"));
numbered(r, !old);
}
- return;
+ break;
case LFUN_INSERT_LABEL: {
row_type r = (type_ == "multline") ? nrows() - 1 : cur.row();
if (!new_label.empty())
numbered(r, true);
label(r, new_label);
- return;
+ break;
}
case LFUN_MATH_EXTERN:
doExtern(cur, cmd);
//cur.dispatched(FINISHED);
- return;
+ break;
case LFUN_MATH_MUTATE: {
lyxerr << "Hull: MUTATE: " << cmd.argument << endl;
if (cur.pos() > cur.lastpos())
cur.pos() = cur.lastpos();
//cur.dispatched(FINISHED);
- return;
+ break;
}
case LFUN_MATH_DISPLAY: {
cur.idx() = 0;
cur.pos() = cur.lastpos();
//cur.dispatched(FINISHED);
- return;
+ break;
}
default:
MathGridInset::priv_dispatch(cur, cmd);
- return;
+ break;
+ }
+}
+
+
+bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
+ FuncStatus & flag) const
+{
+ switch (cmd.action) {
+ case LFUN_BREAKLINE:
+ case LFUN_MATH_NUMBER:
+ case LFUN_MATH_NONUMBER:
+ case LFUN_INSERT_LABEL:
+ case LFUN_MATH_EXTERN:
+ case LFUN_MATH_MUTATE:
+ case LFUN_MATH_DISPLAY:
+ // we handle these
+ return true;
+ default:
+ return MathGridInset::getStatus(cur, cmd, flag);
}
}
}
+void MathHullInset::edit(LCursor & cur, bool left)
+{
+ lyxerr << "MathHullInset: edit left/right" << endl;
+ cur.push(*this);
+}
+
+
string const MathHullInset::editMessage() const
{
return _("Math editor mode");
protected:
///
void priv_dispatch(LCursor & cur, FuncRequest & cmd);
+ /// do we want to handle this event?
+ bool getStatus(LCursor & cur, FuncRequest const & cmd,
+ FuncStatus & status) const;
///
std::string eolString(row_type row, bool fragile) const;
///
virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
///
+ void edit(LCursor & cur, bool left);
+ ///
bool display() const;
///
Code lyxCode() const;
}
-void MathInset::drawSelection(PainterInfo &,
- idx_type, pos_type, idx_type, pos_type) const
-{
- lyxerr << "MathInset::drawSelection() called directly!" << endl;
-}
-
-
void MathInset::metricsT(TextMetricsInfo const &, Dimension &) const
{
#ifdef WITH_WARNINGS
/// substitutes macro arguments if necessary
virtual void substitute(MathMacro const & macro);
- /// draw selection between two positions
- virtual void drawSelection(PainterInfo & pi,
- idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
/// the ascent of the inset above the baseline
/// compute the size of the object for text based drawing
virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
bool MathMacro::defining() const
{
- return 0;
- //return mathcursor && mathcursor->formula()->getInsetName() == name();
+ return false;
+ //return mathcursor->formula()->getInsetName() == name();
}
} else if (editing(mi.base.bv)) {
expand();
- expanded_.metrics(mi_, dim);
+ expanded_.metrics(mi, dim);
metricsMarkers(dim);
dim.wid += mathed_string_width(font_, name()) + 10;
for (idx_type i = 0; i < nargs(); ++i) {
MathArray const & c = cell(i);
- c.metrics(mi_);
+ c.metrics(mi);
dim.wid = max(dim.wid, c.width() + ww);
- dim.des += max(c.ascent(), dim.asc) + 5;
- dim.des += max(c.descent(), dim.des) + 5;
+ dim.des += c.height() + 10;
}
} else {
expand();
expanded_.substitute(*this);
- expanded_.metrics(mi_, dim);
+ expanded_.metrics(mi, dim);
}
#include "debug.h"
#include "LColor.h"
-
using std::string;
using std::auto_ptr;
using std::endl;
+
MathMacroTemplate::MathMacroTemplate()
: MathNestInset(2), numargs_(0), name_(), type_("newcommand")
{}
void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const
{
+ lyxerr << "drawing template " << name() << ' ' << this << std::endl;
cell(0).metrics(mi);
cell(1).metrics(mi);
dim.wid = cell(0).width() + cell(1).width() + 10;
void MathNestInset::drawSelection(PainterInfo & pi, int, int) const
{
+ //lyxerr << "MathNestInset::drawing selection: "
+ // << " x: " << x << " y: " << y << endl;
// this should use the x/y values given, not the cached values
LCursor & cur = pi.base.bv->cursor();
if (!cur.selection())
return;
CursorSlice s1 = cur.selBegin();
CursorSlice s2 = cur.selEnd();
+ lyxerr << "MathNestInset::drawing selection: "
+ << " s1: " << s1 << " s2: " << s2 << endl;
if (s1.idx() == s2.idx()) {
MathArray const & c = cell(s1.idx());
int x1 = c.xo() + c.pos2x(s1.pos());
} else {
MathGridInset::metrics(mi, dim);
}
- metricsMarkers(dim);
dim_ = dim;
}
void MathSubstackInset::draw(PainterInfo & pi, int x, int y) const
{
MathGridInset::draw(pi, x + 1, y);
- drawMarkers(pi, x, y);
}