]> git.lyx.org Git - lyx.git/blob - src/insets/insetminipage.C
updates to minipage inset
[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 "lyxtext.h"
21 #include "insets/insettext.h"
22 #include "support/LOstream.h"
23 #include "debug.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(), pos_(center),
59           inner_pos_(inner_center)
60 {
61         setLabel(_("minipage"));
62         LyXFont font(LyXFont::ALL_SANE);
63         font.decSize();
64         font.decSize();
65         font.setColor(LColor::footnote);
66         setLabelFont(font);
67         setAutoCollapse(false);
68         setInsetName("Minipage");
69 }
70
71
72 void InsetMinipage::Write(Buffer const * buf, ostream & os) const 
73 {
74         os << getInsetName() << "\n";
75         InsetCollapsable::Write(buf, os);
76 }
77
78
79 Inset * InsetMinipage::Clone(Buffer const &) const
80 {
81         InsetMinipage * result = new InsetMinipage;
82         result->inset->init(inset);
83         
84         result->collapsed = collapsed;
85         return result;
86 }
87
88
89 string const InsetMinipage::EditMessage() const
90 {
91         return _("Opened Minipage Inset");
92 }
93
94
95 int InsetMinipage::Latex(Buffer const * buf,
96                          ostream & os, bool fragile, bool fp) const
97 {
98         os << "\\begin{minipage}{\\columnwidth}%\n";
99         
100         int i = inset->Latex(buf, os, fragile, fp);
101         os << "\\end{minipage}%\n";
102         
103         return i + 2;
104 }
105
106
107 bool InsetMinipage::InsertInsetAllowed(Inset * in) const
108 {
109         if ((in->LyxCode() == Inset::FLOAT_CODE) ||
110             (in->LyxCode() == Inset::MARGIN_CODE)) {
111                 return false;
112         }
113         return true;
114 }
115
116
117 InsetMinipage::Position InsetMinipage::pos() const 
118 {
119         return pos_;
120 }
121
122
123 void InsetMinipage::pos(InsetMinipage::Position p)
124 {
125         pos_ = p;
126 }
127
128
129 InsetMinipage::InnerPosition InsetMinipage::innerPos() const
130 {
131         return inner_pos_;
132 }
133
134
135 void InsetMinipage::innerPos(InsetMinipage::InnerPosition ip)
136 {
137         inner_pos_ = ip;
138 }
139
140
141 LyXLength const & InsetMinipage::height() const
142 {
143         return height_;
144 }
145
146
147 void InsetMinipage::height(LyXLength const & ll)
148 {
149         height_ = ll;
150 }
151
152
153 LyXLength const & InsetMinipage::width() const
154 {
155         return width_;
156 }
157
158
159 void InsetMinipage::width(LyXLength const & ll)
160 {
161         width_ = ll;
162 }