]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonController.h
controller-view split of FormLog and FormVCLog.
[lyx.git] / src / frontends / controllers / ButtonController.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  *
11  * \file ButtonController.h
12  * \author Allan Rae
13  */
14
15 #ifndef BUTTONCONTROLLER_H
16 #define BUTTONCONTROLLER_H
17
18 #ifdef __GNUG__
19 #pragma interface
20 #endif
21
22 #include "ButtonPolicies.h"
23 #include "LString.h"
24 #include "gettext.h"
25
26 /** Abstract base class for a ButtonController
27
28  * Controls the activation of the OK, Apply and Cancel buttons.
29  * Actually supports 4 buttons in all and it's up to the user to decide on
30  * the activation policy and which buttons correspond to which output of the
31  * state machine.
32  * Author: Allan Rae <rae@lyx.org>.
33  * This abstract base class stripped of xforms-specific code by
34  * Angus Leeming <a.leeming@ic.ac.uk>
35  */
36 class ButtonControllerBase : public boost::noncopyable
37 {
38 public:
39         /** Constructor.
40             The cancel/close label entries are _not_ managed within the class
41             thereby allowing you to reassign at will and to use static labels.
42             It also means if you really don't want to have the Cancel button
43             label be different when there is nothing changed in the dialog then
44             you can just assign "Cancel" to both labels.  Or even reuse this
45             class for something completely different.
46          */
47         ButtonControllerBase(string const & cancel, string const & close);
48         ///
49         virtual ~ButtonControllerBase() {}
50         ///
51         virtual void refresh() = 0;
52         ///
53         virtual ButtonPolicy & bp() = 0;
54         ///
55         virtual void input(ButtonPolicy::SMInput);
56         ///
57         void ok();
58         ///
59         void apply();
60         ///
61         void cancel();
62         ///
63         void undoAll();
64         ///
65         void hide();
66         /// Passthrough function -- returns its input value
67         bool readOnly(bool = true);
68         ///
69         void readWrite();
70         ///
71         void valid(bool = true);
72         ///
73         void invalid();
74
75 protected:
76         ///
77         string cancel_label;
78         ///
79         string close_label;     
80 };
81
82
83 template <class BP, class GUIBC>
84 class ButtonController: public GUIBC
85 {
86 public:
87         ///
88         ButtonController(string const & = _("Cancel"),
89                          string const & = _("Close"));
90         ///
91         virtual ButtonPolicy & bp() { return bp_; }
92
93 protected:
94         ///
95         BP bp_;
96 };
97
98
99 template <class BP, class GUIBC>
100 ButtonController<BP, GUIBC>::ButtonController(string const & cancel,
101                                               string const & close)
102         : GUIBC(cancel, close)
103 {}
104
105 #endif // BUTTONCONTROLLER_H