]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.h
This file is part of LyX, the document processor.
[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  * \author Angus Leeming 
9  * \author Baruch Even
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #ifndef BUTTONCONTROLLER_H
15 #define BUTTONCONTROLLER_H
16
17
18 #include "ButtonControllerBase.h"
19 #include "gettext.h"
20 #include <list>
21
22 /** A templatised instantiation of the ButtonController requiring the
23  *  gui-frontend widgets.
24  *  The template declarations are in ButtonController.tmpl, which should
25  *  be #included in the gui-frontend BC class, see e.g. xforms/xformsBC.C
26  */
27 template <class Button, class Widget>
28 class GuiBC : public ButtonControllerBase
29 {
30 public:
31         ///
32         GuiBC(string const & cancel, string const & close);
33
34         ///
35         void setOK(Button * obj) { okay_ = obj; }
36         ///
37         void setApply(Button * obj) { apply_ = obj; }
38         ///
39         void setCancel(Button * obj) { cancel_ = obj; }
40         ///
41         void setRestore(Button * obj) { restore_ = obj; }
42         ///
43         void addReadOnly(Widget * obj) { read_only_.push_back(obj); }
44         ///
45         void eraseReadOnly() { read_only_.clear(); }
46
47         /// Refresh the status of the Ok, Apply, Restore, Cancel buttons.
48         void refresh();
49         /// Refresh the status of any widgets in the read_only list
50         void refreshReadOnly();
51
52 private:
53         /// Enable/Disable a widget
54         virtual void setWidgetEnabled(Widget * obj, bool enable) = 0;
55         /// Enable/Disable a button
56         virtual void setButtonEnabled(Button * obj, bool enable) = 0;
57         /// Set the Label on the button
58         virtual void setButtonLabel(Button * obj, string const & label) = 0;
59
60         Button * okay_;
61         Button * apply_;
62         Button * cancel_;
63         Button * restore_;
64
65         typedef std::list<Widget *> Widgets;
66         Widgets read_only_;
67 };
68
69
70 template <class BP, class GUIBC>
71 class ButtonController: public GUIBC
72 {
73 public:
74         ///
75         ButtonController(string const & = _("Cancel"),
76                          string const & = _("Close"));
77         ///
78         ~ButtonController() {}
79         ///
80         virtual ButtonPolicy & bp() { return bp_; }
81
82 protected:
83         ///
84         BP bp_;
85 };
86
87
88 #include "ButtonController.tmpl"
89
90 #endif // BUTTONCONTROLLER_H