]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
patch from Dekel
[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
21 class Buffer;
22
23 /** Used to insert citations  
24  */
25 class InsetCitation: public InsetCommand {
26 public:
27         ///
28         InsetCitation() : InsetCommand("cite") {}
29         ///
30         explicit
31         InsetCitation(string const & key, string const & note = string());
32         ///
33         ~InsetCitation();
34         ///
35         Inset * Clone() const {
36                 return new InsetCitation(contents, options);
37         }
38         ///
39         string getScreenLabel()const;
40         ///
41         void Edit(BufferView *, int x, int y, unsigned int button);
42         ///
43         EDITABLE Editable() const {
44                 return IS_EDITABLE;
45         }
46         int Ascii(std::ostream &) const;
47         ///
48         struct Holder {
49                 InsetCitation * inset;
50                 BufferView * view;
51         };
52
53 private:
54         ///
55         Holder holder;
56 };
57
58
59 /** Used to insert bibitem's information (key and label)
60   
61   Must be automatically inserted as the first object in a
62   bibliography paragraph. 
63   */
64 class InsetBibKey: public InsetCommand {
65 public:
66         ///
67         InsetBibKey() : InsetCommand("bibitem") { counter = 1; }
68         ///
69         explicit
70         InsetBibKey(string const & key, string const & label = string());
71         ///
72         explicit
73         InsetBibKey(InsetBibKey const *);
74         ///
75         ~InsetBibKey();
76         ///
77         Inset * Clone() const { return new InsetBibKey(this); }
78         /// Currently \bibitem is used as a LyX2.x command, so we need this method.
79         void Write(std::ostream &) const;
80         ///
81         virtual string getScreenLabel() const;
82         ///
83         void Edit(BufferView *, int x, int y, unsigned int button);
84         ///
85         EDITABLE Editable() const {
86                 return IS_EDITABLE;
87         }
88         /// A user can't neither insert nor delete this inset
89         bool Deletable() const {
90                 return false;
91         }
92         ///
93         void setCounter(int);
94         ///
95         int  getCounter() const { return counter; }
96         ///
97         struct Holder {
98                 InsetBibKey * inset;
99                 BufferView * view;
100         };
101
102  private:
103         ///
104         int counter;
105
106         ///
107         Holder holder;
108 };
109
110
111 /** Used to insert BibTeX's information 
112   */
113 class InsetBibtex: public InsetCommand {
114 public:
115         /// 
116         InsetBibtex() : InsetCommand("BibTeX") { owner = 0; }
117         ///
118         InsetBibtex(string const & dbase, string const & style,
119                     Buffer *);
120         ///
121         ~InsetBibtex();
122
123         ///
124         Inset * Clone() const {
125                 return new InsetBibtex(contents, options, 0);
126         }
127         ///  
128         Inset::Code LyxCode() const
129         {
130                 return Inset::BIBTEX_CODE;
131         }
132         ///
133         string getScreenLabel() const;
134         ///
135         void Edit(BufferView *, int x, int y, unsigned int button);
136         /// 
137         int Latex(std::ostream &, bool fragile, bool freespace) const;
138         ///
139         string getKeys(char delim);
140         ///
141         EDITABLE Editable() const {
142                 return IS_EDITABLE;
143         }
144         ///
145         bool addDatabase(string const &);
146         ///
147         bool delDatabase(string const &);
148         ///
149         bool display() const { return true; } 
150
151         struct Holder {
152                 InsetBibtex * inset;
153                 BufferView * view;
154         };
155
156 private:
157         ///
158         mutable Buffer * owner;
159
160         ///
161         Holder holder;
162 };
163
164 #endif