// -*- C++ -*-
/* This file is part of*
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2000 The LyX Team.
- *
+ *
+ * Copyright 2000-2001 The LyX Team.
+ *
* ====================================================== */
#ifndef INSET_CITE_H
#endif
#include "insetcommand.h"
-#include "bibforms.h"
-#include <vector>
-class Buffer;
-
-/** Used to insert citations
+/** Used to insert citations
*/
-class InsetCitation: public InsetCommand {
+class InsetCitation : public InsetCommand {
public:
///
- enum State {
- CANCEL,
- OK,
- DOWN,
- UP,
- DELETE,
- ADD,
- BIBBRSR,
- CITEBRSR,
- ON,
- OFF
- };
- ///
- InsetCitation() : InsetCommand("cite") {}
+ InsetCitation(InsetCommandParams const &, bool same_id = false);
///
- explicit
- InsetCitation(string const & key, string const & note = string());
- ///
- ~InsetCitation();
- ///
- Inset * Clone() const {
- return new InsetCitation(getContents(), getOptions());
+ Inset * clone(Buffer const &, bool same_id = false) const {
+ return new InsetCitation(params(), same_id);
}
- ///
- string getScreenLabel()const;
- ///
- void Edit(BufferView *, int x, int y, unsigned int button);
///
- void callback( FD_citation_form *, State );
- ///
- EDITABLE Editable() const {
- return IS_EDITABLE;
- }
+ string const getScreenLabel(Buffer const *) const;
+ ///
+ EDITABLE editable() const { return IS_EDITABLE; }
+ ///
+ Inset::Code lyxCode() const { return Inset::CITE_CODE; }
///
- struct Holder {
- InsetCitation * inset;
- BufferView * view;
+ void edit(BufferView *, int, int, unsigned int);
+ ///
+ void edit(BufferView * bv, bool front = true);
+ ///
+ int ascii(Buffer const *, std::ostream &, int linelen) const;
+ ///
+ int latex(Buffer const *, std::ostream &, bool, bool) const;
+ ///
+ void validate(LaTeXFeatures &) const;
+private:
+ struct Cache {
+ ///
+ enum Style {
+ ///
+ BASIC,
+ ///
+ NATBIB_AY,
+ ///
+ NATBIB_NUM
+ };
+ ///
+ Cache() : style(BASIC) {}
+ ///
+ Style style;
+ ///
+ InsetCommandParams params;
+ ///
+ string generated_label;
+ ///
+ string screen_label;
};
-private:
- ///
- void setSize( FD_citation_form *, int, bool ) const;
+ /// This function does the donkey work of creating the pretty label
+ string const generateLabel(Buffer const *) const;
///
- void setBibButtons( FD_citation_form *, State ) const;
- ///
- void setCiteButtons( FD_citation_form *, State ) const;
+ Cache::Style getStyle(Buffer const * buffer) const;
+
///
- void updateBrowser( FL_OBJECT *, std::vector<string> const & ) const;
- ///
- Holder holder;
+ mutable Cache cache;
};
#endif // INSET_CITE_H