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