]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Qt2BC.h
Another compile fix.
[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 #include <list>
21
22 class QWidget;
23 class QPushButton;
24 class QLineEdit;
25
26 namespace lyx {
27 namespace frontend {
28
29
30 void addCheckedLineEdit(BCView & bcview,
31         QLineEdit * input, QWidget * label = 0);
32
33 class CheckedLineEdit
34 {
35 public:
36         CheckedLineEdit(QLineEdit * input, QWidget * label = 0);
37         bool check() const;
38
39 private:
40         // non-owned
41         QLineEdit * input_;
42         QWidget * label_;
43 };
44
45 /** General purpose button controller for up to four buttons.
46     Controls the activation of the OK, Apply and Cancel buttons.
47     Actually supports 4 buttons in all and it's up to the user to decide on
48     the activation policy and which buttons correspond to which output of the
49     state machine.
50 */
51
52 class Qt2BC : public BCView
53 {
54 public:
55         ///
56         Qt2BC(ButtonController & parent);
57
58         //@{
59         /** Store pointers to these widgets.
60          */
61         void setOK(QPushButton * obj) { okay_ = obj; }
62         void setApply(QPushButton * obj) { apply_ = obj; }
63         void setCancel(QPushButton * obj) { cancel_ = obj; }
64         void setRestore(QPushButton * obj) { restore_ = obj; }
65         //@}
66
67         /** Add a pointer to the list of widgets whose activation
68          *  state is dependent upon the read-only status of the
69          *  underlying buffer.
70          */
71         void addReadOnly(QWidget * obj) { read_only_.push_back(obj); }
72
73         /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
74         virtual void refresh() const;
75         /// Refresh the status of any widgets in the read_only list
76         virtual void refreshReadOnly() const;
77
78         /** Add a widget to the list of all widgets whose validity should
79          *  be checked explicitly when the buttons are refreshed.
80          */
81         void addCheckedLineEdit(QLineEdit * input, QWidget * label = 0);
82
83 protected:
84         /// \return true if all CheckedWidgets are in a valid state.
85         bool checkWidgets() const;
86
87 private:
88         typedef std::list<CheckedLineEdit> CheckedWidgetList;
89         CheckedWidgetList checked_widgets;
90
91 private:
92         /// Updates the widget sensitivity (enabled/disabled)
93         void setWidgetEnabled(QWidget *, bool enabled) const;
94
95         QPushButton * okay_;
96         QPushButton * apply_;
97         QPushButton * cancel_;
98         QPushButton * restore_;
99
100         typedef std::list<QWidget *> Widgets;
101         Widgets read_only_;
102 };
103
104 } // namespace frontend
105 } // namespace lyx
106
107 #endif // QT2BC_H