]> git.lyx.org Git - lyx.git/blob - src/insets/insetoptarg.C
25502904f39aec702280a24539ec632c6d28b1df
[lyx.git] / src / insets / insetoptarg.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2001 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "debug.h"
18
19 #include "insetoptarg.h"
20 #include "support/LOstream.h"
21 #include "frontends/Alert.h"
22 #include "support/lstrings.h" //frontStrip, strip
23 #include "lyxtext.h"
24 #include "buffer.h"
25 #include "gettext.h"
26 #include "BufferView.h"
27 #include "support/lstrings.h"
28
29 using std::ostream;
30 using std::vector;
31 using std::pair;
32
33 /* OptArg. Used to insert a short version of sectioning header etc.
34  *  automatically, or other optional LaTeX arguments */
35
36
37 InsetOptArg::InsetOptArg(BufferParams const & ins)
38         : InsetCollapsable(ins, true)
39 {
40     LyXFont font(LyXFont::ALL_SANE);
41         font.setColor(LColor::collapsable);
42         setLabelFont(font);
43         setLabel(_("opt"));
44 }
45
46 InsetOptArg::InsetOptArg(InsetOptArg const & in, bool same_id)
47                     : InsetCollapsable(in, same_id)
48 {
49     LyXFont font(LyXFont::ALL_SANE);
50         font.setColor(LColor::collapsable);
51         setLabelFont(font);
52         setLabel(_("opt"));
53 }
54
55 Inset * InsetOptArg::clone(Buffer const &, bool same_id) const
56 {
57                     return new InsetOptArg(*this, same_id);
58 }
59
60 string const InsetOptArg::editMessage() const
61 {
62         return _("Opened Optional Argument Inset");
63 }
64
65 void InsetOptArg::write(Buffer const * buf, ostream & os) const
66 {
67         os << "OptArg" << "\n";
68         InsetCollapsable::write(buf, os);
69 }
70
71 int InsetOptArg::latex(Buffer const *, ostream &, bool, bool) const
72 {
73         return 0;
74 }
75
76 int InsetOptArg::latexOptional(Buffer const * buf, ostream & os,
77                                 bool, bool fp) const
78 {
79         os << '[';
80         int const i = inset.latex(buf, os, false, fp);
81         os << ']';
82         return i + 2;
83 }
84