]> git.lyx.org Git - lyx.git/blob - src/insets/insetbase.h
dispatchresult -> DispatchResult
[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
54         dispatch(FuncRequest const & cmd);
55
56         /// compute the size of the object returned in dim
57         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
58         /// draw inset and update (xo, yo)-cache
59         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
60
61         /// request "external features"
62         virtual void validate(LaTeXFeatures &) const {}
63         /// Appends \c list with all labels found within this inset.
64         virtual void getLabelList(Buffer const &,
65                                   std::vector<std::string> & /* list */) const {}
66 protected:
67         // the real dispatcher
68         virtual
69         DispatchResult
70         priv_dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
71 };
72
73 #endif