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