]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ViewBase.h
Really dull and boring header shit
[lyx.git] / src / frontends / controllers / ViewBase.h
1 // -*- C++ -*-
2 /**
3  * \file ViewBase.h
4  * See the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifndef VIEWBASE_H
12 #define VIEWBASE_H
13
14 #include "support/LAssert.h"
15
16 #include <boost/utility.hpp>
17
18 class ControlButtons;
19
20
21 class ViewBase : boost::noncopyable {
22 public:
23         ///
24         ViewBase() : controller_ptr_(0) {}
25         ///
26         virtual ~ViewBase() {}
27
28         /// Apply changes to LyX data from dialog.
29         virtual void apply() = 0;
30         /// build the dialog
31         virtual void build() = 0;
32         /// Hide the dialog.
33         virtual void hide() = 0;
34         /// Redraw the dialog (e.g. if the colors have been remapped).
35         virtual void redraw() {}
36         /// Create the dialog if necessary, update it and display it.
37         virtual void show() = 0;
38         /// Update dialog before/whilst showing it.
39         virtual void update() = 0;
40
41         /** Defaults to nothing. Can be used by the controller, however, to
42          *  indicate to the view that something has changed and that the
43          *  dialog therefore needs updating.
44          */
45         virtual void partialUpdate(int) {}
46
47         /** This should be set by the GUI class that owns both the controller
48          *  and the view
49          */
50         void setController(ControlButtons & c) { controller_ptr_ = &c; }
51         
52         ///
53         ControlButtons & getController()
54         {
55                 lyx::Assert(controller_ptr_);
56                 return *controller_ptr_;
57         }
58         ///
59         ControlButtons const & getController() const
60         {
61                 lyx::Assert(controller_ptr_);
62                 return *controller_ptr_;
63         }
64
65 protected:
66         /// We don't own this.
67         ControlButtons * controller_ptr_;
68 };
69
70
71 #endif // VIEWBASE_H