]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
Herbert's patch, part 3
[lyx.git] / src / insets / insetbib.h
1 // -*- C++ -*-
2 /* This file is part of*
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *       
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  * 
10  * ====================================================== */
11
12 #ifndef INSET_BIB_H
13 #define INSET_BIB_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <vector>
20 #include "insetcommand.h"
21
22 class Buffer;
23
24 /** Used to insert bibitem's information (key and label)
25   
26   Must be automatically inserted as the first object in a
27   bibliography paragraph. 
28   */
29 class InsetBibKey : public InsetCommand {
30 public:
31         ///
32         InsetBibKey(InsetCommandParams const &);
33         ///
34         ~InsetBibKey();
35         ///
36         Inset * clone(Buffer const &, bool same_id = false) const;
37         /** Currently \bibitem is used as a LyX2.x command,
38             so we need this method.
39         */
40         void write(Buffer const *, std::ostream &) const;
41         ///
42         void read(Buffer const *, LyXLex & lex);
43         ///
44         virtual string const getScreenLabel(Buffer const *) const;
45         ///
46         void edit(BufferView *, int x, int y, unsigned int button);
47         ///
48         void edit(BufferView * bv, bool front = true);
49         ///
50         EDITABLE editable() const { return IS_EDITABLE; } 
51         /// A user can't neither insert nor delete this inset
52         bool deletable() const {
53                 return false;
54         }
55         ///
56         void setCounter(int);
57         ///
58         int  getCounter() const { return counter; }
59         ///
60         string const getBibLabel() const;
61         ///
62         struct Holder {
63                 InsetBibKey * inset;
64                 BufferView * view;
65         };
66  
67 private:
68         ///
69         int counter;
70         ///
71         Holder holder;
72         ///
73         static int key_counter;
74 };
75
76
77 /** Used to insert BibTeX's information 
78   */
79 class InsetBibtex : public InsetCommand {
80 public:
81         ///
82         InsetBibtex(InsetCommandParams const &, bool same_id = false);
83         ///
84         ~InsetBibtex();
85         ///
86         Inset * clone(Buffer const &, bool same_id = false) const {
87                 return new InsetBibtex(params(), same_id);
88         }
89         ///
90         string const getScreenLabel(Buffer const *) const;
91         ///
92         EDITABLE editable() const { return IS_EDITABLE; }
93         ///
94         Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
95         ///
96         void edit(BufferView *, int x, int y, unsigned int button);
97         ///
98         void edit(BufferView * bv, bool front = true);
99         /// 
100         int latex(Buffer const *, std::ostream &,
101                   bool fragile, bool freespace) const;
102         ///
103         std::vector<std::pair<string,string> > const getKeys(Buffer const *) const;
104         ///
105         std::vector<string> const getFiles(Buffer const &) const;
106         ///
107         bool addDatabase(string const &);
108         ///
109         bool delDatabase(string const &);
110         ///
111         bool display() const { return true; } 
112         ///
113         struct Holder {
114                 InsetBibtex * inset;
115                 BufferView * view;
116         };
117
118 private:
119         ///
120         Holder holder;
121 };
122
123 #endif