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