lyx_mirror/src/insets/InsetBox.h

158 lines
3.0 KiB
C
Raw Normal View History

// -*- C++ -*-
/**
* \file InsetBox.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Angus Leeming
* \author Martin Vermeer
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSETBOX_H
#define INSETBOX_H
#include "InsetCollapsable.h"
#include "Length.h"
#include "MailInset.h"
namespace lyx {
class InsetBoxParams {
public:
///
InsetBoxParams(std::string const &);
///
void write(std::ostream & os) const;
///
void read(Lexer & lex);
///
std::string type;
/// Use a parbox (true) or minipage (false)
bool use_parbox;
/// Do we have an inner parbox or minipage to format paragraphs to
/// columnwidth?
bool inner_box;
///
Length width;
/// "special" widths, see usrguide.dvi <20>3.5
std::string special;
///
char pos;
///
char hor_pos;
///
char inner_pos;
///
Length height;
///
std::string height_special;
};
/** The fbox/fancybox inset
*/
class InsetBox : public InsetCollapsable {
public:
///
InsetBox(Buffer const &, std::string const &);
///
~InsetBox();
///
docstring editMessage() const;
///
InsetCode lyxCode() const { return BOX_CODE; }
///
docstring name() const;
///
void write(std::ostream &) const;
///
void read(Lexer & lex);
///
void setButtonLabel();
///
void metrics(MetricsInfo &, Dimension &) const;
/// show the Box dialog
bool showInsetDialog(BufferView * bv) const;
///
DisplayType display() const { return Inline; }
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
//FIXME Is this the one we want? or is it:
//allowParagraphCustomization(idx_type)?
///
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 forceEmptyLayout() const;
///
bool neverIndent() const { return true; }
///
bool noFontChange() const { return true; }
///
bool isMacroScope() const;
///
int latex(odocstream &, OutputParams const &) const;
///
int plaintext(odocstream &, OutputParams const &) const;
///
int docbook(odocstream &, OutputParams const &) const;
///
void validate(LaTeXFeatures &) const;
///
InsetBoxParams const & params() const { return params_; }
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
enum BoxType {
Frameless,
Boxed,
Framed,
ovalbox,
Ovalbox,
Shadowbox,
Shaded,
Doublebox
};
protected:
InsetBox(InsetBox const &);
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
/// Is the width forced to some value?
virtual bool hasFixedWidth() const;
private:
friend class InsetBoxParams;
virtual Inset * clone() const;
/// used by the constructors
void init();
///
InsetBoxParams params_;
};
class InsetBoxMailer : public MailInset {
public:
///
InsetBoxMailer(InsetBox & inset);
///
virtual Inset & inset() const { return inset_; }
///
virtual std::string const & name() const { return name_; }
///
virtual std::string const inset2string(Buffer const &) const;
///
static std::string const params2string(InsetBoxParams const &);
///
static void string2params(std::string const &, InsetBoxParams &);
private:
///
static std::string const name_;
///
InsetBox & inset_;
};
} // namespace lyx
#endif // INSET_BOX_H