]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlButtons.h
prefs/tabular MVC work
[lyx.git] / src / frontends / controllers / ControlButtons.h
1 // -*- C++ -*-
2 /**
3  * \file ControlButtons.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS
10  *
11  * ControlButtons serves only to control the activation of the Ok, Apply, Cancel
12  * and Restore buttons on the View dialog.
13  *
14  * More generally, the class is part of a hierarchy of controller classes
15  * that together connect the GUI-dependent dialog to any appropriate
16  * signals and dispatches any changes to the kernel.
17  *
18  * These controllers have no knowledge of the actual instantiation of the
19  * GUI-dependent View and ButtonController, which should therefore
20  * be created elsewhere.
21  *
22  * Once created, the Controller will take care of their initialisation,
23  * management and, ultimately, destruction.
24  */
25
26 #ifndef CONTROLBUTTONS_H
27 #define CONTROLBUTTONS_H
28
29 #ifdef __GNUG__
30 #pragma interface
31 #endif
32
33 #include <boost/utility.hpp>
34
35 class ViewBase;
36 class ButtonControllerBase;
37
38 /** Abstract base class for Controllers with a ButtonController.
39  */
40 class ControlButtons : boost::noncopyable {
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         /// virtual for ControlPrefs
53         virtual 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 protected:
70         ///
71         ViewBase & view();
72
73         /** When Applying it's useful to know whether the dialog is about
74             to close or not (no point refreshing the display for example). */
75         bool isClosing() const { return is_closing_; }
76
77         /// Get changed parameters and Dispatch them to the kernel.
78         virtual void apply() = 0;
79         /// Disconnect signals and hide View.
80         virtual void hide() = 0;
81         /// Update dialog before showing it.
82         virtual void update() = 0;
83
84         /** This flag can be set by one of the miriad the controller methods
85             to ensure that the dialog is shut down. */
86         bool emergency_exit_;
87 private:
88         ///
89         bool is_closing_;
90         /// We own neither of these pointers.
91         ButtonControllerBase * bc_ptr_;
92         ///
93         ViewBase * view_ptr_;
94 };
95
96 #endif // CONTROLBUTTONS_H