]> git.lyx.org Git - lyx.git/blob - src/insets/insetbib.h
First step towards unified insets...
[lyx.git] / src / insets / insetbib.h
1 // -*- C++ -*-
2 /**
3  * \file insetbib.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef INSET_BIB_H
13 #define INSET_BIB_H
14
15
16 #include <vector>
17 #include "insetcommand.h"
18
19 class Buffer;
20
21 /** Used to insert bibitem's information (key and label)
22
23   Must be automatically inserted as the first object in a
24   bibliography paragraph.
25   */
26 class InsetBibKey : public InsetCommand {
27 public:
28         ///
29         InsetBibKey(InsetCommandParams const &);
30         ///
31         ~InsetBibKey();
32         ///
33         Inset * clone(Buffer const &, bool same_id = false) const;
34         /** Currently \bibitem is used as a LyX2.x command,
35             so we need this method.
36         */
37         void write(Buffer const *, std::ostream &) const;
38         ///
39         void read(Buffer const *, LyXLex & lex);
40         ///
41         virtual string const getScreenLabel(Buffer const *) const;
42         ///
43         void edit(BufferView *, int x, int y, mouse_button::state button);
44         ///
45         void edit(BufferView * bv, bool front = true);
46         ///
47         EDITABLE editable() const { return IS_EDITABLE; }
48         /// keep .lyx format compatible
49         bool directWrite() const { return true; }
50         ///
51         void setCounter(int);
52         ///
53         int  getCounter() const { return counter; }
54         ///
55         string const getBibLabel() const;
56         ///
57         struct Holder {
58                 InsetBibKey * inset;
59                 BufferView * view;
60         };
61
62 private:
63         ///
64         int counter;
65         ///
66         Holder holder;
67         ///
68         static int key_counter;
69 };
70
71
72 /** Used to insert BibTeX's information
73   */
74 class InsetBibtex : public InsetCommand {
75 public:
76         ///
77         InsetBibtex(InsetCommandParams const &, bool same_id = false);
78         ///
79         ~InsetBibtex();
80         ///
81         Inset * clone(Buffer const &, bool same_id = false) const {
82                 return new InsetBibtex(params(), same_id);
83         }
84         ///
85         string const getScreenLabel(Buffer const *) const;
86         ///
87         EDITABLE editable() const { return IS_EDITABLE; }
88         ///
89         Inset::Code lyxCode() const { return Inset::BIBTEX_CODE; }
90         ///
91         void edit(BufferView *, int x, int y, mouse_button::state button);
92         ///
93         void edit(BufferView * bv, bool front = true);
94         ///
95         int latex(Buffer const *, std::ostream &,
96                   bool fragile, bool freespace) const;
97         ///
98         std::vector<std::pair<string,string> > const getKeys(Buffer const *) const;
99         ///
100         std::vector<string> const getFiles(Buffer const &) const;
101         ///
102         bool addDatabase(string const &);
103         ///
104         bool delDatabase(string const &);
105         ///
106         bool display() const { return true; }
107         ///
108         struct Holder {
109                 InsetBibtex * inset;
110                 BufferView * view;
111         };
112
113 private:
114         ///
115         Holder holder;
116 };
117
118 #endif