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-12-01 14:51:52 +00:00
|
|
|
|
using std::min;
|
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
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
InsetCollapsable::InsetCollapsable(BufferParams const & bp, CollapseStatus status)
|
|
|
|
|
: UpdatableInset(), inset(bp), status_(status),
|
2003-12-02 07:15:42 +00:00
|
|
|
|
label("Label")
|
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");
|
2003-12-12 14:02:14 +00:00
|
|
|
|
|
|
|
|
|
setButtonLabel();
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetCollapsable::InsetCollapsable(InsetCollapsable const & in)
|
2003-12-02 07:15:42 +00:00
|
|
|
|
: UpdatableInset(in), inset(in.inset), status_(in.status_),
|
2003-11-10 09:06:48 +00:00
|
|
|
|
labelfont_(in.labelfont_), label(in.label)
|
2001-07-24 15:07:09 +00:00
|
|
|
|
{
|
|
|
|
|
inset.setOwner(this);
|
2003-12-12 14:02:14 +00:00
|
|
|
|
setButtonLabel();
|
2001-07-24 15:07:09 +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-12-12 14:02:14 +00:00
|
|
|
|
string st;
|
|
|
|
|
|
|
|
|
|
switch (status_) {
|
|
|
|
|
case Open:
|
|
|
|
|
st = "open";
|
|
|
|
|
break;
|
|
|
|
|
case Collapsed:
|
|
|
|
|
st = "collapsed";
|
|
|
|
|
break;
|
|
|
|
|
case Inlined:
|
|
|
|
|
st = "inlined";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
os << "status " << st << "\n";
|
2003-12-02 12:39:14 +00:00
|
|
|
|
inset.text_.write(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
|
|
|
|
{
|
2003-12-12 14:02:14 +00:00
|
|
|
|
bool token_found = false;
|
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();
|
2003-12-12 14:02:14 +00:00
|
|
|
|
if (token == "status") {
|
2001-04-02 14:02:58 +00:00
|
|
|
|
lex.next();
|
2003-12-12 14:02:14 +00:00
|
|
|
|
string const tmp_token = lex.getString();
|
|
|
|
|
|
|
|
|
|
if (tmp_token == "inlined") {
|
|
|
|
|
status_ = Inlined;
|
|
|
|
|
token_found = true;
|
|
|
|
|
} else if (tmp_token == "collapsed") {
|
|
|
|
|
status_ = Collapsed;
|
|
|
|
|
token_found = true;
|
|
|
|
|
} else if (tmp_token == "open") {
|
|
|
|
|
status_ = Open;
|
|
|
|
|
token_found = true;
|
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetCollapsable::read: Missing status!"
|
|
|
|
|
<< endl;
|
|
|
|
|
// Take countermeasures
|
|
|
|
|
lex.pushToken(token);
|
|
|
|
|
}
|
2001-04-02 14:02:58 +00:00
|
|
|
|
} else {
|
2003-12-12 14:02:14 +00:00
|
|
|
|
lyxerr << "InsetCollapsable::Read: Missing 'status'-tag!"
|
|
|
|
|
<< endl;
|
|
|
|
|
// take countermeasures
|
2001-07-25 22:05:53 +00:00
|
|
|
|
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);
|
2003-12-12 14:02:14 +00:00
|
|
|
|
|
|
|
|
|
if (!token_found) {
|
|
|
|
|
if (isOpen())
|
|
|
|
|
status_ = Open;
|
|
|
|
|
else
|
|
|
|
|
status_ = Collapsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setButtonLabel();
|
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-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Inlined) {
|
|
|
|
|
inset.metrics(mi, dim);
|
|
|
|
|
} else {
|
|
|
|
|
dimension_collapsed(dim);
|
|
|
|
|
if (status_ == Open) {
|
|
|
|
|
Dimension insetdim;
|
|
|
|
|
inset.metrics(mi, insetdim);
|
|
|
|
|
dim.des += insetdim.height() + TEXT_TO_BOTTOM_OFFSET;
|
|
|
|
|
dim.wid = max(dim.wid, insetdim.wid);
|
|
|
|
|
}
|
2003-07-18 07:47:07 +00:00
|
|
|
|
}
|
|
|
|
|
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-12-02 07:15:42 +00:00
|
|
|
|
void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-11-10 15:38:20 +00:00
|
|
|
|
xo_ = x;
|
|
|
|
|
yo_ = y;
|
2003-11-10 11:26:33 +00:00
|
|
|
|
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Inlined) {
|
2003-05-30 06:48:24 +00:00
|
|
|
|
inset.draw(pi, x, y);
|
2003-03-20 14:13:49 +00:00
|
|
|
|
} else {
|
2003-12-02 07:15:42 +00:00
|
|
|
|
Dimension dimc;
|
|
|
|
|
dimension_collapsed(dimc);
|
|
|
|
|
|
|
|
|
|
int const aa = ascent();
|
|
|
|
|
button_dim.x1 = 0;
|
|
|
|
|
button_dim.x2 = dimc.width();
|
|
|
|
|
button_dim.y1 = -aa;
|
|
|
|
|
button_dim.y2 = -aa + dimc.height();
|
|
|
|
|
|
|
|
|
|
draw_collapsed(pi, x, y);
|
|
|
|
|
if (status_ == Open) {
|
|
|
|
|
if (!owner())
|
|
|
|
|
x += scroll();
|
|
|
|
|
inset.draw(pi, x, y - aa + dimc.height() + inset.ascent());
|
|
|
|
|
}
|
2003-03-20 14:13:49 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-02 07:15:42 +00:00
|
|
|
|
InsetOld::EDITABLE InsetCollapsable::editable() const
|
2003-03-20 14:13:49 +00:00
|
|
|
|
{
|
2003-12-02 07:15:42 +00:00
|
|
|
|
return status_ != Collapsed ? HIGHLY_EDITABLE : IS_EDITABLE;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-02 07:15:42 +00:00
|
|
|
|
bool InsetCollapsable::descendable() const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-12-02 07:15:42 +00:00
|
|
|
|
return status_ != Collapsed;
|
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-17 20:28:11 +00:00
|
|
|
|
cmd1.y += ascent() - height_collapsed();
|
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;
|
2003-12-12 14:02:14 +00:00
|
|
|
|
showInsetDialog(bv);
|
2003-11-10 14:29:39 +00:00
|
|
|
|
return DispatchResult(true, true);
|
|
|
|
|
}
|
2003-11-10 09:06:48 +00:00
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
switch (status_) {
|
|
|
|
|
case Collapsed:
|
2003-11-10 14:29:39 +00:00
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
2003-12-02 07:15:42 +00:00
|
|
|
|
setStatus(Open);
|
2003-11-10 14:29:39 +00:00
|
|
|
|
edit(bv, true);
|
|
|
|
|
return DispatchResult(true, true);
|
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
case Open:
|
|
|
|
|
if (hitButton(cmd)) {
|
2003-11-10 14:29:39 +00:00
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
2003-12-12 14:02:14 +00:00
|
|
|
|
setStatus(Collapsed);
|
2003-11-10 14:29:39 +00:00
|
|
|
|
return DispatchResult(false, FINISHED_RIGHT);
|
2003-12-12 14:02:14 +00:00
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
|
|
|
|
return inset.dispatch(adjustCommand(cmd));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case Inlined:
|
|
|
|
|
return inset.dispatch(cmd);
|
2000-04-19 14:42:19 +00:00
|
|
|
|
}
|
2003-11-10 14:29:39 +00:00
|
|
|
|
|
|
|
|
|
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-12-01 14:51:52 +00:00
|
|
|
|
string const InsetCollapsable::getNewLabel(string const & l) const
|
|
|
|
|
{
|
|
|
|
|
string la;
|
|
|
|
|
pos_type const max_length = 15;
|
|
|
|
|
pos_type const p_siz = inset.paragraphs().begin()->size();
|
|
|
|
|
pos_type const n = min(max_length, p_siz);
|
|
|
|
|
pos_type i = 0;
|
|
|
|
|
pos_type j = 0;
|
|
|
|
|
for( ; i < n && j < p_siz; ++j) {
|
|
|
|
|
if (inset.paragraphs().begin()->isInset(j))
|
|
|
|
|
continue;
|
|
|
|
|
la += inset.paragraphs().begin()->getChar(j);
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
if (inset.paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
|
|
|
|
|
la += "...";
|
|
|
|
|
}
|
2003-12-12 14:02:14 +00:00
|
|
|
|
return la.empty() ? l : la;
|
2003-12-01 14:51:52 +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-04 12:36:59 +00:00
|
|
|
|
inset.edit(bv, left);
|
2003-12-12 14:02:14 +00:00
|
|
|
|
open();
|
2003-11-11 09:06:41 +00:00
|
|
|
|
bv->cursor().push(this);
|
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-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Collapsed) {
|
|
|
|
|
setStatus(Open);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
} else {
|
|
|
|
|
if (y <= button_dim.y2)
|
2003-12-01 13:35:49 +00:00
|
|
|
|
y = 0;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
else
|
2003-12-01 13:35:49 +00:00
|
|
|
|
y += inset.ascent() - height_collapsed();
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
2003-12-01 13:35:49 +00:00
|
|
|
|
inset.edit(bv, x, y);
|
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-12-02 07:15:42 +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-12-12 14:02:14 +00:00
|
|
|
|
if (status_ == Inlined)
|
|
|
|
|
inset.dispatch(cmd);
|
|
|
|
|
else if (status_ == Open && 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-12-12 14:02:14 +00:00
|
|
|
|
if (status_ == Inlined)
|
|
|
|
|
inset.dispatch(cmd);
|
|
|
|
|
else if (status_ == Open && 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-12-12 14:02:14 +00:00
|
|
|
|
return lfunMouseRelease(cmd);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
case LFUN_INSET_TOGGLE:
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (inset.text_.toggleInset())
|
|
|
|
|
return DispatchResult(true, true);
|
2003-12-12 15:21:31 +00:00
|
|
|
|
if (status_ == Open) {
|
2003-12-12 14:02:14 +00:00
|
|
|
|
setStatus(Inlined);
|
|
|
|
|
return DispatchResult(true, true);
|
2003-12-12 15:21:31 +00:00
|
|
|
|
} else {
|
|
|
|
|
setStatus(Collapsed);
|
|
|
|
|
return DispatchResult(false, FINISHED_RIGHT);
|
|
|
|
|
}
|
2003-12-01 13:35:49 +00:00
|
|
|
|
|
2002-08-19 10:11:13 +00:00
|
|
|
|
default:
|
2003-11-17 20:28:11 +00:00
|
|
|
|
return inset.dispatch(adjustCommand(cmd));
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2003-12-02 07:15:42 +00:00
|
|
|
|
//lyxerr << "InsetCollapsable::priv_dispatch (end)" << endl;
|
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
|
|
|
|
|
|
|
|
|
|
2004-01-08 18:30:14 +00:00
|
|
|
|
void InsetCollapsable::getCursorPos(int cell, int & x, int & y) const
|
2001-07-20 14:18:48 +00:00
|
|
|
|
{
|
2004-01-08 18:30:14 +00:00
|
|
|
|
inset.getCursorPos(cell, x, y);
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (status_ != Inlined)
|
|
|
|
|
y += - ascent() + height_collapsed() + inset.ascent();
|
2000-07-04 11:30:07 +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)
|
2003-11-25 11:17:27 +00:00
|
|
|
|
sx += inset.scroll(false);
|
2001-04-27 14:03:25 +00:00
|
|
|
|
|
|
|
|
|
return sx;
|
|
|
|
|
}
|
2001-07-06 15:57:54 +00:00
|
|
|
|
|
2001-07-09 09:16:00 +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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-11-21 17:26:11 +00:00
|
|
|
|
void InsetCollapsable::open()
|
2001-07-24 22:08:49 +00:00
|
|
|
|
{
|
2003-12-12 14:02:14 +00:00
|
|
|
|
if (status_ == Collapsed) // ...but not inlined
|
|
|
|
|
setStatus(Open);
|
2001-07-12 14:35:38 +00:00
|
|
|
|
}
|
2001-07-23 12:47:25 +00:00
|
|
|
|
|
|
|
|
|
|
2003-12-02 07:15:42 +00:00
|
|
|
|
void InsetCollapsable::close()
|
2001-07-24 22:08:49 +00:00
|
|
|
|
{
|
2003-12-02 07:15:42 +00:00
|
|
|
|
setStatus(Collapsed);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
void InsetCollapsable::setLabel(string const & l)
|
2001-07-24 22:08:49 +00:00
|
|
|
|
{
|
|
|
|
|
label = l;
|
|
|
|
|
}
|
2001-08-07 15:07:36 +00:00
|
|
|
|
|
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
void InsetCollapsable::setStatus(CollapseStatus st)
|
2003-09-16 15:39:33 +00:00
|
|
|
|
{
|
2003-12-12 14:02:14 +00:00
|
|
|
|
status_ = st;
|
|
|
|
|
setButtonLabel();
|
2003-09-16 15:39:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-12 14:02:14 +00:00
|
|
|
|
void InsetCollapsable::setLabelFont(LyXFont & font)
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{
|
2003-12-12 14:02:14 +00:00
|
|
|
|
labelfont_ = font;
|
2003-11-10 09:06:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
|
|
|
|
|
void InsetCollapsable::scroll(BufferView * bv, float sx) const
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
void InsetCollapsable::scroll(BufferView * bv, int offset) const
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Box const & InsetCollapsable::buttonDim() const
|
|
|
|
|
{
|
|
|
|
|
return button_dim;
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-01 13:35:49 +00:00
|
|
|
|
|
|
|
|
|
void InsetCollapsable::setBackgroundColor(LColor_color color)
|
|
|
|
|
{
|
|
|
|
|
InsetOld::setBackgroundColor(color);
|
|
|
|
|
inset.setBackgroundColor(color);
|
|
|
|
|
}
|