]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.h
Move the external dialog to the new scheme.
[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 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 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 public:
71         ///
72         ButtonController(string const & = _("Cancel"),
73                          string const & = _("Close"));
74         ///
75         ~ButtonController() {}
76         ///
77         virtual ButtonPolicy & bp() { return bp_; }
78 protected:
79         ///
80         BP bp_;
81 };
82
83
84 #include "ButtonController.tmpl"
85
86 #endif // BUTTONCONTROLLER_H