1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1998 The LyX Team.
8 *======================================================*/
13 #pragma implementation
16 #include "insetminipage.h"
19 #include "BufferView.h"
22 #include "insets/insettext.h"
23 #include "support/LOstream.h"
30 // Some information about Minipages in LaTeX:
31 // A minipage is a complete miniversion of a page and can contain
32 // its own footnotes, paragraphs, and array, tabular, and multicols
33 // environments. However it cannot contain floats or \marginpar's,
34 // but it can appear inside floats.
36 // The minipage environment is defined like this:
38 // \begin{minipage}[pos][height][inner-pos]{width} <text> \end{minipage}
41 // pos [opt] = is the vertical placement of the box with respect
42 // to the text baseline, [c], [t] and [b].
43 // height [opt] = the height of the box
44 // inner-pos [opt] = the position of the text within the box.
45 // It can be t, c, b or s, if unspecified the value
47 // width = the width of the box
49 // In LyX we should try to support all these parameters, settable in a
51 // In this pop-up diallog it should also be possible to set all margin
52 // values that is usable in the minipage.
53 // With regard to different formats (like DocBook) I guess a minipage
54 // can be used there also. Perhaps not in the latex way, but we do not
55 // have to output "" for minipages.
58 InsetMinipage::InsetMinipage()
61 setLabel(_("minipage"));
62 LyXFont font(LyXFont::ALL_SANE);
65 font.setColor(LColor::footnote);
67 setAutoCollapse(false);
68 setInsetName("Minipage");
72 void InsetMinipage::Write(Buffer const * buf, ostream & os) const
74 os << getInsetName() << "\n";
75 InsetCollapsable::Write(buf, os);
79 Inset * InsetMinipage::Clone() const
81 InsetMinipage * result = new InsetMinipage;
82 result->inset->init(inset);
84 result->collapsed = collapsed;
89 char const * InsetMinipage::EditMessage() const
91 return _("Opened Minipage Inset");
95 int InsetMinipage::Latex(Buffer const * buf,
96 ostream & os, bool fragile, bool fp) const
98 os << "\\begin{minipage}{\\columnwidth}%\n";
100 int i = inset->Latex(buf, os, fragile, fp);
101 os << "\\end{minipage}%\n";
107 bool InsetMinipage::InsertInsetAllowed(Inset * in) const
109 if ((in->LyxCode() == Inset::FLOAT_CODE) ||
110 (in->LyxCode() == Inset::MARGIN_CODE)) {
118 LyXFont InsetMinipage::GetDrawFont(BufferView * bv,
119 LyXParagraph * p, int pos) const
121 LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
122 fn.decSize().decSize();