]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBox.cpp
Amend f441590c
[lyx.git] / src / insets / InsetBox.cpp
1 /**
2  * \file InsetBox.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  * \author Martin Vermeer
8  * \author Jürgen Spitzmüller
9  * \author Uwe Stöhr
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "InsetBox.h"
17
18 #include "Buffer.h"
19 #include "BufferParams.h"
20 #include "BufferView.h"
21 #include "ColorSet.h"
22 #include "Cursor.h"
23 #include "DispatchResult.h"
24 #include "FuncStatus.h"
25 #include "FuncRequest.h"
26 #include "LaTeXFeatures.h"
27 #include "Lexer.h"
28 #include "MetricsInfo.h"
29 #include "output_xhtml.h"
30 #include "TextClass.h"
31
32 #include "support/debug.h"
33 #include "support/docstream.h"
34 #include "support/gettext.h"
35 #include "support/lstrings.h"
36 #include "support/Translator.h"
37
38 #include "frontends/Application.h"
39
40 #include <sstream>
41
42 using namespace std;
43 using namespace lyx::support;
44
45 namespace lyx {
46
47 namespace {
48
49 typedef Translator<string, InsetBox::BoxType> BoxTranslator;
50 typedef Translator<docstring, InsetBox::BoxType> BoxTranslatorLoc;
51
52 BoxTranslator initBoxtranslator()
53 {
54         BoxTranslator translator("Boxed", InsetBox::Boxed);
55         translator.addPair("Frameless", InsetBox::Frameless);
56         translator.addPair("Framed", InsetBox::Framed);
57         translator.addPair("ovalbox", InsetBox::ovalbox);
58         translator.addPair("Ovalbox", InsetBox::Ovalbox);
59         translator.addPair("Shadowbox", InsetBox::Shadowbox);
60         translator.addPair("Shaded", InsetBox::Shaded);
61         translator.addPair("Doublebox",InsetBox::Doublebox);
62         return translator;
63 }
64
65
66 BoxTranslatorLoc initBoxtranslatorLoc()
67 {
68         BoxTranslatorLoc translator(_("simple frame"), InsetBox::Boxed);
69         translator.addPair(_("frameless"), InsetBox::Frameless);
70         translator.addPair(_("simple frame, page breaks"), InsetBox::Framed);
71         translator.addPair(_("oval, thin"), InsetBox::ovalbox);
72         translator.addPair(_("oval, thick"), InsetBox::Ovalbox);
73         translator.addPair(_("drop shadow"), InsetBox::Shadowbox);
74         translator.addPair(_("shaded background"), InsetBox::Shaded);
75         translator.addPair(_("double frame"), InsetBox::Doublebox);
76         return translator;
77 }
78
79
80 BoxTranslator const & boxtranslator()
81 {
82         static BoxTranslator const translator = initBoxtranslator();
83         return translator;
84 }
85
86
87 BoxTranslatorLoc const & boxtranslator_loc()
88 {
89         static BoxTranslatorLoc const translator = initBoxtranslatorLoc();
90         return translator;
91 }
92
93 } // namespace anon
94
95
96 /////////////////////////////////////////////////////////////////////////
97 //
98 // InsetBox
99 //
100 /////////////////////////////////////////////////////////////////////////
101
102 InsetBox::InsetBox(Buffer * buffer, string const & label)
103         : InsetCollapsable(buffer), params_(label)
104 {}
105
106
107 docstring InsetBox::layoutName() const
108 {
109         // FIXME: UNICODE
110         return from_ascii("Box:" + params_.type);
111 }
112
113
114 void InsetBox::write(ostream & os) const
115 {
116         params_.write(os);
117         InsetCollapsable::write(os);
118 }
119
120
121 void InsetBox::read(Lexer & lex)
122 {
123         params_.read(lex);
124         InsetCollapsable::read(lex);
125 }
126
127
128 void InsetBox::setButtonLabel()
129 {
130         BoxType const btype = boxtranslator().find(params_.type);
131
132         docstring const type = _("Box");
133
134         docstring inner;
135         if (params_.inner_box) {
136                 if (params_.use_parbox)
137                         inner = _("Parbox");
138                 else if (params_.use_makebox)
139                         inner = _("Makebox");
140                 else
141                         inner = _("Minipage");
142         }
143
144         docstring frame;
145         if (btype != Frameless)
146                 frame = boxtranslator_loc().find(btype);
147
148         docstring label;
149         if (inner.empty() && frame.empty())
150                 label = type;
151         else if (inner.empty())
152                 label = bformat(_("%1$s (%2$s)"),
153                         type, frame);
154         else if (frame.empty())
155                 label = bformat(_("%1$s (%2$s)"),
156                         type, inner);
157         else
158                 label = bformat(_("%1$s (%2$s, %3$s)"),
159                         type, inner, frame);
160         setLabel(label);
161
162         // set the frame color for the inset if the type is Boxed
163         if (btype == Boxed)
164                 setFrameColor(lcolor.getFromLaTeXName(params_.framecolor));
165         else
166                 setFrameColor(Color_collapsableframe);
167 }
168
169
170 bool InsetBox::hasFixedWidth() const
171 {
172         return !params_.width.empty();
173 }
174
175
176 bool InsetBox::allowMultiPar() const
177 {
178         return (params_.inner_box && !params_.use_makebox)
179                 || params_.type == "Shaded" || params_.type == "Framed";
180 }
181
182
183 void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
184 {
185         // back up textwidth.
186         int textwidth_backup = m.base.textwidth;
187         if (hasFixedWidth())
188                 m.base.textwidth = params_.width.inPixels(m.base);
189         InsetCollapsable::metrics(m, dim);
190         // retore textwidth.
191         m.base.textwidth = textwidth_backup;
192 }
193
194
195 bool InsetBox::forcePlainLayout(idx_type) const
196 {
197         return (!params_.inner_box || params_.use_makebox)
198                 && params_.type != "Shaded" && params_.type != "Framed";
199 }
200
201
202 ColorCode InsetBox::backgroundColor(PainterInfo const &) const
203 {
204         // we only support background color for 3 types
205         if (params_.type != "Shaded" && params_.type != "Frameless" && params_.type != "Boxed")
206                 return getLayout().bgcolor();
207
208         if (params_.type == "Shaded") {
209                 // FIXME: This hardcoded color is a hack!
210                 if (buffer().params().boxbgcolor == lyx::rgbFromHexName("#ff0000"))
211                         return getLayout().bgcolor();
212
213                 ColorCode c = lcolor.getFromLyXName("boxbgcolor");
214                 if (c == Color_none)
215                         return getLayout().bgcolor();
216                 return c;
217         }
218
219         if (params_.backgroundcolor != "none")
220                 return lcolor.getFromLaTeXName(params_.backgroundcolor);
221
222         return getLayout().bgcolor();
223 }
224
225
226 void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
227 {
228         switch (cmd.action()) {
229
230         case LFUN_INSET_MODIFY: {
231                 //lyxerr << "InsetBox::dispatch MODIFY" << endl;
232                 string const first_arg = cmd.getArg(0);
233                 bool const change_type = first_arg == "changetype";
234                 bool const for_box = first_arg == "box";
235                 if (!change_type && !for_box) {
236                         // not for us
237                         // this will not be handled higher up
238                         cur.undispatched();
239                         return;
240                 }
241                 cur.recordUndoInset(this);
242                 if (change_type)
243                         params_.type = cmd.getArg(1);
244                 else // if (for_box)
245                         string2params(to_utf8(cmd.argument()), params_);
246                 setButtonLabel();
247                 break;
248         }
249
250         default:
251                 InsetCollapsable::doDispatch(cur, cmd);
252                 break;
253         }
254 }
255
256
257 bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
258                 FuncStatus & flag) const
259 {
260         switch (cmd.action()) {
261
262         case LFUN_INSET_MODIFY: {
263                 string const first_arg = cmd.getArg(0);
264                 if (first_arg == "changetype") {
265                         string const type = cmd.getArg(1);
266                         flag.setOnOff(type == params_.type);
267                         flag.setEnabled(!params_.inner_box || type != "Framed");
268                         return true;
269                 }
270                 if (first_arg == "box") {
271                         flag.setEnabled(true);
272                         return true;
273                 }
274                 return InsetCollapsable::getStatus(cur, cmd, flag);
275         }
276
277         case LFUN_INSET_DIALOG_UPDATE:
278                 flag.setEnabled(true);
279                 return true;
280
281         default:
282                 return InsetCollapsable::getStatus(cur, cmd, flag);
283         }
284 }
285
286
287 const string defaultThick = "0.4pt";
288 const string defaultSep = "3pt";
289 const string defaultShadow = "4pt";
290
291 void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
292 {
293         BoxType btype = boxtranslator().find(params_.type);
294
295         string width_string = params_.width.asLatexString();
296         string thickness_string = params_.thickness.asLatexString();
297         string separation_string = params_.separation.asLatexString();
298         string shadowsize_string = params_.shadowsize.asLatexString();
299         bool stdwidth = false;
300         // in general the overall width of some decorated boxes is wider thean the inner box
301         // we could therefore calculate the real width for all sizes so that if the user wants
302         // e.g. 0.1\columnwidth or 2cm he gets exactly this size
303         // however this makes problems when importing TeX code
304         // therefore only recalculate for the most common case that the box should not protrude
305         // the page margins
306         if (params_.inner_box
307                 && ((width_string.find("1\\columnwidth") != string::npos
308                         || width_string.find("1\\textwidth") != string::npos)
309                         || width_string.find("1\\paperwidth") != string::npos
310                         || width_string.find("1\\linewidth") != string::npos)) {
311                 stdwidth = true;
312                 switch (btype) {
313                 case Frameless:
314                         break;
315                 case Framed:
316                         width_string += " - 2\\FrameSep - 2\\FrameRule";
317                         break;
318                 case Boxed:
319                         width_string += " - 2\\fboxsep - 2\\fboxrule";
320                         break;
321                 case Shaded:
322                         break;
323                 case ovalbox:
324                         width_string += " - 2\\fboxsep - 0.8pt";
325                         break;
326                 case Ovalbox:
327                         width_string += " - 2\\fboxsep - 1.6pt";
328                         break;
329                 case Shadowbox:
330                         width_string += " - 2\\fboxsep - 2\\fboxrule - \\shadowsize";
331                         break;
332                 case Doublebox:
333                         width_string += " - 2\\fboxsep - 7.5\\fboxrule - 1pt";
334                         break;
335                 }
336         }
337
338         os << safebreakln;
339         if (runparams.lastid != -1)
340                 os.texrow().start(runparams.lastid, runparams.lastpos);
341
342         // adapt column/text width correctly also if paragraphs indented
343         if (stdwidth && !(buffer().params().paragraph_separation))
344                 os << "\\noindent";
345
346         switch (btype) {
347         case Frameless:
348                 break;
349         case Framed:
350                 if (thickness_string != defaultThick) {
351                         os << "{\\FrameRule " << from_ascii(thickness_string);
352                         if (separation_string != defaultSep)
353                                 os << "\\FrameSep " << from_ascii(separation_string);
354                 }
355                 if (separation_string != defaultSep && thickness_string == defaultThick)
356                         os << "{\\FrameSep " << from_ascii(separation_string);
357
358                 os << "\\begin{framed}%\n";
359                 break;
360         case Boxed:
361                 if (thickness_string != defaultThick) {
362                         os << "{\\fboxrule " << from_ascii(thickness_string);
363                         if (separation_string != defaultSep)
364                                 os << "\\fboxsep " << from_ascii(separation_string);
365                 }
366                 if (separation_string != defaultSep && thickness_string == defaultThick)
367                         os << "{\\fboxsep " << from_ascii(separation_string);
368                 if (!params_.inner_box && !width_string.empty()) {
369                         if (params_.framecolor != "black" || params_.backgroundcolor != "none") {
370                                 os << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}{";
371                                 os << "\\makebox";
372                         } else
373                                 os << "\\framebox";
374                         // Special widths, see usrguide sec. 3.5
375                         // FIXME UNICODE
376                         if (params_.special != "none") {
377                                 os << "[" << params_.width.value()
378                                    << '\\' << from_utf8(params_.special)
379                                    << ']';
380                         } else
381                                 os << '[' << from_ascii(width_string)
382                                    << ']';
383                         if (params_.hor_pos != 'c')
384                                 os << "[" << params_.hor_pos << "]";
385                 } else {
386                         if (params_.framecolor != "black" || params_.backgroundcolor != "none")
387                                 os << "\\fcolorbox{" << params_.framecolor << "}{" << params_.backgroundcolor << "}";
388                         else
389                                 os << "\\fbox";
390                 }
391                 os << "{";
392                 break;
393         case ovalbox:
394                 if (!separation_string.empty() && separation_string != defaultSep)
395                         os << "{\\fboxsep " << from_ascii(separation_string);
396                 os << "\\ovalbox{";
397                 break;
398         case Ovalbox:
399                 if (!separation_string.empty() && separation_string != defaultSep)
400                         os << "{\\fboxsep " << from_ascii(separation_string);
401                 os << "\\Ovalbox{";
402                 break;
403         case Shadowbox:
404                 if (thickness_string != defaultThick) {
405                         os << "{\\fboxrule " << from_ascii(thickness_string);
406                         if (separation_string != defaultSep) {
407                                 os << "\\fboxsep " << from_ascii(separation_string);
408                                 if (shadowsize_string != defaultShadow)
409                                         os << "\\shadowsize " << from_ascii(shadowsize_string);
410                         }
411                         if (shadowsize_string != defaultShadow  && separation_string == defaultSep)
412                                 os << "\\shadowsize " << from_ascii(shadowsize_string);
413                 }
414                 if (separation_string != defaultSep && thickness_string == defaultThick) {
415                                 os << "{\\fboxsep " << from_ascii(separation_string);
416                                 if (shadowsize_string != defaultShadow)
417                                         os << "\\shadowsize " << from_ascii(shadowsize_string);
418                 }
419                 if (shadowsize_string != defaultShadow
420                                 && separation_string == defaultSep
421                                 && thickness_string == defaultThick)
422                                 os << "{\\shadowsize " << from_ascii(shadowsize_string);
423                 os << "\\shadowbox{";
424                 break;
425         case Shaded:
426                 // must be set later because e.g. the width settings only work when
427                 // it is inside a minipage or parbox
428                 break;
429         case Doublebox:
430                 if (thickness_string != defaultThick) {
431                         os << "{\\fboxrule " << from_ascii(thickness_string);
432                         if (separation_string != defaultSep)
433                                 os << "\\fboxsep " << from_ascii(separation_string);
434                 }
435                 if (separation_string != defaultSep && thickness_string == defaultThick)
436                         os << "{\\fboxsep " << from_ascii(separation_string);
437                 os << "\\doublebox{";
438                 break;
439         }
440
441         if (params_.inner_box) {
442                 if (params_.use_parbox) {
443                         if (params_.backgroundcolor != "none" && btype == Frameless)
444                                 os << "\\colorbox{" << params_.backgroundcolor << "}{";
445                         os << "\\parbox";
446                 } else if (params_.use_makebox) {
447                         if (!width_string.empty()) {
448                                 if (params_.backgroundcolor != "none")
449                                         os << "\\colorbox{" << params_.backgroundcolor << "}{";
450                                 os << "\\makebox";
451                                 // FIXME UNICODE
452                                 // output the width and horizontal position
453                                 if (params_.special != "none") {
454                                         os << "[" << params_.width.value()
455                                            << '\\' << from_utf8(params_.special)
456                                            << ']';
457                                 } else
458                                         os << '[' << from_ascii(width_string)
459                                            << ']';
460                                 if (params_.hor_pos != 'c')
461                                         os << "[" << params_.hor_pos << "]";
462                         } else {
463                                 if (params_.backgroundcolor != "none")
464                                         os << "\\colorbox{" << params_.backgroundcolor << "}";
465                                 else
466                                         os << "\\mbox";
467                         }
468                         os << "{";
469                 }
470                 else {
471                         if (params_.backgroundcolor != "none" && btype == Frameless)
472                                 os << "\\colorbox{" << params_.backgroundcolor << "}{";
473                         os << "\\begin{minipage}";
474                 }
475
476                 // output parameters for parbox and minipage
477                 if (!params_.use_makebox) {
478                         os << "[" << params_.pos << "]";
479                         if (params_.height_special == "none") {
480                                 // FIXME UNICODE
481                                 os << "[" << from_ascii(params_.height.asLatexString()) << "]";
482                         } else {
483                                 // Special heights
484                                 // set no optional argument when the value is the default "1\height"
485                                 // (special units like \height are handled as "in")
486                                 // but when the user has chosen a non-default inner_pos, the height
487                                 // must be given: \minipage[pos][height][inner-pos]{width}
488                                 if ((params_.height != Length("1in") ||
489                                         params_.height_special != "totalheight") ||
490                                         params_.inner_pos != params_.pos) {
491                                                 // FIXME UNICODE
492                                                 os << "[" << params_.height.value()
493                                                         << "\\" << from_utf8(params_.height_special) << "]";
494                                 }
495                         }
496                         if (params_.inner_pos != params_.pos)
497                                 os << "[" << params_.inner_pos << "]";
498                         // FIXME UNICODE
499                         os << '{' << from_ascii(width_string) << '}';
500                         if (params_.use_parbox)
501                                 os << "{";
502                 }
503
504                 os << "%\n";
505         } // end if inner_box
506
507         if (btype == Shaded) {
508                 os << "\\begin{shaded}%\n";
509         }
510
511         InsetText::latex(os, runparams);
512
513         if (btype == Shaded)
514                 os << "\\end{shaded}";
515
516         if (params_.inner_box) {
517                 if (params_.use_parbox || params_.use_makebox)
518                         os << "%\n}";
519                 else
520                         os << "%\n\\end{minipage}";
521                 if (params_.backgroundcolor != "none" && btype == Frameless
522                         && !(params_.use_makebox && width_string.empty()))
523                         os << "}";
524         }
525
526         switch (btype) {
527         case Frameless:
528                 break;
529         case Framed:
530                 os << "\\end{framed}";
531                 if (separation_string != defaultSep     || thickness_string != defaultThick)
532                         os << "}";
533                 break;
534         case Boxed:
535                 os << "}";
536                 if (!params_.inner_box && !width_string.empty()
537                         && (params_.framecolor != "black" || params_.backgroundcolor != "none"))
538                         os << "}";
539                 if (separation_string != defaultSep     || thickness_string != defaultThick)
540                         os << "}";
541                 break;
542         case ovalbox:
543                 os << "}";
544                 if (separation_string != defaultSep)
545                         os << "}";
546                 break;
547         case Ovalbox:
548                 os << "}";
549                 if (separation_string != defaultSep)
550                         os << "}";
551                 break;
552         case Doublebox:
553                 os << "}";
554                 if (separation_string != defaultSep || thickness_string != defaultThick)
555                         os << "}";
556                 break;
557         case Shadowbox:
558                 os << "}";
559                 if (separation_string != defaultSep
560                         || thickness_string != defaultThick
561                         || shadowsize_string != defaultShadow)
562                         os << "}";
563                 break;
564         case Shaded:
565                 // already done
566                 break;
567         }
568 }
569
570
571 int InsetBox::plaintext(odocstringstream & os,
572        OutputParams const & runparams, size_t max_length) const
573 {
574         BoxType const btype = boxtranslator().find(params_.type);
575
576         switch (btype) {
577                 case Frameless:
578                         break;
579                 case Framed:
580                 case Boxed:
581                         os << "[\n";
582                         break;
583                 case ovalbox:
584                         os << "(\n";
585                         break;
586                 case Ovalbox:
587                         os << "((\n";
588                         break;
589                 case Shadowbox:
590                 case Shaded:
591                         os << "[/\n";
592                         break;
593                 case Doublebox:
594                         os << "[[\n";
595                         break;
596         }
597
598         InsetText::plaintext(os, runparams, max_length);
599
600         int len = 0;
601         switch (btype) {
602                 case Frameless:
603                         os << "\n";
604                         break;
605                 case Framed:
606                 case Boxed:
607                         os << "\n]";
608                         len = 1;
609                         break;
610                 case ovalbox:
611                         os << "\n)";
612                         len = 1;
613                         break;
614                 case Ovalbox:
615                         os << "\n))";
616                         len = 2;
617                         break;
618                 case Shadowbox:
619                 case Shaded:
620                         os << "\n/]";
621                         len = 2;
622                         break;
623                 case Doublebox:
624                         os << "\n]]";
625                         len = 2;
626                         break;
627         }
628
629         return PLAINTEXT_NEWLINE + len; // len chars on a separate line
630 }
631
632
633 int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
634 {
635         return InsetText::docbook(os, runparams);
636 }
637
638
639 docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
640 {
641         // construct attributes
642         string attrs = "class='" + params_.type + "'";
643         string style;
644         if (!params_.width.empty()) {
645                 string w = params_.width.asHTMLString();
646                 if (w != "100%")
647                         style += ("width: " + params_.width.asHTMLString() + "; ");
648         }
649         // The special heights don't really mean anything for us.
650         if (!params_.height.empty() && params_.height_special == "none")
651                 style += ("height: " + params_.height.asHTMLString() + "; ");
652         if (!style.empty())
653                 attrs += " style='" + style + "'";
654
655         xs << html::StartTag("div", attrs);
656         XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
657         docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
658         xs << html::EndTag("div");
659         xs << defer;
660         return docstring();
661 }
662
663
664 void InsetBox::validate(LaTeXFeatures & features) const
665 {
666         BoxType btype = boxtranslator().find(params_.type);
667         switch (btype) {
668         case Frameless:
669                 if (params_.backgroundcolor != "none")
670                         features.require("xcolor");
671                 break;
672         case Framed:
673                 features.require("calc");
674                 features.require("framed");
675                 break;
676         case Boxed:
677                 features.require("calc");
678                 if (params_.framecolor != "black" || params_.backgroundcolor != "none")
679                         features.require("xcolor");
680                 break;
681         case ovalbox:
682         case Ovalbox:
683         case Shadowbox:
684         case Doublebox:
685                 features.require("calc");
686                 features.require("fancybox");
687                 break;
688         case Shaded:
689                 features.require("color");
690                 features.require("framed");
691                 break;
692         }
693         InsetCollapsable::validate(features);
694 }
695
696
697 string InsetBox::contextMenuName() const
698 {
699         return "context-box";
700 }
701
702
703 string InsetBox::params2string(InsetBoxParams const & params)
704 {
705         ostringstream data;
706         data << "box" << ' ';
707         params.write(data);
708         return data.str();
709 }
710
711
712 void InsetBox::string2params(string const & in, InsetBoxParams & params)
713 {
714         if (in.empty())
715                 return;
716
717         istringstream data(in);
718         Lexer lex;
719         lex.setStream(data);
720
721         string name;
722         lex >> name;
723         if (!lex || name != "box") {
724                 LYXERR0("InsetBox::string2params(" << in << ")\n"
725                                           "Expected arg 1 to be \"box\"\n");
726                 return;
727         }
728
729         // This is part of the inset proper that is usually swallowed
730         // by Text::readInset
731         string id;
732         lex >> id;
733         if (!lex || id != "Box") {
734                 LYXERR0("InsetBox::string2params(" << in << ")\n"
735                                           "Expected arg 2 to be \"Box\"\n");
736         }
737
738         params = InsetBoxParams(string());
739         params.read(lex);
740 }
741
742
743 /////////////////////////////////////////////////////////////////////////
744 //
745 // InsetBoxParams
746 //
747 /////////////////////////////////////////////////////////////////////////
748
749 InsetBoxParams::InsetBoxParams(string const & label)
750         : type(label),
751           use_parbox(false),
752           use_makebox(false),
753           inner_box(true),
754           width(Length("100col%")),
755           special("none"),
756           pos('t'),
757           hor_pos('c'),
758           inner_pos('t'),
759           height(Length("1in")),
760           height_special("totalheight"), // default is 1\\totalheight
761           thickness(Length(defaultThick)),
762           separation(Length(defaultSep)),
763           shadowsize(Length(defaultShadow)),
764           framecolor("black"),
765           backgroundcolor("none")
766 {}
767
768
769 void InsetBoxParams::write(ostream & os) const
770 {
771         os << "Box " << type << "\n";
772         os << "position \"" << pos << "\"\n";
773         os << "hor_pos \"" << hor_pos << "\"\n";
774         os << "has_inner_box " << inner_box << "\n";
775         os << "inner_pos \"" << inner_pos << "\"\n";
776         os << "use_parbox " << use_parbox << "\n";
777         os << "use_makebox " << use_makebox << "\n";
778         os << "width \"" << width.asString() << "\"\n";
779         os << "special \"" << special << "\"\n";
780         os << "height \"" << height.asString() << "\"\n";
781         os << "height_special \"" << height_special << "\"\n";
782         os << "thickness \"" << thickness.asString() << "\"\n";
783         os << "separation \"" << separation.asString() << "\"\n";
784         os << "shadowsize \"" << shadowsize.asString() << "\"\n";
785         os << "framecolor \"" << framecolor << "\"\n";
786         os << "backgroundcolor \"" << backgroundcolor << "\"\n";
787 }
788
789
790 void InsetBoxParams::read(Lexer & lex)
791 {
792         lex.setContext("InsetBoxParams::read");
793         lex >> type;
794         lex >> "position" >> pos;
795         lex >> "hor_pos" >> hor_pos;
796         lex >> "has_inner_box" >> inner_box;
797         if (type == "Framed")
798                 inner_box = false;
799         lex >> "inner_pos" >> inner_pos;
800         lex >> "use_parbox" >> use_parbox;
801         lex >> "use_makebox" >> use_makebox;
802         lex >> "width" >> width;
803         lex >> "special" >> special;
804         lex >> "height" >> height;
805         lex >> "height_special" >> height_special;
806         lex >> "thickness" >> thickness;
807         lex >> "separation" >> separation;
808         lex >> "shadowsize" >> shadowsize;
809         lex >> "framecolor" >> framecolor;
810         lex >> "backgroundcolor" >> backgroundcolor;
811 }
812
813
814 } // namespace lyx