// -*- C++ -*- /** * \file insetbase.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author none * * Full author contact details are available in file CREDITS. */ #ifndef INSETBASE_H #define INSETBASE_H #include #include #include class Buffer; class BufferView; class DispatchResult; class FuncRequest; class LaTeXFeatures; class MathInset; class MetricsInfo; class Dimension; class PainterInfo; class UpdatableInset; /// Common base class to all insets class InsetBase { public: /// typedef ptrdiff_t difference_type; /// short of anything else reasonable typedef size_t size_type; /// type for cell indices typedef size_t idx_type; /// type for cursor positions typedef ptrdiff_t pos_type; /// type for row numbers typedef size_t row_type; /// type for column numbers typedef size_t col_type; /// virtual base class destructor virtual ~InsetBase() {} /// replicate ourselves virtual std::auto_ptr clone() const = 0; /// identification as math inset virtual MathInset * asMathInset() { return 0; } /// identification as non-math inset virtual UpdatableInset * asUpdatableInset() { return 0; } // the real dispatcher DispatchResult dispatch(BufferView & bv, FuncRequest const & cmd); /// cursor enters virtual void edit(BufferView * bv, bool left); /// cursor enters virtual void edit(BufferView * bv, int x, int y); /// compute the size of the object returned in dim virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0; /// draw inset and update (xo, yo)-cache virtual void draw(PainterInfo & pi, int x, int y) const = 0; /// request "external features" virtual void validate(LaTeXFeatures &) const {} /// Appends \c list with all labels found within this inset. virtual void getLabelList(Buffer const &, std::vector & /* list */) const {} /// last drawn position for 'important' insets virtual int x() const { return 0; } /// last drawn position for 'important' insets virtual int y() const { return 0; } /// number of embedded cells virtual size_t nargs() const { return 0; } /// number of rows in gridlike structures virtual size_t nrows() const { return 0; } /// number of columns in gridlike structures virtual size_t ncols() const { return 0; } protected: // the real dispatcher virtual DispatchResult priv_dispatch(BufferView & bv, FuncRequest const & cmd); }; #endif