2003-02-17 17:12:50 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-04-29 13:39:47 +00:00
|
|
|
* \file Inset.h
|
2003-02-17 17:12:50 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2007-04-29 12:32:14 +00:00
|
|
|
* \author Alejandro Aguilar Sierra
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
|
|
|
* \author Lars Gullik Bjønnes
|
2007-04-29 12:32:14 +00:00
|
|
|
* \author Matthias Ettrich
|
2003-02-17 17:12:50 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-17 17:12:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSETBASE_H
|
|
|
|
#define INSETBASE_H
|
|
|
|
|
2007-10-25 12:41:02 +00:00
|
|
|
#include "ColorCode.h"
|
2007-10-13 09:04:52 +00:00
|
|
|
#include "InsetCode.h"
|
2010-10-31 01:26:50 +00:00
|
|
|
#include "LayoutEnums.h"
|
2010-01-20 19:42:12 +00:00
|
|
|
#include "OutputEnums.h"
|
2019-12-28 12:43:17 +00:00
|
|
|
#include "OutputParams.h"
|
2007-10-13 09:04:52 +00:00
|
|
|
|
2020-12-02 20:34:28 +00:00
|
|
|
#include "support/docstring.h"
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "support/strfwd.h"
|
2008-03-15 00:02:41 +00:00
|
|
|
#include "support/types.h"
|
2006-11-28 15:15:49 +00:00
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
#include <climits>
|
|
|
|
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2006-10-20 09:29:19 +00:00
|
|
|
|
2003-09-18 20:18:39 +00:00
|
|
|
class Buffer;
|
2003-03-10 13:33:39 +00:00
|
|
|
class BufferView;
|
2007-08-30 18:03:17 +00:00
|
|
|
class Change;
|
2008-03-15 00:02:41 +00:00
|
|
|
class CompletionList;
|
2007-08-30 18:03:17 +00:00
|
|
|
class Cursor;
|
2004-01-30 11:41:12 +00:00
|
|
|
class CursorSlice;
|
2007-11-01 22:17:22 +00:00
|
|
|
class Dimension;
|
2008-02-22 20:45:18 +00:00
|
|
|
class DocIterator;
|
2018-01-26 07:38:52 +00:00
|
|
|
class Encoding;
|
2003-02-18 11:47:16 +00:00
|
|
|
class FuncRequest;
|
2004-02-20 17:19:53 +00:00
|
|
|
class FuncStatus;
|
2017-05-12 21:13:38 +00:00
|
|
|
class InsetArgument;
|
2017-10-16 08:12:21 +00:00
|
|
|
class InsetCollapsible;
|
2009-12-10 18:30:48 +00:00
|
|
|
class InsetCommand;
|
2018-01-21 03:59:12 +00:00
|
|
|
class InsetGraphics;
|
2007-11-03 18:07:41 +00:00
|
|
|
class InsetIterator;
|
2007-08-13 12:13:17 +00:00
|
|
|
class InsetLayout;
|
2007-10-18 15:29:51 +00:00
|
|
|
class InsetList;
|
2006-09-16 18:11:38 +00:00
|
|
|
class InsetMath;
|
2008-04-11 12:02:10 +00:00
|
|
|
class InsetTabular;
|
2006-03-17 19:45:28 +00:00
|
|
|
class InsetText;
|
2004-01-15 11:58:35 +00:00
|
|
|
class LaTeXFeatures;
|
2007-04-26 11:30:54 +00:00
|
|
|
class Lexer;
|
2007-08-30 18:03:17 +00:00
|
|
|
class MathAtom;
|
2003-05-30 06:48:24 +00:00
|
|
|
class MetricsInfo;
|
2007-08-30 18:03:17 +00:00
|
|
|
class PainterInfo;
|
|
|
|
class ParIterator;
|
|
|
|
class Text;
|
2017-01-13 10:06:48 +00:00
|
|
|
class TocBackend;
|
2019-05-09 23:35:40 +00:00
|
|
|
class XMLStream;
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
class otexstream;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace graphics { class PreviewLoader; }
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2020-10-19 14:15:45 +00:00
|
|
|
namespace support {class FileNameList; }
|
2004-01-30 11:41:12 +00:00
|
|
|
|
2010-02-15 22:46:50 +00:00
|
|
|
/// returns the InsetCode corresponding to the \c name.
|
|
|
|
/// Eg, insetCode("branch") == BRANCH_CODE
|
2008-03-15 00:02:41 +00:00
|
|
|
InsetCode insetCode(std::string const & name);
|
2010-02-15 22:46:50 +00:00
|
|
|
/// returns the Inset name corresponding to the \c InsetCode.
|
|
|
|
/// Eg, insetName(BRANCH_CODE) == "branch"
|
2008-03-15 00:02:41 +00:00
|
|
|
std::string insetName(InsetCode);
|
2010-02-15 22:46:50 +00:00
|
|
|
/// returns the Inset name corresponding to the \c InsetCode.
|
|
|
|
/// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
|
|
|
|
docstring insetDisplayName(InsetCode);
|
2010-12-20 21:55:09 +00:00
|
|
|
///
|
2015-11-26 20:21:21 +00:00
|
|
|
static int const TOC_ENTRY_LENGTH = 120;
|
2008-03-15 00:02:41 +00:00
|
|
|
|
2003-02-17 17:12:50 +00:00
|
|
|
/// Common base class to all insets
|
2004-01-26 10:13:15 +00:00
|
|
|
|
|
|
|
// Do not add _any_ (non-static) data members as this would inflate
|
|
|
|
// everything storing large quantities of insets. Mathed e.g. would
|
|
|
|
// suffer.
|
|
|
|
|
2007-05-31 12:30:17 +00:00
|
|
|
class Inset {
|
2003-02-17 17:12:50 +00:00
|
|
|
public:
|
2008-02-10 19:52:45 +00:00
|
|
|
///
|
2008-02-11 08:20:13 +00:00
|
|
|
enum EntryDirection {
|
|
|
|
ENTRY_DIRECTION_IGNORE,
|
|
|
|
ENTRY_DIRECTION_RIGHT,
|
2010-12-17 19:56:51 +00:00
|
|
|
ENTRY_DIRECTION_LEFT
|
2008-02-10 19:52:45 +00:00
|
|
|
};
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2003-06-16 11:49:38 +00:00
|
|
|
/// virtual base class destructor
|
2007-05-31 12:30:17 +00:00
|
|
|
virtual ~Inset() {}
|
2003-06-16 11:49:38 +00:00
|
|
|
|
2008-02-23 22:32:33 +00:00
|
|
|
/// change associated Buffer
|
2008-02-27 20:43:16 +00:00
|
|
|
virtual void setBuffer(Buffer & buffer);
|
2016-12-05 13:47:13 +00:00
|
|
|
/// reset associated Buffer to null value
|
|
|
|
virtual void resetBuffer();
|
2008-02-23 22:32:33 +00:00
|
|
|
/// retrieve associated Buffer
|
2017-03-27 14:18:14 +00:00
|
|
|
Buffer & buffer();
|
|
|
|
Buffer const & buffer() const;
|
2010-03-08 18:57:42 +00:00
|
|
|
/// Returns true if buffer_ actually points to a Buffer that has
|
|
|
|
/// been loaded into LyX and is still open. Note that this will
|
2010-03-08 19:07:05 +00:00
|
|
|
/// always return false for cloned Buffers. If you want to allow
|
|
|
|
/// for the case of cloned Buffers, use isBufferValid().
|
2010-03-08 18:57:42 +00:00
|
|
|
bool isBufferLoaded() const;
|
2010-03-08 19:07:05 +00:00
|
|
|
/// Returns true if this is a loaded buffer or a cloned buffer.
|
|
|
|
bool isBufferValid() const;
|
2008-02-23 22:32:33 +00:00
|
|
|
|
2008-03-03 17:58:26 +00:00
|
|
|
/// initialize view for this inset.
|
2008-03-02 18:14:12 +00:00
|
|
|
/**
|
|
|
|
* This is typically used after this inset is created interactively.
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
* Intended purpose is to sanitize internal state with regard to current
|
2017-07-03 17:45:58 +00:00
|
|
|
* Buffer.
|
2008-03-02 18:14:12 +00:00
|
|
|
**/
|
2013-05-12 11:00:02 +00:00
|
|
|
virtual void initView() {}
|
2008-03-10 15:30:32 +00:00
|
|
|
/// \return true if this inset is labeled.
|
|
|
|
virtual bool isLabeled() const { return false; }
|
2008-03-02 18:14:12 +00:00
|
|
|
|
2004-01-15 11:58:35 +00:00
|
|
|
/// identification as math inset
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetMath * asInsetMath() { return nullptr; }
|
2009-08-01 21:39:14 +00:00
|
|
|
/// identification as math inset
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetMath const * asInsetMath() const { return nullptr; }
|
2004-04-03 08:37:12 +00:00
|
|
|
/// true for 'math' math inset, but not for e.g. mbox
|
2004-02-25 14:39:14 +00:00
|
|
|
virtual bool inMathed() const { return false; }
|
2007-11-03 18:07:41 +00:00
|
|
|
/// is this inset based on the InsetText class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetText * asInsetText() { return nullptr; }
|
2007-11-03 18:07:41 +00:00
|
|
|
/// is this inset based on the InsetText class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetText const * asInsetText() const { return nullptr; }
|
2017-10-16 08:12:21 +00:00
|
|
|
/// is this inset based on the InsetCollapsible class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetCollapsible * asInsetCollapsible() { return nullptr; }
|
2017-10-16 08:12:21 +00:00
|
|
|
/// is this inset based on the InsetCollapsible class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetCollapsible const * asInsetCollapsible() const { return nullptr; }
|
2008-04-11 12:02:10 +00:00
|
|
|
/// is this inset based on the InsetTabular class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetTabular * asInsetTabular() { return nullptr; }
|
2008-04-11 12:02:10 +00:00
|
|
|
/// is this inset based on the InsetTabular class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetTabular const * asInsetTabular() const { return nullptr; }
|
2009-12-10 18:30:48 +00:00
|
|
|
/// is this inset based on the InsetCommand class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetCommand * asInsetCommand() { return nullptr; }
|
2009-12-10 18:30:48 +00:00
|
|
|
/// is this inset based on the InsetCommand class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetCommand const * asInsetCommand() const { return nullptr; }
|
2017-05-12 21:13:38 +00:00
|
|
|
/// is this inset based on the InsetArgument class?
|
|
|
|
virtual InsetArgument const * asInsetArgument() const { return nullptr; }
|
2018-01-21 03:59:12 +00:00
|
|
|
/// is this inset based on the InsetGraphics class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetGraphics * asInsetGraphics() { return nullptr; }
|
2018-01-21 03:59:12 +00:00
|
|
|
/// is this inset based on the InsetGraphics class?
|
2020-10-27 09:20:27 +00:00
|
|
|
virtual InsetGraphics const * asInsetGraphics() const { return nullptr; }
|
2007-11-03 18:07:41 +00:00
|
|
|
|
2004-12-02 11:32:14 +00:00
|
|
|
/// the real dispatcher
|
2007-04-26 14:56:30 +00:00
|
|
|
void dispatch(Cursor & cur, FuncRequest & cmd);
|
2004-12-02 11:32:14 +00:00
|
|
|
/**
|
|
|
|
* \returns true if this function made a definitive decision on
|
|
|
|
* whether the inset wants to handle the request \p cmd or not.
|
|
|
|
* The result of this decision is put into \p status.
|
2005-04-13 09:43:58 +00:00
|
|
|
*
|
|
|
|
* Every request that is enabled in this method needs to be handled
|
|
|
|
* in doDispatch(). Normally we have a 1:1 relationship between the
|
|
|
|
* requests handled in getStatus() and doDispatch(), but there are
|
|
|
|
* some exceptions:
|
|
|
|
* - A request that is disabled in getStatus() does not need to
|
|
|
|
* appear in doDispatch(). It is guaranteed that doDispatch()
|
|
|
|
* is never called with this request.
|
2007-04-29 13:39:47 +00:00
|
|
|
* - A few requests are en- or disabled in Inset::getStatus().
|
2005-04-13 09:43:58 +00:00
|
|
|
* These need to be handled in the doDispatch() methods of the
|
2007-04-29 13:39:47 +00:00
|
|
|
* derived insets, since Inset::doDispatch() has not enough
|
2005-04-13 09:43:58 +00:00
|
|
|
* information to handle them.
|
2005-04-22 08:57:22 +00:00
|
|
|
* - LFUN_MOUSE_* need not to be handled in getStatus(), because these
|
|
|
|
* are dispatched directly
|
2004-12-02 11:32:14 +00:00
|
|
|
*/
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual bool getStatus(Cursor & cur, FuncRequest const & cmd,
|
2004-03-18 13:57:20 +00:00
|
|
|
FuncStatus & status) const;
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
/// cursor enters
|
2017-07-03 17:45:58 +00:00
|
|
|
virtual void edit(Cursor & cur, bool front,
|
2008-02-11 08:20:13 +00:00
|
|
|
EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
|
2017-06-08 09:35:05 +00:00
|
|
|
/// sets cursor recursively descending into nested editable insets
|
|
|
|
/**
|
|
|
|
\return the inset pointer if x,y is covering that inset
|
|
|
|
\param x,y are absolute screen coordinates.
|
|
|
|
*/
|
2017-03-03 22:26:58 +00:00
|
|
|
/// Note: this method must preserve the selection status. See:
|
|
|
|
/// https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg199001.html
|
2007-04-29 13:39:47 +00:00
|
|
|
virtual Inset * editXY(Cursor & cur, int x, int y);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
2020-01-13 21:09:06 +00:00
|
|
|
/// The default margin inside text insets
|
|
|
|
static int textOffset(BufferView const *) { return 4; }
|
|
|
|
///
|
|
|
|
virtual int topOffset(BufferView const *bv) const { return textOffset(bv); }
|
|
|
|
///
|
|
|
|
virtual int bottomOffset(BufferView const *bv) const { return textOffset(bv); }
|
|
|
|
///
|
|
|
|
virtual int leftOffset(BufferView const *bv) const { return textOffset(bv); }
|
|
|
|
///
|
|
|
|
virtual int rightOffset(BufferView const *bv) const { return textOffset(bv); }
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
/// compute the size of the object returned in dim
|
2007-09-21 20:39:47 +00:00
|
|
|
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
2003-06-02 10:03:27 +00:00
|
|
|
/// draw inset and update (xo, yo)-cache
|
2003-05-30 06:48:24 +00:00
|
|
|
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
2004-02-02 17:32:56 +00:00
|
|
|
/// draw inset selection if necessary
|
|
|
|
virtual void drawSelection(PainterInfo &, int, int) const {}
|
2008-10-25 10:47:38 +00:00
|
|
|
/// draw inset background if the inset has an own background and a
|
|
|
|
/// selection is drawn by drawSelection.
|
2016-08-17 09:21:38 +00:00
|
|
|
virtual void drawBackground(PainterInfo &, int, int) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
///
|
2007-12-22 14:38:43 +00:00
|
|
|
virtual bool editing(BufferView const * bv) const;
|
2005-07-15 22:10:25 +00:00
|
|
|
///
|
2010-02-16 13:35:40 +00:00
|
|
|
virtual bool showInsetDialog(BufferView *) const;
|
2007-01-20 00:55:24 +00:00
|
|
|
|
2007-06-07 21:36:42 +00:00
|
|
|
/// draw two angular markers
|
2017-12-19 21:32:32 +00:00
|
|
|
virtual void drawMarkers(PainterInfo & pi, int x, int y) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
/// add space for markers
|
|
|
|
void metricsMarkers(Dimension & dim, int framesize = 1) const;
|
|
|
|
/// add space for markers
|
|
|
|
void metricsMarkers2(Dimension & dim, int framesize = 1) const;
|
2017-01-06 08:52:10 +00:00
|
|
|
/// draw inset decoration if necessary.
|
|
|
|
/// This can use \c drawMarkers() for example.
|
|
|
|
virtual void drawDecoration(PainterInfo &, int, int) const {}
|
2016-12-06 08:48:49 +00:00
|
|
|
|
|
|
|
/// last metrics computed for the inset
|
|
|
|
Dimension const dimension(BufferView const &) const;
|
2004-01-16 10:55:19 +00:00
|
|
|
/// last drawn position for 'important' insets
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
int xo(BufferView const & bv) const;
|
2004-01-16 10:55:19 +00:00
|
|
|
/// last drawn position for 'important' insets
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
int yo(BufferView const & bv) const;
|
2004-01-30 11:41:12 +00:00
|
|
|
/// do we cover screen position x/y?
|
2016-12-06 08:48:49 +00:00
|
|
|
bool covers(BufferView const & bv, int x, int y) const;
|
2007-04-26 14:56:30 +00:00
|
|
|
/// get the screen positions of the cursor (see note in Cursor.cpp)
|
2006-10-17 16:23:27 +00:00
|
|
|
virtual void cursorPos(BufferView const & bv,
|
|
|
|
CursorSlice const & sl, bool boundary, int & x, int & y) const;
|
2004-04-03 08:37:12 +00:00
|
|
|
|
2021-03-24 19:00:51 +00:00
|
|
|
///
|
|
|
|
virtual docstring layoutName() const;
|
|
|
|
///
|
|
|
|
virtual InsetLayout const & getLayout() const;
|
|
|
|
///
|
|
|
|
virtual bool isPassThru() const;
|
2009-07-13 15:47:40 +00:00
|
|
|
/// Allow multiple blanks
|
2009-07-13 15:57:08 +00:00
|
|
|
virtual bool isFreeSpacing() const;
|
2009-07-13 15:47:40 +00:00
|
|
|
/// Don't eliminate empty paragraphs
|
2009-07-13 15:57:08 +00:00
|
|
|
virtual bool allowEmpty() const;
|
2010-05-22 02:00:41 +00:00
|
|
|
/// Force inset into LTR environment if surroundings are RTL
|
2019-08-05 14:30:01 +00:00
|
|
|
virtual bool forceLTR(OutputParams const &) const;
|
2010-10-26 01:10:19 +00:00
|
|
|
/// whether to include this inset in the strings generated for the TOC
|
|
|
|
virtual bool isInToc() const;
|
2021-03-24 19:00:51 +00:00
|
|
|
/// Inset font
|
|
|
|
virtual FontInfo getFont() const;
|
|
|
|
/// Label font
|
|
|
|
virtual FontInfo getLabelfont() const;
|
2007-10-25 09:19:26 +00:00
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
/// Where should we go when we press the up or down cursor key?
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual bool idxUpDown(Cursor & cur, bool up) const;
|
2007-11-05 19:44:03 +00:00
|
|
|
/// Move one cell backwards
|
|
|
|
virtual bool idxBackward(Cursor &) const { return false; }
|
|
|
|
/// Move one cell forward
|
|
|
|
virtual bool idxForward(Cursor &) const { return false; }
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2007-11-05 19:44:03 +00:00
|
|
|
/// Move to the next cell
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual bool idxNext(Cursor &) const { return false; }
|
2007-11-05 19:44:03 +00:00
|
|
|
/// Move to the previous cell
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual bool idxPrev(Cursor &) const { return false; }
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2007-11-05 19:41:16 +00:00
|
|
|
/// Target pos when we enter the inset while moving forward
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual bool idxFirst(Cursor &) const { return false; }
|
2007-11-05 19:41:16 +00:00
|
|
|
/// Target pos when we enter the inset while moving backwards
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual bool idxLast(Cursor &) const { return false; }
|
2004-01-26 10:13:15 +00:00
|
|
|
|
|
|
|
/// Delete a cell and move cursor
|
|
|
|
virtual bool idxDelete(idx_type &) { return false; }
|
|
|
|
/// pulls cell after pressing erase
|
|
|
|
virtual void idxGlue(idx_type) {}
|
2005-04-13 09:43:58 +00:00
|
|
|
/// returns list of cell indices that are "between" from and to for
|
|
|
|
/// selection purposes
|
2004-01-26 10:13:15 +00:00
|
|
|
virtual bool idxBetween(idx_type idx, idx_type from, idx_type to) const;
|
|
|
|
|
|
|
|
/// to which column belongs a cell with a given index?
|
|
|
|
virtual col_type col(idx_type) const { return 0; }
|
|
|
|
/// to which row belongs a cell with a given index?
|
|
|
|
virtual row_type row(idx_type) const { return 0; }
|
2008-03-12 00:19:07 +00:00
|
|
|
/// cell index corresponding to row and column;
|
2004-01-26 10:13:15 +00:00
|
|
|
virtual idx_type index(row_type row, col_type col) const;
|
2004-04-03 08:37:12 +00:00
|
|
|
/// number of embedded cells
|
|
|
|
virtual size_t nargs() const { return 0; }
|
|
|
|
/// number of rows in gridlike structures
|
|
|
|
virtual size_t nrows() const { return 0; }
|
|
|
|
/// number of columns in gridlike structures
|
|
|
|
virtual size_t ncols() const { return 0; }
|
2008-02-22 20:45:42 +00:00
|
|
|
/// Is called when the cursor leaves this inset.
|
2017-07-03 17:45:58 +00:00
|
|
|
/// Returns true if cursor is now invalid, e.g. if former
|
|
|
|
/// insets in higher cursor slices of \c old do not exist
|
2008-02-22 20:45:42 +00:00
|
|
|
/// anymore.
|
2008-11-15 17:11:01 +00:00
|
|
|
/// \c old is the old cursor, the last slice points to this.
|
2008-02-22 20:45:42 +00:00
|
|
|
/// \c cur is the new cursor. Use the update flags to cause a redraw.
|
|
|
|
virtual bool notifyCursorLeaves(Cursor const & /*old*/, Cursor & /*cur*/)
|
|
|
|
{ return false; }
|
2008-11-15 17:11:01 +00:00
|
|
|
/// Is called when the cursor enters this inset.
|
2017-07-03 17:45:58 +00:00
|
|
|
/// Returns true if cursor is now invalid, e.g. if former
|
|
|
|
/// insets in higher cursor slices of \c old do not exist
|
2008-11-15 17:11:01 +00:00
|
|
|
/// anymore.
|
2010-10-18 14:20:03 +00:00
|
|
|
/// \c cur is the new cursor, some slice points to this. Use the update
|
|
|
|
/// flags to cause a redraw.
|
2008-11-15 17:11:01 +00:00
|
|
|
virtual bool notifyCursorEnters(Cursor & /*cur*/)
|
|
|
|
{ return false; }
|
2010-04-30 14:47:46 +00:00
|
|
|
/// is called when the mouse enters or leaves this inset
|
|
|
|
/// return true if this inset needs a repaint
|
2010-10-24 19:24:36 +00:00
|
|
|
virtual bool setMouseHover(BufferView const *, bool) const
|
|
|
|
{ return false; }
|
2007-06-07 21:36:42 +00:00
|
|
|
/// return true if this inset is hovered (under mouse)
|
2017-07-03 17:45:58 +00:00
|
|
|
/// This is by now only used by mathed to draw corners
|
2007-06-07 21:36:42 +00:00
|
|
|
/// (Inset::drawMarkers() and Inset::drawMarkers2()).
|
2017-07-03 17:45:58 +00:00
|
|
|
/// Other insets do not have to redefine this function to
|
2007-06-07 21:36:42 +00:00
|
|
|
/// return the correct status of mouseHovered.
|
2010-05-01 11:38:05 +00:00
|
|
|
virtual bool mouseHovered(BufferView const *) const { return false; }
|
2004-01-20 14:25:24 +00:00
|
|
|
|
|
|
|
/// request "external features"
|
|
|
|
virtual void validate(LaTeXFeatures &) const {}
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2010-01-30 11:15:05 +00:00
|
|
|
/// Validate LFUN_INSET_MODIFY argument.
|
|
|
|
virtual bool validateModifyArgument(docstring const &) const { return true; }
|
|
|
|
|
2004-01-20 14:25:24 +00:00
|
|
|
/// describe content if cursor inside
|
2006-10-22 10:15:23 +00:00
|
|
|
virtual void infoize(odocstream &) const {}
|
2004-01-20 14:25:24 +00:00
|
|
|
/// describe content if cursor behind
|
2006-10-22 10:15:23 +00:00
|
|
|
virtual void infoize2(odocstream &) const {}
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
enum { PLAINTEXT_NEWLINE = 10000 };
|
2007-02-20 17:52:41 +00:00
|
|
|
|
2006-10-11 19:40:50 +00:00
|
|
|
/// plain text output in ucs4 encoding
|
2007-02-20 17:52:41 +00:00
|
|
|
/// return the number of characters; in case of multiple lines of
|
|
|
|
/// output, add PLAINTEXT_NEWLINE to the number of chars in the last line
|
2013-03-08 19:52:18 +00:00
|
|
|
virtual int plaintext(odocstringstream &, OutputParams const &,
|
|
|
|
size_t max_length = INT_MAX) const = 0;
|
2004-01-26 10:13:15 +00:00
|
|
|
/// docbook output
|
2020-06-08 21:27:49 +00:00
|
|
|
virtual void docbook(XMLStream &, OutputParams const &) const;
|
2009-11-19 20:22:04 +00:00
|
|
|
/// XHTML output
|
2019-05-09 23:35:40 +00:00
|
|
|
/// the inset is expected to write XHTML to the XMLStream
|
2009-11-19 20:22:04 +00:00
|
|
|
/// \return any "deferred" material that should be written outside the
|
|
|
|
/// normal stream, and which will in fact be written after the current
|
|
|
|
/// paragraph closes. this is appropriate e.g. for floats.
|
2019-05-09 23:35:40 +00:00
|
|
|
virtual docstring xhtml(XMLStream &, OutputParams const &) const;
|
2010-11-26 17:08:40 +00:00
|
|
|
|
2010-12-20 21:55:09 +00:00
|
|
|
/// Writes a string representation of the inset to the odocstream.
|
|
|
|
/// This one should be called when you want the whole contents of
|
|
|
|
/// the inset.
|
2010-12-15 01:34:04 +00:00
|
|
|
virtual void toString(odocstream &) const {}
|
2010-12-20 21:55:09 +00:00
|
|
|
/// Appends a potentially abbreviated version of the inset to
|
|
|
|
/// \param str. Intended for use by the TOC.
|
2014-03-29 17:34:36 +00:00
|
|
|
virtual void forOutliner(docstring & str,
|
2021-07-12 09:55:19 +00:00
|
|
|
size_t const maxlen = TOC_ENTRY_LENGTH,
|
|
|
|
bool const shorten = true) const;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2017-07-20 09:18:20 +00:00
|
|
|
/// Can a cursor be put in there ?
|
|
|
|
/// Forced to false for insets that have hidden contents, like
|
|
|
|
/// InsetMathCommand and InsetInfo.
|
|
|
|
virtual bool isActive() const { return nargs() > 0; }
|
2009-04-22 20:55:13 +00:00
|
|
|
/// can the contents of the inset be edited on screen ?
|
2017-10-16 08:12:21 +00:00
|
|
|
// equivalent to isActive except for closed InsetCollapsible
|
2009-04-22 20:55:13 +00:00
|
|
|
virtual bool editable() const;
|
|
|
|
/// has the Inset settings that can be modified in a dialog ?
|
|
|
|
virtual bool hasSettings() const;
|
2004-01-26 10:13:15 +00:00
|
|
|
/// can we go further down on mouse click?
|
2017-10-16 08:12:21 +00:00
|
|
|
/// true for InsetCaption, InsetCollapsibles (not ButtonOnly), InsetTabular
|
2009-10-24 00:02:41 +00:00
|
|
|
virtual bool descendable(BufferView const &) const { return false; }
|
2010-10-24 20:11:40 +00:00
|
|
|
/// can we click at the specified position ?
|
2016-02-02 16:17:10 +00:00
|
|
|
virtual bool clickable(BufferView const &, int, int) const { return false; }
|
2012-12-30 17:29:02 +00:00
|
|
|
/// Move one cell backwards
|
2013-03-22 21:23:38 +00:00
|
|
|
virtual bool allowsCaptionVariation(std::string const &) const { return false; }
|
2016-03-14 10:46:28 +00:00
|
|
|
// true for insets that have a table structure (InsetMathGrid, InsetTabular)
|
|
|
|
virtual bool isTable() const { return false; }
|
2009-04-22 20:55:13 +00:00
|
|
|
|
2006-03-17 19:45:28 +00:00
|
|
|
/// does this contain text that can be change track marked in DVI?
|
|
|
|
virtual bool canTrackChanges() const { return false; }
|
2016-05-22 21:48:28 +00:00
|
|
|
/// Will this inset paint its own change tracking status (in the parent
|
|
|
|
/// paragraph) or will it let RowPainter handle it?
|
|
|
|
virtual bool canPaintChange(BufferView const &) const { return false; }
|
2004-01-26 10:13:15 +00:00
|
|
|
/// return true if the inset should be removed automatically
|
|
|
|
virtual bool autoDelete() const;
|
|
|
|
|
2008-02-21 19:42:34 +00:00
|
|
|
/// Returns true if the inset supports completions.
|
|
|
|
virtual bool completionSupported(Cursor const &) const { return false; }
|
|
|
|
/// Returns true if the inset supports inline completions at the
|
|
|
|
/// cursor position. In this case the completion might be stored
|
|
|
|
/// in the BufferView's inlineCompletion property.
|
2017-07-03 17:45:58 +00:00
|
|
|
virtual bool inlineCompletionSupported(Cursor const & /*cur*/) const
|
2008-02-21 20:04:17 +00:00
|
|
|
{ return false; }
|
2008-02-21 19:42:34 +00:00
|
|
|
/// Return true if the inline completion should be automatic.
|
|
|
|
virtual bool automaticInlineCompletion() const { return true; }
|
|
|
|
/// Return true if the popup completion should be automatic.
|
|
|
|
virtual bool automaticPopupCompletion() const { return true; }
|
2008-03-16 17:07:10 +00:00
|
|
|
/// Return true if the cursor should indicate a completion.
|
|
|
|
virtual bool showCompletionCursor() const { return true; }
|
2008-02-21 19:42:34 +00:00
|
|
|
/// Returns completion suggestions at cursor position. Return an
|
|
|
|
/// null pointer if no completion is a available or possible.
|
2008-02-21 23:38:46 +00:00
|
|
|
/// The caller is responsible to free the returned object!
|
2017-07-03 17:45:58 +00:00
|
|
|
virtual CompletionList const * createCompletionList(Cursor const &) const
|
2008-02-21 23:36:02 +00:00
|
|
|
{ return 0; }
|
2008-02-21 19:42:34 +00:00
|
|
|
/// Returns the completion prefix to filter the suggestions for completion.
|
|
|
|
/// This is only called if completionList returned a non-null list.
|
2008-03-15 00:02:41 +00:00
|
|
|
virtual docstring completionPrefix(Cursor const &) const;
|
2008-02-21 19:42:34 +00:00
|
|
|
/// Do a completion at the cursor position. Return true on success.
|
|
|
|
/// The completion does not contain the prefix. If finished is true, the
|
|
|
|
/// completion is final. If finished is false, completion might only be
|
|
|
|
/// a partial completion.
|
2017-07-03 17:45:58 +00:00
|
|
|
virtual bool insertCompletion(Cursor & /*cur*/,
|
|
|
|
docstring const & /*completion*/, bool /*finished*/)
|
2008-02-21 20:04:17 +00:00
|
|
|
{ return false; }
|
2008-02-21 19:42:34 +00:00
|
|
|
/// Get the completion inset position and size
|
2017-07-03 17:45:58 +00:00
|
|
|
virtual void completionPosAndDim(Cursor const &, int & /*x*/, int & /*y*/,
|
2008-02-21 20:04:17 +00:00
|
|
|
Dimension & /*dim*/) const {}
|
2008-02-21 19:42:34 +00:00
|
|
|
|
2005-04-22 08:57:22 +00:00
|
|
|
/// returns true if the inset can hold an inset of given type
|
2007-10-13 09:04:52 +00:00
|
|
|
virtual bool insetAllowed(InsetCode) const { return false; }
|
2017-07-03 17:45:58 +00:00
|
|
|
/// should this inset use the empty layout by default rather than
|
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
|
|
|
/// the standard layout? (default: only if that is forced.)
|
2008-07-10 17:41:52 +00:00
|
|
|
virtual bool usePlainLayout() const { return forcePlainLayout(); }
|
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
|
|
|
/// if this inset has paragraphs should they be forced to use the
|
|
|
|
/// empty layout?
|
2008-07-10 17:41:52 +00:00
|
|
|
virtual bool forcePlainLayout(idx_type = 0) const { return false; }
|
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
|
|
|
/// if this inset has paragraphs should the user be allowed to
|
|
|
|
/// customize alignment, etc?
|
2010-10-18 14:20:03 +00:00
|
|
|
virtual bool allowParagraphCustomization(idx_type = 0) const
|
|
|
|
{ return true; }
|
2007-04-21 08:43:46 +00:00
|
|
|
/// Is the width forced to some value?
|
|
|
|
virtual bool hasFixedWidth() const { return false; }
|
2015-04-04 09:59:01 +00:00
|
|
|
/// if this inset has paragraphs should they be forced to use a
|
|
|
|
/// local font language switch?
|
|
|
|
virtual bool forceLocalFontSwitch() const { return false; }
|
2019-11-19 12:37:44 +00:00
|
|
|
/// if this inset has paragraphs should they be forced to use a
|
|
|
|
/// font language switch that switches paragraph directions
|
|
|
|
/// (relevant with polyglossia only)?
|
|
|
|
virtual bool forceParDirectionSwitch() const { return false; }
|
2018-01-26 07:38:52 +00:00
|
|
|
/// Does the inset force a specific encoding?
|
|
|
|
virtual Encoding const * forcedEncoding(Encoding const *, Encoding const *) const
|
|
|
|
{ return 0; }
|
|
|
|
|
2005-01-05 20:21:27 +00:00
|
|
|
|
2008-04-23 10:55:51 +00:00
|
|
|
/// Is the content of this inset part of the output document?
|
|
|
|
virtual bool producesOutput() const { return true; }
|
2016-12-27 11:06:54 +00:00
|
|
|
/// Is the content of this inset part of the immediate (visible) text sequence?
|
|
|
|
virtual bool isPartOfTextSequence() const { return producesOutput(); }
|
2008-04-23 10:55:51 +00:00
|
|
|
|
2007-12-25 18:53:38 +00:00
|
|
|
/// \return Tool tip for this inset.
|
2016-06-11 11:57:18 +00:00
|
|
|
/// This default implementation returns an empty string. This can be
|
|
|
|
/// either plain text or Qt html, and formatToolTip will be called
|
|
|
|
/// on it before display in both cases.
|
2007-12-25 18:53:38 +00:00
|
|
|
virtual docstring toolTip(BufferView const & bv, int x, int y) const;
|
2017-07-03 17:45:58 +00:00
|
|
|
|
2010-11-29 21:27:25 +00:00
|
|
|
/// \return Context menu identifier. This function determines
|
|
|
|
/// whose Inset's menu should be shown for the given position.
|
2011-10-29 14:48:55 +00:00
|
|
|
virtual std::string contextMenu(BufferView const & bv, int x, int y) const;
|
2010-11-29 21:27:25 +00:00
|
|
|
|
2007-12-26 12:40:58 +00:00
|
|
|
/// \return Context menu identifier for this inset.
|
|
|
|
/// This default implementation returns an empty string.
|
2011-10-29 14:48:55 +00:00
|
|
|
virtual std::string contextMenuName() const;
|
2010-11-29 21:27:25 +00:00
|
|
|
|
2020-07-04 08:54:20 +00:00
|
|
|
/// Is this inset embedded in a title?
|
|
|
|
virtual bool isInTitle() const { return false; }
|
2009-07-14 20:25:25 +00:00
|
|
|
/// Is this inset's layout defined in the document's textclass?
|
|
|
|
bool undefined() const;
|
2011-03-15 11:26:14 +00:00
|
|
|
/// should this inset be handled like a normal character?
|
|
|
|
/// (a character can be a letter or punctuation)
|
2004-01-26 10:13:15 +00:00
|
|
|
virtual bool isChar() const { return false; }
|
2005-04-22 08:57:22 +00:00
|
|
|
/// is this equivalent to a letter?
|
2011-03-15 11:26:14 +00:00
|
|
|
/// (a letter is a character that is considered part of a word)
|
2004-01-26 10:13:15 +00:00
|
|
|
virtual bool isLetter() const { return false; }
|
2005-04-22 08:57:22 +00:00
|
|
|
/// is this equivalent to a space (which is BTW different from
|
|
|
|
/// a line separator)?
|
2004-01-26 10:13:15 +00:00
|
|
|
virtual bool isSpace() const { return false; }
|
2021-01-10 06:43:34 +00:00
|
|
|
/// returns chars, words if the inset is equivalent to such, otherwise
|
|
|
|
/// (0,0), which should be interpreted as 'false'
|
|
|
|
virtual std::pair<int, int> isWords() const { return std::pair<int,int>(0, 0); }
|
2013-07-18 08:55:52 +00:00
|
|
|
/// does this inset try to use all available space (like \\hfill does)?
|
|
|
|
virtual bool isHfill() const { return false; }
|
2007-05-18 14:32:29 +00:00
|
|
|
|
2020-11-29 23:03:35 +00:00
|
|
|
virtual CtObject getCtObject(OutputParams const &) const;
|
2019-12-28 12:43:17 +00:00
|
|
|
|
2020-06-22 21:11:40 +00:00
|
|
|
enum RowFlags {
|
2007-05-18 14:32:29 +00:00
|
|
|
Inline = 0,
|
2020-06-22 21:11:40 +00:00
|
|
|
// break row before this inset
|
|
|
|
BreakBefore = 1 << 0,
|
|
|
|
// break row after this inset
|
|
|
|
BreakAfter = 1 << 1,
|
2020-06-23 21:34:49 +00:00
|
|
|
// it is possible to break after this inset
|
|
|
|
CanBreakAfter = 1 << 2,
|
2020-06-22 21:11:40 +00:00
|
|
|
// force new (maybe empty) row after this inset
|
2020-06-23 21:34:49 +00:00
|
|
|
RowAfter = 1 << 3,
|
2020-06-22 21:11:40 +00:00
|
|
|
// specify an alignment (left, right) for a display inset
|
|
|
|
// (default is center)
|
2020-06-23 21:34:49 +00:00
|
|
|
AlignLeft = 1 << 4,
|
|
|
|
AlignRight = 1 << 5,
|
2020-06-22 21:11:40 +00:00
|
|
|
// A display inset breaks row at both ends
|
|
|
|
Display = BreakBefore | BreakAfter
|
2007-05-18 14:32:29 +00:00
|
|
|
};
|
2007-05-28 22:27:45 +00:00
|
|
|
|
2020-06-22 21:11:40 +00:00
|
|
|
/// How should this inset be displayed in its row?
|
|
|
|
virtual RowFlags rowFlags() const { return Inline; }
|
2017-04-11 11:03:34 +00:00
|
|
|
/// indentation before this inset (only needed for displayed hull insets with fleqn option)
|
|
|
|
virtual int indent(BufferView const &) const { return 0; }
|
2008-09-13 10:10:01 +00:00
|
|
|
///
|
|
|
|
virtual LyXAlignment contentAlignment() const { return LYX_ALIGN_NONE; }
|
2005-04-22 08:57:22 +00:00
|
|
|
/// should we break lines after this inset?
|
2004-01-26 10:13:15 +00:00
|
|
|
virtual bool isLineSeparator() const { return false; }
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
/// should paragraph indentation be omitted in any case?
|
2008-02-27 20:43:16 +00:00
|
|
|
virtual bool neverIndent() const { return false; }
|
2004-02-02 17:32:56 +00:00
|
|
|
/// dumps content to lyxerr
|
|
|
|
virtual void dump() const;
|
2005-04-22 08:57:22 +00:00
|
|
|
/// write inset in .lyx format
|
2008-02-27 20:43:16 +00:00
|
|
|
virtual void write(std::ostream &) const {}
|
2005-04-22 08:57:22 +00:00
|
|
|
/// read inset in .lyx format
|
2008-02-27 20:43:16 +00:00
|
|
|
virtual void read(Lexer &) {}
|
2007-01-09 19:25:40 +00:00
|
|
|
/** Export the inset to LaTeX.
|
|
|
|
* Don't use a temporary stringstream if the final output is
|
|
|
|
* supposed to go to a file.
|
|
|
|
* \sa Buffer::writeLaTeXSource for the reason.
|
|
|
|
*/
|
2011-02-10 20:02:48 +00:00
|
|
|
virtual void latex(otexstream &, OutputParams const &) const {}
|
2004-01-26 10:13:15 +00:00
|
|
|
/// returns true to override begin and end inset in file
|
|
|
|
virtual bool directWrite() const;
|
|
|
|
///
|
|
|
|
virtual bool allowSpellCheck() const { return false; }
|
|
|
|
|
2020-11-05 10:01:21 +00:00
|
|
|
/// if this insets owns text cells (e.g. InsetText) return cell idx
|
|
|
|
virtual Text * getText(int /*idx*/) const { return 0; }
|
2004-01-26 10:13:15 +00:00
|
|
|
|
|
|
|
/** Adds a LaTeX snippet to the Preview Loader for transformation
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
* into a bitmap image. Does not start the loading process.
|
2004-01-26 10:13:15 +00:00
|
|
|
*
|
|
|
|
* Most insets have no interest in this capability, so the method
|
|
|
|
* defaults to empty.
|
|
|
|
*/
|
2009-11-22 21:29:20 +00:00
|
|
|
virtual void addPreview(DocIterator const &,
|
2009-11-22 20:50:35 +00:00
|
|
|
graphics::PreviewLoader &) const {}
|
2008-09-26 15:53:15 +00:00
|
|
|
|
|
|
|
/** Classifies the unicode characters appearing in a math inset
|
|
|
|
* depending on whether they are to be translated as latex
|
|
|
|
* math/text commands or used as math symbols without translation.
|
|
|
|
*
|
|
|
|
* Only math insets have interest in this classification, so the
|
|
|
|
* method defaults to empty.
|
|
|
|
*/
|
|
|
|
virtual void initUnicodeMath() const {}
|
|
|
|
|
2007-01-07 17:54:26 +00:00
|
|
|
/// Add an entry to the TocList
|
2011-01-12 22:23:27 +00:00
|
|
|
/// Pass a DocIterator that points at the paragraph containing
|
|
|
|
/// the inset
|
2015-09-27 06:05:00 +00:00
|
|
|
///
|
|
|
|
/// \param output_active : is the inset active or is it in an inactive
|
|
|
|
/// branch or a note?
|
|
|
|
///
|
|
|
|
/// \param utype : is the toc being generated for use by the output
|
|
|
|
/// routines?
|
2017-01-13 10:06:48 +00:00
|
|
|
///
|
|
|
|
/// \param tocbackend : where to add the toc information.
|
2015-09-27 06:05:00 +00:00
|
|
|
virtual void addToToc(DocIterator const & /* di */,
|
|
|
|
bool /* output_active */,
|
2017-01-13 10:06:48 +00:00
|
|
|
UpdateType /* utype*/,
|
|
|
|
TocBackend & /* tocbackend */) const {}
|
2010-12-03 20:08:04 +00:00
|
|
|
/// Collect BibTeX information
|
2017-10-18 07:20:31 +00:00
|
|
|
virtual void collectBibKeys(InsetIterator const &, support::FileNameList &) const {}
|
2009-12-04 03:03:38 +00:00
|
|
|
/// Update the counters of this inset and of its contents.
|
|
|
|
/// The boolean indicates whether we are preparing for output, e.g.,
|
|
|
|
/// of XHTML.
|
2020-03-06 12:23:01 +00:00
|
|
|
virtual void updateBuffer(ParIterator const &, UpdateType, bool const) {}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2007-11-17 15:32:12 +00:00
|
|
|
/// Updates the inset's dialog
|
|
|
|
virtual Buffer const * updateFrontend() const;
|
2007-08-14 16:50:51 +00:00
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
public:
|
2004-01-20 14:25:24 +00:00
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
2007-10-13 09:04:52 +00:00
|
|
|
virtual InsetCode lyxCode() const { return NO_CODE; }
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2016-12-12 00:11:26 +00:00
|
|
|
///
|
2004-01-26 10:13:15 +00:00
|
|
|
enum mode_type {UNDECIDED_MODE, TEXT_MODE, MATH_MODE};
|
|
|
|
/// return text or mathmode if that is possible to determine
|
|
|
|
virtual mode_type currentMode() const { return UNDECIDED_MODE; }
|
2009-07-03 00:05:58 +00:00
|
|
|
/// returns whether changing mode during latex export is forbidden
|
|
|
|
virtual bool lockedMode() const { return false; }
|
2010-02-04 19:08:17 +00:00
|
|
|
/// returns whether only ascii chars are allowed during latex export
|
|
|
|
virtual bool asciiOnly() const { return false; }
|
2004-08-14 19:55:00 +00:00
|
|
|
/// returns whether this inset is allowed in other insets of given mode
|
|
|
|
virtual bool allowedIn(mode_type) const { return true; }
|
2020-08-12 14:25:35 +00:00
|
|
|
/// returns whether paragraph breaks can occur inside this inset
|
2020-10-01 07:42:11 +00:00
|
|
|
virtual bool allowMultiPar() const { return false; }
|
2005-12-17 15:03:41 +00:00
|
|
|
/**
|
2021-04-13 08:33:42 +00:00
|
|
|
* The font inside the inset is inherited from the parent for
|
|
|
|
* LaTeX export if this method returns true, as well as on screen.
|
|
|
|
* Otherwise the document default font is used.
|
2011-02-22 19:41:04 +00:00
|
|
|
*/
|
|
|
|
virtual bool inheritFont() const { return true; }
|
|
|
|
/**
|
|
|
|
* If this method returns true all explicitly set font attributes
|
|
|
|
* are reset during editing operations.
|
2014-02-10 21:06:32 +00:00
|
|
|
* For copy/paste operations the language is never changed, since
|
2011-02-22 19:41:04 +00:00
|
|
|
* the language of a given text never changes if the text is
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
* formatted differently, while other font attributes like size may
|
2011-02-22 19:41:04 +00:00
|
|
|
* need to change if the text is copied from one environment to
|
|
|
|
* another one.
|
2014-02-10 21:06:32 +00:00
|
|
|
* If this method returns false no font attribute is reset.
|
|
|
|
* The default implementation returns true if the resetFont layout
|
|
|
|
* tag is set and otherwise the negation of inheritFont(),
|
2011-02-22 19:41:04 +00:00
|
|
|
* since inherited inset font attributes do not need to be changed,
|
|
|
|
* and non-inherited ones need to be set explicitly.
|
2005-12-17 15:03:41 +00:00
|
|
|
*/
|
2014-02-10 21:06:32 +00:00
|
|
|
virtual bool resetFontEdit() const;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
2020-01-11 20:21:34 +00:00
|
|
|
/// does the inset contain changes ?
|
|
|
|
virtual bool isChanged() const { return false; }
|
2006-10-20 09:29:19 +00:00
|
|
|
/// set the change for the entire inset
|
2006-10-20 10:35:07 +00:00
|
|
|
virtual void setChange(Change const &) {}
|
2006-10-24 06:11:45 +00:00
|
|
|
/// accept the changes within the inset
|
2009-12-31 16:34:55 +00:00
|
|
|
virtual void acceptChanges() {}
|
2006-10-24 21:38:47 +00:00
|
|
|
/// reject the changes within the inset
|
2009-12-31 16:34:55 +00:00
|
|
|
virtual void rejectChanges() {}
|
2006-04-05 23:56:29 +00:00
|
|
|
|
2018-04-13 15:46:37 +00:00
|
|
|
///
|
2018-04-30 07:06:15 +00:00
|
|
|
virtual bool needsCProtection(bool const, bool const) const { return false; }
|
2018-04-13 15:46:37 +00:00
|
|
|
|
2005-07-14 17:30:24 +00:00
|
|
|
///
|
2009-12-17 14:09:37 +00:00
|
|
|
virtual ColorCode backgroundColor(PainterInfo const &) const;
|
2007-04-22 21:40:10 +00:00
|
|
|
///
|
2009-07-13 06:46:52 +00:00
|
|
|
virtual ColorCode labelColor() const;
|
2007-04-29 12:32:14 +00:00
|
|
|
|
2017-02-18 18:12:55 +00:00
|
|
|
/// Determine the action of backspace and delete: do we select instead of
|
|
|
|
/// deleting if not already selected?
|
|
|
|
virtual bool confirmDeletion() const { return false; }
|
|
|
|
|
2004-11-23 23:04:52 +00:00
|
|
|
protected:
|
2008-07-23 12:13:41 +00:00
|
|
|
/// Constructors
|
2009-11-08 15:53:21 +00:00
|
|
|
Inset(Buffer * buf) : buffer_(buf) {}
|
2021-07-12 09:55:19 +00:00
|
|
|
Inset(Inset const &) : buffer_(nullptr) {}
|
|
|
|
Inset(Inset const &&) : buffer_(nullptr) {}
|
2007-05-31 12:30:17 +00:00
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
/// replicate ourselves
|
2007-10-18 15:29:51 +00:00
|
|
|
friend class InsetList;
|
2007-08-30 18:03:17 +00:00
|
|
|
friend class MathAtom;
|
|
|
|
virtual Inset * clone() const = 0;
|
|
|
|
|
2005-05-09 17:29:22 +00:00
|
|
|
/** The real dispatcher.
|
2007-04-26 14:56:30 +00:00
|
|
|
* Gets normally called from Cursor::dispatch(). Cursor::dispatch()
|
2005-05-09 17:29:22 +00:00
|
|
|
* assumes the common case of 'LFUN handled, need update'.
|
Run codespell on src/insets
Command was
codespell -w -i 3 -S Makefile.in -L mathed,afe,tthe,ue,fro,uint,larg,alph,te,thes,alle,Claus,pres,pass-thru src/insets/
2020-06-25 21:46:16 +00:00
|
|
|
* This has to be overridden by calling Cursor::undispatched() or
|
2010-07-08 20:04:35 +00:00
|
|
|
* Cursor::noScreenUpdate() if appropriate.
|
2005-05-09 17:29:22 +00:00
|
|
|
* If you need to call the dispatch method of some inset directly
|
|
|
|
* you may have to explicitly request an update at that place. Don't
|
|
|
|
* do it in doDispatch(), since that causes nested updates when
|
2007-04-26 14:56:30 +00:00
|
|
|
* called from Cursor::dispatch(), and these can lead to crashes.
|
2005-05-09 17:29:22 +00:00
|
|
|
* \sa getStatus
|
|
|
|
*/
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2008-02-23 22:32:33 +00:00
|
|
|
|
|
|
|
Buffer * buffer_;
|
2003-02-17 17:12:50 +00:00
|
|
|
};
|
|
|
|
|
2020-06-22 21:11:40 +00:00
|
|
|
|
|
|
|
inline Inset::RowFlags operator|(Inset::RowFlags const d1,
|
|
|
|
Inset::RowFlags const d2)
|
|
|
|
{
|
|
|
|
return static_cast<Inset::RowFlags>(int(d1) | int(d2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline Inset::RowFlags operator&(Inset::RowFlags const d1,
|
|
|
|
Inset::RowFlags const d2)
|
|
|
|
{
|
|
|
|
return static_cast<Inset::RowFlags>(int(d1) & int(d2));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2003-02-17 17:12:50 +00:00
|
|
|
#endif
|