+2000-07-04 Juergen Vigna <jug@sad.it>
+
+ * src/text.C (NextBreakPoint): added support for needFullRow()
+
+ * src/insets/lyxinset.h: added needFullRow()
+
+ * src/insets/insetcollapsable.C: redone now this uses a text-inset
+ and isn't one.
+
+ * src/insets/insettext.C: lots of changes for update!
+
2000-07-03 Angus Leeming <a.leeming@ic.ac.uk>
* src/LaTeXFeatures.h: add a missing std:: qualifier.
* src/lyx_main.C (easyParse): accept linuxdoc and docbook as
formats to export with command line argument -x.
+2000-06-29 Juergen Vigna <jug@sad.it>
+
+ * src/mathed/formula.C (LocalDispatch): changed only-cursor-movements
+ to return DISPATCHED_NOUPDATE so that a it does not redraw the inset!
+
+ * src/text.C (GetVisibleRow): added 'bool cleared' parameter as the
+ region could already been cleared by an inset!
+
2000-06-28 Lars Gullik Bjønnes <larsbj@lyx.org>
* src/BufferView_pimpl.h: remove member variables lyx_focus and
}
+Inset * BufferView::checkInsetHit(LyXText * text, int & x, int & y,
+ unsigned int button)
+{
+ return pimpl_->checkInsetHit(text, x, y, button);
+}
+
+
void BufferView::redoCurrentBuffer()
{
pimpl_->redoCurrentBuffer();
///
void updateScrollbar();
///
+ Inset * checkInsetHit(LyXText *, int & x, int & y, unsigned int button);
+ ///
void redoCurrentBuffer();
///
int resizeCurrentBuffer();
if (buffer_ == 0 || !screen_) return;
- Inset * inset_hit = checkInsetHit(xpos, ypos, button);
+ Inset * inset_hit = checkInsetHit(bv_->text, xpos, ypos, button);
// ok ok, this is a hack.
if (button == 4 || button == 5) {
// If we hit an inset, we have the inset coordinates in these
// and inset_hit points to the inset. If we do not hit an
// inset, inset_hit is 0, and inset_x == x, inset_y == y.
- Inset * inset_hit = checkInsetHit(x, y, button);
+ Inset * inset_hit = checkInsetHit(bv_->text, x, y, button);
if (bv_->the_locking_inset) {
// We are in inset locking mode.
* If hit, the coordinates are changed relative to the inset.
* Otherwise coordinates are not changed, and false is returned.
*/
-Inset * BufferView::Pimpl::checkInsetHit(int & x, int & y,
+Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y,
unsigned int /* button */)
{
if (!screen_)
return 0;
- unsigned int y_tmp = y + bv_->text->first;
+ unsigned int y_tmp = y + text->first;
LyXCursor cursor;
- bv_->text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
+ text->SetCursorFromCoordinates(bv_, cursor, x, y_tmp);
#if 0 // Are you planning to use this Jürgen? (Lgb)
- bool move_cursor = ((cursor.par != bv_->text->cursor.par) ||
- (cursor.pos != bv_->text->cursor.pos()));
+ bool move_cursor = ((cursor.par != text->cursor.par) ||
+ (cursor.pos != text->cursor.pos()));
#endif
if (cursor.pos() < cursor.par()->Last()
&& cursor.par()->GetChar(cursor.pos()) == LyXParagraph::META_INSET
// Check whether the inset really was hit
Inset * tmpinset = cursor.par()->GetInset(cursor.pos());
- LyXFont font = bv_->text->GetFont(bv_->buffer(),
+ LyXFont font = text->GetFont(bv_->buffer(),
cursor.par(), cursor.pos());
bool is_rtl = font.isVisibleRightToLeft();
int start_x, end_x;
#if 0
if (move_cursor && (tmpinset != bv_->the_locking_inset))
#endif
- bv_->text->SetCursor(bv_, cursor.par(),cursor.pos(),true);
+ text->SetCursor(bv_, cursor.par(),cursor.pos(),true);
x = x - start_x;
// The origin of an inset is on the baseline
- y = y_tmp - (bv_->text->cursor.y());
+ y = y_tmp - (text->cursor.y());
return tmpinset;
}
}
(cursor.par()->GetInset(cursor.pos() - 1)) &&
(cursor.par()->GetInset(cursor.pos() - 1)->Editable())) {
Inset * tmpinset = cursor.par()->GetInset(cursor.pos()-1);
- LyXFont font = bv_->text->GetFont(bv_->buffer(), cursor.par(),
+ LyXFont font = text->GetFont(bv_->buffer(), cursor.par(),
cursor.pos()-1);
bool is_rtl = font.isVisibleRightToLeft();
int start_x, end_x;
#if 0
if (move_cursor && (tmpinset != bv_->the_locking_inset))
#endif
- bv_->text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true);
+ text->SetCursor(bv_, cursor.par(),cursor.pos()-1,true);
x = x - start_x;
// The origin of an inset is on the baseline
- y = y_tmp - (bv_->text->cursor.y());
+ y = y_tmp - (text->cursor.y());
return tmpinset;
}
}
///
void scrollCB(double value);
///
- Inset * checkInsetHit(int & x, int & y, unsigned int button);
+ Inset * checkInsetHit(LyXText *, int & x, int & y, unsigned int button);
///
int scrollUp(long time);
///
#include "lyxfont.h"
#include "BufferView.h"
#include "Painter.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
#include "support/lstrings.h"
+class LyXText;
+
using std::ostream;
InsetCollapsable::InsetCollapsable()
- : InsetText()
+ : UpdatableInset()
{
+ inset = new InsetText;
+ inset->setOwner(this);
collapsed = true;
label = "Label";
autocollapse = true;
- autoBreakRows = true;
- framecolor = LColor::footnoteframe;
- widthOffset = 2 * TEXT_TO_INSET_OFFSET + 2; // 1+1 (frame)
+ inset->SetAutoBreakRows(true);
+ inset->SetDrawFrame(0, InsetText::ALWAYS);
+ inset->SetFrameColor(0, LColor::footnoteframe);
button_length = button_top_y = button_bottom_y = 0;
setInsetName("Collapsable");
+ widthCollapsed = oldWidth = 0;
+ need_update = FULL;
}
Inset * InsetCollapsable::Clone() const
{
InsetCollapsable * result = new InsetCollapsable();
- result->init(this);
+ result->inset->init(inset);
+ result->inset->setOwner(result);
result->collapsed = collapsed;
return result;
void InsetCollapsable::Write(Buffer const * buf, ostream & os) const
{
- os << "collapsed " << tostr(!display()) << "\n";
- WriteParagraphData(buf, os);
+ os << "collapsed " << tostr(collapsed) << "\n";
+ inset->WriteParagraphData(buf, os);
}
+
void InsetCollapsable::Read(Buffer const * buf, LyXLex & lex)
{
if (lex.IsOK()) {
collapsed = lex.GetBool();
}
}
- InsetText::Read(buf, lex);
+ inset->Read(buf, lex);
}
if (collapsed)
return ascent_collapsed(pain, font);
else
- return InsetText::ascent(pain, font) + TEXT_TO_TOP_OFFSET;
+ return inset->ascent(pain, font) + TEXT_TO_TOP_OFFSET;
}
if (collapsed)
return descent_collapsed(pain, font);
else
- return InsetText::descent(pain, font) + TEXT_TO_BOTTOM_OFFSET;
+ return inset->descent(pain, font) + TEXT_TO_BOTTOM_OFFSET;
}
int InsetCollapsable::width(Painter & pain, LyXFont const & font) const
{
if (collapsed)
- return width_collapsed(pain, font);
+ return widthCollapsed;
- return InsetText::width(pain, font) + width_collapsed(pain,font) +
- widthOffset;
+ return inset->width(pain, font) + widthCollapsed;
}
-void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const & font,
+void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &,
int baseline, float & x) const
{
int width = 0;
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
- baseline-ascent(pain, font)+ascent_collapsed(pain, font),
- label.c_str(), labelfont, true, width);
- x += width + (2 * TEXT_TO_INSET_OFFSET);
+ baseline, label.c_str(), labelfont, true, width);
+ x += width + TEXT_TO_INSET_OFFSET;
}
{
Painter & pain = bv->painter();
- button_length = width_collapsed(pain, labelfont) + 2;
+ button_length = widthCollapsed;
button_top_y = -ascent_collapsed(pain, f);
button_bottom_y = descent_collapsed(pain, f);
if (collapsed) {
draw_collapsed(pain, f, baseline, x);
+ x += TEXT_TO_INSET_OFFSET;
return;
}
- if (!cleared && ((need_update==FULL) || (topx!=int(x)) ||
- (topbaseline!=baseline))) {
- int w = width(pain, f);
+ if (!cleared && ((need_update == FULL) ||
+ (top_x!=int(x)) || (top_baseline!=baseline))) {
+ int w = owner()? width(pain, f) : pain.paperWidth();
int h = ascent(pain,f) + descent(pain, f);
- int tx = display()? 0:topx;
+ int tx = (display() && !owner())? 0:int(x);
int ty = baseline - ascent(pain,f);
if (ty < 0)
ty = 0;
if ((ty + h) > pain.paperHeight())
h = pain.paperHeight();
- if ((topx + w) > pain.paperWidth())
+ if ((top_x + w) > pain.paperWidth())
w = pain.paperWidth();
pain.fillRectangle(tx, ty-1, w, h+2);
cleared = true;
}
// not needed if collapsed
- topx = int(x);
- topbaseline = baseline;
-
- int w = InsetText::width(pain, f) + (2 * TEXT_TO_INSET_OFFSET);
- int h = ascent(pain,f) + descent(pain, f);
+ top_x = int(x);
+ top_baseline = baseline;
draw_collapsed(pain, f, baseline, x);
- x -= TEXT_TO_INSET_OFFSET;
-
- int save_x = static_cast<int>(x);
- x += TEXT_TO_INSET_OFFSET;
- InsetText::draw(bv, f, baseline, x, cleared);
- pain.rectangle(save_x, baseline - ascent(pain, f), w, h, framecolor);
+ inset->draw(bv, f, baseline, x, cleared);
+ need_update = NONE;
}
void InsetCollapsable::Edit(BufferView * bv, int x, int y, unsigned int button)
{
+ UpdatableInset::Edit(bv, x, y, button);
+
if (collapsed && autocollapse) {
collapsed = false;
- UpdateLocal(bv, FULL, false);
- InsetText::Edit(bv, 0, 0, button);
+ if (!bv->lockInset(this))
+ return;
+ bv->updateInset(this, false);
+ inset->Edit(bv, 0, 0, button);
} else if (!collapsed) {
- InsetText::Edit(bv, x, y, button);
+ if (!bv->lockInset(this))
+ return;
+ inset->Edit(bv, x-widthCollapsed, y, button);
}
}
if (autocollapse) {
collapsed = true;
}
- InsetText::InsetUnlock(bv);
- UpdateLocal(bv, FULL, false);
+ inset->InsetUnlock(bv);
+ bv->updateInset(this, false);
}
void InsetCollapsable::InsetButtonPress(BufferView * bv,int x,int y,int button)
{
if (!collapsed && (x >= button_length)) {
- InsetText::InsetButtonPress(bv, x, y, button);
+ inset->InsetButtonPress(bv, x-widthCollapsed, y, button);
}
}
(y >= button_top_y) && (y < button_bottom_y)) {
if (collapsed) {
collapsed = false;
- InsetText::InsetButtonRelease(bv, 0, 0, button);
- UpdateLocal(bv, FULL, false);
+ inset->InsetButtonRelease(bv, 0, 0, button);
+ bv->updateInset(this, false);
} else {
collapsed = true;
- UpdateLocal(bv, FULL, false);
bv->unlockInset(this);
+ bv->updateInset(this, false);
}
} else if (!collapsed && (x >= button_length) && (y >= button_top_y)) {
- InsetText::InsetButtonRelease(bv, x, y, button);
+ inset->InsetButtonRelease(bv, x-widthCollapsed, y, button);
}
}
int x, int y, int state)
{
if (x >= button_length) {
- InsetText::InsetMotionNotify(bv, x, y, state);
+ inset->InsetMotionNotify(bv, x-widthCollapsed, y, state);
}
}
+void InsetCollapsable::InsetKeyPress(XKeyEvent * xke)
+{
+ inset->InsetKeyPress(xke);
+}
+
+
+int InsetCollapsable::Latex(Buffer const * buf, ostream & os, bool fragile, bool free_spc) const
+{
+ return inset->Latex(buf, os, fragile, free_spc);
+}
+
+
int InsetCollapsable::getMaxWidth(Painter & pain,
UpdatableInset const * inset) const
{
- if ((this == inset) && !owner())
- return pain.paperWidth();
- if (this == inset)
- return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset);
+ int w;
if (owner())
- return static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset)-
- width_collapsed(pain, labelfont) - widthOffset;
+ w = static_cast<UpdatableInset*>(owner())->getMaxWidth(pain,inset);
+ else
+ w = pain.paperWidth();
- return pain.paperWidth()-width_collapsed(pain, labelfont) - widthOffset;
+ if (w < 0)
+ return w;
+
+ return w; // - top_x - widthCollapsed;
}
int InsetCollapsable::getMaxTextWidth(Painter & pain,
UpdatableInset const * inset) const
{
- return getMaxWidth(pain, inset) -
- width_collapsed(pain, labelfont) - widthOffset;
+ return getMaxWidth(pain, inset) - widthCollapsed;
}
void InsetCollapsable::update(BufferView * bv,
LyXFont const & font, bool dodraw)
{
- drawTextXOffset = width_collapsed(bv->painter(), font);
- InsetText::update(bv, font, dodraw);
+ if (!widthCollapsed) {
+ widthCollapsed = width_collapsed(bv->painter(), font);
+ inset->deleteLyXText(bv);
+ need_update = FULL;
+ if (owner()) {
+ owner()->update(bv, font, dodraw);
+ return;
+ }
+ }
+ if (oldWidth != width(bv->painter(), font)) {
+ oldWidth = width(bv->painter(), font);
+ inset->deleteLyXText(bv);
+ need_update = FULL;
+ if (owner()) {
+ owner()->update(bv, font, dodraw);
+ return;
+ }
+ }
+ inset->update(bv, font, dodraw);
+}
+
+UpdatableInset::RESULT
+InsetCollapsable::LocalDispatch(BufferView * bv, int action, string const & arg)
+{
+ UpdatableInset::RESULT result = inset->LocalDispatch(bv, action, arg);
+ if (result == FINISHED)
+ bv->unlockInset(this);
+ return result;
+}
+
+bool InsetCollapsable::LockInsetInInset(BufferView * bv, UpdatableInset * in)
+{
+ if (inset == in)
+ return true;
+ return inset->LockInsetInInset(bv, in);
+}
+
+
+bool InsetCollapsable::UnlockInsetInInset(BufferView * bv, UpdatableInset * in,
+ bool lr)
+{
+ if (inset == in) {
+ bv->unlockInset(this);
+ return true;
+ }
+ return inset->UnlockInsetInInset(bv, in, lr);
+}
+
+
+bool InsetCollapsable::UpdateInsetInInset(BufferView * bv, Inset *in)
+{
+ if (in == inset)
+ return true;
+ return inset->UpdateInsetInInset(bv, in);
+}
+
+
+int InsetCollapsable::InsetInInsetY()
+{
+ return inset->InsetInInsetY();
+}
+
+
+void InsetCollapsable::Validate(LaTeXFeatures & features) const
+{
+ inset->Validate(features);
}
+
+
+void InsetCollapsable::GetCursorPos(BufferView * bv, int & x, int & y) const
+{
+ inset->GetCursorPos(bv, x , y);
+}
+
+
+void InsetCollapsable::ToggleInsetCursor(BufferView * bv)
+{
+ inset->ToggleInsetCursor(bv);
+}
+
+
+UpdatableInset * InsetCollapsable::GetLockingInset()
+{
+ UpdatableInset *in = inset->GetLockingInset();
+ if (inset == in)
+ return this;
+ return in;
+}
+
+
+UpdatableInset * InsetCollapsable::GetFirstLockingInsetOfType(Inset::Code c)
+{
+ if (c == LyxCode())
+ return this;
+ return inset->GetFirstLockingInsetOfType(c);
+}
+
+
+void InsetCollapsable::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
+{
+ inset->SetFont(bv, font, toggleall);
+}
+
+bool InsetCollapsable::doClearArea() const
+{
+ return inset->doClearArea();
+}
+
+
+LyXText * InsetCollapsable::getLyXText(BufferView * bv) const
+{
+ return inset->getLyXText(bv);
+}
+
+
+void InsetCollapsable::deleteLyXText(BufferView * bv)
+{
+ inset->deleteLyXText(bv);
+}
+
#pragma interface
#endif
-#include "insettext.h"
+#include "lyxinset.h"
#include "lyxfont.h"
#include "LColor.h"
class Painter;
+class InsetText;
+class LyXText;
/** A colapsable text inset
*/
-class InsetCollapsable : public InsetText {
+class InsetCollapsable : public UpdatableInset {
public:
+ ///
+ enum UpdateCodes {
+ NONE = 0,
+ FULL
+ };
///
static int const TEXT_TO_TOP_OFFSET = 2;
///
///
EDITABLE Editable() const;
///
+ bool IsTextInset() const { return true; }
+ ///
+ bool doClearArea() const;
+ ///
void InsetUnlock(BufferView *);
///
- bool display() const { return (!collapsed); }
+ bool needFullRow() const { return !collapsed; }
+ ///
+ bool LockInsetInInset(BufferView *, UpdatableInset *);
+ ///
+ bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
+ ///
+ bool UpdateInsetInInset(BufferView *, Inset *);
+ ///
+ int InsetInInsetY();
///
void InsetButtonRelease(BufferView *, int, int, int);
///
///
void InsetMotionNotify(BufferView *, int, int, int);
///
+ void InsetKeyPress(XKeyEvent *);
+ ///
+ UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
+ ///
+ int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
+ ///
+ int Ascii(Buffer const *, std::ostream &) const { return 0; }
+ ///
+ int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
+ ///
+ int DocBook(Buffer const *, std::ostream &) const { return 0; }
+ ///
+ void Validate(LaTeXFeatures & features) const;
+ ///
+ void GetCursorPos(BufferView *, int & x, int & y) const;
+ ///
+ void ToggleInsetCursor(BufferView *);
+ ///
+ UpdatableInset * GetLockingInset();
+ ///
+ UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
+ ///
+ void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ ///
void setLabel(string const & l) { label = l; }
///
void setLabelFont(LyXFont & f) { labelfont = f; }
void setAutoCollapse(bool f) { autocollapse = f; }
///
int getMaxWidth(Painter & pain, UpdatableInset const *) const;
+ ///
+ LyXText * getLyXText(BufferView *) const;
+ void deleteLyXText(BufferView *);
protected:
///
LColor::color framecolor;
///
LyXFont labelfont;
+ ///
+ InsetText * inset;
+ // Instead of making these ints protected we could have a
+ // protected method "clickInButton" (Lgb)
+ ///
+ mutable int
+ button_length, button_top_y, button_bottom_y;
private:
///
string label;
///
bool autocollapse;
-protected:
- // Instead of making these ints protected we could have a
- // protected method "clickInButton" (Lgb)
///
- mutable int
- button_length, button_top_y, button_bottom_y;
-private:
+ int widthCollapsed;
///
- int widthOffset;
+ int oldWidth;
///
mutable int topx;
mutable int topbaseline;
+ mutable UpdateCodes need_update;
};
#endif
#include "lyxfont.h"
#include "Painter.h"
#include "buffer.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
#include "lyx_gui_misc.h"
Inset * InsetERT::Clone() const
{
- InsetERT * result = new InsetERT();
- result->init(this);
+ InsetERT * result = new InsetERT;
+ result->inset->init(inset);
result->collapsed = collapsed;
return result;
#include "BufferView.h"
#include "Painter.h"
#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
#include "FloatList.h"
#include "LaTeXFeatures.h"
Inset * InsetFloat::Clone() const
{
InsetFloat * result = new InsetFloat;
- result->init(this);
+ result->inset->init(inset);
result->collapsed = collapsed;
return result;
os << "[" << floatPlacement << "]";
os << "%\n";
- int i = InsetText::Latex(buf, os, fragile, fp);
+ int i = inset->Latex(buf, os, fragile, fp);
os << "\\end{" << floatType << "}%\n";
return i + 2;
}
-bool InsetFloat::InsertInset(BufferView * bv, Inset * inset)
+bool InsetFloat::InsertInset(BufferView * bv, Inset * in)
{
- if (!InsertInsetAllowed(inset))
+ if (!InsertInsetAllowed(in))
return false;
- return InsetText::InsertInset(bv, inset);
+ return inset->InsertInset(bv, in);
}
-bool InsetFloat::InsertInsetAllowed(Inset * inset) const
+bool InsetFloat::InsertInsetAllowed(Inset * in) const
{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ if ((in->LyxCode() == Inset::FOOT_CODE) ||
+ (in->LyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}
-
+#if 0
LyXFont InsetFloat::GetDrawFont(BufferView * bv,
LyXParagraph * p, int pos) const
{
fn.decSize().decSize();
return fn;
}
-
+#endif
void InsetFloat::InsetButtonRelease(BufferView * bv, int x, int y, int button)
{
///
bool InsertInsetAllowed(Inset * inset) const;
///
- LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
///
void InsetButtonRelease(BufferView * bv, int x, int y, int button);
private:
#include "BufferView.h"
#include "Painter.h"
#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
using std::ostream;
Inset * InsetFoot::Clone() const
{
InsetFoot * result = new InsetFoot;
- result->init(this);
+ result->inset->init(inset);
result->collapsed = collapsed;
return result;
{
os << "\\footnote{%\n";
- int i = InsetText::Latex(buf, os, fragile, fp);
+ int i = inset->Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;
}
-bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
+bool InsetFoot::InsertInset(BufferView * bv, Inset * in)
{
- if (!InsertInsetAllowed(inset))
+ if (!InsertInsetAllowed(in))
return false;
- return InsetText::InsertInset(bv, inset);
+ return inset->InsertInset(bv, in);
}
-bool InsetFoot::InsertInsetAllowed(Inset * inset) const
+bool InsetFoot::InsertInsetAllowed(Inset * in) const
{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ if ((in->LyxCode() == Inset::FOOT_CODE) ||
+ (in->LyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}
-
+#if 0
LyXFont InsetFoot::GetDrawFont(BufferView * bv,
LyXParagraph * p, int pos) const
{
fn.decSize().decSize();
return fn;
}
+#endif
///
bool InsertInsetAllowed(Inset * inset) const;
///
- LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
};
#endif
#include "BufferView.h"
#include "Painter.h"
#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
using std::ostream;
Inset * InsetList::Clone() const
{
InsetList * result = new InsetList;
- result->init(this);
+ result->inset->init(inset);
result->collapsed = collapsed;
return result;
{
os << "\\footnote{%\n";
- int i = InsetText::Latex(buf, os, fragile, fp);
+ int i = inset->Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;
}
-bool InsetList::InsertInset(BufferView * bv, Inset * inset)
+bool InsetList::InsertInset(BufferView * bv, Inset * in)
{
- if (!InsertInsetAllowed(inset))
+ if (!InsertInsetAllowed(in))
return false;
- return InsetText::InsertInset(bv, inset);
+ return inset->InsertInset(bv, in);
}
-bool InsetList::InsertInsetAllowed(Inset * inset) const
+bool InsetList::InsertInsetAllowed(Inset * in) const
{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ if ((in->LyxCode() == Inset::FOOT_CODE) ||
+ (in->LyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}
-
+#if 0
LyXFont InsetList::GetDrawFont(BufferView * bv,LyXParagraph * p, int pos) const
{
LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
fn.decSize().decSize();
return fn;
}
+#endif
///
bool InsertInsetAllowed(Inset * inset) const;
///
- LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
};
#endif
#include "BufferView.h"
#include "Painter.h"
#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
using std::ostream;
Inset * InsetMarginal::Clone() const
{
InsetMarginal * result = new InsetMarginal;
- result->init(this);
+ result->inset->init(inset);
result->collapsed = collapsed;
return result;
{
os << "\\marginpar{%\n";
- int i = InsetText::Latex(buf, os, fragile, fp);
+ int i = inset->Latex(buf, os, fragile, fp);
os << "}%\n";
return i + 2;
}
-bool InsetMarginal::InsertInset(BufferView * bv, Inset * inset)
+bool InsetMarginal::InsertInset(BufferView * bv, Inset * in)
{
- if (!InsertInsetAllowed(inset))
+ if (!InsertInsetAllowed(in))
return false;
- return InsetText::InsertInset(bv, inset);
+ return inset->InsertInset(bv, in);
}
-bool InsetMarginal::InsertInsetAllowed(Inset * inset) const
+bool InsetMarginal::InsertInsetAllowed(Inset * in) const
{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ if ((in->LyxCode() == Inset::FOOT_CODE) ||
+ (in->LyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}
-
+#if 0
LyXFont InsetMarginal::GetDrawFont(BufferView * bv,
LyXParagraph * p, int pos) const
{
fn.decSize().decSize();
return fn;
}
+#endif
///
bool InsertInsetAllowed(Inset * inset) const;
///
- LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
};
#endif
#include "BufferView.h"
#include "Painter.h"
#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
using std::ostream;
Inset * InsetMinipage::Clone() const
{
InsetMinipage * result = new InsetMinipage;
- result->init(this);
+ result->inset->init(inset);
result->collapsed = collapsed;
return result;
{
os << "\\begin{minipage}{\\columnwidth}%\n";
- int i = InsetText::Latex(buf, os, fragile, fp);
+ int i = inset->Latex(buf, os, fragile, fp);
os << "\\end{minipage}%\n";
return i + 2;
}
-bool InsetMinipage::InsertInset(BufferView * bv, Inset * inset)
+bool InsetMinipage::InsertInset(BufferView * bv, Inset * in)
{
- if (!InsertInsetAllowed(inset))
+ if (!InsertInsetAllowed(in))
return false;
- return InsetText::InsertInset(bv, inset);
+ return inset->InsertInset(bv, in);
}
-bool InsetMinipage::InsertInsetAllowed(Inset * inset) const
+bool InsetMinipage::InsertInsetAllowed(Inset * in) const
{
- if ((inset->LyxCode() == Inset::FLOAT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
+ if ((in->LyxCode() == Inset::FLOAT_CODE) ||
+ (in->LyxCode() == Inset::MARGIN_CODE)) {
return false;
}
return true;
}
-
+#if 0
LyXFont InsetMinipage::GetDrawFont(BufferView * bv,
LyXParagraph * p, int pos) const
{
fn.decSize().decSize();
return fn;
}
+#endif
///
bool InsertInsetAllowed(Inset * inset) const;
///
- LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
};
#endif
extern unsigned char getCurrentTextClass(Buffer *);
-// Jürgen, we don't like macros, even small ones like this. (Lgb)
-//#define TEXT(a) getLyXText(a)
-// I created a inline function in insettext.h instead. (Lgb)
-
InsetText::InsetText()
{
par = new LyXParagraph();
no_selection = false;
need_update = INIT;
drawTextXOffset = drawTextYOffset = 0;
- autoBreakRows = drawLockedFrame = false;
+ autoBreakRows = false;
+ drawFrame = NEVER;
xpos = 0.0;
if (ins) {
SetParagraphData(ins->par);
autoBreakRows = ins->autoBreakRows;
- drawLockedFrame = ins->drawLockedFrame;
+ drawFrame = ins->drawFrame;
}
par->SetInsetOwner(this);
frame_color = LColor::insetframe;
int InsetText::textWidth(Painter & pain) const
{
- return getMaxTextWidth(pain, this) - drawTextXOffset;
+ int w = getMaxWidth(pain, this);
+ if (w < 0) {
+// printf("WW1: %d\n",w);
+ return w;
+ }
+#if 0
+ if (owner()) {
+ w = w - top_x + owner()->x();
+ printf("WW2: %d\n",w);
+ return w; // - top_x + owner()->x();
+ }
+#endif
+ w -= (2 * TEXT_TO_INSET_OFFSET);
+// printf("WW2: %d\n",w);
+ return w; // - top_x - (2 * TEXT_TO_INSET_OFFSET);
}
last_width = width(pain, f);
last_height = ascent(pain, f) + descent(pain, f);
- if (the_locking_inset && (cpos(bv) == inset_pos)) {
+ if (the_locking_inset && (cpar(bv) == inset_par) && (cpos(bv) == inset_pos)) {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
}
y += baseline - row->ascent_of_text() + 1;
if (cleared || !locked || (need_update == FULL)) {
while (row != 0) {
- TEXT(bv)->GetVisibleRow(bv, y, x, row, y);
+ TEXT(bv)->GetVisibleRow(bv, y, x, row, y, cleared);
y += row->height();
row = row->next();
}
}
TEXT(bv)->refresh_y = 0;
TEXT(bv)->status = LyXText::UNCHANGED;
- if (drawLockedFrame && locked) {
- pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
- ascent(pain,f) + descent(pain, f), frame_color);
+ if ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)) {
+ pain.rectangle(top_x, baseline - insetAscent, insetWidth,
+ insetAscent + insetDescent, frame_color);
} else {
- pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
- ascent(pain,f) + descent(pain, f),
+ pain.rectangle(top_x, baseline - insetAscent, insetWidth,
+ insetAscent + insetDescent,
LColor::background);
}
x += width(pain, f) - TEXT_TO_INSET_OFFSET;
deleteLyXText(bv);
need_update = FULL;
}
+ int oldw = insetWidth;
+#if 1
+ insetWidth = max(textWidth(bv->painter()),
+ static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
+ (2 * TEXT_TO_INSET_OFFSET);
+#else
+ insetWidth = textWidth(bv->painter());
+ if (insetWidth < 0)
+ insetWidth = static_cast<int>(TEXT(bv)->width);
+#endif
+ if (oldw != insetWidth) {
+ printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
+ textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
+ deleteLyXText(bv);
+#if 0
+ if (owner()) {
+ owner()->update(bv, font, dodraw);
+ return;
+ }
+#else
+#if 1
+ update(bv, font, dodraw);
+#else
+ UpdateLocal(bv, INIT, false);
+#endif
+#endif
+ return;
+ }
if (dodraw && (need_update != CURSOR))
need_update = FULL;
TEXT(bv)->FullRebreak(bv);
+ if ((need_update==CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
+ the_locking_inset)
+ {
+ TEXT(bv)->UpdateInset(bv, the_locking_inset);
+ }
+
long int y_temp = 0;
Row * row = TEXT(bv)->GetRowNearY(y_temp);
insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
insetDescent = TEXT(bv)->height - row->ascent_of_text() +
TEXT_TO_INSET_OFFSET;
- insetWidth = max(textWidth(bv->painter()),
- static_cast<int>(TEXT(bv)->width)) +
- (2 * TEXT_TO_INSET_OFFSET);
+}
+
+
+void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
+{
+ TEXT(bv)->FullRebreak(bv);
+ if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
+ need_update = FULL;
+ else if (!the_locking_inset || (what != CURSOR))
+ need_update = what;
+ if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED))
+ bv->updateInset(this, mark_dirty);
+ if (old_par != cpar(bv)) {
+ bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+ old_par = cpar(bv);
+ }
}
locked = true;
the_locking_inset = 0;
inset_pos = inset_x = inset_y = 0;
- TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
- y+TEXT(bv)->first-drawTextYOffset+
- insetAscent);
- checkAndActivateInset(bv, x, y, button);
+ inset_par = 0;
+ if (!checkAndActivateInset(bv, x, y, button))
+ TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset, y);
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
bv->text->FinishUndo();
UpdateLocal(bv, FULL, false);
if (inset == cpar(bv)->GetInset(cpos(bv))) {
lyxerr[Debug::INSETS] << "OK" << endl;
the_locking_inset = inset;
-// resetPos(bv->painter());
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
inset_pos = cpos(bv);
+ inset_par = cpar(bv);
+ TEXT(bv)->UpdateInset(bv, the_locking_inset);
return true;
} else if (the_locking_inset && (the_locking_inset == inset)) {
- if (cpos(bv) == inset_pos) {
+ if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
lyxerr[Debug::INSETS] << "OK" << endl;
-// resetPos(bv->painter());
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
} else {
the_locking_inset = 0;
if (lr)
moveRight(bv, false);
- UpdateLocal(bv, FULL, false);
+ UpdateLocal(bv, CURSOR_PAR, false);
return true;
}
return the_locking_inset->UnlockInsetInInset(bv, inset, lr);
{
if (!the_locking_inset)
return false;
- if (the_locking_inset != inset)
+ if (the_locking_inset != inset) {
+ TEXT(bv)->UpdateInset(bv, the_locking_inset);
+ need_update = CURSOR_PAR;
return the_locking_inset->UpdateInsetInInset(bv, inset);
+ }
// UpdateLocal(bv, FULL, false);
- TEXT(bv)->UpdateInset(bv, inset);
- if (cpos(bv) == inset_pos) {
+ if (TEXT(bv)->UpdateInset(bv, inset))
+ UpdateLocal(bv, CURSOR_PAR, false);
+ if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
}
UpdateLocal(bv, FULL, false);
}
no_selection = false;
- TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
- y+TEXT(bv)->first-drawTextYOffset+
- insetAscent);
+
+ int tmp_x = x - drawTextXOffset;
+// int tmp_y = y + TEXT(bv)->first + insetAscent;
+ int tmp_y = y + insetAscent;
+ Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
+
if (the_locking_inset) {
- UpdatableInset * inset = 0;
- if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET)
- inset = static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
if (the_locking_inset == inset) {
the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
return;
inset_y = cy(bv) + drawTextYOffset;
inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
inset->Edit(bv, x - inset_x, y - inset_y, button);
- UpdateLocal(bv, FULL, false);
+ if (the_locking_inset)
+ UpdateLocal(bv, CURSOR_PAR, false);
return;
}
// otherwise only unlock the_locking_inset
the_locking_inset = 0;
}
if (bv->the_locking_inset) {
- if ((cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) &&
- cpar(bv)->GetInset(cpos(bv)) &&
- (cpar(bv)->GetInset(cpos(bv))->Editable() == Inset::HIGHLY_EDITABLE)) {
- UpdatableInset * inset =
- static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+ if (inset && inset->Editable() == Inset::HIGHLY_EDITABLE) {
+ UpdatableInset * uinset = static_cast<UpdatableInset*>(inset);
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
- inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
- inset->Edit(bv, x - inset_x, y - inset_y, 0);
- UpdateLocal(bv, FULL, false);
+ inset_pos = cpos(bv);
+ inset_par = cpar(bv);
+ uinset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
+ uinset->Edit(bv, x - inset_x, y - inset_y, 0);
+ if (the_locking_inset)
+ UpdateLocal(bv, CURSOR_PAR, false);
+ return;
}
}
-// selection_start_cursor = selection_end_cursor = cursor;
+ if (!inset)
+ TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+ y+TEXT(bv)->first+insetAscent);
}
{
if (!cpar(bv)->next && (cpos(bv) >= cpar(bv)->Last()))
return FINISHED;
- if (activate_inset && checkAndActivateInset(bv)) {
+ if (activate_inset && checkAndActivateInset(bv, false))
return DISPATCHED;
- }
TEXT(bv)->CursorRight(bv);
-// real_current_font = current_font = GetFont(bv->buffer(), cpar(bv), cpos(bv));
return DISPATCHED_NOUPDATE;
}
if (!cpar(bv)->previous && (cpos(bv) <= 0))
return FINISHED;
TEXT(bv)->CursorLeft(bv);
- if (activate_inset)
- if (checkAndActivateInset(bv, -1, -1))
- return DISPATCHED;
+ if (activate_inset && checkAndActivateInset(bv, true))
+ return DISPATCHED;
return DISPATCHED_NOUPDATE;
}
}
-void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
+bool InsetText::checkAndActivateInset(BufferView * bv, bool behind)
{
- if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
- need_update = FULL;
- else
- need_update = what;
- if ((need_update != CURSOR) || (TEXT(bv)->status != LyXText::UNCHANGED))
- bv->updateInset(this, mark_dirty);
- if (old_par != cpar(bv)) {
- bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
- old_par = cpar(bv);
+ if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
+ int x, y;
+ Inset * inset =
+ static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+ LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
+ if (behind) {
+ x = inset->width(bv->painter(), font);
+ y = inset->descent(bv->painter(), font);
+ } else {
+ x = y = 0;
+ }
+ inset_x = cx(bv) - top_x + drawTextXOffset;
+ inset_y = cy(bv) + drawTextYOffset;
+ inset->Edit(bv, x-inset_x, y-inset_y, 0);
+ if (!the_locking_inset)
+ return false;
+ UpdateLocal(bv, CURSOR_PAR, false);
+ return true;
}
+ return false;
}
bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
int button)
{
- if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
- UpdatableInset * inset =
- static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
- LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
+ int tmp_x = x - drawTextXOffset;
+ int tmp_y = y + insetAscent;
+ Inset * inset = bv->checkInsetHit(TEXT(bv), tmp_x, tmp_y, button);
+
+ if (inset) {
if (x < 0)
- x = inset->width(bv->painter(), font);
+ x = insetWidth;
if (y < 0)
- y = inset->descent(bv->painter(), font);
+ y = insetDescent;
inset_x = cx(bv) - top_x + drawTextXOffset;
inset_y = cy(bv) + drawTextYOffset;
inset->Edit(bv, x - inset_x, y - inset_y, button);
}
-void InsetText::SetDrawLockedFrame(bool flag)
+void InsetText::SetDrawFrame(BufferView * bv, DrawFrame how)
{
- if (flag != drawLockedFrame)
- drawLockedFrame = flag;
+ if (how != drawFrame) {
+ drawFrame = how;
+ if (bv)
+ UpdateLocal(bv, FRAME, false);
+ }
}
-void InsetText::SetFrameColor(LColor::color col)
+void InsetText::SetFrameColor(BufferView * bv, LColor::color col)
{
- if (frame_color != col)
+ if (frame_color != col) {
frame_color = col;
+ if (bv)
+ UpdateLocal(bv, FRAME, false);
+ }
}
-
+#if 0
LyXFont InsetText::GetDrawFont(BufferView * bv, LyXParagraph * p, int pos) const
{
return TEXT(bv)->GetFont(bv->buffer(), p, pos);
}
-
+#endif
int InsetText::cx(BufferView * bv) const
{
LyXText * lt = new LyXText(const_cast<InsetText *>(this));
lt->init(bv);
cache[bv] = lt;
+ if (the_locking_inset) {
+ lt->SetCursor(bv, inset_par, inset_pos);
+ }
return lt;
}
void InsetText::deleteLyXText(BufferView * bv)
{
cache.erase(bv);
+ /// then remove all LyXText in text-insets
+ LyXParagraph * p = par;
+ for(;p;p = p->next) {
+ p->deleteInsetsLyXText(bv);
+ }
}
*/
class InsetText : public UpdatableInset {
public:
- ///
- enum { TEXT_TO_INSET_OFFSET = 2 };
///
enum UpdateCodes {
NONE = 0,
FULL,
CURSOR_PAR,
CURSOR,
- SELECTION
+ SELECTION,
+ FRAME
+ };
+ ///
+ enum DrawFrame {
+ NEVER = 0,
+ LOCKED,
+ ALWAYS
};
///
explicit
///
void init(InsetText const * ins = 0);
///
+ void WriteParagraphData(Buffer const *, std::ostream &) const;
+ ///
void SetParagraphData(LyXParagraph *);
///
void SetAutoBreakRows(bool);
///
- void SetDrawLockedFrame(bool);
+ void SetDrawFrame(BufferView *, DrawFrame);
///
- void SetFrameColor(LColor::color);
+ void SetFrameColor(BufferView *, LColor::color);
///
- LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
///
LyXText * getLyXText(BufferView *) const;
void deleteLyXText(BufferView *);
///
void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
///
- void WriteParagraphData(Buffer const *, std::ostream &) const;
- ///
virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
mutable int drawTextXOffset;
mutable int drawTextYOffset;
///
bool autoBreakRows;
- bool drawLockedFrame;
+ DrawFrame drawFrame;
///
LColor::color frame_color;
///
///
string getText(int);
///
+ bool checkAndActivateInset(BufferView * bv, bool behind);
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
int button = 0);
///
mutable int last_height;
mutable int top_y;
///
+ LyXParagraph * inset_par;
+ ///
int inset_pos;
///
mutable int inset_x;
class BufferView;
class Buffer;
class Painter;
+class LyXText;
struct LaTeXFeatures;
EXTERNAL_CODE
};
+ ///
+ enum { TEXT_TO_INSET_OFFSET = 2 };
+
enum EDITABLE {
NOT_EDITABLE = 0,
IS_EDITABLE,
virtual bool DirectWrite() const;
/// Returns true if the inset should be centered alone
- virtual bool display() const { return false; }
+ virtual bool display() const { return false; }
/// Changes the display state of the inset
- virtual void display(bool) {}
+ virtual void display(bool) {}
+ ///
+ /// returns true if this inset needs a row on it's own
+ ///
+ virtual bool needFullRow() const { return false; }
///
virtual bool InsertInsetAllowed(Inset *) const { return false; }
///
virtual bool isCursorVisible() const { return cursor_visible; }
///
virtual int getMaxWidth(Painter & pain, UpdatableInset const *) const;
+ ///
+ /// because we could have fake text insets and have to call this
+ /// inside them without cast!!!
+ virtual LyXText * getLyXText(BufferView *) const { return 0; }
+ virtual void deleteLyXText(BufferView *) {}
protected:
///
solution but faster.
*/
void GetVisibleRow(BufferView *, int y_offset, int x_offset,
- Row * row_ptr, long y);
+ Row * row_ptr, long y, bool cleared=false);
/* footnotes: */
///
case LFUN_RIGHT:
{
result = DISPATCH_RESULT(mathcursor->Right(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
break;
}
case LFUN_LEFTSEL: sel = true;
case LFUN_LEFT:
{
result = DISPATCH_RESULT(mathcursor->Left(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
break;
}
case LFUN_UPSEL: sel = true;
case LFUN_UP:
result = DISPATCH_RESULT(mathcursor->Up(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
break;
case LFUN_DOWNSEL: sel = true;
case LFUN_DOWN:
result = DISPATCH_RESULT(mathcursor->Down(sel));
+ if (!sel && (result == DISPATCHED))
+ result = DISPATCHED_NOUPDATE;
break;
case LFUN_HOME:
mathcursor->Home();
+ result = DISPATCHED_NOUPDATE;
break;
case LFUN_END:
mathcursor->End();
+ result = DISPATCHED_NOUPDATE;
break;
case LFUN_DELETE_LINE_FORWARD:
//current_view->lockedInsetStoreUndo(Undo::INSERT);
if (mathcursor->Selection() || was_selection)
ToggleInsetSelection(bv);
- if (result == DISPATCHED)
+ if ((result == DISPATCHED) || (result == DISPATCHED_NOUPDATE))
ShowInsetCursor(bv);
else
bv->unlockInset(this);
cit != insetlist.end(); ++cit) {
if ((*cit).inset) {
if ((*cit).inset->IsTextInset()) {
- static_cast<InsetText *>((*cit).inset)->
- deleteLyXText(bv);
+ static_cast<UpdatableInset *>
+ ((*cit).inset)->deleteLyXText(bv);
}
}
}
for (i = 0; i < rows_; ++i) {
for (j = 0; j < columns_; ++j) {
cell_info[i][j].inset.setOwner(owner_);
- cell_info[i][j].inset.SetDrawLockedFrame(true);
+ cell_info[i][j].inset.SetDrawFrame(0, InsetText::LOCKED);
cell_info[i][j].cellno = cellno++;
}
}
} else
#endif
if (c == LyXParagraph::META_INSET) {
- Inset const * tmpinset = row->par()->GetInset(pos);
+ Inset * tmpinset = row->par()->GetInset(pos);
if (tmpinset) {
+ tmpinset->update(bview, font);
tmpinset->draw(bview, font, offset+row->baseline(), x,
cleared);
}
par->Last();
// this is the usual handling
int x = LeftMargin(bview, row);
- while (x < width && i < last) {
+ bool doitonetime = true;
+ while (doitonetime || ((x < width) && (i < last))) {
+ doitonetime = false;
char c = par->GetChar(i);
if (IsNewlineChar(c)) {
last_separator = i;
x = width; // this means break
} else if (c == LyXParagraph::META_INSET &&
- par->GetInset(i) && par->GetInset(i)->display()){
+ par->GetInset(i)) {
+
// check wether a Display() inset is
// valid here. if not, change it to
// non-display
- if (layout.isCommand()
- || (layout.labeltype == LABEL_MANUAL
- && i < BeginningOfMainBody(bview->buffer(), par))){
+ if (par->GetInset(i)->display() &&
+ (layout.isCommand() ||
+ ((layout.labeltype == LABEL_MANUAL) &&
+ (i < BeginningOfMainBody(bview->buffer(), par))))) {
// display istn't allowd
par->GetInset(i)->display(false);
x += SingleWidth(bview, par, i, c);
- } else {
- // inset is display. So break the line here
- if (i == pos){
+ } else if (par->GetInset(i)->display() ||
+ par->GetInset(i)->needFullRow()) {
+ // So break the line here
+ if (i == pos) {
if (pos < last-1) {
last_separator = i;
if (IsLineSeparatorChar(par->GetChar(i+1)))
} else
last_separator = i - 1;
x = width; // this means break
+ } else {
+#if 0
+ last_separator = i;
+ x += width;
+#else
+ x += SingleWidth(bview, par, i, c);
+#endif
}
} else {
if (IsLineSeparatorChar(c))
// the display inset stuff
if (cursor.row()->par()->GetChar(cursor.row()->pos()) == LyXParagraph::META_INSET
&& cursor.row()->par()->GetInset(cursor.row()->pos())
- && cursor.row()->par()->GetInset(cursor.row()->pos())->display())
+ && (cursor.row()->par()->GetInset(cursor.row()->pos())->display() ||
+ cursor.row()->par()->GetInset(cursor.row()->pos())->needFullRow()))
cursor.row()->fill(-1); // to force a new break
// get the cursor row fist
return;
// force complete redo when erasing display insets
// this is a cruel method but safe..... Matthias
- if (cursor.par()->GetInset(cursor.pos())->display()){
+ if (cursor.par()->GetInset(cursor.pos())->display() ||
+ cursor.par()->GetInset(cursor.pos())->needFullRow()) {
cursor.par()->Erase(cursor.pos());
RedoParagraph(bview);
return;
void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
- Row * row_ptr, long y)
+ Row * row_ptr, long y, bool cleared)
{
/* returns a printed row */
Painter & pain = bview->painter();
PrepareToPrint(bview, row_ptr, x, fill_separator,
fill_hfill, fill_label_hfill);
+ if (inset_owner && (x < 0))
+ x = 0;
x += x_offset;
// clear the area where we want to paint/print
{
clear_area = inset->doClearArea();
}
- if (clear_area) {
+ if (cleared) { // we don't need to clear it's already done!!!
+ clear_area = true;
+ } else if (clear_area) {
int w;
if (inset_owner)
w = inset_owner->width(bview->painter(), font);