]> git.lyx.org Git - lyx.git/blob - src/insets/insetlist.C
a126b40e677d23dd8e1deee0789f77325c8a015c
[lyx.git] / src / insets / insetlist.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 "insetlist.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 #include "debug.h"
25
26 using std::ostream;
27 using std::endl;
28
29 // This class is _far_ from finished. I hope that we can have a inset to
30 // handle the different lists that we have. It should also be possible
31 // to create new lists on the fly.
32 // Currently LyX only supports: itemize, enumerate, description and
33 // lyxlist. All support for these should be moved to this class and other
34 // helper classes.
35 // It is also possible that we will need a baseclass and subclasses for
36 // different types of lists. (and should they be collapsable?)
37 //
38 // Lgb
39
40 InsetList::InsetList()
41         : InsetCollapsable()
42 {
43         setLabel(_("list"));
44         LyXFont font(LyXFont::ALL_SANE);
45         font.decSize();
46         font.decSize();
47         font.setColor(LColor::footnote);
48         setLabelFont(font);
49         setAutoCollapse(false);
50         setInsetName("List");
51 }
52
53
54 void InsetList::Write(Buffer const * buf, ostream & os) const
55 {
56         os << getInsetName() << "\n";
57         InsetCollapsable::Write(buf, os);
58 }
59
60
61 Inset * InsetList::Clone() const
62 {
63         InsetList * result = new InsetList;
64         result->inset->init(inset);
65         
66         result->collapsed = collapsed;
67         return result;
68 }
69
70
71 char const * InsetList::EditMessage() const
72 {
73         return _("Opened List Inset");
74 }
75
76
77 int InsetList::Latex(Buffer const * buf,
78                      ostream & os, bool fragile, bool fp) const
79 {
80         os << "\\footnote{%\n";
81         
82         int i = inset->Latex(buf, os, fragile, fp);
83         os << "}%\n";
84         
85         return i + 2;
86 }
87
88
89 bool InsetList::InsertInsetAllowed(Inset * in) const
90 {
91         if ((in->LyxCode() == Inset::FOOT_CODE) ||
92             (in->LyxCode() == Inset::MARGIN_CODE)) {
93                 return false;
94         }
95         return true;
96 }
97
98
99 #if 0
100 LyXFont InsetList::GetDrawFont(BufferView * bv,LyXParagraph * p, int pos) const
101 {
102         LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
103         fn.decSize().decSize();
104         return fn;
105 }
106 #endif