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
|
|
|
|
|
2004-03-31 08:43:47 +00:00
|
|
|
|
void getOutOfInset(LCursor & cur, InsetBase const & in)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned int i = 0; i != cur.size(); ++i) {
|
|
|
|
|
if (&cur[i].inset() == &in) {
|
|
|
|
|
cur.resize(i);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
InsetCollapsable::InsetCollapsable(BufferParams const & bp,
|
|
|
|
|
CollapseStatus status)
|
2004-03-25 09:16:36 +00:00
|
|
|
|
: InsetText(bp), label("Label"), status_(status), openinlined_(false)
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2004-03-25 09:16:36 +00:00
|
|
|
|
setAutoBreakRows(true);
|
|
|
|
|
setDrawFrame(InsetText::ALWAYS);
|
|
|
|
|
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-08-28 07:41:31 +00:00
|
|
|
|
void InsetCollapsable::write(Buffer const & buf, ostream & os) const
|
2000-04-19 14:42:19 +00:00
|
|
|
|
{
|
2004-02-03 16:44:57 +00:00
|
|
|
|
os << "status ";
|
2003-12-12 14:02:14 +00:00
|
|
|
|
switch (status_) {
|
|
|
|
|
case Open:
|
2004-02-03 16:44:57 +00:00
|
|
|
|
os << "open";
|
2003-12-12 14:02:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case Collapsed:
|
2004-02-03 16:44:57 +00:00
|
|
|
|
os << "collapsed";
|
2003-12-12 14:02:14 +00:00
|
|
|
|
break;
|
|
|
|
|
case Inlined:
|
2004-02-03 16:44:57 +00:00
|
|
|
|
os << "inlined";
|
2003-12-12 14:02:14 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2004-02-03 16:44:57 +00:00
|
|
|
|
os << "\n";
|
2004-03-25 09:16:36 +00:00
|
|
|
|
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 {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
lyxerr << "InsetCollapsable::read: Missing 'status'-tag!"
|
2003-12-12 14:02:14 +00:00
|
|
|
|
<< 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
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::read(buf, lex);
|
2003-12-12 14:02:14 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
if (!token_found)
|
|
|
|
|
status_ = isOpen() ? Open : Collapsed;
|
2003-12-12 14:02:14 +00:00
|
|
|
|
|
|
|
|
|
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-06-02 10:03:27 +00:00
|
|
|
|
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2004-03-27 13:29:17 +00:00
|
|
|
|
mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Inlined) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::metrics(mi, dim);
|
2003-12-02 07:15:42 +00:00
|
|
|
|
} else {
|
|
|
|
|
dimension_collapsed(dim);
|
|
|
|
|
if (status_ == Open) {
|
2004-03-27 13:29:17 +00:00
|
|
|
|
InsetText::metrics(mi, textdim_);
|
|
|
|
|
openinlined_ = (textdim_.wid + dim.wid <= mi.base.textwidth);
|
2004-03-10 08:50:46 +00:00
|
|
|
|
if (openinlined_) {
|
2004-03-27 13:29:17 +00:00
|
|
|
|
dim.wid += textdim_.wid;
|
|
|
|
|
dim.des = max(dim.des, textdim_.des);
|
|
|
|
|
dim.asc = max(dim.asc, textdim_.asc);
|
2004-03-10 08:50:46 +00:00
|
|
|
|
} else {
|
2004-03-27 13:29:17 +00:00
|
|
|
|
dim.des += textdim_.height() + TEXT_TO_BOTTOM_OFFSET;
|
|
|
|
|
dim.wid = max(dim.wid, textdim_.wid);
|
2004-03-10 08:50:46 +00:00
|
|
|
|
}
|
2003-12-02 07:15:42 +00:00
|
|
|
|
}
|
2003-07-18 07:47:07 +00:00
|
|
|
|
}
|
2004-03-27 13:29:17 +00:00
|
|
|
|
dim.asc += TEXT_TO_INSET_OFFSET;
|
|
|
|
|
dim.des += TEXT_TO_INSET_OFFSET;
|
|
|
|
|
dim.wid += 2 * TEXT_TO_INSET_OFFSET;
|
|
|
|
|
mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET;
|
2003-07-18 07:47:07 +00:00
|
|
|
|
dim_ = dim;
|
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
|
|
|
|
{
|
2004-03-27 13:29:17 +00:00
|
|
|
|
x += TEXT_TO_INSET_OFFSET;
|
|
|
|
|
y += TEXT_TO_INSET_OFFSET;
|
2003-11-10 11:26:33 +00:00
|
|
|
|
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Inlined) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::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();
|
2004-02-03 16:44:57 +00:00
|
|
|
|
button_dim.x1 = x + 0;
|
|
|
|
|
button_dim.x2 = x + dimc.width();
|
2004-02-06 13:18:49 +00:00
|
|
|
|
button_dim.y1 = y - aa + pi.base.bv->top_y();
|
|
|
|
|
button_dim.y2 = y - aa + pi.base.bv->top_y() + dimc.height();
|
2003-12-02 07:15:42 +00:00
|
|
|
|
|
2004-03-27 13:29:17 +00:00
|
|
|
|
draw_collapsed(pi, x, y - aa + dimc.asc);
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Open) {
|
2004-03-10 08:50:46 +00:00
|
|
|
|
if (openinlined_)
|
2004-03-27 13:29:17 +00:00
|
|
|
|
InsetText::draw(pi, x + dimc.width(),
|
|
|
|
|
y - aa + textdim_.asc);
|
2004-03-10 08:50:46 +00:00
|
|
|
|
else
|
2004-03-27 13:29:17 +00:00
|
|
|
|
InsetText::draw(pi, x, dimc.height()
|
|
|
|
|
+ y - aa + textdim_.asc);
|
2003-12-02 07:15:42 +00:00
|
|
|
|
}
|
2003-03-20 14:13:49 +00:00
|
|
|
|
}
|
2004-03-27 13:29:17 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
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
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
bool InsetCollapsable::hitButton(FuncRequest & cmd) const
|
2003-07-30 14:43:14 +00:00
|
|
|
|
{
|
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
|
|
|
|
|
{
|
2004-03-08 21:14:45 +00:00
|
|
|
|
string label;
|
2003-12-01 14:51:52 +00:00
|
|
|
|
pos_type const max_length = 15;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
pos_type const p_siz = paragraphs().begin()->size();
|
2003-12-01 14:51:52 +00:00
|
|
|
|
pos_type const n = min(max_length, p_siz);
|
|
|
|
|
pos_type i = 0;
|
|
|
|
|
pos_type j = 0;
|
|
|
|
|
for( ; i < n && j < p_siz; ++j) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (paragraphs().begin()->isInset(j))
|
2003-12-01 14:51:52 +00:00
|
|
|
|
continue;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
label += paragraphs().begin()->getChar(j);
|
2003-12-01 14:51:52 +00:00
|
|
|
|
++i;
|
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
if (paragraphs().size() > 1 || (i > 0 && j < p_siz)) {
|
2004-03-08 21:14:45 +00:00
|
|
|
|
label += "...";
|
2003-12-01 14:51:52 +00:00
|
|
|
|
}
|
2004-03-08 21:14:45 +00:00
|
|
|
|
return label.empty() ? l : label;
|
2003-12-01 14:51:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
|
void InsetCollapsable::edit(LCursor & cur, bool left)
|
2003-10-15 08:49:44 +00:00
|
|
|
|
{
|
2004-01-30 11:41:12 +00:00
|
|
|
|
//lyxerr << "InsetCollapsable: edit left/right" << endl;
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cur.push(*this);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::edit(cur, left);
|
2003-12-12 14:02:14 +00:00
|
|
|
|
open();
|
2003-10-15 08:49:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
|
|
2004-02-13 13:51:12 +00:00
|
|
|
|
InsetBase * InsetCollapsable::editXY(LCursor & cur, int x, int y)
|
2003-11-04 12:36:59 +00:00
|
|
|
|
{
|
2004-03-18 12:53:43 +00:00
|
|
|
|
cur.push(*this);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
//lyxerr << "InsetCollapsable: edit xy" << endl;
|
2003-12-02 07:15:42 +00:00
|
|
|
|
if (status_ == Collapsed) {
|
|
|
|
|
setStatus(Open);
|
2004-03-25 09:16:36 +00:00
|
|
|
|
// We are not calling editXY() because the row cache of the
|
|
|
|
|
// inset might be invalid. 'Entering from the left' should be
|
|
|
|
|
// ok, though.
|
|
|
|
|
InsetText::edit(cur, true);
|
2004-02-13 13:51:12 +00:00
|
|
|
|
return this;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
return InsetText::editXY(cur, x, y);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-10-15 08:49:44 +00:00
|
|
|
|
|
2004-03-18 12:53:43 +00:00
|
|
|
|
void InsetCollapsable::priv_dispatch(LCursor & cur, FuncRequest & cmd)
|
2000-07-04 11:30:07 +00:00
|
|
|
|
{
|
2004-02-06 09:34:04 +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) {
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_MOUSE_PRESS:
|
|
|
|
|
if (status_ == Inlined)
|
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
|
|
|
|
else if (status_ == Open && !hitButton(cmd))
|
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
|
|
|
|
break;
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_MOUSE_MOTION:
|
|
|
|
|
if (status_ == Inlined)
|
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
|
|
|
|
else if (status_ == Open && !hitButton(cmd))
|
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
|
|
|
|
break;
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case LFUN_MOUSE_RELEASE:
|
|
|
|
|
if (cmd.button() == mouse_button::button3) {
|
|
|
|
|
showInsetDialog(&cur.bv());
|
|
|
|
|
break;
|
|
|
|
|
}
|
2004-03-25 09:16:36 +00:00
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
switch (status_) {
|
2004-03-25 09:16:36 +00:00
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case Collapsed:
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 1" << endl;
|
|
|
|
|
setStatus(Open);
|
|
|
|
|
edit(cur, true);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2002-08-19 10:11:13 +00:00
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case Open: {
|
|
|
|
|
FuncRequest cmd1 = cmd;
|
|
|
|
|
if (hitButton(cmd1)) {
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 2" << endl;
|
|
|
|
|
setStatus(Collapsed);
|
|
|
|
|
cur.undispatched();
|
|
|
|
|
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
|
|
|
|
|
} else {
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 3" << endl;
|
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
2003-12-12 15:21:31 +00:00
|
|
|
|
}
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2004-03-30 12:36:33 +00:00
|
|
|
|
}
|
2003-12-01 13:35:49 +00:00
|
|
|
|
|
2004-03-30 12:36:33 +00:00
|
|
|
|
case Inlined:
|
|
|
|
|
lyxerr << "InsetCollapsable::lfunMouseRelease 4" << endl;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
2004-02-16 11:58:51 +00:00
|
|
|
|
break;
|
2004-03-30 12:36:33 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case LFUN_INSET_TOGGLE:
|
|
|
|
|
if (cmd.argument == "open")
|
|
|
|
|
setStatus(Open);
|
2004-03-31 08:43:47 +00:00
|
|
|
|
else if (cmd.argument == "close") {
|
2004-03-30 12:36:33 +00:00
|
|
|
|
setStatus(Collapsed);
|
2004-03-31 08:43:47 +00:00
|
|
|
|
getOutOfInset(cur, *this);
|
|
|
|
|
} else if (cmd.argument == "toggle"
|
|
|
|
|
|| cmd.argument.empty()) {
|
|
|
|
|
if (isOpen()) {
|
2004-03-30 12:36:33 +00:00
|
|
|
|
setStatus(Collapsed);
|
2004-03-31 08:43:47 +00:00
|
|
|
|
getOutOfInset(cur, *this);
|
|
|
|
|
} else
|
2004-03-30 12:36:33 +00:00
|
|
|
|
setStatus(Open);
|
|
|
|
|
}
|
|
|
|
|
cur.dispatched();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
InsetText::priv_dispatch(cur, cmd);
|
|
|
|
|
break;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
}
|
2000-07-04 11:30:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-04-27 14:03:25 +00:00
|
|
|
|
int InsetCollapsable::scroll(bool recursive) const
|
|
|
|
|
{
|
|
|
|
|
int sx = UpdatableInset::scroll(false);
|
|
|
|
|
|
|
|
|
|
if (recursive)
|
2004-03-25 09:16:36 +00:00
|
|
|
|
sx += InsetText::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-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-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
|
|
|
|
|
2004-01-15 17:34:44 +00:00
|
|
|
|
void InsetCollapsable::scroll(BufferView & bv, float sx) const
|
2003-11-10 09:06:48 +00:00
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-01-15 17:34:44 +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;
|
|
|
|
|
}
|