2000-03-08 13:52:57 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetCollapsable.h
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* 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
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
#include "Inset.h"
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetText.h"
|
2003-09-07 01:45:40 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Box.h"
|
2008-02-05 10:34:01 +00:00
|
|
|
|
#include "TextClass.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2004-01-13 14:13:51 +00:00
|
|
|
|
class CursorSlice;
|
2007-08-13 12:13:17 +00:00
|
|
|
|
class InsetLayout;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace frontend { class Painter; }
|
2006-06-20 08:39:16 +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
|
|
|
|
*/
|
2004-03-25 09:16:36 +00:00
|
|
|
|
class InsetCollapsable : public InsetText {
|
2000-03-08 13:52:57 +00:00
|
|
|
|
public:
|
2003-12-02 07:15:42 +00:00
|
|
|
|
///
|
2008-03-04 22:28:18 +00:00
|
|
|
|
InsetCollapsable(Buffer const &,
|
2008-02-28 01:42:02 +00:00
|
|
|
|
CollapseStatus status = Inset::Open, DocumentClass * tc = 0);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2006-12-05 05:36:59 +00:00
|
|
|
|
InsetCollapsable(InsetCollapsable const & rhs);
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2007-11-02 21:27:41 +00:00
|
|
|
|
InsetCollapsable * asInsetCollapsable() { return this; }
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2007-11-02 21:27:41 +00:00
|
|
|
|
InsetCollapsable const * asInsetCollapsable() const { return this; }
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2007-12-25 18:53:38 +00:00
|
|
|
|
docstring toolTip(BufferView const & bv, int x, int y) const;
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2007-04-30 14:39:09 +00:00
|
|
|
|
docstring name() const { return from_ascii("Collapsable"); }
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
|
InsetLayout const & getLayout(BufferParams const &) const { return *layout_; }
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetLayout const & getLayout() const { return *layout_; }
|
2007-04-29 12:32:14 +00:00
|
|
|
|
///
|
2007-08-13 12:13:17 +00:00
|
|
|
|
void setLayout(BufferParams const &);
|
2008-02-05 10:34:01 +00:00
|
|
|
|
/// (Re-)set the character style parameters from \p tc according
|
|
|
|
|
/// to name()
|
2008-02-28 01:42:02 +00:00
|
|
|
|
void setLayout(DocumentClass const * const tc);
|
2007-08-13 12:13:17 +00:00
|
|
|
|
///
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
|
virtual bool useEmptyLayout() { return true; }
|
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void read(Lexer &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void write(std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2007-09-21 20:39:47 +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;
|
2007-09-17 21:48:25 +00:00
|
|
|
|
|
2004-11-30 01:59:49 +00:00
|
|
|
|
/// return x,y of given position relative to the inset's baseline
|
2006-10-17 16:23:27 +00:00
|
|
|
|
void cursorPos(BufferView const & bv, CursorSlice const & sl,
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
|
|
|
|
bool boundary, int & x, int & y) const;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
///
|
2005-04-22 08:57:22 +00:00
|
|
|
|
bool hitButton(FuncRequest const &) const;
|
2003-07-30 14:43:14 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
docstring const getNewLabel(docstring const & l) const;
|
2003-12-01 14:51:52 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
EDITABLE editable() const;
|
2003-11-10 11:26:33 +00:00
|
|
|
|
/// can we go further down on mouse click?
|
2003-12-02 07:15:42 +00:00
|
|
|
|
bool descendable() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
void setLabel(docstring const & l);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2004-02-13 11:05:29 +00:00
|
|
|
|
virtual void setButtonLabel() {}
|
2004-04-03 08:37:12 +00:00
|
|
|
|
///
|
2007-08-16 16:36:50 +00:00
|
|
|
|
bool isOpen() const { return geometry() != ButtonOnly; }
|
2003-12-02 07:15:42 +00:00
|
|
|
|
///
|
2005-09-28 15:02:47 +00:00
|
|
|
|
CollapseStatus status() const;
|
2007-08-16 16:36:50 +00:00
|
|
|
|
/** Of the old CollapseStatus we only keep the values
|
|
|
|
|
* Open and Collapsed.
|
|
|
|
|
* We define a list of possible inset decoration
|
|
|
|
|
* styles, and a list of possible (concrete, visual)
|
|
|
|
|
* inset geometries. Relationships between them
|
|
|
|
|
* (geometries in body of table):
|
|
|
|
|
*
|
|
|
|
|
* \ CollapseStatus:
|
|
|
|
|
* Decoration: \ Open Collapsed
|
|
|
|
|
* -------------+-------------------------------
|
|
|
|
|
* Classic | *) TopButton, <--x) ButtonOnly
|
|
|
|
|
* | LeftButton
|
2008-02-05 23:29:15 +00:00
|
|
|
|
* Minimalistic | NoButton ButtonOnly
|
2007-08-16 16:36:50 +00:00
|
|
|
|
* Conglomerate | SubLabel Corners
|
|
|
|
|
* ---------------------------------------------
|
|
|
|
|
* *) toggled by openinlined_
|
|
|
|
|
* x) toggled by autoOpen_
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// Default looks
|
2008-02-22 16:24:55 +00:00
|
|
|
|
virtual InsetLayout::InsetDecoration decoration() const;
|
2007-08-16 16:36:50 +00:00
|
|
|
|
///
|
|
|
|
|
enum Geometry {
|
|
|
|
|
TopButton,
|
|
|
|
|
ButtonOnly,
|
|
|
|
|
NoButton,
|
|
|
|
|
LeftButton,
|
|
|
|
|
SubLabel,
|
|
|
|
|
Corners
|
|
|
|
|
};
|
|
|
|
|
/// Returns the geometry based on CollapseStatus
|
|
|
|
|
/// (status_), autoOpen_ and openinlined_, and of
|
|
|
|
|
/// course decoration().
|
|
|
|
|
Geometry geometry() const;
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2004-01-26 10:13:15 +00:00
|
|
|
|
bool allowSpellCheck() const { return true; }
|
2005-04-22 08:57:22 +00:00
|
|
|
|
///
|
2007-10-11 10:13:45 +00:00
|
|
|
|
bool allowMultiPar() const;
|
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
|
void setStatus(Cursor & cur, CollapseStatus st);
|
2006-12-04 04:31:18 +00:00
|
|
|
|
///
|
|
|
|
|
bool setMouseHover(bool mouse_hover);
|
2007-08-20 19:02:38 +00:00
|
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
|
ColorCode backgroundColor() const { return layout_->bgcolor(); }
|
2008-02-22 02:32:52 +00:00
|
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int latex(odocstream &, OutputParams const &) const;
|
2007-08-22 18:55:03 +00:00
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures &) const;
|
2007-10-16 16:48:21 +00:00
|
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
|
InsetCode lyxCode() const { return COLLAPSABLE_CODE; }
|
2005-07-14 17:30:24 +00:00
|
|
|
|
|
2007-10-25 09:19:26 +00:00
|
|
|
|
/// Allow multiple blanks
|
2008-02-22 02:32:52 +00:00
|
|
|
|
virtual bool isFreeSpacing() const { return layout_->isFreeSpacing(); }
|
2007-10-25 09:19:26 +00:00
|
|
|
|
/// Don't eliminate empty paragraphs
|
2008-02-22 02:32:52 +00:00
|
|
|
|
virtual bool allowEmpty() const { return layout_->isKeepEmpty(); }
|
2007-11-05 23:44:47 +00:00
|
|
|
|
/// Force inset into LTR environment if surroundings are RTL?
|
2008-02-22 02:32:52 +00:00
|
|
|
|
virtual bool forceLTR() const { return layout_->isForceLtr(); }
|
Fix bug 4037 and related problems. The patch has been cleaned up a bit
from the one posted to the list.
The basic idea has two parts. First, we hard code an "empty layout"
(called PlainLayout, for want of a better name) in TextClass and read it
before doing anything else. It can therefore be customized by classes,
if they want---say, to make it left-aligned. Second, InsetText's are
divided into three types: (i) normal ones, that use the "default" layout
defined by the text class; (ii) highly restrictive ones, such as ERT and
(not quite an inset) table cells, which demand the empty layout; (iii)
middling ones, which default to an empty layout and use the empty layout
in place of the default. (This is so we don't get the same problem we
had with ERT in e.g. footnotes.) The type of inset is signaled by new
methods InsetText::forceEmptyLayout() and InsetText::useEmptyLayout().
(The latter might better be called: useEmptyLayoutInsteadOfDefault(),
but that's silly.) The old InsetText::forceDefaultParagraphs() has been
split into these, plus a new method InsetText::allowParagraphCustomization().
A lot of the changes just adapt to this change.
The other big change is in GuiToolbar: We want to show LyXDefault and
the "default" layout only when they're active.
There are a handful of places where I'm not entirely sure whether we
should be using forceEmptyLayout or !allowParagraphCustomization() or
both. The InsetCaption is one of these. These places, and some others,
are marked with FIXMEs, so I'd appreciate it if people would search
through the patch and let me know whether these need changing. If they
don't, the FIXMEs can be deleted.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22966 a592a061-630c-0410-9148-cb99ea01b6c8
2008-02-12 17:31:07 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool useEmptyLayout() const { return true; }
|
2008-02-21 16:31:59 +00:00
|
|
|
|
/// Is this inset's layout defined in the document's textclass?
|
|
|
|
|
/// May be wrong after textclass change or paste from another document
|
|
|
|
|
bool undefined() const;
|
2008-03-08 22:57:22 +00:00
|
|
|
|
///
|
|
|
|
|
virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
|
2005-07-14 17:30:24 +00:00
|
|
|
|
protected:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2004-03-18 13:57:20 +00:00
|
|
|
|
///
|
2008-02-10 19:52:45 +00:00
|
|
|
|
void edit(Cursor & cur, bool front,
|
2008-02-11 08:20:13 +00:00
|
|
|
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset * editXY(Cursor & cur, int x, int y);
|
2005-05-06 20:00:31 +00:00
|
|
|
|
///
|
2007-02-16 09:11:19 +00:00
|
|
|
|
docstring floatName(std::string const & type, BufferParams const &) const;
|
2007-10-30 12:30:46 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void resetParagraphsFont();
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2004-01-30 11:41:12 +00:00
|
|
|
|
private:
|
2008-02-28 01:42:02 +00:00
|
|
|
|
/// cache for the layout_. Make sure it is in sync with the document class!
|
2008-02-05 10:34:01 +00:00
|
|
|
|
InsetLayout const * layout_;
|
2007-11-07 21:57:19 +00:00
|
|
|
|
///
|
|
|
|
|
Dimension dimensionCollapsed() const;
|
2007-11-03 00:35:07 +00:00
|
|
|
|
///
|
|
|
|
|
docstring labelstring_;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
///
|
2007-11-07 21:57:19 +00:00
|
|
|
|
mutable Box button_dim;
|
|
|
|
|
///
|
2004-01-30 11:41:12 +00:00
|
|
|
|
mutable CollapseStatus status_;
|
2004-03-10 08:50:46 +00:00
|
|
|
|
/// a substatus of the Open status, determined automatically in metrics
|
|
|
|
|
mutable bool openinlined_;
|
2005-09-28 15:02:47 +00:00
|
|
|
|
/// the inset will automatically open when the cursor is inside
|
|
|
|
|
mutable bool autoOpen_;
|
2006-12-04 04:31:18 +00:00
|
|
|
|
/// changes color when mouse enters/leaves this inset
|
|
|
|
|
bool mouse_hover_;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#endif
|