2000-07-17 18:27:53 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetCaption.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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Lars Gullik Bjønnes
|
2000-07-17 18:27:53 +00:00
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-07-17 18:27:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSETCAPTION_H
|
|
|
|
#define INSETCAPTION_H
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetText.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2000-07-17 18:27:53 +00:00
|
|
|
/** A caption inset
|
|
|
|
*/
|
|
|
|
class InsetCaption : public InsetText {
|
|
|
|
public:
|
2001-03-11 03:20:44 +00:00
|
|
|
///
|
2012-12-30 17:29:02 +00:00
|
|
|
InsetCaption(Buffer *, std::string const &);
|
2000-07-18 17:45:27 +00:00
|
|
|
///
|
2013-02-04 07:38:50 +00:00
|
|
|
std::string const & floattype() const { return floattype_; }
|
|
|
|
///
|
2011-03-28 22:33:04 +00:00
|
|
|
docstring layoutName() const;
|
2008-03-05 00:21:05 +00:00
|
|
|
/// return the mandatory argument (LaTeX format) only
|
2011-02-10 20:02:48 +00:00
|
|
|
void getArgument(otexstream & os, OutputParams const &) const;
|
2008-04-10 09:22:49 +00:00
|
|
|
/// return the caption text
|
2009-06-19 13:50:19 +00:00
|
|
|
int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
|
2009-06-19 12:49:08 +00:00
|
|
|
/// return the caption text as HTML
|
2009-11-30 17:27:10 +00:00
|
|
|
docstring getCaptionAsHTML(XHTMLStream & os, OutputParams const &) const;
|
2012-12-30 17:29:02 +00:00
|
|
|
///
|
|
|
|
std::string contextMenuName() const;
|
2008-03-05 00:21:05 +00:00
|
|
|
private:
|
2007-01-30 13:23:21 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
void write(std::ostream & os) const;
|
2000-07-18 17:45:27 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
DisplayType display() const { return AlignCenter; }
|
2001-03-11 03:20:44 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
bool neverIndent() const { return true; }
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
2015-06-18 12:17:18 +00:00
|
|
|
bool forceLocalFontSwitch() const { return true; }
|
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
InsetCode lyxCode() const { return CAPTION_CODE; }
|
2001-03-11 03:20:44 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
void cursorPos(BufferView const & bv,
|
2006-10-17 16:23:27 +00:00
|
|
|
CursorSlice const & sl, bool boundary, int & x, int & y) const;
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
2009-10-24 00:02:41 +00:00
|
|
|
bool descendable(BufferView const &) const { return true; }
|
2006-05-28 17:02:57 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2010-12-01 00:32:30 +00:00
|
|
|
///
|
|
|
|
void drawBackground(PainterInfo & pi, int x, int y) const;
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-03-11 03:20:44 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
void edit(Cursor & cur, bool front, EntryDirection entry_from);
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
Inset * editXY(Cursor & cur, int x, int y);
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
2007-10-13 09:04:52 +00:00
|
|
|
bool insetAllowed(InsetCode code) const;
|
2007-02-02 13:55:14 +00:00
|
|
|
///
|
2012-12-30 17:29:02 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd);
|
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
2007-08-12 21:43:58 +00:00
|
|
|
// Update the counters of this inset and of its contents
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer(ParIterator const &, UpdateType);
|
2007-01-30 13:23:21 +00:00
|
|
|
///
|
2011-02-10 20:02:48 +00:00
|
|
|
void latex(otexstream & os, OutputParams const &) const;
|
2001-03-11 03:20:44 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
|
|
|
size_t max_length = INT_MAX) const;
|
2001-03-11 03:20:44 +00:00
|
|
|
///
|
2008-02-27 20:43:16 +00:00
|
|
|
int docbook(odocstream & os, OutputParams const & runparams) const;
|
2009-06-19 18:32:50 +00:00
|
|
|
///
|
2009-11-30 17:27:10 +00:00
|
|
|
docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const;
|
2007-03-15 11:47:02 +00:00
|
|
|
///
|
2007-02-01 12:45:14 +00:00
|
|
|
void setCustomLabel(docstring const & label);
|
2013-03-24 13:34:00 +00:00
|
|
|
/// \param output_active : is the toc being generated for use by the
|
|
|
|
/// output routines?
|
2013-03-08 21:18:26 +00:00
|
|
|
void addToToc(DocIterator const & di, bool output_active) const;
|
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
|
|
|
///
|
2008-07-10 17:41:52 +00:00
|
|
|
virtual bool forcePlainLayout(idx_type = 0) const { return true; }
|
2007-04-17 03:46:55 +00:00
|
|
|
/// Captions don't accept alignment, spacing, etc.
|
2008-03-19 16:21:33 +00:00
|
|
|
virtual bool allowParagraphCustomization(idx_type = 0) const { return false; }
|
2005-02-23 12:01:50 +00:00
|
|
|
///
|
2008-03-05 00:21:05 +00:00
|
|
|
Inset * clone() const { return new InsetCaption(*this); }
|
|
|
|
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
2007-01-30 13:23:21 +00:00
|
|
|
mutable docstring full_label_;
|
2006-05-05 05:51:51 +00:00
|
|
|
///
|
|
|
|
mutable int labelwidth_;
|
|
|
|
///
|
2012-12-30 17:29:02 +00:00
|
|
|
std::string floattype_;
|
|
|
|
///
|
2007-02-01 12:45:14 +00:00
|
|
|
std::string type_;
|
|
|
|
///
|
|
|
|
docstring custom_label_;
|
2000-07-17 18:27:53 +00:00
|
|
|
};
|
|
|
|
|
2001-03-11 03:20:44 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2000-07-17 18:27:53 +00:00
|
|
|
#endif
|