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