]> git.lyx.org Git - lyx.git/blob - src/insets/insetbase.h
fix #832
[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 <vector>
16
17 class BufferView;
18 class FuncRequest;
19
20 /** Dispatch result codes
21                 DISPATCHED          = the inset catched the action
22                 DISPATCHED_NOUPDATE = the inset catched the action and no update
23                                 is needed here to redraw the inset
24                 FINISHED            = the inset must be unlocked as a result
25                                 of the action
26                 FINISHED_RIGHT      = FINISHED, but put the cursor to the RIGHT of
27                                 the inset.
28                 FINISHED_UP         = FINISHED, but put the cursor UP of
29                                 the inset.
30                 FINISHED_DOWN       = FINISHED, but put the cursor DOWN of
31                                 the inset.
32                 UNDISPATCHED        = the action was not catched, it should be
33                                 dispatched by lower level insets
34 */
35 enum dispatch_result {
36         UNDISPATCHED = 0,
37         DISPATCHED,
38         DISPATCHED_NOUPDATE,
39         FINISHED,
40         FINISHED_RIGHT,
41         FINISHED_UP,
42         FINISHED_DOWN,
43         DISPATCHED_POP
44 };
45
46
47 /// Common base class to all insets
48 class InsetBase {
49 public:
50         /// type for cell indices
51         typedef size_t                   idx_type;
52         /// type for cursor positions
53         typedef size_t                   pos_type;
54         /// type for row numbers
55         typedef size_t                   row_type;
56         /// type for column numbers
57         typedef size_t                   col_type;
58
59         // the real dispatcher
60         virtual dispatch_result dispatch
61                 (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
62
63         /// small wrapper for the time being
64         virtual dispatch_result localDispatch(FuncRequest const & cmd);
65
66         ///
67         virtual ~InsetBase() {}
68
69         /// Methods to cache and retrieve a cached BufferView.
70         virtual void cache(BufferView *) const {}
71         ///
72         virtual BufferView * view() const { return 0; }
73 };
74
75 #endif