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 "support/LOstream.h"
28 // Some information about Minipages in LaTeX:
29 // A minipage is a complete miniversion of a page and can contain
30 // its own footnotes, paragraphs, and array, tabular, and multicols
31 // environments. However it cannot contain floats or \marginpar's,
32 // but it can appear inside floats.
34 // The minipage environment is defined like this:
36 // \begin{minipage}[pos][height][inner-pos]{width} <text> \end{minipage}
39 // pos [opt] = is the vertical placement of the box with respect
40 // to the text baseline, [c], [t] and [b].
41 // height [opt] = the height of the box
42 // inner-pos [opt] = the position of the text within the box.
43 // It can be t, c, b or s, if unspecified the value
45 // width = the width of the box
47 // In LyX we should try to support all these parameters, settable in a
49 // In this pop-up diallog it should also be possible to set all margin
50 // values that is usable in the minipage.
51 // With regard to different formats (like DocBook) I guess a minipage
52 // can be used there also. Perhaps not in the latex way, but we do not
53 // have to output "" for minipages.
56 InsetMinipage::InsetMinipage()
59 setLabel(_("minipage"));
60 LyXFont font(LyXFont::ALL_SANE);
63 font.setColor(LColor::footnote);
65 setAutoCollapse(false);
66 setInsetName("Minipage");
70 void InsetMinipage::Write(Buffer const * buf, ostream & os) const
72 os << getInsetName() << "\n";
73 InsetCollapsable::Write(buf, os);
77 Inset * InsetMinipage::Clone() const
79 InsetMinipage * result = new InsetMinipage;
82 result->collapsed = collapsed;
87 char const * InsetMinipage::EditMessage() const
89 return _("Opened Minipage Inset");
93 int InsetMinipage::Latex(Buffer const * buf,
94 ostream & os, bool fragile, bool fp) const
96 os << "\\begin{minipage}{\\columnwidth}%\n";
98 int i = InsetText::Latex(buf, os, fragile, fp);
99 os << "\\end{minipage}%\n";
105 bool InsetMinipage::InsertInset(BufferView * bv, Inset * inset)
107 if (!InsertInsetAllowed(inset))
110 return InsetText::InsertInset(bv, inset);
114 bool InsetMinipage::InsertInsetAllowed(Inset * inset) const
116 if ((inset->LyxCode() == Inset::FLOAT_CODE) ||
117 (inset->LyxCode() == Inset::MARGIN_CODE)) {
124 LyXFont InsetMinipage::GetDrawFont(BufferView * bv,
125 LyXParagraph * p, int pos) const
127 LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
128 fn.decSize().decSize();