]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
b598ec57d7f1be5764fe4218c1cff016e6023414
[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         virtual string getScreenLabel() const;
48         ///
49         void Edit(BufferView *, int x, int y, unsigned int button);
50         ///
51         EDITABLE Editable() const {
52                 return IS_EDITABLE;
53         }
54         /// A user can't neither insert nor delete this inset
55         bool Deletable() const {
56                 return false;
57         }
58         ///
59         void setCounter(int);
60         ///
61         int  getCounter() const { return counter; }
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
77
78 /** Used to insert BibTeX's information 
79   */
80 class InsetBibtex: public InsetCommand {
81 public:
82         /// 
83         InsetBibtex() : InsetCommand("BibTeX") { owner = 0; }
84         ///
85         InsetBibtex(string const & dbase, string const & style,
86                     Buffer *);
87         ///
88         ~InsetBibtex();
89
90         ///
91         Inset * Clone() const {
92                 return new InsetBibtex(getCmdName(), getOptions(), 0);
93         }
94         ///  
95         Inset::Code LyxCode() const
96         {
97                 return Inset::BIBTEX_CODE;
98         }
99         ///
100         string getScreenLabel() const;
101         ///
102         void Edit(BufferView *, int x, int y, unsigned int button);
103         /// 
104         int Latex(Buffer const *, std::ostream &, bool fragile, bool freespace) const;
105         ///
106         std::vector< std::pair<string,string> > getKeys() const;
107         ///
108         EDITABLE Editable() const {
109                 return IS_EDITABLE;
110         }
111         ///
112         bool addDatabase(string const &);
113         ///
114         bool delDatabase(string const &);
115         ///
116         bool display() const { return true; } 
117
118         struct Holder {
119                 InsetBibtex * inset;
120                 BufferView * view;
121         };
122
123 private:
124         ///
125         mutable Buffer * owner;
126
127         ///
128         Holder holder;
129 };
130
131 #endif