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