]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Qt2BC.h
merge GuiBC<.,.> into Qt2BC
[lyx.git] / src / frontends / qt4 / Qt2BC.h
1 // -*- C++ -*-
2 /**
3  * \file Qt2BC.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  * \author Angus Leeming
9  * \author Baruch Even
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef QT2BC_H
15 #define QT2BC_H
16
17 #include "BCView.h"
18 #include "gettext.h"
19
20 class QWidget;
21 class QPushButton;
22
23 namespace lyx {
24 namespace frontend {
25
26 /** General purpose button controller for up to four buttons.
27     Controls the activation of the OK, Apply and Cancel buttons.
28     Actually supports 4 buttons in all and it's up to the user to decide on
29     the activation policy and which buttons correspond to which output of the
30     state machine.
31 */
32
33 class Qt2BC : public BCView
34 {
35 public:
36         ///
37         Qt2BC(ButtonController const & parent);
38
39         //@{
40         /** Store pointers to these widgets.
41          */
42         void setOK(QPushButton * obj) { okay_ = obj; }
43         void setApply(QPushButton * obj) { apply_ = obj; }
44         void setCancel(QPushButton * obj) { cancel_ = obj; }
45         void setRestore(QPushButton * obj) { restore_ = obj; }
46         //@}
47
48         /** Add a pointer to the list of widgets whose activation
49          *  state is dependent upon the read-only status of the
50          *  underlying buffer.
51          */
52         void addReadOnly(QWidget * obj) { read_only_.push_back(obj); }
53
54         /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
55         virtual void refresh() const;
56         /// Refresh the status of any widgets in the read_only list
57         virtual void refreshReadOnly() const;
58
59 private:
60         /// Updates the widget sensitivity (enabled/disabled)
61         void setWidgetEnabled(QWidget *, bool enabled) const;
62
63         QPushButton * okay_;
64         QPushButton * apply_;
65         QPushButton * cancel_;
66         QPushButton * restore_;
67
68         typedef std::list<QWidget *> Widgets;
69         Widgets read_only_;
70 };
71
72 } // namespace frontend
73 } // namespace lyx
74
75 #endif // QT2BC_H