src/mathed/math_hullinset.C
src/mathed/math_macrotemplate.C
src/mathed/math_nestinset.C
-src/mathed/math_parboxinset.C
src/mathed/ref_inset.C
src/output.C
src/output_docbook.C
+2004-08-14 Lars Gullik Bjonnes <larsbj@lyx.org>
+
+ * text3.C: use Debug::DEBUG a bit more
+
+ * text.C (leftMargin): try to simplify a tiny bit change var x to
+ l_margin. Dont output the wide margins always.
+ (rightMargin): no margin in inner texts
+
+ * rowpainter.h (nestMargin): new func
+ (changebarMargin): new func
+ (rightMargin): new func
+
+ * rowpainter.C (paintDepthBar): changebarMargin and nestMargin is
+ now functions.
+ (paintLast): ditto
+
+ * factory.C (createInset): modify setDrawFrame
+
+ * cursor.C: use Debug::DEBUG a bit more
+
2004-08-14 André Pönitz <poenitz@gmx.net>
* coordcache.[Ch]:
* Makefile.am: new files to accomodate an 'external' (x,y)-position
cache for all insets in (at least partially) visible (top-level)
paragraphs.
-
+
* BufferView_pimpl.C: reset external coord cache before every update.
This means the coord cache only contains valid entries.
#include "frontends/LyXView.h"
#include <boost/assert.hpp>
+#include <boost/current_function.hpp>
#include <sstream>
double d = (x - xo) * (x - xo) + (y - yo) * (y - yo);
// '<=' in order to take the last possible position
// this is important for clicking behind \sum in e.g. '\sum_i a'
- lyxerr << "i: " << i << " d: " << d << " best: " << best_dist << endl;
+ lyxerr[Debug::DEBUG] << "i: " << i << " d: " << d << " best: " << best_dist << endl;
if (d <= best_dist) {
best_dist = d;
result = it;
FuncRequest cmd = cmd0;
LCursor safe = *this;
- for ( ; size(); pop()) {
- lyxerr << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
+ for (; size(); pop()) {
+ lyxerr[Debug::DEBUG] << "LCursor::dispatch: cmd: " << cmd0 << endl << *this << endl;
BOOST_ASSERT(pos() <= lastpos());
BOOST_ASSERT(idx() <= lastidx());
BOOST_ASSERT(par() <= lastpar());
void LCursor::handleFont(string const & font)
{
- lyxerr << "LCursor::handleFont: " << font << endl;
+ lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION << ": " << font << endl;
string safe;
if (selection()) {
macroModeClose();
{
disp_.update(false);
}
-
-
if (!up) {
auto_ptr<InsetCaption> inset(new InsetCaption(params));
inset->setAutoBreakRows(true);
- inset->setDrawFrame(InsetText::LOCKED);
+ inset->setDrawFrame(true);
inset->setFrameColor(LColor::captionframe);
return inset.release();
}
+2004-08-14 Lars Gullik Bjonnes <larsbj@lyx.org>
+ * insettext.[Ch] (setDrawFrame): take a bool, get rid of the
+ DrawFrame enum.
+
+ * insetcaption.C (InsetCaption): modify call to setDrawFrame
+ * insetcollapsable.C (InsetCollapsable): ditto
+ * insetenv.C (InsetEnvironment): ditto
+
2004-08-14 André Pönitz <poenitz@gmx.net>
* inset.[Ch]:
* insetoptarg.C (latexOptional): if the optional argument contains
a ']' enclose it in {curly brackets}
- * insettext.C (editXY):
- * insettabular.C (editXY):
- * insetcollapsable.C (editXY):
+ * insettext.C (editXY):
+ * insettabular.C (editXY):
+ * insetcollapsable.C (editXY):
* insetbase.C (editXY): constify
* insetcollapsable.C (priv_dispatch): on a mouse press event, do
not ask for an update if we did nothing; on a mouse release, make
sure that the cursor is moved to the right position; on a mouse
release, exit from the inset instead of invoking a
- LFUN_FINISHED_RIGHT.
+ LFUN_FINISHED_RIGHT.
* insetbase.C (dispatch): before invoking dispatch, set cursor
result to dispatch=update=true.
: InsetText(bp)
{
setAutoBreakRows(true);
- setDrawFrame(InsetText::LOCKED);
+ setDrawFrame(true);
setFrameColor(LColor::captionframe);
}
: InsetText(bp), label("Label"), status_(status), openinlined_(false)
{
setAutoBreakRows(true);
- setDrawFrame(InsetText::ALWAYS);
+ setDrawFrame(true);
setFrameColor(LColor::collapsableframe);
setInsetName("Collapsable");
setButtonLabel();
void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest & cmd)
{
-// lyxerr << "InsetCollapsable::priv_dispatch (begin): cmd: " << cmd
-// << " button y: " << button_dim.y2
-// << " coll/inline/open: " << status_ << endl;
+// lyxerr << "InsetCollapsable::priv_dispatch (begin): cmd: " << cmd
+// << " button y: " << button_dim.y2
+// << " coll/inline/open: " << status_ << endl;
switch (cmd.action) {
case LFUN_MOUSE_PRESS:
if (status_ == Inlined)
InsetText::priv_dispatch(cur, cmd);
else if (status_ == Open && !hitButton(cmd))
InsetText::priv_dispatch(cur, cmd);
- else
+ else
cur.noUpdate();
break;
{
setInsetName(name);
setAutoBreakRows(true);
- setDrawFrame(ALWAYS);
+ setDrawFrame(true);
}
InsetText::InsetText(BufferParams const & bp)
- : autoBreakRows_(false), drawFrame_(NEVER),
+ : autoBreakRows_(false), drawFrame_(false),
frame_color_(LColor::insetframe), text_(0)
{
paragraphs().push_back(Paragraph());
text_.draw(pi, x, y + bv->top_y());
- if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
+ if (drawFrame_)
drawFrame(pi.pain, x, y);
}
InsetBase * InsetText::editXY(LCursor & cur, int x, int y) const
{
- lyxerr << "InsetText::edit xy" << endl;
+ lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION << endl;
old_par = -1;
return text_.editXY(cur, x, y);
//sanitizeEmptyText(cur.bv());
}
-void InsetText::setDrawFrame(DrawFrame how)
+void InsetText::setDrawFrame(bool flag)
{
- drawFrame_ = how;
+ drawFrame_ = flag;
}
*/
class InsetText : public UpdatableInset {
public:
- ///
- enum DrawFrame {
- ///
- NEVER = 0,
- ///
- LOCKED,
- ///
- ALWAYS
- };
///
explicit InsetText(BufferParams const &);
///
///
bool getAutoBreakRows() const { return autoBreakRows_; }
///
- void setDrawFrame(DrawFrame);
+ void setDrawFrame(bool);
///
LColor_color frameColor() const;
///
///
bool autoBreakRows_;
///
- DrawFrame drawFrame_;
+ bool drawFrame_;
/** We store the LColor::color value as an int to get LColor.h out
* of the header file.
*/
using std::max;
using std::string;
-extern int NEST_MARGIN;
-extern int CHANGEBAR_MARGIN;
-
namespace {
//lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
// << " pit->y: " << pit_->y
// << " row: " << (pars_[pit_].size() ? pars_[pit_].getChar(row_.pos()) : 'X') << endl;
+
RowMetrics m = text_.computeRowMetrics(pit, row_);
x_ = m.x + xo_;
+
separator_ = m.separator;
hfill_ = m.hfill;
label_hfill_ = m.label_hfill;
}
for (Paragraph::depth_type i = 1; i <= depth; ++i) {
- int const w = NEST_MARGIN / 5;
- int x = int(w * i + xo_);
+ int const w = nestMargin() / 5;
+ int x = xo_ + w * i;
// only consider the changebar space if we're drawing outer left
if (xo_ == 0)
- x += CHANGEBAR_MARGIN;
+ x += changebarMargin();
+
int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
pain_.line(x, yo_, x, h, LColor::depthbar);
LyXFont const font = getLabelFont();
int const size = int(0.75 * font_metrics::maxAscent(font));
int const y = yo_ + row_.baseline() - size;
- int x = is_rtl ? NEST_MARGIN + CHANGEBAR_MARGIN: width_ - size;
+ int x = is_rtl ? nestMargin() + changebarMargin() : width_ - size;
if (width_ - int(row_.width()) <= size)
x += (size - width_ + row_.width() + 1) * (is_rtl ? -1 : 1);
/// paint the rows of a text inset
void paintTextInset(LyXText const & text, PainterInfo & pi);
+/// some space for drawing the 'nested' markers (in pixel)
+inline int nestMargin()
+{
+ return 15;
+}
+
+
+/// margin for changebar
+inline int changebarMargin()
+{
+ return 10;
+}
+
+
+/// right margin
+inline int rightMargin()
+{
+ return 30;
+}
+
+
#endif // ROWPAINTER_H
int cellno = 0;
for (int i = 0; i < rows_; ++i) {
for (int j = 0; j < columns_; ++j) {
- cell_info[i][j].inset.setDrawFrame(InsetText::LOCKED);
+ // When debugging it can be nice to set
+ // this to true.
+ cell_info[i][j].inset.setDrawFrame(false);
cell_info[i][j].cellno = cellno++;
}
cell_info[i].back().right_line = true;
using std::string;
-/// some space for drawing the 'nested' markers (in pixel)
-extern int const NEST_MARGIN = 20;
-/// margin for changebar
-extern int const CHANGEBAR_MARGIN = 10;
-/// right margin
-extern int const RIGHT_MARGIN = 10;
-
-
namespace {
int numberOfSeparators(Paragraph const & par, Row const & row)
string parindent = layout->parindent;
- int x = NEST_MARGIN + CHANGEBAR_MARGIN;
+ int l_margin = 0;
- x += font_metrics::signedWidth(tclass.leftmargin(), tclass.defaultfont());
+ if (xo_ == 0)
+ l_margin += changebarMargin();
- // This is the way LyX handles LaTeX-Environments.
- // I have had this idea very late, so it seems to be a
- // later added hack and this is true
- if (pars_[pit].getDepth() == 0) {
- if (pars_[pit].layout() == tclass.defaultLayout()) {
- // find the previous same level paragraph
- if (pit != 0) {
- par_type newpit =
- depthHook(pit, paragraphs(), pars_[pit].getDepth());
- if (newpit == pit && pars_[newpit].layout()->nextnoindent)
+ l_margin += font_metrics::signedWidth(tclass.leftmargin(), tclass.defaultfont());
+
+ if (pars_[pit].getDepth() != 0) {
+ // find the next level paragraph
+ par_type newpar = outerHook(pit, pars_);
+ if (newpar != par_type(pars_.size())) {
+ if (pars_[newpar].layout()->isEnvironment()) {
+ l_margin = leftMargin(newpar);
+ }
+ if (pars_[pit].layout() == tclass.defaultLayout()) {
+ if (pars_[newpar].params().noindent())
parindent.erase();
+ else
+ parindent = pars_[newpar].layout()->parindent;
}
}
- } else {
- // find the next level paragraph
- par_type newpar = outerHook(pit, pars_);
-
- // Make a corresponding row. Need to call leftMargin()
- // to check whether it is a sufficent paragraph.
- if (newpar != par_type(pars_.size())
- && pars_[newpar].layout()->isEnvironment()) {
- x = leftMargin(newpar);
- }
-
- if (newpar != par_type(paragraphs().size())
- && pars_[pit].layout() == tclass.defaultLayout()) {
- if (pars_[newpar].params().noindent())
- parindent.erase();
- else
- parindent = pars_[newpar].layout()->parindent;
- }
}
LyXFont const labelfont = getLabelFont(pit);
switch (layout->margintype) {
case MARGIN_DYNAMIC:
if (!layout->leftmargin.empty())
- x += font_metrics::signedWidth(layout->leftmargin,
+ l_margin += font_metrics::signedWidth(layout->leftmargin,
tclass.defaultfont());
if (!pars_[pit].getLabelstring().empty()) {
- x += font_metrics::signedWidth(layout->labelindent,
+ l_margin += font_metrics::signedWidth(layout->labelindent,
labelfont);
- x += font_metrics::width(pars_[pit].getLabelstring(),
+ l_margin += font_metrics::width(pars_[pit].getLabelstring(),
labelfont);
- x += font_metrics::width(layout->labelsep, labelfont);
+ l_margin += font_metrics::width(layout->labelsep, labelfont);
}
break;
case MARGIN_MANUAL:
- x += font_metrics::signedWidth(layout->labelindent, labelfont);
+ l_margin += font_metrics::signedWidth(layout->labelindent, labelfont);
// The width of an empty par, even with manual label, should be 0
if (!pars_[pit].empty() && pos >= pars_[pit].beginOfBody()) {
if (!pars_[pit].getLabelWidthString().empty()) {
- x += font_metrics::width(pars_[pit].getLabelWidthString(),
+ l_margin += font_metrics::width(pars_[pit].getLabelWidthString(),
labelfont);
- x += font_metrics::width(layout->labelsep, labelfont);
+ l_margin += font_metrics::width(layout->labelsep, labelfont);
}
}
break;
case MARGIN_STATIC:
- x += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4
+ l_margin += font_metrics::signedWidth(layout->leftmargin, tclass.defaultfont()) * 4
/ (pars_[pit].getDepth() + 4);
break;
case MARGIN_FIRST_DYNAMIC:
if (layout->labeltype == LABEL_MANUAL) {
if (pos >= pars_[pit].beginOfBody()) {
- x += font_metrics::signedWidth(layout->leftmargin,
+ l_margin += font_metrics::signedWidth(layout->leftmargin,
labelfont);
} else {
- x += font_metrics::signedWidth(layout->labelindent,
+ l_margin += font_metrics::signedWidth(layout->labelindent,
labelfont);
}
} else if (pos != 0
// theorems (JMarc)
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
- && !isFirstInSequence(pit, paragraphs()))) {
- x += font_metrics::signedWidth(layout->leftmargin,
+ && !isFirstInSequence(pit, pars_))) {
+ l_margin += font_metrics::signedWidth(layout->leftmargin,
labelfont);
} else if (layout->labeltype != LABEL_TOP_ENVIRONMENT
&& layout->labeltype != LABEL_BIBLIO
&& layout->labeltype !=
LABEL_CENTERED_TOP_ENVIRONMENT) {
- x += font_metrics::signedWidth(layout->labelindent,
+ l_margin += font_metrics::signedWidth(layout->labelindent,
labelfont);
- x += font_metrics::width(layout->labelsep, labelfont);
- x += font_metrics::width(pars_[pit].getLabelstring(),
+ l_margin += font_metrics::width(layout->labelsep, labelfont);
+ l_margin += font_metrics::width(pars_[pit].getLabelstring(),
labelfont);
}
break;
for ( ; rit != end; ++rit)
if (rit->fill() < minfill)
minfill = rit->fill();
- x += font_metrics::signedWidth(layout->leftmargin,
+ l_margin += font_metrics::signedWidth(layout->leftmargin,
tclass.defaultfont());
- x += minfill;
+ l_margin += minfill;
#endif
// also wrong, but much shorter.
- x += maxwidth_ / 2;
+ l_margin += maxwidth_ / 2;
break;
}
}
-
if (!pars_[pit].params().leftIndent().zero())
- x += pars_[pit].params().leftIndent().inPixels(maxwidth_);
+ l_margin += pars_[pit].params().leftIndent().inPixels(maxwidth_);
LyXAlignment align;
|| layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT
|| (layout->labeltype == LABEL_STATIC
&& layout->latextype == LATEX_ENVIRONMENT
- && !isFirstInSequence(pit, paragraphs())))
+ && !isFirstInSequence(pit, pars_)))
&& align == LYX_ALIGN_BLOCK
&& !pars_[pit].params().noindent()
// in tabulars and ert paragraphs are never indented!
- && (pars_[pit].ownerCode() != InsetOld::TABULAR_CODE
- && pars_[pit].ownerCode() != InsetOld::ERT_CODE)
+ && (pars_[pit].ownerCode() != InsetBase::TEXT_CODE
+ && pars_[pit].ownerCode() != InsetBase::ERT_CODE)
&& (pars_[pit].layout() != tclass.defaultLayout()
|| bv()->buffer()->params().paragraph_separation ==
BufferParams::PARSEP_INDENT))
{
- x += font_metrics::signedWidth(parindent, tclass.defaultfont());
+ l_margin += font_metrics::signedWidth(parindent, tclass.defaultfont());
}
- return x;
+ return l_margin;
}
{
LyXTextClass const & tclass = bv()->buffer()->params().getLyXTextClass();
- return
- RIGHT_MARGIN
+ // We do not want rightmargins on inner texts.
+ if (bv()->text() != this)
+ return 0;
+
+ int const r_margin =
+ ::rightMargin()
+ font_metrics::signedWidth(tclass.rightmargin(),
- tclass.defaultfont())
+ tclass.defaultfont())
+ font_metrics::signedWidth(par.layout()->rightmargin,
- tclass.defaultfont())
+ tclass.defaultfont())
* 4 / (par.getDepth() + 4);
+
+ return r_margin;
+
}
// takes absolute x,y coordinates
-InsetBase * LyXText::checkInsetHit(int x, int y) const
+InsetBase * LyXText::checkInsetHit(int x, int y) const
{
par_type pit;
par_type end;
bv()->top_y() - yo_ + bv()->workHeight(),
pit, end);
- lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
- lyxerr << " pit: " << pit << " end: " << end << endl;
+ lyxerr[Debug::DEBUG] << BOOST_CURRENT_FUNCTION
+ << ": x: " << x << " y: " << y
+ << " pit: " << pit << " end: " << end << endl;
for (; pit != end; ++pit) {
InsetList::const_iterator iit = pars_[pit].insetlist.begin();
InsetList::const_iterator iend = pars_[pit].insetlist.end();
for (; iit != iend; ++iit) {
InsetBase * inset = iit->inset;
#if 1
- lyxerr << "examining inset " << inset << endl;
+ lyxerr[Debug::DEBUG]
+ << "examining inset " << inset << endl;
if (theCoords.insets_.has(inset))
lyxerr
<< " xo: " << inset->xo() << "..." << inset->xo() + inset->width()
lyxerr << " inset has no cached position";
#endif
if (inset->covers(x, y)) {
- lyxerr << "Hit inset: " << inset << endl;
+ lyxerr[Debug::DEBUG]
+ << "Hit inset: " << inset << endl;
return inset;
}
}
}
- lyxerr << "No inset hit. " << endl;
+ lyxerr[Debug::DEBUG] << "No inset hit. " << endl;
return 0;
}
}
case LFUN_FINISHED_LEFT:
- lyxerr << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
+ lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_LEFT:\n" << cur << endl;
break;
case LFUN_FINISHED_RIGHT:
- lyxerr << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
+ lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_RIGHT:\n" << cur << endl;
++cur.pos();
break;
case LFUN_FINISHED_UP:
- lyxerr << "handle LFUN_FINISHED_UP:\n" << cur << endl;
+ lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_UP:\n" << cur << endl;
cursorUp(cur);
break;
case LFUN_FINISHED_DOWN:
- lyxerr << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
+ lyxerr[Debug::DEBUG] << "handle LFUN_FINISHED_DOWN:\n" << cur << endl;
cursorDown(cur);
break;