GuiPrintNomencl.{cpp,h}:
[lyx.git] / src / frontends / qt4 / ButtonController.h
blobcec52bf5666f45f03d49d22770d56f7ce4a6984e
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.
7 * \author Allan Rae
9 * Full author contact details are available in file CREDITS.
12 #ifndef BUTTONCONTROLLER_H
13 #define BUTTONCONTROLLER_H
15 #include "ButtonPolicy.h"
17 class QWidget;
18 class QPushButton;
19 class QLineEdit;
20 class QCheckBox;
22 namespace lyx {
23 namespace frontend {
25 /** General purpose button controller for up to four buttons.
26 Controls the activation of the OK, Apply and Cancel buttons.
27 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.
33 /** \c ButtonController controls the activation of the OK, Apply and
34 * Cancel buttons.
36 * It actually supports 4 buttons in all and it's up to the user to decide on
37 * the activation policy and which buttons correspond to which output of the
38 * state machine.
41 class ButtonController
43 public:
44 ButtonController();
45 ~ButtonController();
47 //@{
48 /** Methods to set and get the ButtonPolicy.
49 * \param ptr is owned by the ButtonController.
51 void setPolicy(ButtonPolicy::Policy policy);
52 ButtonPolicy const & policy() const;
53 ButtonPolicy & policy();
54 //@}
56 ///
57 void input(ButtonPolicy::SMInput);
59 //@{
60 /// Tell the BC that a particular button has been pressed.
61 void ok();
62 void apply();
63 void cancel();
64 void restore();
65 void autoApply();
66 //@}
68 /// Tell the BC that the dialog is being hidden
69 void hide();
71 /**Refresh the activation state of the Ok, Apply, Close and
72 * Restore buttons.
74 void refresh() const;
76 /** Refresh the activation state of all the widgets under the control
77 * of the BC to reflect the read-only status of the underlying buffer.
79 void refreshReadOnly() const;
81 /** Passthrough function -- returns its input value
82 * Tell the BC about the read-only status of the underlying buffer.
84 bool setReadOnly(bool);
86 /** \param validity Tell the BC that the data is, or is not, valid.
87 * Sets the activation state of the buttons immediately.
89 void setValid(bool);
92 // View
95 //@{
96 /** Store pointers to these widgets.
98 void setOK(QPushButton * obj);
99 void setApply(QPushButton * obj);
100 void setCancel(QPushButton * obj);
101 void setRestore(QPushButton * obj);
102 void setAutoApply(QCheckBox * obj);
103 //@}
105 /** Add a pointer to the list of widgets whose activation
106 * state is dependent upon the read-only status of the
107 * underlying buffer.
109 void addReadOnly(QWidget * obj);
111 /** Add a widget to the list of all widgets whose validity should
112 * be checked explicitly when the buttons are refreshed.
114 void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
116 private:
117 /// noncopyable
118 ButtonController(ButtonController const &);
119 void operator=(ButtonController const &);
121 /// pimpl
122 class Private;
123 Private * d;
126 } // namespace frontend
127 } // namespace lyx
129 #endif // BUTTONCONTROLLER_H