#include "InsetLayout.h"
#include "LayoutEnums.h"
#include "OutputEnums.h"
+#include "OutputParams.h"
#include "support/strfwd.h"
#include "support/types.h"
+#include "support/FileNameList.h"
#include <climits>
class CursorSlice;
class Dimension;
class DocIterator;
+class Encoding;
class FuncRequest;
class FuncStatus;
class InsetArgument;
-class InsetCollapsable;
+class InsetCollapsible;
class InsetCommand;
+class InsetGraphics;
class InsetIterator;
class InsetLayout;
class InsetList;
class Text;
class TocBackend;
class TocList;
-class XHTMLStream;
+class XMLStream;
class otexstream;
namespace graphics { class PreviewLoader; }
/// initialize view for this inset.
/**
* This is typically used after this inset is created interactively.
- * Intented purpose is to sanitize internal state with regard to current
+ * Intended purpose is to sanitize internal state with regard to current
* Buffer.
**/
virtual void initView() {}
virtual InsetText * asInsetText() { return 0; }
/// is this inset based on the InsetText class?
virtual InsetText const * asInsetText() const { return 0; }
- /// is this inset based on the InsetCollapsable class?
- virtual InsetCollapsable * asInsetCollapsable() { return 0; }
- /// is this inset based on the InsetCollapsable class?
- virtual InsetCollapsable const * asInsetCollapsable() const { return 0; }
+ /// is this inset based on the InsetCollapsible class?
+ virtual InsetCollapsible * asInsetCollapsible() { return 0; }
+ /// is this inset based on the InsetCollapsible class?
+ virtual InsetCollapsible const * asInsetCollapsible() const { return 0; }
/// is this inset based on the InsetTabular class?
virtual InsetTabular * asInsetTabular() { return 0; }
/// is this inset based on the InsetTabular class?
virtual InsetCommand const * asInsetCommand() const { return 0; }
/// is this inset based on the InsetArgument class?
virtual InsetArgument const * asInsetArgument() const { return nullptr; }
+ /// is this inset based on the InsetGraphics class?
+ virtual InsetGraphics * asInsetGraphics() { return 0; }
+ /// is this inset based on the InsetGraphics class?
+ virtual InsetGraphics const * asInsetGraphics() const { return 0; }
/// the real dispatcher
void dispatch(Cursor & cur, FuncRequest & cmd);
/// https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg199001.html
virtual Inset * editXY(Cursor & cur, int x, int y);
+ /// 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); }
+
/// compute the size of the object returned in dim
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
/// draw inset and update (xo, yo)-cache
virtual bool showInsetDialog(BufferView *) const;
/// draw two angular markers
- void drawMarkers(PainterInfo & pi, int x, int y) const;
- /// draw four angular markers
- void drawMarkers2(PainterInfo & pi, int x, int y) const;
+ virtual void drawMarkers(PainterInfo & pi, int x, int y) const;
/// add space for markers
void metricsMarkers(Dimension & dim, int framesize = 1) const;
/// add space for markers
/// Don't eliminate empty paragraphs
virtual bool allowEmpty() const;
/// Force inset into LTR environment if surroundings are RTL
- virtual bool forceLTR() const;
+ virtual bool forceLTR(OutputParams const &) const;
/// whether to include this inset in the strings generated for the TOC
virtual bool isInToc() const;
virtual int plaintext(odocstringstream &, OutputParams const &,
size_t max_length = INT_MAX) const = 0;
/// docbook output
- virtual int docbook(odocstream & os, OutputParams const &) const;
+ virtual void docbook(XMLStream &, OutputParams const &) const;
/// XHTML output
- /// the inset is expected to write XHTML to the XHTMLStream
+ /// the inset is expected to write XHTML to the XMLStream
/// \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.
- virtual docstring xhtml(XHTMLStream & xs, OutputParams const &) const;
+ virtual docstring xhtml(XMLStream &, OutputParams const &) const;
/// Writes a string representation of the inset to the odocstream.
/// This one should be called when you want the whole contents of
size_t const maxlen = TOC_ENTRY_LENGTH,
bool const shorten = true) const;
+ /// 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; }
/// can the contents of the inset be edited on screen ?
- // true for InsetCollapsables (not ButtonOnly) (not InsetInfo), InsetText
+ // equivalent to isActive except for closed InsetCollapsible
virtual bool editable() const;
/// has the Inset settings that can be modified in a dialog ?
virtual bool hasSettings() const;
/// can we go further down on mouse click?
- // true for InsetCaption, InsetCollapsables (not ButtonOnly), InsetTabular
+ /// true for InsetCaption, InsetCollapsibles (not ButtonOnly), InsetTabular
virtual bool descendable(BufferView const &) const { return false; }
- /// is this an inset that can be moved into?
- /// FIXME: merge with editable()
- // true for InsetTabular & InsetText
- virtual bool isActive() const { return nargs() > 0; }
/// can we click at the specified position ?
virtual bool clickable(BufferView const &, int, int) const { return false; }
/// Move one cell backwards
/// if this inset has paragraphs should they be forced to use a
/// local font language switch?
virtual bool forceLocalFontSwitch() const { return false; }
+ /// 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; }
+ /// Does the inset force a specific encoding?
+ virtual Encoding const * forcedEncoding(Encoding const *, Encoding const *) const
+ { return 0; }
+
/// Is the content of this inset part of the output document?
virtual bool producesOutput() const { return true; }
virtual InsetLayout const & getLayout() const;
///
virtual bool isPassThru() const { return getLayout().isPassThru(); }
+ /// Is this inset embedded in a title?
+ virtual bool isInTitle() const { return false; }
/// Is this inset's layout defined in the document's textclass?
bool undefined() const;
/// should this inset be handled like a normal character?
/// does this inset try to use all available space (like \\hfill does)?
virtual bool isHfill() const { return false; }
- enum DisplayType {
+ virtual OutputParams::CtObject CtObject(OutputParams const &) const { return OutputParams::CT_NORMAL; }
+
+ enum RowFlags {
Inline = 0,
- AlignLeft,
- AlignCenter,
- AlignRight
+ // break row before this inset
+ BreakBefore = 1 << 0,
+ // break row after this inset
+ BreakAfter = 1 << 1,
+ // it is possible to break after this inset
+ CanBreakAfter = 1 << 2,
+ // force new (maybe empty) row after this inset
+ RowAfter = 1 << 3,
+ // specify an alignment (left, right) for a display inset
+ // (default is center)
+ AlignLeft = 1 << 4,
+ AlignRight = 1 << 5,
+ // A display inset breaks row at both ends
+ Display = BreakBefore | BreakAfter
};
- /// should we have a non-filled line before this inset?
- virtual DisplayType display() const { return Inline; }
+ /// How should this inset be displayed in its row?
+ virtual RowFlags rowFlags() const { return Inline; }
/// indentation before this inset (only needed for displayed hull insets with fleqn option)
virtual int indent(BufferView const &) const { return 0; }
///
virtual LyXAlignment contentAlignment() const { return LYX_ALIGN_NONE; }
/// should we break lines after this inset?
virtual bool isLineSeparator() const { return false; }
- /// should paragraph indendation be ommitted in any case?
+ /// should paragraph indentation be omitted in any case?
virtual bool neverIndent() const { return false; }
/// dumps content to lyxerr
virtual void dump() const;
virtual Text * getText(int /*num*/) const { return 0; }
/** Adds a LaTeX snippet to the Preview Loader for transformation
- * into a bitmap image. Does not start the laoding process.
+ * into a bitmap image. Does not start the loading process.
*
* Most insets have no interest in this capability, so the method
* defaults to empty.
UpdateType /* utype*/,
TocBackend & /* tocbackend */) const {}
/// Collect BibTeX information
- virtual void collectBibKeys(InsetIterator const &) const {}
+ virtual void collectBibKeys(InsetIterator const &, support::FileNameList &) const {}
/// Update the counters of this inset and of its contents.
/// The boolean indicates whether we are preparing for output, e.g.,
/// of XHTML.
- virtual void updateBuffer(ParIterator const &, UpdateType) {}
+ virtual void updateBuffer(ParIterator const &, UpdateType, bool const) {}
/// Updates the inset's dialog
virtual Buffer const * updateFrontend() const;
* are reset during editing operations.
* For copy/paste operations the language is never changed, since
* the language of a given text never changes if the text is
- * formatted differently, while other font attribues like size may
+ * formatted differently, while other font attributes like size may
* need to change if the text is copied from one environment to
* another one.
* If this method returns false no font attribute is reset.
*/
virtual bool resetFontEdit() const;
+ /// does the inset contain changes ?
+ virtual bool isChanged() const { return false; }
/// set the change for the entire inset
virtual void setChange(Change const &) {}
/// accept the changes within the inset
/// reject the changes within the inset
virtual void rejectChanges() {}
+ ///
+ virtual bool needsCProtection(bool const, bool const) const { return false; }
+
///
virtual ColorCode backgroundColor(PainterInfo const &) const;
///
virtual ColorCode labelColor() const;
- //
- enum { TEXT_TO_INSET_OFFSET = 4 };
/// Determine the action of backspace and delete: do we select instead of
/// deleting if not already selected?
/** The real dispatcher.
* Gets normally called from Cursor::dispatch(). Cursor::dispatch()
* assumes the common case of 'LFUN handled, need update'.
- * This has to be overriden by calling Cursor::undispatched() or
+ * This has to be overridden by calling Cursor::undispatched() or
* Cursor::noScreenUpdate() if appropriate.
* 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
Buffer * buffer_;
};
+
+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));
+}
+
+
} // namespace lyx
#endif