]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlButtons.h
include sys/time.h
[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
30 #include <boost/utility.hpp>
31
32 class ViewBase;
33 class ButtonControllerBase;
34
35 /** Abstract base class for Controllers with a ButtonController.
36  */
37 class ControlButtons : boost::noncopyable {
38 public:
39         ///
40         ControlButtons();
41         ///
42         virtual ~ControlButtons() {}
43
44         /** These functions are called by the view when the appropriate buttons
45          *  are pressed.
46          */
47         ///
48         void ApplyButton();
49         ///
50         void OKButton();
51         ///
52         void CancelButton();
53         ///
54         void RestoreButton();
55
56         /// Returns the user-specified iconification policy.
57         bool IconifyWithMain() const;
58
59         ///
60         ButtonControllerBase & bc();
61
62         ///
63         void setView(ViewBase &);
64         ///
65         void setButtonController(ButtonControllerBase &);
66         /** When Applying it's useful to know whether the dialog is about
67             to close or not (no point refreshing the display for example). */
68         bool isClosing() const { return is_closing_; }
69
70 protected:
71         ///
72         ViewBase & view();
73
74         /// Get changed parameters and Dispatch them to the kernel.
75         virtual void apply() = 0;
76         /// Disconnect signals and hide View.
77         virtual void hide() = 0;
78         /// Update dialog before showing it.
79         virtual void update() = 0;
80
81         /** This flag can be set by one of the miriad the controller methods
82             to ensure that the dialog is shut down. */
83         bool emergency_exit_;
84 private:
85         ///
86         bool is_closing_;
87         /// We own neither of these pointers.
88         ButtonControllerBase * bc_ptr_;
89         ///
90         ViewBase * view_ptr_;
91 };
92
93 #endif // CONTROLBUTTONS_H