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