]> git.lyx.org Git - lyx.git/blob - src/insets/insetbase.h
Enable convertDefault.sh to run even if its executable bit is not set.
[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 "LString.h"
16
17 #include <vector>
18 #include <memory>
19
20 class BufferView;
21 class FuncRequest;
22 class MetricsInfo;
23 class Dimension;
24 class PainterInfo;
25 class LaTeXFeatures;
26
27 /** Dispatch result codes
28                 DISPATCHED          = the inset catched the action
29                 DISPATCHED_NOUPDATE = the inset catched the action and no update
30                                 is needed here to redraw the inset
31                 FINISHED            = the inset must be unlocked as a result
32                                 of the action
33                 FINISHED_RIGHT      = FINISHED, but put the cursor to the RIGHT of
34                                 the inset.
35                 FINISHED_UP         = FINISHED, but put the cursor UP of
36                                 the inset.
37                 FINISHED_DOWN       = FINISHED, but put the cursor DOWN of
38                                 the inset.
39                 UNDISPATCHED        = the action was not catched, it should be
40                                 dispatched by lower level insets
41 */
42 enum dispatch_result {
43         UNDISPATCHED = 0,
44         DISPATCHED,
45         DISPATCHED_NOUPDATE,
46         FINISHED,
47         FINISHED_RIGHT,
48         FINISHED_UP,
49         FINISHED_DOWN,
50         DISPATCHED_POP
51 };
52
53
54 /// Common base class to all insets
55 class InsetBase {
56 public:
57         ///
58         typedef int      difference_type;
59         /// short of anything else reasonable
60         typedef size_t   size_type;
61         /// type for cell indices
62         typedef size_t  idx_type;
63         /// type for cursor positions
64         typedef size_t  pos_type;
65         /// type for row numbers
66         typedef size_t  row_type;
67         /// type for column numbers
68         typedef size_t  col_type;
69
70         /// virtual base class destructor
71         virtual ~InsetBase() {}
72         /// replicate ourselves
73         virtual std::auto_ptr<InsetBase> clone() const = 0;
74
75         // the real dispatcher
76         virtual dispatch_result dispatch
77                 (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
78
79         /// small wrapper for the time being
80         virtual dispatch_result localDispatch(FuncRequest const & cmd);
81         /// compute the size of the object returned in dim
82         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
83         /// draw inset and update (xo, yo)-cache
84         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
85
86         /// Methods to cache and retrieve a cached BufferView.
87         virtual void cache(BufferView *) const {}
88         ///
89         virtual BufferView * view() const { return 0; }
90         /// request "external features"
91         virtual void validate(LaTeXFeatures &) const {}
92         /// fill in all labels in the inset
93         virtual void getLabelList(std::vector<string> &) const {}
94 };
95
96 #endif