2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetcollapsable.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-06-28 16:03:01 +00:00
|
|
|
|
*/
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "insetcollapsable.h"
|
2002-08-13 14:40:38 +00:00
|
|
|
|
|
2003-09-05 09:01:27 +00:00
|
|
|
|
#include "buffer.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#include "BufferView.h"
|
2003-11-06 16:43:12 +00:00
|
|
|
|
#include "cursor.h"
|
2000-07-04 19:16:35 +00:00
|
|
|
|
#include "debug.h"
|
2003-10-29 10:47:21 +00:00
|
|
|
|
#include "dispatchresult.h"
|
2003-09-16 10:54:23 +00:00
|
|
|
|
#include "LColor.h"
|
2001-07-29 15:34:18 +00:00
|
|
|
|
#include "lyxlex.h"
|
2002-08-13 17:43:40 +00:00
|
|
|
|
#include "funcrequest.h"
|
2003-05-30 06:48:24 +00:00
|
|
|
|
#include "metricsinfo.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
|
#include "paragraph.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
2002-08-13 14:40:38 +00:00
|
|
|
|
#include "frontends/font_metrics.h"
|
|
|
|
|
#include "frontends/Painter.h"
|
2003-02-25 14:51:38 +00:00
|
|
|
|
#include "frontends/LyXView.h"
|
2000-07-04 11:30:07 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2003-09-09 22:13:45 +00:00
|
|
|
|
using lyx::graphics::PreviewLoader;
|
2003-06-30 23:56:22 +00:00
|
|
|
|
|
2000-07-05 14:57:48 +00:00
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2000-07-17 18:27:53 +00:00
|
|
|
|
using std::max;
|
2003-09-05 09:01:27 +00:00
|
|
|
|
using std::ostream;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
2001-04-04 20:34:04 +00:00
|
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetCollapsable::InsetCollapsable(BufferParams const & bp, bool collapsed)
|
2003-11-10 09:06:48 +00:00
|
|
|
|
: UpdatableInset(), inset(bp), collapsed_(collapsed), label("Label")
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#if 0
|
2003-11-10 09:06:48 +00:00
|
|
|
|
,autocollapse(false)
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#endif
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2001-04-02 14:02:58 +00:00
|
|
|
|
inset.setOwner(this);
|
2001-06-28 10:25:20 +00:00
|
|
|
|
inset.setAutoBreakRows(true);
|
2003-08-11 09:09:01 +00:00
|
|
|
|
inset.setDrawFrame(InsetText::ALWAYS);
|
|
|
|
|
inset.setFrameColor(LColor::collapsableframe);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
setInsetName("Collapsable");
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
|
2003-09-16 15:39:33 +00:00
|
|
|
|
: UpdatableInset(in), inset(in.inset), collapsed_(in.collapsed_),
|
2003-11-10 09:06:48 +00:00
|
|
|
|
labelfont_(in.labelfont_), label(in.label)
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#if 0
|
2003-11-10 09:06:48 +00:00
|
|
|
|
,autocollapse(in.autocollapse)
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#endif
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{
|
|
|
|
|
inset.setOwner(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool InsetCollapsable::insertInset(BufferView * bv, InsetOld * in)
|
2000-07-04 19:16:35 +00:00
|
|
|
|
{
|
2001-07-19 08:52:59 +00:00
|
|
|
|
if (!insetAllowed(in->lyxCode())) {
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetCollapsable::write(Buffer const & buf, ostream & os) const
|
2000-04-19 14:42:19 +00:00
|
|
|
|
{
|
2003-05-13 14:36:24 +00:00
|
|
|
|
os << "collapsed " << (collapsed_ ? "true" : "false") << "\n";
|
2001-06-28 10:25:20 +00:00
|
|
|
|
inset.writeParagraphData(buf, os);
|
2000-04-19 14:42:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void InsetCollapsable::read(Buffer const & buf, LyXLex & lex)
|
2000-04-19 14:42:19 +00:00
|
|
|
|
{
|
2001-08-06 19:13:25 +00:00
|
|
|
|
if (lex.isOK()) {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
string const token = lex.getString();
|
2001-04-02 14:02:58 +00:00
|
|
|
|
if (token == "collapsed") {
|
|
|
|
|
lex.next();
|
2001-08-06 19:13:25 +00:00
|
|
|
|
collapsed_ = lex.getBool();
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetCollapsable::Read: Missing collapsed!"
|
2001-04-04 20:34:04 +00:00
|
|
|
|
<< endl;
|
2001-07-25 22:05:53 +00:00
|
|
|
|
// Take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
void InsetCollapsable::dimension_collapsed(Dimension & dim) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-09-16 15:39:33 +00:00
|
|
|
|
font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
|
int InsetCollapsable::height_collapsed() const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-05-19 17:03:12 +00:00
|
|
|
|
Dimension dim;
|
2003-09-16 15:39:33 +00:00
|
|
|
|
font_metrics::buttonText(label, labelfont_, dim.wid, dim.asc, dim.des);
|
2003-05-27 13:55:03 +00:00
|
|
|
|
return dim.asc + dim.des;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-08-02 11:30:30 +00:00
|
|
|
|
//lyxerr << "InsetCollapsable::metrics: width: " << mi.base.textwidth << endl;
|
2003-05-19 17:03:12 +00:00
|
|
|
|
dimension_collapsed(dim);
|
2003-07-18 07:47:07 +00:00
|
|
|
|
if (!collapsed_) {
|
|
|
|
|
Dimension insetdim;
|
|
|
|
|
inset.metrics(mi, insetdim);
|
|
|
|
|
dim.des += insetdim.height() + TEXT_TO_BOTTOM_OFFSET;
|
|
|
|
|
dim.wid = max(dim.wid, insetdim.wid);
|
|
|
|
|
}
|
|
|
|
|
dim_ = dim;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
//lyxerr << "InsetCollapsable::metrics: dim.wid: " << dim.wid << endl;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetCollapsable::draw_collapsed(PainterInfo & pi, int x, int y) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-09-16 15:39:33 +00:00
|
|
|
|
pi.pain.buttonText(x, y, label, labelfont_);
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-05-19 17:03:12 +00:00
|
|
|
|
Dimension dim_collapsed;
|
|
|
|
|
dimension_collapsed(dim_collapsed);
|
|
|
|
|
|
2003-07-30 14:43:14 +00:00
|
|
|
|
int const aa = ascent();
|
|
|
|
|
button_dim.x1 = 0;
|
|
|
|
|
button_dim.x2 = dim_collapsed.width();
|
|
|
|
|
button_dim.y1 = -aa;
|
|
|
|
|
button_dim.y2 = -aa + dim_collapsed.height();
|
2001-04-04 20:34:04 +00:00
|
|
|
|
|
2003-11-10 11:26:33 +00:00
|
|
|
|
top_x = x;
|
|
|
|
|
top_baseline = y;
|
|
|
|
|
|
2001-07-31 09:53:40 +00:00
|
|
|
|
if (!isOpen()) {
|
2003-05-30 06:48:24 +00:00
|
|
|
|
draw_collapsed(pi, x, y);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
int old_x = x;
|
2001-04-27 14:03:25 +00:00
|
|
|
|
|
|
|
|
|
if (!owner())
|
2003-03-20 14:13:49 +00:00
|
|
|
|
x += scroll();
|
2001-07-31 09:53:40 +00:00
|
|
|
|
|
2003-03-20 14:13:49 +00:00
|
|
|
|
if (inlined) {
|
2003-05-30 06:48:24 +00:00
|
|
|
|
inset.draw(pi, x, y);
|
2003-03-20 14:13:49 +00:00
|
|
|
|
} else {
|
2003-11-10 09:06:48 +00:00
|
|
|
|
int const bl = y - aa + dim_collapsed.ascent();
|
2003-05-30 06:48:24 +00:00
|
|
|
|
draw_collapsed(pi, old_x, bl);
|
2003-07-30 15:41:39 +00:00
|
|
|
|
inset.draw(pi, x, bl + dim_collapsed.descent() + inset.ascent());
|
2003-03-20 14:13:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
2003-03-20 14:13:49 +00:00
|
|
|
|
{
|
|
|
|
|
// by default, we are not inlined-drawing
|
2003-05-30 06:48:24 +00:00
|
|
|
|
draw(pi, x, y, false);
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::EDITABLE InsetCollapsable::editable() const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-05-16 14:48:33 +00:00
|
|
|
|
return collapsed_ ? IS_EDITABLE : HIGHLY_EDITABLE;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
|
2003-05-16 14:48:33 +00:00
|
|
|
|
FuncRequest InsetCollapsable::adjustCommand(FuncRequest const & cmd)
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-05-16 14:48:33 +00:00
|
|
|
|
FuncRequest cmd1 = cmd;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
cmd1.y = ascent() + cmd.y - height_collapsed() - inset.ascent();
|
2003-05-16 14:48:33 +00:00
|
|
|
|
return cmd1;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
DispatchResult InsetCollapsable::lfunMouseRelease(FuncRequest const & cmd)
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2002-08-19 10:11:13 +00:00
|
|
|
|
BufferView * bv = cmd.view();
|
2003-05-16 14:48:33 +00:00
|
|
|
|
|
2003-11-10 09:06:48 +00:00
|
|
|
|
if (cmd.button() == mouse_button::button3) {
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 0" << endl;
|
|
|
|
|
if (hitButton(cmd))
|
|
|
|
|
showInsetDialog(bv);
|
2003-11-10 14:29:39 +00:00
|
|
|
|
return DispatchResult(true, true);
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2003-11-10 14:29:39 +00:00
|
|
|
|
if (collapsed_) {
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
|
|
|
|
collapsed_ = false;
|
|
|
|
|
edit(bv, true);
|
|
|
|
|
bv->buffer()->markDirty();
|
|
|
|
|
bv->update();
|
|
|
|
|
return DispatchResult(true, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hitButton(cmd)) {
|
|
|
|
|
if (!collapsed_) {
|
|
|
|
|
collapsed_ = true;
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
2003-11-10 13:23:14 +00:00
|
|
|
|
bv->update();
|
2003-11-10 14:29:39 +00:00
|
|
|
|
return DispatchResult(false, FINISHED_RIGHT);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2003-11-10 14:29:39 +00:00
|
|
|
|
collapsed_ = false;
|
|
|
|
|
bv->update();
|
|
|
|
|
bv->buffer()->markDirty();
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
|
|
|
|
} else if (!collapsed_ && cmd.y > button_dim.y2) {
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
|
|
|
|
|
return inset.dispatch(adjustCommand(cmd));
|
2000-04-19 14:42:19 +00:00
|
|
|
|
}
|
2003-11-10 14:29:39 +00:00
|
|
|
|
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 5" << endl;
|
|
|
|
|
return DispatchResult(true, true);
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
2000-04-19 14:42:19 +00:00
|
|
|
|
|
2000-04-24 20:58:23 +00:00
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int InsetCollapsable::latex(Buffer const & buf, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2000-07-04 11:30:07 +00:00
|
|
|
|
{
|
2003-05-23 08:59:47 +00:00
|
|
|
|
return inset.latex(buf, os, runparams);
|
2000-07-04 11:30:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-27 15:54:25 +00:00
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int InsetCollapsable::plaintext(Buffer const & buf, ostream & os,
|
|
|
|
|
OutputParams const & runparams) const
|
2001-12-27 15:54:25 +00:00
|
|
|
|
{
|
2003-11-05 12:06:20 +00:00
|
|
|
|
return inset.plaintext(buf, os, runparams);
|
2001-12-27 15:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetCollapsable::linuxdoc(Buffer const & buf, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2001-12-27 15:54:25 +00:00
|
|
|
|
{
|
2003-10-31 18:45:43 +00:00
|
|
|
|
return inset.linuxdoc(buf, os, runparams);
|
2001-12-27 15:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int InsetCollapsable::docbook(Buffer const & buf, ostream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2001-12-27 15:54:25 +00:00
|
|
|
|
{
|
2003-10-31 18:45:43 +00:00
|
|
|
|
return inset.docbook(buf, os, runparams);
|
2001-12-27 15:54:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-07-15 23:51:46 +00:00
|
|
|
|
|
2003-07-30 14:43:14 +00:00
|
|
|
|
bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
|
|
|
|
|
{
|
2003-09-02 20:42:28 +00:00
|
|
|
|
return button_dim.contains(cmd.x, cmd.y);
|
2003-07-30 14:43:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
|
void InsetCollapsable::edit(BufferView * bv, bool left)
|
2003-10-15 08:49:44 +00:00
|
|
|
|
{
|
2003-11-06 16:43:12 +00:00
|
|
|
|
lyxerr << "InsetCollapsable: edit left/right" << endl;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv->cursor().push(this);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
inset.edit(bv, left);
|
2003-11-05 09:36:07 +00:00
|
|
|
|
open(bv);
|
2003-10-15 08:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
|
|
|
|
|
|
void InsetCollapsable::edit(BufferView * bv, int x, int y)
|
|
|
|
|
{
|
2003-11-06 16:43:12 +00:00
|
|
|
|
lyxerr << "InsetCollapsable: edit xy" << endl;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
if (collapsed_) {
|
|
|
|
|
collapsed_ = false;
|
|
|
|
|
// set this only here as it should be recollapsed only if
|
|
|
|
|
// it was already collapsed!
|
2003-11-10 13:23:14 +00:00
|
|
|
|
bv->update();
|
2003-11-04 12:36:59 +00:00
|
|
|
|
bv->buffer()->markDirty();
|
|
|
|
|
inset.edit(bv, x, y);
|
|
|
|
|
} else {
|
|
|
|
|
if (y <= button_dim.y2)
|
|
|
|
|
inset.edit(bv, x, 0);
|
|
|
|
|
else
|
|
|
|
|
inset.edit(bv, x,
|
2003-11-10 09:06:48 +00:00
|
|
|
|
ascent() + y - height_collapsed() + inset.ascent());
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
bv->cursor().push(this);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-15 08:49:44 +00:00
|
|
|
|
|
2003-10-29 10:47:21 +00:00
|
|
|
|
DispatchResult
|
2003-11-06 16:43:12 +00:00
|
|
|
|
InsetCollapsable::priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &)
|
2000-07-04 11:30:07 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
lyxerr << "\nInsetCollapsable::priv_dispatch (begin): cmd: " << cmd
|
|
|
|
|
<< " button y: " << button_dim.y2 << endl;
|
2002-08-19 10:11:13 +00:00
|
|
|
|
switch (cmd.action) {
|
|
|
|
|
case LFUN_MOUSE_PRESS:
|
2003-07-30 14:43:14 +00:00
|
|
|
|
if (!collapsed_ && cmd.y > button_dim.y2)
|
2003-10-17 18:01:15 +00:00
|
|
|
|
inset.dispatch(adjustCommand(cmd));
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_MOUSE_MOTION:
|
2003-07-30 14:43:14 +00:00
|
|
|
|
if (!collapsed_ && cmd.y > button_dim.y2)
|
2003-10-17 18:01:15 +00:00
|
|
|
|
inset.dispatch(adjustCommand(cmd));
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
2003-11-10 09:06:48 +00:00
|
|
|
|
if (!collapsed_ && cmd.y > button_dim.y2)
|
|
|
|
|
inset.dispatch(adjustCommand(cmd));
|
|
|
|
|
else
|
|
|
|
|
return lfunMouseRelease(cmd);
|
2003-11-03 19:52:47 +00:00
|
|
|
|
return DispatchResult(true, true);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2003-11-10 09:06:48 +00:00
|
|
|
|
return inset.dispatch(cmd);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
lyxerr << "InsetCollapsable::priv_dispatch (end)" << endl;
|
2000-07-04 11:30:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-04-16 14:10:39 +00:00
|
|
|
|
int InsetCollapsable::insetInInsetY() const
|
2000-07-04 11:30:07 +00:00
|
|
|
|
{
|
2003-11-10 09:06:48 +00:00
|
|
|
|
return inset.y() - top_baseline + inset.insetInInsetY();
|
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
|
|
|
|
|
|
|
|
|
|
2003-05-03 18:05:53 +00:00
|
|
|
|
void InsetCollapsable::getCursorPos(BufferView * bv, int & x, int & y) const
|
2001-07-20 14:18:48 +00:00
|
|
|
|
{
|
2003-05-03 18:05:53 +00:00
|
|
|
|
inset.getCursorPos(bv, x , y);
|
2003-11-10 09:06:48 +00:00
|
|
|
|
y += - ascent() + height_collapsed() + inset.ascent();
|
2000-07-04 11:30:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void InsetCollapsable::setFont(BufferView * bv, LyXFont const & font,
|
2002-03-21 17:09:55 +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-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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-18 20:18:39 +00:00
|
|
|
|
void InsetCollapsable::getLabelList(Buffer const & buffer,
|
|
|
|
|
std::vector<string> & list) const
|
2001-04-04 23:00:42 +00:00
|
|
|
|
{
|
2003-09-18 20:18:39 +00:00
|
|
|
|
inset.getLabelList(buffer, list);
|
2001-04-04 23:00:42 +00:00
|
|
|
|
}
|
2001-04-27 14:03:25 +00:00
|
|
|
|
|
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
|
|
|
|
|
2003-05-05 15:39:48 +00:00
|
|
|
|
ParagraphList * InsetCollapsable::getParagraphs(int i) const
|
2001-09-01 21:26:34 +00:00
|
|
|
|
{
|
2003-05-05 15:39:48 +00:00
|
|
|
|
return inset.getParagraphs(i);
|
2001-09-01 21:26:34 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-01 09:56:18 +00:00
|
|
|
|
int InsetCollapsable::numParagraphs() const
|
|
|
|
|
{
|
|
|
|
|
return inset.numParagraphs();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-10-14 13:01:49 +00:00
|
|
|
|
LyXText * InsetCollapsable::getText(int i) const
|
|
|
|
|
{
|
|
|
|
|
return inset.getText(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-07-24 22:08:49 +00:00
|
|
|
|
void InsetCollapsable::open(BufferView * bv)
|
|
|
|
|
{
|
2003-08-05 08:07:07 +00:00
|
|
|
|
if (!collapsed_)
|
|
|
|
|
return;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-07-24 22:08:49 +00:00
|
|
|
|
collapsed_ = false;
|
2003-11-10 13:23:14 +00:00
|
|
|
|
bv->update();
|
2001-07-12 14:35:38 +00:00
|
|
|
|
}
|
2001-07-23 12:47:25 +00:00
|
|
|
|
|
|
|
|
|
|
2001-08-07 15:07:36 +00:00
|
|
|
|
void InsetCollapsable::close(BufferView * bv) const
|
2001-07-24 22:08:49 +00:00
|
|
|
|
{
|
2001-07-31 09:53:40 +00:00
|
|
|
|
if (collapsed_)
|
|
|
|
|
return;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-07-24 22:08:49 +00:00
|
|
|
|
collapsed_ = true;
|
2003-11-10 13:23:14 +00:00
|
|
|
|
bv->update();
|
2001-07-24 22:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-08-07 15:07:36 +00:00
|
|
|
|
void InsetCollapsable::setLabel(string const & l) const
|
2001-07-24 22:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
label = l;
|
|
|
|
|
}
|
2001-08-07 15:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void InsetCollapsable::setCollapsed(bool c) const
|
|
|
|
|
{
|
|
|
|
|
collapsed_ = c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void InsetCollapsable::markErased()
|
|
|
|
|
{
|
|
|
|
|
inset.markErased();
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-03 15:59:08 +00:00
|
|
|
|
|
2003-07-18 16:13:33 +00:00
|
|
|
|
void InsetCollapsable::addPreview(PreviewLoader & loader) const
|
2002-08-02 16:39:43 +00:00
|
|
|
|
{
|
|
|
|
|
inset.addPreview(loader);
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InsetCollapsable::insetAllowed(InsetOld::Code code) const
|
|
|
|
|
{
|
|
|
|
|
return inset.insetAllowed(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCollapsable::fitInsetCursor(BufferView * bv) const
|
|
|
|
|
{
|
|
|
|
|
inset.fitInsetCursor(bv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCollapsable::setLabelFont(LyXFont & f)
|
|
|
|
|
{
|
|
|
|
|
labelfont_ = f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
void InsetCollapsable::setAutoCollapse(bool f)
|
|
|
|
|
{
|
|
|
|
|
autocollapse = f;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void InsetCollapsable::scroll(BufferView *bv, float sx) const
|
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetCollapsable::scroll(BufferView *bv, int offset) const
|
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InsetCollapsable::isOpen() const
|
|
|
|
|
{
|
|
|
|
|
return !collapsed_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Box const & InsetCollapsable::buttonDim() const
|
|
|
|
|
{
|
|
|
|
|
return button_dim;
|
|
|
|
|
}
|
|
|
|
|
|