+2001-07-24 Juergen Vigna <jug@sad.it>
+
+ * text.C (draw): honor the ignore_language.
+
+ * lyxfont.C (LyXFont): set language to ignore_language in FONT_INIT1.
+
2001-07-24 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* lyxfunc.C (getStatus): BREAKLINE does _not_ insert a special
+2001-07-24 Juergen Vigna <jug@sad.it>
+
+ * insetert.C (InsetERT): put init after the paragraph initialization,
+ as otherwise we don't set the draw_label right.
+
+ * insetcollapsable.C (insetMotionNotify): fixed opening/closing the
+ insets with the mouse without having strange selections.
+ (edit): if the inset was collapsed and we open it here then put the
+ cursor always at the beginning of the inset.
+ (get_new_label): 15 instead of 10 max chars in the label.
+
+ * insetert.C (localDispatch): added and handle various stuff we
+ need to handle here (font setting on paragraph break, not permitted
+ layout setting, etc.).
+
+ * inset.h: added default copy-consturctor and implemented this in
+ various insets with the change to use this in the clone function!
+
2001-07-24 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* insetminipage.C (InsetMinipage): set background color to red :)
// Initialization of the counter for the inset id's,
unsigned int Inset::inset_id = 0;
+Inset::Inset()
+ : top_x(0), top_baseline(0), scx(0), id_(inset_id++), owner_(0),
+ background_color_(LColor::inherit)
+{}
+
+
+Inset::Inset(Inset const & in, bool same_id)
+ : top_x(0), top_baseline(0), scx(0), owner_(0), name(in.name),
+ background_color_(in.background_color_)
+{
+ if (same_id)
+ id_ = in.id();
+ else
+ id_ = inset_id++;
+}
+
+
bool Inset::deletable() const
{
return true;
// some stuff for inset locking
+UpdatableInset::UpdatableInset()
+ : Inset(), cursor_visible_(false), block_drawing_(false)
+{}
+
+
+UpdatableInset::UpdatableInset(UpdatableInset const & in, bool same_id)
+ : Inset(in, same_id), cursor_visible_(false), block_drawing_(false)
+{}
+
+
void UpdatableInset::insetButtonPress(BufferView *, int x, int y, int button)
{
lyxerr[Debug::INFO] << "Inset Button Press x=" << x
};
///
- Inset() : top_x(0), top_baseline(0), scx(0), id_(inset_id++), owner_(0), background_color_(LColor::inherit) {}
- /// Virtual base destructor
+ Inset();
+ ///
+ Inset(Inset const & in, bool same_id = false);
+ ///
virtual ~Inset() {}
///
virtual int ascent(BufferView *, LyXFont const &) const = 0;
}
///
- UpdatableInset() : cursor_visible_(false), block_drawing_(false) {}
+ UpdatableInset();
+ ///
+ UpdatableInset(UpdatableInset const & in, bool same_id = false);
///
virtual EDITABLE editable() const;
const string key_prefix = "key-";
InsetBibKey::InsetBibKey(InsetCommandParams const & p)
- : InsetCommand(p)
+ : InsetCommand(p), counter(1)
{
- counter = 1;
if (getContents().empty())
setContents(key_prefix + tostr(++key_counter));
}
InsetCollapsable::InsetCollapsable(bool collapsed)
: UpdatableInset(), collapsed_(collapsed),
button_length(0), button_top_y(0), button_bottom_y(0),
- label("Label"), draw_label(label), autocollapse(true),
+ label("Label"), draw_label(label), autocollapse(false),
oldWidth(0), need_update(FULL),
inlined(false), change_label_with_text(false)
-
-
{
inset.setOwner(this);
inset.setAutoBreakRows(true);
}
+InsetCollapsable::InsetCollapsable(InsetCollapsable const & in, bool same_id)
+ : UpdatableInset(in, same_id), collapsed_(in.collapsed_),
+ framecolor(in.framecolor), labelfont(in.labelfont),
+ button_length(0), button_top_y(0), button_bottom_y(0),
+ label(in.label), draw_label(label), autocollapse(in.autocollapse),
+ oldWidth(0), need_update(FULL),
+ inlined(in.inlined), change_label_with_text(in.change_label_with_text)
+{
+ inset.init(&(in.inset), same_id);
+ inset.setOwner(this);
+}
+
+
+Inset * InsetCollapsable::clone(Buffer const &, bool same_id) const
+{
+ return new InsetCollapsable(*const_cast<InsetCollapsable *>(this),
+ same_id);
+}
+
+
bool InsetCollapsable::insertInset(BufferView * bv, Inset * in)
{
if (!insetAllowed(in->lyxCode())) {
if (!bv->lockInset(this))
return;
bv->updateInset(this, false);
- inset.edit(bv, 0, 0, button);
+ inset.edit(bv);
} else {
if (!bv->lockInset(this))
return;
- LyXFont font(LyXFont::ALL_SANE);
- int yy = ascent(bv, font) + yp -
- (ascent_collapsed(bv->painter()) +
- descent_collapsed(bv->painter()) +
- inset.ascent(bv, font));
- inset.edit(bv, xp, yy, button);
+ if (yp <= button_bottom_y) {
+ inset.edit(bv);
+ } else {
+ LyXFont font(LyXFont::ALL_SANE);
+ int yy = ascent(bv, font) + yp -
+ (ascent_collapsed(bv->painter()) +
+ descent_collapsed(bv->painter()) +
+ inset.ascent(bv, font));
+ inset.edit(bv, xp, yy, button);
+ }
}
}
bv->unlockInset(this);
bv->updateInset(this, false);
}
- } else if (!collapsed_ && (y > button_top_y)) {
+ } else if (!collapsed_ && (y > button_bottom_y)) {
LyXFont font(LyXFont::ALL_SANE);
int yy = ascent(bv, font) + y -
(ascent_collapsed(bv->painter()) +
void InsetCollapsable::insetMotionNotify(BufferView * bv,
int x, int y, int state)
{
- if (x > button_bottom_y) {
+ if (y > button_bottom_y) {
LyXFont font(LyXFont::ALL_SANE);
int yy = ascent(bv, font) + y -
(ascent_collapsed(bv->painter()) +
string InsetCollapsable::get_new_label() const
{
string la;
- Paragraph::size_type const max_length = 10;
+ Paragraph::size_type const max_length = 15;
int n = std::min(max_length, inset.paragraph()->size());
int i,j;
/// inset is initially collapsed if bool = true
InsetCollapsable(bool = false);
///
+ InsetCollapsable(InsetCollapsable const & in, bool same_id = false);
+ ///
+ Inset * clone(Buffer const &, bool same_id = false) const;
+
void read(Buffer const *, LyXLex &);
///
void write(Buffer const *, std::ostream &) const;
InsetCommand::InsetCommand(InsetCommandParams const & p, bool)
: p_( p.getCmdName(), p.getContents(), p.getOptions() )
-{
-}
+{}
void InsetCommand::setParams(InsetCommandParams const & p )
#include "insets/insettext.h"
#include "support/LOstream.h"
#include "lyx_gui_misc.h"
+#include "BufferView.h"
+#include "LyXView.h"
using std::ostream;
#else
labelfont.setColor(LColor::latex);
#endif
- setAutoCollapse(false);
setInsetName("ERT");
}
+
InsetERT::InsetERT() : InsetCollapsable()
{
init();
}
+#if 0
+InsetERT::InsetERT(InsetERT const & in, bool same_id)
+ : InsetCollapsable(in, same_id)
+{
+}
+#endif
+
+
InsetERT::InsetERT(string const & contents, bool collapsed)
: InsetCollapsable(collapsed)
{
- init();
-
- LyXFont const font(LyXFont::ALL_INHERIT);
+ LyXFont font(LyXFont::ALL_INHERIT);
+ font.setFamily(LyXFont::TYPEWRITER_FAMILY);
+ font.setColor(LColor::latex);
string::const_iterator cit = contents.begin();
string::const_iterator end = contents.end();
Paragraph::size_type pos = 0;
for (; cit != end; ++cit) {
inset.paragraph()->insertChar(pos++, *cit, font);
}
+ // the init has to be after the initialization of the paragraph
+ // because of the label settings (draw_label for ert insets).
+ init();
}
}
-Inset * InsetERT::clone(Buffer const &, bool same_id) const
-{
- InsetERT * result = new InsetERT;
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- if (same_id)
- result->id_ = id_;
- return result;
-}
-
-
string const InsetERT::editMessage() const
{
return _("Opened ERT Inset");
#ifndef NO_LATEX
LyXFont font(LyXFont::ALL_SANE);
font.setLatex (LyXFont::ON);
+#else
+ LyXFont font(LyXFont::ALL_INHERIT);
+ font.setFamily(LyXFont::TYPEWRITER_FAMILY);
+ font.setColor(LColor::latex);
#endif
+ inset.setFont(bv, font);
}
{
return 0;
}
+
+
+UpdatableInset::RESULT
+InsetERT::localDispatch(BufferView * bv, kb_action action, string const & arg)
+{
+ UpdatableInset::RESULT result = DISPATCHED_NOUPDATE;
+
+ switch(action) {
+ case LFUN_LAYOUT:
+ bv->owner()->setLayout(inset.paragraph()->getLayout());
+ break;
+ default:
+ result = InsetCollapsable::localDispatch(bv, action, arg);
+ }
+ switch(action) {
+ case LFUN_BREAKPARAGRAPH:
+ case LFUN_BREAKPARAGRAPHKEEPLAYOUT: {
+#ifndef NO_LATEX
+ LyXFont font(LyXFont::ALL_SANE);
+ font.setLatex (LyXFont::ON);
+#else
+ LyXFont font(LyXFont::ALL_INHERIT);
+ font.setFamily(LyXFont::TYPEWRITER_FAMILY);
+ font.setColor(LColor::latex);
+#endif
+ inset.setFont(bv, font);
+ }
+ break;
+ default:
+ break;
+ }
+ return result;
+}
///
InsetERT(string const & contents, bool collapsed);
///
- virtual void write(Buffer const * buf, std::ostream & os) const;
+ void write(Buffer const * buf, std::ostream & os) const;
///
- virtual Inset * clone(Buffer const &, bool same_id = false) const;
+ string const editMessage() const;
///
- virtual string const editMessage() const;
+ bool insertInset(BufferView *, Inset *);
///
- virtual bool insertInset(BufferView *, Inset *);
+ bool insetAllowed(Inset::Code) const { return false; }
///
- virtual bool insetAllowed(Inset::Code) const { return false; }
- ///
- virtual void setFont(BufferView *, LyXFont const &,
+ void setFont(BufferView *, LyXFont const &,
bool toggleall = false, bool selectall = false);
///
- virtual void edit(BufferView *, int, int, unsigned int);
+ void edit(BufferView *, int, int, unsigned int);
///
- virtual void edit(BufferView * bv, bool front = true);
+ void edit(BufferView * bv, bool front = true);
///
- virtual int latex(Buffer const *, std::ostream &, bool fragile,
+ int latex(Buffer const *, std::ostream &, bool fragile,
bool free_spc) const;
///
- virtual int ascii(Buffer const *,
+ int ascii(Buffer const *,
std::ostream &, int linelen = 0) const;
///
- virtual int linuxdoc(Buffer const *, std::ostream &) const;
+ int linuxdoc(Buffer const *, std::ostream &) const;
+ ///
+ int docBook(Buffer const *, std::ostream &) const;
///
- virtual int docBook(Buffer const *, std::ostream &) const;
+ UpdatableInset::RESULT localDispatch(BufferView *, kb_action,
+ string const &);
private:
///
void init();
font.decSize();
font.setColor(LColor::collapsable);
setLabelFont(font);
- setAutoCollapse(false);
floatType_ = type;
setInsetName(type);
}
+InsetFloat::InsetFloat(InsetFloat const & in, bool same_id)
+ : InsetCollapsable(in, same_id), floatType_(in.floatType_),
+ floatPlacement_(in.floatPlacement_), wide_(in.wide_)
+{}
+
+
void InsetFloat::write(Buffer const * buf, ostream & os) const
{
os << "Float " // getInsetName()
Inset * InsetFloat::clone(Buffer const &, bool same_id) const
{
- InsetFloat * result = new InsetFloat(floatType_);
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- if (same_id)
- result->id_ = id_;
- return result;
+ return new InsetFloat(*const_cast<InsetFloat *>(this), same_id);
}
///
InsetFloat(string const &);
///
+ InsetFloat(InsetFloat const &, bool same_id = false);
+ ///
void write(Buffer const * buf, std::ostream & os) const;
///
void read(Buffer const * buf, LyXLex & lex);
}
-Inset * InsetFoot::clone(Buffer const &, bool same_id) const
-{
- InsetFoot * result = new InsetFoot;
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- if (same_id)
- result->id_ = id_;
- return result;
-}
-
-
string const InsetFoot::editMessage() const
{
return _("Opened Footnote Inset");
///
InsetFoot();
///
- Inset * clone(Buffer const &, bool same_id = false) const;
- ///
Inset::Code lyxCode() const { return Inset::FOOT_CODE; }
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
}
-Inset * InsetList::clone(Buffer const &, bool same_id) const
-{
- InsetList * result = new InsetList;
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- if (same_id)
- result->id_ = id_;
- return result;
-}
-
-
string const InsetList::editMessage() const
{
return _("Opened List Inset");
///
void write(Buffer const * buf, std::ostream & os) const;
///
- virtual Inset * clone(Buffer const &, bool same_id = false) const;
- ///
Inset::Code lyxCode() const { return Inset::FOOT_CODE; }
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
}
-Inset * InsetMarginal::clone(Buffer const &, bool same_id) const
-{
- InsetMarginal * result = new InsetMarginal;
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- if (same_id)
- result->id_ = id_;
- return result;
-}
-
-
string const InsetMarginal::editMessage() const
{
return _("Opened Marginal Note Inset");
///
InsetMarginal();
///
- Inset * clone(Buffer const &, bool same_id = false) const;
- ///
Inset::Code lyxCode() const { return Inset::MARGIN_CODE; }
///
int latex(Buffer const *, std::ostream &, bool fragile, bool fp) const;
}
+InsetMinipage::InsetMinipage(InsetMinipage const & in, bool same_id)
+ : InsetCollapsable(in, same_id),
+ pos_(in.pos_), inner_pos_(in.inner_pos_),
+ height_(in.height_), width_(in.width_)
+{}
+
+
+Inset * InsetMinipage::clone(Buffer const &, bool same_id) const
+{
+ return new InsetMinipage(*const_cast<InsetMinipage *>(this), same_id);
+}
+
+
InsetMinipage::~InsetMinipage()
{
hideDialog();
<< endl;
}
}
-#ifdef WITH_WARNINGS
-#warning Remove me before final 1.2.0 (Jug)
-#warning Can we please remove this as soon as possible? (Lgb)
-#endif
- // this is only for compatibility to the intermediate format and should
- // vanish till the final 1.2.0!
- if (lex.IsOK()) {
- if (token.empty()) {
- lex.next();
- token = lex.GetString();
- }
- if (token == "widthp") {
- lex.next();
- // only do this if the width_-string was not already set!
- if (width_.empty())
- width_ = lex.GetString() + "%";
- token = string();
- }
- }
if (!token.empty())
lex.pushToken(token);
InsetCollapsable::read(buf, lex);
}
-Inset * InsetMinipage::clone(Buffer const &, bool same_id) const
-{
- InsetMinipage * result = new InsetMinipage;
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- result->pos_ = pos_;
- result->inner_pos_ = inner_pos_;
- result->height_ = height_;
- result->width_ = width_;
- if (same_id)
- result->id_ = id_;
- return result;
-}
-
-
int InsetMinipage::ascent(BufferView * bv, LyXFont const & font) const
{
if (collapsed_)
///
InsetMinipage();
///
+ InsetMinipage(InsetMinipage const &, bool same_id = false);
+ ///
~InsetMinipage();
///
void write(Buffer const * buf, std::ostream & os) const;
///
void read(Buffer const * buf, LyXLex & lex);
///
- virtual Inset * clone(Buffer const &, bool same_id = false) const;
+ Inset * clone(Buffer const &, bool same_id = false) const;
///
int ascent(BufferView *, LyXFont const &) const;
///
Paragraph * par = inset.paragraph();
Paragraph::size_type pos = 0;
buf->insertStringAsLines(par, pos, LyXFont(LyXFont::ALL_INHERIT),
- strip(contents, '\n'));
-}
-
-
-Inset * InsetNote::clone(Buffer const &, bool same_id) const
-{
- InsetNote * result = new InsetNote;
- result->inset.init(&inset, same_id);
-
- result->collapsed_ = collapsed_;
- if (same_id)
- result->id_ = id_;
- return result;
+ strip(contents, '\n'));
}
/// constructor with initial contents
InsetNote(Buffer const *, string const & contents, bool collapsed);
///
- virtual Inset * clone(Buffer const &, bool) const;
- ///
virtual string const editMessage() const;
///
virtual Inset::Code lyxCode() const { return Inset::IGNORE_CODE; }
InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf,
bool same_id)
- : buffer(&buf)
+ : UpdatableInset(tab, same_id), buffer(&buf)
{
tabular.reset(new LyXTabular(this, *(tab.tabular)));
the_locking_inset = 0;
actrow = actcell = 0;
sel_cell_start = sel_cell_end = 0;
need_update = INIT;
- if (same_id)
- id_ = tab.id_;
}
autoBreakRows = false;
drawFrame_ = NEVER;
xpos = 0.0;
+ frame_color = LColor::insetframe;
if (ins) {
setParagraphData(ins->par);
autoBreakRows = ins->autoBreakRows;
drawFrame_ = ins->drawFrame_;
+ frame_color = ins->frame_color;
if (same_id)
id_ = ins->id_;
}
par->setInsetOwner(this);
- frame_color = LColor::insetframe;
locked = false;
old_par = 0;
last_drawn_width = -1;
Inset * InsetText::clone(Buffer const &, bool same_id) const
{
- InsetText * t = new InsetText(*this, same_id);
- return t;
+ return new InsetText(*this, same_id);
}
LyXFont::LyXFont(LyXFont::FONT_INIT1)
- : bits(inherit), lang(default_language)
+ : bits(inherit), lang(ignore_language)
{}
void LyXText::draw(BufferView * bview, Row const * row,
- Paragraph::size_type & vpos,
- int offset, float & x, bool cleared)
+ Paragraph::size_type & vpos,
+ int offset, float & x, bool cleared)
{
Painter & pain = bview->painter();
++vpos;
if (lyxrc.mark_foreign_language &&
+ font.language() != ignore_language &&
font.language() != bview->buffer()->params.language) {
int const y = offset + row->height() - 1;
- pain.line(int(tmpx), y, int(x), y,
- LColor::language);
+ pain.line(int(tmpx), y, int(x), y, LColor::language);
}
return;