]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.h
fix crash due to invalidated iterator
[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 "ButtonPolicies.h"
16 #include <boost/scoped_ptr.hpp>
17
18 namespace lyx {
19 namespace frontend {
20
21 class BCView;
22
23 /** \c ButtonController controls the activation of the OK, Apply and
24  *  Cancel buttons.
25  *
26  * It actually supports 4 buttons in all and it's up to the user to decide on
27  * the activation policy and which buttons correspond to which output of the
28  * state machine.
29  */
30
31 class ButtonController : boost::noncopyable {
32 public:
33         //@{
34         /** Methods to set and get the GUI view (containing the actual
35          *   button widgets.
36          *  \param ptr is owned by the ButtonController.
37          */
38         void view(BCView * ptr);
39         BCView & view() const;
40         //@}
41
42         //@{
43         /** Methods to set and get the ButtonPolicy.
44          *  \param ptr is owned by the ButtonController.
45          */
46         void bp(ButtonPolicy * ptr);
47         ButtonPolicy & bp() const;
48         //@}
49
50         ///
51         void input(ButtonPolicy::SMInput) const;
52
53         //@{
54         /// Tell the BC that a particular button has been pressed.
55         void ok() const;
56         void apply() const;
57         void cancel() const;
58         void restore() const;
59         //@}
60
61         /// Tell the BC that the dialog is being hidden
62         void hide() const;
63
64         /**Refresh the activation state of the Ok, Apply, Close and
65          * Restore buttons.
66          */
67         void refresh() const;
68
69         /** Refresh the activation state of all the widgets under the control
70          *  of the BC to reflect the read-only status of the underlying buffer.
71          */
72         void refreshReadOnly() const;
73
74         /** Passthrough function -- returns its input value
75          *  Tell the BC about the read-only status of the underlying buffer.
76          */
77         bool readOnly(bool = true) const;
78
79         /** \param validity Tell the BC that the data is, or is not, valid.
80          *  Sets the activation state of the buttons immediately.
81          */
82         void valid(bool = true) const;
83
84 private:
85         boost::scoped_ptr<ButtonPolicy> bp_;
86         boost::scoped_ptr<BCView> view_;
87 };
88
89 } // namespace frontend
90 } // namespace lyx
91
92 #endif // BUTTONCONTROLLER_H