2000-06-28 13:35:52 +00:00
|
|
|
|
/* This file is part of
|
|
|
|
|
* ======================================================
|
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
*
|
|
|
|
|
* Copyright 1998 The LyX Team.
|
|
|
|
|
*
|
|
|
|
|
*======================================================*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "insetminipage.h"
|
|
|
|
|
#include "gettext.h"
|
|
|
|
|
#include "lyxfont.h"
|
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "Painter.h"
|
|
|
|
|
#include "lyxtext.h"
|
2000-07-04 11:30:07 +00:00
|
|
|
|
#include "insets/insettext.h"
|
2000-06-28 13:35:52 +00:00
|
|
|
|
#include "support/LOstream.h"
|
|
|
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Some information about Minipages in LaTeX:
|
|
|
|
|
// A minipage is a complete miniversion of a page and can contain
|
|
|
|
|
// its own footnotes, paragraphs, and array, tabular, and multicols
|
|
|
|
|
// environments. However it cannot contain floats or \marginpar's,
|
|
|
|
|
// but it can appear inside floats.
|
|
|
|
|
//
|
|
|
|
|
// The minipage environment is defined like this:
|
|
|
|
|
//
|
|
|
|
|
// \begin{minipage}[pos][height][inner-pos]{width} <text> \end{minipage}
|
|
|
|
|
//
|
|
|
|
|
// Where:
|
|
|
|
|
// pos [opt] = is the vertical placement of the box with respect
|
|
|
|
|
// to the text baseline, [c], [t] and [b].
|
|
|
|
|
// height [opt] = the height of the box
|
|
|
|
|
// inner-pos [opt] =<3D>the position of the text within the box.
|
|
|
|
|
// It can be t, c, b or s, if unspecified the value
|
|
|
|
|
// of pos is used.
|
|
|
|
|
// width = the width of the box
|
|
|
|
|
//
|
|
|
|
|
// In LyX we should try to support all these parameters, settable in a
|
|
|
|
|
// pop-up dialog.
|
|
|
|
|
// In this pop-up diallog it should also be possible to set all margin
|
|
|
|
|
// values that is usable in the minipage.
|
|
|
|
|
// With regard to different formats (like DocBook) I guess a minipage
|
|
|
|
|
// can be used there also. Perhaps not in the latex way, but we do not
|
|
|
|
|
// have to output "" for minipages.
|
|
|
|
|
// (Lgb)
|
|
|
|
|
|
|
|
|
|
InsetMinipage::InsetMinipage()
|
|
|
|
|
: InsetCollapsable()
|
|
|
|
|
{
|
|
|
|
|
setLabel(_("minipage"));
|
|
|
|
|
LyXFont font(LyXFont::ALL_SANE);
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.decSize();
|
|
|
|
|
font.setColor(LColor::footnote);
|
|
|
|
|
setLabelFont(font);
|
|
|
|
|
setAutoCollapse(false);
|
|
|
|
|
setInsetName("Minipage");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMinipage::Write(Buffer const * buf, ostream & os) const
|
|
|
|
|
{
|
|
|
|
|
os << getInsetName() << "\n";
|
|
|
|
|
InsetCollapsable::Write(buf, os);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Inset * InsetMinipage::Clone() const
|
|
|
|
|
{
|
|
|
|
|
InsetMinipage * result = new InsetMinipage;
|
2000-07-04 11:30:07 +00:00
|
|
|
|
result->inset->init(inset);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
|
|
|
|
result->collapsed = collapsed;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char const * InsetMinipage::EditMessage() const
|
|
|
|
|
{
|
|
|
|
|
return _("Opened Minipage Inset");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int InsetMinipage::Latex(Buffer const * buf,
|
|
|
|
|
ostream & os, bool fragile, bool fp) const
|
|
|
|
|
{
|
|
|
|
|
os << "\\begin{minipage}{\\columnwidth}%\n";
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
|
int i = inset->Latex(buf, os, fragile, fp);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
os << "\\end{minipage}%\n";
|
|
|
|
|
|
|
|
|
|
return i + 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
|
bool InsetMinipage::InsertInset(BufferView * bv, Inset * in)
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2000-07-04 11:30:07 +00:00
|
|
|
|
if (!InsertInsetAllowed(in))
|
2000-06-28 13:35:52 +00:00
|
|
|
|
return false;
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
|
return inset->InsertInset(bv, in);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
|
bool InsetMinipage::InsertInsetAllowed(Inset * in) const
|
2000-06-28 13:35:52 +00:00
|
|
|
|
{
|
2000-07-04 11:30:07 +00:00
|
|
|
|
if ((in->LyxCode() == Inset::FLOAT_CODE) ||
|
|
|
|
|
(in->LyxCode() == Inset::MARGIN_CODE)) {
|
2000-06-28 13:35:52 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 11:30:07 +00:00
|
|
|
|
#if 0
|
2000-06-28 13:35:52 +00:00
|
|
|
|
LyXFont InsetMinipage::GetDrawFont(BufferView * bv,
|
|
|
|
|
LyXParagraph * p, int pos) const
|
|
|
|
|
{
|
|
|
|
|
LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
|
|
|
|
|
fn.decSize().decSize();
|
|
|
|
|
return fn;
|
|
|
|
|
}
|
2000-07-04 11:30:07 +00:00
|
|
|
|
#endif
|