]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ButtonControllerBase.h
ws fixes, formatting and some other small changes
[lyx.git] / src / frontends / controllers / ButtonControllerBase.h
1 // -*- C++ -*-
2 /**
3  * \file ButtonControllerBase.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  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef BUTTONCONTROLLERBASE_H
13 #define BUTTONCONTROLLERBASE_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "ButtonPolicies.h"
20 #include "LString.h"
21
22 /** Abstract base class for a ButtonController
23
24  * Controls the activation of the OK, Apply and Cancel buttons.
25  * Actually supports 4 buttons in all and it's up to the user to decide on
26  * the activation policy and which buttons correspond to which output of the
27  * state machine.
28  * Author: Allan Rae <rae@lyx.org>.
29  * This abstract base class stripped of xforms-specific code by
30  * Angus Leeming <leeming@lyx.org>
31  */
32 class ButtonControllerBase : boost::noncopyable {
33 public:
34         /** Constructor.
35             The cancel/close label entries are _not_ managed within the class
36             thereby allowing you to reassign at will and to use static labels.
37             It also means if you really don't want to have the Cancel button
38             label be different when there is nothing changed in the dialog then
39             you can just assign "Cancel" to both labels.  Or even reuse this
40             class for something completely different.
41          */
42         ButtonControllerBase(string const & cancel, string const & close);
43         ///
44         virtual ~ButtonControllerBase() {}
45         ///
46         virtual ButtonPolicy & bp() = 0;
47         ///
48         virtual void input(ButtonPolicy::SMInput);
49         ///
50         void ok();
51         ///
52         void apply();
53         ///
54         void cancel();
55         ///
56         void restore();
57         ///
58         void hide();
59         ///
60         virtual void refresh() = 0;
61         ///
62         virtual void refreshReadOnly() = 0;
63
64         /// Passthrough function -- returns its input value
65         bool readOnly(bool = true);
66         ///
67         void readWrite();
68         ///
69         void valid(bool = true);
70         ///
71         void invalid();
72 protected:
73         ///
74         string cancel_label_;
75         ///
76         string close_label_;
77 };
78
79 #endif // BUTTONCONTROLLERBASE_H