]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/ButtonController.h
Complete the removal of the embedding stuff. Maybe. It's hard to be sure we got every...
[lyx.git] / src / frontends / qt4 / 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
17 class QWidget;
18 class QPushButton;
19 class QLineEdit;
20
21 namespace lyx {
22 namespace frontend {
23
24 /** General purpose button controller for up to four buttons.
25     Controls the activation of the OK, Apply and Cancel buttons.
26     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
32 /** \c ButtonController controls the activation of the OK, Apply and
33  *  Cancel buttons.
34  *
35  * It actually supports 4 buttons in all and it's up to the user to decide on
36  * the activation policy and which buttons correspond to which output of the
37  * state machine.
38  */
39
40 class ButtonController
41 {
42 public:
43         ButtonController();
44         ~ButtonController();
45
46         //@{
47         /** Methods to set and get the ButtonPolicy.
48          *  \param ptr is owned by the ButtonController.
49          */
50         void setPolicy(ButtonPolicy::Policy policy);
51         ButtonPolicy const & policy() const;
52         ButtonPolicy & policy();
53         //@}
54
55         ///
56         void input(ButtonPolicy::SMInput);
57
58         //@{
59         /// Tell the BC that a particular button has been pressed.
60         void ok();
61         void apply();
62         void cancel();
63         void restore();
64         //@}
65
66         /// Tell the BC that the dialog is being hidden
67         void hide();
68
69         /**Refresh the activation state of the Ok, Apply, Close and
70          * Restore buttons.
71          */
72         void refresh() const;
73
74         /** Refresh the activation state of all the widgets under the control
75          *  of the BC to reflect the read-only status of the underlying buffer.
76          */
77         void refreshReadOnly() const;
78
79         /** Passthrough function -- returns its input value
80          *  Tell the BC about the read-only status of the underlying buffer.
81          */
82         bool setReadOnly(bool);
83
84         /** \param validity Tell the BC that the data is, or is not, valid.
85          *  Sets the activation state of the buttons immediately.
86          */
87         void setValid(bool);
88
89         //
90         // View
91         //
92
93         //@{
94         /** Store pointers to these widgets.
95          */
96         void setOK(QPushButton * obj);
97         void setApply(QPushButton * obj);
98         void setCancel(QPushButton * obj);
99         void setRestore(QPushButton * obj);
100         //@}
101
102         /** Add a pointer to the list of widgets whose activation
103          *  state is dependent upon the read-only status of the
104          *  underlying buffer.
105          */
106         void addReadOnly(QWidget * obj);
107
108         /** Add a widget to the list of all widgets whose validity should
109          *  be checked explicitly when the buttons are refreshed.
110          */
111         void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
112
113 private:
114         /// noncopyable
115         ButtonController(ButtonController const &);
116         void operator=(ButtonController const &);
117         
118         /// pimpl
119         class Private;
120         Private * d;
121 };
122
123 } // namespace frontend
124 } // namespace lyx
125
126 #endif // BUTTONCONTROLLER_H