2000-03-08 13:52:57 +00:00
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2001-03-14 14:53:55 +00:00
|
|
|
* Copyright 1998-2001 The LyX Team.
|
2000-03-08 13:52:57 +00:00
|
|
|
*
|
2000-06-28 16:03:01 +00:00
|
|
|
* ======================================================
|
|
|
|
*/
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insetcollapsable.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "lyxfont.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "Painter.h"
|
2000-07-04 11:30:07 +00:00
|
|
|
#include "insets/insettext.h"
|
2000-04-24 20:58:23 +00:00
|
|
|
#include "support/LOstream.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
#include "debug.h"
|
2000-07-07 07:46:37 +00:00
|
|
|
#include "lyxtext.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
class LyXText;
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
using std::ostream;
|
2000-07-05 14:57:48 +00:00
|
|
|
using std::endl;
|
2000-07-17 18:27:53 +00:00
|
|
|
using std::max;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
2001-04-04 20:34:04 +00:00
|
|
|
|
2000-06-28 16:03:01 +00:00
|
|
|
InsetCollapsable::InsetCollapsable()
|
2001-03-30 14:28:17 +00:00
|
|
|
: UpdatableInset()
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
inset.setOwner(this);
|
|
|
|
collapsed = false;
|
|
|
|
label = "Label";
|
|
|
|
autocollapse = true;
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.setAutoBreakRows(true);
|
|
|
|
inset.setDrawFrame(0, InsetText::ALWAYS);
|
|
|
|
inset.setFrameColor(0, LColor::collapsableframe);
|
2001-04-02 14:02:58 +00:00
|
|
|
button_length = button_top_y = button_bottom_y = 0;
|
|
|
|
setInsetName("Collapsable");
|
|
|
|
widthCollapsed = oldWidth = 0;
|
|
|
|
need_update = FULL;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetCollapsable::insertInset(BufferView * bv, Inset * in)
|
2000-07-04 19:16:35 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
if (!insertInsetAllowed(in)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
lyxerr << "InsetCollapsable::InsertInset: "
|
|
|
|
"Unable to insert inset." << endl;
|
|
|
|
return false;
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.insertInset(bv, in);
|
2000-07-04 19:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::write(Buffer const * buf, ostream & os) const
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
os << "collapsed " << tostr(collapsed) << "\n";
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.writeParagraphData(buf, os);
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::read(Buffer const * buf, LyXLex & lex)
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (lex.IsOK()) {
|
|
|
|
lex.next();
|
|
|
|
string const token = lex.GetString();
|
|
|
|
if (token == "collapsed") {
|
|
|
|
lex.next();
|
|
|
|
collapsed = lex.GetBool();
|
|
|
|
} else {
|
|
|
|
lyxerr << "InsetCollapsable::Read: Missing collapsed!"
|
2001-04-04 20:34:04 +00:00
|
|
|
<< endl;
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.read(buf, lex);
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
int InsetCollapsable::ascent_collapsed(Painter & pain, LyXFont const &) const
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int width = 0;
|
|
|
|
int ascent = 0;
|
|
|
|
int descent = 0;
|
|
|
|
pain.buttonText(0, 0, label, labelfont, false,
|
2001-04-04 20:34:04 +00:00
|
|
|
width, ascent, descent);
|
2001-04-02 14:02:58 +00:00
|
|
|
return ascent;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetCollapsable::descent_collapsed(Painter & pain, LyXFont const &) const
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int width = 0;
|
|
|
|
int ascent = 0;
|
|
|
|
int descent = 0;
|
|
|
|
pain.buttonText(0, 0, label, labelfont, false,
|
2001-04-04 20:34:04 +00:00
|
|
|
width, ascent, descent);
|
2001-04-02 14:02:58 +00:00
|
|
|
return descent;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetCollapsable::width_collapsed(Painter & pain, LyXFont const &) const
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int width;
|
|
|
|
int ascent;
|
|
|
|
int descent;
|
|
|
|
pain.buttonText(TEXT_TO_INSET_OFFSET, 0, label, labelfont, false,
|
2001-04-04 20:34:04 +00:00
|
|
|
width, ascent, descent);
|
2001-04-02 14:02:58 +00:00
|
|
|
return width + (2*TEXT_TO_INSET_OFFSET);
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetCollapsable::ascent(BufferView * bv, LyXFont const & font) const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return ascent_collapsed(bv->painter(), font);
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetCollapsable::descent(BufferView * bv, LyXFont const & font) const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (collapsed)
|
|
|
|
return descent_collapsed(bv->painter(), font);
|
2001-03-28 09:28:48 +00:00
|
|
|
|
2001-04-04 20:34:04 +00:00
|
|
|
return descent_collapsed(bv->painter(), font)
|
|
|
|
+ inset.descent(bv, font)
|
|
|
|
+ inset.ascent(bv, font)
|
|
|
|
+ TEXT_TO_BOTTOM_OFFSET;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
int InsetCollapsable::width(BufferView * bv, LyXFont const & font) const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (collapsed)
|
|
|
|
return widthCollapsed;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
return (inset.width(bv, font) > widthCollapsed) ?
|
|
|
|
inset.width(bv, font) : widthCollapsed;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const &,
|
2001-04-04 20:34:04 +00:00
|
|
|
int baseline, float & x) const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int width = 0;
|
|
|
|
pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET,
|
2001-04-04 20:34:04 +00:00
|
|
|
baseline, label, labelfont, true, width);
|
2001-04-02 14:02:58 +00:00
|
|
|
x += width + TEXT_TO_INSET_OFFSET;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-26 17:47:40 +00:00
|
|
|
void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
|
|
|
|
int baseline, float & x, bool cleared) const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-27 14:03:25 +00:00
|
|
|
if (nodraw())
|
|
|
|
return;
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
Painter & pain = bv->painter();
|
2000-06-21 15:07:57 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
button_length = widthCollapsed;
|
|
|
|
button_top_y = -ascent(bv, f);
|
|
|
|
button_bottom_y = -ascent(bv, f) + ascent_collapsed(pain,f) +
|
2001-04-04 20:34:04 +00:00
|
|
|
descent_collapsed(pain, f);
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (collapsed) {
|
|
|
|
draw_collapsed(pain, f, baseline, x);
|
|
|
|
x += TEXT_TO_INSET_OFFSET;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
float old_x = x;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
UpdatableInset::draw(bv, f, baseline, x, cleared);
|
|
|
|
#else
|
|
|
|
if (!owner())
|
|
|
|
x += static_cast<float>(scroll());
|
|
|
|
#endif
|
2001-04-04 20:34:04 +00:00
|
|
|
if (!cleared && (inset.need_update == InsetText::FULL ||
|
|
|
|
inset.need_update == InsetText::INIT ||
|
|
|
|
top_x != int(x) ||
|
2001-04-27 14:03:25 +00:00
|
|
|
top_baseline != baseline))
|
|
|
|
{
|
|
|
|
#if 1
|
|
|
|
// we don't need anymore to clear here we just have to tell
|
|
|
|
// the underlying LyXText that it should do the RowClear!
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.setUpdateStatus(bv, InsetText::FULL);
|
2001-07-06 15:57:54 +00:00
|
|
|
bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
|
2001-04-27 14:03:25 +00:00
|
|
|
return;
|
|
|
|
#else
|
|
|
|
int w = owner() ? width(bv, f) : pain.paperWidth();
|
2001-04-02 14:02:58 +00:00
|
|
|
int h = ascent(bv, f) + descent(bv, f);
|
2001-04-04 20:34:04 +00:00
|
|
|
int const tx = (needFullRow() && !owner()) ? 0 : int(x);
|
|
|
|
int const ty = max(0, baseline - ascent(bv, f));
|
2001-04-24 15:25:26 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if ((ty + h) > pain.paperHeight())
|
|
|
|
h = pain.paperHeight();
|
|
|
|
if ((top_x + w) > pain.paperWidth())
|
|
|
|
w = pain.paperWidth();
|
|
|
|
if (baseline < 0)
|
|
|
|
h += (baseline - ascent(bv, f));
|
|
|
|
pain.fillRectangle(tx, ty - 1, w, h + 2);
|
|
|
|
cleared = true;
|
2001-04-27 14:03:25 +00:00
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
top_x = int(x);
|
|
|
|
top_baseline = baseline;
|
|
|
|
|
2001-04-04 20:34:04 +00:00
|
|
|
int const bl = baseline - ascent(bv, f) + ascent_collapsed(pain, f);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
draw_collapsed(pain, f, bl, old_x);
|
2001-04-02 14:02:58 +00:00
|
|
|
inset.draw(bv, f,
|
2001-04-04 20:34:04 +00:00
|
|
|
bl + descent_collapsed(pain, f) + inset.ascent(bv, f),
|
|
|
|
x, cleared);
|
2001-04-02 14:02:58 +00:00
|
|
|
need_update = NONE;
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::edit(BufferView * bv, int xp, int yp,
|
2001-04-04 20:34:04 +00:00
|
|
|
unsigned int button)
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset::edit(bv, xp, yp, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
2001-07-11 12:10:46 +00:00
|
|
|
if (collapsed) {
|
2001-04-02 14:02:58 +00:00
|
|
|
collapsed = false;
|
|
|
|
if (!bv->lockInset(this))
|
|
|
|
return;
|
|
|
|
bv->updateInset(this, false);
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.edit(bv, 0, 0, button);
|
2001-07-11 12:10:46 +00:00
|
|
|
} else {
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!bv->lockInset(this))
|
|
|
|
return;
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.edit(bv, xp, yp + (top_baseline - inset.y()), button);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
Inset::EDITABLE InsetCollapsable::editable() const
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
|
|
|
if (collapsed)
|
|
|
|
return IS_EDITABLE;
|
|
|
|
return HIGHLY_EDITABLE;
|
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::insetUnlock(BufferView * bv)
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (autocollapse) {
|
|
|
|
collapsed = true;
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.insetUnlock(bv);
|
2001-04-27 14:03:25 +00:00
|
|
|
if (scroll())
|
|
|
|
scroll(bv, 0.0F);
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->updateInset(this, false);
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::insetButtonPress(BufferView * bv, int x, int y,
|
2001-04-04 20:34:04 +00:00
|
|
|
int button)
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!collapsed && (y > button_bottom_y)) {
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.insetButtonPress(bv, x, y + (top_baseline - inset.y()),
|
2001-04-04 20:34:04 +00:00
|
|
|
button);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::insetButtonRelease(BufferView * bv,
|
2000-04-24 20:58:23 +00:00
|
|
|
int x, int y, int button)
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if ((x >= 0) && (x < button_length) &&
|
2001-04-04 20:34:04 +00:00
|
|
|
(y >= button_top_y) && (y <= button_bottom_y)) {
|
2001-04-02 14:02:58 +00:00
|
|
|
if (collapsed) {
|
|
|
|
collapsed = false;
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.insetButtonRelease(bv, 0, 0, button);
|
2001-04-02 14:02:58 +00:00
|
|
|
bv->updateInset(this, false);
|
|
|
|
} else {
|
|
|
|
collapsed = true;
|
|
|
|
bv->unlockInset(this);
|
|
|
|
bv->updateInset(this, false);
|
|
|
|
}
|
|
|
|
} else if (!collapsed && (y > button_top_y)) {
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.insetButtonRelease(bv, x, y + (top_baseline-inset.y()),
|
2001-04-04 20:34:04 +00:00
|
|
|
button);
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::insetMotionNotify(BufferView * bv,
|
2000-04-24 20:58:23 +00:00
|
|
|
int x, int y, int state)
|
2000-03-08 13:52:57 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (x > button_bottom_y) {
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.insetMotionNotify(bv, x, y + (top_baseline - inset.y()),
|
2001-04-04 20:34:04 +00:00
|
|
|
state);
|
2001-04-02 14:02:58 +00:00
|
|
|
}
|
2000-03-08 13:52:57 +00:00
|
|
|
}
|
2000-04-19 14:42:19 +00:00
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::insetKeyPress(XKeyEvent * xke)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.insetKeyPress(xke);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
int InsetCollapsable::latex(Buffer const * buf, ostream & os,
|
2001-04-04 20:34:04 +00:00
|
|
|
bool fragile, bool free_spc) const
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.latex(buf, os, fragile, free_spc);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-29 15:00:20 +00:00
|
|
|
int InsetCollapsable::getMaxWidth(BufferView * bv,
|
2000-04-24 20:58:23 +00:00
|
|
|
UpdatableInset const * inset) const
|
2000-04-19 14:42:19 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
int const w = UpdatableInset::getMaxWidth(bv, inset);
|
2000-04-19 14:42:19 +00:00
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
if (w < 0) {
|
|
|
|
// What does a negative max width signify? (Lgb)
|
|
|
|
// Use the max width of the draw-area (Jug)
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
// should be at least 30 pixels !!!
|
|
|
|
return max(30, w - widthCollapsed);
|
2000-04-19 14:42:19 +00:00
|
|
|
}
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2000-07-04 15:46:55 +00:00
|
|
|
void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
|
2001-04-04 20:34:04 +00:00
|
|
|
bool reinit)
|
2000-06-26 15:10:49 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (reinit) {
|
|
|
|
need_update = FULL;
|
|
|
|
if (owner())
|
|
|
|
owner()->update(bv, font, true);
|
2000-07-04 11:30:07 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
if (!widthCollapsed) {
|
|
|
|
widthCollapsed = width_collapsed(bv->painter(), font);
|
|
|
|
inset.resizeLyXText(bv);
|
|
|
|
need_update = FULL;
|
|
|
|
if (owner()) {
|
|
|
|
owner()->update(bv, font);
|
|
|
|
return;
|
|
|
|
}
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
if (oldWidth != width(bv, font)) {
|
|
|
|
oldWidth = width(bv, font);
|
|
|
|
inset.resizeLyXText(bv);
|
|
|
|
need_update = FULL;
|
|
|
|
if (owner()) {
|
|
|
|
owner()->update(bv, font);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inset.update(bv, font);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
UpdatableInset::RESULT
|
2001-06-28 10:25:20 +00:00
|
|
|
InsetCollapsable::localDispatch(BufferView * bv, kb_action action,
|
2000-07-15 23:51:46 +00:00
|
|
|
string const & arg)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset::RESULT result = inset.localDispatch(bv, action, arg);
|
2001-04-02 14:02:58 +00:00
|
|
|
if (result == FINISHED)
|
|
|
|
bv->unlockInset(this);
|
|
|
|
return result;
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetCollapsable::lockInsetInInset(BufferView * bv, UpdatableInset * in)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (&inset == in)
|
|
|
|
return true;
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.lockInsetInInset(bv, in);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetCollapsable::unlockInsetInInset(BufferView * bv, UpdatableInset * in,
|
2000-07-04 11:30:07 +00:00
|
|
|
bool lr)
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (&inset == in) {
|
|
|
|
bv->unlockInset(this);
|
|
|
|
return true;
|
|
|
|
}
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.unlockInsetInInset(bv, in, lr);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
bool InsetCollapsable::updateInsetInInset(BufferView * bv, Inset *in)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
if (&inset == in)
|
|
|
|
return true;
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.updateInsetInInset(bv, in);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
unsigned int InsetCollapsable::insetInInsetY()
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.insetInInsetY() - (top_baseline - inset.y());
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::validate(LaTeXFeatures & features) const
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.validate(features);
|
2000-06-26 15:10:49 +00:00
|
|
|
}
|
2000-07-04 11:30:07 +00:00
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::getCursorPos(BufferView * bv, int & x, int & y) const
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.getCursorPos(bv, x , y);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::toggleInsetCursor(BufferView * bv)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.toggleInsetCursor(bv);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-12 12:26:06 +00:00
|
|
|
UpdatableInset * InsetCollapsable::getLockingInset() const
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * in = inset.getLockingInset();
|
2001-04-02 14:02:58 +00:00
|
|
|
if (&inset == in)
|
2001-07-12 12:26:06 +00:00
|
|
|
return const_cast<InsetCollapsable *>(this);
|
2001-04-02 14:02:58 +00:00
|
|
|
return in;
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
UpdatableInset * InsetCollapsable::getFirstLockingInsetOfType(Inset::Code c)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
if (c == lyxCode())
|
2001-04-02 14:02:58 +00:00
|
|
|
return this;
|
2001-06-28 10:25:20 +00:00
|
|
|
return inset.getFirstLockingInsetOfType(c);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
void InsetCollapsable::setFont(BufferView * bv, LyXFont const & font,
|
2001-05-28 15:11:24 +00:00
|
|
|
bool toggleall, bool selectall)
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-06-28 10:25:20 +00:00
|
|
|
inset.setFont(bv, font, toggleall, selectall);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
bool InsetCollapsable::doClearArea() const
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return inset.doClearArea();
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-22 15:07:07 +00:00
|
|
|
LyXText * InsetCollapsable::getLyXText(BufferView const * bv,
|
2001-04-04 20:34:04 +00:00
|
|
|
bool const recursive) const
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
return inset.getLyXText(bv, recursive);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-14 14:57:20 +00:00
|
|
|
void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
|
2000-07-04 11:30:07 +00:00
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
inset.deleteLyXText(bv, recursive);
|
2000-07-14 14:57:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-07 14:51:20 +00:00
|
|
|
void InsetCollapsable::resizeLyXText(BufferView * bv, bool force) const
|
2000-07-14 14:57:20 +00:00
|
|
|
{
|
2001-06-07 14:51:20 +00:00
|
|
|
inset.resizeLyXText(bv, force);
|
2001-04-02 14:02:58 +00:00
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
oldWidth = width(bv, font);
|
2000-07-04 11:30:07 +00:00
|
|
|
}
|
2001-04-04 23:00:42 +00:00
|
|
|
|
|
|
|
|
2001-04-05 08:03:26 +00:00
|
|
|
std::vector<string> const InsetCollapsable::getLabelList() const
|
2001-04-04 23:00:42 +00:00
|
|
|
{
|
|
|
|
return inset.getLabelList();
|
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
bool InsetCollapsable::nodraw() const
|
|
|
|
{
|
|
|
|
return inset.nodraw();
|
|
|
|
}
|
|
|
|
|
2001-06-05 17:05:51 +00:00
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
int InsetCollapsable::scroll(bool recursive) const
|
|
|
|
{
|
|
|
|
int sx = UpdatableInset::scroll(false);
|
|
|
|
|
|
|
|
if (recursive)
|
|
|
|
sx += inset.scroll(recursive);
|
|
|
|
|
|
|
|
return sx;
|
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
|
2001-07-09 09:16:00 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
Paragraph * InsetCollapsable::getParFromID(int id) const
|
|
|
|
{
|
|
|
|
return inset.getParFromID(id);
|
|
|
|
}
|
|
|
|
|
2001-07-09 09:16:00 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
Paragraph * InsetCollapsable::firstParagraph() const
|
|
|
|
{
|
|
|
|
return inset.firstParagraph();
|
|
|
|
}
|
|
|
|
|
2001-07-09 09:16:00 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
LyXCursor const & InsetCollapsable::cursor(BufferView * bv) const
|
|
|
|
{
|
|
|
|
return inset.cursor(bv);
|
|
|
|
}
|
|
|
|
|
2001-07-09 09:16:00 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
Inset * InsetCollapsable::getInsetFromID(int id_arg) const
|
|
|
|
{
|
|
|
|
if (id_arg == id())
|
|
|
|
return const_cast<InsetCollapsable *>(this);
|
|
|
|
return inset.getInsetFromID(id_arg);
|
|
|
|
}
|