]> git.lyx.org Git - lyx.git/blob - src/insets/insetbase.h
* buffer.[Ch]:
[lyx.git] / src / insets / insetbase.h
1 // -*- C++ -*-
2 /**
3  * \file insetbase.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author none
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETBASE_H
13 #define INSETBASE_H
14
15 #include <string>
16 #include <vector>
17 #include <memory>
18
19 class Buffer;
20 class BufferView;
21 class FuncRequest;
22 class MetricsInfo;
23 class Dimension;
24 class PainterInfo;
25 class LaTeXFeatures;
26 class DispatchResult;
27
28 /// Common base class to all insets
29 class InsetBase {
30 public:
31         ///
32         typedef int      difference_type;
33         /// short of anything else reasonable
34         typedef size_t   size_type;
35         /// type for cell indices
36         typedef size_t  idx_type;
37         /// type for cursor positions
38         typedef size_t  pos_type;
39         /// type for row numbers
40         typedef size_t  row_type;
41         /// type for column numbers
42         typedef size_t  col_type;
43
44         /// virtual base class destructor
45         virtual ~InsetBase() {}
46         /// replicate ourselves
47         virtual std::auto_ptr<InsetBase> clone() const = 0;
48
49         // the real dispatcher
50         DispatchResult
51         dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
52         // the real dispatcher
53         DispatchResult dispatch(FuncRequest const & cmd);
54
55         /// cursor enters
56         virtual void edit(BufferView * bv, bool left);
57         /// cursor enters
58         virtual void edit(BufferView * bv, int x, int y);
59
60         /// compute the size of the object returned in dim
61         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
62         /// draw inset and update (xo, yo)-cache
63         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
64
65         /// request "external features"
66         virtual void validate(LaTeXFeatures &) const {}
67         /// Appends \c list with all labels found within this inset.
68         virtual void getLabelList(Buffer const &,
69                                   std::vector<std::string> & /* list */) const {}
70 protected:
71         // the real dispatcher
72         virtual
73         DispatchResult
74         priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
75 };
76
77 #endif