]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlButtons.h
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ControlButtons.h
1 // -*- C++ -*-
2 /**
3  * \file ControlButtons.h
4  * Read the file COPYING
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  *
10  * ControlButtons serves only to control the activation of the Ok, Apply, Cancel
11  * and Restore buttons on the View dialog.
12  *
13  * More generally, the class is part of a hierarchy of controller classes
14  * that together connect the GUI-dependent dialog to any appropriate
15  * signals and dispatches any changes to the kernel.
16  *
17  * These controllers have no knowledge of the actual instantiation of the
18  * GUI-dependent View and ButtonController, which should therefore
19  * be created elsewhere.
20  *
21  * Once created, the Controller will take care of their initialisation,
22  * management and, ultimately, destruction.
23  */
24
25 #ifndef CONTROLBUTTONS_H
26 #define CONTROLBUTTONS_H
27
28 #ifdef __GNUG__
29 #pragma interface
30 #endif
31
32 #include <boost/utility.hpp>
33
34 class ViewBase;
35 class ButtonControllerBase;
36
37 /** Abstract base class for Controllers with a ButtonController.
38  */
39 class ControlButtons : boost::noncopyable
40 {
41 public:
42         ///
43         ControlButtons();
44         ///
45         virtual ~ControlButtons() {}
46
47         /** These functions are called by the view when the appropriate buttons
48          *  are pressed.
49          */
50         ///
51         void ApplyButton();
52         ///
53         void OKButton();
54         ///
55         void CancelButton();
56         ///
57         void RestoreButton();
58
59         /// Returns the user-specified iconification policy.
60         bool IconifyWithMain() const;
61
62         ///
63         ButtonControllerBase & bc();
64
65         ///
66         void setView(ViewBase &);
67         ///
68         void setButtonController(ButtonControllerBase &);
69
70 protected:
71         ///
72         ViewBase & view();
73
74         /** When Applying it's useful to know whether the dialog is about
75             to close or not (no point refreshing the display for example). */
76         bool isClosing() const { return is_closing_; }
77
78         /// Get changed parameters and Dispatch them to the kernel.
79         virtual void apply() = 0;
80         /// Disconnect signals and hide View.
81         virtual void hide() = 0;
82         /// Update dialog before showing it.
83         virtual void update() = 0;
84
85         /** This flag can be set by one of the miriad the controller methods
86             to ensure that the dialog is shut down. */
87         bool emergency_exit_;
88
89 private:
90         ///
91         bool is_closing_;
92         /// We own neither of these pointers.
93         ButtonControllerBase * bc_ptr_;
94         ///
95         ViewBase * view_ptr_;
96 };
97
98 #endif // CONTROLBUTTONS_H