]> git.lyx.org Git - lyx.git/blob - src/dispatchresult.h
Add support for the jurabib package (www.jurabib.org), a package for elegant BibTeX...
[lyx.git] / src / dispatchresult.h
1 // -*- C++ -*-
2 /**
3  * \file dispatchresult.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  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef DISPATCH_RESULT_H
14 #define DISPATCH_RESULT_H
15
16 /** Dispatch result codes
17         NONE                = no special action required
18         FINISHED_LEFT       = the cursor leaves the inset to the LEFT
19                               as consequence of this action
20         FINISHED_RIGHT      = FINISHED, but move the cursor RIGHT from
21                         the inset.
22         FINISHED_UP         = FINISHED, but move the cursor UP from
23                         the inset.
24         FINISHED_DOWN       = FINISHED, but move the cursor DOWN from
25                         the inset.
26 */
27 enum dispatch_result_t {
28         NONE = 0,
29         FINISHED_LEFT,
30         FINISHED_RIGHT,
31         FINISHED_UP,
32         FINISHED_DOWN
33 };
34
35
36 /** \c DispatchResult is a wrapper for dispatch_result_t.
37  *  It can be forward-declared and passed as a function argument without
38  *  having to expose insetbase.h.
39  */
40 class DispatchResult {
41 public:
42         DispatchResult()
43                 : dispatched_(false), val_(NONE) {}
44         explicit
45         DispatchResult(bool dis)
46                 : dispatched_(dis), update_(false), val_(NONE) {}
47         DispatchResult(bool dis, bool update)
48                 : dispatched_(dis), update_(update), val_(NONE) {}
49         DispatchResult(bool dis, dispatch_result_t val)
50                 : dispatched_(dis), update_(true), val_(val) {}
51         dispatch_result_t val() const { return val_; }
52         void val(dispatch_result_t drt) {
53                 val_ = drt;
54         }
55         bool dispatched() const {
56                 return dispatched_;
57         }
58         void dispatched(bool dis) {
59                 dispatched_ = dis;
60         }
61         bool update() const {
62                 return update_;
63         }
64         void update(bool up) {
65                 update_ = up;
66         }
67 private:
68         bool dispatched_;
69         bool update_;
70         dispatch_result_t val_;
71 };
72
73
74 inline
75 bool operator==(DispatchResult const & lhs, DispatchResult const & rhs)
76 {
77         return lhs.dispatched() == rhs.dispatched() && lhs.val() == rhs.val();
78 }
79
80
81 inline
82 bool operator!=(DispatchResult const & lhs, DispatchResult const & rhs)
83 {
84         return !(lhs == rhs);
85 }
86
87 #endif // DISPATCH_RESULT_H