]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
Update citations if the insetbib key has changed.
[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-2000 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 struct FD_bibitem_form;
24
25 /** Used to insert bibitem's information (key and label)
26   
27   Must be automatically inserted as the first object in a
28   bibliography paragraph. 
29   */
30 class InsetBibKey : public InsetCommand {
31 public:
32         ///
33         InsetBibKey(InsetCommandParams const &);
34         ///
35         ~InsetBibKey();
36         ///
37         Inset * Clone(Buffer const &) const;
38         /** Currently \bibitem is used as a LyX2.x command,
39             so we need this method.
40         */
41         void Write(Buffer const *, std::ostream &) const;
42         ///
43         void Read(Buffer const *, LyXLex & lex);
44         ///
45         virtual string const getScreenLabel() const;
46         ///
47         void Edit(BufferView *, int x, int y, unsigned int button);
48         ///
49         EDITABLE Editable() const {
50                 return IS_EDITABLE;
51         }
52         /// A user can't neither insert nor delete this inset
53         bool Deletable() const {
54                 return false;
55         }
56         ///
57         void setCounter(int);
58         ///
59         int  getCounter() const { return counter; }
60         ///
61         string const getBibLabel() const;
62         ///
63         void callback( FD_bibitem_form *, long );
64         ///
65         struct Holder {
66                 InsetBibKey * inset;
67                 BufferView * view;
68         };
69  
70 private:
71         ///
72         int counter;
73         ///
74         Holder holder;
75         ///
76         static int key_counter;
77 };
78
79
80 /** Used to insert BibTeX's information 
81   */
82 class InsetBibtex : public InsetCommand {
83 public:
84         ///
85         InsetBibtex(InsetCommandParams const &);
86         ///
87         ~InsetBibtex();
88         ///
89         Inset * Clone(Buffer const &) const {
90                 return new InsetBibtex(params());
91         }
92         ///
93         string const getScreenLabel() const;
94         ///
95         EDITABLE Editable() const { return IS_EDITABLE; }
96         ///
97         Inset::Code LyxCode() const { return Inset::BIBTEX_CODE; }
98         ///
99         void Edit(BufferView *, int x, int y, unsigned int button);
100         /// 
101         int Latex(Buffer const *, std::ostream &,
102                   bool fragile, bool freespace) const;
103         ///
104         std::vector<std::pair<string,string> > const getKeys(Buffer const *) const;
105         ///
106         bool addDatabase(string const &);
107         ///
108         bool delDatabase(string const &);
109         ///
110         bool display() const { return true; } 
111         ///
112         struct Holder {
113                 InsetBibtex * inset;
114                 BufferView * view;
115         };
116
117 private:
118         ///
119         Holder holder;
120 };
121
122 #endif