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