]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
simplificatons
[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() 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 {
51                 return IS_EDITABLE;
52         }
53         /// A user can't neither insert nor delete this inset
54         bool deletable() const {
55                 return false;
56         }
57         ///
58         void setCounter(int);
59         ///
60         int  getCounter() const { return counter; }
61         ///
62         string const getBibLabel() const;
63         ///
64         struct Holder {
65                 InsetBibKey * inset;
66                 BufferView * view;
67         };
68  
69 private:
70         ///
71         int counter;
72         ///
73         Holder holder;
74         ///
75         static int key_counter;
76 };
77
78
79 /** Used to insert BibTeX's information 
80   */
81 class InsetBibtex : public InsetCommand {
82 public:
83         ///
84         InsetBibtex(InsetCommandParams const &, bool same_id = false);
85         ///
86         ~InsetBibtex();
87         ///
88         Inset * clone(Buffer const &, bool same_id = false) const {
89                 return new InsetBibtex(params(), same_id);
90         }
91         ///
92         string const getScreenLabel() const;
93         ///
94         EDITABLE editable() const { return IS_EDITABLE; }
95         ///
96         Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
97         ///
98         void edit(BufferView *, int x, int y, unsigned int button);
99         ///
100         void edit(BufferView * bv, bool front = true);
101         /// 
102         int latex(Buffer const *, std::ostream &,
103                   bool fragile, bool freespace) const;
104         ///
105         std::vector<std::pair<string,string> > const getKeys(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