]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBox.cpp
011df87327faaf70ed56d3a24e773641161f1095
[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
163
164 bool InsetBox::hasFixedWidth() const
165 {
166         return !params_.width.empty();
167 }
168
169
170 bool InsetBox::allowMultiPar() const
171 {
172         return (params_.inner_box && !params_.use_makebox)
173                 || params_.type == "Shaded" || params_.type == "Framed";
174 }
175
176
177 void InsetBox::metrics(MetricsInfo & m, Dimension & dim) const
178 {
179         // back up textwidth.
180         int textwidth_backup = m.base.textwidth;
181         if (hasFixedWidth())
182                 m.base.textwidth = params_.width.inPixels(m.base);
183         InsetCollapsable::metrics(m, dim);
184         // retore textwidth.
185         m.base.textwidth = textwidth_backup;
186 }
187
188
189 bool InsetBox::forcePlainLayout(idx_type) const
190 {
191         return (!params_.inner_box || params_.use_makebox)
192                 && params_.type != "Shaded" && params_.type != "Framed";
193 }
194
195
196 ColorCode InsetBox::backgroundColor(PainterInfo const &) const
197 {
198         if (params_.type != "Shaded")
199                 return getLayout().bgcolor();
200         // FIXME: This hardcoded color is a hack!
201         if (buffer().params().boxbgcolor == lyx::rgbFromHexName("#ff0000"))
202                 return getLayout().bgcolor();
203         ColorCode c = lcolor.getFromLyXName("boxbgcolor");
204         if (c == Color_none)
205                 return getLayout().bgcolor();
206         return c;
207 }
208
209
210 void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
211 {
212         switch (cmd.action()) {
213
214         case LFUN_INSET_MODIFY: {
215                 //lyxerr << "InsetBox::dispatch MODIFY" << endl;
216                 string const first_arg = cmd.getArg(0);
217                 bool const change_type = first_arg == "changetype";
218                 bool const for_box = first_arg == "box";
219                 if (!change_type && !for_box) {
220                         // not for us
221                         // this will not be handled higher up
222                         cur.undispatched();
223                         return;
224                 }
225                 cur.recordUndoInset(this);
226                 if (change_type)
227                         params_.type = cmd.getArg(1);
228                 else // if (for_box)
229                         string2params(to_utf8(cmd.argument()), params_);
230                 setButtonLabel();
231                 break;
232         }
233
234         default:
235                 InsetCollapsable::doDispatch(cur, cmd);
236                 break;
237         }
238 }
239
240
241 bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
242                 FuncStatus & flag) const
243 {
244         switch (cmd.action()) {
245
246         case LFUN_INSET_MODIFY: {
247                 string const first_arg = cmd.getArg(0);
248                 if (first_arg == "changetype") {
249                         string const type = cmd.getArg(1);
250                         flag.setOnOff(type == params_.type);
251                         flag.setEnabled(!params_.inner_box || type != "Framed");
252                         return true;
253                 }
254                 if (first_arg == "box") {
255                         flag.setEnabled(true);
256                         return true;
257                 }
258                 return InsetCollapsable::getStatus(cur, cmd, flag);
259         }
260
261         case LFUN_INSET_DIALOG_UPDATE:
262                 flag.setEnabled(true);
263                 return true;
264
265         default:
266                 return InsetCollapsable::getStatus(cur, cmd, flag);
267         }
268 }
269
270
271 void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
272 {
273         BoxType btype = boxtranslator().find(params_.type);
274
275         string width_string = params_.width.asLatexString();
276         string thickness_string = params_.thickness.asLatexString();
277         string defaultThick = "0.4pt";
278         string separation_string = params_.separation.asLatexString();
279         string defaultSep = "3pt";
280         string shadowsize_string = params_.shadowsize.asLatexString();
281         string defaultShadow = "4pt";
282         bool stdwidth = false;
283         // in general the overall width of some decorated boxes is wider thean the inner box
284         // we could therefore calculate the real width for all sizes so that if the user wants
285         // e.g. 0.1\columnwidth or 2cm he gets exactly this size
286         // however this makes problems when importing TeX code
287         // therefore only recalculate for the most common case that the box should not protrude
288         // the page margins
289         if (params_.inner_box
290                 && ((width_string.find("1\\columnwidth") != string::npos
291                         || width_string.find("1\\textwidth") != string::npos)
292                         || width_string.find("1\\paperwidth") != string::npos
293                         || width_string.find("1\\linewidth") != string::npos)) {
294                 stdwidth = true;
295                 switch (btype) {
296                 case Frameless:
297                         break;
298                 case Framed:
299                         width_string += " - 2\\FrameSep - 2\\FrameRule";
300                         break;
301                 case Boxed:
302                         width_string += " - 2\\fboxsep - 2\\fboxrule";
303                         break;
304                 case Shaded:
305                         break;
306                 case ovalbox:
307                         width_string += " - 2\\fboxsep - 0.8pt";
308                         break;
309                 case Ovalbox:
310                         width_string += " - 2\\fboxsep - 1.6pt";
311                         break;
312                 case Shadowbox:
313                         width_string += " - 2\\fboxsep - 2\\fboxrule - \\shadowsize";
314                         break;
315                 case Doublebox:
316                         width_string += " - 2\\fboxsep - 7.5\\fboxrule - 1pt";
317                         break;
318                 }
319         }
320
321         os << safebreakln;
322         if (runparams.lastid != -1)
323                 os.texrow().start(runparams.lastid, runparams.lastpos);
324
325         // adapt column/text width correctly also if paragraphs indented
326         if (stdwidth && !(buffer().params().paragraph_separation))
327                 os << "\\noindent";
328
329         switch (btype) {
330         case Frameless:
331                 break;
332         case Framed:
333                 if (!(thickness_string.find(defaultThick) != string::npos)) {
334                         os << "{\\FrameRule " << from_ascii(thickness_string);
335                         if (!(separation_string.find(defaultSep) != string::npos))
336                                 os << "\\FrameSep " << from_ascii(separation_string);
337                 }
338                 if (!(separation_string.find(defaultSep) != string::npos)
339                         && (thickness_string.find(defaultThick) != string::npos))
340                         os << "{\\FrameSep " << from_ascii(separation_string);
341
342                 os << "\\begin{framed}%\n";
343                 break;
344         case Boxed:
345                 if (!(thickness_string.find(defaultThick) != string::npos)) {
346                         os << "{\\fboxrule " << from_ascii(thickness_string);
347                         if (!(separation_string.find(defaultSep) != string::npos))
348                                 os << "\\fboxsep " << from_ascii(separation_string);
349                 }
350                 if (!(separation_string.find(defaultSep) != string::npos)
351                         && (thickness_string.find(defaultThick) != string::npos))
352                         os << "{\\fboxsep " << from_ascii(separation_string);
353                 if (!width_string.empty()) {
354                         if (!params_.inner_box) {
355                                 os << "\\framebox";
356                                 // Special widths, see usrguide sec. 3.5
357                                 // FIXME UNICODE
358                                 if (params_.special != "none") {
359                                         os << "[" << params_.width.value()
360                                            << '\\' << from_utf8(params_.special)
361                                            << ']';
362                                 } else
363                                         os << '[' << from_ascii(width_string)
364                                            << ']';
365                                 if (params_.hor_pos != 'c')
366                                         os << "[" << params_.hor_pos << "]";
367                         } else
368                                 os << "\\fbox";
369                 } else
370                         os << "\\fbox";
371                 os << "{";
372                 break;
373         case ovalbox:
374                 if (!separation_string.empty() && separation_string.find(defaultSep) == string::npos)
375                         os << "{\\fboxsep " << from_ascii(separation_string);
376                 os << "\\ovalbox{";
377                 break;
378         case Ovalbox:
379                 if (!separation_string.empty() && separation_string.find(defaultSep) == string::npos)
380                         os << "{\\fboxsep " << from_ascii(separation_string);
381                 os << "\\Ovalbox{";
382                 break;
383         case Shadowbox:
384                 if (!(thickness_string.find(defaultThick) != string::npos)) {
385                         os << "{\\fboxrule " << from_ascii(thickness_string);
386                         if (!(separation_string.find(defaultSep) != string::npos)) {
387                                 os << "\\fboxsep " << from_ascii(separation_string);
388                                 if (!(shadowsize_string.find(defaultShadow) != string::npos))
389                                         os << "\\shadowsize " << from_ascii(shadowsize_string);
390                         }
391                         if (!(shadowsize_string.find(defaultShadow) != string::npos)
392                                 && (separation_string.find(defaultSep) != string::npos))
393                                 os << "\\shadowsize " << from_ascii(shadowsize_string);
394                 }
395                 if (!(separation_string.find(defaultSep) != string::npos)
396                         && (thickness_string.find(defaultThick) != string::npos)) {
397                                 os << "{\\fboxsep " << from_ascii(separation_string);
398                                 if (!(shadowsize_string.find(defaultShadow) != string::npos))
399                                         os << "\\shadowsize " << from_ascii(shadowsize_string);
400                 }
401                 if (!(shadowsize_string.find(defaultShadow) != string::npos)
402                                 && (separation_string.find(defaultSep) != string::npos)
403                                 && (thickness_string.find(defaultThick) != string::npos))
404                                 os << "{\\shadowsize " << from_ascii(shadowsize_string);
405                 os << "\\shadowbox{";
406                 break;
407         case Shaded:
408                 // must be set later because e.g. the width settings only work when
409                 // it is inside a minipage or parbox
410                 break;
411         case Doublebox:
412                 if (!(thickness_string.find(defaultThick) != string::npos)) {
413                         os << "{\\fboxrule " << from_ascii(thickness_string);
414                         if (!(separation_string.find(defaultSep) != string::npos))
415                                 os << "\\fboxsep " << from_ascii(separation_string);
416                 }
417                 if (!(separation_string.find(defaultSep) != string::npos)
418                         && (thickness_string.find(defaultThick) != string::npos))
419                         os << "{\\fboxsep " << from_ascii(separation_string);
420                 os << "\\doublebox{";
421                 break;
422         }
423
424         if (params_.inner_box) {
425                 if (params_.use_parbox)
426                         os << "\\parbox";
427                 else if (params_.use_makebox) {
428                         if (!width_string.empty()) {
429                                 os << "\\makebox";
430                                 // FIXME UNICODE
431                                 // output the width and horizontal position
432                                 if (params_.special != "none") {
433                                         os << "[" << params_.width.value()
434                                            << '\\' << from_utf8(params_.special)
435                                            << ']';
436                                 } else
437                                         os << '[' << from_ascii(width_string)
438                                            << ']';
439                                 if (params_.hor_pos != 'c')
440                                         os << "[" << params_.hor_pos << "]";
441                         } else
442                                 os << "\\mbox";
443                         os << "{";
444                 }
445                 else
446                         os << "\\begin{minipage}";
447
448                 // output parameters for parbox and minipage
449                 if (!params_.use_makebox) {
450                         os << "[" << params_.pos << "]";
451                         if (params_.height_special == "none") {
452                                 // FIXME UNICODE
453                                 os << "[" << from_ascii(params_.height.asLatexString()) << "]";
454                         } else {
455                                 // Special heights
456                                 // set no optional argument when the value is the default "1\height"
457                                 // (special units like \height are handled as "in")
458                                 // but when the user has chosen a non-default inner_pos, the height
459                                 // must be given: \minipage[pos][height][inner-pos]{width}
460                                 if ((params_.height != Length("1in") ||
461                                         params_.height_special != "totalheight") ||
462                                         params_.inner_pos != params_.pos) {
463                                                 // FIXME UNICODE
464                                                 os << "[" << params_.height.value()
465                                                         << "\\" << from_utf8(params_.height_special) << "]";
466                                 }
467                         }
468                         if (params_.inner_pos != params_.pos)
469                                 os << "[" << params_.inner_pos << "]";
470                         // FIXME UNICODE
471                         os << '{' << from_ascii(width_string) << '}';
472                         if (params_.use_parbox)
473                                 os << "{";
474                 }
475
476                 os << "%\n";
477         } // end if inner_box
478
479         if (btype == Shaded) {
480                 os << "\\begin{shaded}%\n";
481         }
482
483         // \framebox and \makebox handle hor_pos their own way
484         // hor_pos is senseless for \mbox and \fbox
485         if (!(params_.use_makebox)
486                 && !(btype == Boxed && !params_.inner_box)) {
487                         switch (params_.hor_pos) {
488                         case 'l':
489                                 // do nothing because this is LaTeX's default
490                                 break;
491                         case 'c':
492                                 os << "\\centering ";
493                                 break;
494                         case 'r':
495                                 os << "\\raggedleft ";
496                                 break;
497                         }
498         }
499
500         InsetText::latex(os, runparams);
501
502         if (btype == Shaded)
503                 os << "\\end{shaded}";
504
505         if (params_.inner_box) {
506                 if (params_.use_parbox || params_.use_makebox)
507                         os << "%\n}";
508                 else
509                         os << "%\n\\end{minipage}";
510         }
511
512         switch (btype) {
513         case Frameless:
514                 break;
515         case Framed:
516                 os << "\\end{framed}";
517                 if (!(separation_string.find(defaultSep) != string::npos)
518                         || !(thickness_string.find(defaultThick) != string::npos))
519                         os << "}";
520                 break;
521         case Boxed:
522                 os << "}";
523                 if (!(separation_string.find(defaultSep) != string::npos)
524                         || !(thickness_string.find(defaultThick) != string::npos))
525                         os << "}";
526                 break;
527         case ovalbox:
528                 os << "}";
529                 if (!(separation_string.find(defaultSep) != string::npos))
530                         os << "}";
531                 break;
532         case Ovalbox:
533                 os << "}";
534                 if (!(separation_string.find(defaultSep) != string::npos))
535                         os << "}";
536                 break;
537         case Doublebox:
538                 os << "}";
539                 if (!(separation_string.find(defaultSep) != string::npos)
540                         || !(thickness_string.find(defaultThick) != string::npos))
541                         os << "}";
542                 break;
543         case Shadowbox:
544                 os << "}";
545                 if (!(separation_string.find(defaultSep) != string::npos)
546                         || !(thickness_string.find(defaultThick) != string::npos)
547                         || !(shadowsize_string.find(defaultShadow) != string::npos))
548                         os << "}";
549                 break;
550         case Shaded:
551                 // already done
552                 break;
553         }
554 }
555
556
557 int InsetBox::plaintext(odocstringstream & os,
558        OutputParams const & runparams, size_t max_length) const
559 {
560         BoxType const btype = boxtranslator().find(params_.type);
561
562         switch (btype) {
563                 case Frameless:
564                         break;
565                 case Framed:
566                 case Boxed:
567                         os << "[\n";
568                         break;
569                 case ovalbox:
570                         os << "(\n";
571                         break;
572                 case Ovalbox:
573                         os << "((\n";
574                         break;
575                 case Shadowbox:
576                 case Shaded:
577                         os << "[/\n";
578                         break;
579                 case Doublebox:
580                         os << "[[\n";
581                         break;
582         }
583
584         InsetText::plaintext(os, runparams, max_length);
585
586         int len = 0;
587         switch (btype) {
588                 case Frameless:
589                         os << "\n";
590                         break;
591                 case Framed:
592                 case Boxed:
593                         os << "\n]";
594                         len = 1;
595                         break;
596                 case ovalbox:
597                         os << "\n)";
598                         len = 1;
599                         break;
600                 case Ovalbox:
601                         os << "\n))";
602                         len = 2;
603                         break;
604                 case Shadowbox:
605                 case Shaded:
606                         os << "\n/]";
607                         len = 2;
608                         break;
609                 case Doublebox:
610                         os << "\n]]";
611                         len = 2;
612                         break;
613         }
614
615         return PLAINTEXT_NEWLINE + len; // len chars on a separate line
616 }
617
618
619 int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
620 {
621         return InsetText::docbook(os, runparams);
622 }
623
624
625 docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
626 {
627         // construct attributes
628         string attrs = "class='" + params_.type + "'";
629         string style;
630         if (!params_.width.empty()) {
631                 string w = params_.width.asHTMLString();
632                 if (w != "100%")
633                         style += ("width: " + params_.width.asHTMLString() + "; ");
634         }
635         // The special heights don't really mean anything for us.
636         if (!params_.height.empty() && params_.height_special == "none")
637                 style += ("height: " + params_.height.asHTMLString() + "; ");
638         if (!style.empty())
639                 attrs += " style='" + style + "'";
640
641         xs << html::StartTag("div", attrs);
642         XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
643         docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
644         xs << html::EndTag("div");
645         xs << defer;
646         return docstring();
647 }
648
649
650 void InsetBox::validate(LaTeXFeatures & features) const
651 {
652         BoxType btype = boxtranslator().find(params_.type);
653         switch (btype) {
654         case Frameless:
655                 break;
656         case Framed:
657                 features.require("calc");
658                 features.require("framed");
659                 break;
660         case Boxed:
661                 features.require("calc");
662                 break;
663         case ovalbox:
664         case Ovalbox:
665         case Shadowbox:
666         case Doublebox:
667                 features.require("calc");
668                 features.require("fancybox");
669                 break;
670         case Shaded:
671                 features.require("color");
672                 features.require("framed");
673                 break;
674         }
675         InsetCollapsable::validate(features);
676 }
677
678
679 string InsetBox::contextMenuName() const
680 {
681         return "context-box";
682 }
683
684
685 string InsetBox::params2string(InsetBoxParams const & params)
686 {
687         ostringstream data;
688         data << "box" << ' ';
689         params.write(data);
690         return data.str();
691 }
692
693
694 void InsetBox::string2params(string const & in, InsetBoxParams & params)
695 {
696         if (in.empty())
697                 return;
698
699         istringstream data(in);
700         Lexer lex;
701         lex.setStream(data);
702
703         string name;
704         lex >> name;
705         if (!lex || name != "box") {
706                 LYXERR0("InsetBox::string2params(" << in << ")\n"
707                                           "Expected arg 1 to be \"box\"\n");
708                 return;
709         }
710
711         // This is part of the inset proper that is usually swallowed
712         // by Text::readInset
713         string id;
714         lex >> id;
715         if (!lex || id != "Box") {
716                 LYXERR0("InsetBox::string2params(" << in << ")\n"
717                                           "Expected arg 2 to be \"Box\"\n");
718         }
719
720         params = InsetBoxParams(string());
721         params.read(lex);
722 }
723
724
725 /////////////////////////////////////////////////////////////////////////
726 //
727 // InsetBoxParams
728 //
729 /////////////////////////////////////////////////////////////////////////
730
731 InsetBoxParams::InsetBoxParams(string const & label)
732         : type(label),
733           use_parbox(false),
734           use_makebox(false),
735           inner_box(true),
736           width(Length("100col%")),
737           special("none"),
738           pos('t'),
739           hor_pos('c'),
740           inner_pos('t'),
741           height(Length("1in")),
742           height_special("totalheight"), // default is 1\\totalheight
743           thickness(Length("0.4pt")),
744           separation(Length("3pt")),
745           shadowsize(Length("4pt"))
746 {}
747
748
749 void InsetBoxParams::write(ostream & os) const
750 {
751         os << "Box " << type << "\n";
752         os << "position \"" << pos << "\"\n";
753         os << "hor_pos \"" << hor_pos << "\"\n";
754         os << "has_inner_box " << inner_box << "\n";
755         os << "inner_pos \"" << inner_pos << "\"\n";
756         os << "use_parbox " << use_parbox << "\n";
757         os << "use_makebox " << use_makebox << "\n";
758         os << "width \"" << width.asString() << "\"\n";
759         os << "special \"" << special << "\"\n";
760         os << "height \"" << height.asString() << "\"\n";
761         os << "height_special \"" << height_special << "\"\n";
762         os << "thickness \"" << thickness.asString() << "\"\n";
763         os << "separation \"" << separation.asString() << "\"\n";
764         os << "shadowsize \"" << shadowsize.asString() << "\"\n";
765 }
766
767
768 void InsetBoxParams::read(Lexer & lex)
769 {
770         lex.setContext("InsetBoxParams::read");
771         lex >> type;
772         lex >> "position" >> pos;
773         lex >> "hor_pos" >> hor_pos;
774         lex >> "has_inner_box" >> inner_box;
775         if (type == "Framed")
776                 inner_box = false;
777         lex >> "inner_pos" >> inner_pos;
778         lex >> "use_parbox" >> use_parbox;
779         lex >> "use_makebox" >> use_makebox;
780         lex >> "width" >> width;
781         lex >> "special" >> special;
782         lex >> "height" >> height;
783         lex >> "height_special" >> height_special;
784         lex >> "thickness" >> thickness;
785         lex >> "separation" >> separation;
786         lex >> "shadowsize" >> shadowsize;
787 }
788
789
790 } // namespace lyx