]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.h
5 new lfuns, move all apply code out of ControlDocument and into the core.
[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
16 #include "ButtonPolicies.h"
17
18 #include <boost/scoped_ptr.hpp>
19
20
21 class BCView;
22
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         //@{
35         /** Methods to set and get the GUI view (containing the actual
36          *   button widgets.
37          *  \param ptr is owned by the ButtonController.
38          */
39         void view(BCView * ptr);
40         BCView & view() const;
41         //@}
42
43         //@{
44         /** Methods to set and get the ButtonPolicy.
45          *  \param ptr is owned by the ButtonController.
46          */
47         void bp(ButtonPolicy * ptr);
48         ButtonPolicy & bp() const;
49         //@}
50
51         ///
52         void input(ButtonPolicy::SMInput) const;
53
54         //@{
55         /// Tell the BC that a particular button has been pressed.
56         void ok() const;
57         void apply() const;
58         void cancel() const;
59         void restore() const;
60         //@}
61
62         /// Tell the BC that the dialog is being hidden
63         void hide() const;
64
65         /**Refresh the activation state of the Ok, Apply, Close and
66          * Restore buttons.
67          */
68         void refresh() const;
69
70         /** Refresh the activation state of all the widgets under the control
71          *  of the BC to reflect the read-only status of the underlying buffer.
72          */
73         void refreshReadOnly() const;
74
75         /** Passthrough function -- returns its input value
76          *  Tell the BC about the read-only status of the underlying buffer.
77          */
78         bool readOnly(bool = true) const;
79
80         /** \param validity Tell the BC that the data is, or is not, valid.
81          *  Sets the activation state of the buttons immediately.
82          */
83         void valid(bool = true) const;
84
85 private:
86         boost::scoped_ptr<ButtonPolicy> bp_;
87         boost::scoped_ptr<BCView> view_;
88 };
89
90 #endif // BUTTONCONTROLLER_H