]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
0ca6e3de191715c03728272716fb1915ff97a8da
[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 "insetcommand.h"
20 #include <vector>
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() : InsetCommand("bibitem") { counter = 1; }
34         ///
35         explicit
36         InsetBibKey(string const & key, string const & label = string());
37         ///
38         explicit
39         InsetBibKey(InsetBibKey const *);
40         ///
41         ~InsetBibKey();
42         ///
43         Inset * Clone() const { return new InsetBibKey(this); }
44         /// Currently \bibitem is used as a LyX2.x command, so we need this method.
45         void Write(Buffer const *, std::ostream &) const;
46         ///
47         void Read(Buffer const *, LyXLex & lex);
48         ///
49         virtual string getScreenLabel() const;
50         ///
51         void Edit(BufferView *, int x, int y, unsigned int button);
52         ///
53         EDITABLE Editable() const {
54                 return IS_EDITABLE;
55         }
56         /// A user can't neither insert nor delete this inset
57         bool Deletable() const {
58                 return false;
59         }
60         ///
61         void setCounter(int);
62         ///
63         int  getCounter() const { return counter; }
64         ///
65         void callback( FD_bibitem_form *, long );
66         ///
67         struct Holder {
68                 InsetBibKey * inset;
69                 BufferView * view;
70         };
71  
72  private:
73         ///
74         int counter;
75         ///
76         Holder holder;
77 };
78
79
80 /** Used to insert BibTeX's information 
81   */
82 class InsetBibtex: public InsetCommand {
83 public:
84         /// 
85         InsetBibtex() : InsetCommand("BibTeX") { owner = 0; }
86         ///
87         InsetBibtex(string const & dbase, string const & style,
88                     Buffer *);
89         ///
90         ~InsetBibtex();
91
92         ///
93         Inset * Clone() const {
94                 return new InsetBibtex(getCmdName(), getOptions(), 0);
95         }
96         ///  
97         Inset::Code LyxCode() const
98         {
99                 return Inset::BIBTEX_CODE;
100         }
101         ///
102         string getScreenLabel() const;
103         ///
104         void Edit(BufferView *, int x, int y, unsigned int button);
105         /// 
106         int Latex(Buffer const *, std::ostream &, bool fragile, bool freespace) const;
107         ///
108         std::vector< std::pair<string,string> > getKeys() const;
109         ///
110         EDITABLE Editable() const {
111                 return IS_EDITABLE;
112         }
113         ///
114         bool addDatabase(string const &);
115         ///
116         bool delDatabase(string const &);
117         ///
118         bool display() const { return true; } 
119
120         struct Holder {
121                 InsetBibtex * inset;
122                 BufferView * view;
123         };
124
125 private:
126         ///
127         mutable Buffer * owner;
128
129         ///
130         Holder holder;
131 };
132
133 #endif