]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.h
Compile fix.
[lyx.git] / src / frontends / controllers / ButtonController.h
1 // -*- C++ -*-
2 /**
3  * \file ButtonController.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Allan Rae
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef BUTTONCONTROLLER_H
13 #define BUTTONCONTROLLER_H
14
15 #include "ButtonPolicy.h"
16 #include "BCView.h"
17
18 #include <boost/scoped_ptr.hpp>
19 #include <boost/noncopyable.hpp>
20
21 namespace lyx {
22 namespace frontend {
23
24 /** \c ButtonController controls the activation of the OK, Apply and
25  *  Cancel buttons.
26  *
27  * It actually supports 4 buttons in all and it's up to the user to decide on
28  * the activation policy and which buttons correspond to which output of the
29  * state machine.
30  */
31
32 class ButtonController : boost::noncopyable {
33 public:
34         ButtonController() : policy_(ButtonPolicy::IgnorantPolicy) {}
35         //@{
36         /** Methods to set and get the GUI view (containing the actual
37          *   button widgets.
38          *  \param ptr is owned by the ButtonController.
39          */
40         void view(BCView * ptr);
41         BCView & view() const;
42         //@}
43
44         //@{
45         /** Methods to set and get the ButtonPolicy.
46          *  \param ptr is owned by the ButtonController.
47          */
48         void setPolicy(ButtonPolicy::Policy policy);
49         ButtonPolicy const & policy() const { return policy_; }
50         ButtonPolicy & policy() { return policy_; }
51         //@}
52
53         ///
54         void input(ButtonPolicy::SMInput);
55
56         //@{
57         /// Tell the BC that a particular button has been pressed.
58         void ok();
59         void apply();
60         void cancel();
61         void restore();
62         //@}
63
64         /// Tell the BC that the dialog is being hidden
65         void hide();
66
67         /**Refresh the activation state of the Ok, Apply, Close and
68          * Restore buttons.
69          */
70         void refresh() const;
71
72         /** Refresh the activation state of all the widgets under the control
73          *  of the BC to reflect the read-only status of the underlying buffer.
74          */
75         void refreshReadOnly() const;
76
77         /** Passthrough function -- returns its input value
78          *  Tell the BC about the read-only status of the underlying buffer.
79          */
80         bool readOnly(bool = true);
81
82         /** \param validity Tell the BC that the data is, or is not, valid.
83          *  Sets the activation state of the buttons immediately.
84          */
85         void valid(bool = true);
86
87 private:
88         ButtonPolicy policy_;
89         boost::scoped_ptr<BCView> view_;
90 };
91
92 } // namespace frontend
93 } // namespace lyx
94
95 #endif // BUTTONCONTROLLER_H