]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlBase.h
Merging BRANCH_MVC back into HEAD.
[lyx.git] / src / frontends / controllers / ControlBase.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  *
11  * \file ControlBase.h
12  * \author Angus Leeming <a.leeming@ic.ac.uk>
13  *
14  * The Controller connects the GUI-dependent popup to any appropriate
15  * signals and dispatches any changes to the kernel.
16  * It has no knowledge of the actual instantiation of the
17  * GUI-dependent View and ButtonController, which should therefore
18  * be created elsewhere.
19  * Once created, the Controller will take care of their initialisation,
20  * management and, ultimately, destruction.
21  */
22
23 #ifndef CONTROLBASE_H
24 #define CONTROLBASE_H
25
26 #ifdef __GNUG__
27 #pragma interface
28 #endif
29
30 #include "DialogBase.h" // This can go eventually
31
32 class ButtonControllerBase;
33 class Dialogs;
34 class LyXView;
35 class ViewBase;
36
37 /** Abstract base class for Controllers with a ButtonController.
38  */
39 class ControlBase : public DialogBase
40 {
41 public: // methods
42         ///
43         ControlBase(LyXView & lv) : lv_(lv) {}
44         ///
45         virtual ~ControlBase() {};
46
47         /// These functions are called when the controlling buttons are pressed.
48         ///
49         void ApplyButton();
50         ///
51         void OKButton();
52         ///
53         void CancelButton();
54         ///
55         void RestoreButton();
56
57         /// The View may need to know if the buffer is read-only.
58         bool isReadonly() const;
59
60         /** Allow the view to access the ButtonController. This method must be
61             instantiated in a daughter class that creates the actual instance
62             of the ButtonController. */
63         virtual ButtonControllerBase & bc() = 0;
64
65 protected:
66         /// Get changed parameters and Dispatch them to the kernel.
67         virtual void apply() = 0;
68         /// Disconnect signals and hide View.
69         virtual void hide() = 0;
70         /// Update dialog before showing it.
71         virtual void update() = 0;
72
73         /** Allow the Controller to access the View. This method must be
74             instantiated in a daughter class that creates the actual instance
75             of the View. */
76         virtual ViewBase & view() = 0;
77         
78         /// Get at the kernel Dispatch methods we need to apply() parameters.
79         LyXView & lv_;
80 };
81
82
83 #endif // CONTROLBASE_H