4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "support/std_string.h"
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
33 FINISHED_RIGHT = FINISHED, but put the cursor to the RIGHT of
35 FINISHED_UP = FINISHED, but put the cursor UP of
37 FINISHED_DOWN = FINISHED, but put the cursor DOWN of
39 UNDISPATCHED = the action was not catched, it should be
40 dispatched by lower level insets
42 enum dispatch_result {
53 /** \c DispatchResult is a wrapper for dispatch_result.
54 * It can be forward-declared and passed as a function argument without
55 * having to expose insetbase.h.
57 class DispatchResult {
60 DispatchResult(dispatch_result val) : val_(val) {}
61 operator dispatch_result() const{ return val_; }
66 /// Common base class to all insets
70 typedef int difference_type;
71 /// short of anything else reasonable
72 typedef size_t size_type;
73 /// type for cell indices
74 typedef size_t idx_type;
75 /// type for cursor positions
76 typedef size_t pos_type;
77 /// type for row numbers
78 typedef size_t row_type;
79 /// type for column numbers
80 typedef size_t col_type;
82 /// virtual base class destructor
83 virtual ~InsetBase() {}
84 /// replicate ourselves
85 virtual std::auto_ptr<InsetBase> clone() const = 0;
87 // the real dispatcher
88 virtual dispatch_result dispatch
89 (FuncRequest const & cmd, idx_type & idx, pos_type & pos);
91 /// small wrapper for the time being
92 virtual dispatch_result localDispatch(FuncRequest const & cmd);
93 /// compute the size of the object returned in dim
94 virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
95 /// draw inset and update (xo, yo)-cache
96 virtual void draw(PainterInfo & pi, int x, int y) const = 0;
98 /// Methods to cache and retrieve a cached BufferView.
99 virtual void cache(BufferView *) const {}
101 virtual BufferView * view() const { return 0; }
102 /// request "external features"
103 virtual void validate(LaTeXFeatures &) const {}
104 /// fill in all labels in the inset
105 virtual void getLabelList(std::vector<string> &) const {}