lyx_mirror/src/insets/InsetCaption.h

100 lines
2.6 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file InsetCaption.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Lars Gullik Bjønnes
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSETCAPTION_H
#define INSETCAPTION_H
#include "InsetText.h"
namespace lyx {
/** A caption inset
*/
class InsetCaption : public InsetText {
public:
///
InsetCaption(Buffer const &);
///
std::string const & type() const { return type_; }
/// return the mandatory argument (LaTeX format) only
int getArgument(odocstream & os, OutputParams const &) const;
/// return the optional argument(s) only
int getOptArg(odocstream & os, OutputParams const &) const;
/// return the caption text
int getCaptionAsPlaintext(odocstream & os, OutputParams const &) const;
/// return the caption text as HTML
docstring getCaptionAsHTML(odocstream & os, OutputParams const &) const;
private:
///
void write(std::ostream & os) const;
///
void read(Lexer & lex);
///
DisplayType display() const { return AlignCenter; }
///
bool neverIndent() const { return true; }
///
InsetCode lyxCode() const { return CAPTION_CODE; }
///
docstring editMessage() const;
///
void cursorPos(BufferView const & bv,
CursorSlice const & sl, bool boundary, int & x, int & y) const;
///
bool descendable() const { return true; }
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
void edit(Cursor & cur, bool front, EntryDirection entry_from);
///
Inset * editXY(Cursor & cur, int x, int y);
///
bool insetAllowed(InsetCode code) const;
///
bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
Rewrite the label numbering code. * buffer_funcs.cpp (updateLabels): new function taking a buffer and a ParIterator as arguments. This one is used to update labels into an InsetText. Cleanup the code to reset depth. Call setLabel for each paragraph, and then updateLabel on each inset it contains. (setCaptionLabels, setCaptions): removed. (setLabel): use Counters::current_float to make caption paragraphs labels. * insets/Inset.h (updateLabels): new virtual method, empty by default; this numbers the inset itself (if relevant) and then all the paragraphs it may contain. * insets/InsetText.cpp (updateLabels): basically calls lyx::updateLabels from buffer_func.cpp. * insets/InsetCaption.cpp (addToToc): use the label constructed by updateLabels. (computeFullLabel): removed. (metrics, plaintext): don't use computeFullLabel. (updateLabels): new method; set the label from Counters::current_float. * insets/InsetWrap.cpp (updateLabels): * insets/InsetFloat.cpp (updateLabel): new method; sets Counters::current_float to the float type. * insets/InsetBranch.cpp (updateLabels): new method; the numbering is reset afterwards if the branch is inactive. (bug 2671) * insets/InsetNote.cpp (updateLabels): new method; the numbering is reset after the underlying InsetText has been numbered. (bug 2671) * insets/InsetTabular.cpp (updateLabels): new method (also handles longtable) * insets/InsetListings.cpp (updateLabels): new method; mimics what is done for Floats (although Listings are not floats technically) * insets/InsetInclude.cpp (getScreenLabel): in the listings case, use the computed label. (updateLabels): new method; that either renumbers the child document or number the current listing. * LyXFunc.cpp (menuNew): do not updateLabels on empty documents (why do we do that at all?) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19482 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-12 21:43:58 +00:00
// Update the counters of this inset and of its contents
void updateLabels(ParIterator const &);
///
int latex(odocstream & os, OutputParams const &) const;
///
int plaintext(odocstream & os, OutputParams const & runparams) const;
///
int docbook(odocstream & os, OutputParams const & runparams) const;
///
docstring xhtml(odocstream & os, OutputParams const & runparams) const;
///
void setCustomLabel(docstring const & label);
///
void addToToc(DocIterator 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
///
virtual bool forcePlainLayout(idx_type = 0) const { return true; }
/// Captions don't accept alignment, spacing, etc.
virtual bool allowParagraphCustomization(idx_type = 0) const { return false; }
///
Inset * clone() const { return new InsetCaption(*this); }
///
mutable docstring full_label_;
///
mutable int labelwidth_;
///
std::string type_;
///
docstring custom_label_;
};
} // namespace lyx
#endif