2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-11 08:26:02 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/*
|
2002-09-11 08:26:02 +00:00
|
|
|
|
* Common parts of the math LyX insets
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
2001-06-25 00:06:33 +00:00
|
|
|
|
*
|
2002-09-11 08:26:02 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-06-25 00:06:33 +00:00
|
|
|
|
*
|
2002-09-11 08:26:02 +00:00
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
2001-06-25 00:06:33 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2002-03-21 17:42:56 +00:00
|
|
|
|
#ifndef INSET_FORMULABASE_H
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#define INSET_FORMULABASE_H
|
|
|
|
|
|
|
|
|
|
|
2003-02-20 17:39:48 +00:00
|
|
|
|
#include "insets/updatableinset.h"
|
2002-05-26 17:33:14 +00:00
|
|
|
|
#include "frontends/mouse_state.h"
|
2001-10-22 15:37:49 +00:00
|
|
|
|
#include "lyxfont.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-08-02 12:38:20 +00:00
|
|
|
|
#include <boost/weak_ptr.hpp>
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include <iosfwd>
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class Buffer;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
class BufferView;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
class MathAtom;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-02-13 13:15:15 +00:00
|
|
|
|
/// An abstract base class for all math related LyX insets
|
2001-06-25 00:06:33 +00:00
|
|
|
|
class InsetFormulaBase : public UpdatableInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2001-08-03 09:54:48 +00:00
|
|
|
|
InsetFormulaBase();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
virtual int ascent(BufferView *, LyXFont const &) const = 0;
|
|
|
|
|
///
|
|
|
|
|
virtual int descent(BufferView *, LyXFont const &) const = 0;
|
|
|
|
|
///
|
|
|
|
|
virtual int width(BufferView *, LyXFont const &) const = 0;
|
|
|
|
|
///
|
|
|
|
|
virtual void draw(BufferView *,LyXFont const &, int, float &, bool) const = 0;
|
2001-12-05 18:55:45 +00:00
|
|
|
|
/// lowest x coordinate
|
|
|
|
|
virtual int xlow() const;
|
|
|
|
|
/// highest x coordinate
|
|
|
|
|
virtual int xhigh() const;
|
|
|
|
|
/// lowest y coordinate
|
|
|
|
|
virtual int ylow() const;
|
|
|
|
|
/// highest y coordinate
|
|
|
|
|
virtual int yhigh() const;
|
2001-07-06 12:09:32 +00:00
|
|
|
|
|
|
|
|
|
public:
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-03-06 08:10:50 +00:00
|
|
|
|
// Don't use this for AMS validation as long as there is no
|
|
|
|
|
// user-accessible way to override "false positives"
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void validate(LaTeXFeatures &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
|
virtual Inset * clone(Buffer const &, bool same_id = false) const = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual Inset::Code lyxCode() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// what appears in the minibuffer when opening
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual string const editMessage() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
|
virtual void edit(BufferView *, int x, int y, mouse_button::state button);
|
2001-08-15 05:50:39 +00:00
|
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
|
virtual void edit(BufferView *, bool front = true);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void toggleInsetCursor(BufferView *);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void showInsetCursor(BufferView *, bool show = true);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void hideInsetCursor(BufferView *);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
virtual void fitInsetCursor(BufferView *) const;
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void getCursorPos(BufferView *, int &, int &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void toggleInsetSelection(BufferView * bv);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual void insetUnlock(BufferView *);
|
2002-03-21 17:42:56 +00:00
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
|
/// To allow transparent use of math editing functions
|
2003-02-18 11:47:16 +00:00
|
|
|
|
virtual dispatch_result localDispatch(FuncRequest const &);
|
2002-08-15 14:33:14 +00:00
|
|
|
|
/// To allow transparent use of math editing functions
|
|
|
|
|
//virtual void status(FuncRequest const &);
|
2002-03-21 17:42:56 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
virtual std::vector<string> const getLabelList() const;
|
|
|
|
|
///
|
2001-10-12 12:02:49 +00:00
|
|
|
|
virtual MathAtom const & par() const = 0;
|
|
|
|
|
///
|
|
|
|
|
virtual MathAtom & par() = 0;
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
2001-07-17 09:46:07 +00:00
|
|
|
|
virtual void updateLocal(BufferView * bv, bool mark_dirty);
|
2001-10-24 09:16:06 +00:00
|
|
|
|
///
|
2003-03-03 15:59:08 +00:00
|
|
|
|
// And shouldn't this really return a shared_ptr<BufferView> instead?
|
2003-03-06 08:10:50 +00:00
|
|
|
|
BufferView * view() const;
|
2001-11-13 15:04:46 +00:00
|
|
|
|
|
2002-01-03 09:41:26 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool searchForward(BufferView *, string const &,
|
2002-12-01 22:59:25 +00:00
|
|
|
|
bool = true, bool = false);
|
2002-01-03 09:41:26 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool searchBackward(BufferView *, string const &,
|
2002-12-01 22:59:25 +00:00
|
|
|
|
bool = true, bool = false);
|
2002-01-03 09:41:26 +00:00
|
|
|
|
///
|
|
|
|
|
virtual bool isTextInset() const { return true; }
|
2002-02-07 08:19:47 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void mutateToText();
|
2002-02-15 14:07:09 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void revealCodes(BufferView *) const;
|
2002-04-03 13:40:22 +00:00
|
|
|
|
///
|
2002-08-19 10:11:13 +00:00
|
|
|
|
virtual EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
2002-08-15 14:33:14 +00:00
|
|
|
|
///
|
|
|
|
|
bool display() const;
|
2002-10-22 15:15:40 +00:00
|
|
|
|
// return the selection as string
|
|
|
|
|
string selectionAsString() const;
|
2002-01-03 09:41:26 +00:00
|
|
|
|
|
2001-08-01 09:18:21 +00:00
|
|
|
|
private:
|
|
|
|
|
/// unimplemented
|
|
|
|
|
void operator=(const InsetFormulaBase &);
|
2002-02-01 14:56:49 +00:00
|
|
|
|
/// common base for handling accents
|
|
|
|
|
void handleAccent(BufferView * bv, string const & arg, string const & name);
|
2002-12-01 22:59:25 +00:00
|
|
|
|
/// lfun handler
|
2003-02-18 11:47:16 +00:00
|
|
|
|
dispatch_result lfunMousePress(FuncRequest const &);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
2003-02-18 11:47:16 +00:00
|
|
|
|
dispatch_result lfunMouseRelease(FuncRequest const &);
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
2003-02-18 11:47:16 +00:00
|
|
|
|
dispatch_result lfunMouseMotion(FuncRequest const &);
|
2001-11-13 15:04:46 +00:00
|
|
|
|
|
2002-07-04 11:00:51 +00:00
|
|
|
|
protected:
|
2001-10-19 11:25:48 +00:00
|
|
|
|
///
|
2002-08-02 12:38:20 +00:00
|
|
|
|
mutable boost::weak_ptr<BufferView> view_;
|
2001-10-19 11:25:48 +00:00
|
|
|
|
///
|
2001-10-22 15:37:49 +00:00
|
|
|
|
mutable LyXFont font_;
|
2001-11-13 15:04:46 +00:00
|
|
|
|
|
2001-10-24 09:16:06 +00:00
|
|
|
|
protected:
|
2001-11-13 15:04:46 +00:00
|
|
|
|
///
|
|
|
|
|
void metrics(BufferView * bv, LyXFont const & font) const;
|
|
|
|
|
///
|
|
|
|
|
void metrics(BufferView * bv = 0) const;
|
2002-05-15 21:53:28 +00:00
|
|
|
|
///
|
2002-05-30 07:09:54 +00:00
|
|
|
|
void handleFont(BufferView * bv, string const & arg, string const & font);
|
2001-11-13 15:04:46 +00:00
|
|
|
|
|
2001-10-24 09:16:06 +00:00
|
|
|
|
///
|
|
|
|
|
mutable int xo_;
|
|
|
|
|
///
|
|
|
|
|
mutable int yo_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
|
// We don't really mess want around with mathed stuff outside mathed.
|
|
|
|
|
// So do it here.
|
2002-08-15 14:33:14 +00:00
|
|
|
|
void mathDispatch(FuncRequest const &);
|
2001-07-06 12:09:32 +00:00
|
|
|
|
|
2002-11-14 07:48:34 +00:00
|
|
|
|
///
|
|
|
|
|
void releaseMathCursor(BufferView * bv);
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#endif
|