]> git.lyx.org Git - lyx.git/blob - src/insets/insetminipage.C
Some more changes for updating text-insets.
[lyx.git] / src / insets / insetminipage.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1998 The LyX Team.
7  *
8  *======================================================*/
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include "insetminipage.h"
17 #include "gettext.h"
18 #include "lyxfont.h"
19 #include "BufferView.h"
20 #include "Painter.h"
21 #include "lyxtext.h"
22 #include "insets/insettext.h"
23 #include "support/LOstream.h"
24
25 using std::ostream;
26 using std::endl;
27
28
29 // Some information about Minipages in LaTeX:
30 // A minipage is a complete miniversion of a page and can contain
31 // its own footnotes, paragraphs, and array, tabular, and multicols
32 // environments. However it cannot contain floats or \marginpar's,
33 // but it can appear inside floats.
34 //
35 // The minipage environment is defined like this:
36 //
37 // \begin{minipage}[pos][height][inner-pos]{width} <text> \end{minipage}
38 //
39 // Where:
40 //     pos [opt] = is the vertical placement of the box with respect
41 //                 to the text baseline, [c], [t] and [b].
42 //     height [opt] = the height of the box
43 //     inner-pos [opt] = the position of the text within the box.
44 //                 It can be t, c, b or s, if unspecified the value
45 //                 of pos is used.
46 //     width = the width of the box
47 //
48 // In LyX we should try to support all these parameters, settable in a
49 // pop-up dialog.
50 // In this pop-up diallog it should also be possible to set all margin
51 // values that is usable in the minipage.
52 // With regard to different formats (like DocBook) I guess a minipage
53 // can be used there also. Perhaps not in the latex way, but we do not
54 // have to output "" for minipages.
55 // (Lgb)
56
57 InsetMinipage::InsetMinipage()
58         : InsetCollapsable()
59 {
60         setLabel(_("minipage"));
61         LyXFont font(LyXFont::ALL_SANE);
62         font.decSize();
63         font.decSize();
64         font.setColor(LColor::footnote);
65         setLabelFont(font);
66         setAutoCollapse(false);
67         setInsetName("Minipage");
68 }
69
70
71 void InsetMinipage::Write(Buffer const * buf, ostream & os) const 
72 {
73         os << getInsetName() << "\n";
74         InsetCollapsable::Write(buf, os);
75 }
76
77
78 Inset * InsetMinipage::Clone() const
79 {
80         InsetMinipage * result = new InsetMinipage;
81         result->inset->init(inset);
82         
83         result->collapsed = collapsed;
84         return result;
85 }
86
87
88 char const * InsetMinipage::EditMessage() const
89 {
90         return _("Opened Minipage Inset");
91 }
92
93
94 int InsetMinipage::Latex(Buffer const * buf,
95                          ostream & os, bool fragile, bool fp) const
96 {
97         os << "\\begin{minipage}{\\columnwidth}%\n";
98         
99         int i = inset->Latex(buf, os, fragile, fp);
100         os << "\\end{minipage}%\n";
101         
102         return i + 2;
103 }
104
105
106 bool InsetMinipage::InsertInset(BufferView * bv, Inset * in)
107 {
108         if (!InsertInsetAllowed(in))
109                 return false;
110         
111         return inset->InsertInset(bv, in);
112 }
113
114
115 bool InsetMinipage::InsertInsetAllowed(Inset * in) const
116 {
117         if ((in->LyxCode() == Inset::FLOAT_CODE) ||
118             (in->LyxCode() == Inset::MARGIN_CODE)) {
119                 return false;
120         }
121         return true;
122 }
123
124 #if 0
125 LyXFont InsetMinipage::GetDrawFont(BufferView * bv,
126                                    LyXParagraph * p, int pos) const
127 {
128         LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
129         fn.decSize().decSize();
130         return fn;
131 }
132 #endif