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