2003-02-17 17:12:50 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file insetbase.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author none
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-02-17 17:12:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSETBASE_H
|
|
|
|
#define INSETBASE_H
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
#include <string>
|
2003-02-18 11:47:16 +00:00
|
|
|
#include <vector>
|
2003-07-27 15:52:05 +00:00
|
|
|
#include <memory>
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2003-09-18 20:18:39 +00:00
|
|
|
class Buffer;
|
2003-03-10 13:33:39 +00:00
|
|
|
class BufferView;
|
2004-01-15 11:58:35 +00:00
|
|
|
class DispatchResult;
|
2003-02-18 11:47:16 +00:00
|
|
|
class FuncRequest;
|
2004-01-15 11:58:35 +00:00
|
|
|
class LaTeXFeatures;
|
2004-01-20 14:25:24 +00:00
|
|
|
class LCursor;
|
2004-01-15 11:58:35 +00:00
|
|
|
class MathInset;
|
2003-05-30 06:48:24 +00:00
|
|
|
class MetricsInfo;
|
2003-06-02 10:03:27 +00:00
|
|
|
class Dimension;
|
2003-05-30 06:48:24 +00:00
|
|
|
class PainterInfo;
|
2004-01-15 11:58:35 +00:00
|
|
|
class UpdatableInset;
|
2003-02-17 17:12:50 +00:00
|
|
|
|
|
|
|
/// Common base class to all insets
|
|
|
|
class InsetBase {
|
|
|
|
public:
|
2003-06-02 10:03:27 +00:00
|
|
|
///
|
2004-01-13 12:28:35 +00:00
|
|
|
typedef ptrdiff_t difference_type;
|
2003-06-02 10:03:27 +00:00
|
|
|
/// short of anything else reasonable
|
2004-01-13 12:28:35 +00:00
|
|
|
typedef size_t size_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for cell indices
|
2004-01-13 12:28:35 +00:00
|
|
|
typedef size_t idx_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for cursor positions
|
2004-01-13 12:28:35 +00:00
|
|
|
typedef ptrdiff_t pos_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for row numbers
|
2004-01-13 12:28:35 +00:00
|
|
|
typedef size_t row_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for column numbers
|
2004-01-13 12:28:35 +00:00
|
|
|
typedef size_t col_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2003-06-16 11:49:38 +00:00
|
|
|
/// virtual base class destructor
|
|
|
|
virtual ~InsetBase() {}
|
|
|
|
/// replicate ourselves
|
2003-07-25 17:11:25 +00:00
|
|
|
virtual std::auto_ptr<InsetBase> clone() const = 0;
|
2003-06-16 11:49:38 +00:00
|
|
|
|
2004-01-15 11:58:35 +00:00
|
|
|
/// identification as math inset
|
|
|
|
virtual MathInset * asMathInset() { return 0; }
|
|
|
|
/// identification as non-math inset
|
|
|
|
virtual UpdatableInset * asUpdatableInset() { return 0; }
|
|
|
|
|
2003-02-18 11:47:16 +00:00
|
|
|
// the real dispatcher
|
2004-01-20 14:25:24 +00:00
|
|
|
DispatchResult dispatch(LCursor & cur, FuncRequest const & cmd);
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
/// cursor enters
|
2004-01-20 14:25:24 +00:00
|
|
|
virtual void edit(LCursor & cur, bool left);
|
2003-11-04 12:36:59 +00:00
|
|
|
/// cursor enters
|
2004-01-20 14:25:24 +00:00
|
|
|
virtual void edit(LCursor & cur, int x, int y);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
/// 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
|
2003-05-30 06:48:24 +00:00
|
|
|
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
2004-01-16 10:55:19 +00:00
|
|
|
/// 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; }
|
2004-01-20 14:25:24 +00:00
|
|
|
|
|
|
|
/// 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<std::string> & /* list */) const {}
|
|
|
|
/// describe content if cursor inside
|
|
|
|
virtual void infoize(std::ostream &) const {}
|
|
|
|
/// describe content if cursor behind
|
|
|
|
virtual void infoize2(std::ostream &) const {}
|
2003-10-17 18:01:15 +00:00
|
|
|
protected:
|
|
|
|
// the real dispatcher
|
2003-10-29 10:47:21 +00:00
|
|
|
virtual
|
2004-01-20 14:25:24 +00:00
|
|
|
DispatchResult priv_dispatch(LCursor & cur, FuncRequest const & cmd);
|
|
|
|
public:
|
|
|
|
/** This is not quite the correct place for this enum. I think
|
|
|
|
the correct would be to let each subclass of Inset declare
|
|
|
|
its own enum code. Actually the notion of an InsetOld::Code
|
|
|
|
should be avoided, but I am not sure how this could be done
|
|
|
|
in a cleaner way. */
|
|
|
|
enum Code {
|
|
|
|
///
|
|
|
|
NO_CODE, // 0
|
|
|
|
///
|
|
|
|
TOC_CODE, // do these insets really need a code? (ale)
|
|
|
|
///
|
|
|
|
QUOTE_CODE,
|
|
|
|
///
|
|
|
|
MARK_CODE,
|
|
|
|
///
|
|
|
|
REF_CODE,
|
|
|
|
///
|
|
|
|
URL_CODE, // 5
|
|
|
|
///
|
|
|
|
HTMLURL_CODE,
|
|
|
|
///
|
|
|
|
SEPARATOR_CODE,
|
|
|
|
///
|
|
|
|
ENDING_CODE,
|
|
|
|
///
|
|
|
|
LABEL_CODE,
|
|
|
|
///
|
|
|
|
NOTE_CODE, // 10
|
|
|
|
///
|
|
|
|
ACCENT_CODE,
|
|
|
|
///
|
|
|
|
MATH_CODE,
|
|
|
|
///
|
|
|
|
INDEX_CODE,
|
|
|
|
///
|
|
|
|
INCLUDE_CODE,
|
|
|
|
///
|
|
|
|
GRAPHICS_CODE, // 15
|
|
|
|
///
|
|
|
|
BIBITEM_CODE,
|
|
|
|
///
|
|
|
|
BIBTEX_CODE,
|
|
|
|
///
|
|
|
|
TEXT_CODE,
|
|
|
|
///
|
|
|
|
ERT_CODE,
|
|
|
|
///
|
|
|
|
FOOT_CODE, // 20
|
|
|
|
///
|
|
|
|
MARGIN_CODE,
|
|
|
|
///
|
|
|
|
FLOAT_CODE,
|
|
|
|
///
|
|
|
|
WRAP_CODE,
|
|
|
|
///
|
|
|
|
SPACE_CODE, // 25
|
|
|
|
///
|
|
|
|
SPECIALCHAR_CODE,
|
|
|
|
///
|
|
|
|
TABULAR_CODE,
|
|
|
|
///
|
|
|
|
EXTERNAL_CODE,
|
|
|
|
#if 0
|
|
|
|
///
|
|
|
|
THEOREM_CODE,
|
|
|
|
#endif
|
|
|
|
///
|
|
|
|
CAPTION_CODE,
|
|
|
|
///
|
|
|
|
MATHMACRO_CODE, // 30
|
|
|
|
///
|
|
|
|
ERROR_CODE,
|
|
|
|
///
|
|
|
|
CITE_CODE,
|
|
|
|
///
|
|
|
|
FLOAT_LIST_CODE,
|
|
|
|
///
|
|
|
|
INDEX_PRINT_CODE,
|
|
|
|
///
|
|
|
|
OPTARG_CODE, // 35
|
|
|
|
///
|
|
|
|
ENVIRONMENT_CODE,
|
|
|
|
///
|
|
|
|
HFILL_CODE,
|
|
|
|
///
|
|
|
|
NEWLINE_CODE,
|
|
|
|
///
|
|
|
|
LINE_CODE,
|
|
|
|
///
|
|
|
|
BRANCH_CODE, // 40
|
|
|
|
///
|
|
|
|
BOX_CODE,
|
|
|
|
///
|
|
|
|
CHARSTYLE_CODE,
|
|
|
|
///
|
|
|
|
VSPACE_CODE,
|
|
|
|
///
|
|
|
|
MATHGRID_CODE,
|
|
|
|
///
|
|
|
|
MATHHULL_CODE
|
|
|
|
};
|
|
|
|
/// returns LyX code associated with the inset. Used for TOC, ...)
|
|
|
|
virtual InsetBase::Code lyxCode() const { return NO_CODE; }
|
|
|
|
|
2003-02-17 17:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|