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;
|
2003-02-18 11:47:16 +00:00
|
|
|
class FuncRequest;
|
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;
|
2003-06-02 16:14:33 +00:00
|
|
|
class LaTeXFeatures;
|
2003-10-29 10:47:21 +00:00
|
|
|
class DispatchResult;
|
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
|
|
|
///
|
|
|
|
typedef int difference_type;
|
|
|
|
/// short of anything else reasonable
|
|
|
|
typedef size_t size_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for cell indices
|
2003-06-02 10:03:27 +00:00
|
|
|
typedef size_t idx_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for cursor positions
|
2003-06-02 10:03:27 +00:00
|
|
|
typedef size_t pos_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for row numbers
|
2003-06-02 10:03:27 +00:00
|
|
|
typedef size_t row_type;
|
2003-02-18 11:47:16 +00:00
|
|
|
/// type for column numbers
|
2003-06-02 10:03:27 +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
|
|
|
|
2003-02-18 11:47:16 +00:00
|
|
|
// the real dispatcher
|
2003-10-29 10:47:21 +00:00
|
|
|
DispatchResult
|
2003-10-17 18:01:15 +00:00
|
|
|
dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
|
|
|
|
// the real dispatcher
|
2003-12-01 13:35:49 +00:00
|
|
|
DispatchResult dispatch(FuncRequest const & cmd);
|
2003-02-18 11:47:16 +00:00
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
/// cursor enters
|
|
|
|
virtual void edit(BufferView * bv, bool left);
|
|
|
|
/// cursor enters
|
|
|
|
virtual void edit(BufferView * bv, int x, int y);
|
|
|
|
|
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;
|
2003-02-17 17:12:50 +00:00
|
|
|
|
2003-06-02 16:14:33 +00:00
|
|
|
/// request "external features"
|
|
|
|
virtual void validate(LaTeXFeatures &) const {}
|
2003-09-18 20:18:39 +00:00
|
|
|
/// Appends \c list with all labels found within this inset.
|
|
|
|
virtual void getLabelList(Buffer const &,
|
2003-10-06 15:43:21 +00:00
|
|
|
std::vector<std::string> & /* list */) const {}
|
2003-10-17 18:01:15 +00:00
|
|
|
protected:
|
|
|
|
// the real dispatcher
|
2003-10-29 10:47:21 +00:00
|
|
|
virtual
|
|
|
|
DispatchResult
|
|
|
|
priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
|
2003-02-17 17:12:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|