2000-03-08 13:52:57 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetcollapsable.h
|
|
|
|
|
* 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
|
2000-03-08 13:52:57 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-03-08 13:52:57 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef INSETCOLLAPSABLE_H
|
|
|
|
|
#define INSETCOLLAPSABLE_H
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "inset.h"
|
2001-03-30 14:28:17 +00:00
|
|
|
|
#include "insettext.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
|
2003-07-30 14:43:14 +00:00
|
|
|
|
#include "box.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
#include "lyxfont.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
|
|
class Painter;
|
2000-07-04 11:30:07 +00:00
|
|
|
|
class LyXText;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
class Paragraph;
|
|
|
|
|
class LyXCursor;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
2001-07-23 09:11:14 +00:00
|
|
|
|
/** A collapsable text inset
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
*/
|
2000-07-04 11:30:07 +00:00
|
|
|
|
class InsetCollapsable : public UpdatableInset {
|
2000-03-08 13:52:57 +00:00
|
|
|
|
public:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
static int const TEXT_TO_TOP_OFFSET = 2;
|
|
|
|
|
///
|
|
|
|
|
static int const TEXT_TO_BOTTOM_OFFSET = 2;
|
2001-07-23 09:11:14 +00:00
|
|
|
|
/// inset is initially collapsed if bool = true
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetCollapsable(BufferParams const &, bool collapsed = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetCollapsable(InsetCollapsable const & in);
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const &, LyXLex &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2003-03-20 14:13:49 +00:00
|
|
|
|
/// draw, either inlined (no button) or collapsed/open
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y, bool inlined) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-30 14:43:14 +00:00
|
|
|
|
bool hitButton(FuncRequest const &) const;
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
EDITABLE editable() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool insertInset(BufferView *, InsetOld * inset);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
virtual bool insetAllowed(InsetOld::Code code) const;
|
2001-07-09 14:19:41 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
bool isTextInset() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void insetUnlock(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool lockInsetInInset(BufferView *, UpdatableInset *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool unlockInsetInInset(BufferView *, UpdatableInset *,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool lr = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-04-16 14:10:39 +00:00
|
|
|
|
int insetInInsetY() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-13 01:35:47 +00:00
|
|
|
|
dispatch_result localDispatch(FuncRequest const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int latex(Buffer const &, std::ostream &,
|
2003-05-23 08:59:47 +00:00
|
|
|
|
LatexRunParams const &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int ascii(Buffer const &, std::ostream &, int) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &, bool mixcont) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// FIXME, document
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void getCursorPos(BufferView *, int & x, int & y) const;
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// Get the absolute document x,y of the cursor
|
|
|
|
|
virtual void getCursor(BufferView &, int &, int &) const;
|
2001-07-20 14:18:48 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void fitInsetCursor(BufferView * bv) const;
|
|
|
|
|
///
|
2001-07-12 12:26:06 +00:00
|
|
|
|
UpdatableInset * getLockingInset() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void setFont(BufferView *, LyXFont const &, bool toggleall = false,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool selectall = false);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void setLabel(std::string const & l) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void setLabelFont(LyXFont & f);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#if 0
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void setAutoCollapse(bool f);
|
2001-11-29 16:29:30 +00:00
|
|
|
|
#endif
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
LyXText * getLyXText(BufferView const *, bool const recursive) const;
|
|
|
|
|
///
|
|
|
|
|
void deleteLyXText(BufferView *, bool recursive=true) const;
|
2003-09-18 20:18:39 +00:00
|
|
|
|
/// Appends \c list with all labels found within this inset.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void getLabelList(Buffer const &, std::vector<std::string> & list) const;
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
|
|
|
|
int scroll(bool recursive=true) const;
|
2001-05-08 10:50:09 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void scroll(BufferView *bv, float sx) const;
|
2001-05-08 10:50:09 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void scroll(BufferView *bv, int offset) const;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * getInsetFromID(int id) const;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2003-05-05 15:39:48 +00:00
|
|
|
|
ParagraphList * getParagraphs(int) const;
|
2001-09-01 21:26:34 +00:00
|
|
|
|
///
|
2003-10-14 13:01:49 +00:00
|
|
|
|
LyXText * getText(int) const;
|
|
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
|
LyXCursor const & cursor(BufferView *) const;
|
2001-07-12 14:35:38 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
bool isOpen() const;
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
|
|
|
|
void open(BufferView *);
|
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
|
void close(BufferView *) const;
|
2001-07-17 15:39:12 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
bool allowSpellcheck() const;
|
2002-08-13 14:40:38 +00:00
|
|
|
|
///
|
|
|
|
|
WordLangTuple const
|
|
|
|
|
selectNextWordToSpellcheck(BufferView *, float &) const;
|
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void selectSelectedWord(BufferView *);
|
2003-05-26 09:13:55 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
void markErased();
|
2003-05-26 09:13:55 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool nextChange(BufferView * bv, lyx::pos_type & length);
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool searchForward(BufferView * bv, std::string const & str,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool = true, bool = false);
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool searchBackward(BufferView * bv, std::string const & str,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool = true, bool = false);
|
2001-04-27 14:03:25 +00:00
|
|
|
|
|
2002-08-02 16:39:43 +00:00
|
|
|
|
///
|
2003-07-04 08:23:23 +00:00
|
|
|
|
void addPreview(lyx::graphics::PreviewLoader &) const;
|
2002-08-02 16:39:43 +00:00
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
protected:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-19 17:03:12 +00:00
|
|
|
|
void dimension_collapsed(Dimension &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-19 17:03:12 +00:00
|
|
|
|
int height_collapsed() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw_collapsed(PainterInfo & pi, int x, int y) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
int getMaxTextWidth(Painter & pain, UpdatableInset const *) const;
|
2003-09-16 15:39:33 +00:00
|
|
|
|
/// Should be non-const...
|
|
|
|
|
void setCollapsed(bool) const;
|
|
|
|
|
///
|
|
|
|
|
Box const & buttonDim() const;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-16 15:39:33 +00:00
|
|
|
|
private:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
void lfunMouseRelease(FuncRequest const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-16 15:39:33 +00:00
|
|
|
|
FuncRequest adjustCommand(FuncRequest const &);
|
2003-10-15 08:49:44 +00:00
|
|
|
|
///
|
|
|
|
|
void edit(BufferView *, int index);
|
2003-09-16 15:39:33 +00:00
|
|
|
|
|
2001-03-11 03:20:44 +00:00
|
|
|
|
public:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
|
mutable InsetText inset;
|
2003-09-16 15:39:33 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
|
|
|
|
mutable bool collapsed_;
|
|
|
|
|
///
|
|
|
|
|
LyXFont labelfont_;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-30 14:43:14 +00:00
|
|
|
|
mutable Box button_dim;
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
|
|
|
|
mutable int topx;
|
|
|
|
|
mutable int topbaseline;
|
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
mutable std::string label;
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#if 0
|
2001-07-23 12:47:25 +00:00
|
|
|
|
///
|
2001-04-02 14:02:58 +00:00
|
|
|
|
bool autocollapse;
|
2001-07-24 22:08:49 +00:00
|
|
|
|
#endif
|
2001-08-01 15:42:53 +00:00
|
|
|
|
///
|
|
|
|
|
bool in_update;
|
2001-08-07 15:07:36 +00:00
|
|
|
|
///
|
|
|
|
|
mutable bool first_after_edit;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-09-16 15:39:33 +00:00
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool InsetCollapsable::insetAllowed(InsetOld::Code code) const
|
|
|
|
|
{
|
|
|
|
|
return inset.insetAllowed(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool InsetCollapsable::isTextInset() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void InsetCollapsable::fitInsetCursor(BufferView * bv) const
|
|
|
|
|
{
|
|
|
|
|
inset.fitInsetCursor(bv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void InsetCollapsable::setLabelFont(LyXFont & f)
|
|
|
|
|
{
|
|
|
|
|
labelfont_ = f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
inline
|
|
|
|
|
void InsetCollapsable::setAutoCollapse(bool f)
|
|
|
|
|
{
|
|
|
|
|
autocollapse = f;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void InsetCollapsable::scroll(BufferView *bv, float sx) const
|
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void InsetCollapsable::scroll(BufferView *bv, int offset) const
|
|
|
|
|
{
|
|
|
|
|
UpdatableInset::scroll(bv, offset);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool InsetCollapsable::isOpen() const
|
|
|
|
|
{
|
|
|
|
|
return !collapsed_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
bool InsetCollapsable::allowSpellcheck() const
|
|
|
|
|
{
|
|
|
|
|
return inset.allowSpellcheck();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
void InsetCollapsable::selectSelectedWord(BufferView * bv)
|
|
|
|
|
{
|
|
|
|
|
inset.selectSelectedWord(bv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
|
Box const & InsetCollapsable::buttonDim() const
|
|
|
|
|
{
|
|
|
|
|
return button_dim;
|
|
|
|
|
}
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#endif
|